Commit 58dd97ef authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

msvcrt: Implement _wmakepath_s.

parent 9628a0d3
...@@ -1310,8 +1310,8 @@ ...@@ -1310,8 +1310,8 @@
@ stub _wgetdcwd_nolock @ stub _wgetdcwd_nolock
@ cdecl _wgetenv(wstr) msvcrt._wgetenv @ cdecl _wgetenv(wstr) msvcrt._wgetenv
@ stub _wgetenv_s @ stub _wgetenv_s
@ cdecl _wmakepath(wstr wstr wstr wstr wstr) msvcrt._wmakepath @ cdecl _wmakepath(ptr wstr wstr wstr wstr) msvcrt._wmakepath
@ stub _wmakepath_s @ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr) msvcrt._wmakepath_s
@ cdecl _wmkdir(wstr) msvcrt._wmkdir @ cdecl _wmkdir(wstr) msvcrt._wmkdir
@ cdecl _wmktemp(wstr) msvcrt._wmktemp @ cdecl _wmktemp(wstr) msvcrt._wmktemp
@ stub _wmktemp_s @ stub _wmktemp_s
......
...@@ -1159,8 +1159,8 @@ ...@@ -1159,8 +1159,8 @@
@ extern _winmajor msvcrt._winmajor @ extern _winmajor msvcrt._winmajor
@ extern _winminor msvcrt._winminor @ extern _winminor msvcrt._winminor
@ extern _winver msvcrt._winver @ extern _winver msvcrt._winver
@ cdecl _wmakepath(wstr wstr wstr wstr wstr) msvcrt._wmakepath @ cdecl _wmakepath(ptr wstr wstr wstr wstr) msvcrt._wmakepath
@ stub _wmakepath_s @ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr) msvcrt._wmakepath_s
@ cdecl _wmkdir(wstr) msvcrt._wmkdir @ cdecl _wmkdir(wstr) msvcrt._wmkdir
@ cdecl _wmktemp(wstr) msvcrt._wmktemp @ cdecl _wmktemp(wstr) msvcrt._wmktemp
@ stub _wmktemp_s @ stub _wmktemp_s
......
...@@ -1143,8 +1143,8 @@ ...@@ -1143,8 +1143,8 @@
@ stub _wgetdcwd_nolock @ stub _wgetdcwd_nolock
@ cdecl _wgetenv(wstr) msvcrt._wgetenv @ cdecl _wgetenv(wstr) msvcrt._wgetenv
@ stub _wgetenv_s @ stub _wgetenv_s
@ cdecl _wmakepath(wstr wstr wstr wstr wstr) msvcrt._wmakepath @ cdecl _wmakepath(ptr wstr wstr wstr wstr) msvcrt._wmakepath
@ stub _wmakepath_s @ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr) msvcrt._wmakepath_s
@ cdecl _wmkdir(wstr) msvcrt._wmkdir @ cdecl _wmkdir(wstr) msvcrt._wmkdir
@ cdecl _wmktemp(wstr) msvcrt._wmktemp @ cdecl _wmktemp(wstr) msvcrt._wmktemp
@ stub _wmktemp_s @ stub _wmktemp_s
......
...@@ -1182,6 +1182,110 @@ range: ...@@ -1182,6 +1182,110 @@ range:
} }
/********************************************************************* /*********************************************************************
* _wmakepath_s (MSVCRT.@)
*
* Safe version of _wmakepath.
*/
int CDECL _wmakepath_s(MSVCRT_wchar_t *path, MSVCRT_size_t size, const MSVCRT_wchar_t *drive,
const MSVCRT_wchar_t *directory, const MSVCRT_wchar_t *filename,
const MSVCRT_wchar_t *extension)
{
MSVCRT_wchar_t *p = path;
if (!path || !size)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
}
if (drive && drive[0])
{
if (size <= 2)
goto range;
*p++ = drive[0];
*p++ = ':';
size -= 2;
}
if (directory && directory[0])
{
unsigned int len = strlenW(directory);
unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\';
unsigned int copylen = min(size - 1, len);
if (size < 2)
goto range;
memmove(p, directory, copylen * sizeof(MSVCRT_wchar_t));
if (size <= len)
goto range;
p += copylen;
size -= copylen;
if (needs_separator)
{
if (size < 2)
goto range;
*p++ = '\\';
size -= 1;
}
}
if (filename && filename[0])
{
unsigned int len = strlenW(filename);
unsigned int copylen = min(size - 1, len);
if (size < 2)
goto range;
memmove(p, filename, copylen * sizeof(MSVCRT_wchar_t));
if (size <= len)
goto range;
p += len;
size -= len;
}
if (extension && extension[0])
{
unsigned int len = strlenW(extension);
unsigned int needs_period = extension[0] != '.';
unsigned int copylen;
if (size < 2)
goto range;
if (needs_period)
{
*p++ = '.';
size -= 1;
}
copylen = min(size - 1, len);
memcpy(p, extension, copylen * sizeof(MSVCRT_wchar_t));
if (size <= len)
goto range;
p += copylen;
}
*p = '\0';
return 0;
range:
path[0] = '\0';
*MSVCRT__errno() = MSVCRT_ERANGE;
return MSVCRT_ERANGE;
}
/*********************************************************************
* _searchenv (MSVCRT.@) * _searchenv (MSVCRT.@)
* *
* Search for a file in a list of paths from an environment variable. * Search for a file in a list of paths from an environment variable.
......
...@@ -1089,8 +1089,8 @@ ...@@ -1089,8 +1089,8 @@
@ extern _winminor MSVCRT__winminor @ extern _winminor MSVCRT__winminor
# stub _winput_s # stub _winput_s
@ extern _winver MSVCRT__winver @ extern _winver MSVCRT__winver
@ cdecl _wmakepath(wstr wstr wstr wstr wstr) @ cdecl _wmakepath(ptr wstr wstr wstr wstr)
# stub _wmakepath_s @ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr)
@ cdecl _wmkdir(wstr) @ cdecl _wmkdir(wstr)
@ cdecl _wmktemp(wstr) @ cdecl _wmktemp(wstr)
# stub _wmktemp_s # stub _wmktemp_s
......
...@@ -205,6 +205,7 @@ wchar_t* __cdecl _ultow(__msvcrt_ulong,wchar_t*,int); ...@@ -205,6 +205,7 @@ wchar_t* __cdecl _ultow(__msvcrt_ulong,wchar_t*,int);
wchar_t* __cdecl _wfullpath(wchar_t*,const wchar_t*,size_t); wchar_t* __cdecl _wfullpath(wchar_t*,const wchar_t*,size_t);
wchar_t* __cdecl _wgetenv(const wchar_t*); wchar_t* __cdecl _wgetenv(const wchar_t*);
void __cdecl _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*); void __cdecl _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*);
int __cdecl _wmakepath_s(wchar_t*,size_t,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*);
void __cdecl _wperror(const wchar_t*); void __cdecl _wperror(const wchar_t*);
int __cdecl _wputenv(const wchar_t*); int __cdecl _wputenv(const wchar_t*);
void __cdecl _wsearchenv(const wchar_t*,const wchar_t*,wchar_t*); void __cdecl _wsearchenv(const wchar_t*,const wchar_t*,wchar_t*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment