NetBSD Problem Report #11827

Received: (qmail 11569 invoked from network); 27 Dec 2000 20:24:37 -0000
Message-Id: <200012272024.eBRKORA00350@syn.hamachi.org>
Date: Wed, 27 Dec 2000 15:24:27 -0500 (EST)
From: sommerfeld@netbsd.org
Sender: wes@orchard.arlington.ma.us
Reply-To: sommerfeld@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Cc: tibbetts@mit.edu
Subject: wscons vt100 emulation botches scroll region
X-Send-Pr-Version: 3.95

>Number:         11827
>Category:       kern
>Synopsis:       wscons-vt100 scrolls when outside scroll region
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 27 20:25:01 +0000 2000
>Closed-Date:    Sun Jan 05 23:20:29 +0000 2003
>Last-Modified:  Thu Aug 03 02:52:15 +0000 2023
>Originator:     Bill Sommerfeld
>Release:        200012xx
>Organization:

>Environment:

System: NetBSD syn 1.5O NetBSD 1.5O (VAIO) #7: Wed Dec 27 15:06:41 EST 2000 wes@syn:/usr/wes/vanilla-sys/arch/i386/compile/VAIO i386


>Description:

This bug was noticed by Richard Tibbetts <tibbetts@mit.edu>

wscons output involving a newline or line wrap below the scroll region
forces the screen to scroll; this does not match (e.g.)  xterm
behavior.

>How-To-Repeat:

uudecode the following, and send to
	a) an xterm.
	b) wscons running in 80x50 mode.

Observe that the final screen state is not the same.

begin 664 screen-bug-test
M&UL_-V@;6SX;6S\Q:!L@1AM;/S1L&ULT;!M;,&T/&ULQ.S4P<AM;2!M;2AM;
M2!M;2AM;-#E"&ULW;2`M+2`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@&ULR-VT;6T@;6T@;6TH;6S0Y0AM;-VTQ,SHP,R`\/B`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@(!M;,C=M&UM(&ULT.4(;6TL;6S=M,3,Z,#,@/'9T
M/B`P*B!V="`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`;6T@;6S(W;1M;2!M;2AM;-#E"
M&ULW;3$S.C`S(#QV=#X@,"H@=G0@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@&UM(&ULT
M.4(;6TLQ,SHP,R`\=G0^(#`J('9T("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(!M;2!M;
M-#E"&UM+,3,Z,#,@/&UA:6P^(#`@=G0@(#$J(&UA:6P@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`;6T@;
M6S(W;1M;2!M;2AM;-#E"&ULW;3$S.C`S(#QM86EL/B`P('9T("`Q*B!M86EL
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@&UM(&ULT.4(;6TLQ,SHP,R`\;6%I;#X@,"!V="`@,2H@;6%I
M;"`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@(!M;2!M;-#E"&UM+,3,Z,#,@/&5M86-S/B`P('9T("`Q(&UA
M:6P@(#(J(&5M86-S("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`;6T@;6S(W;1M;2!M;2AM;-#E"&ULW;3$S.C`S(#QE;6%C
M<SX@,"!V="`@,2!M86EL("`R*B!E;6%C<R`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@&UM(&ULT.4(;6TLQ,SHP,R`\96UA
M8W,^(#`@=G0@(#$@;6%I;"`@,BH@96UA8W,@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("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]?7PTM7QM;,S5M
M*C(^86QE='1A&ULS-FU?,3YT:6)B971T<U]?7U]?7U]?7U]?7U]?7U]?7U]?
L7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7PT*&ULR00I?
`
end

>Fix:

This appears to fix the problem but has not been extensively tested;
also, the code sequence in question should probably be refactored as
it occurrs 3 times in the driver.

The current logic is: 
	scroll if we are at or below the bottom of the
	scroll region, otherwise move down a line

The enclosed patch changes this to:

	scroll if we are at the bottom of the scroll region,
	otherwise, move down a line if we are not at the bottom of the
	screen.

It is not clear if the "move down a line if outside the scroll region"
behavior of the patch is correct; however, the existing behavior is
clearly incorrect.

Index: wsemul_vt100.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/wscons/wsemul_vt100.c,v
retrieving revision 1.13
diff -u -r1.13 wsemul_vt100.c
--- wsemul_vt100.c	2000/04/28 21:56:16	1.13
+++ wsemul_vt100.c	2000/12/27 20:15:17
@@ -324,11 +324,13 @@

 	if ((edp->flags & (VTFL_LASTCHAR | VTFL_DECAWM)) ==
 	    (VTFL_LASTCHAR | VTFL_DECAWM)) {
-		if (ROWS_BELOW > 0) {
-			edp->crow++;
+		if (ROWS_BELOW == 0) {
+		  	wsemul_vt100_scrollup(edp, 1);
+		} else {
+			if ((edp->crow+1) < edp->nrows)
+				edp->crow++;
 			CHECK_DW;
-		} else
-			wsemul_vt100_scrollup(edp, 1);
+		}
 		edp->ccol = 0;
 		edp->flags &= ~VTFL_LASTCHAR;
 	}
@@ -437,11 +439,13 @@
 	    case ASCII_LF:
 	    case ASCII_VT:
 	    case ASCII_FF:
-		if (ROWS_BELOW > 0) {
-			edp->crow++;
+		if (ROWS_BELOW == 0) {
+		  	wsemul_vt100_scrollup(edp, 1);
+		} else {
+			if ((edp->crow+1) < edp->nrows)
+				edp->crow++;
 			CHECK_DW;
-		} else
-			wsemul_vt100_scrollup(edp, 1);
+		}
 		break;
 	}
 }
@@ -497,12 +501,13 @@
 		edp->ccol = 0;
 		/* FALLTHRU */
 	    case 'D': /* IND */
-		if (ROWS_BELOW > 0) {
-			edp->crow++;
+		if (ROWS_BELOW == 0) {
+		  	wsemul_vt100_scrollup(edp, 1);
+		} else {
+			if ((edp->crow+1) < edp->nrows)
+				edp->crow++;
 			CHECK_DW;
-			break;
 		}
-		wsemul_vt100_scrollup(edp, 1);
 		break;
 	    case 'H': /* HTS */
 		KASSERT(edp->tabs != 0);

>Release-Note:
>Audit-Trail:

From: Richard Tibbetts <tibbetts@MIT.EDU>
To: gnats-bugs@gnats.netbsd.org, tibbetts@MIT.EDU, tibbetts@MIT.EDU
Cc: sommerfeld@netbsd.org, tibbetts@MIT.EDU
Subject: Re: kern/11827
Date: Sat, 30 Dec 2000 22:10:00 -0500

 The included patch fixes not only the forward scrolling bug, but also
 the complementary bug in scrolling up when above the top margin. It
 refactors the repeated code in Bill's patch into a function,
 wsemul_vt100_nextline().

 I verified the correctness of this patch with xterm. Of particular
 interest are xtermIndex() and RevIndex() defined in cursor.c:
 http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/xc/programs/xterm/cursor.c

 tibbetts

 Index: wsemul_vt100.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/wscons/wsemul_vt100.c,v
 retrieving revision 1.13
 diff -u -r1.13 wsemul_vt100.c
 --- wsemul_vt100.c	2000/04/28 21:56:16	1.13
 +++ wsemul_vt100.c	2000/12/31 03:02:33
 @@ -75,6 +75,7 @@
  					    u_char, int));
  static void wsemul_vt100_output_c0c1 __P((struct wsemul_vt100_emuldata *,
  					  u_char, int));
 +static void wsemul_vt100_nextline __P((struct wsemul_vt100_emuldata *));
  typedef u_int vt100_handler __P((struct wsemul_vt100_emuldata *, u_char));
  static vt100_handler
  wsemul_vt100_output_esc,
 @@ -314,6 +315,26 @@
   * now all the state machine bits
   */

 +/*
 + * Move the cursor to the next line if possible. If the cursor is at
 + * the bottom of the scroll area, then scroll it up. If the cursor is
 + * at the bottom of the screen then don't move it down.
 + */
 +static void
 +wsemul_vt100_nextline(edp)
 +	struct wsemul_vt100_emuldata *edp;
 +{
 +	if (ROWS_BELOW == -1) {
 +		/* Bottom of the scroll region. */
 +	  	wsemul_vt100_scrollup(edp, 1);
 +	} else {
 +		if ((edp->crow+1) < edp->nrows)
 +			/* Cursor not at the bottom of the screen. */
 +			edp->crow++;
 +		CHECK_DW;
 +	}
 +}	
 +
  static void
  wsemul_vt100_output_normal(edp, c, kernel)
  	struct wsemul_vt100_emuldata *edp;
 @@ -324,11 +345,7 @@

  	if ((edp->flags & (VTFL_LASTCHAR | VTFL_DECAWM)) ==
  	    (VTFL_LASTCHAR | VTFL_DECAWM)) {
 -		if (ROWS_BELOW > 0) {
 -			edp->crow++;
 -			CHECK_DW;
 -		} else
 -			wsemul_vt100_scrollup(edp, 1);
 +		wsemul_vt100_nextline(edp);
  		edp->ccol = 0;
  		edp->flags &= ~VTFL_LASTCHAR;
  	}
 @@ -437,11 +454,7 @@
  	    case ASCII_LF:
  	    case ASCII_VT:
  	    case ASCII_FF:
 -		if (ROWS_BELOW > 0) {
 -			edp->crow++;
 -			CHECK_DW;
 -		} else
 -			wsemul_vt100_scrollup(edp, 1);
 +		wsemul_vt100_nextline(edp);
  		break;
  	}
  }
 @@ -497,12 +510,7 @@
  		edp->ccol = 0;
  		/* FALLTHRU */
  	    case 'D': /* IND */
 -		if (ROWS_BELOW > 0) {
 -			edp->crow++;
 -			CHECK_DW;
 -			break;
 -		}
 -		wsemul_vt100_scrollup(edp, 1);
 +		wsemul_vt100_nextline(edp);
  		break;
  	    case 'H': /* HTS */
  		KASSERT(edp->tabs != 0);
 @@ -530,12 +538,15 @@
  		edp->sschartab = 3;
  		break;
  	    case 'M': /* RI */
 -		if (ROWS_ABOVE > 0) {
 -			edp->crow--;
 +		if (ROWS_ABOVE == 0) {
 +			/* Top of the scroll region. */
 +	  		wsemul_vt100_scrolldown(edp, 1);
 +		} else {
 +			if (edp->crow > 0)
 +				/* Cursor not at the top of the screen. */
 +				edp->crow--;
  			CHECK_DW;
 -			break;
  		}
 -		wsemul_vt100_scrolldown(edp, 1);
  		break;
  	    case 'P': /* DCS */
  		edp->nargs = 0;

From: Richard Tibbetts <tibbetts@MIT.EDU>
To: gnats-bugs@gnats.netbsd.org
Cc: sommerfeld@netbsd.org, tibbetts@MIT.EDU
Subject: Re: kern/11827
Date: Sat, 30 Dec 2000 23:21:05 -0500

 The previous patch (which I sent only a few minutes ago) was made
 against the wrong copy of the code. I had been testing a bug that
 turned out to be in my testing utility. The following patch is
 correct. The difference is that wsemul_vt100_nextline() checks if
 ROWS_BELOW == 0 (correct) rather than -1 (incorrect).

 Sorry about the mixup.

 tibbetts

 Index: wsemul_vt100.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/wscons/wsemul_vt100.c,v
 retrieving revision 1.13
 diff -u -r1.13 wsemul_vt100.c
 --- wsemul_vt100.c	2000/04/28 21:56:16	1.13
 +++ wsemul_vt100.c	2000/12/31 04:16:13
 @@ -75,6 +75,7 @@
  					    u_char, int));
  static void wsemul_vt100_output_c0c1 __P((struct wsemul_vt100_emuldata *,
  					  u_char, int));
 +static void wsemul_vt100_nextline __P((struct wsemul_vt100_emuldata *));
  typedef u_int vt100_handler __P((struct wsemul_vt100_emuldata *, u_char));
  static vt100_handler
  wsemul_vt100_output_esc,
 @@ -314,6 +315,26 @@
   * now all the state machine bits
   */

 +/*
 + * Move the cursor to the next line if possible. If the cursor is at
 + * the bottom of the scroll area, then scroll it up. If the cursor is
 + * at the bottom of the screen then don't move it down.
 + */
 +static void
 +wsemul_vt100_nextline(edp)
 +	struct wsemul_vt100_emuldata *edp;
 +{
 +	if (ROWS_BELOW == 0) {
 +		/* Bottom of the scroll region. */
 +	  	wsemul_vt100_scrollup(edp, 1);
 +	} else {
 +		if ((edp->crow+1) < edp->nrows)
 +			/* Cursor not at the bottom of the screen. */
 +			edp->crow++;
 +		CHECK_DW;
 +	}
 +}	
 +
  static void
  wsemul_vt100_output_normal(edp, c, kernel)
  	struct wsemul_vt100_emuldata *edp;
 @@ -324,11 +345,7 @@

  	if ((edp->flags & (VTFL_LASTCHAR | VTFL_DECAWM)) ==
  	    (VTFL_LASTCHAR | VTFL_DECAWM)) {
 -		if (ROWS_BELOW > 0) {
 -			edp->crow++;
 -			CHECK_DW;
 -		} else
 -			wsemul_vt100_scrollup(edp, 1);
 +		wsemul_vt100_nextline(edp);
  		edp->ccol = 0;
  		edp->flags &= ~VTFL_LASTCHAR;
  	}
 @@ -437,11 +454,7 @@
  	    case ASCII_LF:
  	    case ASCII_VT:
  	    case ASCII_FF:
 -		if (ROWS_BELOW > 0) {
 -			edp->crow++;
 -			CHECK_DW;
 -		} else
 -			wsemul_vt100_scrollup(edp, 1);
 +		wsemul_vt100_nextline(edp);
  		break;
  	}
  }
 @@ -497,12 +510,7 @@
  		edp->ccol = 0;
  		/* FALLTHRU */
  	    case 'D': /* IND */
 -		if (ROWS_BELOW > 0) {
 -			edp->crow++;
 -			CHECK_DW;
 -			break;
 -		}
 -		wsemul_vt100_scrollup(edp, 1);
 +		wsemul_vt100_nextline(edp);
  		break;
  	    case 'H': /* HTS */
  		KASSERT(edp->tabs != 0);
 @@ -530,12 +538,15 @@
  		edp->sschartab = 3;
  		break;
  	    case 'M': /* RI */
 -		if (ROWS_ABOVE > 0) {
 -			edp->crow--;
 +		if (ROWS_ABOVE == 0) {
 +			/* Top of the scroll region. */
 +	  		wsemul_vt100_scrolldown(edp, 1);
 +		} else {
 +			if (edp->crow > 0)
 +				/* Cursor not at the top of the screen. */
 +				edp->crow--;
  			CHECK_DW;
 -			break;
  		}
 -		wsemul_vt100_scrolldown(edp, 1);
  		break;
  	    case 'P': /* DCS */
  		edp->nargs = 0;
State-Changed-From-To: open->closed 
State-Changed-By: sommerfeld 
State-Changed-When: Sun Jan 5 15:20:03 PST 2003 
State-Changed-Why:  
fix committed 

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Subject: Re: kern/11827: CVS commit: src/sys/dev/wscons
Date: Thu, 3 Aug 2023 05:39:59 +0300

 For the record: the same problem also existed for RI (reverse index ~=
 "newline upwards").  Fixed by the following commit.

 Date: Wed, 2 Aug 2023 22:37:02 +0000
 From: Valery Ushakov <uwe@netbsd.org>
 Subject: CVS commit: src/sys/dev/wscons
 To: source-changes@NetBSD.org
 Reply-To: source-changes-d@NetBSD.org
 Mail-Followup-To: source-changes-d@NetBSD.org

 Module Name:	src
 Committed By:	uwe
 Date:		Wed Aug  2 22:37:02 UTC 2023

 Modified Files:
 	src/sys/dev/wscons: wsemul_vt100.c

 Log Message:
 wsemul_vt100: fix RI to not scroll outside of scroll region

 This is the inverse (scroll down) of the problem reported and fixed
 for IND (scroll up) in PR kern/11827 back in 2000.

 We only have one call site for this, but still move this bit of code
 into a separate wsemul_vt100_prevline function to make it symmetric
 with wsemul_vt100_nextline.  While here, make both take vt100base_data.


 To generate a diff of this commit:
 cvs rdiff -u -r1.51 -r1.52 src/sys/dev/wscons/wsemul_vt100.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.