Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses If either set_escdelay(3) or set_tabsize(3) ar...



details:   https://anonhg.NetBSD.org/src/rev/f7752e46acf6
branches:  trunk
changeset: 821257:f7752e46acf6
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Jan 30 14:55:58 2017 +0000

description:
If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.

diffstat:

 lib/libcurses/curses.c         |  5 +++--
 lib/libcurses/curses_private.h |  3 ++-
 lib/libcurses/get_wch.c        |  7 ++++---
 lib/libcurses/getch.c          |  8 +++++---
 lib/libcurses/ins_wch.c        |  6 +++---
 lib/libcurses/ins_wstr.c       |  7 ++++---
 lib/libcurses/setterm.c        |  5 +++--
 7 files changed, 24 insertions(+), 17 deletions(-)

diffs (188 lines):

diff -r 5d4e5fec9bd1 -r f7752e46acf6 lib/libcurses/curses.c
--- a/lib/libcurses/curses.c    Mon Jan 30 14:55:17 2017 +0000
+++ b/lib/libcurses/curses.c    Mon Jan 30 14:55:58 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses.c,v 1.26 2016/10/22 21:55:06 christos Exp $     */
+/*     $NetBSD: curses.c,v 1.27 2017/01/30 14:55:58 roy Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -35,7 +35,7 @@
 #if 0
 static char sccsid[] = "@(#)curses.c   8.3 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: curses.c,v 1.26 2016/10/22 21:55:06 christos Exp $");
+__RCSID("$NetBSD: curses.c,v 1.27 2017/01/30 14:55:58 roy Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -64,6 +64,7 @@
 WINDOW *stdscr;                        /* Standard screen. */
 WINDOW *__virtscr;                     /* Virtual screen (for doupdate()). */
 SCREEN  *_cursesi_screen;               /* the current screen we are using */
+volatile bool   _reentrant;            /* If true, some global vars are ro. */
 int     COLS;                          /* Columns on the screen. */
 int     LINES;                         /* Lines on the screen. */
 int     TABSIZE;                       /* Size of a tab. */
diff -r 5d4e5fec9bd1 -r f7752e46acf6 lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h    Mon Jan 30 14:55:17 2017 +0000
+++ b/lib/libcurses/curses_private.h    Mon Jan 30 14:55:58 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses_private.h,v 1.60 2017/01/24 17:27:30 roy Exp $  */
+/*     $NetBSD: curses_private.h,v 1.61 2017/01/30 14:55:58 roy Exp $  */
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -314,6 +314,7 @@
 extern int      My_term;               /* Use Def_term regardless. */
 extern const char      *Def_term;      /* Default terminal type. */
 extern SCREEN   *_cursesi_screen;       /* The current screen in use */
+extern volatile bool    _reentrant;    /* If true, some global vars are ro. */
 
 /* Debugging options/functions. */
 #ifdef DEBUG
diff -r 5d4e5fec9bd1 -r f7752e46acf6 lib/libcurses/get_wch.c
--- a/lib/libcurses/get_wch.c   Mon Jan 30 14:55:17 2017 +0000
+++ b/lib/libcurses/get_wch.c   Mon Jan 30 14:55:58 2017 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: get_wch.c,v 1.12 2017/01/06 13:53:18 roy Exp $ */
+/*   $NetBSD: get_wch.c,v 1.13 2017/01/30 14:55:58 roy 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.12 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.13 2017/01/30 14:55:58 roy Exp $");
 #endif                                           /* not lint */
 
 #include <string.h>
@@ -91,7 +91,8 @@
                                *working = &_cursesi_screen->cbuf_cur,
                                *end = &_cursesi_screen->cbuf_tail;
        char            *inbuf = &_cursesi_screen->cbuf[ 0 ];
-       int             escdelay = _cursesi_screen->ESCDELAY;
+       int             escdelay = _reentrant ?
+                           _cursesi_screen->ESCDELAY : ESCDELAY;
 
 #ifdef DEBUG
        __CTRACE(__CTRACE_INPUT, "inkey (%p, %d, %d)\n", wc, to, delay);
diff -r 5d4e5fec9bd1 -r f7752e46acf6 lib/libcurses/getch.c
--- a/lib/libcurses/getch.c     Mon Jan 30 14:55:17 2017 +0000
+++ b/lib/libcurses/getch.c     Mon Jan 30 14:55:58 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getch.c,v 1.62 2017/01/06 13:53:18 roy Exp $   */
+/*     $NetBSD: getch.c,v 1.63 2017/01/30 14:55:58 roy 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.62 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: getch.c,v 1.63 2017/01/30 14:55:58 roy Exp $");
 #endif
 #endif                                 /* not lint */
 
@@ -550,7 +550,8 @@
        int              c, mapping;
        keymap_t        *current = _cursesi_screen->base_keymap;
        FILE            *infd = _cursesi_screen->infd;
-       int             escdelay = _cursesi_screen->ESCDELAY;
+       int             escdelay = _reentrant ?
+                           _cursesi_screen->ESCDELAY : ESCDELAY;
 
        k = 0;          /* XXX gcc -Wuninitialized */
 
@@ -988,6 +989,7 @@
 {
 
        _cursesi_screen->ESCDELAY = escdelay;
+       _reentrant = true;
        ESCDELAY = escdelay;
        return OK;
 }
diff -r 5d4e5fec9bd1 -r f7752e46acf6 lib/libcurses/ins_wch.c
--- a/lib/libcurses/ins_wch.c   Mon Jan 30 14:55:17 2017 +0000
+++ b/lib/libcurses/ins_wch.c   Mon Jan 30 14:55:58 2017 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wch.c,v 1.9 2017/01/06 13:53:18 roy Exp $ */
+/*   $NetBSD: ins_wch.c,v 1.10 2017/01/30 14:55:58 roy Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ins_wch.c,v 1.9 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: ins_wch.c,v 1.10 2017/01/30 14:55:58 roy Exp $");
 #endif                                           /* not lint */
 
 #include <string.h>
@@ -146,7 +146,7 @@
                        }
                        return OK;
                case L'\t':
-                       tabsize = win->screen->TABSIZE;
+                       tabsize = _reentrant ? win->screen->TABSIZE : TABSIZE;
                        if (wins_nwstr(win, ws, min(win->maxx - x,
                            tabsize - (x % tabsize))) == ERR)
                                return ERR;
diff -r 5d4e5fec9bd1 -r f7752e46acf6 lib/libcurses/ins_wstr.c
--- a/lib/libcurses/ins_wstr.c  Mon Jan 30 14:55:17 2017 +0000
+++ b/lib/libcurses/ins_wstr.c  Mon Jan 30 14:55:58 2017 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wstr.c,v 1.9 2017/01/02 10:28:34 roy Exp $ */
+/*   $NetBSD: ins_wstr.c,v 1.10 2017/01/30 14:55:58 roy Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ins_wstr.c,v 1.9 2017/01/02 10:28:34 roy Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.10 2017/01/30 14:55:58 roy Exp $");
 #endif                                           /* not lint */
 
 #include <string.h>
@@ -266,7 +266,8 @@
                                }
                                continue;
                        case L'\t':
-                               tabsize = win->screen->TABSIZE;
+                               tabsize = _reentrant ?
+                                   win->screen->TABSIZE : TABSIZE;
                                if (wins_nwstr(win, ws,
                                    min(win->maxx - x, tabsize - (x % tabsize)))
                                    == ERR)
diff -r 5d4e5fec9bd1 -r f7752e46acf6 lib/libcurses/setterm.c
--- a/lib/libcurses/setterm.c   Mon Jan 30 14:55:17 2017 +0000
+++ b/lib/libcurses/setterm.c   Mon Jan 30 14:55:58 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setterm.c,v 1.61 2017/01/11 20:43:03 roy Exp $ */
+/*     $NetBSD: setterm.c,v 1.62 2017/01/30 14:55:58 roy Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setterm.c  8.8 (Berkeley) 10/25/94";
 #else
-__RCSID("$NetBSD: setterm.c,v 1.61 2017/01/11 20:43:03 roy Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.62 2017/01/30 14:55:58 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -404,6 +404,7 @@
 {
 
        _cursesi_screen->TABSIZE = tabsize;
+       _reentrant = true;
        TABSIZE = tabsize;
        return OK;
 }



Home | Main Index | Thread Index | Old Index