From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 20F84385041C; Wed, 9 Sep 2020 21:44:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20F84385041C Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pty: Fix input charset for non-cygwin apps with disable_pcon. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano via Cygwin-patches X-Git-Refname: refs/heads/master X-Git-Oldrev: 91908fe00096d0979dd021599865a1ad02179078 X-Git-Newrev: fd3ad92f9ee1e6f58ffe3597fbd5bba3c778677d Message-Id: <20200909214449.20F84385041C@sourceware.org> Date: Wed, 9 Sep 2020 21:44:49 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2020 21:44:49 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=fd3ad92f9ee1e6f58ffe3597fbd5bba3c778677d commit fd3ad92f9ee1e6f58ffe3597fbd5bba3c778677d Author: Takashi Yano via Cygwin-patches Date: Thu Sep 10 00:28:00 2020 +0900 Cygwin: pty: Fix input charset for non-cygwin apps with disable_pcon. - If the non-cygwin apps is executed under pseudo console disabled, multibyte input for the apps are garbled. This patch fixes the issue. Diff: --- winsup/cygwin/fhandler_tty.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 0bfc32ea9..16d4a99f4 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -295,8 +295,22 @@ fhandler_pty_master::accept_input () bytes_left = eat_readahead (-1); HANDLE write_to = get_output_handle (); + tmp_pathbuf tp; if (to_be_read_from_pcon ()) - write_to = to_slave; + { + write_to = to_slave; + UINT cp_to = GetConsoleCP (); + if (get_ttyp ()->term_code_page != cp_to) + { + static mbstate_t mbp; + char *mbbuf = tp.c_get (); + size_t nlen = NT_MAX_PATH; + convert_mb_str (cp_to, mbbuf, &nlen, + get_ttyp ()->term_code_page, p, bytes_left, &mbp); + p = mbbuf; + bytes_left = nlen; + } + } if (!bytes_left) {