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: Discard "OSC Ps; ? BEL/ST" in pseudo console output. Date: Mon, 23 Nov 2020 15:23:56 +0000 (GMT) [thread overview] Message-ID: <20201123152356.3ECE8385481C@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2eee095928285ea7695f4d7d74153deff6fb9e3d commit 2eee095928285ea7695f4d7d74153deff6fb9e3d Author: Takashi Yano via Cygwin-patches <cygwin-patches@cygwin.com> Date: Mon Nov 23 20:03:03 2020 +0900 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. Diff: --- winsup/cygwin/fhandler_tty.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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;
reply other threads:[~2020-11-23 15:23 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=20201123152356.3ECE8385481C@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).