diff options
author | Tom de Vries <tdevries@suse.de> | 2025-07-23 20:28:46 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-07-23 20:28:46 +0200 |
commit | 63338cd5683d7d48a8bfca8c026543566d3f461b (patch) | |
tree | beaae3f08b40db56c43c6220cc5ca6b3f1614c49 | |
parent | 778164cffebba2bb48b983ff6164b04e03eb5153 (diff) | |
download | binutils-63338cd5683d7d48a8bfca8c026543566d3f461b.zip binutils-63338cd5683d7d48a8bfca8c026543566d3f461b.tar.gz binutils-63338cd5683d7d48a8bfca8c026543566d3f461b.tar.bz2 |
[gdb/testsuite] Fix Cursor Horizontal Absolute clipping
I looked at the tuiterm implementation of Cursor Horizontal Absolute:
...
proc _csi_G {args} {
set arg [_default [lindex $args 0] 1]
_log_cur "Cursor Horizontal Absolute ($arg)" {
variable _cur_col
variable _cols
set _cur_col [expr {min ($arg - 1, $_cols)}]
}
}
...
and noticed a problem with the clipping behavior.
If we have say $_cols == 80, and we do _csi_G 81 we get $_cur_col == 80, while
$_cur_col is zero-based and should be in the 0..79 range.
Fix this by using:
...
set _cur_col [expr {min ($arg, $_cols)} - 1]
...
which gets us $_cur_col == 79.
Add two boundary tests to gdb.tui/tuiterm.exp.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r-- | gdb/testsuite/gdb.tui/tuiterm.exp | 16 | ||||
-rw-r--r-- | gdb/testsuite/lib/tuiterm.exp | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp index 9dc2402..fff7c37 100644 --- a/gdb/testsuite/gdb.tui/tuiterm.exp +++ b/gdb/testsuite/gdb.tui/tuiterm.exp @@ -435,6 +435,22 @@ proc test_horizontal_absolute { } { "qrstuvwx" "yz01234 " } 3 2 + + Term::_csi_G 8 + check "cursor horizontal absolute 3" { + "abcdefgh" + "ijklmnop" + "qrstuvwx" + "yz01234 " + } 7 2 + + Term::_csi_G 9 + check "cursor horizontal absolute 4" { + "abcdefgh" + "ijklmnop" + "qrstuvwx" + "yz01234 " + } 7 2 } proc test_cursor_position { } { diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index a0cd199..71ef6a4 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -251,7 +251,7 @@ namespace eval Term { variable _cur_col variable _cols - set _cur_col [expr {min ($arg - 1, $_cols)}] + set _cur_col [expr {min ($arg, $_cols)} - 1] } } |