From de7e687801e3e66c27c0b9822767e37f52d93c09 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 13 Nov 2017 19:04:04 +0100 Subject: [PATCH] kernel32: Also match script name when looking for a locale. Signed-off-by: Alexandre Julliard --- dlls/kernel32/locale.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c index 64966e540cd..47d0c8972b0 100644 --- a/dlls/kernel32/locale.c +++ b/dlls/kernel32/locale.c @@ -406,6 +406,24 @@ static BOOL CALLBACK find_locale_id_callback( HMODULE hModule, LPCWSTR type, if (strcmpiW( buffer, data->lang )) return TRUE; 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 (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 ); *p++ = 0; name->country = p; - if (!(p = strpbrkW( p, winsepW ))) goto done; - if (*p == '-') + if ((p = strpbrkW( p, winsepW )) && *p == '-') { *p++ = 0; name->script = name->country; 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 */ {