Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2023-02-25 21:43:08 +0300
committerCorinna Vinschen <corinna@vinschen.de>2023-02-25 21:43:08 +0300
commit6e6111671a1258ead1235c7e129b1f272c67f9e9 (patch)
tree20a34038f0214cb76516f50ba1d0469cdd661a56 /winsup/utils/locale.cc
parent2483e54be852e66d1a96a0da2af8324b51ef8b65 (diff)
Cygwin: locale(1): redefine rule for adding a @euro locale
The @euro locale is only useful, if the locale uses the EUR currency and the codeset of the base locale is ISO-8859-1, or the locale is el_GR. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/utils/locale.cc')
-rw-r--r--winsup/utils/locale.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/winsup/utils/locale.cc b/winsup/utils/locale.cc
index 2c7845fc2..25c4d3270 100644
--- a/winsup/utils/locale.cc
+++ b/winsup/utils/locale.cc
@@ -221,7 +221,7 @@ compare_locales (const void *a, const void *b)
return strcmp (la->name, lb->name);
}
-void
+size_t
add_locale (const char *name, const wchar_t *language, const wchar_t *territory,
bool alias = false)
{
@@ -246,7 +246,7 @@ add_locale (const char *name, const wchar_t *language, const wchar_t *territory,
locale[loc_num].codeset = strdup (nl_langinfo (CODESET));
setlocale (LC_CTYPE, orig_locale);
locale[loc_num].alias = alias;
- ++loc_num;
+ return loc_num++;
}
void
@@ -304,7 +304,6 @@ print_all_locales_proc (LPWSTR loc_name, DWORD info, LPARAM param)
wchar_t iso639[32] = { 0 };
wchar_t iso3166[32] = { 0 };
wchar_t iso15924[32] = { 0 };
- DWORD cp;
#if 0
struct {
@@ -391,18 +390,18 @@ print_all_locales_proc (LPWSTR loc_name, DWORD info, LPARAM param)
/* Print */
GetLocaleInfoEx (loc_name, LOCALE_SENGLISHLANGUAGENAME, language, 256);
GetLocaleInfoEx (loc_name, LOCALE_SENGLISHCOUNTRYNAME, country, 256);
- add_locale (posix_loc, language, country);
+ size_t idx = add_locale (posix_loc, language, country);
/* Check for locales sporting an additional modifier for
changing the codeset and other stuff. */
if (!wcscmp (iso639, L"be") && !wcscmp (iso3166, L"BY"))
stpcpy (c, "@latin");
if (!wcscmp (iso639, L"tt") && !wcscmp (iso3166, L"RU"))
stpcpy (c, "@iqtelif");
- else if (GetLocaleInfoEx (loc_name,
- LOCALE_IDEFAULTANSICODEPAGE
- | LOCALE_RETURN_NUMBER,
- (PWCHAR) &cp, sizeof cp)
- && cp == 1252 /* Latin1*/
+ /* 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
+ a greek @euro locale, albeit it doesn't change the codeset. */
+ else if ((!strcmp (locale[idx].codeset, "ISO-8859-1")
+ || !strcmp (posix_loc, "el_GR"))
&& GetLocaleInfoEx (loc_name, LOCALE_SINTLSYMBOL, currency, 9)
&& !wcsncmp (currency, L"EUR", 3))
stpcpy (c, "@euro");