This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit 677fd17b17761311e03900f04c5544b9bcf140c7
Author: Boris Faure <[email protected]>
AuthorDate: Wed Nov 4 22:36:29 2026 +0000

    termptyesc: keep C0 controls out of the CSI parameters
    
    A C0 control within a CSI is executed and is not part of the sequence
    (https://vt100.net/emu/dec_ansi_parser). Terminology also kept it in
    the parameters, where it split them: \033[1\r5C moved the cursor 1
    column instead of 15.
    
    csi-c0.sh changes checksum: its first SGR, 1\n\n\n32, was read as
    1;32 and is now 132, so the test now gives parameters that mean
    something once the controls are taken out. The tybench sgr corpus is
    no slower.
---
 src/bin/termptyesc.c | 25 +++++++++++++++++--------
 tests/csi-c0.sh      | 16 ++++++++++------
 tests/tests.results  |  2 +-
 3 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 2b41f1d9..95efb0f5 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -3701,20 +3701,23 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
 {
    const Eina_Unicode *cc, *be;
    Eina_Unicode buf[4096], *b;
+   const Eina_Unicode *ccmax = c + sizeof(buf) / sizeof(buf[0]);
    unsigned int scanned = ty->seq_scanned;
 
    ty->seq_scanned = 0;
    cc = c + scanned;
-   b = buf + scanned;
-   be = buf + sizeof(buf) / sizeof(buf[0]);
-   while ((cc < ce) && (*cc <= '?') && (b < be))
+   b = buf;
+   /* C0 controls are executed and are not part of the sequence, as in the
+    * DEC parser: https://vt100.net/emu/dec_ansi_parser */
+   while ((cc < ce) && (*cc <= '?') && (cc < ccmax))
      {
-        _handle_cursor_control(ty, cc);
-        *b = *cc;
-        b++;
+        if (*cc < ' ')
+          _handle_cursor_control(ty, cc);
+        else if (!scanned)
+          *b++ = *cc;
         cc++;
      }
-   if (b == be)
+   if (cc == ccmax)
      {
         ERR("csi parsing overflowed, skipping the whole buffer (binary data?)");
         return cc - c;
@@ -3722,7 +3725,13 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
    if (cc == ce)
      return _seq_incomplete(ty, c, cc);
    if (scanned)
-     memcpy(buf, c, scanned * sizeof(Eina_Unicode));
+     {
+        const Eina_Unicode *p;
+
+        for (p = c; p < cc; p++)
+          if (*p >= ' ')
+            *b++ = *p;
+     }
    *b = 0;
    be = b;
    b = buf;
diff --git a/tests/csi-c0.sh b/tests/csi-c0.sh
index 56749bec..308e890a 100644
--- a/tests/csi-c0.sh
+++ b/tests/csi-c0.sh
@@ -2,7 +2,8 @@
 # shellcheck source=tests/utils.sh
 . "$(dirname "$0")/utils.sh"
 
-# C0 controls within a CSI are executed once, wherever the reads split it
+# C0 controls within a CSI are executed once, wherever the reads split it,
+# and are not part of its parameters
 
 # clear screen
 printf '\033[2J'
@@ -10,17 +11,20 @@ printf '\033[2J'
 # move to 0; 0
 printf '\033[0;0H'
 
-# three LFs within a SGR
-printf '\033[1\n\n\n32mA'
+# three LFs within a SGR 32
+printf '\033[3\n\n\n2mA'
 
-# a BS and a HT within a SGR
+# a BS and a HT within a SGR 0
 printf '\033[\b\t0mB'
 
-# LFs within a CSI longer than a read, ended by a SGR
+# a CR within a CUF 15
+printf '\033[1\r5CC'
+
+# LFs within a CSI longer than a read, whose last parameter is 31
 printf '\033[3'
 i=0
 while [ $i -lt 64 ]; do
     printf ';3'
     i=$((i + 1))
 done
-printf "\n\n1mC"
+printf '\n\n1mD'
diff --git a/tests/tests.results b/tests/tests.results
index a5ef5064..5dd40440 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -208,6 +208,6 @@ dcs-cancel.sh 5802db97bcbf6f2ab0d8e49723fcfea8
 dcs-long.sh 56028fb44070f1bf64f323f751f0d79a
 backlog-long-line.sh f4423fa1c7069b9bf8a62045cc97dda3
 ty-escape-long.sh 83d61b472b818eb3d699021e14e45452
-csi-c0.sh 68f5a8be4feacac8b7b8d4d5b9b026af
+csi-c0.sh eae470a815753e4af0a094089ca16fc9
 dcs-full-buffer.sh f4cb1513ca59539f373e8d389e6ac01d
 osc-long.sh a94cb70dd58d07f52bbdf0cc5e7b95e1

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to