]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/testsuite] Fix Cursor Horizontal Absolute clipping
authorTom de Vries <tdevries@suse.de>
Wed, 23 Jul 2025 18:28:46 +0000 (20:28 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 23 Jul 2025 18:28:46 +0000 (20:28 +0200)
commit63338cd5683d7d48a8bfca8c026543566d3f461b
treebeaae3f08b40db56c43c6220cc5ca6b3f1614c49
parent778164cffebba2bb48b983ff6164b04e03eb5153
[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>
gdb/testsuite/gdb.tui/tuiterm.exp
gdb/testsuite/lib/tuiterm.exp