From 71200a9818dbdf60610e7e6e1eff8ad668df0851 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Tue, 2 Nov 2010 22:03:47 +0100 Subject: [PATCH] msvcrt: Implemented (_)wcserror. --- dlls/msvcr100/msvcr100.spec | 4 ++-- dlls/msvcr70/msvcr70.spec | 4 ++-- dlls/msvcr71/msvcr71.spec | 4 ++-- dlls/msvcr80/msvcr80.spec | 4 ++-- dlls/msvcr90/msvcr90.spec | 4 ++-- dlls/msvcrt/errno.c | 46 +++++++++++++++++++++++++++++++++++++ dlls/msvcrt/main.c | 1 + dlls/msvcrt/msvcrt.h | 1 + dlls/msvcrt/msvcrt.spec | 4 ++-- 9 files changed, 60 insertions(+), 12 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index e6fadd692d..87898611b7 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -482,7 +482,7 @@ @ extern __unguarded_readlc_active msvcrt.__unguarded_readlc_active @ stub __vswprintf_l @ extern __wargv msvcrt.__wargv -@ stub __wcserror +@ cdecl __wcserror(wstr) msvcrt.__wcserror @ stub __wcserror_s @ stub __wcsncnt @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @@ -1284,7 +1284,7 @@ @ cdecl _wcreat(wstr long) msvcrt._wcreat @ stub _wcscoll_l @ cdecl _wcsdup(wstr) msvcrt._wcsdup -@ stub _wcserror +@ cdecl _wcserror(long) msvcrt._wcserror @ stub _wcserror_s @ stub _wcsftime_l @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp diff --git a/dlls/msvcr70/msvcr70.spec b/dlls/msvcr70/msvcr70.spec index 52156b7ac9..307ae0942c 100644 --- a/dlls/msvcr70/msvcr70.spec +++ b/dlls/msvcr70/msvcr70.spec @@ -206,7 +206,7 @@ @ cdecl __unDNameEx(ptr str long ptr ptr ptr long) msvcrt.__unDNameEx @ extern __unguarded_readlc_active msvcrt.__unguarded_readlc_active @ extern __wargv msvcrt.__wargv -@ stub __wcserror +@ cdecl __wcserror(wstr) msvcrt.__wcserror @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @ extern __winitenv msvcrt.__winitenv @ cdecl _abnormal_termination() msvcrt._abnormal_termination @@ -595,7 +595,7 @@ @ extern _wcmdln msvcrt._wcmdln @ cdecl _wcreat(wstr long) msvcrt._wcreat @ cdecl _wcsdup(wstr) msvcrt._wcsdup -@ stub _wcserror +@ cdecl _wcserror(long) msvcrt._wcserror @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp @ cdecl _wcsicoll(wstr wstr) msvcrt._wcsicoll @ cdecl _wcslwr(wstr) msvcrt._wcslwr diff --git a/dlls/msvcr71/msvcr71.spec b/dlls/msvcr71/msvcr71.spec index 33db3a6824..fc8491da43 100644 --- a/dlls/msvcr71/msvcr71.spec +++ b/dlls/msvcr71/msvcr71.spec @@ -201,7 +201,7 @@ @ cdecl __unDNameEx(ptr str long ptr ptr ptr long) msvcrt.__unDNameEx @ extern __unguarded_readlc_active msvcrt.__unguarded_readlc_active @ extern __wargv msvcrt.__wargv -@ stub __wcserror +@ cdecl __wcserror(wstr) msvcrt.__wcserror @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @ extern __winitenv msvcrt.__winitenv @ cdecl _abnormal_termination() msvcrt._abnormal_termination @@ -591,7 +591,7 @@ @ extern _wcmdln msvcrt._wcmdln @ cdecl _wcreat(wstr long) msvcrt._wcreat @ cdecl _wcsdup(wstr) msvcrt._wcsdup -@ stub _wcserror +@ cdecl _wcserror(long) msvcrt._wcserror @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp @ cdecl _wcsicoll(wstr wstr) msvcrt._wcsicoll @ cdecl _wcslwr(wstr) msvcrt._wcslwr diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 3953b5cf41..1ca1b193b2 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -306,7 +306,7 @@ @ extern __unguarded_readlc_active msvcrt.__unguarded_readlc_active @ stub __vswprintf_l @ extern __wargv msvcrt.__wargv -@ stub __wcserror +@ cdecl __wcserror(wstr) msvcrt.__wcserror @ stub __wcserror_s @ stub __wcsncnt @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @@ -1137,7 +1137,7 @@ @ cdecl _wcreat(wstr long) msvcrt._wcreat @ stub _wcscoll_l @ cdecl _wcsdup(wstr) msvcrt._wcsdup -@ stub _wcserror +@ cdecl _wcserror(long) msvcrt._wcserror @ stub _wcserror_s @ stub _wcsftime_l @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index f9188e3a24..8d38a07ae0 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -298,7 +298,7 @@ @ extern __unguarded_readlc_active msvcrt.__unguarded_readlc_active @ stub __vswprintf_l @ extern __wargv msvcrt.__wargv -@ stub __wcserror +@ cdecl __wcserror(wstr) msvcrt.__wcserror @ stub __wcserror_s @ stub __wcsncnt @ cdecl __wgetmainargs(ptr ptr ptr long ptr) msvcrt.__wgetmainargs @@ -1124,7 +1124,7 @@ @ cdecl _wcreat(wstr long) msvcrt._wcreat @ stub _wcscoll_l @ cdecl _wcsdup(wstr) msvcrt._wcsdup -@ stub _wcserror +@ cdecl _wcserror(long) msvcrt._wcserror @ stub _wcserror_s @ stub _wcsftime_l @ cdecl _wcsicmp(wstr wstr) msvcrt._wcsicmp diff --git a/dlls/msvcrt/errno.c b/dlls/msvcrt/errno.c index 266b6dbbb5..0457869cd6 100644 --- a/dlls/msvcrt/errno.c +++ b/dlls/msvcrt/errno.c @@ -27,6 +27,7 @@ #include "windef.h" #include "winternl.h" #include "msvcrt.h" +#include "winnls.h" #include "excpt.h" #include "wine/debug.h" @@ -326,6 +327,51 @@ void CDECL MSVCRT_perror(const char* str) MSVCRT__write( 2, "\n", 1 ); } +/********************************************************************* + * _wcserror (MSVCRT.@) + */ +MSVCRT_wchar_t* CDECL _wcserror(int err) +{ + thread_data_t *data = msvcrt_get_thread_data(); + + if (!data->wcserror_buffer) + if (!(data->wcserror_buffer = MSVCRT_malloc(256 * sizeof(MSVCRT_wchar_t)))) return NULL; + + 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; +} + +/********************************************************************** + * __wcserror (MSVCRT.@) + */ +MSVCRT_wchar_t* CDECL __wcserror(const MSVCRT_wchar_t* str) +{ + thread_data_t *data = msvcrt_get_thread_data(); + int err; + static const WCHAR colonW[] = {':', ' ', '\0'}; + static const WCHAR nlW[] = {'\n', '\0'}; + size_t len; + + if (!data->wcserror_buffer) + 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 (str && *str) + { + lstrcpyW(data->wcserror_buffer, str); + lstrcatW(data->wcserror_buffer, colonW); + } + else data->wcserror_buffer[0] = '\0'; + len = lstrlenW(data->wcserror_buffer); + MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, data->wcserror_buffer + len, 256 - len); + lstrcatW(data->wcserror_buffer, nlW); + + return data->wcserror_buffer; +} + /****************************************************************************** * _set_error_mode (MSVCRT.@) * diff --git a/dlls/msvcrt/main.c b/dlls/msvcrt/main.c index 323f8b770c..ac2427021b 100644 --- a/dlls/msvcrt/main.c +++ b/dlls/msvcrt/main.c @@ -70,6 +70,7 @@ static inline void msvcrt_free_tls_mem(void) HeapFree(GetProcessHeap(),0,tls->asctime_buffer); HeapFree(GetProcessHeap(),0,tls->wasctime_buffer); HeapFree(GetProcessHeap(),0,tls->strerror_buffer); + HeapFree(GetProcessHeap(),0,tls->wcserror_buffer); MSVCRT__free_locale(tls->locale); } HeapFree(GetProcessHeap(), 0, tls); diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index c36b5bd824..2e8263e8ca 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -116,6 +116,7 @@ struct __thread_data { MSVCRT_wchar_t *wasctime_buffer; /* buffer for wasctime */ struct MSVCRT_tm time_buffer; /* buffer for localtime/gmtime */ char *strerror_buffer; /* buffer for strerror */ + MSVCRT_wchar_t *wcserror_buffer; /* buffer for wcserror */ int fpecode; MSVCRT_terminate_function terminate_handler; MSVCRT_unexpected_function unexpected_handler; diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index f6baa107cd..d1a5c5904a 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -263,7 +263,7 @@ @ cdecl __unDNameEx(ptr str long ptr ptr ptr long) @ extern __unguarded_readlc_active MSVCRT___unguarded_readlc_active @ extern __wargv MSVCRT___wargv -# stub __wcserror +@ cdecl __wcserror(wstr) # stub __wcserror_s # stub __wcsncnt @ cdecl __wgetmainargs(ptr ptr ptr long ptr) @@ -1057,7 +1057,7 @@ # stub _wcscoll_l @ cdecl _wcsdup(wstr) # stub _wcsdup_dbg -# stub _wcserror +@ cdecl _wcserror(long) # stub _wcserror_s # stub _wcsftime_l @ cdecl _wcsicmp(wstr wstr) ntdll._wcsicmp -- 2.32.0.93.g670b81a890