Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/lib/libcurses Pull up following revision(s) (requested by...
details: https://anonhg.NetBSD.org/src/rev/057019148256
branches: netbsd-7
changeset: 449667:057019148256
user: martin <martin%NetBSD.org@localhost>
date: Fri Mar 15 14:36:22 2019 +0000
description:
Pull up following revision(s) (requested by rin in ticket #1686):
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
diffstat:
lib/libcurses/get_wch.c | 24 ++++++++++++------------
lib/libcurses/getch.c | 34 ++++++++++++++++++----------------
2 files changed, 30 insertions(+), 28 deletions(-)
diffs (218 lines):
diff -r bc6bf114d534 -r 057019148256 lib/libcurses/get_wch.c
--- a/lib/libcurses/get_wch.c Wed Mar 13 12:34:15 2019 +0000
+++ b/lib/libcurses/get_wch.c Fri Mar 15 14:36:22 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: get_wch.c,v 1.10 2012/06/29 10:40:29 blymn Exp $ */
+/* $NetBSD: get_wch.c,v 1.10.10.1 2019/03/15 14:36:22 martin 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.10 2012/06/29 10:40:29 blymn Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.10.10.1 2019/03/15 14:36:22 martin Exp $");
#endif /* not lint */
#include <string.h>
@@ -48,9 +48,9 @@
#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
@@ -222,7 +222,7 @@
*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, "
@@ -230,7 +230,7 @@
*start, *working, *end);
#endif /* DEBUG */
} else {
- state = wstate = INKEY_BACKOUT;
+ _cursesi_state = wstate = INKEY_BACKOUT;
#ifdef DEBUG
__CTRACE(__CTRACE_INPUT,
"inkey: WCASSEMBLING=>BACKOUT, "
@@ -289,7 +289,7 @@
}
if (*start == *end) { /* only one char processed */
- state = wstate = INKEY_NORM;
+ _cursesi_state = wstate = INKEY_NORM;
#ifdef DEBUG
__CTRACE(__CTRACE_INPUT,
"inkey: WCASSEMBLING=>NORM, "
@@ -298,7 +298,7 @@
#endif /* DEBUG */
} 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, "
@@ -385,7 +385,7 @@
}
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, "
@@ -394,7 +394,7 @@
#endif /* DEBUG */
} 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, "
@@ -418,7 +418,7 @@
#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), "
@@ -427,7 +427,7 @@
#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), "
diff -r bc6bf114d534 -r 057019148256 lib/libcurses/getch.c
--- a/lib/libcurses/getch.c Wed Mar 13 12:34:15 2019 +0000
+++ b/lib/libcurses/getch.c Fri Mar 15 14:36:22 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.59 2012/04/21 12:27:28 roy Exp $ */
+/* $NetBSD: getch.c,v 1.59.10.1 2019/03/15 14:36:22 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.59 2012/04/21 12:27:28 roy Exp $");
+__RCSID("$NetBSD: getch.c,v 1.59.10.1 2019/03/15 14:36:22 martin Exp $");
#endif
#endif /* not lint */
@@ -46,7 +46,7 @@
#include "curses_private.h"
#include "keymap.h"
-short state; /* state of the inkey function */
+short _cursesi_state; /* state of the inkey function */
static const struct tcdata tc[] = {
{TICODE_kSAV, KEY_SSAVE},
@@ -447,7 +447,7 @@
#endif
/* init the inkey state variable */
- state = INKEY_NORM;
+ _cursesi_state = INKEY_NORM;
/* init the base keymap */
screen->base_keymap = new_keymap();
@@ -557,7 +557,7 @@
#endif
for (;;) { /* loop until we get a complete key sequence */
reread:
- if (state == INKEY_NORM) {
+ if (_cursesi_state == INKEY_NORM) {
if (delay && __timeout(delay) == ERR)
return ERR;
c = fgetc(infd);
@@ -579,9 +579,11 @@
inbuf[working] = k;
INC_POINTER(working);
end = working;
- state = INKEY_ASSEMBLING; /* go to the assembling
- * state now */
- } else if (state == INKEY_BACKOUT) {
+
+ /* go to the assembling state now */
+ _cursesi_state = INKEY_ASSEMBLING;
+
+ } else if (_cursesi_state == INKEY_BACKOUT) {
k = inbuf[working];
INC_POINTER(working);
if (working == end) { /* see if we have run
@@ -589,9 +591,9 @@
* backlog */
/* if we have then switch to assembling */
- state = INKEY_ASSEMBLING;
+ _cursesi_state = INKEY_ASSEMBLING;
}
- } else if (state == INKEY_ASSEMBLING) {
+ } else if (_cursesi_state == INKEY_ASSEMBLING) {
/* assembling a key sequence */
if (delay) {
if (__timeout(to ? (ESCDELAY / 100) : delay)
@@ -623,7 +625,7 @@
goto reread;
k = inbuf[start];
- state = INKEY_TIMEOUT;
+ _cursesi_state = INKEY_TIMEOUT;
} else {
k = (wchar_t) c;
inbuf[working] = k;
@@ -640,7 +642,7 @@
* timed out and the key has not been disabled
*/
mapping = current->mapping[k];
- if (((state == INKEY_TIMEOUT) || (mapping < 0))
+ if (((_cursesi_state == INKEY_TIMEOUT) || (mapping < 0))
|| ((current->key[mapping]->type == KEYMAP_LEAF)
&& (current->key[mapping]->enable == FALSE))) {
/* return the first key we know about */
@@ -650,10 +652,10 @@
working = start;
if (start == end) { /* only one char processed */
- state = INKEY_NORM;
+ _cursesi_state = INKEY_NORM;
} else {/* otherwise we must have more than one char
* to backout */
- state = INKEY_BACKOUT;
+ _cursesi_state = INKEY_BACKOUT;
}
return k;
} else { /* must be part of a multikey sequence */
@@ -665,10 +667,10 @@
/* check if inbuf empty now */
if (start == end) {
/* if it is go back to normal */
- state = INKEY_NORM;
+ _cursesi_state = INKEY_NORM;
} else {
/* otherwise go to backout state */
- state = INKEY_BACKOUT;
+ _cursesi_state = INKEY_BACKOUT;
}
/* return the symbol */
Home |
Main Index |
Thread Index |
Old Index