Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/lib/libcurses Pull up following revision(s) (requested by...



details:   https://anonhg.NetBSD.org/src/rev/9ec9a49f0d1d
branches:  netbsd-8
changeset: 852014:9ec9a49f0d1d
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Sep 27 14:59:28 2018 +0000

description:
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

diffstat:

 lib/libcurses/get_wch.c |  24 +++++++++++++++++++-----
 lib/libcurses/getch.c   |  23 ++++++++++++++++++-----
 lib/libcurses/tstp.c    |   9 ++++++---
 3 files changed, 43 insertions(+), 13 deletions(-)

diffs (152 lines):

diff -r 58ac291d8f69 -r 9ec9a49f0d1d lib/libcurses/get_wch.c
--- a/lib/libcurses/get_wch.c   Thu Sep 27 14:52:26 2018 +0000
+++ b/lib/libcurses/get_wch.c   Thu Sep 27 14:59:28 2018 +0000
@@ -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 <sys/cdefs.h>
 #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 <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -102,7 +103,11 @@
                        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 @@
                        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 @@
 
                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;
diff -r 58ac291d8f69 -r 9ec9a49f0d1d lib/libcurses/getch.c
--- a/lib/libcurses/getch.c     Thu Sep 27 14:52:26 2018 +0000
+++ b/lib/libcurses/getch.c     Thu Sep 27 14:59:28 2018 +0000
@@ -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 <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -562,7 +563,11 @@
                        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 @@
                        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 @@
 
                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;
                }
diff -r 58ac291d8f69 -r 9ec9a49f0d1d lib/libcurses/tstp.c
--- a/lib/libcurses/tstp.c      Thu Sep 27 14:52:26 2018 +0000
+++ b/lib/libcurses/tstp.c      Thu Sep 27 14:59:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tstp.c,v 1.42 2017/01/06 13:53:18 roy Exp $    */
+/*     $NetBSD: tstp.c,v 1.42.6.1 2018/09/27 14:59:28 martin Exp $     */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)tstp.c     8.3 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: tstp.c,v 1.42 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: tstp.c,v 1.42.6.1 2018/09/27 14:59:28 martin Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -150,7 +150,10 @@
         * If there was a previous handler, call that,
         * otherwise tell getch() to send KEY_RESIZE.
         */
-       if (owsa.sa_handler !=  NULL)
+       if (owsa.sa_handler != SIG_DFL &&
+           owsa.sa_handler != SIG_IGN &&
+           owsa.sa_handler != SIG_ERR &&
+           owsa.sa_handler != SIG_HOLD)
                owsa.sa_handler(signo);
        else
                _cursesi_screen->resized = 1;



Home | Main Index | Thread Index | Old Index