msvcrt: Fix _makepath().

This commit is contained in:
Peter Beutner 2007-08-06 15:38:49 +02:00 committed by Alexandre Julliard
parent 2b3c19fe55
commit 1a688cd058
2 changed files with 15 additions and 14 deletions

View File

@ -853,7 +853,7 @@ VOID CDECL _makepath(char * path, const char * drive,
const char *directory, const char * filename, const char *directory, const char * filename,
const char * extension) const char * extension)
{ {
char ch; char *p = path;
TRACE("(%s %s %s %s)\n", debugstr_a(drive), debugstr_a(directory), TRACE("(%s %s %s %s)\n", debugstr_a(drive), debugstr_a(directory),
debugstr_a(filename), debugstr_a(extension) ); debugstr_a(filename), debugstr_a(extension) );
@ -861,28 +861,30 @@ VOID CDECL _makepath(char * path, const char * drive,
if ( !path ) if ( !path )
return; return;
path[0] = '\0';
if (drive && drive[0]) if (drive && drive[0])
{ {
path[0] = drive[0]; *p++ = drive[0];
path[1] = ':'; *p++ = ':';
path[2] = 0; *p = 0;
} }
if (directory && directory[0]) if (directory && directory[0])
{ {
strcat(path, directory); strcpy(p, directory);
ch = path[strlen(path)-1]; p += strlen(directory) - 1;
if (ch != '/' && ch != '\\') if (*p != '/' && *p != '\\') {
strcat(path,"\\"); strcat(p, "\\");
p++;
}
p++;
} }
if (filename && filename[0]) if (filename && filename[0])
{ {
strcat(path, filename); strcpy(p, filename);
if (extension && extension[0]) if (extension && extension[0])
{ {
if ( extension[0] != '.' ) if ( extension[0] != '.' )
strcat(path,"."); strcat(p,".");
strcat(path,extension); strcat(p,extension);
} }
} }
TRACE("returning %s\n",path); TRACE("returning %s\n",path);

View File

@ -43,8 +43,7 @@ static void test_makepath(void)
/* this works with native and e.g. Freelancer depends on it */ /* this works with native and e.g. Freelancer depends on it */
strcpy(buffer, "foo"); strcpy(buffer, "foo");
_makepath(buffer, NULL, buffer, "dummy.txt", NULL); _makepath(buffer, NULL, buffer, "dummy.txt", NULL);
todo_wine { ok( strcmp(buffer, "foo\\dummy.txt") == 0, ok( strcmp(buffer, "foo\\dummy.txt") == 0, "unexpected result: %s\n", buffer);
"unexpected result: %s\n", buffer); }
} }
static void test_fullpath(void) static void test_fullpath(void)