summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Yano via Cygwin-patches <cygwin-patches@cygwin.com>2020-11-23 20:03:03 +0900
committerCorinna Vinschen <corinna@vinschen.de>2020-11-23 16:23:27 +0100
commit2eee095928285ea7695f4d7d74153deff6fb9e3d (patch)
treef5499aa06a18d32fe2139fbfcfcf3343869215c3
parent65ee05d326ddbbc5cb60668bc5b9d631fa72ede8 (diff)
downloadcygnal-2eee095928285ea7695f4d7d74153deff6fb9e3d.tar.gz
cygnal-2eee095928285ea7695f4d7d74153deff6fb9e3d.tar.bz2
cygnal-2eee095928285ea7695f4d7d74153deff6fb9e3d.zip
Cygwin: pty: Discard "OSC Ps; ? BEL/ST" in pseudo console output.
- If vim is executed in WSL in mintty, some garbage string caused by "OSC Ps;? BEL/ST" will be shown in some situations. This patch fixes the issue by removing "OSC Ps;? BEL/ST" from pseudo console output.
-rw-r--r--winsup/cygwin/fhandler_tty.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 911945675..82ad9d6f4 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2069,6 +2069,36 @@ fhandler_pty_master::pty_master_fwd_thread ()
else
state = 0;
+ /* Remove OSC Ps ; ? BEL/ST */
+ for (DWORD i = 0; i < rlen; i++)
+ if (state == 0 && outbuf[i] == '\033')
+ {
+ start_at = i;
+ state = 1;
+ continue;
+ }
+ else if ((state == 1 && outbuf[i] == ']')
+ || (state == 2 && outbuf[i] == ';')
+ || (state == 3 && outbuf[i] == '?')
+ || (state == 4 && outbuf[i] == '\033'))
+ {
+ state ++;
+ continue;
+ }
+ else if (state == 2 && isdigit (outbuf[i]))
+ continue;
+ else if ((state == 4 && outbuf[i] == '\a')
+ || (state == 5 && outbuf[i] == '\\'))
+ {
+ memmove (&outbuf[start_at], &outbuf[i+1], rlen-i-1);
+ rlen = wlen = start_at + rlen - i - 1;
+ state = 0;
+ i = start_at - 1;
+ continue;
+ }
+ else
+ state = 0;
+
if (get_ttyp ()->term_code_page != CP_UTF8)
{
size_t nlen = NT_MAX_PATH;