[comp.bugs.4bsd] BSD curses sometimes outputs 8-bit chars

karl@haddock.ima.isc.com (Karl Heuer) (10/03/89)

The obvious optimization of rightward cursor-motion is to emit the character
that's already under the cursor.  This includes the case where the character
in question has the standout bit set, and the physical terminal is already in
standout mode.

Unfortunately, the code as written emits the whole char, without masking off
the standout bit.  If your system and terminal don't ignore the high-order bit
on output, the wrong data will get written to the screen.  This has been
observed by running a curses program in a sunview window.

The problem can be fixed with the enclosed patch.

*** cr_put.c~	Fri Jun  7 23:59:37 1985
--- cr_put.c	Thu Sep 28 23:08:12 1989
***************
*** 348,354 ****
  			else {
  				i = curscr->_y[outline][outcol];
  				if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT))
! 					_putchar(i);
  				else
  					goto nondes;
  			}
--- 348,354 ----
  			else {
  				i = curscr->_y[outline][outcol];
  				if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT))
! 					_putchar(i & 0x7F);
  				else
  					goto nondes;
  			}