[PATCH v2 4/4] msvcrt: Pass temporary locale to MSVCRT__towupper_l.

Rémi Bernon rbernon at codeweavers.com
Mon Nov 9 08:32:22 CST 2020


When not provided, instead of calling get_locinfo on every character.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/msvcrt/wcs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index 793c37a343f..41c70fdad12 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 = {};
   MSVCRT_wchar_t* ptr = str;
 
   if (!str || !n)
@@ -364,13 +365,19 @@ 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) break;
     *ptr = MSVCRT__towupper_l(*ptr, locale);
     ptr++;
   }
 
+  free_locale_noalloc(&tmp);
+  if (!*ptr) return 0;
+
   /* 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';
-- 
2.29.2




More information about the wine-devel mailing list