*BSD News Article 9659


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA6221 ; Wed, 06 Jan 93 03:10:25 EST
Path: sserve!manuel.anu.edu.au!munnari.oz.au!uunet!mcsun!fuug!kiae!demos!newsserv
From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su>
Newsgroups: comp.unix.bsd
Subject: [386bsd] Patch for curses library, make it clean 8-bit
Date: Fri, 08 Jan 93 18:06:29 +0300
Distribution: world
Organization: Ha-oh-lahm Yetzirah
Message-ID: <WHrXPJh8b6@astral.msk.su>
Sender: news-service@newcom.kiae.su
Reply-To: ache@astral.msk.su
Lines: 864

Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.

*** addbytes.c.was	Sun Apr 21 00:13:50 1991
--- addbytes.c	Fri Jan  8 15:46:02 1993
***************
*** 37,49 ****
  
  # include	"curses.ext"
  
  /*
   *	This routine adds the character to the current position
   *
   */
! waddbytes(win, bytes, count)
  reg WINDOW	*win;
! reg char	*bytes;
  reg int		count;
  {
  #define	SYNCH_OUT()	{win->_cury = y; win->_curx = x;}
--- 37,65 ----
  
  # include	"curses.ext"
  
+ waddbytes(win, bytes, count)
+ reg WINDOW	*win;
+ reg char        *bytes;
+ int         count;
+ {
+ 	chtype c;
+ 	reg int i;
+ 
+ 	for (i = 0; i < count; i++) {
+ 		c = (unsigned char) *bytes++;
+ 		if (_waddbytes(win, &c, 1) == ERR)
+ 			return ERR;
+ 	}
+ 	return OK;
+ }
+ 
  /*
   *	This routine adds the character to the current position
   *
   */
! _waddbytes(win, bytes, count)
  reg WINDOW	*win;
! reg chtype      *bytes;
  reg int		count;
  {
  #define	SYNCH_OUT()	{win->_cury = y; win->_curx = x;}
***************
*** 52,69 ****
  	reg int		newx;
  
  	SYNCH_IN();
- # ifdef FULLDEBUG
- 	fprintf(outf, "ADDBYTES('%c') at (%d, %d)\n", c, y, x);
- # endif
  	while (count--) {
! 	    register int c;
! 	    static char blanks[] = "        ";
  
  	    c = *bytes++;
  	    switch (c) {
  	      case '\t':
  		    SYNCH_IN();
! 		    if (waddbytes(win, blanks, 8-(x%8)) == ERR) {
  			return ERR;
  		    }
  		    SYNCH_OUT();
--- 68,82 ----
  	reg int		newx;
  
  	SYNCH_IN();
  	while (count--) {
! 	    register chtype c;
! 	    static chtype blanks[] = {' ',' ',' ',' ',' ',' ',' ',' '};
  
  	    c = *bytes++;
  	    switch (c) {
  	      case '\t':
  		    SYNCH_IN();
! 		    if (_waddbytes(win, blanks, 8-(x%8)) == ERR) {
  			return ERR;
  		    }
  		    SYNCH_OUT();
*** addch.c.was	Sun Apr 21 00:13:50 1991
--- addch.c	Fri Jan  8 15:40:46 1993
***************
*** 43,49 ****
   */
  waddch(win, c)
  WINDOW	*win;
! char		c;
  {
!     return waddbytes(win, &c, 1);
  }
--- 43,49 ----
   */
  waddch(win, c)
  WINDOW	*win;
! chtype c;
  {
!     return _waddbytes(win, &c, 1);
  }
*** addstr.c.was	Sun Apr 21 00:13:50 1991
--- addstr.c	Fri Jan  8 17:22:38 1993
***************
*** 43,52 ****
   */
  waddstr(win,str)
  reg WINDOW	*win; 
! reg char	*str;
  {
  # ifdef DEBUG
  	fprintf(outf, "WADDSTR(\"%s\")\n", str);
  # endif
! 	return waddbytes(win, str, strlen(str));
  }
--- 43,59 ----
   */
  waddstr(win,str)
  reg WINDOW	*win; 
! char        *str;
  {
+ 	chtype c;
+ 	reg char *s;
  # ifdef DEBUG
  	fprintf(outf, "WADDSTR(\"%s\")\n", str);
  # endif
! 	for (s = str; *s;) {
! 		c = (unsigned char) *s++;
! 		if (_waddbytes(win, &c, 1) == ERR)
! 			return ERR;
! 	}
! 	return OK;
  }
*** box.c.was	Sun Apr 21 00:13:50 1991
--- box.c	Fri Jan  8 17:00:54 1993
***************
*** 44,54 ****
   */
  box(win, vert, hor)
  reg WINDOW	*win;
! char		vert, hor; {
  
  	reg int		i;
  	reg int		endy, endx;
! 	reg char	*fp, *lp;
  
  	endx = win->_maxx;
  	endy = win->_maxy - 1;
--- 44,54 ----
   */
  box(win, vert, hor)
  reg WINDOW	*win;
! chtype vert, hor; {
  
  	reg int		i;
  	reg int		endy, endx;
! 	reg chtype      *fp, *lp;
  
  	endx = win->_maxx;
  	endy = win->_maxy - 1;
*** clrtobot.c.was	Sun Apr 21 00:13:51 1991
--- clrtobot.c	Fri Jan  8 15:51:42 1993
***************
*** 45,51 ****
  reg WINDOW	*win; {
  
  	reg int		y;
! 	reg char	*sp, *end, *maxx;
  	reg int		startx, minx;
  
  	startx = win->_curx;
--- 45,51 ----
  reg WINDOW	*win; {
  
  	reg int		y;
! 	reg chtype      *sp, *end, *maxx;
  	reg int		startx, minx;
  
  	startx = win->_curx;
*** clrtoeol.c.was	Sun Apr 21 00:13:51 1991
--- clrtoeol.c	Fri Jan  8 15:53:06 1993
***************
*** 44,52 ****
  wclrtoeol(win)
  reg WINDOW	*win; {
  
! 	reg char	*sp, *end;
  	reg int		y, x;
! 	reg char	*maxx;
  	reg int		minx;
  
  	y = win->_cury;
--- 44,52 ----
  wclrtoeol(win)
  reg WINDOW	*win; {
  
! 	reg chtype      *sp, *end;
  	reg int		y, x;
! 	reg chtype      *maxx;
  	reg int		minx;
  
  	y = win->_cury;
*** cr_put.c.was	Sun Apr 21 00:13:51 1991
--- cr_put.c	Fri Jan  8 16:46:36 1993
***************
*** 180,185 ****
--- 180,186 ----
  {
  	register int i, j, k;
  	register int soutcol, soutline;
+ 	chtype ch;
  
  	plodcnt = plodflg = cnt;
  	soutcol = outcol;
***************
*** 373,381 ****
  			if (plodflg)	/* avoid a complex calculation */
  				plodcnt--;
  			else {
! 				i = curscr->_y[outline][outcol];
! 				if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT))
! 					_putchar(i & 0177);
  				else
  					goto nondes;
  			}
--- 374,382 ----
  			if (plodflg)	/* avoid a complex calculation */
  				plodcnt--;
  			else {
! 				ch = curscr->_y[outline][outcol];
! 				if ((ch&_STANDOUT) == (curscr->_flags&_STANDOUT))
! 					_putchar(ch);
  				else
  					goto nondes;
  			}
*** curses.h.was	Sun Apr 21 00:13:52 1991
--- curses.h	Fri Jan  8 17:03:22 1993
***************
*** 44,49 ****
--- 44,51 ----
  #define	bool	char
  #define	reg	register
  
+ typedef unsigned short chtype;
+ 
  #define	TRUE	(1)
  #define	FALSE	(0)
  #define	ERR	(0)
***************
*** 55,61 ****
  #define	_FLUSH		010
  #define	_FULLLINE	020
  #define	_IDLINE		040
! #define	_STANDOUT	0200
  #define	_NOCHANGE	-1
  
  #define	_puts(s)	tputs(s, 0, _putchar)
--- 57,63 ----
  #define	_FLUSH		010
  #define	_FULLLINE	020
  #define	_IDLINE		040
! #define _STANDOUT       0400
  #define	_NOCHANGE	-1
  
  #define	_puts(s)	tputs(s, 0, _putchar)
***************
*** 92,98 ****
  	bool		_clear;
  	bool		_leave;
  	bool		_scroll;
! 	char		**_y;
  	short		*_firstch;
  	short		*_lastch;
  	struct _win_st	*_nextp, *_orig;
--- 94,100 ----
  	bool		_clear;
  	bool		_leave;
  	bool		_scroll;
! 	chtype          **_y;
  	short		*_firstch;
  	short		*_lastch;
  	struct _win_st	*_nextp, *_orig;
***************
*** 127,133 ****
  #define	addch(ch)	VOID(waddch(stdscr, ch))
  #define	getch()		VOID(wgetch(stdscr))
  #define	addbytes(da,co)	VOID(waddbytes(stdscr, da,co))
! #define	addstr(str)	VOID(waddbytes(stdscr, str, strlen(str)))
  #define	getstr(str)	VOID(wgetstr(stdscr, str))
  #define	move(y, x)	VOID(wmove(stdscr, y, x))
  #define	clear()		VOID(wclear(stdscr))
--- 129,135 ----
  #define	addch(ch)	VOID(waddch(stdscr, ch))
  #define	getch()		VOID(wgetch(stdscr))
  #define	addbytes(da,co)	VOID(waddbytes(stdscr, da,co))
! #define addstr(str)     VOID(waddstr(stdscr, str))
  #define	getstr(str)	VOID(wgetstr(stdscr, str))
  #define	move(y, x)	VOID(wmove(stdscr, y, x))
  #define	clear()		VOID(wclear(stdscr))
***************
*** 151,157 ****
  #define	mvwaddbytes(win,y,x,da,co) \
  		VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co))
  #define	mvwaddstr(win,y,x,str) \
! 		VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str)))
  #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  #define	mvwinch(win,y,x)	VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
  #define	mvwdelch(win,y,x)	VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
--- 153,159 ----
  #define	mvwaddbytes(win,y,x,da,co) \
  		VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co))
  #define	mvwaddstr(win,y,x,str) \
! 		VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
  #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  #define	mvwinch(win,y,x)	VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
  #define	mvwdelch(win,y,x)	VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
***************
*** 174,180 ****
  #define	scrollok(win,bf) (win->_scroll = bf)
  #define flushok(win,bf)	 (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
  #define	getyx(win,y,x)	 y = win->_cury, x = win->_curx
! #define	winch(win)	 (win->_y[win->_cury][win->_curx] & 0177)
  
  #define raw()	 (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \
  	ioctl(_tty_ch, TIOCSETP, &_tty))
--- 176,182 ----
  #define	scrollok(win,bf) (win->_scroll = bf)
  #define flushok(win,bf)	 (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
  #define	getyx(win,y,x)	 y = win->_cury, x = win->_curx
! #define winch(win)       (win->_y[win->_cury][win->_curx] & 0xFF)
  
  #define raw()	 (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \
  	ioctl(_tty_ch, TIOCSETP, &_tty))
*** delch.c.was	Sun Apr 21 00:13:52 1991
--- delch.c	Fri Jan  8 15:56:16 1993
***************
*** 45,53 ****
  wdelch(win)
  reg WINDOW	*win; {
  
! 	reg char	*temp1, *temp2;
! 	reg char	*end;
! 	reg int		lch;
  
  	end = &win->_y[win->_cury][win->_maxx - 1];
  	temp1 = &win->_y[win->_cury][win->_curx];
--- 45,52 ----
  wdelch(win)
  reg WINDOW	*win; {
  
! 	reg chtype      *temp1, *temp2;
! 	reg chtype      *end;
  
  	end = &win->_y[win->_cury][win->_maxx - 1];
  	temp1 = &win->_y[win->_cury][win->_curx];
*** deleteln.c.was	Sun Apr 21 00:13:52 1991
--- deleteln.c	Fri Jan  8 16:00:59 1993
***************
*** 45,53 ****
  wdeleteln(win)
  reg WINDOW	*win;
  {
! 	reg char	*temp;
  	reg int		y;
! 	reg char	*end;
  	reg int		x;
  
  # ifdef DEBUG
--- 45,53 ----
  wdeleteln(win)
  reg WINDOW	*win;
  {
! 	reg chtype      *temp;
  	reg int		y;
! 	reg chtype      *end;
  	reg int		x;
  
  # ifdef DEBUG
***************
*** 58,64 ****
  		if (win->_orig == NULL)
  			win->_y[y] = win->_y[y + 1];
  		else
! 			bcopy(win->_y[y + 1], win->_y[y], win->_maxx);
  		touchline(win, y, 0, win->_maxx - 1);
  	}
  	if (win->_orig == NULL)
--- 58,64 ----
  		if (win->_orig == NULL)
  			win->_y[y] = win->_y[y + 1];
  		else
! 			bcopy(win->_y[y + 1], win->_y[y], win->_maxx * sizeof(chtype));
  		touchline(win, y, 0, win->_maxx - 1);
  	}
  	if (win->_orig == NULL)
*** erase.c.was	Sun Apr 21 00:13:53 1991
--- erase.c	Fri Jan  8 16:03:21 1993
***************
*** 45,51 ****
  reg WINDOW	*win; {
  
  	reg int		y;
! 	reg char	*sp, *end, *start, *maxx;
  	reg int		minx;
  
  # ifdef DEBUG
--- 45,51 ----
  reg WINDOW	*win; {
  
  	reg int		y;
! 	reg chtype      *sp, *end, *start, *maxx;
  	reg int		minx;
  
  # ifdef DEBUG
*** getch.c.was	Sun Apr 21 00:13:53 1991
--- getch.c	Fri Jan  8 16:06:46 1993
***************
*** 45,51 ****
  reg WINDOW	*win; {
  
  	reg bool	weset = FALSE;
! 	reg char	inp;
  
  	if (!win->_scroll && (win->_flags&_FULLWIN)
  	    && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1)
--- 45,51 ----
  reg WINDOW	*win; {
  
  	reg bool	weset = FALSE;
! 	reg int         inp;
  
  	if (!win->_scroll && (win->_flags&_FULLWIN)
  	    && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1)
***************
*** 58,70 ****
  		weset++;
  	}
  	inp = getchar();
  # ifdef DEBUG
  	fprintf(outf,"WGETCH got '%s'\n",unctrl(inp));
  # endif
  	if (_echoit) {
  		mvwaddch(curscr, win->_cury + win->_begy,
! 			win->_curx + win->_begx, inp);
! 		waddch(win, inp);
  	}
  	if (weset)
  		nocbreak();
--- 58,72 ----
  		weset++;
  	}
  	inp = getchar();
+ 	if (inp != EOF) {
  # ifdef DEBUG
  		fprintf(outf,"WGETCH got '%s'\n",unctrl(inp));
  # endif
  		if (_echoit) {
  			mvwaddch(curscr, win->_cury + win->_begy,
! 				win->_curx + win->_begx, (unsigned char) inp);
! 			waddch(win, (unsigned char) inp);
! 		}
  	}
  	if (weset)
  		nocbreak();
*** getstr.c.was	Sun Apr 21 00:13:54 1991
--- getstr.c	Fri Jan  8 16:09:33 1993
***************
*** 44,56 ****
  wgetstr(win,str)
  reg WINDOW	*win; 
  reg char	*str; {
  
! 	while ((*str = wgetch(win)) != ERR && *str != '\n')
! 		str++;
! 	if (*str == ERR) {
  		*str = '\0';
  		return ERR;
- 	}
- 	*str = '\0';
  	return OK;
  }
--- 44,55 ----
  wgetstr(win,str)
  reg WINDOW	*win; 
  reg char	*str; {
+ 	int c;
  
! 	while ((c = wgetch(win)) != ERR && c != EOF && c != '\n')
! 		*str++ = c;
  	*str = '\0';
+ 	if (c == ERR)
  		return ERR;
  	return OK;
  }
*** insch.c.was	Sun Apr 21 00:13:54 1991
--- insch.c	Fri Jan  8 16:11:22 1993
***************
*** 44,53 ****
   */
  winsch(win, c)
  reg WINDOW	*win;
! char		c; {
  
! 	reg char	*temp1, *temp2;
! 	reg char	*end;
  
  	end = &win->_y[win->_cury][win->_curx];
  	temp1 = &win->_y[win->_cury][win->_maxx - 1];
--- 44,53 ----
   */
  winsch(win, c)
  reg WINDOW	*win;
! chtype          c; {
  
! 	reg chtype      *temp1, *temp2;
! 	reg chtype      *end;
  
  	end = &win->_y[win->_cury][win->_curx];
  	temp1 = &win->_y[win->_cury][win->_maxx - 1];
*** insertln.c.was	Sun Apr 21 00:13:55 1991
--- insertln.c	Fri Jan  8 16:00:59 1993
***************
*** 45,53 ****
  winsertln(win)
  reg WINDOW	*win; {
  
! 	reg char	*temp;
  	reg int		y;
! 	reg char	*end;
  	reg int		x;
  
  #ifdef	DEBUG
--- 45,53 ----
  winsertln(win)
  reg WINDOW	*win; {
  
! 	reg chtype      *temp;
  	reg int		y;
! 	reg chtype      *end;
  	reg int		x;
  
  #ifdef	DEBUG
***************
*** 59,65 ****
  		if (win->_orig == NULL)
  			win->_y[y] = win->_y[y - 1];
  		else
! 			bcopy(win->_y[y - 1], win->_y[y], win->_maxx);
  		touchline(win, y, 0, win->_maxx - 1);
  	}
  	if (win->_orig == NULL)
--- 59,65 ----
  		if (win->_orig == NULL)
  			win->_y[y] = win->_y[y - 1];
  		else
! 			bcopy(win->_y[y - 1], win->_y[y], win->_maxx * sizeof(chtype));
  		touchline(win, y, 0, win->_maxx - 1);
  	}
  	if (win->_orig == NULL)
*** newwin.c.was	Sun Apr 21 00:13:56 1991
--- newwin.c	Fri Jan  8 16:18:59 1993
***************
*** 55,61 ****
  int	num_lines, num_cols, begy, begx;
  {
  	reg WINDOW	*win;
! 	reg char	*sp;
  	reg int		i, by, bx, nl, nc;
  	reg int		j;
  
--- 55,61 ----
  int	num_lines, num_cols, begy, begx;
  {
  	reg WINDOW	*win;
! 	reg chtype      *sp;
  	reg int		i, by, bx, nl, nc;
  	reg int		j;
  
***************
*** 87,93 ****
  		win->_lastch[i] = _NOCHANGE;
  	}
  	for (i = 0; i < nl; i++)
! 		if ((win->_y[i] = malloc(nc * sizeof win->_y[0])) == NULL) {
  			for (j = 0; j < i; j++)
  				free(win->_y[j]);
  			free(win->_firstch);
--- 87,93 ----
  		win->_lastch[i] = _NOCHANGE;
  	}
  	for (i = 0; i < nl; i++)
! 		if ((win->_y[i] = (chtype *) malloc(nc * sizeof(chtype))) == NULL) {
  			for (j = 0; j < i; j++)
  				free(win->_y[j]);
  			free(win->_firstch);
***************
*** 188,194 ****
  # ifdef DEBUG
  	fprintf(outf, "MAKENEW: nl = %d\n", nl);
  # endif
! 	if ((win->_y = (char **) malloc(nl * sizeof win->_y[0])) == NULL) {
  		free(win);
  		return NULL;
  	}
--- 188,194 ----
  # ifdef DEBUG
  	fprintf(outf, "MAKENEW: nl = %d\n", nl);
  # endif
! 	if ((win->_y = (chtype **) malloc(nl * sizeof(chtype *))) == NULL) {
  		free(win);
  		return NULL;
  	}
*** overlay.c.was	Sun Apr 21 00:13:56 1991
--- overlay.c	Fri Jan  8 16:21:04 1993
***************
*** 36,42 ****
  #endif /* not lint */
  
  # include	"curses.ext"
- # include	<ctype.h>
  
  # define	min(a,b)	(a < b ? a : b)
  # define	max(a,b)	(a > b ? a : b)
--- 36,41 ----
***************
*** 48,54 ****
  overlay(win1, win2)
  reg WINDOW	*win1, *win2; {
  
! 	reg char	*sp, *end;
  	reg int		x, y, endy, endx, starty, startx;
  	reg int 	y1,y2;
  
--- 47,53 ----
  overlay(win1, win2)
  reg WINDOW	*win1, *win2; {
  
! 	reg chtype      *sp, *end;
  	reg int		x, y, endy, endx, starty, startx;
  	reg int 	y1,y2;
  
***************
*** 70,76 ****
  		end = &win1->_y[y1][endx - win1->_begx];
  		x = startx - win2->_begx;
  		for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) {
! 			if (!isspace(*sp))
  				mvwaddch(win2, y2, x, *sp);
  			x++;
  		}
--- 69,75 ----
  		end = &win1->_y[y1][endx - win1->_begx];
  		x = startx - win2->_begx;
  		for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) {
! 			if (*sp != ' ')
  				mvwaddch(win2, y2, x, *sp);
  			x++;
  		}
*** overwrite.c.was	Sun Apr 21 00:13:56 1991
--- overwrite.c	Fri Jan  8 16:00:59 1993
***************
*** 48,54 ****
  overwrite(win1, win2)
  reg WINDOW	*win1, *win2; {
  
- 	reg char	*sp, *end;
  	reg int		x, y, endy, endx, starty, startx;
  
  # ifdef DEBUG
--- 48,53 ----
***************
*** 66,72 ****
  	x = endx - startx;
  	for (y = starty; y < endy; y++) {
  		bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx],
! 		      &win2->_y[y - win2->_begy][startx - win2->_begx], x);
  		touchline(win2, y, startx - win2->_begx, endx - win2->_begx);
  	}
  }
--- 65,71 ----
  	x = endx - startx;
  	for (y = starty; y < endy; y++) {
  		bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx],
! 		      &win2->_y[y - win2->_begy][startx - win2->_begx], x * sizeof(chtype));
  		touchline(win2, y, startx - win2->_begx, endx - win2->_begx);
  	}
  }
*** printw.c.was	Sun Apr 21 00:13:56 1991
--- printw.c	Fri Jan  8 16:23:10 1993
***************
*** 111,117 ****
  	register int c = n;
  
  	while (--c >= 0) {
! 		if (waddch(win, *buf++) == ERR)
  			return (-1);
  	}
  	return n;
--- 111,117 ----
  	register int c = n;
  
  	while (--c >= 0) {
! 		if (waddch(win, (unsigned char) *buf++) == ERR)
  			return (-1);
  	}
  	return n;
*** refresh.c.was	Sun Apr 21 00:13:57 1991
--- refresh.c	Fri Jan  8 16:36:09 1993
***************
*** 169,177 ****
  reg WINDOW	*win;
  short		wy;
  {
! 	reg char	*nsp, *csp, *ce;
  	reg short	wx, lch, y;
  	reg int		nlsp, clsp;	/* last space in lines		*/
  
  	wx = win->_firstch[wy] - win->_ch_off;
  	if (wx >= win->_maxx)
--- 169,179 ----
  reg WINDOW	*win;
  short		wy;
  {
! 	reg chtype      *nsp, *csp, *ce;
  	reg short	wx, lch, y;
  	reg int		nlsp, clsp;	/* last space in lines		*/
+ 	char *ce_tcap;
+ 	static chtype blank[] = {' ','\0'};
  
  	wx = win->_firstch[wy] - win->_ch_off;
  	if (wx >= win->_maxx)
***************
*** 186,192 ****
  	y = wy + win->_begy;
  
  	if (curwin)
! 		csp = " ";
  	else
  		csp = &curscr->_y[wy + win->_begy][wx + win->_begx];
  
--- 188,194 ----
  	y = wy + win->_begy;
  
  	if (curwin)
! 		csp = blank;
  	else
  		csp = &curscr->_y[wy + win->_begy][wx + win->_begx];
  
***************
*** 199,207 ****
  	}
  
  	if (!curwin)
! 		ce = CE;
  	else
! 		ce = NULL;
  
  	while (wx <= lch) {
  		if (*nsp != *csp) {
--- 201,209 ----
  	}
  
  	if (!curwin)
! 		ce_tcap = CE;
  	else
! 		ce_tcap = NULL;
  
  	while (wx <= lch) {
  		if (*nsp != *csp) {
***************
*** 212,218 ****
  			ly = y;
  			lx = wx + win->_begx;
  			while (*nsp != *csp && wx <= lch) {
! 				if (ce != NULL && wx >= nlsp && *nsp == ' ') {
  					/*
  					 * check for clear to end-of-line
  					 */
--- 214,220 ----
  			ly = y;
  			lx = wx + win->_begx;
  			while (*nsp != *csp && wx <= lch) {
! 				if (ce_tcap != NULL && wx >= nlsp && *nsp == ' ') {
  					/*
  					 * check for clear to end-of-line
  					 */
***************
*** 235,241 ****
  							*csp++ = ' ';
  						return OK;
  					}
! 					ce = NULL;
  				}
  				/*
  				 * enter/exit standout mode as appropriate
--- 237,243 ----
  							*csp++ = ' ';
  						return OK;
  					}
! 					ce_tcap = NULL;
  				}
  				/*
  				 * enter/exit standout mode as appropriate
***************
*** 260,268 ****
  							curscr->_flags &= ~_STANDOUT;
  						    }
  					    if (!curwin)
! 						_putchar((*csp = *nsp) & 0177);
  					    else
! 						_putchar(*nsp & 0177);
  					    if (win->_flags&_FULLWIN && !curwin)
  						scroll(curscr);
  					    ly = win->_begy+win->_cury;
--- 262,270 ----
  							curscr->_flags &= ~_STANDOUT;
  						    }
  					    if (!curwin)
! 						_putchar((*csp = *nsp));
  					    else
! 						_putchar(*nsp);
  					    if (win->_flags&_FULLWIN && !curwin)
  						scroll(curscr);
  					    ly = win->_begy+win->_cury;
***************
*** 274,285 ****
  					    return ERR;
  					}
  				if (!curwin)
! 					_putchar((*csp++ = *nsp) & 0177);
  				else
! 					_putchar(*nsp & 0177);
  # ifdef FULLDEBUG
  				fprintf(outf,
! 					"MAKECH:putchar(%c)\n", *nsp & 0177);
  # endif
  				if (UC && (*nsp & _STANDOUT)) {
  					_putchar('\b');
--- 276,287 ----
  					    return ERR;
  					}
  				if (!curwin)
! 					_putchar((*csp++ = *nsp));
  				else
! 					_putchar(*nsp);
  # ifdef FULLDEBUG
  				fprintf(outf,
! 					"MAKECH:putchar(%c)\n", *nsp);
  # endif
  				if (UC && (*nsp & _STANDOUT)) {
  					_putchar('\b');
-- 
In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
Organization:  The RELCOM Corp.,    |  "Brujuleada entre los lejos
               Moscow, Russia       |  "De lo imposible?!"  (Calderon)