]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Move setting of Term::_last_char to Term::_insert
authorTom de Vries <tdevries@suse.de>
Sat, 16 Aug 2025 07:18:45 +0000 (09:18 +0200)
committerTom de Vries <tdevries@suse.de>
Sat, 16 Aug 2025 07:18:45 +0000 (09:18 +0200)
The variable Term::_last_char is meant to represent the last char inserted by
Term::_insert, but setting it is done alongside the only call to _insert in
lib/tuiterm.exp:
...
_insert $expect_out(0,string)
variable _last_char
set _last_char [string index $expect_out(0,string) end]
...

Fix this by moving the setting of _last_char to inside _insert.

Tested on x86_64-linux.

gdb/testsuite/gdb.tui/tuiterm.exp
gdb/testsuite/lib/tuiterm.exp

index 6cd65f3ede7d8573e1fb9bc2319bc25245d628dc..ed9478a67d3292c3982ab78c991cad183fe1d3c8 100644 (file)
@@ -653,13 +653,21 @@ proc test_cursor_backward_tabulation { } {
 }
 
 proc test_repeat { } {
-    Term::_move_cursor 2 1
-    set Term::_last_char X
+    Term::_move_cursor 0 1
+
+    Term::_insert "xxX"
+    gdb_assert { $Term::_last_char == "X"  }
+    check "insert" {
+       "abcdefgh"
+       "xxXlmnop"
+       "qrstuvwx"
+       "yz01234 "
+    } 3 1
 
-    Term::_csi_b 3
+    Term::_csi_b 2
     check "repeat" {
        "abcdefgh"
-       "ijXXXnop"
+       "xxXXXnop"
        "qrstuvwx"
        "yz01234 "
     } 5 1
index 4ef3dc091595947a6a4a1a2f53272bcbd1b0dd1c..d622003624264bbcb2ced4c171c9382a43c5b1d6 100644 (file)
@@ -889,6 +889,9 @@ proc Term::_insert {str} {
                }
            }
        }
+
+       variable _last_char
+       set _last_char [string index $str end]
     }
 }
 
@@ -1042,8 +1045,6 @@ proc Term::accept_gdb_output { } {
        }
        -re "^\[^\x07\x08\x0a\x0d\x1b\]+" {
            _insert $expect_out(0,string)
-           variable _last_char
-           set _last_char [string index $expect_out(0,string) end]
        }
 
        timeout {