Module Name: src
Committed By: kamil
Date: Wed Sep 26 14:42:22 UTC 2018
Modified Files:
src/lib/libcurses: get_wch.c getch.c
Log Message:
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.15 -r1.16 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.66 -r1.67 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.15 src/lib/libcurses/get_wch.c:1.16
--- src/lib/libcurses/get_wch.c:1.15 Tue Sep 18 22:46:18 2018
+++ src/lib/libcurses/get_wch.c Wed Sep 26 14:42:22 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: get_wch.c,v 1.15 2018/09/18 22:46:18 rin Exp $ */
+/* $NetBSD: get_wch.c,v 1.16 2018/09/26 14:42:22 kamil Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.15 2018/09/18 22:46:18 rin Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.16 2018/09/26 14:42:22 kamil Exp $");
#endif /* not lint */
#include <errno.h>
@@ -103,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))
@@ -151,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))
Index: src/lib/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.66 src/lib/libcurses/getch.c:1.67
--- src/lib/libcurses/getch.c:1.66 Tue Sep 18 22:46:18 2018
+++ src/lib/libcurses/getch.c Wed Sep 26 14:42:22 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.66 2018/09/18 22:46:18 rin Exp $ */
+/* $NetBSD: getch.c,v 1.67 2018/09/26 14:42:22 kamil 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.66 2018/09/18 22:46:18 rin Exp $");
+__RCSID("$NetBSD: getch.c,v 1.67 2018/09/26 14:42:22 kamil Exp $");
#endif
#endif /* not lint */
@@ -563,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))
@@ -605,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))