Alexandre Julliard : kernelbase: Reimplement LCIDToLocaleName() using the locale.nls data.

Alexandre Julliard julliard at winehq.org
Mon Mar 28 15:53:40 CDT 2022


Module: wine
Branch: master
Commit: 412e79181fc15aec030a584ca484a6b6fedee868
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=412e79181fc15aec030a584ca484a6b6fedee868

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Mar 28 12:21:15 2022 +0200

kernelbase: Reimplement LCIDToLocaleName() using the locale.nls data.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/locale.c |  8 ++++++++
 dlls/kernelbase/locale.c     | 16 ++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index d30a771c2c2..9475df22cbe 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -2790,6 +2790,14 @@ static void test_LocaleNameToLCID(void)
         ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(L"zh-hans"), ret);
         ok(!lstrcmpW(L"zh-CN", buffer), "%s: got wrong locale name %s\n",
            wine_dbgstr_w(L"zh-hans"), wine_dbgstr_w(buffer));
+
+        /* de-DE_phoneb */
+        lcid = pLocaleNameToLCID(L"de-DE_phoneb", 0);
+        ok(lcid == MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_GERMAN_PHONE_BOOK),
+           "%s: got wrong lcid 0x%04lx\n", wine_dbgstr_w(L"zh-hans"), lcid);
+        ret = pLCIDToLocaleName(lcid, buffer, ARRAY_SIZE(buffer), 0);
+        ok(!lstrcmpW(L"de-DE_phoneb", buffer), "got wrong locale name %s\n",
+           wine_dbgstr_w(buffer));
     }
 
     if (pRtlLocaleNameToLcid)
diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c
index 39d7fe1ccd9..8b137cdf90a 100644
--- a/dlls/kernelbase/locale.c
+++ b/dlls/kernelbase/locale.c
@@ -5180,9 +5180,9 @@ LANGID WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLangID(void)
 /***********************************************************************
  *	GetSystemDefaultLocaleName   (kernelbase.@)
  */
-INT WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLocaleName( LPWSTR name, INT len )
+INT WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLocaleName( LPWSTR name, INT count )
 {
-    return LCIDToLocaleName( GetSystemDefaultLCID(), name, len, 0 );
+    return get_locale_info( system_locale, system_lcid, LOCALE_SNAME, name, count );
 }
 
 
@@ -5329,7 +5329,7 @@ LANGID WINAPI DECLSPEC_HOTPATCH GetUserDefaultLangID(void)
  */
 INT WINAPI DECLSPEC_HOTPATCH GetUserDefaultLocaleName( LPWSTR name, INT len )
 {
-    return LCIDToLocaleName( GetUserDefaultLCID(), name, len, 0 );
+    return get_locale_info( user_locale, user_lcid, LOCALE_SNAME, name, len );
 }
 
 
@@ -5692,10 +5692,14 @@ DWORD WINAPI DECLSPEC_HOTPATCH IsValidNLSVersion( NLS_FUNCTION func, const WCHAR
  */
 INT WINAPI DECLSPEC_HOTPATCH LCIDToLocaleName( LCID lcid, WCHAR *name, INT count, DWORD flags )
 {
-    static int once;
-    if (flags && !once++) FIXME( "unsupported flags %lx\n", flags );
+    const NLS_LOCALE_DATA *locale = get_locale_by_id( &lcid, flags );
 
-    return GetLocaleInfoW( lcid, LOCALE_SNAME | LOCALE_NOUSEROVERRIDE, name, count );
+    if (!locale)
+    {
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return 0;
+    }
+    return get_locale_info( locale, lcid, LOCALE_SNAME, name, count );
 }
 
 




More information about the wine-cvs mailing list