=?UTF-8?Q?Andr=C3=A9=20Hentschel=20?=: kernel32: Fix LocaleNameToLCID on mismatch.

Alexandre Julliard julliard at winehq.org
Fri Aug 17 10:37:46 CDT 2012


Module: wine
Branch: master
Commit: 20e1b46d83c1c8e51aee80befc60665cb1f81eff
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=20e1b46d83c1c8e51aee80befc60665cb1f81eff

Author: André Hentschel <nerv at dawncrow.de>
Date:   Fri Aug 17 00:46:31 2012 +0200

kernel32: Fix LocaleNameToLCID on mismatch.

---

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

diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 29e38c9..1e5b7e5 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -998,8 +998,12 @@ LCID WINAPI LocaleNameToLCID( LPCWSTR name, DWORD flags )
            locale_name.lcid, debugstr_w(name), locale_name.matches );
 
     if (!locale_name.matches)
-        WARN( "locale %s not recognized, defaulting to English\n", debugstr_w(name) );
-    else if (locale_name.matches == 1)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return 0;
+    }
+
+    if (locale_name.matches == 1)
         WARN( "locale %s not recognized, defaulting to %s\n",
               debugstr_w(name), debugstr_w(locale_name.lang) );
 
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index a2a33fa..c264ca3 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -1869,22 +1869,25 @@ static void test_LocaleNameToLCID(void)
 
     /* special cases */
     buffer[0] = 0;
+    SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(LOCALE_NAME_USER_DEFAULT, 0);
     ok(lcid == GetUserDefaultLCID() || broken(GetLastError() == ERROR_INVALID_PARAMETER /* Vista */),
-       "Expected lcid == %08x, got %08x, error %d\n", lcid, GetUserDefaultLCID(), GetLastError());
+       "Expected lcid == %08x, got %08x, error %d\n", GetUserDefaultLCID(), lcid, GetLastError());
     ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
     ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
     trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
 
     buffer[0] = 0;
+    SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(LOCALE_NAME_SYSTEM_DEFAULT, 0);
-    todo_wine ok(!lcid && GetLastError() == ERROR_INVALID_PARAMETER,
-                 "Expected lcid != 0, got %08x, error %d\n", lcid, GetLastError());
+    ok(!lcid && GetLastError() == ERROR_INVALID_PARAMETER,
+       "Expected lcid == 0, got %08x, error %d\n", lcid, GetLastError());
     ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
     ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
     trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
 
     buffer[0] = 0;
+    SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(LOCALE_NAME_INVARIANT, 0);
     todo_wine ok(lcid == 0x7F, "Expected lcid = 0x7F, got %08x, error %d\n", lcid, GetLastError());
     ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
@@ -1892,8 +1895,10 @@ static void test_LocaleNameToLCID(void)
     trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
 
     /* bad name */
+    SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(fooW, 0);
-    todo_wine ok(lcid == 0, "got 0x%04x\n", lcid);
+    ok(!lcid && GetLastError() == ERROR_INVALID_PARAMETER,
+       "Expected lcid == 0, got got %08x, error %d\n", lcid, GetLastError());
 
     /* english neutral name */
     lcid = pLocaleNameToLCID(enW, 0);




More information about the wine-cvs mailing list