From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id m3leChns0WpQyRgAWB0awg (envelope-from ) for ; Fri, 16 Oct 2026 05:19:21 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HR42Jsuc; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=VeD9W+g/; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HR42Jsuc; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=VeD9W+g/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BCBD41E047; Fri, 16 Oct 2026 05:19:20 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8A5C61E047 for ; Fri, 16 Oct 2026 05:19:15 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7359F4BA2E32 for ; Fri, 16 Oct 2026 09:19:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7359F4BA2E32 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HR42Jsuc; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=VeD9W+g/; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HR42Jsuc; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=VeD9W+g/ Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id A45D34BA2E14 for ; Fri, 16 Oct 2026 09:18:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A45D34BA2E14 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A45D34BA2E14 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792142323; cv=none; b=nJyjb+KnxggDsijduVuwbEkzB7ZOo4G+aLG51t68tEYELBHavB6dNlQ5+hDgzPxAXgemUI1bbAYoqWmcbKFa3157TD3uGYFQwyWaddV0NRXHpJQdSooejqAEsUFHFVwJNA0W6fnLhjp24k8DVbT72zO23RwIpE+XinH0VqKMI8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792142323; c=relaxed/simple; bh=dYNvRkJGvcqoAb0eFnm1tiTMXA4yvSfxYmvCHrXwYUc=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=KJxfadOXQBfGn18zll8O+fNZBLVKzKJNylzOMXKZh5bcXujVunP5Vnhn4DsrPQeo6MdEGfLwg8qcxWgJ6qZ6kcHckulAVBU3mNvu44ASskHkN83B2f5X/9Y36Eu9oUtasaO/ABFyMGGXsSeiMj8JCaOXtL+fbU2uIIxgLQ1Ab0Y= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HR42Jsuc; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=VeD9W+g/; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HR42Jsuc; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=VeD9W+g/ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A45D34BA2E14 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6D94721CA9 for ; Fri, 16 Oct 2026 09:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792142322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5t1xBt95ObVM3hwkAb1UmaRo9MkbWziPKJp20luyzT4=; b=HR42Jsucu/vXUJdjmsklZkIDa+Tq6bAHheitwd3dvMMJstZoDN495q6gO5I3Hs6BgxJTnN 7vhKORcZI4qyxfOkxk6HeX4c0bsp2KY9YziHoeRqDAW7TGlzNGHFk51Fo36/v59uTH6IDA 5HvqCBXY4h8Vml30rNpW8jcvWntbXRY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792142322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5t1xBt95ObVM3hwkAb1UmaRo9MkbWziPKJp20luyzT4=; b=VeD9W+g/7z9z6QbXs8tLiTM/4DdanrBEsYgZQmtB8Ug6S4uLU/EqG63XOQPub4LePRuNQW dBLBWRyMHGwcDdBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=HR42Jsuc; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="VeD9W+g/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792142322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5t1xBt95ObVM3hwkAb1UmaRo9MkbWziPKJp20luyzT4=; b=HR42Jsucu/vXUJdjmsklZkIDa+Tq6bAHheitwd3dvMMJstZoDN495q6gO5I3Hs6BgxJTnN 7vhKORcZI4qyxfOkxk6HeX4c0bsp2KY9YziHoeRqDAW7TGlzNGHFk51Fo36/v59uTH6IDA 5HvqCBXY4h8Vml30rNpW8jcvWntbXRY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792142322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5t1xBt95ObVM3hwkAb1UmaRo9MkbWziPKJp20luyzT4=; b=VeD9W+g/7z9z6QbXs8tLiTM/4DdanrBEsYgZQmtB8Ug6S4uLU/EqG63XOQPub4LePRuNQW dBLBWRyMHGwcDdBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DED5E139B6 for ; Fri, 16 Oct 2026 09:18:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id BPSVFvHr0WoPDgAAD6G6ig:T3 (envelope-from ) for ; Fri, 16 Oct 2026 09:18:41 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [pushed 2/2] [gdb/testsuite] Factor out Term::_copy_lines Date: Fri, 16 Oct 2026 11:18:40 +0200 Message-ID: <20261016091840.4148802-3-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20261016091840.4148802-1-tdevries@suse.de> References: <20261016091840.4148802-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 6D94721CA9 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Factor out Term::_copy_lines. No functional changes. Tested on x86_64-linux. --- gdb/testsuite/lib/tuiterm.exp | 77 ++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 6140d32872f..edabadeb1a3 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -148,6 +148,35 @@ proc Term::_copy_line { from to } { } } +# Helper function. Copy the lines [SY, EY) to [DY, ...). Return the size of +# the source range. +proc Term::_copy_lines { sy ey dy } { + set cnt [expr {max($ey - $sy, 0)}] + if {$cnt == 0} { + # Empty source range. + return $cnt + } + + if {$sy == $dy} { + # Copy has no effect. + return $cnt + } + + # Handle overlapping source and destination ranges by choosing iteration + # order. + if {$sy > $dy} { + for {set n 0} {$n < $cnt} {incr n} { + _copy_line [expr {$sy + $n}] [expr {$dy + $n}] + } + } else { + for {set n [expr {$cnt - 1}]} {$n >= 0} {incr n -1} { + _copy_line [expr {$sy + $n}] [expr {$dy + $n}] + } + } + + return $cnt +} + # Linefeed. proc Term::_ctl_0x0a {} { _log_cur "Line feed" { @@ -162,10 +191,7 @@ proc Term::_ctl_0x0a {} { # cursor back on the screen. But we wrap the # scrolling inside a while loop just to be on the safe # side. - for {set y 0} {$y < $_rows - 1} {incr y} { - set next_y [expr {$y + 1}] - _copy_line $next_y $y - } + _copy_lines 1 $_rows 0 incr _cur_row -1 _clear_lines $_cur_row $_rows @@ -485,15 +511,10 @@ proc Term::_csi_L {args} { set arg [expr {min($arg, $_rows - $_cur_row)}] - set y [expr {$_rows - $arg - 1}] - set next_y [expr {$_rows - 1}] - while {$y >= $_cur_row} { - _copy_line $y $next_y - incr y -1 - incr next_y -1 - } + set dy [expr {$_cur_row + $arg}] + _copy_lines $_cur_row [expr {$_rows - $arg}] $dy - _clear_lines $_cur_row [expr {$_cur_row + $arg}] + _clear_lines $_cur_row $dy } } @@ -507,14 +528,10 @@ proc Term::_csi_M {args} { variable _cur_row variable _rows - set y $_cur_row - set next_y [expr {$y + $count}] - while {$next_y < $_rows} { - _copy_line $next_y $y - incr y - incr next_y - } - _clear_lines $y $_rows + set sy [expr {$_cur_row + $count}] + set copy_cnt [_copy_lines $sy $_rows $_cur_row] + + _clear_lines [expr {$_cur_row + $copy_cnt}] $_rows } } @@ -560,16 +577,9 @@ proc Term::_csi_S {args} { # margins. If/when that changes, then the following will # need to be updated. - set dy 0 - set y $count + set copy_cnt [_copy_lines $count $_rows 0] - while {$y < $_rows} { - _copy_line $y $dy - incr y 1 - incr dy 1 - } - - _clear_lines $dy $_rows + _clear_lines $copy_cnt $_rows } } @@ -590,14 +600,7 @@ proc Term::_csi_T {args} { # margins. If/when that changes, then the following will # need to be updated. - set y [expr {$_rows - $count - 1}] - set dy [expr {$_rows - 1}] - - while {$dy >= $count} { - _copy_line $y $dy - incr y -1 - incr dy -1 - } + _copy_lines 0 [expr {$_rows - $count}] $count _clear_lines 0 $count } -- 2.51.0