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: locales: fix behaviour for @cjk* and @euro locales
Date: Sun, 26 Mar 2023 12:18:11 +0000 (GMT)	[thread overview]
Message-ID: <20230326121811.DEA24385840A@sourceware.org> (raw)

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

commit c3e7f7609e46383ee7952f6ab3345abfb535d7a4
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Sun Mar 26 13:01:52 2023 +0200
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Sun Mar 26 13:01:52 2023 +0200

    Cygwin: locales: fix behaviour for @cjk* and @euro locales
    
    @cjknarrow and @cjkwide modifiers are newlib only, so they need
    some tweaking in __set_charset_from_locale.
    
    Fixes: 2483e54be852e ("Cygwin: locale: Set default charset from Linux locale -> codeset mapping")
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/nlsfuncs.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc
index ee44de03e5f6..6821a43c3fb7 100644
--- a/winsup/cygwin/nlsfuncs.cc
+++ b/winsup/cygwin/nlsfuncs.cc
@@ -1528,7 +1528,7 @@ __set_charset_from_locale (const char *loc, char *charset)
 {
   wchar_t win_locale[ENCODING_LEN + 1];
   char locale[ENCODING_LEN + 1];
-  const char *modifier;
+  char *modifier;
   char *c;
   UINT cp;
 
@@ -1537,6 +1537,12 @@ __set_charset_from_locale (const char *loc, char *charset)
   modifier = strchr (loc, '@');
   if ((c = strchr (locale, '.')))
     stpcpy (c, modifier ?: "");
+  /* Cut out @cjknarrow/@cjkwide modifier, both are newlib specials and
+    don't affect the codeset. */
+  modifier = strchr (locale, '@');
+  if (modifier && (!strcmp (modifier + 1, "cjknarrow")
+		   || !strcmp (modifier + 1, "cjkwide")))
+    *modifier = '\0';
 
   default_codeset_t srch_dc = { locale, NULL };
   default_codeset_t *dc = (default_codeset_t *)

                 reply	other threads:[~2023-03-26 12:18 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=20230326121811.DEA24385840A@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).