summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2020-01-01 15:50:36 +0900
committerCorinna Vinschen <corinna@vinschen.de>2020-01-13 17:00:14 +0100
commitb3e78186d107c3cf6cabad4fc18ee829f2b279f4 (patch)
tree79412079c6de45d9f5a0bff6b2ad9e028c927f41
parentfd03749b9c255d6f78d71c65fb4f49d8f766a629 (diff)
downloadcygnal-b3e78186d107c3cf6cabad4fc18ee829f2b279f4.tar.gz
cygnal-b3e78186d107c3cf6cabad4fc18ee829f2b279f4.tar.bz2
cygnal-b3e78186d107c3cf6cabad4fc18ee829f2b279f4.zip
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.
-rw-r--r--winsup/cygwin/fhandler_tty.cc52
-rw-r--r--winsup/cygwin/release/3.1.33
2 files changed, 28 insertions, 27 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index a235ea708..0837b63e1 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 d698b444d..0fcdccabb 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