public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: /proc/locales: use modifier when checking default codeset
@ 2023-03-26 12:18 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-03-26 12:18 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 4e578fad7927b074837475ccbff698a20742f78d
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Sun Mar 26 12:50:57 2023 +0200
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Sun Mar 26 12:51:28 2023 +0200

    Cygwin: /proc/locales: use modifier when checking default codeset
    
    Drop usage of newlocale/nl_langinfo_l/freelocale.
    Call __set_charset_from_locale instead, and make sure to call it
    with modifier, if any, otherwise suffer wrong results.
    
    Fixes: c42b98bdc665f ("Cygwin: introduce /proc/codesets and /proc/locales")
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/proc.cc | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc
index b74c58a11d77..e0e05f1c1707 100644
--- a/winsup/cygwin/fhandler/proc.cc
+++ b/winsup/cygwin/fhandler/proc.cc
@@ -2121,8 +2121,8 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD info, LPARAM param)
   wchar_t currency[9] = { 0 };
   char modifier[32] = { 0 };
   char posix_loc[32];
-  char *codeset;
-  locale_t loc;
+  char posix_loc_and_modifier[32];
+  char codeset[32];
   wchar_t *cp;
 
   /* Skip language-only locales, e. g. "en" */
@@ -2236,8 +2236,8 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD info, LPARAM param)
       wcstombs (modifier + 1, iso15924_postfix, 31);
     }
 
-  loc = newlocale (LC_CTYPE_MASK, posix_loc, (locale_t) 0);
-  codeset = nl_langinfo_l (CODESET, loc);
+  stpcpy (stpcpy (posix_loc_and_modifier, posix_loc), modifier);
+  __set_charset_from_locale (posix_loc_and_modifier, codeset);
   *bufptr_p = add_locale (*bufptr_p, posix_loc, codeset, false, modifier,
 			  win_locale);
   *bufptr_p = add_locale (*bufptr_p, posix_loc, "UTF-8", true, modifier,
@@ -2270,12 +2270,13 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD info, LPARAM param)
   else
     return TRUE;
 
+  stpcpy (stpcpy (posix_loc_and_modifier, posix_loc), modifier);
+  __set_charset_from_locale (posix_loc_and_modifier, codeset);
   *bufptr_p = add_locale (*bufptr_p, posix_loc, codeset, false, modifier,
 			  win_locale);
   *bufptr_p = add_locale (*bufptr_p, posix_loc, "UTF-8", true, modifier,
 			  win_locale);
 
-  freelocale (loc);
   return TRUE;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-26 12:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-26 12:18 [newlib-cygwin/main] Cygwin: /proc/locales: use modifier when checking default codeset Corinna Vinschen

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).