From: Tom de Vries Date: Sat, 16 Aug 2025 07:18:45 +0000 (+0200) Subject: [gdb/testsuite] Move setting of Term::_last_char to Term::_insert X-Git-Tag: gdb-17-branchpoint~281 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96265ee7fa3fcc3532a323cac74e3828df331114;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Move setting of Term::_last_char to Term::_insert 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. --- diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp index 6cd65f3ede7..ed9478a67d3 100644 --- a/gdb/testsuite/gdb.tui/tuiterm.exp +++ b/gdb/testsuite/gdb.tui/tuiterm.exp @@ -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 diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 4ef3dc09159..d6220036242 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -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 {