kernel32: Also match script name when looking for a locale.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-11-13 19:04:04 +01:00
parent 8b94c5b51c
commit de7e687801

View file

@ -406,6 +406,24 @@ static BOOL CALLBACK find_locale_id_callback( HMODULE hModule, LPCWSTR type,
if (strcmpiW( buffer, data->lang )) return TRUE; if (strcmpiW( buffer, data->lang )) return TRUE;
matches++; /* language name matched */ matches++; /* language name matched */
if (data->script)
{
if (GetLocaleInfoW( lcid, LOCALE_SSCRIPTS | LOCALE_NOUSEROVERRIDE,
buffer, sizeof(buffer)/sizeof(WCHAR) ))
{
const WCHAR *p = buffer;
unsigned int len = strlenW( data->script );
while (*p)
{
if (!strncmpiW( p, data->script, len ) && (!p[len] || p[len] == ';')) break;
if (!(p = strchrW( p, ';'))) goto done;
p++;
}
if (!*p) goto done;
matches++; /* script matched */
}
}
if (data->country) if (data->country)
{ {
if (GetLocaleInfoW( lcid, LOCALE_SISO3166CTRYNAME|LOCALE_NOUSEROVERRIDE, if (GetLocaleInfoW( lcid, LOCALE_SISO3166CTRYNAME|LOCALE_NOUSEROVERRIDE,
@ -489,16 +507,24 @@ static void parse_locale_name( const WCHAR *str, struct locale_name *name )
strcpyW( name->win_name, name->lang ); strcpyW( name->win_name, name->lang );
*p++ = 0; *p++ = 0;
name->country = p; name->country = p;
if (!(p = strpbrkW( p, winsepW ))) goto done; if ((p = strpbrkW( p, winsepW )) && *p == '-')
if (*p == '-')
{ {
*p++ = 0; *p++ = 0;
name->script = name->country; name->script = name->country;
name->country = p; name->country = p;
if (!(p = strpbrkW( p, winsepW ))) goto done; p = strpbrkW( p, winsepW );
}
if (p)
{
*p++ = 0;
name->modifier = p;
}
/* second value can be script or country, check length to resolve the ambiguity */
if (!name->script && strlenW( name->country ) == 4)
{
name->script = name->country;
name->country = NULL;
} }
*p++ = 0;
name->modifier = p;
} }
else /* Unix format */ else /* Unix format */
{ {