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] Cygwin: pty: Revise the code for setting code page of pseudo console. Date: Mon, 13 Jan 2020 16:00:00 -0000 [thread overview] Message-ID: <20200113160039.65332.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b3e78186d107c3cf6cabad4fc18ee829f2b279f4 commit b3e78186d107c3cf6cabad4fc18ee829f2b279f4 Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Wed Jan 1 15:50:36 2020 +0900 Cygwin: pty: Revise the code for setting code page of pseudo console. - Fix the problem which overrides the code page setting, reported in https://www.cygwin.com/ml/cygwin/2019-12/msg00292.html. Diff: --- winsup/cygwin/fhandler_tty.cc | 52 +++++++++++++++++++++---------------------- winsup/cygwin/release/3.1.3 | 3 +++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index a235ea7..0837b63 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -2629,39 +2629,36 @@ fhandler_pty_slave::setup_locale (void) if (lcid == 0 || lcid == (LCID) -1) code_page = 20127; /* ASCII */ else if (!GetLocaleInfo (lcid, - LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, + LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER, (char *) &code_page, sizeof (code_page))) code_page = 20127; /* ASCII */ SetConsoleCP (code_page); SetConsoleOutputCP (code_page); - if (get_ttyp ()->term_code_page == 0) - { - /* Set terminal code page from locale */ - /* This code is borrowed from mintty: charset.c */ - get_ttyp ()->term_code_page = 20127; /* Default ASCII */ - char charset_u[ENCODING_LEN + 1] = {0, }; - for (int i=0; charset[i] && i<ENCODING_LEN; i++) - charset_u[i] = toupper (charset[i]); - unsigned int iso; - UINT cp = 20127; /* Default for fallback */ - if (sscanf (charset_u, "ISO-8859-%u", &iso) == 1 || - sscanf (charset_u, "ISO8859-%u", &iso) == 1 || - sscanf (charset_u, "ISO8859%u", &iso) == 1) + /* Set terminal code page from locale */ + /* This code is borrowed from mintty: charset.c */ + get_ttyp ()->term_code_page = 20127; /* Default ASCII */ + char charset_u[ENCODING_LEN + 1] = {0, }; + for (int i=0; charset[i] && i<ENCODING_LEN; i++) + charset_u[i] = toupper (charset[i]); + unsigned int iso; + UINT cp = 20127; /* Default for fallback */ + if (sscanf (charset_u, "ISO-8859-%u", &iso) == 1 || + sscanf (charset_u, "ISO8859-%u", &iso) == 1 || + sscanf (charset_u, "ISO8859%u", &iso) == 1) + { + if (iso && iso <= 16 && iso !=12) + get_ttyp ()->term_code_page = 28590 + iso; + } + else if (sscanf (charset_u, "CP%u", &cp) == 1) + get_ttyp ()->term_code_page = cp; + else + for (int i=0; cs_names[i].cp; i++) + if (strcasecmp (charset_u, cs_names[i].name) == 0) { - if (iso && iso <= 16 && iso !=12) - get_ttyp ()->term_code_page = 28590 + iso; + get_ttyp ()->term_code_page = cs_names[i].cp; + break; } - else if (sscanf (charset_u, "CP%u", &cp) == 1) - get_ttyp ()->term_code_page = cp; - else - for (int i=0; cs_names[i].cp; i++) - if (strcasecmp (charset_u, cs_names[i].name) == 0) - { - get_ttyp ()->term_code_page = cs_names[i].cp; - break; - } - } } void @@ -2792,7 +2789,8 @@ fhandler_pty_slave::fixup_after_exec () } /* Set locale */ - setup_locale (); + if (get_ttyp ()->term_code_page == 0) + setup_locale (); #if USE_API_HOOK /* Hook Console API */ diff --git a/winsup/cygwin/release/3.1.3 b/winsup/cygwin/release/3.1.3 index d698b44..0fcdcca 100644 --- a/winsup/cygwin/release/3.1.3 +++ b/winsup/cygwin/release/3.1.3 @@ -3,3 +3,6 @@ Bug Fixes - Define CPU_SETSIZE, as on Linux. Addresses: https://cygwin.com/ml/cygwin/2019-12/msg00248.html + +- Fix the problem which overrides the code page setting. + Addresses: https://www.cygwin.com/ml/cygwin/2019-12/msg00292.html
reply other threads:[~2020-01-13 16:00 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=20200113160039.65332.qmail@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).