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: /proc/locales: fix sd_IN locale
Date: Fri, 24 Mar 2023 11:52:01 +0000 (GMT)	[thread overview]
Message-ID: <20230324115201.E96E6384D18E@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9296f134fb5aa808893d5bbf68b84d6b1edc193b

commit 9296f134fb5aa808893d5bbf68b84d6b1edc193b
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Mar 24 11:47:23 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Mar 24 12:50:59 2023 +0100

    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: c42b98bdc665 ("Cygwin: introduce /proc/codesets and /proc/locales")
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/proc.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc
index d5e3c60fcf1a..3dc0421a53b4 100644
--- a/winsup/cygwin/fhandler/proc.cc
+++ b/winsup/cygwin/fhandler/proc.cc
@@ -2193,6 +2193,11 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD info, LPARAM param)
       else
 	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
      locale is the default locale in that language.  If not, we
      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. */
   if (!wcscmp (iso639, L"be") && !wcscmp (iso3166, L"BY"))
     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");
+  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
       as EUR, add a @euro locale. For historical reasons there's also
       a greek @euro locale, albeit it doesn't change the codeset. */

                 reply	other threads:[~2023-03-24 11:52 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=20230324115201.E96E6384D18E@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: link
Be 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).