CVS commit: [netbsd-8] src/lib/libcurses

2020-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 14 13:39:09 UTC 2020

Modified Files:
src/lib/libcurses [netbsd-8]: newwin.c

Log Message:
Pull up following revision(s) (requested by uwe in ticket #1574):

lib/libcurses/newwin.c: revision 1.58

newwin - fix crash with negative ncols.

When support for negative nrows/ncols was added, one s/ncols/maxx/ was
missed so we ended up passing negative (i.e. huge unsigned) length
when hashing the line contents.

Reported by Naman Jain in PR lib/55484


To generate a diff of this commit:
cvs rdiff -u -r1.50.6.3 -r1.50.6.4 src/lib/libcurses/newwin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/newwin.c
diff -u src/lib/libcurses/newwin.c:1.50.6.3 src/lib/libcurses/newwin.c:1.50.6.4
--- src/lib/libcurses/newwin.c:1.50.6.3	Tue Oct  9 10:01:38 2018
+++ src/lib/libcurses/newwin.c	Tue Jul 14 13:39:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.50.6.3 2018/10/09 10:01:38 martin Exp $	*/
+/*	$NetBSD: newwin.c,v 1.50.6.4 2020/07/14 13:39:09 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c	8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.50.6.3 2018/10/09 10:01:38 martin Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.50.6.4 2020/07/14 13:39:09 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -174,7 +174,7 @@ __newwin(SCREEN *screen, int nlines, int
 #endif /* HAVE_WCHAR */
 		}
 		lp->hash = __hash((char *)(void *)lp->line,
-  (size_t)(ncols * __LDATASIZE));
+  (size_t)(maxx * __LDATASIZE));
 	}
 	return (win);
 }



CVS commit: [netbsd-8] src/lib/libcurses

2020-07-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul  7 12:48:42 UTC 2020

Modified Files:
src/lib/libcurses [netbsd-8]: ins_wch.c ins_wstr.c insch.c insstr.c

Log Message:
Pull up following revision(s) (requested by uwe in ticket #1567):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
>From Naman Jain in PR lib/55460.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.4.1 src/lib/libcurses/ins_wch.c \
src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.23 -r1.23.6.1 src/lib/libcurses/insch.c
cvs rdiff -u -r1.5 -r1.5.6.1 src/lib/libcurses/insstr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/ins_wch.c
diff -u src/lib/libcurses/ins_wch.c:1.11 src/lib/libcurses/ins_wch.c:1.11.4.1
--- src/lib/libcurses/ins_wch.c:1.11	Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/ins_wch.c	Tue Jul  7 12:48:42 2020
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wch.c,v 1.11 2017/01/31 09:17:53 roy Exp $ */
+/*   $NetBSD: ins_wch.c,v 1.11.4.1 2020/07/07 12:48:42 martin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ins_wch.c,v 1.11 2017/01/31 09:17:53 roy Exp $");
+__RCSID("$NetBSD: ins_wch.c,v 1.11.4.1 2020/07/07 12:48:42 martin Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -86,7 +86,7 @@ mvwins_wch(WINDOW *win, int y, int x, co
 	if (wmove(win, y, x) == ERR)
 		return ERR;
 
-	return wins_wch(stdscr, wch);
+	return wins_wch(win, wch);
 #endif /* HAVE_WCHAR */
 }
 
Index: src/lib/libcurses/ins_wstr.c
diff -u src/lib/libcurses/ins_wstr.c:1.11 src/lib/libcurses/ins_wstr.c:1.11.4.1
--- src/lib/libcurses/ins_wstr.c:1.11	Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/ins_wstr.c	Tue Jul  7 12:48:42 2020
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wstr.c,v 1.11 2017/01/31 09:17:53 roy Exp $ */
+/*   $NetBSD: ins_wstr.c,v 1.11.4.1 2020/07/07 12:48:42 martin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ins_wstr.c,v 1.11 2017/01/31 09:17:53 roy Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.11.4.1 2020/07/07 12:48:42 martin Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -96,7 +96,7 @@ mvwins_wstr(WINDOW *win, int y, int x, c
 	if (wmove(win, y, x) == ERR)
 		return ERR;
 
-	return wins_wstr(stdscr, wstr);
+	return wins_wstr(win, wstr);
 }
 
 /*
@@ -109,7 +109,7 @@ mvwins_nwstr(WINDOW *win, int y, int x, 
 	if (wmove(win, y, x) == ERR)
 		return ERR;
 
-	return wins_nwstr(stdscr, wstr, n);
+	return wins_nwstr(win, wstr, n);
 }
 
 

Index: src/lib/libcurses/insch.c
diff -u src/lib/libcurses/insch.c:1.23 src/lib/libcurses/insch.c:1.23.6.1
--- src/lib/libcurses/insch.c:1.23	Fri Jan  6 13:53:18 2017
+++ src/lib/libcurses/insch.c	Tue Jul  7 12:48:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: insch.c,v 1.23 2017/01/06 13:53:18 roy Exp $	*/
+/*	$NetBSD: insch.c,v 1.23.6.1 2020/07/07 12:48:42 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)insch.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: insch.c,v 1.23 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: insch.c,v 1.23.6.1 2020/07/07 12:48:42 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -79,7 +79,7 @@ mvwinsch(WINDOW *win, int y, int x, chty
 	if (wmove(win, y, x) == ERR)
 		return ERR;
 
-	return winsch(stdscr, ch);
+	return winsch(win, ch);
 }
 
 #endif

Index: src/lib/libcurses/insstr.c
diff -u src/lib/libcurses/insstr.c:1.5 src/lib/libcurses/insstr.c:1.5.6.1
--- src/lib/libcurses/insstr.c:1.5	Fri Jan  6 13:53:18 2017
+++ src/lib/libcurses/insstr.c	Tue Jul  7 12:48:42 2020
@@ -1,4 +1,4 @@
-/*   $NetBSD: insstr.c,v 1.5 2017/01/06 13:53:18 roy Exp $ */
+/*   $NetBSD: insstr.c,v 1.5.6.1 2020/07/07 12:48:42 martin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: insstr.c,v 1.5 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: insstr.c,v 1.5.6.1 2020/07/07 12:48:42 martin Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -103,7 +103,7 @@ mvwinsstr(WINDOW *win, int y, int x, con
 	if (wmove(win, y, x) == ERR)
 		return ERR;
 
-	return winsstr(stdscr, str);
+	return winsstr(win, str);
 }
 
 /*
@@ -117,7 +117,7 @@ mvwinsnstr(WINDOW *win, int y, int x, co
 	if (wmove(win, y, x) == ERR)
 		return ERR;
 
-	return winsnstr(stdscr, str, n);
+	return winsnstr(win, str, n);
 }
 
 #endif



CVS commit: [netbsd-8] src/lib/libcurses

2019-03-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 15 14:30:19 UTC 2019

Modified Files:
src/lib/libcurses [netbsd-8]: get_wch.c getch.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1214):

lib/libcurses/get_wch.c: revision 1.21
lib/libcurses/getch.c: revision 1.71

Rename global variable "state" to "_cursesi_state".

Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.3 -r1.14.4.4 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.65.4.3 -r1.65.4.4 src/lib/libcurses/getch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/get_wch.c
diff -u src/lib/libcurses/get_wch.c:1.14.4.3 src/lib/libcurses/get_wch.c:1.14.4.4
--- src/lib/libcurses/get_wch.c:1.14.4.3	Wed Oct  3 17:49:06 2018
+++ src/lib/libcurses/get_wch.c	Fri Mar 15 14:30:19 2019
@@ -1,4 +1,4 @@
-/*   $NetBSD: get_wch.c,v 1.14.4.3 2018/10/03 17:49:06 martin Exp $ */
+/*   $NetBSD: get_wch.c,v 1.14.4.4 2019/03/15 14:30:19 martin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.14.4.3 2018/10/03 17:49:06 martin Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.14.4.4 2019/03/15 14:30:19 martin Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -49,9 +49,9 @@ __RCSID("$NetBSD: get_wch.c,v 1.14.4.3 2
 #include "keymap.h"
 
 #ifdef HAVE_WCHAR
-static short   wstate;		  /* state of the wcinkey function */
+static short   wstate;		/* state of the wcinkey function */
 #endif /* HAVE_WCHAR */
-extern short state;		/* storage declared in getch.c */
+extern short _cursesi_state;	/* storage declared in getch.c */
 
 /* prototypes for private functions */
 #ifdef HAVE_WCHAR
@@ -223,7 +223,7 @@ inkey(wchar_t *wc, int to, int delay)
 *wc = inbuf[*start];
 *working = *start = (*start +1) % MAX_CBUF_SIZE;
 if (*start == *end) {
-	state = wstate = INKEY_NORM;
+	_cursesi_state = wstate = INKEY_NORM;
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 	"inkey: WCASSEMBLING=>NORM, "
@@ -231,7 +231,7 @@ inkey(wchar_t *wc, int to, int delay)
 	*start, *working, *end);
 #endif /* DEBUG */
 } else {
-	state = wstate = INKEY_BACKOUT;
+	_cursesi_state = wstate = INKEY_BACKOUT;
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 	"inkey: WCASSEMBLING=>BACKOUT, "
@@ -290,7 +290,7 @@ inkey(wchar_t *wc, int to, int delay)
 
 if (*start == *end) {
 	/* only one char processed */
-	state = wstate = INKEY_NORM;
+	_cursesi_state = wstate = INKEY_NORM;
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 	"inkey: WCASSEMBLING=>NORM, "
@@ -300,7 +300,7 @@ inkey(wchar_t *wc, int to, int delay)
 } else {
 	/* otherwise we must have more than
 	 * one char to backout */
-	state = wstate = INKEY_BACKOUT;
+	_cursesi_state = wstate = INKEY_BACKOUT;
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 	"inkey: WCASSEMBLING=>BACKOUT, "
@@ -388,7 +388,7 @@ inkey(wchar_t *wc, int to, int delay)
 			}
 
 			if (*start == *end) {	/* only one char processed */
-state = wstate = INKEY_NORM;
+_cursesi_state = wstate = INKEY_NORM;
 #ifdef DEBUG
 __CTRACE(__CTRACE_INPUT,
 "inkey: Empty cbuf=>NORM, "
@@ -398,7 +398,7 @@ inkey(wchar_t *wc, int to, int delay)
 			} else {
 /* otherwise we must have more than one
  * char to backout */
-state = wstate = INKEY_BACKOUT;
+_cursesi_state = wstate = INKEY_BACKOUT;
 #ifdef DEBUG
 __CTRACE(__CTRACE_INPUT,
 "inkey: Non-empty cbuf=>BACKOUT, "
@@ -423,7 +423,7 @@ inkey(wchar_t *wc, int to, int delay)
 #endif /* DEBUG */
 if (*start == *end) {
 	/* if it is go back to normal */
-	state = wstate = INKEY_NORM;
+	_cursesi_state = wstate = INKEY_NORM;
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 	"[inkey]=>NORM, start(%d), "
@@ -432,7 +432,7 @@ inkey(wchar_t *wc, int to, int delay)
 #endif /* DEBUG */
 } else {
 	/* otherwise go to backout state */
-	state = wstate = INKEY_BACKOUT;
+	_cursesi_state = wstate = INKEY_BACKOUT;
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 	"[inkey]=>BACKOUT, start(%d), "

Index: src/lib/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.65.4.3 src/lib/libcurses/getch.c:1.65.4.4
--- src/lib/libcurses/getch.c:1.65.4.3	Wed Oct  3 17:49:06 2018
+++ src/lib/libcurses/getch.c	Fri Mar 15 14:30:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: getch.c,v 1.65.4.3 2018/10/03 17:49:06 martin Exp $	*/
+/*	$NetBSD: getch.c,v 1.65.4.4 2019/03/15 14:30:19 

CVS commit: [netbsd-8] src/lib/libcurses

2018-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  9 10:01:38 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: newwin.c refresh.c

Log Message:
Back out the following revision(s) (requested by roy in ticket #1049):

lib/libcurses/refresh.c: revision 1.89
lib/libcurses/newwin.c: revision 1.53

  curses: allow drawing the lowest right hand cell of the terminal

  This is a historical behaviour that needs fixing
  If any terminal does scroll when drawing in the lowest right hand cell
  of the terminal then an entry should be made in the terminfo database
  (currently there is no standard code) to state that and define
  __SCROLLWIN as before.

  Fixes PR# 30978.

As discussed in the PR, this change introduces a regression.


To generate a diff of this commit:
cvs rdiff -u -r1.50.6.2 -r1.50.6.3 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.88.4.1 -r1.88.4.2 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/newwin.c
diff -u src/lib/libcurses/newwin.c:1.50.6.2 src/lib/libcurses/newwin.c:1.50.6.3
--- src/lib/libcurses/newwin.c:1.50.6.2	Tue Oct  9 09:49:35 2018
+++ src/lib/libcurses/newwin.c	Tue Oct  9 10:01:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.50.6.2 2018/10/09 09:49:35 martin Exp $	*/
+/*	$NetBSD: newwin.c,v 1.50.6.3 2018/10/09 10:01:38 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c	8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.50.6.2 2018/10/09 09:49:35 martin Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.50.6.3 2018/10/09 10:01:38 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -422,14 +422,8 @@ __swflags(WINDOW *win)
 		win->flags |= __ENDLINE;
 		if (win->begx == 0 && win->maxy == LINES && win->begy == 0)
 			win->flags |= __FULLWIN;
-		/*
-		 * Enable this if we have a terminfo setting which claims
-		 * terminal will scroll. Currently there is none.
-		 */
-#if 0
 		if (win->begy + win->maxy == LINES)
 			win->flags |= __SCROLLWIN;
-#endif
 	}
 }
 

Index: src/lib/libcurses/refresh.c
diff -u src/lib/libcurses/refresh.c:1.88.4.1 src/lib/libcurses/refresh.c:1.88.4.2
--- src/lib/libcurses/refresh.c:1.88.4.1	Tue Oct  9 09:49:35 2018
+++ src/lib/libcurses/refresh.c	Tue Oct  9 10:01:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.88.4.1 2018/10/09 09:49:35 martin Exp $	*/
+/*	$NetBSD: refresh.c,v 1.88.4.2 2018/10/09 10:01:38 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)refresh.c	8.7 (Berkeley) 8/13/94";
 #else
-__RCSID("$NetBSD: refresh.c,v 1.88.4.1 2018/10/09 09:49:35 martin Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.88.4.2 2018/10/09 10:01:38 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -1208,46 +1208,50 @@ makech(int wy)
 			wx++;
 			if (wx >= win->maxx &&
 			wy == win->maxy - 1 && !_cursesi_screen->curwin) {
-if (win->flags & __ENDLINE)
-	__unsetattr(1);
-if (!(win->flags & __SCROLLWIN)) {
-	if (!_cursesi_screen->curwin) {
-		csp->attr = nsp->attr;
-		csp->ch = nsp->ch;
+if (win->flags & __SCROLLOK) {
+	if (win->flags & __ENDLINE)
+		__unsetattr(1);
+	if (!(win->flags & __SCROLLWIN)) {
+		if (!_cursesi_screen->curwin) {
+			csp->attr = nsp->attr;
+			csp->ch = nsp->ch;
 #ifdef HAVE_WCHAR
-		if (_cursesi_copy_nsp(nsp->nsp, csp) == ERR)
-			return ERR;
+			if (_cursesi_copy_nsp(nsp->nsp, csp) == ERR)
+return ERR;
 #endif /* HAVE_WCHAR */
-	}
+		}
 #ifndef HAVE_WCHAR
-	__cputchar((int) nsp->ch);
+		__cputchar((int) nsp->ch);
 #else
-	if ( WCOL( *nsp ) > 0 ) {
-		__cputwchar((int)nsp->ch);
+		if ( WCOL( *nsp ) > 0 ) {
+			__cputwchar((int)nsp->ch);
 #ifdef DEBUG
-		__CTRACE(__CTRACE_REFRESH,
-		"makech: (%d,%d)putwchar(0x%x)\n",
-			wy, wx - 1,
-			nsp->ch );
+			__CTRACE(__CTRACE_REFRESH,
+			"makech: (%d,%d)putwchar(0x%x)\n",
+wy, wx - 1,
+nsp->ch );
 #endif /* DEBUG */
-		/*
-		 * Output non-spacing
-		 * characters for the
-		 * cell.
-		 */
-		__cursesi_putnsp(nsp->nsp, wy, wx);
-	}
+			/*
+			 * Output non-spacing
+			 * characters for the
+			 * cell.
+			 */
+			__cursesi_putnsp(nsp->nsp,
+	 wy, wx);
+
+		}
 #endif /* HAVE_WCHAR */
+	}
+	if (wx < curscr->maxx) {
+		domvcur(win,
+		_cursesi_screen->ly, wx,
+		(int)(win->maxy - 1),
+		(int)(win->maxx - 1));
+	}
+	_cursesi_screen->ly = win->maxy - 1;
+	_cursesi_screen->lx = win->maxx - 1;
+	return (OK);
 }
-if (wx < curscr->maxx) {
-	domvcur(win,
-	_cursesi_screen->ly, wx,
-	(int)(win->maxy - 1),
-	(int)(win->maxx - 1));
-}
-_cursesi_screen->ly = win->maxy - 1;
-_cursesi_screen->lx = 

CVS commit: [netbsd-8] src/lib/libcurses

2018-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  9 09:49:35 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: newwin.c refresh.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #1049):

lib/libcurses/refresh.c: revision 1.89
lib/libcurses/newwin.c: revision 1.53

curses: allow drawing the lowest right hand cell of the terminal

This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.


To generate a diff of this commit:
cvs rdiff -u -r1.50.6.1 -r1.50.6.2 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.88 -r1.88.4.1 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/newwin.c
diff -u src/lib/libcurses/newwin.c:1.50.6.1 src/lib/libcurses/newwin.c:1.50.6.2
--- src/lib/libcurses/newwin.c:1.50.6.1	Thu Oct  4 10:20:12 2018
+++ src/lib/libcurses/newwin.c	Tue Oct  9 09:49:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.50.6.1 2018/10/04 10:20:12 martin Exp $	*/
+/*	$NetBSD: newwin.c,v 1.50.6.2 2018/10/09 09:49:35 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c	8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.50.6.1 2018/10/04 10:20:12 martin Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.50.6.2 2018/10/09 09:49:35 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -422,8 +422,14 @@ __swflags(WINDOW *win)
 		win->flags |= __ENDLINE;
 		if (win->begx == 0 && win->maxy == LINES && win->begy == 0)
 			win->flags |= __FULLWIN;
+		/*
+		 * Enable this if we have a terminfo setting which claims
+		 * terminal will scroll. Currently there is none.
+		 */
+#if 0
 		if (win->begy + win->maxy == LINES)
 			win->flags |= __SCROLLWIN;
+#endif
 	}
 }
 

Index: src/lib/libcurses/refresh.c
diff -u src/lib/libcurses/refresh.c:1.88 src/lib/libcurses/refresh.c:1.88.4.1
--- src/lib/libcurses/refresh.c:1.88	Mon Mar 20 20:42:39 2017
+++ src/lib/libcurses/refresh.c	Tue Oct  9 09:49:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.88 2017/03/20 20:42:39 christos Exp $	*/
+/*	$NetBSD: refresh.c,v 1.88.4.1 2018/10/09 09:49:35 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)refresh.c	8.7 (Berkeley) 8/13/94";
 #else
-__RCSID("$NetBSD: refresh.c,v 1.88 2017/03/20 20:42:39 christos Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.88.4.1 2018/10/09 09:49:35 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -1208,50 +1208,46 @@ makech(int wy)
 			wx++;
 			if (wx >= win->maxx &&
 			wy == win->maxy - 1 && !_cursesi_screen->curwin) {
-if (win->flags & __SCROLLOK) {
-	if (win->flags & __ENDLINE)
-		__unsetattr(1);
-	if (!(win->flags & __SCROLLWIN)) {
-		if (!_cursesi_screen->curwin) {
-			csp->attr = nsp->attr;
-			csp->ch = nsp->ch;
+if (win->flags & __ENDLINE)
+	__unsetattr(1);
+if (!(win->flags & __SCROLLWIN)) {
+	if (!_cursesi_screen->curwin) {
+		csp->attr = nsp->attr;
+		csp->ch = nsp->ch;
 #ifdef HAVE_WCHAR
-			if (_cursesi_copy_nsp(nsp->nsp, csp) == ERR)
-return ERR;
+		if (_cursesi_copy_nsp(nsp->nsp, csp) == ERR)
+			return ERR;
 #endif /* HAVE_WCHAR */
-		}
+	}
 #ifndef HAVE_WCHAR
-		__cputchar((int) nsp->ch);
+	__cputchar((int) nsp->ch);
 #else
-		if ( WCOL( *nsp ) > 0 ) {
-			__cputwchar((int)nsp->ch);
+	if ( WCOL( *nsp ) > 0 ) {
+		__cputwchar((int)nsp->ch);
 #ifdef DEBUG
-			__CTRACE(__CTRACE_REFRESH,
-			"makech: (%d,%d)putwchar(0x%x)\n",
-wy, wx - 1,
-nsp->ch );
+		__CTRACE(__CTRACE_REFRESH,
+		"makech: (%d,%d)putwchar(0x%x)\n",
+			wy, wx - 1,
+			nsp->ch );
 #endif /* DEBUG */
-			/*
-			 * Output non-spacing
-			 * characters for the
-			 * cell.
-			 */
-			__cursesi_putnsp(nsp->nsp,
-	 wy, wx);
-
-		}
-#endif /* HAVE_WCHAR */
-	}
-	if (wx < curscr->maxx) {
-		domvcur(win,
-		_cursesi_screen->ly, wx,
-		(int)(win->maxy - 1),
-		(int)(win->maxx - 1));
+		/*
+		 * Output non-spacing
+		 * characters for the
+		 * cell.
+		 */
+		__cursesi_putnsp(nsp->nsp, wy, wx);
 	}
-	_cursesi_screen->ly = win->maxy - 1;
-	_cursesi_screen->lx = win->maxx - 1;
-	return (OK);
+#endif /* HAVE_WCHAR */
 }
+if (wx < curscr->maxx) {
+	domvcur(win,
+	_cursesi_screen->ly, wx,
+	(int)(win->maxy - 1),
+	(int)(win->maxx - 1));
+}
+_cursesi_screen->ly = win->maxy - 1;
+_cursesi_screen->lx = win->maxx - 1;
+return OK;
 			}
 			if (wx < win->maxx || wy < win->maxy - 

CVS commit: [netbsd-8] src/lib/libcurses

2018-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct  8 19:06:52 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: curses_private.h slk.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #1048):

lib/libcurses/curses_private.h: revision 1.66
lib/libcurses/slk.c: revision 1.3
lib/libcurses/slk.c: revision 1.4

curses: declare SLK format as invalid until slk_init(3) called

If we don't, then when __slk_init with a valid format of 0 it sets
up labels to be drawn without a window.

 -

curses: once __slk_init is called, reset slk_fmt

This allows soft label keys to be used on more than one terminal.


To generate a diff of this commit:
cvs rdiff -u -r1.62.4.2 -r1.62.4.3 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.2 -r1.2.8.1 src/lib/libcurses/slk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.62.4.2 src/lib/libcurses/curses_private.h:1.62.4.3
--- src/lib/libcurses/curses_private.h:1.62.4.2	Thu Oct  4 10:20:12 2018
+++ src/lib/libcurses/curses_private.h	Mon Oct  8 19:06:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_private.h,v 1.62.4.2 2018/10/04 10:20:12 martin Exp $	*/
+/*	$NetBSD: curses_private.h,v 1.62.4.3 2018/10/08 19:06:52 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -289,6 +289,7 @@ struct __screen {
 	bool		 is_term_slk;
 	WINDOW		*slk_window;
 	int		 slk_format;
+#define	SLK_FMT_INVAL	-1
 #define	SLK_FMT_3_2_3	0
 #define	SLK_FMT_4_4	1
 	int		 slk_nlabels;

Index: src/lib/libcurses/slk.c
diff -u src/lib/libcurses/slk.c:1.2 src/lib/libcurses/slk.c:1.2.8.1
--- src/lib/libcurses/slk.c:1.2	Mon Jan 30 17:15:52 2017
+++ src/lib/libcurses/slk.c	Mon Oct  8 19:06:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: slk.c,v 1.2 2017/01/30 17:15:52 roy Exp $	*/
+/*	$NetBSD: slk.c,v 1.2.8.1 2018/10/08 19:06:52 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: slk.c,v 1.2 2017/01/30 17:15:52 roy Exp $");
+__RCSID("$NetBSD: slk.c,v 1.2.8.1 2018/10/08 19:06:52 martin Exp $");
 #endif/* not lint */
 
 #include 
@@ -57,7 +57,7 @@ __RCSID("$NetBSD: slk.c,v 1.2 2017/01/30
 #define	SLK_SIZE	MAX_SLK_COLS
 #endif
 
-static int	 slk_fmt;	/* fmt of slk_init */
+static int	 slk_fmt = SLK_FMT_INVAL;	/* fmt of slk_init */
 
 /* Safe variants of public functions. */
 static int	 __slk_attron(SCREEN *, const chtype);
@@ -562,6 +562,10 @@ __slk_init(SCREEN *screen)
 	__slk_free(screen);	/* safety */
 
 	screen->slk_format = slk_fmt;
+	if (slk_fmt == SLK_FMT_INVAL)
+		return OK;
+	slk_fmt = SLK_FMT_INVAL;
+
 	switch(screen->slk_format) {
 	case SLK_FMT_3_2_3:
 	case SLK_FMT_4_4:



CVS commit: [netbsd-8] src/lib/libcurses

2018-10-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  4 10:20:13 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: curses_private.h curses_screen.3 fileio.c
initscr.c newwin.c resize.c ripoffline.c screen.c setterm.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

 -

curses: resize ripped off windows
The application must still redraw them though.

 -

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function


To generate a diff of this commit:
cvs rdiff -u -r1.62.4.1 -r1.62.4.2 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.23 -r1.23.4.1 src/lib/libcurses/curses_screen.3
cvs rdiff -u -r1.5 -r1.5.6.1 src/lib/libcurses/fileio.c
cvs rdiff -u -r1.32 -r1.32.6.1 src/lib/libcurses/initscr.c
cvs rdiff -u -r1.50 -r1.50.6.1 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.26.4.1 -r1.26.4.2 src/lib/libcurses/resize.c
cvs rdiff -u -r1.3 -r1.3.6.1 src/lib/libcurses/ripoffline.c
cvs rdiff -u -r1.33 -r1.33.4.1 src/lib/libcurses/screen.c
cvs rdiff -u -r1.66 -r1.66.4.1 src/lib/libcurses/setterm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.62.4.1 src/lib/libcurses/curses_private.h:1.62.4.2
--- src/lib/libcurses/curses_private.h:1.62.4.1	Thu Sep 27 15:12:15 2018
+++ src/lib/libcurses/curses_private.h	Thu Oct  4 10:20:12 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_private.h,v 1.62.4.1 2018/09/27 15:12:15 martin Exp $	*/
+/*	$NetBSD: curses_private.h,v 1.62.4.2 2018/10/04 10:20:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -368,7 +368,7 @@ void	__cursesi_chtype_to_cchar(chtype, c
 int	 __fgetc_resize(FILE *);
 int	 __unget(wint_t);
 int	 __mvcur(int, int, int, int, int);
-WINDOW  *__newwin(SCREEN *, int, int, int, int, int);
+WINDOW  *__newwin(SCREEN *, int, int, int, int, int, int);
 int	 __nodelay(void);
 int	 __notimeout(void);
 void	 __restartwin(void);
@@ -378,9 +378,10 @@ void __restore_meta_state(void);
 void	 __restore_termios(void);
 void	 __restore_stophandler(void);
 void	 __restore_winchhandler(void);
-int	 __ripoffscreen(SCREEN *, int *);
-void	 __ripoffresize(SCREEN *);
-int	 __rippedlines(const SCREEN *);
+int	 __ripoffscreen(SCREEN *);
+int	 __ripoffresize(SCREEN *);
+void	 __ripofftouch(SCREEN *);
+int	 __rippedlines(const SCREEN *, int);
 void	 __save_termios(void);
 void	 __set_color(WINDOW *win, attr_t attr);
 void	 __set_stophandler(void);

Index: src/lib/libcurses/curses_screen.3
diff -u src/lib/libcurses/curses_screen.3:1.23 src/lib/libcurses/curses_screen.3:1.23.4.1
--- src/lib/libcurses/curses_screen.3:1.23	Tue Jan 24 16:45:41 2017
+++ src/lib/libcurses/curses_screen.3	Thu Oct  4 10:20:12 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_screen.3,v 1.23 2017/01/24 16:45:41 roy Exp $
+.\"	$NetBSD: curses_screen.3,v 1.23.4.1 2018/10/04 10:20:12 martin Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd January 24, 2017
+.Dd October 2, 2018
 .Dt CURSES_SCREEN 3
 .Os
 .Sh NAME
@@ -74,7 +74,7 @@
 .Fn isendwin "void"
 .Ft bool
 .Fn is_term_resized "int lines" "int cols"
-.Fn int
+.Ft int
 .Fn resize_term "int lines" "int cols"
 .Ft int
 .Fn resizeterm "int lines" "int cols"
@@ -216,7 +216,7 @@ Set lines equal to 1.
 .Pp
 The
 .Fn ripoffline
-funcion will rip a line from
+function will rip a line from
 .Dv stdscr
 at the top if
 .Fa line
@@ -239,8 +239,6 @@ or
 .Xr doupdate 3 ,
 but may call
 .Xr wnoutrefresh 3 .
-.Dv LINES
-will be reduced by the total number of lines ripped off.
 .Fn ripoffline
 can be called up to five times.
 .Pp

Index: src/lib/libcurses/fileio.c
diff -u src/lib/libcurses/fileio.c:1.5 src/lib/libcurses/fileio.c:1.5.6.1
--- src/lib/libcurses/fileio.c:1.5	Sat Oct 22 21:55:06 2016
+++ src/lib/libcurses/fileio.c	Thu Oct  4 10:20:12 2018
@@ -1,4 +1,4 

CVS commit: [netbsd-8] src/lib/libcurses

2018-10-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  3 17:49:06 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: get_wch.c getch.c resize.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #1043):

lib/libcurses/resize.c: revision 1.27
lib/libcurses/get_wch.c: revision 1.19
lib/libcurses/getch.c: revision 1.70

curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

OK kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.2 -r1.14.4.3 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.65.4.2 -r1.65.4.3 src/lib/libcurses/getch.c
cvs rdiff -u -r1.26 -r1.26.4.1 src/lib/libcurses/resize.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/get_wch.c
diff -u src/lib/libcurses/get_wch.c:1.14.4.2 src/lib/libcurses/get_wch.c:1.14.4.3
--- src/lib/libcurses/get_wch.c:1.14.4.2	Thu Sep 27 15:12:15 2018
+++ src/lib/libcurses/get_wch.c	Wed Oct  3 17:49:06 2018
@@ -1,4 +1,4 @@
-/*   $NetBSD: get_wch.c,v 1.14.4.2 2018/09/27 15:12:15 martin Exp $ */
+/*   $NetBSD: get_wch.c,v 1.14.4.3 2018/10/03 17:49:06 martin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.14.4.2 2018/09/27 15:12:15 martin Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.14.4.3 2018/10/03 17:49:06 martin Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -530,8 +530,8 @@ wget_wch(WINDOW *win, wint_t *ch)
 	__echoit, __rawmode, _cursesi_screen->nl, win->flags);
 #endif
 	if (_cursesi_screen->resized) {
-		_cursesi_screen->resized = 0;
 		resizeterm(LINES, COLS);
+		_cursesi_screen->resized = 0;
 		*ch = KEY_RESIZE;
 		return KEY_CODE_YES;
 	}
@@ -684,8 +684,8 @@ __fgetwc_resize(FILE *infd, bool *resize
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT, "__fgetwc_resize returning KEY_RESIZE\n");
 #endif
-	_cursesi_screen->resized = 0;
 	resizeterm(LINES, COLS);
+	_cursesi_screen->resized = 0;
 	*resized = true;
 	return c;
 }

Index: src/lib/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.65.4.2 src/lib/libcurses/getch.c:1.65.4.3
--- src/lib/libcurses/getch.c:1.65.4.2	Thu Sep 27 15:12:15 2018
+++ src/lib/libcurses/getch.c	Wed Oct  3 17:49:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: getch.c,v 1.65.4.2 2018/09/27 15:12:15 martin Exp $	*/
+/*	$NetBSD: getch.c,v 1.65.4.3 2018/10/03 17:49:06 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)getch.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: getch.c,v 1.65.4.2 2018/09/27 15:12:15 martin Exp $");
+__RCSID("$NetBSD: getch.c,v 1.65.4.3 2018/10/03 17:49:06 martin Exp $");
 #endif
 #endif	/* not lint */
 
@@ -824,8 +824,8 @@ wgetch(WINDOW *win)
 	__echoit, __rawmode, _cursesi_screen->nl, win->flags, win->delay);
 #endif
 	if (_cursesi_screen->resized) {
-		_cursesi_screen->resized = 0;
 		resizeterm(LINES, COLS);
+		_cursesi_screen->resized = 0;
 #ifdef DEBUG
 		__CTRACE(__CTRACE_INPUT, "wgetch returning KEY_RESIZE\n");
 #endif
@@ -1013,7 +1013,7 @@ __fgetc_resize(FILE *infd)
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT, "__fgetc_resize returning KEY_RESIZE\n");
 #endif
-	_cursesi_screen->resized = 0;
 	resizeterm(LINES, COLS);
+	_cursesi_screen->resized = 0;
 	return KEY_RESIZE;
 }

Index: src/lib/libcurses/resize.c
diff -u src/lib/libcurses/resize.c:1.26 src/lib/libcurses/resize.c:1.26.4.1
--- src/lib/libcurses/resize.c:1.26	Tue Jan 24 17:27:30 2017
+++ src/lib/libcurses/resize.c	Wed Oct  3 17:49:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: resize.c,v 1.26 2017/01/24 17:27:30 roy Exp $	*/
+/*	$NetBSD: resize.c,v 1.26.4.1 2018/10/03 17:49:06 martin Exp $	*/
 
 /*
  * Copyright (c) 2001
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)resize.c   blymn 2001/08/26";
 #else
-__RCSID("$NetBSD: resize.c,v 1.26 2017/01/24 17:27:30 roy Exp $");
+__RCSID("$NetBSD: resize.c,v 1.26.4.1 2018/10/03 17:49:06 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -163,6 +163,8 @@ resizeterm(int nlines, int ncols)
 	__CTRACE(__CTRACE_WINDOW, "resizeterm: (%d, %d)\n", nlines, ncols);
 #endif
 
+	/* Unconditionally inform application screen has been resized. */
+	_cursesi_screen->resized = 1;
 
 	if (!is_term_resized(nlines, ncols))
 		return OK;



CVS commit: [netbsd-8] src/lib/libcurses

2018-09-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 27 15:12:15 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: curses_private.h get_wch.c getch.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #1042):
lib/libcurses/getch.c: revision 1.68
lib/libcurses/getch.c: revision 1.69
lib/libcurses/get_wch.c: revision 1.17
lib/libcurses/get_wch.c: revision 1.18
lib/libcurses/curses_private.h: revision 1.63
curses: unify resize handling in getch
Instead of testing each fgetc call for resize event, add the wrapper
__fgetc_resize to simplify the logic.
While here, ensure that get_wch uses the correct input stream which
may or may not be stdin.
curses: call resizeterm if getch issues KEY_RESIZE
This fixes PR #53633.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.62.4.1 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.14.4.1 -r1.14.4.2 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.65.4.1 -r1.65.4.2 src/lib/libcurses/getch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.62 src/lib/libcurses/curses_private.h:1.62.4.1
--- src/lib/libcurses/curses_private.h:1.62	Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/curses_private.h	Thu Sep 27 15:12:15 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_private.h,v 1.62 2017/01/31 09:17:53 roy Exp $	*/
+/*	$NetBSD: curses_private.h,v 1.62.4.1 2018/09/27 15:12:15 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -365,6 +365,7 @@ void	__cursesi_win_free_nsp(WINDOW *);
 void	__cursesi_putnsp(nschar_t *, const int, const int);
 void	__cursesi_chtype_to_cchar(chtype, cchar_t *);
 #endif /* HAVE_WCHAR */
+int	 __fgetc_resize(FILE *);
 int	 __unget(wint_t);
 int	 __mvcur(int, int, int, int, int);
 WINDOW  *__newwin(SCREEN *, int, int, int, int, int);

Index: src/lib/libcurses/get_wch.c
diff -u src/lib/libcurses/get_wch.c:1.14.4.1 src/lib/libcurses/get_wch.c:1.14.4.2
--- src/lib/libcurses/get_wch.c:1.14.4.1	Thu Sep 27 14:59:28 2018
+++ src/lib/libcurses/get_wch.c	Thu Sep 27 15:12:15 2018
@@ -1,4 +1,4 @@
-/*   $NetBSD: get_wch.c,v 1.14.4.1 2018/09/27 14:59:28 martin Exp $ */
+/*   $NetBSD: get_wch.c,v 1.14.4.2 2018/09/27 15:12:15 martin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.14.4.1 2018/09/27 14:59:28 martin Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.14.4.2 2018/09/27 15:12:15 martin Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -56,6 +56,7 @@ extern short state;		/* storage declared
 /* prototypes for private functions */
 #ifdef HAVE_WCHAR
 static int inkey(wchar_t *wc, int to, int delay);
+static wint_t __fgetwc_resize(FILE *infd, bool *resized);
 #endif /* HAVE_WCHAR */
 
 #ifdef HAVE_WCHAR
@@ -100,14 +101,10 @@ inkey(wchar_t *wc, int to, int delay)
 		if (wstate == INKEY_NORM) {
 			if (delay && __timeout(delay) == ERR)
 return ERR;
-			c = fgetc(infd);
-			if (c == WEOF) {
+			c = __fgetc_resize(infd);
+			if (c == ERR || c == KEY_RESIZE) {
 clearerr(infd);
-if (errno == EINTR && _cursesi_screen->resized) {
-	_cursesi_screen->resized = 0;
-	return KEY_RESIZE;
-} else
-	return ERR;
+return c;
 			}
 
 			if (delay && (__notimeout() == ERR))
@@ -152,14 +149,10 @@ inkey(wchar_t *wc, int to, int delay)
 	return ERR;
 			}
 
-			c = fgetc(infd);
+			c = __fgetc_resize(infd);
 			if (ferror(infd)) {
 clearerr(infd);
-if (errno == EINTR && _cursesi_screen->resized) {
-	_cursesi_screen->resized = 0;
-	return KEY_RESIZE;
-} else
-	return ERR;
+return c;
 			}
 
 			if ((to || delay) && (__notimeout() == ERR))
@@ -206,10 +199,10 @@ inkey(wchar_t *wc, int to, int delay)
 	return ERR;
 			}
 
-			c = fgetc(infd);
+			c = __fgetc_resize(infd);
 			if (ferror(infd)) {
 clearerr(infd);
-return ERR;
+return c;
 			}
 
 			if ((to || delay) && (__notimeout() == ERR))
@@ -538,6 +531,7 @@ wget_wch(WINDOW *win, wint_t *ch)
 #endif
 	if (_cursesi_screen->resized) {
 		_cursesi_screen->resized = 0;
+		resizeterm(LINES, COLS);
 		*ch = KEY_RESIZE;
 		return KEY_CODE_YES;
 	}
@@ -583,6 +577,8 @@ wget_wch(WINDOW *win, wint_t *ch)
 		if ( ret == ERR )
 			return ERR;
 	} else {
+		bool resized;
+
 		switch (win->delay) {
 			case -1:
 break;
@@ -596,17 +592,11 @@ wget_wch(WINDOW *win, wint_t *ch)
 break;
 		}
 
-		c = getwchar();
-		if (feof(infd)) {
+		c = __fgetwc_resize(infd, );
+		if (c == WEOF) {
 			clearerr(infd);
 			__restore_termios();
-			return ERR;	/* we have timed out */
-		}
-
-		if (ferror(infd)) {
-			clearerr(infd);
-			if (errno == EINTR && _cursesi_screen->resized) {
-_cursesi_screen->resized = 0;
+			if (resized) {
 *ch = KEY_RESIZE;
 return KEY_CODE_YES;
 			} else
@@ -674,3 +664,29 @@ 

CVS commit: [netbsd-8] src/lib/libcurses

2018-09-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 27 15:02:26 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: move.c

Log Message:
Pull up following revision(s) (requested by kamil in ticket #1040):

lib/libcurses/move.c: revision 1.19

According to POSIX moving the cursor in curses(3) touches the window

Mark the old and new lines as dirty, so they will be refreshed upon next
call to getch(3)-like routine.

This also matches the ncurses behavior.
Reviewed by 


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.6.1 src/lib/libcurses/move.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/move.c
diff -u src/lib/libcurses/move.c:1.18 src/lib/libcurses/move.c:1.18.6.1
--- src/lib/libcurses/move.c:1.18	Fri Jan  6 13:53:18 2017
+++ src/lib/libcurses/move.c	Thu Sep 27 15:02:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: move.c,v 1.18 2017/01/06 13:53:18 roy Exp $	*/
+/*	$NetBSD: move.c,v 1.18.6.1 2018/09/27 15:02:26 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)move.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: move.c,v 1.18 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: move.c,v 1.18.6.1 2018/09/27 15:02:26 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -72,8 +72,10 @@ wmove(WINDOW *win, int y, int x)
 		return ERR;
 	win->curx = x;
 	win->alines[win->cury]->flags &= ~__ISPASTEOL;
+	win->alines[win->cury]->flags |= __ISDIRTY;
 	win->cury = y;
 	win->alines[y]->flags &= ~__ISPASTEOL;
+	win->alines[y]->flags |= __ISDIRTY;
 	return OK;
 }
 



CVS commit: [netbsd-8] src/lib/libcurses

2018-09-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 27 14:59:28 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: get_wch.c getch.c tstp.c

Log Message:
Pull up following revision(s) (requested by kamil in ticket #1039):

lib/libcurses/getch.c: revision 1.66
lib/libcurses/getch.c: revision 1.67
lib/libcurses/tstp.c: revision 1.43
lib/libcurses/get_wch.c: revision 1.15
lib/libcurses/get_wch.c: revision 1.16

PR lib/53615
getch() and get_wch() should return KEY_RESIZE when interrupted by SIGWIN=
CH.

OK roy

 -

PR lib/53615
Before invoking a previous signal handler, make sure it is not SIG_*.
Fix potential crash with SIGWINCH.

OK roy

 -

Correct detecting of terminal resize in curses(3) with keypad(,TRUE)
A previous change fixed only keypad(,FALSE) scenarios.

 -

Handle catching terminal resize in INKEY_NORM and INKEY_ASSEMBLING (in the
middle of assembling a key code from passed codes) as both accept keys with
fgetc(3) and both can be in theory interrupted with a resize.

PR lib/53615


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.4.1 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.65 -r1.65.4.1 src/lib/libcurses/getch.c
cvs rdiff -u -r1.42 -r1.42.6.1 src/lib/libcurses/tstp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/get_wch.c
diff -u src/lib/libcurses/get_wch.c:1.14 src/lib/libcurses/get_wch.c:1.14.4.1
--- src/lib/libcurses/get_wch.c:1.14	Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/get_wch.c	Thu Sep 27 14:59:28 2018
@@ -1,4 +1,4 @@
-/*   $NetBSD: get_wch.c,v 1.14 2017/01/31 09:17:53 roy Exp $ */
+/*   $NetBSD: get_wch.c,v 1.14.4.1 2018/09/27 14:59:28 martin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,9 +36,10 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.14 2017/01/31 09:17:53 roy Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.14.4.1 2018/09/27 14:59:28 martin Exp $");
 #endif		  /* not lint */
 
+#include 
 #include 
 #include 
 #include 
@@ -102,7 +103,11 @@ inkey(wchar_t *wc, int to, int delay)
 			c = fgetc(infd);
 			if (c == WEOF) {
 clearerr(infd);
-return ERR;
+if (errno == EINTR && _cursesi_screen->resized) {
+	_cursesi_screen->resized = 0;
+	return KEY_RESIZE;
+} else
+	return ERR;
 			}
 
 			if (delay && (__notimeout() == ERR))
@@ -150,7 +155,11 @@ inkey(wchar_t *wc, int to, int delay)
 			c = fgetc(infd);
 			if (ferror(infd)) {
 clearerr(infd);
-return ERR;
+if (errno == EINTR && _cursesi_screen->resized) {
+	_cursesi_screen->resized = 0;
+	return KEY_RESIZE;
+} else
+	return ERR;
 			}
 
 			if ((to || delay) && (__notimeout() == ERR))
@@ -596,7 +605,12 @@ wget_wch(WINDOW *win, wint_t *ch)
 
 		if (ferror(infd)) {
 			clearerr(infd);
-			return ERR;
+			if (errno == EINTR && _cursesi_screen->resized) {
+_cursesi_screen->resized = 0;
+*ch = KEY_RESIZE;
+return KEY_CODE_YES;
+			} else
+return ERR;
 		} else {
 			ret = c;
 			inp = c;

Index: src/lib/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.65 src/lib/libcurses/getch.c:1.65.4.1
--- src/lib/libcurses/getch.c:1.65	Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/getch.c	Thu Sep 27 14:59:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: getch.c,v 1.65 2017/01/31 09:17:53 roy Exp $	*/
+/*	$NetBSD: getch.c,v 1.65.4.1 2018/09/27 14:59:28 martin Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,10 +34,11 @@
 #if 0
 static char sccsid[] = "@(#)getch.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: getch.c,v 1.65 2017/01/31 09:17:53 roy Exp $");
+__RCSID("$NetBSD: getch.c,v 1.65.4.1 2018/09/27 14:59:28 martin Exp $");
 #endif
 #endif	/* not lint */
 
+#include 
 #include 
 #include 
 #include 
@@ -562,7 +563,11 @@ reread:
 			c = fgetc(infd);
 			if (c == EOF) {
 clearerr(infd);
-return ERR;
+if (errno == EINTR && _cursesi_screen->resized) {
+	_cursesi_screen->resized = 0;
+	return KEY_RESIZE;
+} else
+	return ERR;
 			}
 
 			if (delay && (__notimeout() == ERR))
@@ -604,7 +609,11 @@ reread:
 			c = fgetc(infd);
 			if (ferror(infd)) {
 clearerr(infd);
-return ERR;
+if (errno == EINTR && _cursesi_screen->resized) {
+	_cursesi_screen->resized = 0;
+	return KEY_RESIZE;
+} else
+	return ERR;
 			}
 
 			if ((to || delay) && (__notimeout() == ERR))
@@ -889,7 +898,11 @@ wgetch(WINDOW *win)
 
 		if (ferror(infd)) {
 			clearerr(infd);
-			inp = ERR;
+			if (errno == EINTR && _cursesi_screen->resized) {
+_cursesi_screen->resized = 0;
+inp = KEY_RESIZE;
+			} else
+inp = ERR;
 		} else {
 			inp = c;
 		}

Index: src/lib/libcurses/tstp.c
diff -u src/lib/libcurses/tstp.c:1.42 src/lib/libcurses/tstp.c:1.42.6.1
--- src/lib/libcurses/tstp.c:1.42	Fri Jan  6 13:53:18 2017
+++ src/lib/libcurses/tstp.c	Thu Sep 27 14:59:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tstp.c,v 1.42 

CVS commit: [netbsd-8] src/lib/libcurses

2018-08-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  8 10:32:18 UTC 2018

Modified Files:
src/lib/libcurses [netbsd-8]: addbytes.c

Log Message:
Pull up following revision(s) (requested by simonb in ticket #964):

lib/libcurses/addbytes.c: revision 1.48

Avoid curx going beyond end of window when adding a wide character to the
last column.

OK @blymn.
- --


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.47.6.1 src/lib/libcurses/addbytes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.47 src/lib/libcurses/addbytes.c:1.47.6.1
--- src/lib/libcurses/addbytes.c:1.47	Fri Jan  6 14:25:41 2017
+++ src/lib/libcurses/addbytes.c	Wed Aug  8 10:32:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.47 2017/01/06 14:25:41 roy Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.47.6.1 2018/08/08 10:32:18 martin Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addbytes.c	8.4 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addbytes.c,v 1.47 2017/01/06 14:25:41 roy Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.47.6.1 2018/08/08 10:32:18 martin Exp $");
 #endif
 #endif/* not lint */
 
@@ -582,7 +582,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		if (newx > *(*lnp)->lastchp)
 			*(*lnp)->lastchp = newx;
 		__touchline(win, *y, sx, (int) win->maxx - 1);
-		win->curx = sx;
+		*x = win->curx = sx;
 	} else {
 		win->curx = *x;