Commit 9ba0cf76 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

kernel32: Fix base for value returned with LOCALE_RETURN_NUMBER.

parent 5b7efa8e
...@@ -1264,6 +1264,10 @@ INT WINAPI GetLocaleInfoA( LCID lcid, LCTYPE lctype, LPSTR buffer, INT len ) ...@@ -1264,6 +1264,10 @@ INT WINAPI GetLocaleInfoA( LCID lcid, LCTYPE lctype, LPSTR buffer, INT len )
return ret; return ret;
} }
static int get_value_base_by_lctype( LCTYPE lctype )
{
return lctype == LOCALE_ILANGUAGE || lctype == LOCALE_IDEFAULTLANGUAGE ? 16 : 10;
}
/****************************************************************************** /******************************************************************************
* GetLocaleInfoW (KERNEL32.@) * GetLocaleInfoW (KERNEL32.@)
...@@ -1317,7 +1321,7 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len ) ...@@ -1317,7 +1321,7 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
if (ret > 0) if (ret > 0)
{ {
WCHAR *end; WCHAR *end;
UINT number = strtolW( tmp, &end, 10 ); UINT number = strtolW( tmp, &end, get_value_base_by_lctype( lctype ) );
if (*end) /* invalid number */ if (*end) /* invalid number */
{ {
SetLastError( ERROR_INVALID_FLAGS ); SetLastError( ERROR_INVALID_FLAGS );
...@@ -1390,7 +1394,7 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len ) ...@@ -1390,7 +1394,7 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
if (!tmp) return 0; if (!tmp) return 0;
memcpy( tmp, p + 1, *p * sizeof(WCHAR) ); memcpy( tmp, p + 1, *p * sizeof(WCHAR) );
tmp[*p] = 0; tmp[*p] = 0;
number = strtolW( tmp, &end, 10 ); number = strtolW( tmp, &end, get_value_base_by_lctype( lctype ) );
if (!*end) if (!*end)
memcpy( buffer, &number, sizeof(number) ); memcpy( buffer, &number, sizeof(number) );
else /* invalid number */ else /* invalid number */
......
...@@ -139,7 +139,6 @@ static void test_GetLocaleInfoA(void) ...@@ -139,7 +139,6 @@ static void test_GetLocaleInfoA(void)
ret = GetLocaleInfoA(lcid, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (char*)&val, sizeof(val)); ret = GetLocaleInfoA(lcid, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (char*)&val, sizeof(val));
ok(ret, "got %d\n", ret); ok(ret, "got %d\n", ret);
todo_wine
ok(val == lcid, "got 0x%08x\n", val); ok(val == lcid, "got 0x%08x\n", val);
/* en and ar use SUBLANG_NEUTRAL, but GetLocaleInfo assume SUBLANG_DEFAULT /* en and ar use SUBLANG_NEUTRAL, but GetLocaleInfo assume SUBLANG_DEFAULT
...@@ -204,6 +203,7 @@ struct neutralsublang_name2_t { ...@@ -204,6 +203,7 @@ struct neutralsublang_name2_t {
WCHAR name[3]; WCHAR name[3];
LCID lcid; LCID lcid;
LCID lcid_broken; LCID lcid_broken;
int todo;
}; };
static const struct neutralsublang_name2_t neutralsublang_names2[] = { static const struct neutralsublang_name2_t neutralsublang_names2[] = {
...@@ -212,8 +212,8 @@ static const struct neutralsublang_name2_t neutralsublang_names2[] = { ...@@ -212,8 +212,8 @@ static const struct neutralsublang_name2_t neutralsublang_names2[] = {
{ {'d','e',0}, MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) }, { {'d','e',0}, MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) },
{ {'e','n',0}, MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) }, { {'e','n',0}, MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) },
{ {'e','s',0}, MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT), { {'e','s',0}, MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT),
MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) /* vista */ }, MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) /* vista */, 1 },
{ {'g','a',0}, MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_IRISH_IRELAND), SORT_DEFAULT) }, { {'g','a',0}, MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_IRISH_IRELAND), SORT_DEFAULT), 0, 1 },
{ {'i','t',0}, MAKELCID(MAKELANGID(LANG_ITALIAN, SUBLANG_ITALIAN), SORT_DEFAULT) }, { {'i','t',0}, MAKELCID(MAKELANGID(LANG_ITALIAN, SUBLANG_ITALIAN), SORT_DEFAULT) },
{ {'m','s',0}, MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_MALAY_MALAYSIA), SORT_DEFAULT) }, { {'m','s',0}, MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_MALAY_MALAYSIA), SORT_DEFAULT) },
{ {'n','l',0}, MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DUTCH), SORT_DEFAULT) }, { {'n','l',0}, MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DUTCH), SORT_DEFAULT) },
...@@ -221,7 +221,7 @@ static const struct neutralsublang_name2_t neutralsublang_names2[] = { ...@@ -221,7 +221,7 @@ static const struct neutralsublang_name2_t neutralsublang_names2[] = {
{ {'s','r',0}, MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_CROATIA), SORT_DEFAULT) }, { {'s','r',0}, MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_CROATIA), SORT_DEFAULT) },
{ {'s','v',0}, MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) }, { {'s','v',0}, MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) },
{ {'u','z',0}, MAKELCID(MAKELANGID(LANG_UZBEK, SUBLANG_UZBEK_LATIN), SORT_DEFAULT) }, { {'u','z',0}, MAKELCID(MAKELANGID(LANG_UZBEK, SUBLANG_UZBEK_LATIN), SORT_DEFAULT) },
{ {'z','h',0}, MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT) }, { {'z','h',0}, MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT), 0, 1 },
{ {0} } { {0} }
}; };
...@@ -244,7 +244,6 @@ static void test_GetLocaleInfoW(void) ...@@ -244,7 +244,6 @@ static void test_GetLocaleInfoW(void)
ret = GetLocaleInfoW(lcid_en, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR)); ret = GetLocaleInfoW(lcid_en, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR));
ok(ret, "got %d\n", ret); ok(ret, "got %d\n", ret);
todo_wine
ok(val == lcid_en, "got 0x%08x\n", val); ok(val == lcid_en, "got 0x%08x\n", val);
ret = GetLocaleInfoW(lcid_en_neut, LOCALE_SNAME, bufferW, COUNTOF(bufferW)); ret = GetLocaleInfoW(lcid_en_neut, LOCALE_SNAME, bufferW, COUNTOF(bufferW));
...@@ -275,8 +274,14 @@ todo_wine ...@@ -275,8 +274,14 @@ todo_wine
val = 0; val = 0;
GetLocaleInfoW(MAKELCID(langid, SORT_DEFAULT), LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR)); GetLocaleInfoW(MAKELCID(langid, SORT_DEFAULT), LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR));
if (ptr->todo)
{
todo_wine todo_wine
ok(val == ptr->lcid || broken(val == ptr->lcid_broken), "%s: got wrong lcid 0x%04x, expected 0x%04x\n", ok(val == ptr->lcid || (val && broken(val == ptr->lcid_broken)), "%s: got wrong lcid 0x%04x, expected 0x%04x\n",
wine_dbgstr_w(ptr->name), val, ptr->lcid);
}
else
ok(val == ptr->lcid || (val && broken(val == ptr->lcid_broken)), "%s: got wrong lcid 0x%04x, expected 0x%04x\n",
wine_dbgstr_w(ptr->name), val, ptr->lcid); wine_dbgstr_w(ptr->name), val, ptr->lcid);
ptr++; ptr++;
} }
...@@ -3381,8 +3386,11 @@ todo_wine ...@@ -3381,8 +3386,11 @@ todo_wine
{ {
val = 0; val = 0;
pGetLocaleInfoEx(ptr->name, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR)); pGetLocaleInfoEx(ptr->name, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR));
if (ptr->todo)
todo_wine todo_wine
ok(val == ptr->lcid, "%s: got wrong lcid 0x%04x, expected 0x%04x\n", wine_dbgstr_w(ptr->name), val, ptr->lcid); ok(val == ptr->lcid, "%s: got wrong lcid 0x%04x, expected 0x%04x\n", wine_dbgstr_w(ptr->name), val, ptr->lcid);
else
ok(val == ptr->lcid, "%s: got wrong lcid 0x%04x, expected 0x%04x\n", wine_dbgstr_w(ptr->name), val, ptr->lcid);
ptr++; ptr++;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment