From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1527179-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 81C1A15812E
	for <garchives@archives.gentoo.org>; Sat, 10 Jun 2023 07:23:19 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A4E1FE0938;
	Sat, 10 Jun 2023 07:23:18 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 8EB5DE0938
	for <gentoo-commits@lists.gentoo.org>; Sat, 10 Jun 2023 07:23:18 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(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.gentoo.org (Postfix) with ESMTPS id C7388341148
	for <gentoo-commits@lists.gentoo.org>; Sat, 10 Jun 2023 07:23:17 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 0DC6FA87
	for <gentoo-commits@lists.gentoo.org>; Sat, 10 Jun 2023 07:23:16 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1686381356.c3c6ba532055f01cde10882b67aecda00abd01e1.sam@gentoo>
Subject: [gentoo-commits] proj/gentoo-functions:master commit in: /
X-VCS-Repository: proj/gentoo-functions
X-VCS-Files: functions.sh.in
X-VCS-Directories: /
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: c3c6ba532055f01cde10882b67aecda00abd01e1
X-VCS-Branch: master
Date: Sat, 10 Jun 2023 07:23:16 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 957a93a4-fa8b-4bee-97af-d60f47d42dba
X-Archives-Hash: ee162dfb9b2cb95156506b87c6b009d6

commit:     c3c6ba532055f01cde10882b67aecda00abd01e1
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 10 07:10:48 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 10 07:15:56 2023 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=c3c6ba53

Fix the order of the arguments used to compose the CUP sequence

The CUP (ECMA-48 CSI) sequence expects for the row to come first, and
the column second. I could have just swapped the arguments but, instead,
I have adjusted the surrounding code so as to strictly adhere to this
convention (one that is also observed by stty size). This should
eliminate the possibility of any such mistake being made in the future.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Fixes: 20bc15b5b1009149c4a3d531911d3c219dc55f3a

 functions.sh.in | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/functions.sh.in b/functions.sh.in
index 0c3e7ba..9be9978 100644
--- a/functions.sh.in
+++ b/functions.sh.in
@@ -270,7 +270,7 @@ _eend()
 	fi
 
 	# Stash the last known terminal dimensions, if any.
-	set -- "${genfun_cols}" "${genfun_rows}"
+	set -- "${genfun_rows}" "${genfun_cols}"
 
 	# Check whether STDOUT is a terminal, and how capable it is.
 	_update_tty_level <&1
@@ -304,9 +304,9 @@ _eend()
 		# Provided that the terminal has not since been resized, it may
 		# be possible to write the indicator on the same row as the
 		# last printed message, even if it were LF-terminated.
-		if [ "${genfun_cols}" -eq "$1" ] && [ "${genfun_rows}" -eq "$2" ]; then
+		if [ "${genfun_rows}" -eq "$1" ] && [ "${genfun_cols}" -eq "$2" ]; then
 			# Stash the current position of the cursor.
-			set -- "${genfun_x}" "${genfun_y}"
+			set -- "${genfun_y}" "${genfun_x}"
 
 			# Using the DECRC sequence, restore the cursor position
 			# to wherever it was just after the last message was
@@ -324,11 +324,11 @@ _eend()
 			# preceding row. If it did, assume that scrolling has
 			# occurred since printing the last message and move the
 			# cursor back to where it was with CUP (ECMA-48 CSI).
-			offset=$(( $2 - genfun_y ))
+			offset=$(( $1 - genfun_y ))
 			if [ "${offset}" -lt 0 ] || [ "${offset}" -gt 1 ]; then
 				printf '\033[%d;%dH' "$1" "$2"
-				genfun_x=$1
-				genfun_y=$2
+				genfun_y=$1
+				genfun_x=$2
 			fi
 		fi