Commit 5437c72f authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

msvcrt: Implemented (_)wcserror_s.

parent 71200a98
...@@ -483,7 +483,7 @@ ...@@ -483,7 +483,7 @@
@ stub __vswprintf_l @ stub __vswprintf_l
@ extern __wargv msvcrt.__wargv @ extern __wargv msvcrt.__wargv
@ cdecl __wcserror(wstr) msvcrt.__wcserror @ cdecl __wcserror(wstr) msvcrt.__wcserror
@ stub __wcserror_s @ cdecl __wcserror_s(ptr long wstr) msvcrt.__wcserror_s
@ stub __wcsncnt @ stub __wcsncnt
@ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs
@ extern __winitenv msvcrt.__winitenv @ extern __winitenv msvcrt.__winitenv
...@@ -1285,7 +1285,7 @@ ...@@ -1285,7 +1285,7 @@
@ stub _wcscoll_l @ stub _wcscoll_l
@ cdecl _wcsdup(wstr) msvcrt._wcsdup @ cdecl _wcsdup(wstr) msvcrt._wcsdup
@ cdecl _wcserror(long) msvcrt._wcserror @ cdecl _wcserror(long) msvcrt._wcserror
@ stub _wcserror_s @ cdecl _wcserror_s(ptr long long) msvcrt._wcserror_s
@ stub _wcsftime_l @ stub _wcsftime_l
@ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp
@ stub _wcsicmp_l @ stub _wcsicmp_l
......
...@@ -307,7 +307,7 @@ ...@@ -307,7 +307,7 @@
@ stub __vswprintf_l @ stub __vswprintf_l
@ extern __wargv msvcrt.__wargv @ extern __wargv msvcrt.__wargv
@ cdecl __wcserror(wstr) msvcrt.__wcserror @ cdecl __wcserror(wstr) msvcrt.__wcserror
@ stub __wcserror_s @ cdecl __wcserror_s(ptr long wstr) msvcrt.__wcserror_s
@ stub __wcsncnt @ stub __wcsncnt
@ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs
@ extern __winitenv msvcrt.__winitenv @ extern __winitenv msvcrt.__winitenv
...@@ -1138,7 +1138,7 @@ ...@@ -1138,7 +1138,7 @@
@ stub _wcscoll_l @ stub _wcscoll_l
@ cdecl _wcsdup(wstr) msvcrt._wcsdup @ cdecl _wcsdup(wstr) msvcrt._wcsdup
@ cdecl _wcserror(long) msvcrt._wcserror @ cdecl _wcserror(long) msvcrt._wcserror
@ stub _wcserror_s @ cdecl _wcserror_s(ptr long long) msvcrt._wcserror_s
@ stub _wcsftime_l @ stub _wcsftime_l
@ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp
@ stub _wcsicmp_l @ stub _wcsicmp_l
......
...@@ -299,7 +299,7 @@ ...@@ -299,7 +299,7 @@
@ stub __vswprintf_l @ stub __vswprintf_l
@ extern __wargv msvcrt.__wargv @ extern __wargv msvcrt.__wargv
@ cdecl __wcserror(wstr) msvcrt.__wcserror @ cdecl __wcserror(wstr) msvcrt.__wcserror
@ stub __wcserror_s @ cdecl __wcserror_s(ptr long wstr) msvcrt.__wcserror_s
@ stub __wcsncnt @ stub __wcsncnt
@ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs
@ extern __winitenv msvcrt.__winitenv @ extern __winitenv msvcrt.__winitenv
...@@ -1125,7 +1125,7 @@ ...@@ -1125,7 +1125,7 @@
@ stub _wcscoll_l @ stub _wcscoll_l
@ cdecl _wcsdup(wstr) msvcrt._wcsdup @ cdecl _wcsdup(wstr) msvcrt._wcsdup
@ cdecl _wcserror(long) msvcrt._wcserror @ cdecl _wcserror(long) msvcrt._wcserror
@ stub _wcserror_s @ cdecl _wcserror_s(ptr long long) msvcrt._wcserror_s
@ stub _wcsftime_l @ stub _wcsftime_l
@ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp
@ stub _wcsicmp_l @ stub _wcsicmp_l
......
...@@ -328,6 +328,21 @@ void CDECL MSVCRT_perror(const char* str) ...@@ -328,6 +328,21 @@ void CDECL MSVCRT_perror(const char* str)
} }
/********************************************************************* /*********************************************************************
* _wcserror_s (MSVCRT.@)
*/
int CDECL _wcserror_s(MSVCRT_wchar_t* buffer, MSVCRT_size_t nc, int err)
{
if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(nc > 0))
{
_set_errno(MSVCRT_EINVAL);
return MSVCRT_EINVAL;
}
if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr;
MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, buffer, nc);
return 0;
}
/*********************************************************************
* _wcserror (MSVCRT.@) * _wcserror (MSVCRT.@)
*/ */
MSVCRT_wchar_t* CDECL _wcserror(int err) MSVCRT_wchar_t* CDECL _wcserror(int err)
...@@ -336,38 +351,57 @@ MSVCRT_wchar_t* CDECL _wcserror(int err) ...@@ -336,38 +351,57 @@ MSVCRT_wchar_t* CDECL _wcserror(int err)
if (!data->wcserror_buffer) if (!data->wcserror_buffer)
if (!(data->wcserror_buffer = MSVCRT_malloc(256 * sizeof(MSVCRT_wchar_t)))) return NULL; if (!(data->wcserror_buffer = MSVCRT_malloc(256 * sizeof(MSVCRT_wchar_t)))) return NULL;
_wcserror_s(data->wcserror_buffer, 256, err);
if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr;
MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, data->wcserror_buffer, 256);
return data->wcserror_buffer; return data->wcserror_buffer;
} }
/********************************************************************** /**********************************************************************
* __wcserror (MSVCRT.@) * __wcserror_s (MSVCRT.@)
*/ */
MSVCRT_wchar_t* CDECL __wcserror(const MSVCRT_wchar_t* str) int CDECL __wcserror_s(MSVCRT_wchar_t* buffer, MSVCRT_size_t nc, const MSVCRT_wchar_t* str)
{ {
thread_data_t *data = msvcrt_get_thread_data();
int err; int err;
static const WCHAR colonW[] = {':', ' ', '\0'}; static const WCHAR colonW[] = {':', ' ', '\0'};
static const WCHAR nlW[] = {'\n', '\0'}; static const WCHAR nlW[] = {'\n', '\0'};
size_t len; size_t len;
if (!data->wcserror_buffer) err = *MSVCRT__errno();
if (!(data->wcserror_buffer = MSVCRT_malloc(256 * sizeof(MSVCRT_wchar_t)))) return NULL;
err = data->thread_errno;
if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr; if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr;
len = MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, NULL, 0) + 1 /* \n */;
if (str && *str) len += lstrlenW(str) + 2 /* ': ' */;
if (len > nc)
{
MSVCRT_INVALID_PMT("buffer[nc] is too small");
_set_errno(MSVCRT_ERANGE);
return MSVCRT_ERANGE;
}
if (str && *str) if (str && *str)
{ {
lstrcpyW(data->wcserror_buffer, str); lstrcpyW(buffer, str);
lstrcatW(data->wcserror_buffer, colonW); lstrcatW(buffer, colonW);
} }
else data->wcserror_buffer[0] = '\0'; else buffer[0] = '\0';
len = lstrlenW(data->wcserror_buffer); len = lstrlenW(buffer);
MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, data->wcserror_buffer + len, 256 - len); MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, buffer + len, 256 - len);
lstrcatW(data->wcserror_buffer, nlW); lstrcatW(buffer, nlW);
return 0;
}
/**********************************************************************
* __wcserror (MSVCRT.@)
*/
MSVCRT_wchar_t* CDECL __wcserror(const MSVCRT_wchar_t* str)
{
thread_data_t *data = msvcrt_get_thread_data();
int err;
if (!data->wcserror_buffer)
if (!(data->wcserror_buffer = MSVCRT_malloc(256 * sizeof(MSVCRT_wchar_t)))) return NULL;
err = __wcserror_s(data->wcserror_buffer, 256, str);
if (err) FIXME("bad wcserror call (%d)\n", err);
return data->wcserror_buffer; return data->wcserror_buffer;
} }
......
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
@ extern __unguarded_readlc_active MSVCRT___unguarded_readlc_active @ extern __unguarded_readlc_active MSVCRT___unguarded_readlc_active
@ extern __wargv MSVCRT___wargv @ extern __wargv MSVCRT___wargv
@ cdecl __wcserror(wstr) @ cdecl __wcserror(wstr)
# stub __wcserror_s @ cdecl __wcserror_s(ptr long wstr)
# stub __wcsncnt # stub __wcsncnt
@ cdecl __wgetmainargs(ptr ptr ptr long ptr) @ cdecl __wgetmainargs(ptr ptr ptr long ptr)
@ extern __winitenv MSVCRT___winitenv @ extern __winitenv MSVCRT___winitenv
...@@ -1058,7 +1058,7 @@ ...@@ -1058,7 +1058,7 @@
@ cdecl _wcsdup(wstr) @ cdecl _wcsdup(wstr)
# stub _wcsdup_dbg # stub _wcsdup_dbg
@ cdecl _wcserror(long) @ cdecl _wcserror(long)
# stub _wcserror_s @ cdecl _wcserror_s(ptr long long)
# stub _wcsftime_l # stub _wcsftime_l
@ cdecl _wcsicmp(wstr wstr) ntdll._wcsicmp @ cdecl _wcsicmp(wstr wstr) ntdll._wcsicmp
# stub _wcsicmp_l # stub _wcsicmp_l
......
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