summaryrefslogtreecommitdiffstats
path: root/contrib/ncurses
diff options
context:
space:
mode:
authorrafan <rafan@FreeBSD.org>2007-12-30 11:15:46 +0000
committerrafan <rafan@FreeBSD.org>2007-12-30 11:15:46 +0000
commit34082ac356240b34d98c81c18e720f5939ad6d67 (patch)
tree34f63c088d9de29603662adcc70f527e94c8f87c /contrib/ncurses
parentfa111939911afb0742eae3463d2fb25448a02041 (diff)
downloadFreeBSD-src-34082ac356240b34d98c81c18e720f5939ad6d67.zip
FreeBSD-src-34082ac356240b34d98c81c18e720f5939ad6d67.tar.gz
- Resolve conflicts
- Our changes in lib_termcap.c is now merged in upstream
Diffstat (limited to 'contrib/ncurses')
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_baudrate.c27
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_raw.c8
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termcap.c60
3 files changed, 54 insertions, 41 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
index 15ba3bb..2d1c3ea 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/* $FreeBSD$ */
@@ -41,6 +42,9 @@
#include <curses.priv.h>
#include <term.h> /* cur_term, pad_char */
#include <termcap.h> /* ospeed */
+#if defined(__FreeBSD__)
+#include <sys/param.h>
+#endif
/*
* These systems use similar header files, which define B1200 as 1200, etc.,
@@ -48,7 +52,7 @@
* of the indices up to B115200 fit nicely in a 'short', allowing us to retain
* ospeed's type for compatibility.
*/
-#if defined(__NetBSD__) || defined(__OpenBSD__)
+#if (defined(__FreeBSD__) && (__FreeBSD_version < 700000)) || defined(__NetBSD__) || defined(__OpenBSD__)
#undef B0
#undef B50
#undef B75
@@ -78,7 +82,7 @@
#undef USE_OLD_TTY
#endif /* USE_OLD_TTY */
-MODULE_ID("$Id: lib_baudrate.c,v 1.22 2002/01/19 23:07:53 Andrey.A.Chernov Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.25 2007/10/20 15:00:41 Rong-En.Fan Exp $")
/*
* int
@@ -143,16 +147,20 @@ static struct speed const speeds[] =
NCURSES_EXPORT(int)
_nc_baudrate(int OSpeed)
{
+#if !USE_REENTRANT
static int last_OSpeed;
static int last_baudrate;
+#endif
- int result;
+ int result = ERR;
unsigned i;
+#if !USE_REENTRANT
if (OSpeed == last_OSpeed) {
result = last_baudrate;
- } else {
- result = ERR;
+ }
+#endif
+ if (result == ERR) {
if (OSpeed >= 0) {
for (i = 0; i < SIZEOF(speeds); i++) {
if (speeds[i].s == OSpeed) {
@@ -161,7 +169,12 @@ _nc_baudrate(int OSpeed)
}
}
}
- last_baudrate = result;
+#if !USE_REENTRANT
+ if (OSpeed == last_OSpeed) {
+ last_OSpeed = OSpeed;
+ last_baudrate = result;
+ }
+#endif
}
return (result);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_raw.c b/contrib/ncurses/ncurses/tinfo/lib_raw.c
index 1f6d90a..a360972 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_raw.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -51,7 +51,7 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.13 2002/07/06 22:00:45 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.14 2007/09/29 21:50:22 tom Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -71,8 +71,8 @@ MODULE_ID("$Id: lib_raw.c,v 1.13 2002/07/06 22:00:45 tom Exp $")
#define COOKED_INPUT (IXON|BRKINT|PARMRK)
#ifdef TRACE
-#define BEFORE(N) if (_nc_tracing&TRACE_BITS) _tracef("%s before bits: %s", N, _nc_tracebits())
-#define AFTER(N) if (_nc_tracing&TRACE_BITS) _tracef("%s after bits: %s", N, _nc_tracebits())
+#define BEFORE(N) if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s before bits: %s", N, _nc_tracebits())
+#define AFTER(N) if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s after bits: %s", N, _nc_tracebits())
#else
#define BEFORE(s)
#define AFTER(s)
diff --git a/contrib/ncurses/ncurses/tinfo/lib_termcap.c b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
index 66d8701..2291df8 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -47,7 +47,7 @@
#include <term_entry.h>
-MODULE_ID("$Id: lib_termcap.c,v 1.58 2006/09/02 19:39:46 Miroslav.Lichvar Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.61 2007/06/02 19:36:03 tom Exp $")
NCURSES_EXPORT_VAR(char *) UP = 0;
NCURSES_EXPORT_VAR(char *) BC = 0;
@@ -56,21 +56,15 @@ NCURSES_EXPORT_VAR(char *) BC = 0;
extern char _nc_termcap[]; /* buffer to copy out */
#endif
-typedef struct {
- long sequence;
- char *fix_sgr0; /* this holds the filtered sgr0 string */
- char *last_bufp; /* help with fix_sgr0 leak */
- TERMINAL *last_term;
-} CACHE;
+#define MyCache _nc_globals.tgetent_cache
+#define CacheInx _nc_globals.tgetent_index
+#define CacheSeq _nc_globals.tgetent_sequence
-#define MAX_CACHE 4
-static CACHE cache[MAX_CACHE];
-static int in_cache = 0;
-
-#define FIX_SGR0 cache[in_cache].fix_sgr0
-#define LAST_TRM cache[in_cache].last_term
-#define LAST_BUF cache[in_cache].last_bufp
-#define LAST_SEQ cache[in_cache].sequence
+#define FIX_SGR0 MyCache[CacheInx].fix_sgr0
+#define LAST_TRM MyCache[CacheInx].last_term
+#define LAST_BUF MyCache[CacheInx].last_bufp
+#define LAST_USE MyCache[CacheInx].last_used
+#define LAST_SEQ MyCache[CacheInx].sequence
/***************************************************************************
*
@@ -90,8 +84,6 @@ static int in_cache = 0;
NCURSES_EXPORT(int)
tgetent(char *bufp, const char *name)
{
- static long sequence;
-
int errcode;
int n;
bool found_cache = FALSE;
@@ -106,11 +98,17 @@ tgetent(char *bufp, const char *name)
* caller, but if tgetent() is called with the same buffer, that is
* good enough, since the previous data would be invalidated by the
* current call.
+ *
+ * bufp may be a null pointer, e.g., GNU termcap. That allocates data,
+ * which is good until the next tgetent() call. The conventional termcap
+ * is inconvenient because of the fixed buffer size, but because it uses
+ * caller-supplied buffers, can have multiple terminal descriptions in
+ * use at a given time.
*/
- for (n = 0; n < MAX_CACHE; ++n) {
- bool same_result = (bufp != 0 && cache[n].last_bufp == bufp);
+ for (n = 0; n < TGETENT_MAX; ++n) {
+ bool same_result = (MyCache[n].last_used && MyCache[n].last_bufp == bufp);
if (same_result) {
- in_cache = n;
+ CacheInx = n;
if (FIX_SGR0 != 0) {
FreeAndNull(FIX_SGR0);
}
@@ -120,10 +118,10 @@ tgetent(char *bufp, const char *name)
if (LAST_TRM != 0 && LAST_TRM != cur_term) {
TERMINAL *trm = LAST_TRM;
del_curterm(LAST_TRM);
- for (in_cache = 0; in_cache < MAX_CACHE; ++in_cache)
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx)
if (LAST_TRM == trm)
LAST_TRM = 0;
- in_cache = n;
+ CacheInx = n;
}
found_cache = TRUE;
break;
@@ -132,15 +130,15 @@ tgetent(char *bufp, const char *name)
if (!found_cache) {
int best = 0;
- for (in_cache = 0; in_cache < MAX_CACHE; ++in_cache) {
- if (LAST_SEQ < cache[best].sequence) {
- best = in_cache;
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
+ if (LAST_SEQ < MyCache[best].sequence) {
+ best = CacheInx;
}
}
- in_cache = best;
+ CacheInx = best;
}
LAST_TRM = cur_term;
- LAST_SEQ = ++sequence;
+ LAST_SEQ = ++CacheSeq;
PC = 0;
UP = 0;
@@ -170,6 +168,7 @@ tgetent(char *bufp, const char *name)
}
}
LAST_BUF = bufp;
+ LAST_USE = TRUE;
(void) baudrate(); /* sets ospeed as a side-effect */
@@ -298,9 +297,10 @@ tgetstr(NCURSES_CONST char *id, char **area)
NCURSES_EXPORT(void)
_nc_tgetent_leaks(void)
{
- for (in_cache = 0; in_cache < MAX_CACHE; ++in_cache) {
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
FreeIfNeeded(FIX_SGR0);
- del_curterm(LAST_TRM);
+ if (LAST_TRM != 0)
+ del_curterm(LAST_TRM);
}
}
#endif
OpenPOWER on IntegriCloud