https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9dfed83bdc748ccb55988c78ae373270e259369c

commit 9dfed83bdc748ccb55988c78ae373270e259369c
Author: Takashi Yano <[email protected]>
Date:   Wed Dec 10 10:01:24 2025 +0900

    Cygwin: pty: Allow ST as a termination in pty_master_fwd_thread
    
    In the ESC sequence parser in pty_master_fwd_thread, the termination
    ST (ESC \) was not supported for title set ESC sequence, that is, only
    BEL was detected. This patch allows ST as a termination.
    
    Fixes: 10d083c745dd ("Cygwin: pty: Inherit typeahead data between two input 
pipes.")
    Reviewed-by: Corinna Vinschen <[email protected]>, Johannes Schindelin 
<[email protected]>
    Signed-off-by: Takashi Yano <[email protected]>
    (cherry picked from commit f840dd0a0b11498cdc206c8ad48df1975d511209)

Diff:
---
 winsup/cygwin/fhandler/pty.cc | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index d2a9f3b79..a7d2bb42e 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -2659,7 +2659,7 @@ fhandler_pty_master::pty_master_fwd_thread (const 
master_fwd_thread_param_t *p)
          int state = 0;
          int start_at = 0;
          for (DWORD i=0; i<rlen; i++)
-           if (outbuf[i] == '\033')
+           if (state == 0 && outbuf[i] == '\033')
              {
                start_at = i;
                state = 1;
@@ -2667,12 +2667,14 @@ fhandler_pty_master::pty_master_fwd_thread (const 
master_fwd_thread_param_t *p)
              }
            else if ((state == 1 && outbuf[i] == ']') ||
                     (state == 2 && outbuf[i] == '0') ||
-                    (state == 3 && outbuf[i] == ';'))
+                    (state == 3 && outbuf[i] == ';') ||
+                    (state == 4 && outbuf[i] == '\033'))
              {
                state ++;
                continue;
              }
-           else if (state == 4 && outbuf[i] == '\a')
+           else if ((state == 4 && outbuf[i] == '\a')
+                    || (state == 5 && outbuf[i] == '\\'))
              {
                const char *helper_str = "\\bin\\cygwin-console-helper.exe";
                if (memmem (&outbuf[start_at], i + 1 - start_at,
@@ -2685,7 +2687,9 @@ fhandler_pty_master::pty_master_fwd_thread (const 
master_fwd_thread_param_t *p)
                state = 0;
                continue;
              }
-           else if (outbuf[i] == '\a')
+           else if (state == 4)
+             continue;
+           else
              {
                state = 0;
                continue;

Reply via email to