Subject: lib/10732: libcurses: screen crash due to gratuitous \r\n
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 08/01/2000 08:16:12
>Number:         10732
>Category:       lib
>Synopsis:       libcurses: screen crash due to gratuitous \r\n
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 01 08:17:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Jun-ichiro itojun Hagino
>Release:        latest 20000801
>Organization:
	itojun.org
>Environment:
System: NetBSD starfruit.itojun.org 1.5C NetBSD 1.5C (STARFRUIT) #80: Mon Jul 31 13:13:49 JST 2000 itojun@starfruit.itojun.org:/usr/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386


>Description:
	a curses code (KAME mchat) works fine with 1.4.2 curses, however,
	it does not work right.  it will experience screen crash, due to
	extra \r\n output on the end of screen (line LINES - 1), on
	wrefresh().
>How-To-Repeat:
	compile KAME mchat, type any key at startup.  see the screen crash.
>Fix:
	this solved problem for me, but it may not be the right place to fix.
	maybe it hsa sometihng to do with "win->lines->flags" lookup, multiple
	window support part change, or something else.

	i looked into nvi curses, and ncurses.  nvi curses had the same
	statement as the #if 0'ed portion (so, i guess the following patch
	may not be the right one).  ncurses used 100% different code so
	I could not get any info from ncurses.

	i will try to come up with repeatable small example.

Index: refresh.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libcurses/refresh.c,v
retrieving revision 1.39
diff -c -r1.39 refresh.c
*** refresh.c	2000/08/01 04:17:09	1.39
--- refresh.c	2000/08/01 15:11:53
***************
*** 385,392 ****
--- 385,397 ----
  		win = __virtscr;
  	/* Is the cursor still on the end of the last line? */
  	if (wy > 0 && win->lines[wy - 1]->flags & __ISPASTEOL) {
+ #if 0
+ 		/* gratiutous scroll down if ly == LINES - 1 */
  		domvcur(ly, lx, ly + 1, 0);
  		ly++;
+ #else
+ 		domvcur(ly, lx, ly, 0);
+ #endif
  		lx = 0;
  	}
  	wx = *win->lines[wy]->firstchp;
>Release-Note:
>Audit-Trail:
>Unformatted: