[net.bugs.4bsd] YACB

laman@sdcsvax.UUCP (07/09/84)

<Curses, foiled again>

The bug that Mike Lilley found in overlay() is where the last line of the window
being overlayed is not overlayed.  The following program will tell you
if you have the bug.  The fix follows the program.  It seems that the
extraction of this library from "vi" has bitten us again.

/* Beginning of program.  Cut here------- */
#include <curses.h>

main() {
	register WINDOW *win;

	initscr();
	noecho();
	win = newwin(0, 0, 0, 0);
	mvwaddstr(win, LINES/2, 12, "---Hit return to exit---");
	mvwaddstr(win, LINES-2, 0, "The middle of the next line should say \"Hi\".  If not you have the overlay bug.");
	mvwaddstr(win, LINES-1, COLS / 2 - 10, "Hi.  You don't have the bug");
	overlay(win, stdscr);
	refresh();
	getchar();
	move(LINES - 1, 0);
	refresh();
	echo();
	endwin();
}
/* End of program. Cut here--------- */

If you have the bug, the following fixes takes care of the problem:

	On the first for loop in overlay() is:

		for (y = starty; y < endy; y++) {

	It should be:

		for (y = starty; y <= endy; y++) {

	The problem is that the computation of "endy" takes into account
    the fact that "_maxy" is "1 relative".  The subtraction of 1 now makes
    it "0 relative", but the for-loop is treating it as "1 relative".
    Another solution is to remove the "- 1" from the assignment to "endy".
    Which ever you prefer.

		Mike Laman, NCR Torrey Pines
		UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman