From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id CD9B93858D32; Sun, 26 Mar 2023 12:18:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD9B93858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679833081; bh=6zqpU/EMr9S7BBbxuV5mey2EYa/WX7uEGKlG9dycwJc=; h=From:To:Subject:Date:From; b=G7cSGWgjy2iXC32sUY5zDbiojDcX6PI/vMwwCU6c5hrbkbD8DvV4sqIl1EYJxiGdL JxwA1y/LeD/Ua3xnEne6H5AaoJjkKEO2D0p693IyRG2Ofxbx6fmNEJ+JJXXJiTlS3P 2Y/l8qqZaCdPl1lbGj0a7mpcDLx89KeJv96dBHlM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: /proc/locales: use modifier when checking default codeset X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: a97fbb58e209586f92381e90aaec8fb211287938 X-Git-Newrev: 4e578fad7927b074837475ccbff698a20742f78d Message-Id: <20230326121801.CD9B93858D32@sourceware.org> Date: Sun, 26 Mar 2023 12:18:01 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D4e578fad792= 7b074837475ccbff698a20742f78d commit 4e578fad7927b074837475ccbff698a20742f78d Author: Corinna Vinschen AuthorDate: Sun Mar 26 12:50:57 2023 +0200 Commit: Corinna Vinschen CommitDate: Sun Mar 26 12:51:28 2023 +0200 Cygwin: /proc/locales: use modifier when checking default codeset =20 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. =20 Fixes: c42b98bdc665f ("Cygwin: introduce /proc/codesets and /proc/local= es") Signed-off-by: Corinna Vinschen 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 inf= o, LPARAM param) wchar_t currency[9] =3D { 0 }; char modifier[32] =3D { 0 }; char posix_loc[32]; - char *codeset; - locale_t loc; + char posix_loc_and_modifier[32]; + char codeset[32]; wchar_t *cp; =20 /* Skip language-only locales, e. g. "en" */ @@ -2236,8 +2236,8 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD inf= o, LPARAM param) wcstombs (modifier + 1, iso15924_postfix, 31); } =20 - loc =3D newlocale (LC_CTYPE_MASK, posix_loc, (locale_t) 0); - codeset =3D 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 =3D add_locale (*bufptr_p, posix_loc, codeset, false, modifier, win_locale); *bufptr_p =3D add_locale (*bufptr_p, posix_loc, "UTF-8", true, modifier, @@ -2270,12 +2270,13 @@ format_proc_locale_proc (LPWSTR win_locale, DWORD i= nfo, LPARAM param) else return TRUE; =20 + stpcpy (stpcpy (posix_loc_and_modifier, posix_loc), modifier); + __set_charset_from_locale (posix_loc_and_modifier, codeset); *bufptr_p =3D add_locale (*bufptr_p, posix_loc, codeset, false, modifier, win_locale); *bufptr_p =3D add_locale (*bufptr_p, posix_loc, "UTF-8", true, modifier, win_locale); =20 - freelocale (loc); return TRUE; }