From 35886486d4aa88f49369d1196ac891e56b43c026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 10 Nov 2020 16:58:57 +0100 Subject: [PATCH] msvcrt: Pass temporary locale to MSVCRT__towupper_l. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When not provided, instead of calling get_locinfo on every character. Signed-off-by: RĂ©mi Bernon Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/wcs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 63f9fd472d7..fcadad77832 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -355,6 +355,7 @@ MSVCRT_wchar_t* CDECL MSVCRT__wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c ) int CDECL MSVCRT__wcsupr_s_l( MSVCRT_wchar_t* str, MSVCRT_size_t n, MSVCRT__locale_t locale ) { + MSVCRT__locale_tstruct tmp = {0}; MSVCRT_wchar_t* ptr = str; if (!str || !n) @@ -364,13 +365,22 @@ int CDECL MSVCRT__wcsupr_s_l( MSVCRT_wchar_t* str, MSVCRT_size_t n, return MSVCRT_EINVAL; } + if(!locale) + locale = get_current_locale_noalloc(&tmp); + while (n--) { - if (!*ptr) return 0; + if (!*ptr) + { + free_locale_noalloc(&tmp); + return 0; + } *ptr = MSVCRT__towupper_l(*ptr, locale); ptr++; } + free_locale_noalloc(&tmp); + /* MSDN claims that the function should return and set errno to * ERANGE, which doesn't seem to be true based on the tests. */ *str = '\0';