mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 19:53:38 +00:00
msvcrt: Skip exhaustive locale search with valid snames.
This commit is contained in:
parent
45dd09d0cf
commit
72c3b8f3a0
|
@ -153,14 +153,14 @@ static void test_setlocale(void)
|
||||||
ok(!ret, "setlocale(en-us.1250) succeeded (%s)\n", ret);
|
ok(!ret, "setlocale(en-us.1250) succeeded (%s)\n", ret);
|
||||||
|
|
||||||
ret = p_setlocale(LC_ALL, "zh-Hans");
|
ret = p_setlocale(LC_ALL, "zh-Hans");
|
||||||
todo_wine ok((ret != NULL
|
ok((ret != NULL
|
||||||
|| broken(ret == NULL)), /* Vista */
|
|| broken(ret == NULL)), /* Vista */
|
||||||
"expected success, but got NULL\n");
|
"expected success, but got NULL\n");
|
||||||
if (ret)
|
if (ret)
|
||||||
ok(!strcmp(ret, "zh-Hans"), "setlocale zh-Hans failed\n");
|
ok(!strcmp(ret, "zh-Hans"), "setlocale zh-Hans failed\n");
|
||||||
|
|
||||||
ret = p_setlocale(LC_ALL, "zh-Hant");
|
ret = p_setlocale(LC_ALL, "zh-Hant");
|
||||||
todo_wine ok((ret != NULL
|
ok((ret != NULL
|
||||||
|| broken(ret == NULL)), /* Vista */
|
|| broken(ret == NULL)), /* Vista */
|
||||||
"expected success, but got NULL\n");
|
"expected success, but got NULL\n");
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -598,11 +598,11 @@ static void test____lc_locale_name_func(void)
|
||||||
|
|
||||||
p_setlocale(LC_ALL, "zh-Hans");
|
p_setlocale(LC_ALL, "zh-Hans");
|
||||||
lc_names = p____lc_locale_name_func();
|
lc_names = p____lc_locale_name_func();
|
||||||
todo_wine ok(!lstrcmpW(lc_names[1], L"zh-Hans"), "lc_names[1] expected zh-Hans got %s\n", wine_dbgstr_w(lc_names[1]));
|
ok(!lstrcmpW(lc_names[1], L"zh-Hans"), "lc_names[1] expected zh-Hans got %s\n", wine_dbgstr_w(lc_names[1]));
|
||||||
|
|
||||||
p_setlocale(LC_ALL, "zh-Hant");
|
p_setlocale(LC_ALL, "zh-Hant");
|
||||||
lc_names = p____lc_locale_name_func();
|
lc_names = p____lc_locale_name_func();
|
||||||
todo_wine ok(!lstrcmpW(lc_names[1], L"zh-Hant"), "lc_names[1] expected zh-Hant got %s\n", wine_dbgstr_w(lc_names[1]));
|
ok(!lstrcmpW(lc_names[1], L"zh-Hant"), "lc_names[1] expected zh-Hant got %s\n", wine_dbgstr_w(lc_names[1]));
|
||||||
|
|
||||||
p_setlocale(LC_ALL, "C");
|
p_setlocale(LC_ALL, "C");
|
||||||
lc_names = p____lc_locale_name_func();
|
lc_names = p____lc_locale_name_func();
|
||||||
|
|
|
@ -343,6 +343,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
|
||||||
if(!locale[0] || (cp == locale && !region)) {
|
if(!locale[0] || (cp == locale && !region)) {
|
||||||
GetUserDefaultLocaleName(sname, sname_size);
|
GetUserDefaultLocaleName(sname, sname_size);
|
||||||
} else {
|
} else {
|
||||||
|
WCHAR wbuf[LOCALE_NAME_MAX_LENGTH];
|
||||||
locale_search_t search;
|
locale_search_t search;
|
||||||
|
|
||||||
memset(&search, 0, sizeof(locale_search_t));
|
memset(&search, 0, sizeof(locale_search_t));
|
||||||
|
@ -364,9 +365,19 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
|
||||||
if(!cp && !region)
|
if(!cp && !region)
|
||||||
{
|
{
|
||||||
remap_synonym(search.search_language);
|
remap_synonym(search.search_language);
|
||||||
|
#if _MSVCR_VER >= 110
|
||||||
search.allow_sname = TRUE;
|
search.allow_sname = TRUE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, search.search_language, -1, wbuf, LOCALE_NAME_MAX_LENGTH);
|
||||||
|
if (search.allow_sname && IsValidLocaleName(wbuf))
|
||||||
|
{
|
||||||
|
search.match_flags = FOUND_SNAME;
|
||||||
|
wcsncpy(sname, wbuf, sname_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
EnumSystemLocalesEx( find_best_locale_proc, 0, (LPARAM)&search, NULL);
|
EnumSystemLocalesEx( find_best_locale_proc, 0, (LPARAM)&search, NULL);
|
||||||
|
|
||||||
if (!search.match_flags)
|
if (!search.match_flags)
|
||||||
|
@ -379,6 +390,8 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
LCIDToLocaleName(search.found_lang_id, sname, sname_size, LOCALE_ALLOW_NEUTRAL_NAMES);
|
LCIDToLocaleName(search.found_lang_id, sname, sname_size, LOCALE_ALLOW_NEUTRAL_NAMES);
|
||||||
|
}
|
||||||
|
|
||||||
is_sname = (search.match_flags & FOUND_SNAME) != 0;
|
is_sname = (search.match_flags & FOUND_SNAME) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue