Peter Beutner : msvcrt: Fix _makepath().

Alexandre Julliard julliard at wine.codeweavers.com
Tue Aug 7 08:26:23 CDT 2007


Module: wine
Branch: master
Commit: 1a688cd058e38dde7b5f1978fe564facd48f22a0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1a688cd058e38dde7b5f1978fe564facd48f22a0

Author: Peter Beutner <p.beutner at gmx.net>
Date:   Mon Aug  6 15:38:49 2007 +0200

msvcrt: Fix _makepath().

---

 dlls/msvcrt/dir.c       |   26 ++++++++++++++------------
 dlls/msvcrt/tests/dir.c |    3 +--
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c
index 21a3115..8340d28 100644
--- a/dlls/msvcrt/dir.c
+++ b/dlls/msvcrt/dir.c
@@ -853,7 +853,7 @@ VOID CDECL _makepath(char * path, const char * drive,
                      const char *directory, const char * filename,
                      const char * extension)
 {
-    char ch;
+    char *p = path;
 
     TRACE("(%s %s %s %s)\n", debugstr_a(drive), debugstr_a(directory),
           debugstr_a(filename), debugstr_a(extension) );
@@ -861,28 +861,30 @@ VOID CDECL _makepath(char * path, const char * drive,
     if ( !path )
         return;
 
-    path[0] = '\0';
     if (drive && drive[0])
     {
-        path[0] = drive[0];
-        path[1] = ':';
-        path[2] = 0;
+        *p++ = drive[0];
+        *p++ = ':';
+        *p = 0;
     }
     if (directory && directory[0])
     {
-        strcat(path, directory);
-        ch = path[strlen(path)-1];
-        if (ch != '/' && ch != '\\')
-            strcat(path,"\\");
+        strcpy(p, directory);
+        p += strlen(directory) - 1;
+        if (*p != '/' && *p != '\\') {
+            strcat(p, "\\");
+            p++;
+        }
+        p++;
     }
     if (filename && filename[0])
     {
-        strcat(path, filename);
+        strcpy(p, filename);
         if (extension && extension[0])
         {
             if ( extension[0] != '.' )
-                strcat(path,".");
-            strcat(path,extension);
+                strcat(p,".");
+            strcat(p,extension);
         }
     }
     TRACE("returning %s\n",path);
diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c
index f3c4d08..6929a76 100644
--- a/dlls/msvcrt/tests/dir.c
+++ b/dlls/msvcrt/tests/dir.c
@@ -43,8 +43,7 @@ static void test_makepath(void)
     /* this works with native and e.g. Freelancer depends on it */
     strcpy(buffer, "foo");
     _makepath(buffer, NULL, buffer, "dummy.txt", NULL);
-    todo_wine { ok( strcmp(buffer, "foo\\dummy.txt") == 0,
-                    "unexpected result: %s\n", buffer); }
+    ok( strcmp(buffer, "foo\\dummy.txt") == 0, "unexpected result: %s\n", buffer);
 }
 
 static void test_fullpath(void)




More information about the wine-cvs mailing list