Cygwin: /proc/locales: fix sd_IN locale

Due to the way locales are evaluated in Windows, we can't ask for
the script of the "sd-IN" locale, because Windows only knows the
"sd-Deva-IN" locale.  So asking for the script of the "sd" locale
returns "Arab;", because "sd" is converted to "sd-Arab-PK".

Special case "sd-IN" to workaround that issue.

Fixes: c42b98bdc6 ("Cygwin: introduce /proc/codesets and /proc/locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-03-24 11:47:23 +01:00
parent 606373e7d2
commit 9296f134fb
1 changed files with 8 additions and 1 deletions

View File

@ -2193,6 +2193,11 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD info, LPARAM param)
else else
return TRUE; return TRUE;
} }
/* "sd-IN" is no valid Windows locale, only "sd-Deva-IN" is. However,
asking for LOCALE_SSCRIPTS below returns "Arab;" because the first "sd"
locale Windows finds is "sd-Arab-PK", so we have to override this here. */
else if (!wcscmp (iso639, L"sd") && !wcscmp (iso3166, L"IN"))
strcpy (posix_loc, "sd_IN");
/* In all other cases, we check if the script from the Windows /* In all other cases, we check if the script from the Windows
locale is the default locale in that language. If not, we locale is the default locale in that language. If not, we
add it as modifier if possible, or skip it */ add it as modifier if possible, or skip it */
@ -2242,8 +2247,10 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD info, LPARAM param)
changing the codeset and other stuff. */ changing the codeset and other stuff. */
if (!wcscmp (iso639, L"be") && !wcscmp (iso3166, L"BY")) if (!wcscmp (iso639, L"be") && !wcscmp (iso3166, L"BY"))
stpcpy (modifier, "@latin"); stpcpy (modifier, "@latin");
if (!wcscmp (iso639, L"tt") && !wcscmp (iso3166, L"RU")) else if (!wcscmp (iso639, L"tt") && !wcscmp (iso3166, L"RU"))
stpcpy (modifier, "@iqtelif"); stpcpy (modifier, "@iqtelif");
else if (!wcscmp (iso639, L"sd") && !wcscmp (iso3166, L"IN"))
stpcpy (modifier, "@devanagari");
/* If the base locale is ISO-8859-1 and the locale defines currency /* If the base locale is ISO-8859-1 and the locale defines currency
as EUR, add a @euro locale. For historical reasons there's also as EUR, add a @euro locale. For historical reasons there's also
a greek @euro locale, albeit it doesn't change the codeset. */ a greek @euro locale, albeit it doesn't change the codeset. */