]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pty: Change the timing of set_locale() call again.
authorTakashi Yano via Cygwin-patches <cygwin-patches@cygwin.com>
Sat, 15 Aug 2020 03:23:52 +0000 (12:23 +0900)
committerCorinna Vinschen <corinna@vinschen.de>
Mon, 17 Aug 2020 09:12:59 +0000 (11:12 +0200)
- After commit 095972ce5b1d319915501a7e381802914bed790c, charset
  conversion in mintty is broken if charset is set to other than
  UTF-8. This seems to be caused because mintty does not set locale
  yet at fork() call. This patch changes the timing of set_locale()
  call again to avoid this issue.

winsup/cygwin/fhandler_tty.cc
winsup/cygwin/spawn.cc

index 40b79bfbba1d187000f28a8a1199dc629f37c3f5..6294e2c20a551b29ca6e178cc77fa25bb622512f 100644 (file)
@@ -2852,6 +2852,9 @@ get_langinfo (char *locale_out, char *charset_out)
 void
 fhandler_pty_slave::setup_locale (void)
 {
+  if (get_ttyp ()->term_code_page != 0)
+    return;
+
   char locale[ENCODING_LEN + 1] = "C";
   char charset[ENCODING_LEN + 1] = "ASCII";
   LCID lcid = get_langinfo (locale, charset);
@@ -2983,10 +2986,6 @@ fhandler_pty_slave::fixup_after_fork (HANDLE parent)
   // fork_fixup (parent, inuse, "inuse");
   // fhandler_pty_common::fixup_after_fork (parent);
   report_tty_counts (this, "inherited", "");
-
-  /* Set locale */
-  if (get_ttyp ()->term_code_page == 0)
-    setup_locale ();
 }
 
 void
@@ -3024,6 +3023,9 @@ fhandler_pty_slave::fixup_after_exec ()
        }
     }
 
+  /* Set locale */
+  setup_locale ();
+
   /* Hook Console API */
   if (get_pseudo_console ())
     {
index e70ceb86d6c935dca3c1891081446051ed95b222..af177c0f13e0f02435c9d3e1002384f50926774f 100644 (file)
@@ -628,6 +628,18 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
            }
        }
 
+      if (!iscygwin ())
+       {
+         cfd.rewind ();
+         while (cfd.next () >= 0)
+           if (cfd->get_major () == DEV_PTYS_MAJOR)
+             {
+               fhandler_pty_slave *ptys =
+                 (fhandler_pty_slave *)(fhandler_base *) cfd;
+               ptys->setup_locale ();
+             }
+       }
+
       /* Set up needed handles for stdio */
       si.dwFlags = STARTF_USESTDHANDLES;
       si.hStdInput = handle ((in__stdin < 0 ? 0 : in__stdin), false,
This page took 0.036338 seconds and 5 git commands to generate.