🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs
Article #150

Curses bug fixes (4.2 and net.sources dist.)

#150
From: laman
Date: Wed, 16 Nov 1983 22:32
93 lines
3225 bytes
Luckily I saved copies of my two bug fixes.  Here are the two fixes that I sent
out earlier, but which probably didn't make it far out of San Diego.  I have
since used the second bug fix (the one to wrefresh()) enough to say that
it speeds up some of the output up on non CPU bound programs.  The speed up
was noticeable in some of my programs!

First bug report:

There is a bug in wdeleteln().  This bug is in the curses library distributed
over net.sources, and in the 4.2 BSD distribution (that sdcsvax received
at least).

Even though the last line of the window gets cleared internally, its "refresh"
image may not.  The fix is simple.  Add the following two lines to the end
of the wdeleteln() routine.

	win->_firstch[win->_maxy-1] = 0;
	win->_lastch[win->_maxy-1] = win->_maxx - 1;

Now wrefresh() will look at the entire line.

I have enclosed a little program that will show you if you have the bug.  Just
compile it with you curses library (termlib too) and run it.

#include	<curses.h>

main() {
	register i;

	initscr();
	mvaddstr(0, 20, "This program will delete line #5 after");
	mvaddstr(1, 20, "writing the line number for each line.");
	for(i = 0; i < LINES; ++i)
		mvprintw(i, 0, "Line #%d", i);
	refresh();
	addstr("     You have the bug if the BOTTOM line is not COMPLETELY blank!");
	move(5, 0);
	deleteln();
	move(LINES - 3, 0);
	refresh();
	endwin();
}

Second Bug Report:

    The following bug is in the curses library distributed over net.sources,
and in the 4.2 BSD distribution (that sdcsvax received at least).

    The bug is in makech() (in refresh.c).  makech() gets called to give
output for the given LINE (hint hint).  It is interesting that this bug
managed to get out.  Here is the offending code (the simple fix follows).

			:
			:
			:
		else if (wx < lch)
			while (*nsp == *csp) {
				nsp++;
				if (!curwin)
					csp++;
				++wx;
			}
		else
			:
			:
			:

I wrote a program that added '*' to (0, 0) on stdscr then a refresh().
wx ended up with a value of over 3000!  That loop walked down the line
and the next, ... (all the way down the window!).  The following code
is the fix.  Notice that the ++wx looks just perfect.  It really makes one
think "they" thought of it, but merely forgot to add the test.

			:
			:
			:
		else if (wx < lch)
			while (*nsp == *csp && wx <= lch) {
				nsp++;
				if (!curwin)
					csp++;
				++wx;
			}
		else
			:
			:
			:


I apologize to those of you seeing some of this for a THIRD time, but I want
these to get into the distribution.
			Mike Laman
			UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman
Technical Details
Message-ID: <18@sdcsvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!security!genrad!decvax!ittvax!dcdwest!sdcsvax!laman

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site sdcsvax.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!security!genrad!decvax!ittvax!dcdwest!sdcsvax!laman
From: laman@sdcsvax.UUCP
Newsgroups: net.bugs,net.bugs.4bsd
Subject: Curses bug fixes (4.2 and net.sources dist.)
Message-ID: <18@sdcsvax.UUCP>
Date: Wed, 16-Nov-83 17:32:47 EST
Article-I.D.: sdcsvax.18
Posted: Wed Nov 16 17:32:47 1983
Date-Received: Fri, 18-Nov-83 00:59:00 EST
Organization: U.C. San Diego, Computer Science Dept.
Lines: 93