Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Move ESCDELAY to curses.c so all globals are c...
details: https://anonhg.NetBSD.org/src/rev/e612c21aa719
branches: trunk
changeset: 351027:e612c21aa719
user: roy <roy%NetBSD.org@localhost>
date: Tue Jan 31 09:17:53 2017 +0000
description:
Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
diffstat:
lib/libcurses/curses.c | 5 +++--
lib/libcurses/curses_private.h | 3 +--
lib/libcurses/get_wch.c | 14 ++++++--------
lib/libcurses/getch.c | 13 ++++---------
lib/libcurses/ins_wch.c | 9 ++++-----
lib/libcurses/ins_wstr.c | 10 ++++------
lib/libcurses/screen.c | 8 ++++++--
lib/libcurses/setterm.c | 5 ++---
8 files changed, 30 insertions(+), 37 deletions(-)
diffs (295 lines):
diff -r 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/curses.c
--- a/lib/libcurses/curses.c Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/curses.c Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.c,v 1.27 2017/01/30 14:55:58 roy Exp $ */
+/* $NetBSD: curses.c,v 1.28 2017/01/31 09:17:53 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.27 2017/01/30 14:55:58 roy Exp $");
+__RCSID("$NetBSD: curses.c,v 1.28 2017/01/31 09:17:53 roy Exp $");
#endif
#endif /* not lint */
@@ -67,6 +67,7 @@
volatile bool _reentrant; /* If true, some global vars are ro. */
int COLS; /* Columns on the screen. */
int LINES; /* Lines on the screen. */
+int ESCDELAY; /* ms delay between keys for esc seq */
int TABSIZE; /* Size of a tab. */
int COLORS; /* Maximum colors on the screen */
int COLOR_PAIRS = 0; /* Maximum color pairs on the screen */
diff -r 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/curses_private.h Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses_private.h,v 1.61 2017/01/30 14:55:58 roy Exp $ */
+/* $NetBSD: curses_private.h,v 1.62 2017/01/31 09:17:53 roy Exp $ */
/*-
* Copyright (c) 1998-2000 Brett Lymn
@@ -314,7 +314,6 @@
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 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/get_wch.c
--- a/lib/libcurses/get_wch.c Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/get_wch.c Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: get_wch.c,v 1.13 2017/01/30 14:55:58 roy Exp $ */
+/* $NetBSD: get_wch.c,v 1.14 2017/01/31 09:17:53 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.13 2017/01/30 14:55:58 roy Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.14 2017/01/31 09:17:53 roy Exp $");
#endif /* not lint */
#include <string.h>
@@ -91,8 +91,6 @@
*working = &_cursesi_screen->cbuf_cur,
*end = &_cursesi_screen->cbuf_tail;
char *inbuf = &_cursesi_screen->cbuf[ 0 ];
- int escdelay = _reentrant ?
- _cursesi_screen->ESCDELAY : ESCDELAY;
#ifdef DEBUG
__CTRACE(__CTRACE_INPUT, "inkey (%p, %d, %d)\n", wc, to, delay);
@@ -141,11 +139,11 @@
} else if (wstate == INKEY_ASSEMBLING) {
/* assembling a key sequence */
if (delay) {
- if (__timeout(to ? (escdelay / 100) : delay)
+ if (__timeout(to ? (ESCDELAY / 100) : delay)
== ERR)
return ERR;
} else {
- if (to && (__timeout(escdelay / 100) == ERR))
+ if (to && (__timeout(ESCDELAY / 100) == ERR))
return ERR;
}
@@ -191,11 +189,11 @@
} else if (wstate == INKEY_WCASSEMBLING) {
/* assembling a wide-char sequence */
if (delay) {
- if (__timeout(to ? (escdelay / 100) : delay)
+ if (__timeout(to ? (ESCDELAY / 100) : delay)
== ERR)
return ERR;
} else {
- if (to && (__timeout(escdelay / 100) == ERR))
+ if (to && (__timeout(ESCDELAY / 100) == ERR))
return ERR;
}
diff -r 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/getch.c
--- a/lib/libcurses/getch.c Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/getch.c Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.64 2017/01/30 16:50:44 roy Exp $ */
+/* $NetBSD: getch.c,v 1.65 2017/01/31 09:17:53 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.64 2017/01/30 16:50:44 roy Exp $");
+__RCSID("$NetBSD: getch.c,v 1.65 2017/01/31 09:17:53 roy Exp $");
#endif
#endif /* not lint */
@@ -203,8 +203,6 @@
/* Number of TC entries .... */
static const int num_tcs = (sizeof(tc) / sizeof(struct tcdata));
-int ESCDELAY; /* Delay in ms between keys for esc seq's */
-
/* Key buffer */
#define INBUF_SZ 16 /* size of key buffer - must be larger than
* longest multi-key sequence */
@@ -550,8 +548,6 @@
int c, mapping;
keymap_t *current = _cursesi_screen->base_keymap;
FILE *infd = _cursesi_screen->infd;
- int escdelay = _reentrant ?
- _cursesi_screen->ESCDELAY : ESCDELAY;
k = 0; /* XXX gcc -Wuninitialized */
@@ -597,11 +593,11 @@
} else if (state == INKEY_ASSEMBLING) {
/* assembling a key sequence */
if (delay) {
- if (__timeout(to ? (escdelay / 100) : delay)
+ if (__timeout(to ? (ESCDELAY / 100) : delay)
== ERR)
return ERR;
} else {
- if (to && (__timeout(escdelay / 100) == ERR))
+ if (to && (__timeout(ESCDELAY / 100) == ERR))
return ERR;
}
@@ -999,7 +995,6 @@
if (_cursesi_screen == NULL)
return ERR;
_cursesi_screen->ESCDELAY = escdelay;
- _reentrant = true;
ESCDELAY = escdelay;
return OK;
}
diff -r 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/ins_wch.c
--- a/lib/libcurses/ins_wch.c Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/ins_wch.c Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ins_wch.c,v 1.10 2017/01/30 14:55:58 roy Exp $ */
+/* $NetBSD: ins_wch.c,v 1.11 2017/01/31 09:17:53 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.10 2017/01/30 14:55:58 roy Exp $");
+__RCSID("$NetBSD: ins_wch.c,v 1.11 2017/01/31 09:17:53 roy Exp $");
#endif /* not lint */
#include <string.h>
@@ -102,7 +102,7 @@
#else
__LDATA *start, *temp1, *temp2;
__LINE *lnp;
- int cw, pcw, x, y, sx, ex, newx, i, tabsize;
+ int cw, pcw, x, y, sx, ex, newx, i;
nschar_t *np, *tnp;
wchar_t ws[] = L" ";
@@ -146,9 +146,8 @@
}
return OK;
case L'\t':
- tabsize = _reentrant ? win->screen->TABSIZE : TABSIZE;
if (wins_nwstr(win, ws, min(win->maxx - x,
- tabsize - (x % tabsize))) == ERR)
+ TABSIZE - (x % TABSIZE))) == ERR)
return ERR;
return OK;
}
diff -r 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/ins_wstr.c
--- a/lib/libcurses/ins_wstr.c Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/ins_wstr.c Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ins_wstr.c,v 1.10 2017/01/30 14:55:58 roy Exp $ */
+/* $NetBSD: ins_wstr.c,v 1.11 2017/01/31 09:17:53 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.10 2017/01/30 14:55:58 roy Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.11 2017/01/31 09:17:53 roy Exp $");
#endif /* not lint */
#include <string.h>
@@ -136,7 +136,7 @@
__LDATA *start, *temp1, *temp2;
__LINE *lnp;
const wchar_t *scp;
- int width, len, sx, x, y, cw, pcw, newx, tabsize;
+ int width, len, sx, x, y, cw, pcw, newx;
nschar_t *np;
wchar_t ws[] = L" ";
@@ -266,10 +266,8 @@
}
continue;
case L'\t':
- tabsize = _reentrant ?
- win->screen->TABSIZE : TABSIZE;
if (wins_nwstr(win, ws,
- min(win->maxx - x, tabsize - (x % tabsize)))
+ min(win->maxx - x, TABSIZE - (x % TABSIZE)))
== ERR)
return ERR;
continue;
diff -r 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/screen.c
--- a/lib/libcurses/screen.c Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/screen.c Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: screen.c,v 1.30 2017/01/24 17:27:30 roy Exp $ */
+/* $NetBSD: screen.c,v 1.31 2017/01/31 09:17:53 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)screen.c 8.2 (blymn) 11/27/2001";
#else
-__RCSID("$NetBSD: screen.c,v 1.30 2017/01/24 17:27:30 roy Exp $");
+__RCSID("$NetBSD: screen.c,v 1.31 2017/01/31 09:17:53 roy Exp $");
#endif
#endif /* not lint */
@@ -66,6 +66,8 @@
old_screen->noqch = __noqch;
old_screen->COLS = COLS;
old_screen->LINES = LINES + __rippedlines(old_screen);
+ old_screen->ESCDELAY = ESCDELAY;
+ old_screen->TABSIZE = TABSIZE;
old_screen->COLORS = COLORS;
old_screen->COLOR_PAIRS = COLOR_PAIRS;
old_screen->GT = __GT;
@@ -81,6 +83,8 @@
__noqch = new->noqch;
COLS = new->COLS;
LINES = new->LINES - __rippedlines(new);
+ ESCDELAY = new->ESCDELAY;
+ TABSIZE = new->TABSIZE;
COLORS = new->COLORS;
COLOR_PAIRS = new->COLOR_PAIRS;
__GT = new->GT;
diff -r 6a7c0c40cd52 -r e612c21aa719 lib/libcurses/setterm.c
--- a/lib/libcurses/setterm.c Tue Jan 31 07:34:02 2017 +0000
+++ b/lib/libcurses/setterm.c Tue Jan 31 09:17:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: setterm.c,v 1.63 2017/01/30 16:50:44 roy Exp $ */
+/* $NetBSD: setterm.c,v 1.64 2017/01/31 09:17:53 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.63 2017/01/30 16:50:44 roy Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.64 2017/01/31 09:17:53 roy Exp $");
#endif
#endif /* not lint */
@@ -406,7 +406,6 @@
if (_cursesi_screen == NULL)
return ERR;
_cursesi_screen->TABSIZE = tabsize;
- _reentrant = true;
TABSIZE = tabsize;
return OK;
}
Home |
Main Index |
Thread Index |
Old Index