Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Rename global variable "state" to "_cursesi_st...
details: https://anonhg.NetBSD.org/src/rev/5000f8cec59b
branches: trunk
changeset: 997580:5000f8cec59b
user: rin <rin%NetBSD.org@localhost>
date: Thu Mar 14 00:36:06 2019 +0000
description:
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 (217 lines):
diff -r a32d8a71a31b -r 5000f8cec59b lib/libcurses/get_wch.c
--- a/lib/libcurses/get_wch.c Wed Mar 13 23:37:48 2019 +0000
+++ b/lib/libcurses/get_wch.c Thu Mar 14 00:36:06 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: get_wch.c,v 1.20 2018/11/22 22:16:45 uwe Exp $ */
+/* $NetBSD: get_wch.c,v 1.21 2019/03/14 00:36:06 rin 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.20 2018/11/22 22:16:45 uwe Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.21 2019/03/14 00:36:06 rin Exp $");
#endif /* not lint */
#include <errno.h>
@@ -48,8 +48,8 @@
#include "curses_private.h"
#include "keymap.h"
-static short wstate; /* state of the wcinkey function */
-extern short state; /* storage declared in getch.c */
+static short wstate; /* state of the wcinkey function */
+extern short _cursesi_state; /* storage declared in getch.c */
/* prototypes for private functions */
static int inkey(wchar_t *wc, int to, int delay);
@@ -216,7 +216,7 @@
*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, "
@@ -224,7 +224,7 @@
*start, *working, *end);
#endif /* DEBUG */
} else {
- state = wstate = INKEY_BACKOUT;
+ _cursesi_state = wstate = INKEY_BACKOUT;
#ifdef DEBUG
__CTRACE(__CTRACE_INPUT,
"inkey: WCASSEMBLING=>BACKOUT, "
@@ -283,7 +283,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, "
@@ -293,7 +293,7 @@
} 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, "
@@ -381,7 +381,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, "
@@ -391,7 +391,7 @@
} 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, "
@@ -416,7 +416,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), "
@@ -425,7 +425,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 a32d8a71a31b -r 5000f8cec59b lib/libcurses/getch.c
--- a/lib/libcurses/getch.c Wed Mar 13 23:37:48 2019 +0000
+++ b/lib/libcurses/getch.c Thu Mar 14 00:36:06 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.70 2018/09/28 15:03:48 roy Exp $ */
+/* $NetBSD: getch.c,v 1.71 2019/03/14 00:36:06 rin 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.70 2018/09/28 15:03:48 roy Exp $");
+__RCSID("$NetBSD: getch.c,v 1.71 2019/03/14 00:36:06 rin Exp $");
#endif
#endif /* not lint */
@@ -47,7 +47,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_resize(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