kernel32: Fix LocaleNameToLCID on mismatch.

This commit is contained in:
André Hentschel 2012-08-17 00:46:31 +02:00 committed by Alexandre Julliard
parent ca234e3ed4
commit 20e1b46d83
2 changed files with 15 additions and 6 deletions

View File

@ -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) );

View File

@ -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);