[comp.sys.sun] Bug in SunOs -lcurses

gnb@melba.oz.au (Gregory N. Bond) (02/02/90)

This bug has been in SunOs -lcurses since (at least) 3.5, but it is only a
problem since SunOs 4.0 became 8-bit transparent.  In certain situations,
termcap emits space characters with the high order bit set.  This causes
"interesting" problems with SunOs 4.0 version of shelltool.  (The bug was
noticed when the sc spreadsheet (see comp.sources.unix) was mangling the
row/column labels.)

/*
 *	Show a bug in SunOs 4.0.3 curses.
 *
 *	This program should generate a line of highlighted letters spaced
 *	every 4 characters.  Instead, it produces a highlighted line like 
 *	"ABCDEFGHIJKLMNO"  (when run under the SunOs 4.0 shelltool or cmdtool).
 *
 *	The reason?  The second refresh() is redrawing the line with Meta-space 
 *	characters (0xA0 or 0240), which are ignored by the 4.0.3 shelltool.  
 *	Running the output through an 8th-bit stripping program makes it work.
 *
 *	This worked under SunOs 3.5, as the shelltool ignored the 8th bit.
 *
 *	Compile by: Save in a file "cbug.c" and click and stuff this line:
cc -o cbug cbug.c -lcurses -ltermcap
 */
#include <curses.h>

main()
{
	initscr();
	standout();

	move (1,0);
	printw("       A       B       C       D       E       F       G       ");
	refresh();

	move (1,0);
	printw("   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   ");
	refresh();

	endwin();
}

Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb@melba.bby.oz.au    non-MX: gnb%melba.bby.oz@uunet.uu.net
Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb