Author: gschneider Date: Sat Dec 13 15:06:47 2008 New Revision: 38050
URL: http://svn.reactos.org/svn/reactos?rev=38050&view=rev Log: - Update _makepath and _wmakepath to allow in place operation and separated extension processing, based on wine code - Fixes all 14 msvcrt dir winetests
Modified: trunk/reactos/lib/sdk/crt/stdlib/makepath.c trunk/reactos/lib/sdk/crt/stdlib/wmakpath.c
Modified: trunk/reactos/lib/sdk/crt/stdlib/makepath.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdlib/makepath... ============================================================================== --- trunk/reactos/lib/sdk/crt/stdlib/makepath.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/stdlib/makepath.c [iso-8859-1] Sat Dec 13 15:06:47 2008 @@ -1,3 +1,16 @@ +/* + * PROJECT: ReactOS CRT library + * LICENSE: See COPYING in the top level directory + * FILE: lib/sdk/crt/stdlib/makepath.c + * PURPOSE: Creates a path + * PROGRAMMERS: Wine team + * Copyright 1996,1998 Marcus Meissner + * Copyright 1996 Jukka Iivonen + * Copyright 1997,2000 Uwe Bonnes + * Copyright 2000 Jon Griffiths + * + */ + /* $Id$ */ #include <precomp.h> @@ -9,29 +22,36 @@ */ void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext) { - int dir_len; + char *p = path;
- if ((drive != NULL) && (*drive)) { - path[0] = *drive; - path[1] = ':'; - path[2] = 0; - } else { - (*path)=0; + if ( !path ) + return; + + if (drive && drive[0]) + { + *p++ = drive[0]; + *p++ = ':'; } - - if (dir != NULL) { - strcat(path, dir); - dir_len = strlen(dir); - if (dir_len && *(dir + dir_len - 1) != '\') - strcat(path, "\"); + if (dir && dir[0]) + { + unsigned int len = strlen(dir); + memmove(p, dir, len); + p += len; + if (p[-1] != '/' && p[-1] != '\') + *p++ = '\'; } - - if (fname != NULL) { - strcat(path, fname); - if (ext != NULL && *ext != 0) { - if (*ext != '.') - strcat(path, "."); - strcat(path, ext); - } + if (fname && fname[0]) + { + unsigned int len = strlen(fname); + memmove(p, fname, len); + p += len; } + if (ext && ext[0]) + { + if (ext[0] != '.') + *p++ = '.'; + strcpy(p, ext); + } + else + *p = '\0'; }
Modified: trunk/reactos/lib/sdk/crt/stdlib/wmakpath.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdlib/wmakpath... ============================================================================== --- trunk/reactos/lib/sdk/crt/stdlib/wmakpath.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/stdlib/wmakpath.c [iso-8859-1] Sat Dec 13 15:06:47 2008 @@ -1,11 +1,14 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: gdalsnes - * UPDATE HISTORY: - * 25/11/05: Added license header + * PROJECT: ReactOS CRT library + * LICENSE: See COPYING in the top level directory + * FILE: lib/sdk/crt/stdlib/wmakpath.c + * PURPOSE: Creates a unicode path + * PROGRAMMERS: Wine team + * Copyright 1996,1998 Marcus Meissner + * Copyright 1996 Jukka Iivonen + * Copyright 1997,2000 Uwe Bonnes + * Copyright 2000 Jon Griffiths + * */
/* $Id$ @@ -17,29 +20,36 @@ */ void _wmakepath(wchar_t* path, const wchar_t* drive, const wchar_t* dir, const wchar_t* fname, const wchar_t* ext) { - int dir_len; + wchar_t *p = path;
- if ((drive != NULL) && (*drive)) { - path[0] = *drive; - path[1] = L':'; - path[2] = 0; - } else { - (*path) = 0; + if ( !path ) + return; + + if (drive && drive[0]) + { + *p++ = drive[0]; + *p++ = ':'; } - - if (dir != NULL) { - wcscat(path, dir); - dir_len = wcslen(dir); - if (dir_len && *(dir + dir_len - 1) != L'\') - wcscat(path, L"\"); + if (dir && dir[0]) + { + unsigned int len = strlenW(dir); + memmove(p, dir, len * sizeof(wchar_t)); + p += len; + if (p[-1] != '/' && p[-1] != '\') + *p++ = '\'; } - - if (fname != NULL) { - wcscat(path, fname); - if (ext != NULL && *ext != 0) { - if (*ext != L'.') - wcscat(path, L"."); - wcscat(path, ext); - } + if (fname && fname[0]) + { + unsigned int len = strlenW(fname); + memmove(p, fname, len * sizeof(wchar_t)); + p += len; } + if (ext && ext[0]) + { + if (ext[0] != '.') + *p++ = '.'; + strcpyW(p, ext); + } + else + *p = '\0'; }