Commit ec7816a4 authored by Victor Chiletto's avatar Victor Chiletto Committed by Alexandre Julliard

msvcrt: Remap synonyms to snames.

Gives us more control over what we map to which is required due to changes in Chinese locales.
parent d71e9394
...@@ -172,43 +172,54 @@ static struct lconv cloc_lconv = ...@@ -172,43 +172,54 @@ static struct lconv cloc_lconv =
/* Friendly country strings & language names abbreviations. */ /* Friendly country strings & language names abbreviations. */
static const char * const _country_synonyms[] = static const char * const _country_synonyms[] =
{ {
"american", "enu", "american", "en",
"american english", "enu", "american english", "en-US",
"american-english", "enu", "american-english", "en-US",
"english-american", "enu", "english-american", "en-US",
"english-us", "enu", "english-us", "en-US",
"english-usa", "enu", "english-usa", "en-US",
"us", "enu", "us", "en-US",
"usa", "enu", "usa", "en-US",
"australian", "ena", "australian", "en-AU",
"english-aus", "ena", "english-aus", "en-AU",
"belgian", "nlb", "belgian", "nl-BE",
"french-belgian", "frb", "french-belgian", "fr-BE",
"canadian", "enc", "canadian", "en-CA",
"english-can", "enc", "english-can", "en-CA",
"french-canadian", "frc", "french-canadian", "fr-CA",
"chinese", "chs", #if _MSVCR_VER >= 110
"chinese-simplified", "chs", "chinese", "zh",
"chinese-traditional", "cht", "chinese-simplified", "zh",
"dutch-belgian", "nlb", "chinese-traditional", "zh-HK",
"english-nz", "enz", "chs", "zh",
"uk", "eng", "cht", "zh-HK",
"english-uk", "eng", #else
"french-swiss", "frs", "chinese", "zh-CN",
"swiss", "des", "chinese-simplified", "zh-CN",
"german-swiss", "des", "chinese-traditional", "zh-TW",
"italian-swiss", "its", "chs", "zh-CN",
"german-austrian", "dea", "cht", "zh-TW",
"portuguese", "ptb", #endif
"portuguese-brazil", "ptb", "dutch-belgian", "nl-BE",
"spanish-mexican", "esm", "english-nz", "en-NZ",
"norwegian-bokmal", "nor", "uk", "en-GB",
"norwegian-nynorsk", "non", "english-uk", "en-GB",
"spanish-modern", "esn" "french-swiss", "fr-CH",
"swiss", "de-CH",
"german-swiss", "de-CH",
"italian-swiss", "it-CH",
"german-austrian", "de-AT",
"portuguese", "pt-BR",
"portuguese-brazil", "pt-BR",
"spanish-mexican", "es-MX",
"norwegian-bokmal", "nb",
"norwegian-nynorsk", "nn-NO",
"spanish-modern", "es-ES"
}; };
/* INTERNAL: Map a synonym to an ISO code */ /* INTERNAL: Map a synonym to an ISO code */
static void remap_synonym(char *name) static BOOL remap_synonym(char *name)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(_country_synonyms); i += 2) for (i = 0; i < ARRAY_SIZE(_country_synonyms); i += 2)
...@@ -217,9 +228,11 @@ static void remap_synonym(char *name) ...@@ -217,9 +228,11 @@ static void remap_synonym(char *name)
{ {
TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]); TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]);
strcpy(name, _country_synonyms[i+1]); strcpy(name, _country_synonyms[i+1]);
return; return TRUE;
} }
} }
return FALSE;
} }
/* Note: Flags are weighted in order of matching importance */ /* Note: Flags are weighted in order of matching importance */
...@@ -270,7 +283,6 @@ find_best_locale_proc( WCHAR *name, DWORD locale_flags, LPARAM lParam ) ...@@ -270,7 +283,6 @@ find_best_locale_proc( WCHAR *name, DWORD locale_flags, LPARAM lParam )
if (lcid == LOCALE_CUSTOM_UNSPECIFIED) return CONTINUE_LOOKING; if (lcid == LOCALE_CUSTOM_UNSPECIFIED) return CONTINUE_LOOKING;
#if _MSVCR_VER >= 110
if (res->allow_sname && compare_info(lcid,LOCALE_SNAME,buff,res->search_language, TRUE)) if (res->allow_sname && compare_info(lcid,LOCALE_SNAME,buff,res->search_language, TRUE))
{ {
TRACE(":Found locale: %s->%s\n", res->search_language, buff); TRACE(":Found locale: %s->%s\n", res->search_language, buff);
...@@ -278,7 +290,6 @@ find_best_locale_proc( WCHAR *name, DWORD locale_flags, LPARAM lParam ) ...@@ -278,7 +290,6 @@ find_best_locale_proc( WCHAR *name, DWORD locale_flags, LPARAM lParam )
res->found_lang_id = LANGIDFROMLCID(lcid); res->found_lang_id = LANGIDFROMLCID(lcid);
return STOP_LOOKING; return STOP_LOOKING;
} }
#endif
/* Check Language */ /* Check Language */
if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language, TRUE) || if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language, TRUE) ||
...@@ -345,6 +356,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m ...@@ -345,6 +356,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
} else { } else {
WCHAR wbuf[LOCALE_NAME_MAX_LENGTH]; WCHAR wbuf[LOCALE_NAME_MAX_LENGTH];
locale_search_t search; locale_search_t search;
BOOL remapped = FALSE;
memset(&search, 0, sizeof(locale_search_t)); memset(&search, 0, sizeof(locale_search_t));
lstrcpynA(search.search_language, locale, MAX_ELEM_LEN); lstrcpynA(search.search_language, locale, MAX_ELEM_LEN);
...@@ -362,13 +374,17 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m ...@@ -362,13 +374,17 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
search.search_language[cp-locale] = '\0'; search.search_language[cp-locale] = '\0';
} }
if(!cp && !region) if ((remapped = remap_synonym(search.search_language)))
{ {
remap_synonym(search.search_language); search.allow_sname = TRUE;
}
#if _MSVCR_VER >= 110 #if _MSVCR_VER >= 110
if(!cp && !region)
{
search.allow_sname = TRUE; search.allow_sname = TRUE;
#endif
} }
#endif
MultiByteToWideChar(CP_ACP, 0, search.search_language, -1, wbuf, LOCALE_NAME_MAX_LENGTH); MultiByteToWideChar(CP_ACP, 0, search.search_language, -1, wbuf, LOCALE_NAME_MAX_LENGTH);
if (search.allow_sname && IsValidLocaleName(wbuf)) if (search.allow_sname && IsValidLocaleName(wbuf))
...@@ -392,7 +408,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m ...@@ -392,7 +408,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
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 = !remapped && (search.match_flags & FOUND_SNAME) != 0;
} }
/* Obtain code page */ /* Obtain code page */
......
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