[PATCH v2 0/3] Three pty fixes regarding pseudo console.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH v2 0/3] Three pty fixes regarding pseudo console.

cygwin-patches mailing list
Takashi Yano (3):
  Cygwin: pty: Fix a bug in the code removing "CSI > Pm m".
  Cygwin: pty: Discard "OSC Ps;? BEL/ST" in pseudo console output.
  Cygwin: pty: Fix minor style issue.

 winsup/cygwin/fhandler_tty.cc | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

--
2.29.2

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 1/3] Cygwin: pty: Fix a bug in the code removing "CSI > Pm m".

cygwin-patches mailing list
- The code added by 8121b606e843c001d5ca5213d24099e04ebc62ca has a
  bug which fails to remove multiple "CSI > Pm m" sequences. This
  patch fixes the bug.
---
 winsup/cygwin/fhandler_tty.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 600de085c..911945675 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2063,6 +2063,7 @@ fhandler_pty_master::pty_master_fwd_thread ()
  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
--
2.29.2

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 2/3] Cygwin: pty: Discard "OSC Ps; ? BEL/ST" in pseudo console output.

cygwin-patches mailing list
In reply to this post by cygwin-patches mailing list
- 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.
---
 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..3d58cc7df 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;
--
2.29.2

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 3/3] Cygwin: pty: Fix minor style issue.

cygwin-patches mailing list
In reply to this post by cygwin-patches mailing list
---
 winsup/cygwin/fhandler_tty.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 3d58cc7df..422d7349d 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2043,7 +2043,7 @@ fhandler_pty_master::pty_master_fwd_thread ()
   /* Remove CSI > Pm m */
   int state = 0;
   int start_at = 0;
-  for (DWORD i=0; i<rlen; i++)
+  for (DWORD i = 0; i < rlen; i ++)
     if (outbuf[i] == '\033')
       {
  start_at = i;
--
2.29.2

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 0/3] Three pty fixes regarding pseudo console.

Corinna Vinschen-2
In reply to this post by cygwin-patches mailing list
On Nov 23 20:03, Takashi Yano via Cygwin-patches wrote:

> Takashi Yano (3):
>   Cygwin: pty: Fix a bug in the code removing "CSI > Pm m".
>   Cygwin: pty: Discard "OSC Ps;? BEL/ST" in pseudo console output.
>   Cygwin: pty: Fix minor style issue.
>
>  winsup/cygwin/fhandler_tty.cc | 33 ++++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
>
> --
> 2.29.2

Pushed (with minor minor style issue reverted, i ++ --> i++.


Thanks,
Corinna