public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: locale(1): redefine rule for adding a @euro locale Date: Sat, 25 Feb 2023 19:16:08 +0000 (GMT) [thread overview] Message-ID: <20230225191608.6312C385841A@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6e6111671a1258ead1235c7e129b1f272c67f9e9 commit 6e6111671a1258ead1235c7e129b1f272c67f9e9 Author: Corinna Vinschen <corinna@vinschen.de> AuthorDate: Sat Feb 25 19:43:08 2023 +0100 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Sat Feb 25 19:43:08 2023 +0100 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> Diff: --- winsup/utils/locale.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/winsup/utils/locale.cc b/winsup/utils/locale.cc index 2c7845fc24be..25c4d327023d 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");
reply other threads:[~2023-02-25 19:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230225191608.6312C385841A@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).