aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses')
-rw-r--r--contrib/ncurses/ncurses/Makefile.in14
-rwxr-xr-xcontrib/ncurses/ncurses/base/MKlib_gen.sh9
-rw-r--r--contrib/ncurses/ncurses/base/lib_addstr.c4
-rw-r--r--contrib/ncurses/ncurses/base/lib_color.c12
-rw-r--r--contrib/ncurses/ncurses/base/lib_colorset.c26
-rw-r--r--contrib/ncurses/ncurses/base/lib_dft_fgbg.c4
-rw-r--r--contrib/ncurses/ncurses/base/lib_getch.c65
-rw-r--r--contrib/ncurses/ncurses/base/lib_hline.c4
-rw-r--r--contrib/ncurses/ncurses/base/lib_mouse.c144
-rw-r--r--contrib/ncurses/ncurses/base/lib_newterm.c18
-rw-r--r--contrib/ncurses/ncurses/base/lib_restart.c65
-rw-r--r--contrib/ncurses/ncurses/base/lib_set_term.c38
-rw-r--r--contrib/ncurses/ncurses/base/lib_winch.c19
-rw-r--r--contrib/ncurses/ncurses/curses.priv.h77
-rw-r--r--contrib/ncurses/ncurses/llib-lncurses203
-rw-r--r--contrib/ncurses/ncurses/modules4
-rw-r--r--contrib/ncurses/ncurses/tinfo/access.c77
-rw-r--r--contrib/ncurses/ncurses/tinfo/alloc_ttype.c86
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_parse.c33
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_scan.c59
-rw-r--r--contrib/ncurses/ncurses/tinfo/free_ttype.c27
-rw-r--r--contrib/ncurses/ncurses/tinfo/home_terminfo.c27
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_baudrate.c164
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_options.c4
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_raw.c4
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_setup.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termcap.c18
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tgoto.c197
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tparm.c950
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tputs.c38
-rw-r--r--contrib/ncurses/ncurses/tinfo/parse_entry.c304
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_entry.c76
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_termcap.c71
-rw-r--r--contrib/ncurses/ncurses/tinfo/strings.c139
-rw-r--r--contrib/ncurses/ncurses/tinfo/write_entry.c8
-rw-r--r--contrib/ncurses/ncurses/trace/lib_traceatr.c238
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracebits.c63
-rwxr-xr-xcontrib/ncurses/ncurses/tty/MKexpanded.sh10
-rw-r--r--contrib/ncurses/ncurses/tty/lib_mvcur.c251
-rw-r--r--contrib/ncurses/ncurses/tty/lib_tstp.c342
-rw-r--r--contrib/ncurses/ncurses/tty/lib_twait.c284
-rw-r--r--contrib/ncurses/ncurses/tty/lib_vidattr.c93
-rw-r--r--contrib/ncurses/ncurses/tty/tty_update.c261
43 files changed, 2631 insertions, 1905 deletions
diff --git a/contrib/ncurses/ncurses/Makefile.in b/contrib/ncurses/ncurses/Makefile.in
index 41b66f69732b..10b3ca5d87d6 100644
--- a/contrib/ncurses/ncurses/Makefile.in
+++ b/contrib/ncurses/ncurses/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.66 2000/05/28 01:39:56 tom Exp $
+# $Id: Makefile.in,v 1.69 2000/08/26 21:51:30 tom Exp $
##############################################################################
# Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. #
# #
@@ -54,7 +54,7 @@ CF_MFLAGS = @cf_cv_makeflags@
@SET_MAKE@
MODEL = @DFT_LWR_MODEL@
-INSTALL_PREFIX = @INSTALL_PREFIX@
+DESTDIR = @DESTDIR@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
@@ -62,8 +62,6 @@ libdir = @libdir@
includedir = @includedir@
datadir = @datadir@
-ticdir = $(datadir)/terminfo
-
INSTALL = @INSTALL@
INSTALL_LIB = @INSTALL@ @INSTALL_LIB@
INSTALL_DATA = @INSTALL_DATA@
@@ -80,7 +78,7 @@ CFLAGS = @CFLAGS@
INCDIR = $(srcdir)/../include
CPPFLAGS = -I../ncurses -I$(srcdir) @CPPFLAGS@ \
- -DHAVE_CONFIG_H -DTERMINFO=\"$(ticdir)\"
+ -DHAVE_CONFIG_H
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
@@ -150,7 +148,7 @@ libs :: $(AUTO_SRC) ../lib $(LIBRARIES)
sources: $(AUTO_SRC)
-$(INSTALL_PREFIX)$(libdir) :
+$(DESTDIR)$(libdir) :
$(srcdir)/../mkinstalldirs $@
../lib : ; mkdir $@
@@ -202,8 +200,8 @@ make_hash$x : \
tags:
ctags *.[ch]
-TAGS:
- etags *.[ch]
+@MAKE_UPPER_TAGS@TAGS:
+@MAKE_UPPER_TAGS@ etags *.[ch]
mostlyclean ::
-rm -f core tags TAGS *~ *.ln *.atac trace
diff --git a/contrib/ncurses/ncurses/base/MKlib_gen.sh b/contrib/ncurses/ncurses/base/MKlib_gen.sh
index 0a29c6085f62..337794007035 100755
--- a/contrib/ncurses/ncurses/base/MKlib_gen.sh
+++ b/contrib/ncurses/ncurses/base/MKlib_gen.sh
@@ -2,7 +2,7 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# ($Id: MKlib_gen.sh,v 1.11 1998/01/17 14:16:52 Juan.Jose.Garcia.Ripoll Exp $)
+# ($Id: MKlib_gen.sh,v 1.12 2000/07/29 16:30:11 tom Exp $)
#
# The XSI Curses standard requires all curses entry points to exist as
# functions, even though many definitions would normally be shadowed
@@ -113,6 +113,11 @@ BEGIN {
print "\n"
skip=1;
+ if ( $1 == "chtype" ) {
+ returnType = "Char";
+ } else {
+ returnType = "Code";
+ }
print "M_" $2
print $0;
print "{";
@@ -200,7 +205,7 @@ BEGIN {
if (match($0, "^void"))
call = ""
else if (dotrace)
- call = "returnCode( ";
+ call = sprintf("return%s( ", returnType);
else
call = "%%return ";
diff --git a/contrib/ncurses/ncurses/base/lib_addstr.c b/contrib/ncurses/ncurses/base/lib_addstr.c
index 0a72165910f3..59a3bae81c8c 100644
--- a/contrib/ncurses/ncurses/base/lib_addstr.c
+++ b/contrib/ncurses/ncurses/base/lib_addstr.c
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_addstr.c,v 1.17 2000/04/29 21:15:55 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.18 2000/07/29 16:42:41 tom Exp $")
int
waddnstr(WINDOW *win, const char *const astr, int n)
@@ -51,7 +51,7 @@ waddnstr(WINDOW *win, const char *const astr, int n)
T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));
if (win && (str != 0)) {
- T(("... current %s", _traceattr(win->_attrs)));
+ TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs)));
TR(TRACE_VIRTPUT, ("str is not null"));
code = OK;
if (n < 0)
diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c
index 71bee42487cd..492194babbfb 100644
--- a/contrib/ncurses/ncurses/base/lib_color.c
+++ b/contrib/ncurses/ncurses/base/lib_color.c
@@ -41,7 +41,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_color.c,v 1.51 2000/05/20 20:09:22 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.53 2000/09/02 18:02:15 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
@@ -85,7 +85,7 @@ static const color_t hls_palette[] =
};
/* *INDENT-ON* */
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
/*
* These are called from _nc_do_color(), which in turn is called from
* vidattr - so we have to assume that SP may be null.
@@ -265,7 +265,7 @@ init_pair(short pair, short f, short b)
if ((pair < 0) || (pair >= COLOR_PAIRS))
returnCode(ERR);
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (SP->_default_color) {
if (f < 0)
f = C_MASK;
@@ -438,7 +438,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
pair_content(old_pair, &old_fg, &old_bg);
if ((fg == C_MASK && old_fg != C_MASK)
|| (bg == C_MASK && old_bg != C_MASK)) {
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
/*
* A minor optimization - but extension. If "AX" is specified in
* the terminal description, treat it as screen's indicator of ECMA
@@ -458,7 +458,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
return;
}
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (fg == C_MASK)
fg = default_fg();
if (bg == C_MASK)
@@ -471,7 +471,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
bg = xx;
}
- T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+ TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
if (fg != C_MASK) {
set_foreground_color(fg, outc);
diff --git a/contrib/ncurses/ncurses/base/lib_colorset.c b/contrib/ncurses/ncurses/base/lib_colorset.c
index d9fc5c28dc01..3870e875f322 100644
--- a/contrib/ncurses/ncurses/base/lib_colorset.c
+++ b/contrib/ncurses/ncurses/base/lib_colorset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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 *
@@ -40,17 +40,19 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_colorset.c,v 1.5 1999/05/16 17:13:43 juergen Exp $")
+MODULE_ID("$Id: lib_colorset.c,v 1.6 2000/07/29 16:37:19 tom Exp $")
-int wcolor_set(WINDOW *win, short color_pair_number, void *opts)
+int
+wcolor_set(WINDOW *win, short color_pair_number, void *opts)
{
- T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
- if (win && !opts && (color_pair_number >= 0) && (color_pair_number < COLOR_PAIRS)) {
- T(("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
- toggle_attr_on(win->_attrs,COLOR_PAIR(color_pair_number));
- returnCode(OK);
- } else
- returnCode(ERR);
+ T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
+ if (win
+ && !opts
+ && (color_pair_number >= 0)
+ && (color_pair_number < COLOR_PAIRS)) {
+ TR(TRACE_ATTRS, ("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
+ toggle_attr_on(win->_attrs, COLOR_PAIR(color_pair_number));
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
-
-
diff --git a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
index 19d75477b140..7c090244f291 100644
--- a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
+++ b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
@@ -33,7 +33,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.11 2000/05/07 01:26:06 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.13 2000/07/07 16:50:27 tom Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -61,7 +61,7 @@ assume_default_colors(int fg, int bg)
if (initialize_pair) /* don't know how to handle this */
returnCode(ERR);
- SP->_default_color = (fg != COLOR_WHITE) || (bg != COLOR_BLACK);
+ SP->_default_color = (fg < 0 || fg == C_MASK) || (bg < 0 || bg == C_MASK);
SP->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK;
SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK;
diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c
index 7ab4b5085c75..f67bf9a35f77 100644
--- a/contrib/ncurses/ncurses/base/lib_getch.c
+++ b/contrib/ncurses/ncurses/base/lib_getch.c
@@ -40,56 +40,17 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.47 2000/05/28 01:12:51 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.50 2000/10/09 23:53:57 Ilya.Zakharevich Exp $")
#include <fifo_defs.h>
int ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
-#ifdef USE_EMX_MOUSE
-# include <sys/select.h>
-static int
-kbd_mouse_read(unsigned char *p)
-{
- fd_set fdset;
- int nums = SP->_ifd + 1;
-
- for (;;) {
- FD_ZERO(&fdset);
- FD_SET(SP->_ifd, &fdset);
- if (SP->_checkfd >= 0) {
- FD_SET(SP->_checkfd, &fdset);
- if (SP->_checkfd >= nums)
- nums = SP->_checkfd + 1;
- }
- if (SP->_mouse_fd >= 0) {
- FD_SET(SP->_mouse_fd, &fdset);
- if (SP->_mouse_fd >= nums)
- nums = SP->_mouse_fd + 1;
- }
- if (select(nums, &fdset, NULL, NULL, NULL) >= 0) {
- int n;
-
- if (SP->_mouse_fd >= 0
- && FD_ISSET(SP->_mouse_fd, &fdset)) { /* Prefer mouse */
- n = read(SP->_mouse_fd, p, 1);
- } else {
- n = read(SP->_ifd, p, 1);
- }
- return n;
- }
- if (errno != EINTR) {
- return -1;
- }
- }
-}
-#endif /* USE_EMX_MOUSE */
-
static inline int
fifo_peek(void)
{
int ch = SP->_fifo[peek];
- T(("peeking at %d", peek));
+ TR(TRACE_IEVENT, ("peeking at %d", peek));
p_inc();
return ch;
@@ -100,7 +61,7 @@ fifo_pull(void)
{
int ch;
ch = SP->_fifo[head];
- T(("pulling %d from %d", ch, head));
+ TR(TRACE_IEVENT, ("pulling %d from %d", ch, head));
if (peek == head) {
h_inc();
@@ -129,7 +90,7 @@ fifo_push(void)
errno = 0;
#endif
-#if USE_GPM_SUPPORT
+#if USE_GPM_SUPPORT || defined(USE_EMX_MOUSE)
if ((SP->_mouse_fd >= 0)
&& (_nc_timed_wait(3, -1, (int *) 0) & 2)) {
SP->_mouse_event(SP);
@@ -139,11 +100,7 @@ fifo_push(void)
#endif
{
unsigned char c2 = 0;
-#ifdef USE_EMX_MOUSE
- n = kbd_mouse_read(&c2);
-#else
n = read(SP->_ifd, &c2, 1);
-#endif
ch = c2 & 0xff;
}
@@ -162,17 +119,17 @@ fifo_push(void)
#endif
if ((n == -1) || (n == 0)) {
- T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
- return ERR;
+ TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
+ ch = ERR;
}
- T(("read %d characters", n));
+ TR(TRACE_IEVENT, ("read %d characters", n));
SP->_fifo[tail] = ch;
SP->_fifohold = 0;
if (head == -1)
head = peek = tail;
t_inc();
- T(("pushed %#x at %d", ch, tail));
+ TR(TRACE_IEVENT, ("pushed %#x at %d", ch, tail));
#ifdef TRACE
if (_nc_tracing & TRACE_IEVENT)
_nc_fifo_dump();
@@ -223,7 +180,7 @@ wgetch(WINDOW *win)
if (head == -1 && !SP->_raw && !SP->_cbreak) {
char buf[MAXCOLUMNS], *sp;
- T(("filling queue in cooked mode"));
+ TR(TRACE_IEVENT, ("filling queue in cooked mode"));
wgetnstr(win, buf, MAXCOLUMNS);
@@ -241,13 +198,13 @@ wgetch(WINDOW *win)
if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
int delay;
- T(("timed delay in wgetch()"));
+ TR(TRACE_IEVENT, ("timed delay in wgetch()"));
if (SP->_cbreak > 1)
delay = (SP->_cbreak - 1) * 100;
else
delay = win->_delay;
- T(("delay is %d milliseconds", delay));
+ TR(TRACE_IEVENT, ("delay is %d milliseconds", delay));
if (head == -1) /* fifo is empty */
if (!_nc_timed_wait(3, delay, (int *) 0))
diff --git a/contrib/ncurses/ncurses/base/lib_hline.c b/contrib/ncurses/ncurses/base/lib_hline.c
index 71d6b140424c..fd32d35a38e7 100644
--- a/contrib/ncurses/ncurses/base/lib_hline.c
+++ b/contrib/ncurses/ncurses/base/lib_hline.c
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_hline.c,v 1.5 2000/04/29 21:14:30 tom Exp $")
+MODULE_ID("$Id: lib_hline.c,v 1.6 2000/07/04 14:08:09 Philippe.Blain Exp $")
int
whline(WINDOW *win, chtype ch, int n)
@@ -69,6 +69,8 @@ whline(WINDOW *win, chtype ch, int n)
line->text[end] = ch;
end--;
}
+
+ _nc_synchook(win);
code = OK;
}
returnCode(code);
diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c
index 59db16d1aea6..3b8563503979 100644
--- a/contrib/ncurses/ncurses/base/lib_mouse.c
+++ b/contrib/ncurses/ncurses/base/lib_mouse.c
@@ -84,7 +84,7 @@
#endif
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.52 2000/06/29 23:02:26 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.55 2000/10/10 00:07:28 Ilya.Zakharevich Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
@@ -130,8 +130,8 @@ _trace_slot(const char *tag)
for (ep = events; ep < events + EV_MAX; ep++)
_tracef("mouse event queue slot %ld = %s",
- (long) (ep - events),
- _tracemouse(ep));
+ (long) (ep - events),
+ _tracemouse(ep));
}
#endif
@@ -154,7 +154,7 @@ write_event(int down, int button, int x, int y)
char buf[6];
unsigned long ignore;
- strcpy(buf, key_mouse);
+ strncpy(buf, key_mouse, 3); /* should be "\033[M" */
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
@@ -169,20 +169,27 @@ mouse_server(unsigned long ignored GCC_UNUSED)
MOUEVENTINFO mouev;
HMOU hmou;
unsigned short mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN;
+ int nbuttons = 3;
int oldstate = 0;
- char errmess[] = "Unexpected termination of mouse thread\r\n";
- unsigned long ignore;
+ char err[80];
+ unsigned long rc;
/* open the handle for the mouse */
if (MouOpen(NULL, &hmou) == 0) {
-
- if (MouSetEventMask(&mask, hmou) == 0
- && MouDrawPtr(hmou) == 0) {
-
+ rc = MouSetEventMask(&mask, hmou);
+ if (rc) { /* retry with 2 buttons */
+ mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN;
+ rc = MouSetEventMask(&mask, hmou);
+ nbuttons = 2;
+ }
+ if (rc == 0 && MouDrawPtr(hmou) == 0) {
for (;;) {
/* sit and wait on the event queue */
- if (MouReadEventQue(&mouev, &fWait, hmou))
+ rc = MouReadEventQue(&mouev, &fWait, hmou);
+ if (rc) {
+ sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc);
break;
+ }
if (!mouse_activated)
goto finish;
@@ -195,24 +202,27 @@ mouse_server(unsigned long ignored GCC_UNUSED)
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
write_event(mouev.fs & MOUSE_BN1_DOWN,
- mouse_buttons[1], mouev.col, mouev.row);
+ mouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
write_event(mouev.fs & MOUSE_BN2_DOWN,
- mouse_buttons[3], mouev.col, mouev.row);
+ mouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
write_event(mouev.fs & MOUSE_BN3_DOWN,
- mouse_buttons[2], mouev.col, mouev.row);
+ mouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
}
- }
+ } else
+ sprintf(err, "Error setting event mask, buttons=%d, rc=%lu.\r\n",
+ nbuttons, rc);
- DosWrite(2, errmess, strlen(errmess), &ignore);
+ DosWrite(2, err, strlen(err), &rc);
MouClose(hmou);
}
DosExit(EXIT_THREAD, 0L);
}
+
static void
server_state(const int state)
{ /* It would be nice to implement pointer-off and stop looping... */
@@ -248,8 +258,10 @@ initialize_mousetype(void)
&& strstr(cur_term->type.term_names, "xterm") == 0
&& key_mouse) {
int handles[2];
+
if (pipe(handles) < 0) {
perror("mouse pipe error");
+ return;
} else {
int rc;
@@ -270,9 +282,10 @@ initialize_mousetype(void)
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
rc = DosCreateThread((unsigned long *) &mouse_thread,
- mouse_server, 0, 0, 8192);
+ mouse_server, 0, 0, 8192);
if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
+ return;
} else {
mousetype = M_XTERM;
return;
@@ -359,6 +372,23 @@ _nc_mouse_event(SCREEN * sp GCC_UNUSED)
}
#endif
+#ifdef USE_EMX_MOUSE
+ if (SP->_mouse_fd >= 0
+ && (_nc_timed_wait(3, 0, (int *) 0) & 2) != 0) {
+ char kbuf[3];
+
+ int i, res = read(M_FD(sp), &kbuf, 3); /* Eat the prefix */
+ if (res != 3)
+ printf("Got %d chars instead of 3 for prefix.\n", res);
+ for (i = 0; i < res; i++) {
+ if (kbuf[i] != key_mouse[i])
+ printf("Got char %d instead of %d for prefix.\n",
+ (int) kbuf[i], (int) key_mouse[i]);
+ }
+ return TRUE;
+ }
+#endif /* USE_EMX_MOUSE */
+
/* xterm: never have to query, mouse events are in the keyboard stream */
return (FALSE); /* no event waiting */
}
@@ -419,7 +449,7 @@ _nc_mouse_inline(SCREEN * sp)
kbuf[3] = '\0';
TR(TRACE_IEVENT,
- ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+ ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
eventp->id = 0; /* there's only one mouse... */
@@ -457,8 +487,8 @@ _nc_mouse_inline(SCREEN * sp)
*/
eventp->bstate =
(BUTTON1_RELEASED |
- BUTTON2_RELEASED |
- BUTTON3_RELEASED);
+ BUTTON2_RELEASED |
+ BUTTON3_RELEASED);
/*
* ...however, because there are no kinds of mouse events under
* xterm that can intervene between press and release, we can
@@ -488,9 +518,9 @@ _nc_mouse_inline(SCREEN * sp)
eventp->x = (kbuf[1] - ' ') - 1;
eventp->y = (kbuf[2] - ' ') - 1;
TR(MY_TRACE,
- ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
- _tracemouse(eventp),
- (long) (eventp - events)));
+ ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
+ _tracemouse(eventp),
+ (long) (eventp - events)));
/* bump the next-free pointer into the circular list */
eventp = NEXT(eventp);
@@ -514,7 +544,7 @@ mouse_activate(bool on)
switch (mousetype) {
case M_XTERM:
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
keyok(KEY_MOUSE, on);
#endif
TPUTS_TRACE("xterm mouse initialization");
@@ -598,9 +628,9 @@ _nc_mouse_parse(int runcount)
*/
if (runcount == 1) {
TR(MY_TRACE,
- ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
+ _tracemouse(prev),
+ (long) (prev - events)));
return (prev->id >= 0)
? ((prev->bstate & eventmask) ? TRUE : FALSE)
: FALSE;
@@ -616,9 +646,9 @@ _nc_mouse_parse(int runcount)
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse press/release merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
- runcount);
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ runcount);
}
#endif /* TRACE */
@@ -664,9 +694,9 @@ _nc_mouse_parse(int runcount)
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse click merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
- runcount);
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ runcount);
}
#endif /* TRACE */
@@ -700,7 +730,7 @@ _nc_mouse_parse(int runcount)
/* merge click events forward */
if ((ep->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
&& (follower->bstate &
(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_DOUBLE_CLICKED)
@@ -727,9 +757,9 @@ _nc_mouse_parse(int runcount)
/* merge double-click events forward */
if ((ep->bstate &
- (BUTTON1_DOUBLE_CLICKED
- | BUTTON2_DOUBLE_CLICKED
- | BUTTON3_DOUBLE_CLICKED))
+ (BUTTON1_DOUBLE_CLICKED
+ | BUTTON2_DOUBLE_CLICKED
+ | BUTTON3_DOUBLE_CLICKED))
&& (follower->bstate &
(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_TRIPLE_CLICKED)
@@ -761,9 +791,9 @@ _nc_mouse_parse(int runcount)
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
- runcount);
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ runcount);
}
#endif /* TRACE */
@@ -779,16 +809,16 @@ _nc_mouse_parse(int runcount)
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("after mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
- runcount);
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ runcount);
}
for (ep = runp; ep != eventp; ep = NEXT(ep))
if (ep->id != INVALID_EVENT)
TR(MY_TRACE,
- ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
- _tracemouse(ep),
- (long) (ep - events)));
+ ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
+ _tracemouse(ep),
+ (long) (ep - events)));
#endif /* TRACE */
/* after all this, do we have a valid event? */
@@ -847,8 +877,8 @@ getmouse(MEVENT * aevent)
*aevent = *prev;
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ _tracemouse(prev),
+ (long) (prev - events)));
prev->id = INVALID_EVENT; /* so the queue slot becomes free */
returnCode(OK);
@@ -888,12 +918,12 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
if (mousetype != M_NONE) {
eventmask = newmask &
(BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
- | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
- | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
- | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
- | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
- | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
- | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
+ | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
+ | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
+ | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
+ | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
+ | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
+ | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
mouse_activate(eventmask != 0);
@@ -910,9 +940,9 @@ wenclose(const WINDOW *win, int y, int x)
if (win) {
y -= win->_yoffset;
return ((win->_begy <= y &&
- win->_begx <= x &&
- (win->_begx + win->_maxx) >= x &&
- (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+ win->_begx <= x &&
+ (win->_begx + win->_maxx) >= x &&
+ (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
}
return FALSE;
}
diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c
index 08e35cf50182..7da4069b5b85 100644
--- a/contrib/ncurses/ncurses/base/lib_newterm.c
+++ b/contrib/ncurses/ncurses/base/lib_newterm.c
@@ -40,14 +40,14 @@
#include <curses.priv.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.46 2000/07/01 22:26:22 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.48 2000/09/02 18:11:42 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -191,17 +191,21 @@ newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
SP->_use_rmso = SGR0_TEST(exit_standout_mode);
SP->_use_rmul = SGR0_TEST(exit_underline_mode);
-#ifdef USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT
/*
* XFree86 xterm can be configured to support UTF-8 based on environment
* variable settings.
*/
{
char *s;
- if (((s = getenv("LC_ALL")) != 0
- || (s = getenv("LC_CTYPE")) != 0
- || (s = getenv("LANG")) != 0)
- && strstr(s, "UTF-8") != 0) {
+ s = getenv("LC_ALL");
+ if (s == NULL || *s == '\0') {
+ s = getenv("LC_CTYPE");
+ if (s == NULL || *s == '\0') {
+ s = getenv("LANG");
+ }
+ }
+ if (s != NULL && *s != '\0' && strstr(s, "UTF-8") != NULL) {
SP->_outch = _nc_utf8_outch;
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_restart.c b/contrib/ncurses/ncurses/base/lib_restart.c
index de0182f42691..831e3255d842 100644
--- a/contrib/ncurses/ncurses/base/lib_restart.c
+++ b/contrib/ncurses/ncurses/base/lib_restart.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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 *
@@ -41,50 +41,51 @@
#include <curses.priv.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
-#include <term.h> /* lines, columns, cur_term */
+#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_restart.c,v 1.2 1999/07/24 20:10:04 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.3 2000/09/02 18:09:44 tom Exp $")
-int restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
+int
+restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
{
-int saveecho = SP->_echo;
-int savecbreak = SP->_cbreak;
-int saveraw = SP->_raw;
-int savenl = SP->_nl;
+ int saveecho = SP->_echo;
+ int savecbreak = SP->_cbreak;
+ int saveraw = SP->_raw;
+ int savenl = SP->_nl;
- T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
+ T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
- setupterm(termp, filenum, errret);
+ setupterm(termp, filenum, errret);
- if (saveecho)
- echo();
- else
- noecho();
+ if (saveecho)
+ echo();
+ else
+ noecho();
- if (savecbreak) {
- cbreak();
- noraw();
- } else if (saveraw) {
- nocbreak();
- raw();
- } else {
- nocbreak();
- noraw();
- }
- if (savenl)
- nl();
- else
- nonl();
+ if (savecbreak) {
+ cbreak();
+ noraw();
+ } else if (saveraw) {
+ nocbreak();
+ raw();
+ } else {
+ nocbreak();
+ noraw();
+ }
+ if (savenl)
+ nl();
+ else
+ nonl();
- reset_prog_mode();
+ reset_prog_mode();
#if USE_SIZECHANGE
- _nc_update_screensize();
+ _nc_update_screensize();
#endif
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c
index b4d547fcf514..15dd6d3f505d 100644
--- a/contrib/ncurses/ncurses/base/lib_set_term.c
+++ b/contrib/ncurses/ncurses/base/lib_set_term.c
@@ -43,7 +43,7 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.55 2000/07/02 00:22:18 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.58 2000/10/04 22:05:48 tom Exp $")
SCREEN *
set_term(SCREEN * screenp)
@@ -171,7 +171,7 @@ no_mouse_wrap(SCREEN * sp GCC_UNUSED)
{
}
-#if defined(NCURSES_EXT_FUNCS) && defined(USE_COLORFGBG)
+#if NCURSES_EXT_FUNCS && USE_COLORFGBG
static char *
extract_fgbg(char *src, int *result)
{
@@ -220,17 +220,45 @@ _nc_setupscreen(short slines, short const scolumns, FILE * output)
SP->_endwin = TRUE;
SP->_ofp = output;
SP->_cursor = -1; /* cannot know real cursor shape */
-#ifdef NCURSES_NO_PADDING
+
+#if NCURSES_NO_PADDING
SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
SP->_no_padding ? " not" : ""));
#endif
-#ifdef NCURSES_EXT_FUNCS
+
+#if NCURSES_EXT_FUNCS
SP->_default_color = FALSE;
SP->_has_sgr_39_49 = FALSE;
+
+ /*
+ * Set our assumption of the terminal's default foreground and background
+ * colors. The curs_color man-page states that we can assume that the
+ * background is black. The origin of this assumption appears to be
+ * terminals that displayed colored text, but no colored backgrounds, e.g.,
+ * the first colored terminals around 1980. More recent ones with better
+ * technology can display not only colored backgrounds, but all
+ * combinations. So a terminal might be something other than "white" on
+ * black (green/black looks monochrome too), but black on white or even
+ * on ivory.
+ *
+ * White-on-black is the simplest thing to use for monochrome. Almost
+ * all applications that use color paint both text and background, so
+ * the distinction is moot. But a few do not - which is why we leave this
+ * configurable (a better solution is to use assume_default_colors() for
+ * the rare applications that do require that sort of appearance, since
+ * is appears that more users expect to be able to make a white-on-black
+ * or black-on-white display under control of the application than not).
+ */
+#ifdef USE_ASSUMED_COLOR
SP->_default_fg = COLOR_WHITE;
SP->_default_bg = COLOR_BLACK;
-#ifdef USE_COLORFGBG
+#else
+ SP->_default_fg = C_MASK;
+ SP->_default_bg = C_MASK;
+#endif
+
+#if USE_COLORFGBG
/*
* If rxvt's $COLORFGBG variable is set, use it to specify the assumed
* default colors. Note that rxvt (mis)uses bold colors, equating a bold
diff --git a/contrib/ncurses/ncurses/base/lib_winch.c b/contrib/ncurses/ncurses/base/lib_winch.c
index 119c731ebe3b..765220799a50 100644
--- a/contrib/ncurses/ncurses/base/lib_winch.c
+++ b/contrib/ncurses/ncurses/base/lib_winch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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 *
@@ -39,14 +39,15 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_winch.c,v 1.1 1998/11/14 22:06:09 tom Exp $")
+MODULE_ID("$Id: lib_winch.c,v 1.2 2000/07/29 16:41:44 tom Exp $")
-chtype winch(WINDOW *win)
+chtype
+winch(WINDOW *win)
{
- T((T_CALLED("winch(%p)"), win));
- if (win != 0) {
- returnCode(win->_line[win->_cury].text[win->_curx]);
- } else {
- returnCode(0);
- }
+ T((T_CALLED("winch(%p)"), win));
+ if (win != 0) {
+ returnChar(win->_line[win->_cury].text[win->_curx]);
+ } else {
+ returnChar(0);
+ }
}
diff --git a/contrib/ncurses/ncurses/curses.priv.h b/contrib/ncurses/ncurses/curses.priv.h
index d3d5f296ef8b..d82e3aad752a 100644
--- a/contrib/ncurses/ncurses/curses.priv.h
+++ b/contrib/ncurses/ncurses/curses.priv.h
@@ -33,7 +33,7 @@
/*
- * $Id: curses.priv.h,v 1.162 2000/06/24 21:06:10 tom Exp $
+ * $Id: curses.priv.h,v 1.168 2000/10/08 01:24:59 tom Exp $
*
* curses.priv.h
*
@@ -99,7 +99,7 @@ extern int errno;
/* Some systems have a broken 'select()', but workable 'poll()'. Use that */
#if HAVE_WORKING_POLL
#define USE_FUNC_POLL 1
-#ifdef HAVE_POLL_H
+#if HAVE_POLL_H
#include <poll.h>
#else
#include <sys/poll.h>
@@ -134,7 +134,7 @@ extern int errno;
* If we don't have signals to support it, don't add a sigwinch handler.
* In any case, resizing is an extended feature. Use it if we've got it.
*/
-#ifndef NCURSES_EXT_FUNCS
+#if !NCURSES_EXT_FUNCS
#undef HAVE_SIZECHANGE
#endif
@@ -145,6 +145,17 @@ extern int errno;
#endif
/*
+ * If desired, one can configure this, disabling environment variables that
+ * point to custom terminfo/termcap locations.
+ */
+#ifdef USE_ROOT_ENVIRON
+#define use_terminfo_vars() 1
+#else
+#define use_terminfo_vars() _nc_env_access()
+extern int _nc_env_access(void);
+#endif
+
+/*
* Not all platforms have memmove; some have an equivalent bcopy. (Some may
* have neither).
*/
@@ -288,7 +299,7 @@ struct screen {
SLK *_slk; /* ptr to soft key struct / NULL */
int slk_format; /* selected format for this screen */
/* cursor movement costs; units are 10ths of milliseconds */
-#ifdef NCURSES_NO_PADDING
+#if NCURSES_NO_PADDING
int _no_padding; /* flag to set if padding disabled */
#endif
int _char_padding; /* cost of character put */
@@ -329,9 +340,7 @@ struct screen {
int _ip_cost; /* cost of (insert_padding) */
/* used in lib_mvcur.c */
char * _address_cursor;
- int _carriage_return_length;
- int _cursor_home_length;
- int _cursor_to_ll_length;
+ /* used in tty_update.c */
int _scrolling; /* 1 if terminal's smart enough to */
/* used in lib_color.c */
@@ -339,7 +348,7 @@ struct screen {
int _color_count; /* count of colors in palette */
unsigned short *_color_pairs; /* screen's color pair list */
int _pair_count; /* count of color pairs */
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
bool _default_color; /* use default colors */
bool _has_sgr_39_49; /* has ECMA default color support */
int _default_fg; /* assumed default foreground */
@@ -407,7 +416,7 @@ struct screen {
extern SCREEN *_nc_screen_chain;
-#ifdef NCURSES_NOMACROS
+#if NCURSES_NOMACROS
#include <nomacros.h>
#endif
@@ -530,12 +539,14 @@ typedef struct {
#define TPUTS_TRACE(s) _nc_tputs_trace = s;
#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
#define returnAttr(code) TRACE_RETURN(code,attr_t)
+#define returnChar(code) TRACE_RETURN(code,chtype)
#define returnCode(code) TRACE_RETURN(code,int)
#define returnPtr(code) TRACE_RETURN(code,ptr)
#define returnVoid T((T_RETURN(""))); return
#define returnWin(code) TRACE_RETURN(code,win)
extern WINDOW * _nc_retrace_win(WINDOW *);
extern attr_t _nc_retrace_attr_t(attr_t);
+extern attr_t _nc_retrace_chtype(chtype);
extern char *_nc_retrace_ptr(char *);
extern const char *_nc_tputs_trace;
extern int _nc_retrace_int(int);
@@ -546,6 +557,7 @@ extern void _nc_fifo_dump(void);
#define TR(n, a)
#define TPUTS_TRACE(s)
#define returnAttr(code) return code
+#define returnChar(code) return code
#define returnCode(code) return code
#define returnPtr(code) return code
#define returnVoid return
@@ -568,7 +580,7 @@ extern const char *_nc_visbuf2(int, const char *);
(S) = ((S) & ALL_BUT_COLOR) | (at);\
else\
(S) |= (at);\
- T(("new attribute is %s", _traceattr((S))));}
+ TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define toggle_attr_off(S,at) {\
@@ -583,7 +595,7 @@ extern const char *_nc_visbuf2(int, const char *);
else /* leave color alone */\
(S) &= ~(at);\
}\
- T(("new attribute is %s", _traceattr((S))));}
+ TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define DelCharCost(count) \
((parm_dch != 0) \
@@ -607,7 +619,8 @@ extern const char *_nc_visbuf2(int, const char *);
vidattr(AttrOf(c)); \
if (magic_cookie_glitch > 0 \
&& XMC_CHANGES((chg ^ SP->_current_attr))) { \
- T(("%s @%d before glitch %d,%d", \
+ TR(TRACE_ATTRS, \
+ ("%s @%d before glitch %d,%d", \
__FILE__, __LINE__, \
SP->_cursrow, \
SP->_curscol)); \
@@ -619,7 +632,7 @@ extern const char *_nc_visbuf2(int, const char *);
vidattr(AttrOf(c))
#endif
-#if defined(NCURSES_EXPANDED) && defined(NCURSES_EXT_FUNCS)
+#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
#undef toggle_attr_on
#define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
@@ -678,14 +691,40 @@ extern void _nc_screen_init(void);
extern void _nc_screen_resume(void);
extern void _nc_screen_wrap(void);
+/* lib_mouse.c */
+extern int _nc_has_mouse(void);
+
+/* lib_mvcur.c */
+#define INFINITY 1000000 /* cost: too high to use */
+
+typedef struct {
+ char *s_head;
+ char *s_tail;
+ size_t s_size;
+} string_desc;
+
+/* strings.c */
+extern string_desc *_nc_str_init(string_desc * dst, char *src, size_t len);
+extern string_desc *_nc_str_null(string_desc * dst, size_t len);
+extern string_desc *_nc_str_copy(string_desc * dst, string_desc * src);
+extern bool _nc_safe_strcat(string_desc * dst, const char *src);
+extern bool _nc_safe_strcpy(string_desc * dst, const char *src);
+
+extern void _nc_mvcur_init(void);
+extern void _nc_mvcur_resume(void);
+extern void _nc_mvcur_wrap(void);
+
+extern int _nc_scrolln(int, int, int, int);
+
+extern void _nc_screen_init(void);
+extern void _nc_screen_resume(void);
+extern void _nc_screen_wrap(void);
+
#if !HAVE_STRSTR
#define strstr _nc_strstr
extern char *_nc_strstr(const char *, const char *);
#endif
-/* lib_mouse.c */
-extern int _nc_has_mouse(void);
-
/* safe_sprintf.c */
extern char * _nc_printf_string(const char *fmt, va_list ap);
@@ -731,7 +770,7 @@ extern void _nc_trace_tries(struct tries *tree);
extern void _nc_update_screensize(void);
#endif
-#ifdef USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT
extern int _nc_utf8_outch(int);
#endif
@@ -750,10 +789,6 @@ extern int *_nc_oldnums;
* On systems with a broken linker, define 'SP' as a function to force the
* linker to pull in the data-only module with 'SP'.
*/
-#ifndef BROKEN_LINKER
-#define BROKEN_LINKER 0
-#endif
-
#if BROKEN_LINKER
#define SP _nc_screen()
extern SCREEN *_nc_screen(void);
diff --git a/contrib/ncurses/ncurses/llib-lncurses b/contrib/ncurses/ncurses/llib-lncurses
index 4ea7899429f0..280325ace2c5 100644
--- a/contrib/ncurses/ncurses/llib-lncurses
+++ b/contrib/ncurses/ncurses/llib-lncurses
@@ -42,6 +42,10 @@ int *_nc_oldnums;
void _nc_scroll_optimize(void)
{ /* void */ }
+#undef _nc_linedump
+void _nc_linedump(void)
+ { /* void */ }
+
/* ./tty/hashmap.c */
#include <term.h>
@@ -247,6 +251,7 @@ int pair_content(
#undef _nc_do_color
void _nc_do_color(
+ int old_pair,
int pair,
bool reverse,
int (*outc)(
@@ -894,6 +899,18 @@ void timeout(
int z)
{ /* void */ }
+#undef touchline
+int touchline(
+ WINDOW *a1,
+ int a2,
+ int z)
+ { return(*(int *)0); }
+
+#undef touchwin
+int touchwin(
+ WINDOW *z)
+ { return(*(int *)0); }
+
#undef untouchwin
int untouchwin(
WINDOW *z)
@@ -1196,6 +1213,9 @@ int mvcur(
int xnew)
{ return(*(int *)0); }
+#undef _nc_optimize_enable
+int _nc_optimize_enable;
+
/* ./base/lib_mvwin.c */
#undef mvwin
@@ -1681,21 +1701,52 @@ int wtouchln(
/* ./trace/lib_traceatr.c */
-#undef _nc_lib_traceatr
-void _nc_lib_traceatr(void)
- { /* void */ }
+#undef _traceattr2
+char *_traceattr2(
+ int bufnum,
+ attr_t newmode)
+ { return(*(char **)0); }
+
+#undef _traceattr
+char *_traceattr(
+ attr_t newmode)
+ { return(*(char **)0); }
+
+#undef _nc_retrace_attr_t
+attr_t _nc_retrace_attr_t(
+ attr_t code)
+ { return(*(attr_t *)0); }
+
+#undef _tracechtype2
+char *_tracechtype2(
+ int bufnum,
+ chtype ch)
+ { return(*(char **)0); }
+
+#undef _tracechtype
+char *_tracechtype(
+ chtype ch)
+ { return(*(char **)0); }
+
+#undef _nc_retrace_chtype
+attr_t _nc_retrace_chtype(
+ attr_t code)
+ { return(*(attr_t *)0); }
/* ./trace/lib_tracedmp.c */
-#undef _nc_lib_tracedmp
-void _nc_lib_tracedmp(void)
+#undef _tracedump
+void _tracedump(
+ const char *name,
+ WINDOW *win)
{ /* void */ }
/* ./trace/lib_tracemse.c */
-#undef _nc_lib_tracemouse
-void _nc_lib_tracemouse(void)
- { /* void */ }
+#undef _tracemouse
+char *_tracemouse(
+ MEVENT const *ep)
+ { return(*(char **)0); }
/* ./tty/lib_tstp.c */
@@ -1709,6 +1760,10 @@ void _nc_signal_handler(
/* ./base/lib_ungetch.c */
+#undef _nc_fifo_dump
+void _nc_fifo_dump(void)
+ { /* void */ }
+
#undef ungetch
int ungetch(
int ch)
@@ -1823,6 +1878,7 @@ char *_nc_printf_string(
/* ./tty/tty_update.c */
#include <sys/time.h>
+#include <sys/times.h>
#undef doupdate
int doupdate(void)
@@ -1898,11 +1954,6 @@ void _nc_toggle_attr_off(
attr_t at)
{ /* void */ }
-#undef _nc_can_clear_with
-int _nc_can_clear_with(
- chtype ch)
- { return(*(int *)0); }
-
#undef _nc_DelCharCost
int _nc_DelCharCost(
int count)
@@ -2016,18 +2067,27 @@ int wresize(
/* ./tinfo/access.c */
+#undef _nc_basename
+char *_nc_basename(
+ char *path)
+ { return(*(char **)0); }
+
#undef _nc_access
int _nc_access(
const char *path,
int mode)
{ return(*(int *)0); }
+#undef _nc_env_access
+int _nc_env_access(void)
+ { return(*(int *)0); }
+
/* ./tinfo/add_tries.c */
#undef _nc_add_to_try
void _nc_add_to_try(
struct tries **tree,
- char *str,
+ const char *str,
unsigned short code)
{ /* void */ }
@@ -2221,7 +2281,8 @@ void _nc_read_entry_source(
{ /* void */ }
#undef _nc_resolve_uses
-int _nc_resolve_uses(void)
+int _nc_resolve_uses(
+ bool fullresolve)
{ return(*(int *)0); }
/* ./tinfo/comp_scan.c */
@@ -2236,6 +2297,10 @@ long _nc_comment_start;
long _nc_comment_end;
#undef _nc_start_line
long _nc_start_line;
+#undef _nc_curr_token
+struct token _nc_curr_token;
+#undef _nc_disable_period
+bool _nc_disable_period;
#undef _nc_get_token
int _nc_get_token(void)
@@ -2243,7 +2308,8 @@ int _nc_get_token(void)
#undef _nc_trans_string
char _nc_trans_string(
- char *ptr)
+ char *ptr,
+ char *last)
{ return(*(char *)0); }
#undef _nc_push_token
@@ -2311,11 +2377,10 @@ char *_nc_home_terminfo(void)
#include <init_keytry.h>
-#endif
+#undef _nc_tinfo_fkeys
+struct tinfo_fkeys _nc_tinfo_fkeys[];
-#undef _nc_tinfo_fkeysf
-struct tinfo_fkeys *_nc_tinfo_fkeysf(void)
- { return(*(struct tinfo_fkeys **)0); }
+#endif
#undef _nc_init_keytry
void _nc_init_keytry(void)
@@ -2335,8 +2400,8 @@ void _nc_init_acs(void)
#include <termcap.h>
struct speed {
- speed_t s;
- int sp;
+ int s;
+ int sp;
};
#undef _nc_baudrate
@@ -2598,6 +2663,14 @@ char *tgetstr(
char **area)
{ return(*(char **)0); }
+/* ./tinfo/lib_termname.c */
+
+#undef termname
+char *termname(void)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_tgoto.c */
+
#undef tgoto
char *tgoto(
const char *string,
@@ -2605,12 +2678,6 @@ char *tgoto(
int y)
{ return(*(char **)0); }
-/* ./tinfo/lib_termname.c */
-
-#undef termname
-char *termname(void)
- { return(*(char **)0); }
-
/* ./tinfo/lib_ti.c */
#undef tigetflag
@@ -2630,9 +2697,12 @@ char *tigetstr(
/* ./tinfo/lib_tparm.c */
-typedef union {
- unsigned int num;
- char *str;
+typedef struct {
+ union {
+ unsigned int num;
+ char *str;
+ } data;
+ bool num_type;
} stack_frame;
#undef tparm
@@ -2646,7 +2716,7 @@ char *tparm(
#undef PC
char PC;
#undef ospeed
-speed_t ospeed;
+short ospeed;
#undef _nc_nulls_sent
int _nc_nulls_sent;
@@ -2655,6 +2725,10 @@ int delay_output(
int ms)
{ return(*(int *)0); }
+#undef _nc_flush
+void _nc_flush(void)
+ { /* void */ }
+
#undef _nc_outch
int _nc_outch(
int ch)
@@ -2677,6 +2751,10 @@ int tputs(
#undef _nc_tracing
unsigned _nc_tracing;
+#undef _nc_tputs_trace
+const char *_nc_tputs_trace = {0};
+#undef _nc_outchars
+long _nc_outchars;
#undef trace
void trace(
@@ -2694,8 +2772,34 @@ const char *_nc_visbuf(
const char *buf)
{ return(*(const char **)0); }
+#undef _tracef
+void _tracef(
+ const char *fmt,
+ ...)
+ { /* void */ }
+
+#undef _nc_retrace_int
+int _nc_retrace_int(
+ int code)
+ { return(*(int *)0); }
+
+#undef _nc_retrace_ptr
+char *_nc_retrace_ptr(
+ char *code)
+ { return(*(char **)0); }
+
+#undef _nc_retrace_win
+WINDOW *_nc_retrace_win(
+ WINDOW *code)
+ { return(*(WINDOW **)0); }
+
/* ./trace/lib_tracebits.c */
+typedef struct {
+ unsigned int val;
+ const char *name;
+} BITNAMES;
+
#undef _nc_tracebits
char *_nc_tracebits(void)
{ return(*(char **)0); }
@@ -2782,8 +2886,6 @@ char *const strnames[] = {0};
char *const strfnames[] = {0};
/* ./tinfo/parse_entry.c */
-#undef _nc_curr_token
-struct token _nc_curr_token;
#undef _nc_parse_entry
int _nc_parse_entry(
@@ -2842,6 +2944,39 @@ void _nc_set_buffer(
bool buffered)
{ /* void */ }
+/* ./tinfo/strings.c */
+
+#undef _nc_str_init
+string_desc *_nc_str_init(
+ string_desc *dst,
+ char *src,
+ size_t len)
+ { return(*(string_desc **)0); }
+
+#undef _nc_str_null
+string_desc *_nc_str_null(
+ string_desc *dst,
+ size_t len)
+ { return(*(string_desc **)0); }
+
+#undef _nc_str_copy
+string_desc *_nc_str_copy(
+ string_desc *dst,
+ string_desc *src)
+ { return(*(string_desc **)0); }
+
+#undef _nc_safe_strcat
+bool _nc_safe_strcat(
+ string_desc *dst,
+ const char *src)
+ { return(*(bool *)0); }
+
+#undef _nc_safe_strcpy
+bool _nc_safe_strcpy(
+ string_desc *dst,
+ const char *src)
+ { return(*(bool *)0); }
+
/* ./trace/trace_buf.c */
typedef struct {
diff --git a/contrib/ncurses/ncurses/modules b/contrib/ncurses/ncurses/modules
index 12ed6a5f6aba..eb84a07e51f0 100644
--- a/contrib/ncurses/ncurses/modules
+++ b/contrib/ncurses/ncurses/modules
@@ -1,4 +1,4 @@
-# $Id: modules,v 1.72 2000/02/13 01:03:28 tom Exp $
+# $Id: modules,v 1.74 2000/10/03 08:51:18 tom Exp $
##############################################################################
# Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. #
# #
@@ -167,6 +167,7 @@ lib_raw lib $(tinfo) ../include/term.h
lib_setup lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h
lib_termcap lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h $(INCDIR)/capdefaults.c
lib_termname lib $(tinfo) $(INCDIR)/tic.h
+lib_tgoto lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
lib_ti lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
lib_tparm lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
lib_tputs lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
@@ -181,6 +182,7 @@ parse_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic
read_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
read_termcap lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
setbuf lib $(tinfo)
+strings lib $(tinfo)
trace_buf lib $(trace)
trace_tries lib $(trace)
unctrl lib .
diff --git a/contrib/ncurses/ncurses/tinfo/access.c b/contrib/ncurses/ncurses/tinfo/access.c
index 54e549497c94..6fbe92176045 100644
--- a/contrib/ncurses/ncurses/tinfo/access.c
+++ b/contrib/ncurses/ncurses/tinfo/access.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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 *
@@ -27,29 +27,68 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 *
****************************************************************************/
-
#include <curses.priv.h>
+#include <tic.h>
-MODULE_ID("$Id: access.c,v 1.1 1998/07/25 20:17:09 tom Exp $")
+MODULE_ID("$Id: access.c,v 1.4 2000/10/08 01:25:06 tom Exp $")
-int _nc_access(const char *path, int mode)
+char *
+_nc_basename(char *path)
{
- if (access(path, mode) < 0) {
- if ((mode & W_OK) != 0
- && errno == ENOENT) {
- char head[PATH_MAX];
- char *leaf = strrchr(strcpy(head, path), '/');
- if (leaf == 0)
- leaf = head;
- *leaf = '\0';
- if (head == leaf)
- (void)strcpy(head, ".");
- return access(head, R_OK|W_OK|X_OK);
- }
- return -1;
+ char *result = strrchr(path, '/');
+#ifdef __EMX__
+ if (result == 0)
+ result = strrchr(path, '\\');
+#endif
+ if (result == 0)
+ result = path;
+ else
+ result++;
+ return result;
+}
+
+int
+_nc_access(const char *path, int mode)
+{
+ if (access(path, mode) < 0) {
+ if ((mode & W_OK) != 0
+ && errno == ENOENT
+ && strlen(path) < PATH_MAX) {
+ char head[PATH_MAX];
+ char *leaf = _nc_basename(strcpy(head, path));
+
+ if (leaf == 0)
+ leaf = head;
+ *leaf = '\0';
+ if (head == leaf)
+ (void) strcpy(head, ".");
+
+ return access(head, R_OK | W_OK | X_OK);
}
- return 0;
+ return -1;
+ }
+ return 0;
+}
+
+#ifndef USE_ROOT_ENVIRON
+/*
+ * Returns true if we allow application to use environment variables that are
+ * used for searching lists of directories, etc.
+ */
+int
+_nc_env_access(void)
+{
+#if HAVE_ISSETUGID
+ if (issetugid())
+ return FALSE;
+#elif HAVE_GETEUID && HAVE_GETEGID
+ if (getuid() != geteuid()
+ || getgid() != getegid())
+ return FALSE;
+#endif
+ return getuid() != 0; /* ...finally, disallow root */
}
+#endif
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
index 660381a32b5f..eac7c80f0328 100644
--- a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
@@ -43,7 +43,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: alloc_ttype.c,v 1.8 2000/03/25 17:03:11 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.10 2000/08/12 21:56:24 tom Exp $")
#if NCURSES_XNAMES
/*
@@ -54,7 +54,7 @@ static int
merge_names(char **dst, char **a, int na, char **b, int nb)
{
int n = 0;
- while (na && nb) {
+ while (na > 0 && nb > 0) {
int cmp = strcmp(*a, *b);
if (cmp < 0) {
dst[n++] = *a++;
@@ -93,7 +93,7 @@ find_name(char **table, int length, char *name)
static void
realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
- ext_Numbers, int ext_Strings)
+ ext_Numbers, int ext_Strings)
{
int n, m, base;
int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
@@ -102,8 +102,8 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
to->num_Booleans += (ext_Booleans - to->ext_Booleans);
to->Booleans = typeRealloc(char, to->num_Booleans, to->Booleans);
for (n = to->ext_Booleans - 1,
- m = ext_Booleans - 1,
- base = to->num_Booleans - (m + 1); m >= 0; m--) {
+ m = ext_Booleans - 1,
+ base = to->num_Booleans - (m + 1); m >= 0; m--) {
if (find_name(to->ext_Names, limit, ext_Names[m])) {
to->Booleans[base + m] = to->Booleans[base + n--];
} else {
@@ -116,8 +116,8 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
to->num_Numbers += (ext_Numbers - to->ext_Numbers);
to->Numbers = typeRealloc(short, to->num_Numbers, to->Numbers);
for (n = to->ext_Numbers - 1,
- m = ext_Numbers - 1,
- base = to->num_Numbers - (m + 1); m >= 0; m--) {
+ m = ext_Numbers - 1,
+ base = to->num_Numbers - (m + 1); m >= 0; m--) {
if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans])) {
to->Numbers[base + m] = to->Numbers[base + n--];
} else {
@@ -130,8 +130,8 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
to->num_Strings += (ext_Strings - to->ext_Strings);
to->Strings = typeRealloc(char *, to->num_Strings, to->Strings);
for (n = to->ext_Strings - 1,
- m = ext_Strings - 1,
- base = to->num_Strings - (m + 1); m >= 0; m--) {
+ m = ext_Strings - 1,
+ base = to->num_Strings - (m + 1); m >= 0; m--) {
if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans + ext_Numbers])) {
to->Strings[base + m] = to->Strings[base + n--];
} else {
@@ -235,7 +235,7 @@ _nc_ext_data_index(TERMTYPE * tp, int n, int token_type)
* Adjust tables to remove (not free) an extended name and its corresponding
* data.
*/
-static void
+static bool
_nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
{
int j;
@@ -270,7 +270,9 @@ _nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
tp->num_Strings -= 1;
break;
}
+ return TRUE;
}
+ return FALSE;
}
/*
@@ -345,14 +347,22 @@ adjust_cancels(TERMTYPE * to, TERMTYPE * from)
if (to->Strings[j + j_str] == CANCELLED_STRING) {
if ((k = _nc_find_ext_name(from, to->ext_Names[j], BOOLEAN)) >= 0) {
- _nc_del_ext_name(to, name, STRING);
- k = _nc_ins_ext_name(to, name, BOOLEAN);
- to->Booleans[k] = FALSE;
+ if (_nc_del_ext_name(to, name, STRING)
+ || _nc_del_ext_name(to, name, NUMBER)) {
+ k = _nc_ins_ext_name(to, name, BOOLEAN);
+ to->Booleans[k] = FALSE;
+ } else {
+ j++;
+ }
} else if ((k = _nc_find_ext_name(from, to->ext_Names[j],
- NUMBER)) >= 0) {
- _nc_del_ext_name(to, name, STRING);
- k = _nc_ins_ext_name(to, name, NUMBER);
- to->Numbers[k] = CANCELLED_NUMERIC;
+ NUMBER)) >= 0) {
+ if (_nc_del_ext_name(to, name, STRING)
+ || _nc_del_ext_name(to, name, BOOLEAN)) {
+ k = _nc_ins_ext_name(to, name, NUMBER);
+ to->Numbers[k] = CANCELLED_NUMERIC;
+ } else {
+ j++;
+ }
}
} else {
j++;
@@ -371,7 +381,7 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
int ext_Booleans, ext_Numbers, ext_Strings;
DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names,
- nb, from->term_names));
+ nb, from->term_names));
if (na != 0 || nb != 0) {
if ((na == nb) /* check if the arrays are equivalent */
@@ -402,26 +412,26 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
adjust_cancels(from, to);
ext_Booleans = merge_names(ext_Names,
- to->ext_Names,
- to->ext_Booleans,
- from->ext_Names,
- from->ext_Booleans);
+ to->ext_Names,
+ to->ext_Booleans,
+ from->ext_Names,
+ from->ext_Booleans);
ext_Numbers = merge_names(ext_Names + ext_Booleans,
- to->ext_Names
- + to->ext_Booleans,
- to->ext_Numbers,
- from->ext_Names
- + from->ext_Booleans,
- from->ext_Numbers);
+ to->ext_Names
+ + to->ext_Booleans,
+ to->ext_Numbers,
+ from->ext_Names
+ + from->ext_Booleans,
+ from->ext_Numbers);
ext_Strings = merge_names(ext_Names + ext_Numbers + ext_Booleans,
- to->ext_Names
- + to->ext_Booleans
- + to->ext_Numbers,
- to->ext_Strings,
- from->ext_Names
- + from->ext_Booleans
- + from->ext_Numbers,
- from->ext_Strings);
+ to->ext_Names
+ + to->ext_Booleans
+ + to->ext_Numbers,
+ to->ext_Strings,
+ from->ext_Names
+ + from->ext_Booleans
+ + from->ext_Numbers,
+ from->ext_Strings);
/*
* Now we must reallocate the Booleans, etc., to allow the data to be
* overlaid.
@@ -431,7 +441,7 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
FreeIfNeeded(to->ext_Names);
to->ext_Names = ext_Names;
DEBUG(2, ("realigned %d extended names for '%s' (to)",
- NUM_EXT_NAMES(to), to->term_names));
+ NUM_EXT_NAMES(to), to->term_names));
}
if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) {
nb = (ext_Booleans + ext_Numbers + ext_Strings);
@@ -439,7 +449,7 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
from->ext_Names = typeRealloc(char *, nb, from->ext_Names);
memcpy(from->ext_Names, ext_Names, sizeof(char *) * nb);
DEBUG(2, ("realigned %d extended names for '%s' (from)",
- NUM_EXT_NAMES(from), from->term_names));
+ NUM_EXT_NAMES(from), from->term_names));
}
}
}
diff --git a/contrib/ncurses/ncurses/tinfo/comp_parse.c b/contrib/ncurses/ncurses/tinfo/comp_parse.c
index ca58bb5746e7..c4083877ebca 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_parse.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_parse.c
@@ -52,7 +52,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: comp_parse.c,v 1.40 2000/04/15 16:57:08 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.41 2000/10/03 09:53:49 tom Exp $")
static void sanity_check(TERMTYPE *);
void (*_nc_check_termtype) (TERMTYPE *) = sanity_check;
@@ -122,26 +122,29 @@ _nc_free_entries(ENTRY * headp)
}
}
+static char *
+force_bar(char *dst, char *src)
+{
+ if (strchr(src, '|') == 0) {
+ size_t len = strlen(src);
+ if (len >= MAX_NAME_SIZE)
+ len = MAX_NAME_SIZE;
+ (void) strncpy(dst, src, len);
+ (void) strcpy(dst + len, "|");
+ src = dst;
+ }
+ return src;
+}
+
bool
_nc_entry_match(char *n1, char *n2)
/* do any of the aliases in a pair of terminal names match? */
{
char *pstart, *qstart, *pend, *qend;
- char nc1[MAX_NAME_SIZE + 1], nc2[MAX_NAME_SIZE + 1];
+ char nc1[MAX_NAME_SIZE + 2], nc2[MAX_NAME_SIZE + 2];
- if (strchr(n1, '|') == 0) {
- (void) strncpy(nc1, n1, sizeof(nc1) - 2);
- nc1[sizeof(nc1) - 2] = '\0';
- (void) strcat(nc1, "|");
- n1 = nc1;
- }
-
- if (strchr(n2, '|') == 0) {
- (void) strncpy(nc2, n2, sizeof(nc2) - 2);
- nc2[sizeof(nc2) - 2] = '\0';
- (void) strcat(nc2, "|");
- n2 = nc2;
- }
+ n1 = force_bar(nc1, n1);
+ n2 = force_bar(nc2, n2);
for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1)
for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1)
diff --git a/contrib/ncurses/ncurses/tinfo/comp_scan.c b/contrib/ncurses/ncurses/tinfo/comp_scan.c
index 8997e417ae57..e1118f6f9ea9 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_scan.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_scan.c
@@ -50,7 +50,7 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$Id: comp_scan.c,v 1.44 2000/06/10 21:59:21 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.47 2000/09/24 01:15:17 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -80,6 +80,10 @@ static char separator; /* capability separator */
static int pushtype; /* type of pushback token */
static char pushname[MAX_NAME_SIZE + 1];
+#if NCURSES_EXT_FUNCS
+bool _nc_disable_period = FALSE; /* used by tic -a option */
+#endif
+
static int last_char(void);
static int next_char(void);
static long stream_pos(void);
@@ -149,7 +153,7 @@ _nc_get_token(void)
_nc_set_type(pushname);
DEBUG(3, ("pushed-back token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
+ _nc_curr_token.tk_name, pushtype));
pushtype = NO_PUSHBACK;
pushname[0] = '\0';
@@ -176,10 +180,10 @@ _nc_get_token(void)
ch = next_char();
if (ch == '.'
-#ifdef NCURSES_EXT_FUNCS
- && !_nc_disable_period
+#if NCURSES_EXT_FUNCS
+ && !_nc_disable_period
#endif
- ) {
+ ) {
dot_flag = TRUE;
DEBUG(8, ("dot-flag set"));
@@ -194,12 +198,12 @@ _nc_get_token(void)
/* have to make some punctuation chars legal for terminfo */
if (!isalnum(ch)
-#ifdef NCURSES_EXT_FUNCS
- && !(ch == '.' && _nc_disable_period)
+#if NCURSES_EXT_FUNCS
+ && !(ch == '.' && _nc_disable_period)
#endif
- && !strchr(terminfo_punct, (char) ch)) {
+ && !strchr(terminfo_punct, (char) ch)) {
_nc_warning("Illegal character (expected alphanumeric or %s) - %s",
- terminfo_punct, unctrl(ch));
+ terminfo_punct, unctrl(ch));
_nc_panic_mode(separator);
goto start_token;
}
@@ -334,7 +338,7 @@ _nc_get_token(void)
case '@':
if ((ch = next_char()) != separator)
_nc_warning("Missing separator after `%s', have %s",
- buffer, unctrl(ch));
+ buffer, unctrl(ch));
_nc_curr_token.tk_name = buffer;
type = CANCEL;
break;
@@ -387,30 +391,30 @@ _nc_get_token(void)
switch (type) {
case BOOLEAN:
_tracef("Token: Boolean; name='%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
break;
case NUMBER:
_tracef("Token: Number; name='%s', value=%d",
- _nc_curr_token.tk_name,
- _nc_curr_token.tk_valnumber);
+ _nc_curr_token.tk_name,
+ _nc_curr_token.tk_valnumber);
break;
case STRING:
_tracef("Token: String; name='%s', value=%s",
- _nc_curr_token.tk_name,
- _nc_visbuf(_nc_curr_token.tk_valstring));
+ _nc_curr_token.tk_name,
+ _nc_visbuf(_nc_curr_token.tk_valstring));
break;
case CANCEL:
_tracef("Token: Cancel; name='%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
break;
case NAMES:
_tracef("Token: Names; value='%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
break;
case EOF:
@@ -567,7 +571,7 @@ _nc_trans_string(char *ptr, char *last)
default:
_nc_warning("Illegal character %s in \\ sequence",
- unctrl(ch));
+ unctrl(ch));
*(ptr++) = (char) ch;
} /* endswitch (ch) */
} /* endelse (ch < '0' || ch > '7') */
@@ -617,7 +621,7 @@ _nc_push_token(int tokclass)
_nc_get_type(pushname);
DEBUG(3, ("pushing token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
+ _nc_curr_token.tk_name, pushtype));
}
/*
@@ -732,7 +736,7 @@ next_char(void)
} while
(bufstart != NULL && line[0] == '#');
- if (bufstart == NULL)
+ if (bufstart == NULL || *bufstart == 0)
return (EOF);
while (iswhite(*bufptr))
@@ -745,10 +749,19 @@ next_char(void)
if ((len = strlen(bufptr)) > 1) {
if (bufptr[len - 1] == '\n'
&& bufptr[len - 2] == '\r') {
- bufptr[len - 2] = '\n';
- bufptr[len - 1] = '\0';
+ len--;
+ bufptr[len - 1] = '\n';
+ bufptr[len] = '\0';
}
}
+
+ /*
+ * If we don't have a trailing newline, it's because the line is simply
+ * too long. Give up. (FIXME: We could instead reallocate the line
+ * buffer and allow arbitrary-length lines).
+ */
+ if (len == 0 || (bufptr[len - 1] != '\n'))
+ return (EOF);
}
first_column = (bufptr == bufstart);
@@ -778,7 +791,7 @@ end_of_stream(void)
/* are we at end of input? */
{
return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
- ? TRUE : FALSE);
+ ? TRUE : FALSE);
}
/* comp_scan.c ends here */
diff --git a/contrib/ncurses/ncurses/tinfo/free_ttype.c b/contrib/ncurses/ncurses/tinfo/free_ttype.c
index d9d9c0aa52e8..aba1aeb9d82f 100644
--- a/contrib/ncurses/ncurses/tinfo/free_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/free_ttype.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999 Free Software Foundation, Inc. *
+ * Copyright (c) 1999,2000 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 *
@@ -44,30 +44,29 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: free_ttype.c,v 1.3 2000/03/19 02:03:07 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.5 2000/07/08 00:43:58 tom Exp $")
void _nc_free_termtype(TERMTYPE *ptr)
{
- FreeIfNeeded(ptr->str_table);
- FreeIfNeeded(ptr->term_names);
+ FreeIfNeeded(ptr->str_table);
+ FreeIfNeeded(ptr->term_names);
+ FreeIfNeeded(ptr->Booleans);
+ FreeIfNeeded(ptr->Numbers);
+ FreeIfNeeded(ptr->Strings);
#if NCURSES_XNAMES
- FreeIfNeeded(ptr->ext_str_table);
- FreeIfNeeded(ptr->Booleans);
- FreeIfNeeded(ptr->Numbers);
- FreeIfNeeded(ptr->Strings);
- FreeIfNeeded(ptr->ext_Names);
+ FreeIfNeeded(ptr->ext_str_table);
+ FreeIfNeeded(ptr->ext_Names);
#endif
- memset(ptr, 0, sizeof(TERMTYPE));
+ memset(ptr, 0, sizeof(TERMTYPE));
}
#if NCURSES_XNAMES
bool _nc_user_definable = TRUE;
-bool _nc_disable_period = FALSE; /* used by tic -a option */
int use_extended_names(bool flag)
{
- int oldflag = _nc_user_definable;
- _nc_user_definable = flag;
- return oldflag;
+ int oldflag = _nc_user_definable;
+ _nc_user_definable = flag;
+ return oldflag;
}
#endif
diff --git a/contrib/ncurses/ncurses/tinfo/home_terminfo.c b/contrib/ncurses/ncurses/tinfo/home_terminfo.c
index 7aa4ca112e5a..69b8a96ffcff 100644
--- a/contrib/ncurses/ncurses/tinfo/home_terminfo.c
+++ b/contrib/ncurses/ncurses/tinfo/home_terminfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 *
****************************************************************************/
/*
@@ -37,7 +37,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: home_terminfo.c,v 1.2 1999/02/27 19:58:46 tom Exp $")
+MODULE_ID("$Id: home_terminfo.c,v 1.3 2000/10/04 02:31:53 tom Exp $");
#define my_length (strlen(home) + sizeof(PRIVATE_INFO))
@@ -46,17 +46,20 @@ MODULE_ID("$Id: home_terminfo.c,v 1.2 1999/02/27 19:58:46 tom Exp $")
char *
_nc_home_terminfo(void)
{
- char *home;
- static char *temp = 0;
+ char *home;
+ static char *temp = 0;
+ if (use_terminfo_vars()) {
if (temp == 0) {
- if ((home = getenv("HOME")) != 0
- && my_length <= PATH_MAX) {
- temp = typeMalloc(char, my_length);
- if (temp == 0)
- _nc_err_abort("Out of memory");
- (void) sprintf(temp, PRIVATE_INFO, home);
- }
+ if ((home = getenv("HOME")) != 0
+ && my_length <= PATH_MAX) {
+ temp = typeMalloc(char, my_length);
+ if (temp == 0)
+ _nc_err_abort("Out of memory");
+ (void) sprintf(temp, PRIVATE_INFO, home);
+ }
}
return temp;
+ }
+ return 0;
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
index 4077ba384076..0d7fa27bcc3d 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
@@ -31,17 +31,16 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* lib_baudrate.c
*
*/
#include <curses.priv.h>
-#include <term.h> /* cur_term, pad_char */
-#include <termcap.h> /* ospeed */
+#include <term.h> /* cur_term, pad_char */
+#include <termcap.h> /* ospeed */
-MODULE_ID("$Id: lib_baudrate.c,v 1.15 1999/01/31 03:05:25 tom Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.17 2000/10/08 00:59:08 tom Exp $")
/*
* int
@@ -52,117 +51,118 @@ MODULE_ID("$Id: lib_baudrate.c,v 1.15 1999/01/31 03:05:25 tom Exp $")
*/
struct speed {
- speed_t s;
- int sp;
+ int s; /* value for 'ospeed' is an index */
+ int sp; /* the actual speed */
};
-static struct speed const speeds[] = {
- {B0, 0},
- {B50, 50},
- {B75, 75},
- {B110, 110},
- {B134, 134},
- {B150, 150},
- {B200, 200},
- {B300, 300},
- {B600, 600},
- {B1200, 1200},
- {B1800, 1800},
- {B2400, 2400},
- {B4800, 4800},
- {B9600, 9600},
+static struct speed const speeds[] =
+{
+ {B0, 0},
+ {B50, 50},
+ {B75, 75},
+ {B110, 110},
+ {B134, 134},
+ {B150, 150},
+ {B200, 200},
+ {B300, 300},
+ {B600, 600},
+ {B1200, 1200},
+ {B1800, 1800},
+ {B2400, 2400},
+ {B4800, 4800},
+ {B9600, 9600},
#ifdef B19200
- {B19200, 19200},
+ {B19200, 19200},
#else
#ifdef EXTA
- {EXTA, 19200},
+ {EXTA, 19200},
#endif
#endif
#ifdef B38400
- {B38400, 38400},
+ {B38400, 38400},
#else
#ifdef EXTB
- {EXTB, 38400},
+ {EXTB, 38400},
#endif
#endif
#ifdef B57600
- {B57600, 57600},
+ {B57600, 57600},
#endif
#ifdef B115200
- {B115200, 115200},
+ {B115200, 115200},
#endif
#ifdef B230400
- {B230400, 230400},
+ {B230400, 230400},
#endif
#ifdef B460800
- {B460800, 460800},
+ {B460800, 460800},
#endif
};
-int _nc_baudrate(int OSpeed)
+int
+_nc_baudrate(int OSpeed)
{
- static int last_OSpeed;
- static int last_baudrate;
-
- int result;
- unsigned i;
-
- if (OSpeed == last_OSpeed) {
- result = last_baudrate;
- } else {
- result = ERR;
- if (OSpeed >= 0) {
- for (i = 0; i < SIZEOF(speeds); i++) {
- if (speeds[i].s == (speed_t)OSpeed) {
- result = speeds[i].sp;
- break;
- }
- }
+ static int last_OSpeed;
+ static int last_baudrate;
+
+ int result;
+ unsigned i;
+
+ if (OSpeed == last_OSpeed) {
+ result = last_baudrate;
+ } else {
+ result = ERR;
+ if (OSpeed >= 0) {
+ for (i = 0; i < SIZEOF(speeds); i++) {
+ if (speeds[i].s == OSpeed) {
+ result = speeds[i].sp;
+ break;
}
- last_baudrate = result;
+ }
}
- return (result);
+ last_baudrate = result;
+ }
+ return (result);
}
-
-int _nc_ospeed(int BaudRate)
+int
+_nc_ospeed(int BaudRate)
{
- speed_t result = 1;
- unsigned i;
-
- if (BaudRate >= 0) {
- for (i = 0; i < SIZEOF(speeds); i++) {
- if (speeds[i].sp == BaudRate) {
- result = speeds[i].s;
- break;
- }
- }
+ int result = 1;
+ unsigned i;
+
+ if (BaudRate >= 0) {
+ for (i = 0; i < SIZEOF(speeds); i++) {
+ if (speeds[i].sp == BaudRate) {
+ result = speeds[i].s;
+ break;
+ }
}
- return (result);
+ }
+ return (result);
}
int
baudrate(void)
{
-int result;
+ int result;
- T((T_CALLED("baudrate()")));
+ T((T_CALLED("baudrate()")));
- /*
- * In debugging, allow the environment symbol to override when we're
- * redirecting to a file, so we can construct repeatable test-cases
- * that take into account costs that depend on baudrate.
- */
+ /*
+ * In debugging, allow the environment symbol to override when we're
+ * redirecting to a file, so we can construct repeatable test-cases
+ * that take into account costs that depend on baudrate.
+ */
#ifdef TRACE
- if (SP && !isatty(fileno(SP->_ofp))
- && getenv("BAUDRATE") != 0) {
- int ret;
- if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
- ret = 9600;
- ospeed = _nc_ospeed(ret);
- returnCode(ret);
- }
- else
+ if (SP && !isatty(fileno(SP->_ofp))
+ && getenv("BAUDRATE") != 0) {
+ int ret;
+ if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
+ ret = 9600;
+ ospeed = _nc_ospeed(ret);
+ returnCode(ret);
+ } else
#endif
#ifdef TERMIOS
@@ -170,9 +170,9 @@ int result;
#else
ospeed = cur_term->Nttyb.sg_ospeed;
#endif
- result = _nc_baudrate(ospeed);
- if (cur_term != 0)
- cur_term->_baudrate = result;
+ result = _nc_baudrate(ospeed);
+ if (cur_term != 0)
+ cur_term->_baudrate = result;
- returnCode(result);
+ returnCode(result);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_options.c b/contrib/ncurses/ncurses/tinfo/lib_options.c
index b58602af72bb..fc3dc42bca41 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_options.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_options.c
@@ -42,7 +42,7 @@
#include <term.h>
-MODULE_ID("$Id: lib_options.c,v 1.39 2000/03/12 00:19:11 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.40 2000/09/02 18:02:05 tom Exp $")
int
idlok(WINDOW *win, bool flag)
@@ -206,7 +206,7 @@ typeahead(int fd)
**
*/
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
static int
has_key_internal(int keycode, struct tries *tp)
{
diff --git a/contrib/ncurses/ncurses/tinfo/lib_raw.c b/contrib/ncurses/ncurses/tinfo/lib_raw.c
index 6033ed9c10c3..6df95714a9b1 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_raw.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_raw.c
@@ -48,9 +48,9 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.7 2000/02/13 01:01:26 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.8 2000/09/02 18:08:48 tom Exp $")
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
diff --git a/contrib/ncurses/ncurses/tinfo/lib_setup.c b/contrib/ncurses/ncurses/tinfo/lib_setup.c
index 50c330eb5739..1fd0d48f3cc8 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_setup.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_setup.c
@@ -42,13 +42,13 @@
#include <tic.h> /* for MAX_NAME_SIZE */
#include <term_entry.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_setup.c,v 1.59 2000/02/13 01:01:26 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.60 2000/09/02 18:13:12 tom Exp $")
/****************************************************************************
*
@@ -245,7 +245,7 @@ grab_entry(const char *const tn, TERMTYPE * const tp)
if ((status = _nc_read_entry(tn, filename, tp)) != 1) {
-#ifndef PURE_TERMINFO
+#if !PURE_TERMINFO
/*
* Try falling back on the termcap file.
* Note: allowing this call links the entire terminfo/termcap
diff --git a/contrib/ncurses/ncurses/tinfo/lib_termcap.c b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
index c47400132fa8..ecec2865fbae 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
@@ -39,7 +39,7 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$Id: lib_termcap.c,v 1.36 2000/02/13 01:01:26 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.37 2000/09/16 20:30:16 tom Exp $")
/*
some of the code in here was contributed by:
@@ -190,19 +190,3 @@ tgetstr(NCURSES_CONST char *id, char **area)
}
returnPtr(NULL);
}
-
-/*
- * char *
- * tgoto(string, x, y)
- *
- * Retained solely for upward compatibility. Note the intentional
- * reversing of the last two arguments.
- *
- */
-
-char *
-tgoto(const char *string, int x, int y)
-{
- T((T_CALLED("tgoto(%s,%d,%d)"), string, x, y));
- returnPtr(tparm((NCURSES_CONST char *) string, y, x));
-}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tgoto.c b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
new file mode 100644
index 000000000000..73557eb7cc25
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
@@ -0,0 +1,197 @@
+/****************************************************************************
+ * Copyright (c) 2000 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 *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+#include <termcap.h>
+
+MODULE_ID("$Id: lib_tgoto.c,v 1.2 2000/09/24 00:19:14 tom Exp $")
+
+#if !PURE_TERMINFO
+static bool
+is_termcap(const char *string)
+{
+ bool result = TRUE;
+
+ while ((*string != '\0') && result) {
+ if (*string == '%') {
+ switch (*++string) {
+ case 'p':
+ result = FALSE;
+ break;
+ case '\0':
+ string--;
+ break;
+ }
+ } else if (string[0] == '$' && string[1] == '<') {
+ result = FALSE;
+ }
+ string++;
+ }
+ return result;
+}
+
+static char *
+tgoto_internal(const char *string, int x, int y)
+{
+ static char *result;
+ static size_t length;
+
+ int swap_arg;
+ int param[3];
+ size_t used = 0;
+ size_t need = 10;
+ int *value = param;
+ bool need_BC = FALSE;
+
+ if (BC)
+ need += strlen(BC);
+
+ param[0] = y;
+ param[1] = x;
+ param[2] = 0;
+
+ while (*string != 0) {
+ if ((used + need) > length) {
+ length += (used + need);
+ if ((result = _nc_doalloc(result, length)) == 0) {
+ length = 0;
+ break;
+ }
+ }
+ if (*string == '%') {
+ char *fmt = 0;
+
+ switch (*++string) {
+ case '\0':
+ string--;
+ break;
+ case 'd':
+ fmt = "%d";
+ break;
+ case '2':
+ fmt = "%02d";
+ *value %= 100;
+ break;
+ case '3':
+ fmt = "%03d";
+ *value %= 1000;
+ break;
+ case '+':
+ *value += (*++string & 0xff);
+ /* FALLTHRU */
+ case '.':
+ /*
+ * Guard against tputs() seeing a truncated string. The
+ * termcap documentation refers to a similar fixup for \n
+ * and \r, but I don't see that it could work -TD
+ */
+ if (*value == 0) {
+ if (BC != 0) {
+ *value += 1;
+ need_BC = TRUE;
+ } else {
+ *value = 0200; /* tputs will treat this as \0 */
+ }
+ }
+ result[used++] = *value++;
+ break;
+ case '%':
+ result[used++] = *string;
+ break;
+ case 'r':
+ swap_arg = param[0];
+ param[0] = param[1];
+ param[1] = swap_arg;
+ break;
+ case 'i':
+ param[0] += 1;
+ param[1] += 1;
+ break;
+ case '>':
+ if (*value > string[1])
+ *value += string[2];
+ string += 2;
+ break;
+ case 'n': /* Datamedia 2500 */
+ param[0] ^= 0140;
+ param[1] ^= 0140;
+ break;
+ case 'B': /* BCD */
+ *value = 16 * (*value / 10) + (*value % 10);
+ break;
+ case 'D': /* Reverse coding (Delta Data) */
+ *value -= 2 * (*value / 16);
+ break;
+ }
+ if (fmt != 0) {
+ sprintf(result + used, fmt, *value++);
+ used += strlen(result + used);
+ fmt = 0;
+ }
+ if (value - param > 2) {
+ value = param + 2;
+ *value = 0;
+ }
+ } else {
+ result[used++] = *string;
+ }
+ string++;
+ }
+ if (need_BC) {
+ strcpy(result + used, BC);
+ used += strlen(BC);
+ }
+ result[used] = '\0';
+ return result;
+}
+#endif
+
+/*
+ * Retained solely for upward compatibility. Note the intentional reversing of
+ * the last two arguments when invoking tparm().
+ */
+char *
+tgoto(const char *string, int x, int y)
+{
+ char *result;
+
+ T((T_CALLED("tgoto(%s, %d, %d)"), _nc_visbuf(string), x, y));
+#if !PURE_TERMINFO
+ if (is_termcap(string))
+ result = tgoto_internal(string, x, y);
+ else
+#endif
+ result = tparm((NCURSES_CONST char *) string, y, x);
+ returnPtr(result);
+}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tparm.c b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
index 71b82916a356..6a8ca1f0419a 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tparm.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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 *
@@ -31,7 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* tparm.c
*
@@ -43,7 +42,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.39 1999/06/06 00:04:55 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.47 2000/10/04 00:57:13 tom Exp $")
/*
* char *
@@ -74,6 +73,8 @@ MODULE_ID("$Id: lib_tparm.c,v 1.39 1999/06/06 00:04:55 tom Exp $")
* %s print pop() like %s in printf()
* %[[:]flags][width[.precision]][doxXs]
* as in printf, flags are [-+#] and space
+ * The ':' is used to avoid making %+ or %-
+ * patterns (see below).
*
* %p[1-9] push ith parm
* %P[a-z] set dynamic variable [a-z] to pop()
@@ -105,481 +106,636 @@ MODULE_ID("$Id: lib_tparm.c,v 1.39 1999/06/06 00:04:55 tom Exp $")
#define STACKSIZE 20
-typedef union {
- unsigned int num;
- char *str;
+typedef struct {
+ union {
+ unsigned int num;
+ char *str;
+ } data;
+ bool num_type;
} stack_frame;
-static stack_frame stack[STACKSIZE];
-static int stack_ptr;
+static stack_frame stack[STACKSIZE];
+static int stack_ptr;
+
#ifdef TRACE
static const char *tname;
#endif /* TRACE */
-static char *out_buff;
+static char *out_buff;
static size_t out_size;
static size_t out_used;
#if NO_LEAKS
-void _nc_free_tparm(void)
+void
+_nc_free_tparm(void)
{
- if (out_buff != 0) {
- FreeAndNull(out_buff);
- out_size = 0;
- out_used = 0;
- }
+ if (out_buff != 0) {
+ FreeAndNull(out_buff);
+ out_size = 0;
+ out_used = 0;
+ }
}
#endif
-static void really_get_space(size_t need)
+static void
+really_get_space(size_t need)
{
- out_size = need * 2;
- out_buff = typeRealloc(char, out_size, out_buff);
- if (out_buff == 0)
- _nc_err_abort("Out of memory");
+ out_size = need * 2;
+ out_buff = typeRealloc(char, out_size, out_buff);
+ if (out_buff == 0)
+ _nc_err_abort("Out of memory");
}
-static inline void get_space(size_t need)
+static inline void
+get_space(size_t need)
{
- need += out_used;
- if (need > out_size)
- really_get_space(need);
+ need += out_used;
+ if (need > out_size)
+ really_get_space(need);
}
-static inline void save_text(const char *fmt, char *s, int len)
+static inline void
+save_text(const char *fmt, const char *s, int len)
{
- size_t s_len = strlen(s);
- if (len > (int)s_len)
- s_len = len;
+ size_t s_len = strlen(s);
+ if (len > (int) s_len)
+ s_len = len;
- get_space(s_len + 1);
+ get_space(s_len + 1);
- (void)sprintf(out_buff+out_used, fmt, s);
- out_used += strlen(out_buff+out_used);
+ (void) sprintf(out_buff + out_used, fmt, s);
+ out_used += strlen(out_buff + out_used);
}
-static inline void save_number(const char *fmt, int number, int len)
+static inline void
+save_number(const char *fmt, int number, int len)
{
- if (len < 30)
- len = 30; /* actually log10(MAX_INT)+1 */
+ if (len < 30)
+ len = 30; /* actually log10(MAX_INT)+1 */
- get_space(len + 1);
+ get_space(len + 1);
- (void)sprintf(out_buff+out_used, fmt, number);
- out_used += strlen(out_buff+out_used);
+ (void) sprintf(out_buff + out_used, fmt, number);
+ out_used += strlen(out_buff + out_used);
}
-static inline void save_char(int c)
+static inline void
+save_char(int c)
{
- if (c == 0)
- c = 0200;
- get_space(1);
- out_buff[out_used++] = c;
+ if (c == 0)
+ c = 0200;
+ get_space(1);
+ out_buff[out_used++] = c;
}
-static inline void npush(int x)
+static inline void
+npush(int x)
{
- if (stack_ptr < STACKSIZE) {
- stack[stack_ptr].num = x;
- stack_ptr++;
- }
+ if (stack_ptr < STACKSIZE) {
+ stack[stack_ptr].num_type = TRUE;
+ stack[stack_ptr].data.num = x;
+ stack_ptr++;
+ }
}
-static inline int npop(void)
+static inline int
+npop(void)
{
- return (stack_ptr > 0 ? stack[--stack_ptr].num : 0);
+ int result = 0;
+ if (stack_ptr > 0) {
+ stack_ptr--;
+ if (stack[stack_ptr].num_type)
+ result = stack[stack_ptr].data.num;
+ }
+ return result;
}
-static inline char *spop(void)
+static inline void
+spush(char *x)
{
- static char dummy[] = ""; /* avoid const-cast */
- return (stack_ptr > 0 ? stack[--stack_ptr].str : dummy);
+ if (stack_ptr < STACKSIZE) {
+ stack[stack_ptr].num_type = FALSE;
+ stack[stack_ptr].data.str = x;
+ stack_ptr++;
+ }
}
-static inline const char *parse_format(const char *s, char *format, int *len)
+static inline char *
+spop(void)
{
- bool done = FALSE;
- bool allowminus = FALSE;
- bool dot = FALSE;
- int prec = 0;
- int width = 0;
+ static char dummy[] = ""; /* avoid const-cast */
+ char *result = dummy;
+ if (stack_ptr > 0) {
+ stack_ptr--;
+ if (!stack[stack_ptr].num_type && stack[stack_ptr].data.str != 0)
+ result = stack[stack_ptr].data.str;
+ }
+ return result;
+}
- *len = 0;
- *format++ = '%';
- while (*s != '\0' && !done) {
- switch (*s) {
- case 'c': /* FALLTHRU */
- case 'd': /* FALLTHRU */
- case 'o': /* FALLTHRU */
- case 'x': /* FALLTHRU */
- case 'X': /* FALLTHRU */
- case 's':
- *format++ = *s;
- done = TRUE;
- break;
- case '.':
- *format++ = *s++;
- dot = TRUE;
- break;
- case '#':
- *format++ = *s++;
- break;
- case ' ':
- *format++ = *s++;
- break;
- case ':':
- s++;
- allowminus = TRUE;
- break;
- case '-':
- if (allowminus) {
- *format++ = *s++;
- } else {
- done = TRUE;
- }
- break;
- default:
- if (isdigit(*s)) {
- if (dot)
- prec = (prec * 10) + (*s - '0');
- else
- width = (width * 10) + (*s - '0');
- *format++ = *s++;
- } else {
- done = TRUE;
- }
- }
+static inline const char *
+parse_format(const char *s, char *format, int *len)
+{
+ bool done = FALSE;
+ bool allowminus = FALSE;
+ bool dot = FALSE;
+ bool err = FALSE;
+ char *fmt = format;
+ int prec = 0;
+ int width = 0;
+ int value = 0;
+
+ *len = 0;
+ *format++ = '%';
+ while (*s != '\0' && !done) {
+ switch (*s) {
+ case 'c': /* FALLTHRU */
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 's':
+ *format++ = *s;
+ done = TRUE;
+ break;
+ case '.':
+ *format++ = *s++;
+ if (dot) {
+ err = TRUE;
+ } else {
+ dot = TRUE;
+ prec = value;
+ }
+ value = 0;
+ break;
+ case '#':
+ *format++ = *s++;
+ break;
+ case ' ':
+ *format++ = *s++;
+ break;
+ case ':':
+ s++;
+ allowminus = TRUE;
+ break;
+ case '-':
+ if (allowminus) {
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
+ break;
+ default:
+ if (isdigit(*s)) {
+ value = (value * 10) + (*s - '0');
+ if (value > 10000)
+ err = TRUE;
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
}
- *format = '\0';
- /* return maximum string length in print */
- *len = (prec > width) ? prec : width;
- return s;
+ }
+
+ /*
+ * If we found an error, ignore (and remove) the flags.
+ */
+ if (err) {
+ prec = width = value = 0;
+ format = fmt;
+ *format++ = '%';
+ *format++ = *s;
+ }
+
+ if (dot)
+ width = value;
+ else
+ prec = value;
+
+ *format = '\0';
+ /* return maximum string length in print */
+ *len = (prec > width) ? prec : width;
+ return s;
}
#define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
-static inline char *tparam_internal(const char *string, va_list ap)
+static inline char *
+tparam_internal(const char *string, va_list ap)
{
#define NUM_VARS 26
-int param[9];
-int popcount;
-int number;
-int len;
-int level;
-int x, y;
-int i;
-register const char *cp;
-static size_t len_fmt;
-static char *format;
-static int dynamic_var[NUM_VARS];
-static int static_vars[NUM_VARS];
-
- out_used = 0;
- if (string == NULL)
- return NULL;
-
- /*
- * Find the highest parameter-number referred to in the format string.
- * Use this value to limit the number of arguments copied from the
- * variable-length argument list.
- */
- for (cp = string, popcount = number = 0; *cp != '\0'; cp++) {
- if (cp[0] == '%' && cp[1] != '\0') {
- switch (cp[1]) {
- case '%':
- cp++;
- break;
- case 'i':
- if (popcount < 2)
- popcount = 2;
- break;
- case 'p':
- cp++;
- if (cp[1] >= '1' && cp[1] <= '9') {
- int c = cp[1] - '0';
- if (c > popcount)
- popcount = c;
- }
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'd': case 'c': case 's':
- ++number;
- break;
- }
+ char *p_is_s[9];
+ int param[9];
+ int lastpop;
+ int popcount;
+ int number;
+ int len;
+ int level;
+ int x, y;
+ int i;
+ size_t len2;
+ register const char *cp;
+ static size_t len_fmt;
+ static char dummy[] = "";
+ static char *format;
+ static int dynamic_var[NUM_VARS];
+ static int static_vars[NUM_VARS];
+
+ out_used = 0;
+ if (string == NULL)
+ return NULL;
+
+ if ((len2 = strlen(string)) > len_fmt) {
+ len_fmt = len2 + len_fmt + 2;
+ if ((format = typeRealloc(char, len_fmt, format)) == 0)
+ return 0;
+ }
+
+ /*
+ * Find the highest parameter-number referred to in the format string.
+ * Use this value to limit the number of arguments copied from the
+ * variable-length argument list.
+ */
+
+ number = 0;
+ lastpop = -1;
+ popcount = 0;
+ memset(p_is_s, 0, sizeof(p_is_s));
+
+ /*
+ * Analyze the string to see how many parameters we need from the varargs
+ * list, and what their types are. We will only accept string parameters
+ * if they appear as a %l or %s format following an explicit parameter
+ * reference (e.g., %p2%s). All other parameters are numbers.
+ *
+ * 'number' counts coarsely the number of pop's we see in the string, and
+ * 'popcount' shows the highest parameter number in the string. We would
+ * like to simply use the latter count, but if we are reading termcap
+ * strings, there may be cases that we cannot see the explicit parameter
+ * numbers.
+ */
+ for (cp = string; (cp - string) < (int) len2;) {
+ if (*cp == '%') {
+ cp++;
+ cp = parse_format(cp, format, &len);
+ switch (*cp) {
+ default:
+ break;
+
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 'c': /* FALLTHRU */
+ number++;
+ lastpop = -1;
+ break;
+
+ case 'l':
+ case 's':
+ if (lastpop > 0)
+ p_is_s[lastpop - 1] = dummy;
+ ++number;
+ break;
+
+ case 'p':
+ cp++;
+ i = (*cp - '0');
+ if (i >= 0 && i <= 9) {
+ lastpop = i;
+ if (lastpop > popcount)
+ popcount = lastpop;
}
+ break;
+
+ case 'P':
+ case 'g':
+ cp++;
+ break;
+
+ case S_QUOTE:
+ cp += 2;
+ lastpop = -1;
+ break;
+
+ case L_BRACE:
+ cp++;
+ while (*cp >= '0' && *cp <= '9') {
+ cp++;
+ }
+ break;
+
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case 'm':
+ case 'A':
+ case 'O':
+ case '&':
+ case '|':
+ case '^':
+ case '=':
+ case '<':
+ case '>':
+ case '!':
+ case '~':
+ lastpop = -1;
+ number += 2;
+ break;
+
+ case 'i':
+ lastpop = -1;
+ if (popcount < 2)
+ popcount = 2;
+ break;
+ }
}
- if ((size_t)(cp - string) > len_fmt) {
- len_fmt = (cp - string) + len_fmt + 2;
- if ((format = typeRealloc(char, len_fmt, format)) == 0)
- return 0;
- }
-
- if (number > 9) number = 9;
- for (i = 0; i < max(popcount, number); i++) {
- /*
- * FIXME: potential loss here if sizeof(int) != sizeof(char *).
- * A few caps (such as plab_norm) have string-valued parms.
- */
- param[i] = va_arg(ap, int);
- }
+ if (*cp != '\0')
+ cp++;
+ }
+ if (number > 9)
+ number = 9;
+ for (i = 0; i < max(popcount, number); i++) {
/*
- * This is a termcap compatibility hack. If there are no explicit pop
- * operations in the string, load the stack in such a way that
- * successive pops will grab successive parameters. That will make
- * the expansion of (for example) \E[%d;%dH work correctly in termcap
- * style, which means tparam() will expand termcap strings OK.
+ * A few caps (such as plab_norm) have string-valued parms.
+ * We'll have to assume that the caller knows the difference, since
+ * a char* and an int may not be the same size on the stack.
*/
- stack_ptr = 0;
- if (popcount == 0) {
- popcount = number;
- for (i = number - 1; i >= 0; i--)
- npush(param[i]);
+ if (p_is_s[i] != 0) {
+ p_is_s[i] = va_arg(ap, char *);
+ } else {
+ param[i] = va_arg(ap, int);
}
-
+ }
+
+ /*
+ * This is a termcap compatibility hack. If there are no explicit pop
+ * operations in the string, load the stack in such a way that
+ * successive pops will grab successive parameters. That will make
+ * the expansion of (for example) \E[%d;%dH work correctly in termcap
+ * style, which means tparam() will expand termcap strings OK.
+ */
+ stack_ptr = 0;
+ if (popcount == 0) {
+ popcount = number;
+ for (i = number - 1; i >= 0; i--)
+ npush(param[i]);
+ }
#ifdef TRACE
- if (_nc_tracing & TRACE_CALLS) {
- for (i = 0; i < popcount; i++)
- save_number(", %d", param[i], 0);
- _tracef(T_CALLED("%s(%s%s)"), tname, _nc_visbuf(string), out_buff);
- out_used = 0;
+ if (_nc_tracing & TRACE_CALLS) {
+ for (i = 0; i < popcount; i++) {
+ if (p_is_s[i] != 0)
+ save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
+ else
+ save_number(", %d", param[i], 0);
}
+ _tracef(T_CALLED("%s(%s%s)"), tname, _nc_visbuf(string), out_buff);
+ out_used = 0;
+ }
#endif /* TRACE */
- while (*string) {
- if (*string != '%') {
- save_char(*string);
- } else {
- string++;
- string = parse_format(string, format, &len);
- switch (*string) {
- default:
- break;
- case '%':
- save_char('%');
- break;
-
- case 'd': /* FALLTHRU */
- case 'o': /* FALLTHRU */
- case 'x': /* FALLTHRU */
- case 'X': /* FALLTHRU */
- case 'c':
- save_number(format, npop(), len);
- break;
-
- case 'l':
- save_number("%d", strlen(spop()), 0);
- break;
-
- case 's':
- save_text(format, spop(), len);
- break;
-
- case 'p':
- string++;
- if (*string >= '1' && *string <= '9')
- npush(param[*string - '1']);
- break;
-
- case 'P':
- string++;
- if (isUPPER(*string)) {
- i = (*string - 'A');
- static_vars[i] = npop();
- } else if (isLOWER(*string)) {
- i = (*string - 'a');
- dynamic_var[i] = npop();
- }
- break;
-
- case 'g':
- string++;
- if (isUPPER(*string)) {
- i = (*string - 'A');
- npush(static_vars[i]);
- } else if (isLOWER(*string)) {
- i = (*string - 'a');
- npush(dynamic_var[i]);
- }
- break;
-
- case S_QUOTE:
- string++;
- npush(*string);
- string++;
- break;
-
- case L_BRACE:
- number = 0;
- string++;
- while (*string >= '0' && *string <= '9') {
- number = number * 10 + *string - '0';
- string++;
- }
- npush(number);
- break;
-
- case '+':
- npush(npop() + npop());
- break;
-
- case '-':
- y = npop();
- x = npop();
- npush(x - y);
- break;
-
- case '*':
- npush(npop() * npop());
- break;
-
- case '/':
- y = npop();
- x = npop();
- npush(y ? (x / y) : 0);
- break;
-
- case 'm':
- y = npop();
- x = npop();
- npush(y ? (x % y) : 0);
- break;
-
- case 'A':
- npush(npop() && npop());
- break;
-
- case 'O':
- npush(npop() || npop());
- break;
-
- case '&':
- npush(npop() & npop());
- break;
-
- case '|':
- npush(npop() | npop());
- break;
-
- case '^':
- npush(npop() ^ npop());
- break;
-
- case '=':
- y = npop();
- x = npop();
- npush(x == y);
- break;
-
- case '<':
- y = npop();
- x = npop();
- npush(x < y);
- break;
+ while (*string) {
+ if (*string != '%') {
+ save_char(*string);
+ } else {
+ string++;
+ string = parse_format(string, format, &len);
+ switch (*string) {
+ default:
+ break;
+ case '%':
+ save_char('%');
+ break;
+
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 'c': /* FALLTHRU */
+ save_number(format, npop(), len);
+ break;
+
+ case 'l':
+ save_number("%d", strlen(spop()), 0);
+ break;
+
+ case 's':
+ save_text(format, spop(), len);
+ break;
+
+ case 'p':
+ string++;
+ i = (*string - '1');
+ if (i >= 0 && i < 9) {
+ if (p_is_s[i])
+ spush(p_is_s[i]);
+ else
+ npush(param[i]);
+ }
+ break;
- case '>':
- y = npop();
- x = npop();
- npush(x > y);
- break;
+ case 'P':
+ string++;
+ if (isUPPER(*string)) {
+ i = (*string - 'A');
+ static_vars[i] = npop();
+ } else if (isLOWER(*string)) {
+ i = (*string - 'a');
+ dynamic_var[i] = npop();
+ }
+ break;
- case '!':
- npush(! npop());
- break;
+ case 'g':
+ string++;
+ if (isUPPER(*string)) {
+ i = (*string - 'A');
+ npush(static_vars[i]);
+ } else if (isLOWER(*string)) {
+ i = (*string - 'a');
+ npush(dynamic_var[i]);
+ }
+ break;
- case '~':
- npush(~ npop());
- break;
+ case S_QUOTE:
+ string++;
+ npush(*string);
+ string++;
+ break;
- case 'i':
- param[0]++;
- param[1]++;
+ case L_BRACE:
+ number = 0;
+ string++;
+ while (*string >= '0' && *string <= '9') {
+ number = number * 10 + *string - '0';
+ string++;
+ }
+ npush(number);
+ break;
+
+ case '+':
+ npush(npop() + npop());
+ break;
+
+ case '-':
+ y = npop();
+ x = npop();
+ npush(x - y);
+ break;
+
+ case '*':
+ npush(npop() * npop());
+ break;
+
+ case '/':
+ y = npop();
+ x = npop();
+ npush(y ? (x / y) : 0);
+ break;
+
+ case 'm':
+ y = npop();
+ x = npop();
+ npush(y ? (x % y) : 0);
+ break;
+
+ case 'A':
+ npush(npop() && npop());
+ break;
+
+ case 'O':
+ npush(npop() || npop());
+ break;
+
+ case '&':
+ npush(npop() & npop());
+ break;
+
+ case '|':
+ npush(npop() | npop());
+ break;
+
+ case '^':
+ npush(npop() ^ npop());
+ break;
+
+ case '=':
+ y = npop();
+ x = npop();
+ npush(x == y);
+ break;
+
+ case '<':
+ y = npop();
+ x = npop();
+ npush(x < y);
+ break;
+
+ case '>':
+ y = npop();
+ x = npop();
+ npush(x > y);
+ break;
+
+ case '!':
+ npush(!npop());
+ break;
+
+ case '~':
+ npush(~npop());
+ break;
+
+ case 'i':
+ if (p_is_s[0] == 0)
+ param[0]++;
+ if (p_is_s[1] == 0)
+ param[1]++;
+ break;
+
+ case '?':
+ break;
+
+ case 't':
+ x = npop();
+ if (!x) {
+ /* scan forward for %e or %; at level zero */
+ string++;
+ level = 0;
+ while (*string) {
+ if (*string == '%') {
+ string++;
+ if (*string == '?')
+ level++;
+ else if (*string == ';') {
+ if (level > 0)
+ level--;
+ else
+ break;
+ } else if (*string == 'e' && level == 0)
break;
+ }
- case '?':
- break;
+ if (*string)
+ string++;
+ }
+ }
+ break;
- case 't':
- x = npop();
- if (!x) {
- /* scan forward for %e or %; at level zero */
- string++;
- level = 0;
- while (*string) {
- if (*string == '%') {
- string++;
- if (*string == '?')
- level++;
- else if (*string == ';') {
- if (level > 0)
- level--;
- else
- break;
- }
- else if (*string == 'e' && level == 0)
- break;
- }
-
- if (*string)
- string++;
- }
- }
+ case 'e':
+ /* scan forward for a %; at level zero */
+ string++;
+ level = 0;
+ while (*string) {
+ if (*string == '%') {
+ string++;
+ if (*string == '?')
+ level++;
+ else if (*string == ';') {
+ if (level > 0)
+ level--;
+ else
break;
+ }
+ }
- case 'e':
- /* scan forward for a %; at level zero */
- string++;
- level = 0;
- while (*string) {
- if (*string == '%') {
- string++;
- if (*string == '?')
- level++;
- else if (*string == ';') {
- if (level > 0)
- level--;
- else
- break;
- }
- }
-
- if (*string)
- string++;
- }
- break;
+ if (*string)
+ string++;
+ }
+ break;
- case ';':
- break;
+ case ';':
+ break;
- } /* endswitch (*string) */
- } /* endelse (*string == '%') */
+ } /* endswitch (*string) */
+ } /* endelse (*string == '%') */
- if (*string == '\0')
- break;
+ if (*string == '\0')
+ break;
- string++;
- } /* endwhile (*string) */
+ string++;
+ } /* endwhile (*string) */
- if (out_buff == 0 && (out_buff = typeCalloc(char,1)) == NULL)
- return(NULL);
- out_buff[out_used] = '\0';
+ if (out_buff == 0 && (out_buff = typeCalloc(char, 1)) == NULL)
+ return (NULL);
+ out_buff[out_used] = '\0';
- T((T_RETURN("%s"), _nc_visbuf(out_buff)));
- return(out_buff);
+ T((T_RETURN("%s"), _nc_visbuf(out_buff)));
+ return (out_buff);
}
-char *tparm(NCURSES_CONST char *string, ...)
+char *
+tparm(NCURSES_CONST char *string,...)
{
-va_list ap;
-char *result;
+ va_list ap;
+ char *result;
- va_start(ap, string);
+ va_start(ap, string);
#ifdef TRACE
- tname = "tparm";
+ tname = "tparm";
#endif /* TRACE */
- result = tparam_internal(string, ap);
- va_end(ap);
- return result;
+ result = tparam_internal(string, ap);
+ va_end(ap);
+ return result;
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
index f17d8382e921..93eebf88691f 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
@@ -45,10 +45,10 @@
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$Id: lib_tputs.c,v 1.47 2000/05/27 23:08:41 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.51 2000/10/08 00:22:24 tom Exp $")
char PC = 0; /* used by termcap library */
-speed_t ospeed = 0; /* used by termcap library */
+short ospeed = 0; /* used by termcap library */
int _nc_nulls_sent = 0; /* used by 'tack' program */
@@ -78,7 +78,7 @@ delay_output(int ms)
void
_nc_flush(void)
{
- (void)fflush(NC_OUTPUT);
+ (void) fflush(NC_OUTPUT);
}
int
@@ -102,7 +102,7 @@ _nc_outch(int ch)
return OK;
}
-#ifdef USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT
/*
* Reference: The Unicode Standard 2.0
*
@@ -120,20 +120,20 @@ _nc_utf8_outch(int ch)
int result[7], *ptr;
int count = 0;
- if (ch < 0x80)
+ if ((unsigned int) ch < 0x80)
count = 1;
- else if (ch < 0x800)
+ else if ((unsigned int) ch < 0x800)
count = 2;
- else if (ch < 0x10000)
+ else if ((unsigned int) ch < 0x10000)
count = 3;
- else if (ch < 0x200000)
+ else if ((unsigned int) ch < 0x200000)
count = 4;
- else if (ch < 0x4000000)
+ else if ((unsigned int) ch < 0x4000000)
count = 5;
- else if (ch <= 0x7FFFFFFF)
+ else if ((unsigned int) ch <= 0x7FFFFFFF)
count = 6;
else {
- count = 2;
+ count = 3;
ch = 0xFFFD;
}
ptr = result + count;
@@ -141,20 +141,26 @@ _nc_utf8_outch(int ch)
case 6:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 5:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 4:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 3:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 2:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 1:
*--ptr = (ch | firstMark[count]);
+ break;
}
while (count--)
_nc_outch(*ptr++);
@@ -174,7 +180,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
bool always_delay;
bool normal_delay;
int number;
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
int trailpad;
#endif /* BSD_TPUTS */
@@ -188,7 +194,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
(void) sprintf(addrbuf, "%p", outc);
if (_nc_tputs_trace) {
_tracef("tputs(%s = %s, %d, %s) called", _nc_tputs_trace,
- _nc_visbuf(string), affcnt, addrbuf);
+ _nc_visbuf(string), affcnt, addrbuf);
} else {
_tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf);
}
@@ -207,13 +213,13 @@ tputs(const char *string, int affcnt, int (*outc) (int))
normal_delay =
!xon_xoff
&& padding_baud_rate
-#ifdef NCURSES_NO_PADDING
+#if NCURSES_NO_PADDING
&& (SP == 0 || !(SP->_no_padding))
#endif
&& (_nc_baudrate(ospeed) >= padding_baud_rate);
}
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
/*
* This ugly kluge deals with the fact that some ancient BSD programs
* (like nethack) actually do the likes of tputs("50") to get delays.
@@ -304,7 +310,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
string++;
}
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
/*
* Emit any BSD-style prefix padding that we've accumulated now.
*/
diff --git a/contrib/ncurses/ncurses/tinfo/parse_entry.c b/contrib/ncurses/ncurses/tinfo/parse_entry.c
index 1aff562d0dd6..24bf3c37f584 100644
--- a/contrib/ncurses/ncurses/tinfo/parse_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/parse_entry.c
@@ -47,7 +47,7 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$Id: parse_entry.c,v 1.44 2000/04/30 00:17:42 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.48 2000/10/03 09:38:48 tom Exp $")
#ifdef LINT
static short const parametrized[] =
@@ -200,7 +200,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
{
int token_type;
struct name_table_entry const *entry_ptr;
- char *ptr, namecpy[MAX_NAME_SIZE + 1];
+ char *ptr, *base;
token_type = _nc_get_token();
@@ -235,22 +235,22 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
_nc_set_type(_nc_first_name(entryp->tterm.term_names));
/* check for overly-long names and aliases */
- (void) strncpy(namecpy, entryp->tterm.term_names, MAX_NAME_SIZE);
- namecpy[MAX_NAME_SIZE] = '\0';
- if ((ptr = strrchr(namecpy, '|')) != (char *) 0)
- *ptr = '\0';
- ptr = strtok(namecpy, "|");
- if (strlen(ptr) > MAX_ALIAS)
- _nc_warning("primary name may be too long");
- while ((ptr = strtok((char *) 0, "|")) != (char *) 0)
- if (strlen(ptr) > MAX_ALIAS)
- _nc_warning("alias `%s' may be too long", ptr);
+ for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != 0;
+ base = ptr + 1) {
+ if (ptr - base > MAX_ALIAS) {
+ _nc_warning("%s `%.*s' may be too long",
+ (base == entryp->tterm.term_names)
+ ? "primary name"
+ : "alias",
+ ptr - base, base);
+ }
+ }
entryp->nuses = 0;
for (token_type = _nc_get_token();
- token_type != EOF && token_type != NAMES;
- token_type = _nc_get_token()) {
+ token_type != EOF && token_type != NAMES;
+ token_type = _nc_get_token()) {
if (strcmp(_nc_curr_token.tk_name, "use") == 0
|| strcmp(_nc_curr_token.tk_name, "tc") == 0) {
entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
@@ -259,7 +259,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
} else {
/* normal token lookup */
entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
- _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
+ _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
/*
* Our kluge to handle aliasing. The reason it's done
@@ -277,14 +277,14 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s termcap extension) ignored",
- ap->from, ap->source);
+ ap->from, ap->source);
goto nexttok;
}
entry_ptr = _nc_find_entry(ap->to, _nc_cap_hash_table);
if (entry_ptr && !silent)
_nc_warning("%s (%s termcap extension) aliased to %s",
- ap->from, ap->source, ap->to);
+ ap->from, ap->source, ap->to);
break;
}
} else { /* if (_nc_syntax == SYN_TERMINFO) */
@@ -292,14 +292,14 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s terminfo extension) ignored",
- ap->from, ap->source);
+ ap->from, ap->source);
goto nexttok;
}
entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
if (entry_ptr && !silent)
_nc_warning("%s (%s terminfo extension) aliased to %s",
- ap->from, ap->source, ap->to);
+ ap->from, ap->source, ap->to);
break;
}
@@ -316,7 +316,8 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (entry_ptr == NOTFOUND
&& _nc_user_definable
&& (entry_ptr = _nc_extend_names(entryp,
- _nc_curr_token.tk_name, token_type)) != 0) {
+ _nc_curr_token.tk_name,
+ token_type)) != 0) {
if (_nc_tracing >= DEBUG_LEVEL(1))
_nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
}
@@ -326,7 +327,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (entry_ptr == NOTFOUND) {
if (!silent)
_nc_warning("unknown capability '%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
continue;
}
@@ -345,12 +346,14 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
/* tell max_attributes from arrow_key_map */
if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name))
entry_ptr = _nc_find_type_entry("ma", NUMBER,
- _nc_get_table(_nc_syntax != 0));
+ _nc_get_table(_nc_syntax
+ != 0));
/* map terminfo's string MT to MT */
else if (token_type == STRING && !strcmp("MT", _nc_curr_token.tk_name))
entry_ptr = _nc_find_type_entry("MT", STRING,
- _nc_get_table(_nc_syntax != 0));
+ _nc_get_table(_nc_syntax
+ != 0));
/* treat strings without following "=" as empty strings */
else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING)
@@ -374,7 +377,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
break;
}
_nc_warning("wrong type used for %s capability '%s'",
- type_name, _nc_curr_token.tk_name);
+ type_name, _nc_curr_token.tk_name);
}
continue;
}
@@ -411,8 +414,8 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
ptr = _nc_curr_token.tk_valstring;
if (_nc_syntax == SYN_TERMCAP)
ptr = _nc_captoinfo(_nc_curr_token.tk_name,
- ptr,
- parametrized[entry_ptr->nte_index]);
+ ptr,
+ parametrized[entry_ptr->nte_index]);
entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr);
break;
@@ -479,14 +482,14 @@ _nc_capcmp(const char *s, const char *t)
if (s[0] == '$' && s[1] == '<') {
for (s += 2;; s++)
if (!(isdigit(*s) || *s == '.' || *s == '*' || *s == '/' ||
- *s == '>'))
+ *s == '>'))
break;
}
if (t[0] == '$' && t[1] == '<') {
for (t += 2;; t++)
if (!(isdigit(*t) || *t == '.' || *t == '*' || *t == '/' ||
- *t == '>'))
+ *t == '>'))
break;
}
@@ -503,6 +506,26 @@ _nc_capcmp(const char *s, const char *t)
}
}
+static void
+append_acs0(string_desc *dst, int code, int src)
+{
+ if (src != 0) {
+ char temp[3];
+ temp[0] = code;
+ temp[1] = src;
+ temp[2] = 0;
+ _nc_safe_strcat(dst, temp);
+ }
+}
+
+static void
+append_acs(string_desc *dst, int code, char *src)
+{
+ if (src != 0 && strlen(src) == 1) {
+ append_acs0(dst, code, *src);
+ }
+}
+
/*
* The ko capability, if present, consists of a comma-separated capability
* list. For each capability, we may assume there is a keycap that sends the
@@ -563,11 +586,11 @@ static const char C_HT[] = "\t";
#undef CUR
#define CUR tp->
-static
-void
+static void
postprocess_termcap(TERMTYPE * tp, bool has_base)
{
char buf[MAX_LINE * 2 + 2];
+ string_desc result;
/*
* TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS
@@ -632,17 +655,15 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
} else
newline = _nc_save_str(C_LF);
} else if (PRESENT(carriage_return) && PRESENT(scroll_forward)) {
- strncpy(buf, carriage_return, MAX_LINE - 2);
- buf[MAX_LINE - 1] = '\0';
- strncat(buf, scroll_forward, MAX_LINE - strlen(buf) - 1);
- buf[MAX_LINE] = '\0';
- newline = _nc_save_str(buf);
+ _nc_str_init(&result, buf, sizeof(buf));
+ if (_nc_safe_strcat(&result, carriage_return)
+ && _nc_safe_strcat(&result, scroll_forward))
+ newline = _nc_save_str(buf);
} else if (PRESENT(carriage_return) && PRESENT(cursor_down)) {
- strncpy(buf, carriage_return, MAX_LINE - 2);
- buf[MAX_LINE - 1] = '\0';
- strncat(buf, cursor_down, MAX_LINE - strlen(buf) - 1);
- buf[MAX_LINE] = '\0';
- newline = _nc_save_str(buf);
+ _nc_str_init(&result, buf, sizeof(buf));
+ if (_nc_safe_strcat(&result, carriage_return)
+ && _nc_safe_strcat(&result, cursor_down))
+ newline = _nc_save_str(buf);
}
}
}
@@ -695,7 +716,7 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
else {
if (tab && _nc_capcmp(tab, C_HT))
_nc_warning("hardware tabs with a non-^I tab string %s",
- _nc_visbuf(tab));
+ _nc_visbuf(tab));
else {
if (WANTED(tab))
tab = _nc_save_str(C_HT);
@@ -708,7 +729,8 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
* isn't from mytinfo...
*/
if (PRESENT(other_non_function_keys)) {
- char *dp, *cp = strtok(other_non_function_keys, ",");
+ char *base = other_non_function_keys;
+ char *bp, *cp, *dp;
struct name_table_entry const *from_ptr;
struct name_table_entry const *to_ptr;
assoc const *ap;
@@ -717,15 +739,21 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
/* we're going to use this for a special case later */
dp = strchr(other_non_function_keys, 'i');
- foundim = dp && dp[1] == 'm';
+ foundim = (dp != 0) && (dp[1] == 'm');
/* look at each comma-separated capability in the ko string... */
- do {
+ for (base = other_non_function_keys;
+ (cp = strchr(base, ',')) != 0;
+ base = cp + 1) {
+ size_t len = cp - base;
+
for (ap = ko_xlate; ap->from; ap++)
- if (strcmp(ap->from, cp) == 0)
+ if (len == strlen(ap->from)
+ && strncmp(ap->from, base, len) == 0)
break;
if (!ap->to) {
- _nc_warning("unknown capability `%s' in ko string", cp);
+ _nc_warning("unknown capability `%.*s' in ko string",
+ (int) len, base);
continue;
} else if (ap->to == CANCELLED_STRING) /* ignore it */
continue;
@@ -748,11 +776,11 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
* string; that's just an inefficiency.
*/
if (strcmp(
- tp->Strings[from_ptr->nte_index],
- tp->Strings[to_ptr->nte_index]) != 0)
+ tp->Strings[from_ptr->nte_index],
+ tp->Strings[to_ptr->nte_index]) != 0)
_nc_warning("%s (%s) already has an explicit value %s, ignoring ko",
- ap->to, ap->from,
- _nc_visbuf(tp->Strings[to_ptr->nte_index]));
+ ap->to, ap->from,
+ _nc_visbuf(tp->Strings[to_ptr->nte_index]));
continue;
}
@@ -760,22 +788,18 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
* The magic moment -- copy the mapped key string over,
* stripping out padding.
*/
- dp = buf2;
- for (cp = tp->Strings[from_ptr->nte_index]; *cp; cp++) {
- if (cp[0] == '$' && cp[1] == '<') {
- while (*cp && *cp != '>')
- if (!*cp)
- break;
- else
- ++cp;
+ for (dp = buf2, bp = tp->Strings[from_ptr->nte_index]; *bp; bp++) {
+ if (bp[0] == '$' && bp[1] == '<') {
+ while (*bp && *bp != '>') {
+ ++bp;
+ }
} else
- *dp++ = *cp;
+ *dp++ = *bp;
}
*dp++ = '\0';
tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
- } while
- ((cp = strtok((char *) 0, ",")) != 0);
+ }
/*
* Note: ko=im and ko=ic both want to grab the `Insert'
@@ -812,74 +836,36 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
PRESENT(acs_hline) ||
PRESENT(acs_vline) ||
PRESENT(acs_plus)) {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
-
- if (acs_chars) {
- (void) strcpy(bp, acs_chars);
- bp += strlen(bp);
- }
-
- if (acs_ulcorner && acs_ulcorner[1] == '\0') {
- *bp++ = 'l';
- *bp++ = *acs_ulcorner;
- }
- if (acs_llcorner && acs_llcorner[1] == '\0') {
- *bp++ = 'm';
- *bp++ = *acs_llcorner;
- }
- if (acs_urcorner && acs_urcorner[1] == '\0') {
- *bp++ = 'k';
- *bp++ = *acs_urcorner;
- }
- if (acs_lrcorner && acs_lrcorner[1] == '\0') {
- *bp++ = 'j';
- *bp++ = *acs_lrcorner;
- }
- if (acs_ltee && acs_ltee[1] == '\0') {
- *bp++ = 't';
- *bp++ = *acs_ltee;
- }
- if (acs_rtee && acs_rtee[1] == '\0') {
- *bp++ = 'u';
- *bp++ = *acs_rtee;
- }
- if (acs_btee && acs_btee[1] == '\0') {
- *bp++ = 'v';
- *bp++ = *acs_btee;
- }
- if (acs_ttee && acs_ttee[1] == '\0') {
- *bp++ = 'w';
- *bp++ = *acs_ttee;
- }
- if (acs_hline && acs_hline[1] == '\0') {
- *bp++ = 'q';
- *bp++ = *acs_hline;
- }
- if (acs_vline && acs_vline[1] == '\0') {
- *bp++ = 'x';
- *bp++ = *acs_vline;
- }
- if (acs_plus) {
- *bp++ = 'n';
- strcpy(bp, acs_plus);
- bp = buf2 + strlen(buf2);
- }
-
- if (bp != buf2) {
- *bp++ = '\0';
+ char buf2[MAX_TERMCAP_LENGTH];
+
+ _nc_str_init(&result, buf2, sizeof(buf2));
+ _nc_safe_strcat(&result, acs_chars);
+
+ append_acs (&result, 'j', acs_lrcorner);
+ append_acs (&result, 'k', acs_urcorner);
+ append_acs (&result, 'l', acs_ulcorner);
+ append_acs (&result, 'm', acs_llcorner);
+ append_acs (&result, 'n', acs_plus);
+ append_acs (&result, 'q', acs_hline);
+ append_acs (&result, 't', acs_ltee);
+ append_acs (&result, 'u', acs_rtee);
+ append_acs (&result, 'v', acs_btee);
+ append_acs (&result, 'w', acs_ttee);
+ append_acs (&result, 'x', acs_vline);
+
+ if (buf2[0]) {
acs_chars = _nc_save_str(buf2);
_nc_warning("acsc string synthesized from XENIX capabilities");
}
} else if (acs_chars == 0
- && enter_alt_charset_mode != 0
- && exit_alt_charset_mode != 0) {
+ && enter_alt_charset_mode != 0
+ && exit_alt_charset_mode != 0) {
acs_chars =
_nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
}
}
-static
-void
+static void
postprocess_terminfo(TERMTYPE * tp)
{
/*
@@ -891,60 +877,25 @@ postprocess_terminfo(TERMTYPE * tp)
* Translate AIX forms characters.
*/
if (PRESENT(box_chars_1)) {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
-
- if (acs_chars) {
- (void) strcpy(bp, acs_chars);
- bp += strlen(bp);
- }
-
- if (box_chars_1[0]) { /* ACS_ULCORNER */
- *bp++ = 'l';
- *bp++ = box_chars_1[0];
- }
- if (box_chars_1[1]) { /* ACS_HLINE */
- *bp++ = 'q';
- *bp++ = box_chars_1[1];
- }
- if (box_chars_1[2]) { /* ACS_URCORNER */
- *bp++ = 'k';
- *bp++ = box_chars_1[2];
- }
- if (box_chars_1[3]) { /* ACS_VLINE */
- *bp++ = 'x';
- *bp++ = box_chars_1[3];
- }
- if (box_chars_1[4]) { /* ACS_LRCORNER */
- *bp++ = 'j';
- *bp++ = box_chars_1[4];
- }
- if (box_chars_1[5]) { /* ACS_LLCORNER */
- *bp++ = 'm';
- *bp++ = box_chars_1[5];
- }
- if (box_chars_1[6]) { /* ACS_TTEE */
- *bp++ = 'w';
- *bp++ = box_chars_1[6];
- }
- if (box_chars_1[7]) { /* ACS_RTEE */
- *bp++ = 'u';
- *bp++ = box_chars_1[7];
- }
- if (box_chars_1[8]) { /* ACS_BTEE */
- *bp++ = 'v';
- *bp++ = box_chars_1[8];
- }
- if (box_chars_1[9]) { /* ACS_LTEE */
- *bp++ = 't';
- *bp++ = box_chars_1[9];
- }
- if (box_chars_1[10]) { /* ACS_PLUS */
- *bp++ = 'n';
- *bp++ = box_chars_1[10];
- }
-
- if (bp != buf2) {
- *bp++ = '\0';
+ char buf2[MAX_TERMCAP_LENGTH];
+ string_desc result;
+
+ _nc_str_init(&result, buf2, sizeof(buf2));
+ _nc_safe_strcat(&result, acs_chars);
+
+ append_acs0 (&result, 'l', box_chars_1[0]); /* ACS_ULCORNER */
+ append_acs0 (&result, 'q', box_chars_1[1]); /* ACS_HLINE */
+ append_acs0 (&result, 'k', box_chars_1[2]); /* ACS_URCORNER */
+ append_acs0 (&result, 'x', box_chars_1[3]); /* ACS_VLINE */
+ append_acs0 (&result, 'j', box_chars_1[4]); /* ACS_LRCORNER */
+ append_acs0 (&result, 'm', box_chars_1[5]); /* ACS_LLCORNER */
+ append_acs0 (&result, 'w', box_chars_1[6]); /* ACS_TTEE */
+ append_acs0 (&result, 'u', box_chars_1[7]); /* ACS_RTEE */
+ append_acs0 (&result, 'v', box_chars_1[8]); /* ACS_BTEE */
+ append_acs0 (&result, 't', box_chars_1[9]); /* ACS_LTEE */
+ append_acs0 (&result, 'n', box_chars_1[10]); /* ACS_PLUS */
+
+ if (buf2[0]) {
acs_chars = _nc_save_str(buf2);
_nc_warning("acsc string synthesized from AIX capabilities");
box_chars_1 = ABSENT_STRING;
@@ -963,8 +914,7 @@ postprocess_terminfo(TERMTYPE * tp)
* up in _nc_info_table, which is organized so that the nte_index fields are
* sorted, but the nte_type fields are not necessarily grouped together.
*/
-static
-struct name_table_entry const *
+static struct name_table_entry const *
lookup_fullname(const char *find)
{
int state = -1;
@@ -991,7 +941,7 @@ lookup_fullname(const char *find)
if (!strcmp(names[count], find)) {
struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
while (entry_ptr->nte_type != state
- || entry_ptr->nte_index != count)
+ || entry_ptr->nte_index != count)
entry_ptr++;
return entry_ptr;
}
diff --git a/contrib/ncurses/ncurses/tinfo/read_entry.c b/contrib/ncurses/ncurses/tinfo/read_entry.c
index 85dc3e0bf6e9..deef49859a3e 100644
--- a/contrib/ncurses/ncurses/tinfo/read_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/read_entry.c
@@ -41,7 +41,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: read_entry.c,v 1.67 2000/03/11 12:35:45 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.69 2000/10/10 00:57:40 Todd.Miller Exp $")
#if !HAVE_TELL
#define tell(fd) 0 /* lseek() is POSIX, but not tell() - odd... */
@@ -79,7 +79,7 @@ _nc_tic_dir(const char *path)
if (path != 0) {
result = path;
have_tic_directory = TRUE;
- } else if (!have_tic_directory) {
+ } else if (!have_tic_directory && use_terminfo_vars()) {
char *envp;
if ((envp = getenv("TERMINFO")) != 0)
return _nc_tic_dir(envp);
@@ -176,9 +176,9 @@ read_termtype(int fd, TERMTYPE * ptr)
str_size = LOW_MSB(buf + 10);
TR(TRACE_DATABASE,
- ("TERMTYPE name_size=%d, bool=%d/%d, num=%d/%d str=%d/%d(%d)",
- name_size, bool_count, BOOLCOUNT, num_count, NUMCOUNT,
- str_count, STRCOUNT, str_size));
+ ("TERMTYPE name_size=%d, bool=%d/%d, num=%d/%d str=%d/%d(%d)",
+ name_size, bool_count, BOOLCOUNT, num_count, NUMCOUNT,
+ str_count, STRCOUNT, str_size));
if (name_size < 0
|| bool_count < 0
|| num_count < 0
@@ -281,19 +281,20 @@ read_termtype(int fd, TERMTYPE * ptr)
ptr->Strings = typeRealloc(char *, ptr->num_Strings, ptr->Strings);
TR(TRACE_DATABASE, ("extended header is %d/%d/%d(%d:%d)",
- ext_bool_count, ext_num_count, ext_str_count, ext_str_size, ext_str_limit));
+ ext_bool_count, ext_num_count, ext_str_count,
+ ext_str_size, ext_str_limit));
TR(TRACE_DATABASE, ("READ %d extended-booleans @%d",
- ext_bool_count, tell(fd)));
+ ext_bool_count, tell(fd)));
if ((ptr->ext_Booleans = ext_bool_count) != 0) {
if (read(fd, ptr->Booleans + BOOLCOUNT, (unsigned)
- ext_bool_count) != ext_bool_count)
+ ext_bool_count) != ext_bool_count)
return (0);
}
even_boundary(ext_bool_count);
TR(TRACE_DATABASE, ("READ %d extended-numbers @%d",
- ext_num_count, tell(fd)));
+ ext_num_count, tell(fd)));
if ((ptr->ext_Numbers = ext_num_count) != 0) {
if (!read_shorts(fd, buf, ext_num_count))
return (0);
@@ -307,7 +308,7 @@ read_termtype(int fd, TERMTYPE * ptr)
return (0);
TR(TRACE_DATABASE, ("READ %d bytes of extended-strings @%d",
- ext_str_limit, tell(fd)));
+ ext_str_limit, tell(fd)));
if (ext_str_limit) {
if ((ptr->ext_str_table = typeMalloc(char, ext_str_limit)) == 0)
@@ -319,20 +320,20 @@ read_termtype(int fd, TERMTYPE * ptr)
if ((ptr->ext_Strings = ext_str_count) != 0) {
TR(TRACE_DATABASE,
- ("Before computing extended-string capabilities str_count=%d, ext_str_count=%d",
- str_count, ext_str_count));
+ ("Before computing extended-string capabilities str_count=%d, ext_str_count=%d",
+ str_count, ext_str_count));
convert_strings(buf, ptr->Strings + str_count, ext_str_count,
- ext_str_limit, ptr->ext_str_table);
+ ext_str_limit, ptr->ext_str_table);
for (i = ext_str_count - 1; i >= 0; i--) {
TR(TRACE_DATABASE, ("MOVE from [%d:%d] %s",
- i, i + str_count,
- _nc_visbuf(ptr->Strings[i + str_count])));
+ i, i + str_count,
+ _nc_visbuf(ptr->Strings[i + str_count])));
ptr->Strings[i + STRCOUNT] = ptr->Strings[i + str_count];
if (VALID_STRING(ptr->Strings[i + STRCOUNT]))
base += (strlen(ptr->Strings[i + STRCOUNT]) + 1);
TR(TRACE_DATABASE, ("... to [%d] %s",
- i + STRCOUNT,
- _nc_visbuf(ptr->Strings[i + STRCOUNT])));
+ i + STRCOUNT,
+ _nc_visbuf(ptr->Strings[i + STRCOUNT])));
}
}
@@ -340,23 +341,23 @@ read_termtype(int fd, TERMTYPE * ptr)
if ((ptr->ext_Names = typeCalloc(char *, need)) == 0)
return (0);
TR(TRACE_DATABASE,
- ("ext_NAMES starting @%d in extended_strings, first = %s",
- base, _nc_visbuf(ptr->ext_str_table + base)));
+ ("ext_NAMES starting @%d in extended_strings, first = %s",
+ base, _nc_visbuf(ptr->ext_str_table + base)));
convert_strings(buf + (2 * ext_str_count), ptr->ext_Names, need,
- ext_str_limit, ptr->ext_str_table + base);
+ ext_str_limit, ptr->ext_str_table + base);
}
T(("...done reading terminfo bool %d(%d) num %d(%d) str %d(%d)",
- ptr->num_Booleans, ptr->ext_Booleans,
- ptr->num_Numbers, ptr->ext_Numbers,
- ptr->num_Strings, ptr->ext_Strings));
+ ptr->num_Booleans, ptr->ext_Booleans,
+ ptr->num_Numbers, ptr->ext_Numbers,
+ ptr->num_Strings, ptr->ext_Strings));
TR(TRACE_DATABASE, ("extend: num_Booleans:%d", ptr->num_Booleans));
} else
#endif /* NCURSES_XNAMES */
{
T(("...done reading terminfo bool %d num %d str %d",
- bool_count, num_count, str_count));
+ bool_count, num_count, str_count));
#if NCURSES_XNAMES
TR(TRACE_DATABASE, ("normal: num_Booleans:%d", ptr->num_Booleans));
#endif
@@ -398,7 +399,7 @@ _nc_read_file_entry(const char *const filename, TERMTYPE * ptr)
*/
static int
_nc_read_tic_entry(char *const filename,
- const char *const dir, const char *ttn, TERMTYPE * const tp)
+ const char *const dir, const char *ttn, TERMTYPE * const tp)
{
/* maximum safe length of terminfo root directory name */
#define MAX_TPATH (PATH_MAX - MAX_ALIAS - 6)
@@ -415,7 +416,7 @@ _nc_read_tic_entry(char *const filename,
*/
static int
_nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const
- ttn, TERMTYPE * const tp)
+ ttn, TERMTYPE * const tp)
{
char *list, *a;
const char *b;
@@ -471,19 +472,22 @@ _nc_read_entry(const char *const tn, char *const filename, TERMTYPE * const tp)
&& _nc_read_tic_entry(filename, _nc_tic_dir(0), ttn, tp) == 1)
return 1;
- if ((envp = getenv("TERMINFO")) != 0
- && _nc_read_tic_entry(filename, _nc_tic_dir(envp), ttn, tp) == 1)
- return 1;
+ if (use_terminfo_vars()) {
+ if ((envp = getenv("TERMINFO")) != 0
+ && _nc_read_tic_entry(filename, _nc_tic_dir(envp), ttn, tp) == 1)
+ return 1;
- if ((envp = _nc_home_terminfo()) != 0) {
- if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
- return (1);
+ /* this is an ncurses extension */
+ if ((envp = _nc_home_terminfo()) != 0) {
+ if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
+ return (1);
+ }
}
- }
- /* this is an ncurses extension */
- if ((envp = getenv("TERMINFO_DIRS")) != 0)
- return _nc_read_terminfo_dirs(envp, filename, ttn, tp);
+ /* this is an ncurses extension */
+ if ((envp = getenv("TERMINFO_DIRS")) != 0)
+ return _nc_read_terminfo_dirs(envp, filename, ttn, tp);
+ }
/* Try the system directory. Note that the TERMINFO_DIRS value, if
* defined by the configure script, begins with a ":", which will be
diff --git a/contrib/ncurses/ncurses/tinfo/read_termcap.c b/contrib/ncurses/ncurses/tinfo/read_termcap.c
index 26e72d403263..f74c5a1eb760 100644
--- a/contrib/ncurses/ncurses/tinfo/read_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/read_termcap.c
@@ -55,9 +55,9 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: read_termcap.c,v 1.47 2000/04/15 16:53:19 Todd.C.Miller Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.50 2000/10/10 00:56:46 Todd.Miller Exp $")
-#ifndef PURE_TERMINFO
+#if !PURE_TERMINFO
#ifdef __EMX__
#define is_pathname(s) ((((s) != 0) && ((s)[0] == '/')) \
@@ -81,7 +81,8 @@ MODULE_ID("$Id: read_termcap.c,v 1.47 2000/04/15 16:53:19 Todd.C.Miller Exp $")
#define _nc_cgetset cgetset
#else
static int _nc_cgetmatch(char *, const char *);
-static int _nc_getent(char **, unsigned *, int *, int, char **, int, const char *, int, char *);
+static int _nc_getent(char **, unsigned *, int *, int, char **, int, const char
+ *, int, char *);
static int _nc_nfcmp(const char *, char *);
/*-
@@ -257,15 +258,15 @@ _nc_cgetent(char **buf, int *oline, char **db_array, const char *name)
#define DOALLOC(size) typeRealloc(char, size, record)
static int
_nc_getent(
- char **cap, /* termcap-content */
- unsigned *len, /* length, needed for recursion */
- int *beginning, /* line-number at match */
- int in_array, /* index in 'db_array[] */
- char **db_array, /* list of files to search */
- int fd,
- const char *name,
- int depth,
- char *nfield)
+ char **cap, /* termcap-content */
+ unsigned *len, /* length, needed for recursion */
+ int *beginning, /* line-number at match */
+ int in_array, /* index in 'db_array[] */
+ char **db_array, /* list of files to search */
+ int fd,
+ const char *name,
+ int depth,
+ char *nfield)
{
register char *r_end, *rp;
int myfd = FALSE;
@@ -318,7 +319,7 @@ _nc_getent(
if (fd >= 0) {
(void) lseek(fd, (off_t) 0, SEEK_SET);
} else if ((_nc_access(db_array[current], R_OK) < 0)
- || (fd = open(db_array[current], O_RDONLY, 0)) < 0) {
+ || (fd = open(db_array[current], O_RDONLY, 0)) < 0) {
/* No error on unfound file. */
if (errno == ENOENT)
continue;
@@ -481,7 +482,7 @@ _nc_getent(
tcend = s;
iret = _nc_getent(&icap, &ilen, &oline, current, db_array, fd,
- tc, depth + 1, 0);
+ tc, depth + 1, 0);
newicap = icap; /* Put into a register. */
newilen = ilen;
if (iret != TC_SUCCESS) {
@@ -777,12 +778,13 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
char **pvec; /* holds usable tail of path vector */
char *termpath;
+ string_desc desc;
fname = pathvec;
pvec = pathvec;
tbuf = bp;
p = pathbuf;
- cp = getenv("TERMCAP");
+ cp = use_terminfo_vars() ? getenv("TERMCAP") : NULL;
/*
* TERMCAP can have one of two things in it. It can be the name of a file
@@ -793,22 +795,29 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
* instead. The path is found in the TERMPATH variable, or becomes
* "$HOME/.termcap /etc/termcap" if no TERMPATH exists.
*/
- if (!is_pathname(cp)) { /* no TERMCAP or it holds an entry */
+ _nc_str_init(&desc, pathbuf, sizeof(pathbuf));
+ if (cp == NULL) {
+ _nc_safe_strcpy(&desc, "/etc/termcap /usr/share/misc/termcap");
+ } else if (!is_pathname(cp)) { /* TERMCAP holds an entry */
if ((termpath = getenv("TERMPATH")) != 0) {
- strncpy(pathbuf, termpath, PBUFSIZ - 1);
+ _nc_safe_strcat(&desc, termpath);
} else {
- if ((home = getenv("HOME")) != 0 &&
- strlen(home) < PBUFSIZ) { /* setup path */
- p += strlen(home); /* path, looking in */
- strcpy(pathbuf, home); /* $HOME first */
- *p++ = '/';
- } /* if no $HOME look in current directory */
-#define MY_PATH_DEF ".termcap /etc/termcap /usr/share/misc/termcap"
- strncpy(p, MY_PATH_DEF, (size_t) (PBUFSIZ - (p - pathbuf) - 1));
+ char temp[PBUFSIZ];
+ temp[0] = 0;
+ if ((home = getenv("HOME")) != 0 && *home != '\0'
+ && strchr(home, ' ') == 0
+ && strlen(home) < sizeof(temp) - 10) { /* setup path */
+ sprintf(temp, "%s/", home); /* $HOME first */
+ }
+ /* if no $HOME look in current directory */
+ strcat(temp, ".termcap");
+ _nc_safe_strcat(&desc, temp);
+ _nc_safe_strcat(&desc, " /etc/termcap");
+ _nc_safe_strcat(&desc, " /usr/share/misc/termcap");
}
- } else /* user-defined name in TERMCAP */
- strncpy(pathbuf, cp, PBUFSIZ - 1); /* still can be tokenized */
- pathbuf[PBUFSIZ - 1] = '\0';
+ } else { /* user-defined name in TERMCAP */
+ _nc_safe_strcat(&desc, cp); /* still can be tokenized */
+ }
*fname++ = pathbuf; /* tokenize path into vector of names */
while (*++p) {
@@ -921,7 +930,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
static char *source;
static int lineno;
- if ((p = getenv("TERMCAP")) != 0
+ if (use_terminfo_vars() && (p = getenv("TERMCAP")) != 0
&& !is_pathname(p) && _nc_name_match(p, tn, "|:")) {
/* TERMCAP holds a termcap entry */
strncpy(tc, p, sizeof(tc) - 1);
@@ -971,7 +980,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
char pathbuf[PATH_MAX];
termpaths[filecount] = 0;
- if ((tc = getenv("TERMCAP")) != 0) {
+ if (use_terminfo_vars() && (tc = getenv("TERMCAP")) != 0) {
if (is_pathname(tc)) { /* interpret as a filename */
ADD_TC(tc, 0);
} else if (_nc_name_match(tc, tn, "|:")) { /* treat as a capability file */
@@ -1004,7 +1013,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
#define PRIVATE_CAP "%s/.termcap"
- if ((h = getenv("HOME")) != NULL
+ if ((h = getenv("HOME")) != NULL && *h != '\0'
&& (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) {
/* user's .termcap, if any, should override it */
(void) strcpy(envhome, h);
diff --git a/contrib/ncurses/ncurses/tinfo/strings.c b/contrib/ncurses/ncurses/tinfo/strings.c
new file mode 100644
index 000000000000..8198ec4050ad
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/strings.c
@@ -0,0 +1,139 @@
+/****************************************************************************
+ * Copyright (c) 2000 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 *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+/*
+** lib_mvcur.c
+**/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id")
+
+/****************************************************************************
+ * Useful string functions (especially for mvcur)
+ ****************************************************************************/
+
+#if !HAVE_STRSTR
+char *
+_nc_strstr(const char *haystack, const char *needle)
+{
+ size_t len1 = strlen(haystack);
+ size_t len2 = strlen(needle);
+ char *result = 0;
+
+ while ((len1 != 0) && (len1-- >= len2)) {
+ if (!strncmp(haystack, needle, len2)) {
+ result = haystack;
+ break;
+ }
+ haystack++;
+ }
+ return result;
+}
+#endif
+
+/*
+ * Initialize the descriptor so we can append to it.
+ */
+string_desc *
+_nc_str_init(string_desc * dst, char *src, size_t len)
+{
+ if (dst != 0) {
+ dst->s_head = src;
+ dst->s_tail = src;
+ dst->s_size = len - 1;
+ if (src != 0)
+ *src = 0;
+ }
+ return dst;
+}
+
+/*
+ * Initialize the descriptor for only tracking the amount of memory used.
+ */
+string_desc *
+_nc_str_null(string_desc * dst, size_t len)
+{
+ return _nc_str_init(dst, 0, len);
+}
+
+/*
+ * Copy a descriptor
+ */
+string_desc *
+_nc_str_copy(string_desc * dst, string_desc * src)
+{
+ *dst = *src;
+ return dst;
+}
+
+/*
+ * Replaces strcat into a fixed buffer, returning false on failure.
+ */
+bool
+_nc_safe_strcat(string_desc * dst, const char *src)
+{
+ if (src != 0) {
+ size_t len = strlen(src);
+
+ if (len < dst->s_size) {
+ if (dst->s_tail != 0) {
+ strcpy(dst->s_tail, src);
+ dst->s_tail += len;
+ }
+ dst->s_size -= len;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/*
+ * Replaces strcpy into a fixed buffer, returning false on failure.
+ */
+bool
+_nc_safe_strcpy(string_desc * dst, const char *src)
+{
+ if (src != 0) {
+ size_t len = strlen(src);
+
+ if (len < dst->s_size) {
+ if (dst->s_head != 0) {
+ strcpy(dst->s_head, src);
+ dst->s_tail = dst->s_head + len;
+ }
+ dst->s_size -= len;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
diff --git a/contrib/ncurses/ncurses/tinfo/write_entry.c b/contrib/ncurses/ncurses/tinfo/write_entry.c
index 12aedd6e565c..af4b4fda2a3a 100644
--- a/contrib/ncurses/ncurses/tinfo/write_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/write_entry.c
@@ -52,7 +52,7 @@
#define TRACE_OUT(p) /*nothing */
#endif
-MODULE_ID("$Id: write_entry.c,v 1.52 2000/03/11 12:23:42 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.53 2000/10/04 02:32:14 tom Exp $")
static int total_written;
@@ -116,10 +116,12 @@ _nc_set_writedir(char *dir)
const char *destination;
char actual[PATH_MAX];
+ if (dir == 0
+ && use_terminfo_vars())
+ dir = getenv("TERMINFO");
+
if (dir != 0)
(void) _nc_tic_dir(dir);
- else if (getenv("TERMINFO") != NULL)
- (void) _nc_tic_dir(getenv("TERMINFO"));
destination = _nc_tic_dir(0);
if (make_directory(destination) < 0) {
diff --git a/contrib/ncurses/ncurses/trace/lib_traceatr.c b/contrib/ncurses/ncurses/trace/lib_traceatr.c
index d9e007517f76..c65c584f8600 100644
--- a/contrib/ncurses/ncurses/trace/lib_traceatr.c
+++ b/contrib/ncurses/ncurses/trace/lib_traceatr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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 *
@@ -31,27 +31,29 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* lib_traceatr.c - Tracing/Debugging routines (attributes)
*/
#include <curses.priv.h>
-#include <term.h> /* acs_chars */
+#include <term.h> /* acs_chars */
-MODULE_ID("$Id: lib_traceatr.c,v 1.28 1998/03/21 18:39:36 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.30 2000/07/29 18:06:09 tom Exp $")
#define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
#ifdef TRACE
-char *_traceattr2(int bufnum, attr_t newmode)
+char *
+_traceattr2(int bufnum, attr_t newmode)
{
-char *buf = _nc_trace_buf(bufnum, BUFSIZ);
-char *tmp = buf;
-static const struct {unsigned int val; const char *name;}
-names[] =
+ char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+ char *tmp = buf;
+ static const struct {
+ unsigned int val;
+ const char *name;
+ } names[] =
{
+ /* *INDENT-OFF* */
{ A_STANDOUT, "A_STANDOUT" },
{ A_UNDERLINE, "A_UNDERLINE" },
{ A_REVERSE, "A_REVERSE" },
@@ -64,9 +66,12 @@ names[] =
{ A_CHARTEXT, "A_CHARTEXT" },
{ A_NORMAL, "A_NORMAL" },
{ A_COLOR, "A_COLOR" },
+ /* *INDENT-ON* */
+
},
-colors[] =
+ colors[] =
{
+ /* *INDENT-OFF* */
{ COLOR_BLACK, "COLOR_BLACK" },
{ COLOR_RED, "COLOR_RED" },
{ COLOR_GREEN, "COLOR_GREEN" },
@@ -75,122 +80,125 @@ colors[] =
{ COLOR_MAGENTA, "COLOR_MAGENTA" },
{ COLOR_CYAN, "COLOR_CYAN" },
{ COLOR_WHITE, "COLOR_WHITE" },
+ /* *INDENT-ON* */
+
};
-size_t n;
-unsigned save_nc_tracing = _nc_tracing;
- _nc_tracing = 0;
-
- strcpy(tmp++, "{");
-
- for (n = 0; n < SIZEOF(names); n++) {
- if ((newmode & names[n].val) != 0) {
- if (buf[1] != '\0')
- strcat(tmp, "|");
- strcat(tmp, names[n].name);
- tmp += strlen(tmp);
-
- if (names[n].val == A_COLOR)
- {
- short pairnum = PAIR_NUMBER(newmode);
- short fg, bg;
-
- if (pair_content(pairnum, &fg, &bg) == OK)
- (void) sprintf(tmp,
- "{%d = {%s, %s}}",
- pairnum,
- COLOR_OF(fg),
- COLOR_OF(bg)
- );
- else
- (void) sprintf(tmp, "{%d}", pairnum);
- }
- }
- }
- if (AttrOf(newmode) == A_NORMAL) {
- if (buf[1] != '\0')
- strcat(tmp, "|");
- strcat(tmp, "A_NORMAL");
+ size_t n;
+ unsigned save_nc_tracing = _nc_tracing;
+ _nc_tracing = 0;
+
+ strcpy(tmp++, "{");
+
+ for (n = 0; n < SIZEOF(names); n++) {
+ if ((newmode & names[n].val) != 0) {
+ if (buf[1] != '\0')
+ strcat(tmp, "|");
+ strcat(tmp, names[n].name);
+ tmp += strlen(tmp);
+
+ if (names[n].val == A_COLOR) {
+ short pairnum = PAIR_NUMBER(newmode);
+ short fg, bg;
+
+ if (pair_content(pairnum, &fg, &bg) == OK)
+ (void) sprintf(tmp,
+ "{%d = {%s, %s}}",
+ pairnum,
+ COLOR_OF(fg),
+ COLOR_OF(bg)
+ );
+ else
+ (void) sprintf(tmp, "{%d}", pairnum);
+ }
}
+ }
+ if (AttrOf(newmode) == A_NORMAL) {
+ if (buf[1] != '\0')
+ strcat(tmp, "|");
+ strcat(tmp, "A_NORMAL");
+ }
- _nc_tracing = save_nc_tracing;
- return (strcat(buf,"}"));
+ _nc_tracing = save_nc_tracing;
+ return (strcat(buf, "}"));
}
-char *_traceattr(attr_t newmode)
+char *
+_traceattr(attr_t newmode)
{
- return _traceattr2(0, newmode);
+ return _traceattr2(0, newmode);
}
/* Trace 'int' return-values */
-attr_t _nc_retrace_attr_t(attr_t code)
+attr_t
+_nc_retrace_attr_t(attr_t code)
{
- T((T_RETURN("%s"), _traceattr(code)));
- return code;
+ T((T_RETURN("%s"), _traceattr(code)));
+ return code;
}
-char *_tracechtype2(int bufnum, chtype ch)
+char *
+_tracechtype2(int bufnum, chtype ch)
{
-char *buf = _nc_trace_buf(bufnum, BUFSIZ);
-char *found = 0;
+ char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+ char *found = 0;
strcpy(buf, "{");
- if (ch & A_ALTCHARSET)
- {
- char *cp;
- static const struct {unsigned int val; const char *name;}
- names[] =
+ if (ch & A_ALTCHARSET) {
+ char *cp;
+ static const struct {
+ unsigned int val;
+ const char *name;
+ } names[] =
{
- {'l', "ACS_ULCORNER"}, /* upper left corner */
- {'m', "ACS_LLCORNER"}, /* lower left corner */
- {'k', "ACS_URCORNER"}, /* upper right corner */
- {'j', "ACS_LRCORNER"}, /* lower right corner */
- {'t', "ACS_LTEE"}, /* tee pointing right */
- {'u', "ACS_RTEE"}, /* tee pointing left */
- {'v', "ACS_BTEE"}, /* tee pointing up */
- {'w', "ACS_TTEE"}, /* tee pointing down */
- {'q', "ACS_HLINE"}, /* horizontal line */
- {'x', "ACS_VLINE"}, /* vertical line */
- {'n', "ACS_PLUS"}, /* large plus or crossover */
- {'o', "ACS_S1"}, /* scan line 1 */
- {'s', "ACS_S9"}, /* scan line 9 */
- {'`', "ACS_DIAMOND"}, /* diamond */
- {'a', "ACS_CKBOARD"}, /* checker board (stipple) */
- {'f', "ACS_DEGREE"}, /* degree symbol */
- {'g', "ACS_PLMINUS"}, /* plus/minus */
- {'~', "ACS_BULLET"}, /* bullet */
- {',', "ACS_LARROW"}, /* arrow pointing left */
- {'+', "ACS_RARROW"}, /* arrow pointing right */
- {'.', "ACS_DARROW"}, /* arrow pointing down */
- {'-', "ACS_UARROW"}, /* arrow pointing up */
- {'h', "ACS_BOARD"}, /* board of squares */
- {'i', "ACS_LANTERN"}, /* lantern symbol */
- {'0', "ACS_BLOCK"}, /* solid square block */
- {'p', "ACS_S3"}, /* scan line 3 */
- {'r', "ACS_S7"}, /* scan line 7 */
- {'y', "ACS_LEQUAL"}, /* less/equal */
- {'z', "ACS_GEQUAL"}, /* greater/equal */
- {'{', "ACS_PI"}, /* Pi */
- {'|', "ACS_NEQUAL"}, /* not equal */
- {'}', "ACS_STERLING"}, /* UK pound sign */
- {'\0',(char *)0}
+ /* *INDENT-OFF* */
+ { 'l', "ACS_ULCORNER" }, /* upper left corner */
+ { 'm', "ACS_LLCORNER" }, /* lower left corner */
+ { 'k', "ACS_URCORNER" }, /* upper right corner */
+ { 'j', "ACS_LRCORNER" }, /* lower right corner */
+ { 't', "ACS_LTEE" }, /* tee pointing right */
+ { 'u', "ACS_RTEE" }, /* tee pointing left */
+ { 'v', "ACS_BTEE" }, /* tee pointing up */
+ { 'w', "ACS_TTEE" }, /* tee pointing down */
+ { 'q', "ACS_HLINE" }, /* horizontal line */
+ { 'x', "ACS_VLINE" }, /* vertical line */
+ { 'n', "ACS_PLUS" }, /* large plus or crossover */
+ { 'o', "ACS_S1" }, /* scan line 1 */
+ { 's', "ACS_S9" }, /* scan line 9 */
+ { '`', "ACS_DIAMOND" }, /* diamond */
+ { 'a', "ACS_CKBOARD" }, /* checker board (stipple) */
+ { 'f', "ACS_DEGREE" }, /* degree symbol */
+ { 'g', "ACS_PLMINUS" }, /* plus/minus */
+ { '~', "ACS_BULLET" }, /* bullet */
+ { ',', "ACS_LARROW" }, /* arrow pointing left */
+ { '+', "ACS_RARROW" }, /* arrow pointing right */
+ { '.', "ACS_DARROW" }, /* arrow pointing down */
+ { '-', "ACS_UARROW" }, /* arrow pointing up */
+ { 'h', "ACS_BOARD" }, /* board of squares */
+ { 'i', "ACS_LANTERN" }, /* lantern symbol */
+ { '0', "ACS_BLOCK" }, /* solid square block */
+ { 'p', "ACS_S3" }, /* scan line 3 */
+ { 'r', "ACS_S7" }, /* scan line 7 */
+ { 'y', "ACS_LEQUAL" }, /* less/equal */
+ { 'z', "ACS_GEQUAL" }, /* greater/equal */
+ { '{', "ACS_PI" }, /* Pi */
+ { '|', "ACS_NEQUAL" }, /* not equal */
+ { '}', "ACS_STERLING" }, /* UK pound sign */
+ { '\0', (char *) 0 }
+ /* *INDENT-OFF* */
},
- *sp;
+ *sp;
- for (cp = acs_chars; cp[0] && cp[1]; cp += 2)
- {
- if (TextOf(cp[1]) == TextOf(ch))
- {
+ for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
+ if (TextOf(cp[1]) == TextOf(ch)) {
found = cp;
/* don't exit from loop - there may be redefinitions */
}
}
- if (found != 0)
- {
+ if (found != 0) {
ch = TextOf(*found);
for (sp = names; sp->val; sp++)
- if (sp->val == ch)
- {
+ if (sp->val == ch) {
(void) strcat(buf, sp->name);
ch &= ~A_ALTCHARSET;
break;
@@ -202,17 +210,31 @@ char *found = 0;
(void) strcat(buf, _tracechar(TextOf(ch)));
if (AttrOf(ch) != A_NORMAL)
- (void) sprintf(buf + strlen(buf), " | %s", _traceattr2(bufnum+20,AttrOf(ch)));
+ (void) sprintf(buf + strlen(buf), " | %s",
+ _traceattr2(bufnum + 20, AttrOf(ch)));
strcat(buf, "}");
- return(buf);
+ return (buf);
}
-char *_tracechtype(chtype ch)
+char *
+_tracechtype(chtype ch)
{
- return _tracechtype2(0, ch);
+ return _tracechtype2(0, ch);
}
+
+/* Trace 'chtype' return-values */
+attr_t
+_nc_retrace_chtype(attr_t code)
+{
+ T((T_RETURN("%s"), _tracechtype(code)));
+ return code;
+}
+
#else
-extern void _nc_lib_traceatr(void);
- void _nc_lib_traceatr(void) { }
+extern void _nc_lib_traceatr(void);
+void
+_nc_lib_traceatr(void)
+{
+}
#endif /* TRACE */
diff --git a/contrib/ncurses/ncurses/trace/lib_tracebits.c b/contrib/ncurses/ncurses/trace/lib_tracebits.c
index 6dbb2f793ad0..a8cb343be59f 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracebits.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracebits.c
@@ -34,9 +34,9 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_tracebits.c,v 1.5 2000/02/13 01:01:55 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.7 2000/09/02 18:08:37 tom Exp $")
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
@@ -153,30 +153,41 @@ _nc_tracebits(void)
lookup_bits(buf, cflags, "cflags", cur_term->Nttyb.c_cflag);
#if defined(CS5) && defined(CS8)
- switch (cur_term->Nttyb.c_cflag & CSIZE) {
-#if defined(CS5) && (CS5 != 0)
- case CS5:
- strcat(buf, "CS5 ");
- break;
-#endif
-#if defined(CS6) && (CS6 != 0)
- case CS6:
- strcat(buf, "CS6 ");
- break;
-#endif
-#if defined(CS7) && (CS7 != 0)
- case CS7:
- strcat(buf, "CS7 ");
- break;
-#endif
-#if defined(CS8) && (CS8 != 0)
- case CS8:
- strcat(buf, "CS8 ");
- break;
-#endif
- default:
- strcat(buf, "CSIZE? ");
- break;
+ {
+ static struct {
+ char *name;
+ int value;
+ } csizes[] = {
+ {
+ "CS5 ", CS5
+ },
+#ifdef CS6
+ {
+ "CS6 ", CS6
+ },
+#endif
+#ifdef CS7
+ {
+ "CS7 ", CS7
+ },
+#endif
+ {
+ "CS8 ", CS8
+ },
+ };
+ char *result = "CSIZE? ";
+ int value = (cur_term->Nttyb.c_cflag & CSIZE);
+ unsigned n;
+
+ if (value != 0) {
+ for (n = 0; n < SIZEOF(csizes); n++) {
+ if (csizes[n].value == value) {
+ result = csizes[n].name;
+ break;
+ }
+ }
+ }
+ strcat(buf, result);
}
#endif
diff --git a/contrib/ncurses/ncurses/tty/MKexpanded.sh b/contrib/ncurses/ncurses/tty/MKexpanded.sh
index b008becc4f07..e44f58343a5d 100755
--- a/contrib/ncurses/ncurses/tty/MKexpanded.sh
+++ b/contrib/ncurses/ncurses/tty/MKexpanded.sh
@@ -1,6 +1,6 @@
#! /bin/sh
##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc. #
+# Copyright (c) 1998,2000 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 "Software"), #
@@ -29,7 +29,7 @@
#
# Author: Thomas E. Dickey <dickey@clark.net> 1997
#
-# $Id: MKexpanded.sh,v 1.7 1998/11/11 20:15:39 Alexander.V.Lukyanov Exp $
+# $Id: MKexpanded.sh,v 1.9 2000/09/02 22:55:21 tom Exp $
#
# Script to generate 'expanded.c', a dummy source that contains functions
# corresponding to complex macros used in this library. By making functions,
@@ -54,7 +54,7 @@ cat <<EOF
/* generated by MKexpanded.sh */
#include <curses.priv.h>
#include <term.h>
-#ifdef NCURSES_EXPANDED
+#if NCURSES_EXPANDED
EOF
cat >$TMP <<EOF
@@ -76,10 +76,6 @@ void _nc_toggle_attr_off(attr_t *S, attr_t at)
{
toggle_attr_off(*S,at);
}
-int _nc_can_clear_with(chtype ch)
-{
- return can_clear_with(ch);
-}
int _nc_DelCharCost(int count)
{
return DelCharCost(count);
diff --git a/contrib/ncurses/ncurses/tty/lib_mvcur.c b/contrib/ncurses/ncurses/tty/lib_mvcur.c
index 190c59bd4a15..03abaffb4d84 100644
--- a/contrib/ncurses/ncurses/tty/lib_mvcur.c
+++ b/contrib/ncurses/ncurses/tty/lib_mvcur.c
@@ -152,9 +152,7 @@
#include <term.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_mvcur.c,v 1.67 2000/06/24 21:13:51 tom Exp $")
-
-#define STRLEN(s) (s != 0) ? strlen(s) : 0
+MODULE_ID("$Id: lib_mvcur.c,v 1.72 2000/10/08 00:58:25 tom Exp $")
#define CURRENT_ROW SP->_cursrow /* phys cursor row */
#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
@@ -174,25 +172,6 @@ static float diff;
static int normalized_cost(const char *const cap, int affcnt);
-#if !HAVE_STRSTR
-char *
-_nc_strstr(const char *haystack, const char *needle)
-{
- size_t len1 = strlen(haystack);
- size_t len2 = strlen(needle);
- char *result = 0;
-
- while ((len1 != 0) && (len1-- >= len2)) {
- if (!strncmp(haystack, needle, len2)) {
- result = haystack;
- break;
- }
- haystack++;
- }
- return result;
-}
-#endif
-
/****************************************************************************
*
* Initialization/wrapup (including cost pre-computation)
@@ -205,7 +184,7 @@ trace_cost_of(const char *capname, const char *cap, int affcnt)
{
int result = _nc_msec_cost(cap, affcnt);
TR(TRACE_CHARPUT | TRACE_MOVE,
- ("CostOf %s %d %s", capname, result, _nc_visbuf(cap)));
+ ("CostOf %s %d %s", capname, result, _nc_visbuf(cap)));
return result;
}
#define CostOf(cap,affcnt) trace_cost_of(#cap,cap,affcnt);
@@ -215,7 +194,7 @@ trace_normalized_cost(const char *capname, const char *cap, int affcnt)
{
int result = normalized_cost(cap, affcnt);
TR(TRACE_CHARPUT | TRACE_MOVE,
- ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap)));
+ ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap)));
return result;
}
#define NormalizedCost(cap,affcnt) trace_normalized_cost(#cap,cap,affcnt);
@@ -235,12 +214,12 @@ _nc_msec_cost(const char *const cap, int affcnt)
return (INFINITY);
else {
const char *cp;
- float cum_cost = 0;
+ float cum_cost = 0.0;
for (cp = cap; *cp; cp++) {
/* extract padding, either mandatory or required */
if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) {
- float number = 0;
+ float number = 0.0;
for (cp += 2; *cp != '>'; cp++) {
if (isdigit(*cp))
@@ -251,7 +230,7 @@ _nc_msec_cost(const char *const cap, int affcnt)
number += (*cp - '0') / 10.0;
}
-#ifdef NCURSES_NO_PADDING
+#if NCURSES_NO_PADDING
if (!(SP->_no_padding))
#endif
cum_cost += number * 10;
@@ -402,13 +381,8 @@ _nc_mvcur_init(void)
SP->_hpa_ch_cost = NormalizedCost(tparm(column_address, 23), 1);
SP->_cuf_ch_cost = NormalizedCost(tparm(parm_right_cursor, 23), 1);
SP->_inline_cost = min(SP->_cup_ch_cost,
- min(SP->_hpa_ch_cost,
- SP->_cuf_ch_cost));
-
- /* pre-compute some capability lengths */
- SP->_carriage_return_length = STRLEN(carriage_return);
- SP->_cursor_home_length = STRLEN(cursor_home);
- SP->_cursor_to_ll_length = STRLEN(cursor_to_ll);
+ min(SP->_hpa_ch_cost,
+ SP->_cuf_ch_cost));
/*
* If save_cursor is used within enter_ca_mode, we should not use it for
@@ -468,18 +442,17 @@ _nc_mvcur_wrap(void)
* Perform repeated-append, returning cost
*/
static inline int
-repeated_append(int total, int num, int repeat, char *dst, const char *src)
+repeated_append(string_desc * target, int total, int num, int repeat, const char *src)
{
- register size_t src_len = strlen(src);
- register size_t dst_len = STRLEN(dst);
-
- if ((dst_len + repeat * src_len) < OPT_SIZE - 1) {
- total += (num * repeat);
- if (dst) {
- dst += dst_len;
- while (repeat-- > 0) {
- (void) strcpy(dst, src);
- dst += src_len;
+ size_t need = repeat * strlen(src);
+
+ if (need < target->s_size) {
+ while (repeat-- > 0) {
+ if (_nc_safe_strcat(target, src)) {
+ total += num;
+ } else {
+ total = INFINITY;
+ break;
}
}
} else {
@@ -497,53 +470,51 @@ repeated_append(int total, int num, int repeat, char *dst, const char *src)
*/
#define LASTTAB(fr) ((fr > 0) ? ((fr - 1) / init_tabs) * init_tabs : -1)
-/* Note: we'd like to inline this for speed, but GNU C barfs on the attempt. */
-
static int
-relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw)
+relative_move(string_desc * target, int from_y, int from_x, int to_y, int
+ to_x, bool ovw)
/* move via local motions (cuu/cuu1/cud/cud1/cub1/cub/cuf1/cuf/vpa/hpa) */
{
+ string_desc save;
int n, vcost = 0, hcost = 0;
- if (result)
- result[0] = '\0';
+ (void) _nc_str_copy(&save, target);
if (to_y != from_y) {
vcost = INFINITY;
- if (row_address) {
- if (result)
- (void) strcpy(result, tparm(row_address, to_y));
+ if (row_address != 0
+ && _nc_safe_strcat(target, tparm(row_address, to_y))) {
vcost = SP->_vpa_cost;
}
if (to_y > from_y) {
n = (to_y - from_y);
- if (parm_down_cursor && SP->_cud_cost < vcost) {
- if (result)
- (void) strcpy(result, tparm(parm_down_cursor, n));
+ if (parm_down_cursor
+ && SP->_cud_cost < vcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_down_cursor, n))) {
vcost = SP->_cud_cost;
}
if (cursor_down && (n * SP->_cud1_cost < vcost)) {
- if (result)
- result[0] = '\0';
- vcost = repeated_append(0, SP->_cud1_cost, n, result, cursor_down);
+ vcost = repeated_append(_nc_str_copy(target, &save), 0,
+ SP->_cud1_cost, n, cursor_down);
}
} else { /* (to_y < from_y) */
n = (from_y - to_y);
- if (parm_up_cursor && SP->_cup_cost < vcost) {
- if (result)
- (void) strcpy(result, tparm(parm_up_cursor, n));
+ if (parm_up_cursor
+ && SP->_cup_cost < vcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_up_cursor, n))) {
vcost = SP->_cup_cost;
}
if (cursor_up && (n * SP->_cuu1_cost < vcost)) {
- if (result)
- result[0] = '\0';
- vcost = repeated_append(0, SP->_cuu1_cost, n, result, cursor_up);
+ vcost = repeated_append(_nc_str_copy(target, &save), 0,
+ SP->_cuu1_cost, n, cursor_up);
}
}
@@ -551,33 +522,34 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
return (INFINITY);
}
- if (result)
- result += strlen(result);
+ save = *target;
if (to_x != from_x) {
char str[OPT_SIZE];
+ string_desc check;
hcost = INFINITY;
- if (column_address) {
- if (result)
- (void) strcpy(result, tparm(column_address, to_x));
+ if (column_address
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(column_address, to_x))) {
hcost = SP->_hpa_cost;
}
if (to_x > from_x) {
n = to_x - from_x;
- if (parm_right_cursor && SP->_cuf_cost < hcost) {
- if (result)
- (void) strcpy(result, tparm(parm_right_cursor, n));
+ if (parm_right_cursor
+ && SP->_cuf_cost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_right_cursor, n))) {
hcost = SP->_cuf_cost;
}
if (cursor_right) {
int lhcost = 0;
- str[0] = '\0';
+ (void) _nc_str_init(&check, str, sizeof(str));
#if USE_HARD_TABS
/* use hard tabs, if we have them, to do as much as possible */
@@ -585,8 +557,8 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
int nxt, fr;
for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt) {
- lhcost = repeated_append(lhcost, SP->_ht_cost, 1,
- str, tab);
+ lhcost = repeated_append(&check, lhcost,
+ SP->_ht_cost, 1, tab);
if (lhcost == INFINITY)
break;
}
@@ -597,7 +569,7 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
#endif /* USE_HARD_TABS */
#if defined(REAL_ATTR) && defined(WANT_CHAR)
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
/*
* If we're allowing BSD-style padding in tputs, don't generate
* a string with a leading digit. Otherwise, that will be
@@ -606,6 +578,7 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
*/
if (ovw
&& n > 0
+ && n < (int) check.s_size
&& vcost == 0
&& str[0] == '\0'
&& isdigit(TextOf(WANT_CHAR(to_y, from_x))))
@@ -629,48 +602,47 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
}
}
if (ovw) {
- char *sp;
int i;
- sp = str + strlen(str);
-
for (i = 0; i < n; i++)
- *sp++ = WANT_CHAR(to_y, from_x + i);
- *sp = '\0';
+ *check.s_tail++ = WANT_CHAR(to_y, from_x + i);
+ *check.s_tail = '\0';
+ check.s_size -= n;
lhcost += n * SP->_char_padding;
} else
#endif /* defined(REAL_ATTR) && defined(WANT_CHAR) */
{
- lhcost = repeated_append(lhcost, SP->_cuf1_cost, n, str, cursor_right);
+ lhcost = repeated_append(&check, lhcost, SP->_cuf1_cost,
+ n, cursor_right);
}
- if (lhcost < hcost) {
- if (result)
- (void) strcpy(result, str);
+ if (lhcost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save), str)) {
hcost = lhcost;
}
}
} else { /* (to_x < from_x) */
n = from_x - to_x;
- if (parm_left_cursor && SP->_cub_cost < hcost) {
- if (result)
- (void) strcpy(result, tparm(parm_left_cursor, n));
+ if (parm_left_cursor
+ && SP->_cub_cost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_left_cursor, n))) {
hcost = SP->_cub_cost;
}
if (cursor_left) {
int lhcost = 0;
- str[0] = '\0';
+ (void) _nc_str_init(&check, str, sizeof(str));
#if USE_HARD_TABS
if (init_tabs > 0 && back_tab) {
int nxt, fr;
for (fr = from_x; (nxt = LASTTAB(fr)) >= to_x; fr = nxt) {
- lhcost = repeated_append(lhcost, SP->_cbt_cost, 1,
- str, back_tab);
+ lhcost = repeated_append(&check, lhcost,
+ SP->_cbt_cost, 1, back_tab);
if (lhcost == INFINITY)
break;
}
@@ -679,11 +651,10 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
}
#endif /* USE_HARD_TABS */
- lhcost = repeated_append(lhcost, SP->_cub1_cost, n, str, cursor_left);
+ lhcost = repeated_append(&check, lhcost, SP->_cub1_cost, n, cursor_left);
- if (lhcost < hcost) {
- if (result)
- (void) strcpy(result, str);
+ if (lhcost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save), str)) {
hcost = lhcost;
}
}
@@ -712,7 +683,8 @@ static inline int
onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* onscreen move from (yold, xold) to (ynew, xnew) */
{
- char use[OPT_SIZE], *sp;
+ string_desc result;
+ char buffer[OPT_SIZE];
int tactic = 0, newcost, usecost = INFINITY;
int t5_cr_cost;
@@ -722,11 +694,12 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
gettimeofday(&before, NULL);
#endif /* MAIN */
+#define NullResult _nc_str_null(&result, sizeof(buffer))
+#define InitResult _nc_str_init(&result, buffer, sizeof(buffer))
+
/* tactic #0: use direct cursor addressing */
- sp = tparm(SP->_address_cursor, ynew, xnew);
- if (sp) {
+ if (_nc_safe_strcpy(InitResult, tparm(SP->_address_cursor, ynew, xnew))) {
tactic = 0;
- (void) strcpy(use, sp);
usecost = SP->_cup_cost;
#if defined(TRACE) || defined(NCURSES_TEST)
@@ -756,7 +729,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
#ifndef NO_OPTIMIZE
/* tactic #1: use local movement */
if (yold != -1 && xold != -1
- && ((newcost = relative_move(NULL, yold, xold, ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, yold, xold, ynew, xnew,
+ ovw)) != INFINITY)
&& newcost < usecost) {
tactic = 1;
usecost = newcost;
@@ -764,7 +738,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* tactic #2: use carriage-return + local movement */
if (yold != -1 && carriage_return
- && ((newcost = relative_move(NULL, yold, 0, ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, yold, 0, ynew, xnew, ovw))
+ != INFINITY)
&& SP->_cr_cost + newcost < usecost) {
tactic = 2;
usecost = SP->_cr_cost + newcost;
@@ -772,7 +747,7 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* tactic #3: use home-cursor + local movement */
if (cursor_home
- && ((newcost = relative_move(NULL, 0, 0, ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, 0, 0, ynew, xnew, ovw)) != INFINITY)
&& SP->_home_cost + newcost < usecost) {
tactic = 3;
usecost = SP->_home_cost + newcost;
@@ -780,8 +755,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* tactic #4: use home-down + local movement */
if (cursor_to_ll
- && ((newcost = relative_move(NULL, screen_lines - 1, 0, ynew, xnew,
- ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, screen_lines - 1, 0, ynew,
+ xnew, ovw)) != INFINITY)
&& SP->_ll_cost + newcost < usecost) {
tactic = 4;
usecost = SP->_ll_cost + newcost;
@@ -794,8 +769,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
t5_cr_cost = (xold > 0 ? SP->_cr_cost : 0);
if (auto_left_margin && !eat_newline_glitch
&& yold > 0 && cursor_left
- && ((newcost = relative_move(NULL, yold - 1, screen_columns - 1,
- ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, yold - 1, screen_columns -
+ 1, ynew, xnew, ovw)) != INFINITY)
&& t5_cr_cost + SP->_cub1_cost + newcost < usecost) {
tactic = 5;
usecost = t5_cr_cost + SP->_cub1_cost + newcost;
@@ -804,32 +779,30 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/*
* These cases are ordered by estimated relative frequency.
*/
+ if (tactic)
+ InitResult;
switch (tactic) {
case 1:
- (void) relative_move(use, yold, xold, ynew, xnew, ovw);
+ (void) relative_move(&result, yold, xold, ynew, xnew, ovw);
break;
case 2:
- (void) strcpy(use, carriage_return);
- (void) relative_move(use + SP->_carriage_return_length,
- yold, 0, ynew, xnew, ovw);
+ (void) _nc_safe_strcpy(&result, carriage_return);
+ (void) relative_move(&result, yold, 0, ynew, xnew, ovw);
break;
case 3:
- (void) strcpy(use, cursor_home);
- (void) relative_move(use + SP->_cursor_home_length,
- 0, 0, ynew, xnew, ovw);
+ (void) _nc_safe_strcpy(&result, cursor_home);
+ (void) relative_move(&result, 0, 0, ynew, xnew, ovw);
break;
case 4:
- (void) strcpy(use, cursor_to_ll);
- (void) relative_move(use + SP->_cursor_to_ll_length,
- screen_lines - 1, 0, ynew, xnew, ovw);
+ (void) _nc_safe_strcpy(&result, cursor_to_ll);
+ (void) relative_move(&result, screen_lines - 1, 0, ynew, xnew, ovw);
break;
case 5:
- use[0] = '\0';
if (xold > 0)
- (void) strcat(use, carriage_return);
- (void) strcat(use, cursor_left);
- (void) relative_move(use + strlen(use),
- yold - 1, screen_columns - 1, ynew, xnew, ovw);
+ (void) _nc_safe_strcat(&result, carriage_return);
+ (void) _nc_safe_strcat(&result, cursor_left);
+ (void) relative_move(&result, yold - 1, screen_columns - 1, ynew,
+ xnew, ovw);
break;
}
#endif /* !NO_OPTIMIZE */
@@ -840,14 +813,14 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
+ (after.tv_sec - before.tv_sec) * 1000000;
if (!profiling)
(void) fprintf(stderr,
- "onscreen: %d msec, %f 28.8Kbps char-equivalents\n",
- (int) diff, diff / 288);
+ "onscreen: %d msec, %f 28.8Kbps char-equivalents\n",
+ (int) diff, diff / 288);
#endif /* MAIN */
nonlocal:
if (usecost != INFINITY) {
TPUTS_TRACE("mvcur");
- tputs(use, 1, _nc_outch);
+ tputs(buffer, 1, _nc_outch);
return (OK);
} else
return (ERR);
@@ -951,7 +924,7 @@ _nc_outch(int ch)
}
char PC = 0; /* used by termcap library */
-speed_t ospeed = 0; /* used by termcap library */
+short ospeed = 0; /* used by termcap library */
int _nc_nulls_sent = 0; /* used by 'tack' program */
int
@@ -1009,7 +982,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
(void) puts("s[croll] n t b m -- display scrolling sequence");
(void)
printf("r[eload] -- reload terminal info for %s\n",
- termname());
+ termname());
(void)
puts("l[oad] <term> -- load terminal info for type <term>");
(void) puts("d[elete] <cap> -- delete named capability");
@@ -1030,8 +1003,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
gettimeofday(&after, NULL);
printf("\" (%ld msec)\n",
- (long) (after.tv_usec - before.tv_usec + (after.tv_sec -
- before.tv_sec) * 1000000));
+ (long) (after.tv_usec - before.tv_usec
+ + (after.tv_sec - before.tv_sec)
+ * 1000000));
} else if (sscanf(buf, "s %d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
struct timeval before, after;
@@ -1042,8 +1016,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
gettimeofday(&after, NULL);
printf("\" (%ld msec)\n",
- (long) (after.tv_usec - before.tv_usec + (after.tv_sec -
- before.tv_sec) * 1000000));
+ (long) (after.tv_usec - before.tv_usec + (after.tv_sec -
+ before.tv_sec)
+ * 1000000));
} else if (buf[0] == 'r') {
(void) strcpy(tname, termname());
load_term();
@@ -1051,7 +1026,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
load_term();
} else if (sscanf(buf, "d %s", capname) == 1) {
struct name_table_entry const *np = _nc_find_entry(capname,
- _nc_info_hash_table);
+ _nc_info_hash_table);
if (np == NULL)
(void) printf("No such capability as \"%s\"\n", capname);
@@ -1061,19 +1036,19 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
cur_term->type.Booleans[np->nte_index] = FALSE;
(void)
printf("Boolean capability `%s' (%d) turned off.\n",
- np->nte_name, np->nte_index);
+ np->nte_name, np->nte_index);
break;
case NUMBER:
cur_term->type.Numbers[np->nte_index] = ABSENT_NUMERIC;
(void) printf("Number capability `%s' (%d) set to -1.\n",
- np->nte_name, np->nte_index);
+ np->nte_name, np->nte_index);
break;
case STRING:
cur_term->type.Strings[np->nte_index] = ABSENT_STRING;
(void) printf("String capability `%s' (%d) deleted.\n",
- np->nte_name, np->nte_index);
+ np->nte_name, np->nte_index);
break;
}
}
@@ -1110,7 +1085,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
* is winning.
*/
else if (sscanf(buf, "t %d", &n) == 1) {
- float cumtime = 0, perchar;
+ float cumtime = 0.0, perchar;
int speeds[] =
{2400, 9600, 14400, 19200, 28800, 38400, 0};
@@ -1148,7 +1123,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
perchar = cumtime / n;
(void) printf("%d moves (%ld chars) in %d msec, %f msec each:\n",
- n, xmits, (int) cumtime, perchar);
+ n, xmits, (int) cumtime, perchar);
for (i = 0; speeds[i]; i++) {
/*
@@ -1167,7 +1142,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
(void)
printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n",
- speeds[i], overhead, totalest);
+ speeds[i], overhead, totalest);
}
} else if (buf[0] == 'c') {
(void) printf("char padding: %d\n", SP->_char_padding);
diff --git a/contrib/ncurses/ncurses/tty/lib_tstp.c b/contrib/ncurses/ncurses/tty/lib_tstp.c
index d01a62f71487..512de68dc5ff 100644
--- a/contrib/ncurses/ncurses/tty/lib_tstp.c
+++ b/contrib/ncurses/ncurses/tty/lib_tstp.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000 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 *
@@ -31,7 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
** lib_tstp.c
**
@@ -44,11 +43,11 @@
#include <signal.h>
#include <SigAction.h>
-#if defined(SVR4_ACTION) && !defined(_POSIX_SOURCE)
+#if SVR4_ACTION && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
-MODULE_ID("$Id: lib_tstp.c,v 1.21 2000/05/20 23:28:56 tom Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.22 2000/09/02 18:33:17 tom Exp $")
#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
#define USE_SIGTSTP 1
@@ -100,151 +99,152 @@ MODULE_ID("$Id: lib_tstp.c,v 1.21 2000/05/20 23:28:56 tom Exp $")
*/
#if USE_SIGTSTP
-static void tstp(int dummy GCC_UNUSED)
+static void
+tstp(int dummy GCC_UNUSED)
{
- sigset_t mask, omask;
- sigaction_t act, oact;
+ sigset_t mask, omask;
+ sigaction_t act, oact;
#ifdef SIGTTOU
- int sigttou_blocked;
+ int sigttou_blocked;
#endif
- T(("tstp() called"));
-
- /*
- * The user may have changed the prog_mode tty bits, so save them.
- *
- * But first try to detect whether we still are in the foreground
- * process group - if not, an interactive shell may already have
- * taken ownership of the tty and modified the settings when our
- * parent was stopped before us, and we would likely pick up the
- * settings already modified by the shell.
- */
- if (SP != 0 && !SP->_endwin) /* don't do this if we're not in curses */
+ T(("tstp() called"));
+
+ /*
+ * The user may have changed the prog_mode tty bits, so save them.
+ *
+ * But first try to detect whether we still are in the foreground
+ * process group - if not, an interactive shell may already have
+ * taken ownership of the tty and modified the settings when our
+ * parent was stopped before us, and we would likely pick up the
+ * settings already modified by the shell.
+ */
+ if (SP != 0 && !SP->_endwin) /* don't do this if we're not in curses */
#if HAVE_TCGETPGRP
if (tcgetpgrp(STDIN_FILENO) == getpgrp())
#endif
def_prog_mode();
- /*
- * Block window change and timer signals. The latter
- * is because applications use timers to decide when
- * to repaint the screen.
- */
- (void)sigemptyset(&mask);
- (void)sigaddset(&mask, SIGALRM);
+ /*
+ * Block window change and timer signals. The latter
+ * is because applications use timers to decide when
+ * to repaint the screen.
+ */
+ (void) sigemptyset(&mask);
+ (void) sigaddset(&mask, SIGALRM);
#if USE_SIGWINCH
- (void)sigaddset(&mask, SIGWINCH);
+ (void) sigaddset(&mask, SIGWINCH);
#endif
- (void)sigprocmask(SIG_BLOCK, &mask, &omask);
+ (void) sigprocmask(SIG_BLOCK, &mask, &omask);
#ifdef SIGTTOU
- sigttou_blocked = sigismember(&omask, SIGTTOU);
- if (!sigttou_blocked) {
- (void)sigemptyset(&mask);
- (void)sigaddset(&mask, SIGTTOU);
- (void)sigprocmask(SIG_BLOCK, &mask, NULL);
- }
+ sigttou_blocked = sigismember(&omask, SIGTTOU);
+ if (!sigttou_blocked) {
+ (void) sigemptyset(&mask);
+ (void) sigaddset(&mask, SIGTTOU);
+ (void) sigprocmask(SIG_BLOCK, &mask, NULL);
+ }
#endif
- /*
- * End window mode, which also resets the terminal state to the
- * original (pre-curses) modes.
- */
- endwin();
+ /*
+ * End window mode, which also resets the terminal state to the
+ * original (pre-curses) modes.
+ */
+ endwin();
- /* Unblock SIGTSTP. */
- (void)sigemptyset(&mask);
- (void)sigaddset(&mask, SIGTSTP);
+ /* Unblock SIGTSTP. */
+ (void) sigemptyset(&mask);
+ (void) sigaddset(&mask, SIGTSTP);
#ifdef SIGTTOU
- if (!sigttou_blocked) {
- /* Unblock this too if it wasn't blocked on entry */
- (void)sigaddset(&mask, SIGTTOU);
- }
+ if (!sigttou_blocked) {
+ /* Unblock this too if it wasn't blocked on entry */
+ (void) sigaddset(&mask, SIGTTOU);
+ }
#endif
- (void)sigprocmask(SIG_UNBLOCK, &mask, NULL);
+ (void) sigprocmask(SIG_UNBLOCK, &mask, NULL);
- /* Now we want to resend SIGSTP to this process and suspend it */
- act.sa_handler = SIG_DFL;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
+ /* Now we want to resend SIGSTP to this process and suspend it */
+ act.sa_handler = SIG_DFL;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
+ act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
- sigaction(SIGTSTP, &act, &oact);
- kill(getpid(), SIGTSTP);
+ sigaction(SIGTSTP, &act, &oact);
+ kill(getpid(), SIGTSTP);
- /* Process gets suspended...time passes...process resumes */
+ /* Process gets suspended...time passes...process resumes */
- T(("SIGCONT received"));
- sigaction(SIGTSTP, &oact, NULL);
- flushinp();
+ T(("SIGCONT received"));
+ sigaction(SIGTSTP, &oact, NULL);
+ flushinp();
- /*
- * If the user modified the tty state while suspended, he wants
- * those changes to stick. So save the new "default" terminal state.
- */
- def_shell_mode();
+ /*
+ * If the user modified the tty state while suspended, he wants
+ * those changes to stick. So save the new "default" terminal state.
+ */
+ def_shell_mode();
- /*
- * This relies on the fact that doupdate() will restore the
- * program-mode tty state, and issue enter_ca_mode if need be.
- */
- doupdate();
+ /*
+ * This relies on the fact that doupdate() will restore the
+ * program-mode tty state, and issue enter_ca_mode if need be.
+ */
+ doupdate();
- /* Reset the signals. */
- (void)sigprocmask(SIG_SETMASK, &omask, NULL);
+ /* Reset the signals. */
+ (void) sigprocmask(SIG_SETMASK, &omask, NULL);
}
-#endif /* USE_SIGTSTP */
+#endif /* USE_SIGTSTP */
-static void cleanup(int sig)
+static void
+cleanup(int sig)
{
- static int nested;
-
- /*
- * Actually, doing any sort of I/O from within an signal handler is
- * "unsafe". But we'll _try_ to clean up the screen and terminal
- * settings on the way out.
- */
- if (!nested++
- && (sig == SIGINT
- || sig == SIGQUIT)) {
+ static int nested;
+
+ /*
+ * Actually, doing any sort of I/O from within an signal handler is
+ * "unsafe". But we'll _try_ to clean up the screen and terminal
+ * settings on the way out.
+ */
+ if (!nested++
+ && (sig == SIGINT
+ || sig == SIGQUIT)) {
#if HAVE_SIGACTION || HAVE_SIGVEC
- sigaction_t act;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- act.sa_handler = SIG_IGN;
- if (sigaction(sig, &act, (sigaction_t *)0) == 0)
+ sigaction_t act;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = SIG_IGN;
+ if (sigaction(sig, &act, (sigaction_t *) 0) == 0)
#else
- if (signal(sig, SIG_IGN) != SIG_ERR)
+ if (signal(sig, SIG_IGN) != SIG_ERR)
#endif
- {
- SCREEN *scan = _nc_screen_chain;
- while(scan)
- {
- if (SP != 0
- && SP->_ofp != 0
- && isatty(fileno(SP->_ofp))) {
- SP->_cleanup = TRUE;
- SP->_outch = _nc_outch;
- }
- set_term(scan);
- endwin();
- if (SP)
- SP->_endwin = FALSE; /* in case we have an atexit! */
- scan = scan->_next_screen;
- }
+ {
+ SCREEN *scan = _nc_screen_chain;
+ while (scan) {
+ if (SP != 0
+ && SP->_ofp != 0
+ && isatty(fileno(SP->_ofp))) {
+ SP->_cleanup = TRUE;
+ SP->_outch = _nc_outch;
}
+ set_term(scan);
+ endwin();
+ if (SP)
+ SP->_endwin = FALSE; /* in case we have an atexit! */
+ scan = scan->_next_screen;
+ }
}
- exit(EXIT_FAILURE);
+ }
+ exit(EXIT_FAILURE);
}
#if USE_SIGWINCH
-static void sigwinch(int sig GCC_UNUSED)
+static void
+sigwinch(int sig GCC_UNUSED)
{
SCREEN *scan = _nc_screen_chain;
- while(scan)
- {
+ while (scan) {
scan->_sig_winch = TRUE;
scan = scan->_next_screen;
}
@@ -256,38 +256,40 @@ static void sigwinch(int sig GCC_UNUSED)
* handler.
*/
#if HAVE_SIGACTION || HAVE_SIGVEC
-static int CatchIfDefault(int sig, sigaction_t *act)
+static int
+CatchIfDefault(int sig, sigaction_t * act)
{
- sigaction_t old_act;
+ sigaction_t old_act;
- if (sigaction(sig, (sigaction_t *)0, &old_act) == 0
- && (old_act.sa_handler == SIG_DFL
+ if (sigaction(sig, (sigaction_t *) 0, &old_act) == 0
+ && (old_act.sa_handler == SIG_DFL
#if USE_SIGWINCH
|| (sig == SIGWINCH && old_act.sa_handler == SIG_IGN)
#endif
- )) {
- (void)sigaction(sig, act, (sigaction_t *)0);
- return TRUE;
- }
- return FALSE;
+ )) {
+ (void) sigaction(sig, act, (sigaction_t *) 0);
+ return TRUE;
+ }
+ return FALSE;
}
#else
-static int CatchIfDefault(int sig, RETSIGTYPE (*handler)(int))
+static int
+CatchIfDefault(int sig, RETSIGTYPE(*handler) (int))
{
- void (*ohandler)(int);
+ void (*ohandler) (int);
- ohandler = signal(sig, SIG_IGN);
- if (ohandler == SIG_DFL
+ ohandler = signal(sig, SIG_IGN);
+ if (ohandler == SIG_DFL
#if USE_SIGWINCH
- || (sig == SIGWINCH && ohandler == SIG_IGN)
+ || (sig == SIGWINCH && ohandler == SIG_IGN)
#endif
) {
- signal(sig, handler);
- return TRUE;
- } else {
- signal(sig, ohandler);
- return FALSE;
- }
+ signal(sig, handler);
+ return TRUE;
+ } else {
+ signal(sig, ohandler);
+ return FALSE;
+ }
}
#endif
@@ -302,69 +304,63 @@ static int CatchIfDefault(int sig, RETSIGTYPE (*handler)(int))
* The XSI document implies that we shouldn't keep the SIGTSTP handler if
* the caller later changes its mind, but that doesn't seem correct.
*/
-void _nc_signal_handler(bool enable)
+void
+_nc_signal_handler(bool enable)
{
-#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */
-static sigaction_t act, oact;
-static int ignore;
-
- if (!ignore)
- {
- if (!enable)
- {
- act.sa_handler = SIG_IGN;
- sigaction(SIGTSTP, &act, &oact);
- }
- else if (act.sa_handler)
- {
- sigaction(SIGTSTP, &oact, NULL);
- }
- else /*initialize */
- {
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
+#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */
+ static sigaction_t act, oact;
+ static int ignore;
+
+ if (!ignore) {
+ if (!enable) {
+ act.sa_handler = SIG_IGN;
+ sigaction(SIGTSTP, &act, &oact);
+ } else if (act.sa_handler) {
+ sigaction(SIGTSTP, &oact, NULL);
+ } else { /*initialize */
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
#if USE_SIGWINCH
- act.sa_handler = sigwinch;
- CatchIfDefault(SIGWINCH, &act);
+ act.sa_handler = sigwinch;
+ CatchIfDefault(SIGWINCH, &act);
#endif
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
+ act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
- act.sa_handler = cleanup;
- CatchIfDefault(SIGINT, &act);
- CatchIfDefault(SIGTERM, &act);
+ act.sa_handler = cleanup;
+ CatchIfDefault(SIGINT, &act);
+ CatchIfDefault(SIGTERM, &act);
- act.sa_handler = tstp;
- if (!CatchIfDefault(SIGTSTP, &act))
- ignore = TRUE;
- }
+ act.sa_handler = tstp;
+ if (!CatchIfDefault(SIGTSTP, &act))
+ ignore = TRUE;
}
+ }
#else /* !USE_SIGTSTP */
- if (enable)
- {
+ if (enable) {
#if HAVE_SIGACTION || HAVE_SIGVEC
- static sigaction_t act;
- sigemptyset(&act.sa_mask);
+ static sigaction_t act;
+ sigemptyset(&act.sa_mask);
#if USE_SIGWINCH
- act.sa_handler = sigwinch;
- CatchIfDefault(SIGWINCH, &act);
+ act.sa_handler = sigwinch;
+ CatchIfDefault(SIGWINCH, &act);
#endif
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
+ act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
- act.sa_handler = cleanup;
- CatchIfDefault(SIGINT, &act);
- CatchIfDefault(SIGTERM, &act);
+ act.sa_handler = cleanup;
+ CatchIfDefault(SIGINT, &act);
+ CatchIfDefault(SIGTERM, &act);
#else /* !(HAVE_SIGACTION || HAVE_SIGVEC) */
- CatchIfDefault(SIGINT, cleanup);
- CatchIfDefault(SIGTERM, cleanup);
+ CatchIfDefault(SIGINT, cleanup);
+ CatchIfDefault(SIGTERM, cleanup);
#if USE_SIGWINCH
- CatchIfDefault(SIGWINCH, sigwinch);
+ CatchIfDefault(SIGWINCH, sigwinch);
#endif
#endif /* !(HAVE_SIGACTION || HAVE_SIGVEC) */
- }
+ }
#endif /* !USE_SIGTSTP */
}
diff --git a/contrib/ncurses/ncurses/tty/lib_twait.c b/contrib/ncurses/ncurses/tty/lib_twait.c
index a21e2a16db0f..6d24d8ddc6cb 100644
--- a/contrib/ncurses/ncurses/tty/lib_twait.c
+++ b/contrib/ncurses/ncurses/tty/lib_twait.c
@@ -59,33 +59,34 @@
# endif
#endif
-MODULE_ID("$Id: lib_twait.c,v 1.37 2000/06/29 23:03:09 tom Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.39 2000/08/26 19:34:15 tom Exp $")
-static long _nc_gettime(bool first)
+static long
+_nc_gettime(bool first)
{
- long res;
+ long res;
#if HAVE_GETTIMEOFDAY
# define PRECISE_GETTIME 1
- static struct timeval t0;
- struct timeval t1;
- gettimeofday(&t1, (struct timezone *)0);
- if (first) {
- t0 = t1;
- }
- res = (t1.tv_sec - t0.tv_sec) * 1000
- + (t1.tv_usec - t0.tv_usec) / 1000;
+ static struct timeval t0;
+ struct timeval t1;
+ gettimeofday(&t1, (struct timezone *) 0);
+ if (first) {
+ t0 = t1;
+ }
+ res = (t1.tv_sec - t0.tv_sec) * 1000
+ + (t1.tv_usec - t0.tv_usec) / 1000;
#else
# define PRECISE_GETTIME 0
- static time_t t0;
- time_t t1 = time((time_t*)0);
- if (first) {
- t0 = t1;
- }
- res = (t1 - t0) * 1000;
+ static time_t t0;
+ time_t t1 = time((time_t *) 0);
+ if (first) {
+ t0 = t1;
+ }
+ res = (t1 - t0) * 1000;
#endif
- T(("%s time: %ld msec", first ? "get" : "elapsed", res));
- return res;
+ T(("%s time: %ld msec", first ? "get" : "elapsed", res));
+ return res;
}
/*
@@ -101,163 +102,164 @@ static long _nc_gettime(bool first)
* If the milliseconds given are -1, the wait blocks until activity on the
* descriptors.
*/
-int _nc_timed_wait(int mode, int milliseconds, int *timeleft)
+int
+_nc_timed_wait(int mode, int milliseconds, int *timeleft)
{
-int fd;
-int count;
+ int fd;
+ int count;
-int result;
+ int result;
#if USE_FUNC_POLL
-struct pollfd fds[2];
+ struct pollfd fds[2];
#elif defined(__BEOS__)
#elif HAVE_SELECT
-static fd_set set;
+ static fd_set set;
#endif
-long starttime, returntime;
+ long starttime, returntime;
- T(("start twait: %d milliseconds, mode: %d", milliseconds, mode));
+ T(("start twait: %d milliseconds, mode: %d", milliseconds, mode));
#if PRECISE_GETTIME
-retry:
+ retry:
#endif
- starttime = _nc_gettime(TRUE);
+ starttime = _nc_gettime(TRUE);
- count = 0;
+ count = 0;
#if USE_FUNC_POLL
- if (mode & 1) {
- fds[count].fd = SP->_ifd;
- fds[count].events = POLLIN;
- count++;
- }
- if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0) {
- fds[count].fd = fd;
- fds[count].events = POLLIN;
- count++;
- }
- result = poll(fds, count, milliseconds);
+ memset(fds, 0, sizeof(fds));
+ if (mode & 1) {
+ fds[count].fd = SP->_ifd;
+ fds[count].events = POLLIN;
+ count++;
+ }
+ if ((mode & 2)
+ && (fd = SP->_mouse_fd) >= 0) {
+ fds[count].fd = fd;
+ fds[count].events = POLLIN;
+ count++;
+ }
+ result = poll(fds, count, milliseconds);
#elif defined(__BEOS__)
- /*
- * BeOS's select() is declared in socket.h, so the configure script does
- * not see it. That's just as well, since that function works only for
- * sockets. This (using snooze and ioctl) was distilled from Be's patch
- * for ncurses which uses a separate thread to simulate select().
- *
- * FIXME: the return values from the ioctl aren't very clear if we get
- * interrupted.
- */
- result = 0;
- if (mode & 1) {
- bigtime_t d;
- bigtime_t useconds = milliseconds * 1000;
- int n, howmany;
+ /*
+ * BeOS's select() is declared in socket.h, so the configure script does
+ * not see it. That's just as well, since that function works only for
+ * sockets. This (using snooze and ioctl) was distilled from Be's patch
+ * for ncurses which uses a separate thread to simulate select().
+ *
+ * FIXME: the return values from the ioctl aren't very clear if we get
+ * interrupted.
+ */
+ result = 0;
+ if (mode & 1) {
+ bigtime_t d;
+ bigtime_t useconds = milliseconds * 1000;
+ int n, howmany;
- if (useconds == 0) /* we're here to go _through_ the loop */
- useconds = 1;
+ if (useconds == 0) /* we're here to go _through_ the loop */
+ useconds = 1;
- for (d = 0; d < useconds; d += 5000) {
- n = 0;
- howmany = ioctl(0, 'ichr', &n);
- if (howmany >= 0 && n > 0) {
- result = 1;
- break;
- }
- if (useconds > 1)
- snooze(5000);
- milliseconds -= 5;
- }
- } else if (milliseconds > 0) {
- snooze(milliseconds * 1000);
- milliseconds = 0;
+ for (d = 0; d < useconds; d += 5000) {
+ n = 0;
+ howmany = ioctl(0, 'ichr', &n);
+ if (howmany >= 0 && n > 0) {
+ result = 1;
+ break;
+ }
+ if (useconds > 1)
+ snooze(5000);
+ milliseconds -= 5;
}
+ } else if (milliseconds > 0) {
+ snooze(milliseconds * 1000);
+ milliseconds = 0;
+ }
#elif HAVE_SELECT
- /*
- * select() modifies the fd_set arguments; do this in the
- * loop.
- */
- FD_ZERO(&set);
+ /*
+ * select() modifies the fd_set arguments; do this in the
+ * loop.
+ */
+ FD_ZERO(&set);
- if (mode & 1) {
- FD_SET(SP->_ifd, &set);
- count = SP->_ifd + 1;
- }
- if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0) {
- FD_SET(fd, &set);
- count = max(fd, count) + 1;
- }
+ if (mode & 1) {
+ FD_SET(SP->_ifd, &set);
+ count = SP->_ifd + 1;
+ }
+ if ((mode & 2)
+ && (fd = SP->_mouse_fd) >= 0) {
+ FD_SET(fd, &set);
+ count = max(fd, count) + 1;
+ }
- if (milliseconds >= 0) {
- struct timeval ntimeout;
- ntimeout.tv_sec = milliseconds / 1000;
- ntimeout.tv_usec = (milliseconds % 1000) * 1000;
- result = select(count, &set, NULL, NULL, &ntimeout);
- } else {
- result = select(count, &set, NULL, NULL, NULL);
- }
+ if (milliseconds >= 0) {
+ struct timeval ntimeout;
+ ntimeout.tv_sec = milliseconds / 1000;
+ ntimeout.tv_usec = (milliseconds % 1000) * 1000;
+ result = select(count, &set, NULL, NULL, &ntimeout);
+ } else {
+ result = select(count, &set, NULL, NULL, NULL);
+ }
#endif
- returntime = _nc_gettime(FALSE);
+ returntime = _nc_gettime(FALSE);
- if (milliseconds >= 0)
- milliseconds -= (returntime - starttime);
+ if (milliseconds >= 0)
+ milliseconds -= (returntime - starttime);
#if PRECISE_GETTIME
- /*
- * If the timeout hasn't expired, and we've gotten no data,
- * this is probably a system where 'select()' needs to be left
- * alone so that it can complete. Make this process sleep,
- * then come back for more.
- */
- if (result == 0 && milliseconds > 100) {
- napms(100);
- milliseconds -= 100;
- goto retry;
- }
+ /*
+ * If the timeout hasn't expired, and we've gotten no data,
+ * this is probably a system where 'select()' needs to be left
+ * alone so that it can complete. Make this process sleep,
+ * then come back for more.
+ */
+ if (result == 0 && milliseconds > 100) {
+ napms(100);
+ milliseconds -= 100;
+ goto retry;
+ }
#endif
- /* return approximate time left in milliseconds */
- if (timeleft)
- *timeleft = milliseconds;
+ /* return approximate time left in milliseconds */
+ if (timeleft)
+ *timeleft = milliseconds;
- T(("end twait: returned %d (%d), remaining time %d msec",
- result, errno, milliseconds));
+ T(("end twait: returned %d (%d), remaining time %d msec",
+ result, errno, milliseconds));
- /*
- * Both 'poll()' and 'select()' return the number of file descriptors
- * that are active. Translate this back to the mask that denotes which
- * file-descriptors, so that we don't need all of this system-specific
- * code everywhere.
- */
- if (result != 0) {
- if (result > 0) {
- result = 0;
+ /*
+ * Both 'poll()' and 'select()' return the number of file descriptors
+ * that are active. Translate this back to the mask that denotes which
+ * file-descriptors, so that we don't need all of this system-specific
+ * code everywhere.
+ */
+ if (result != 0) {
+ if (result > 0) {
+ result = 0;
#if USE_FUNC_POLL
- for (count = 0; count < 2; count++) {
- if ((mode & (1 << count))
- && (fds[count].revents & POLLIN)) {
- result |= (1 << count);
- }
- }
+ for (count = 0; count < 2; count++) {
+ if ((mode & (1 << count))
+ && (fds[count].revents & POLLIN)) {
+ result |= (1 << count);
+ }
+ }
#elif defined(__BEOS__)
- result = 1; /* redundant, but simple */
+ result = 1; /* redundant, but simple */
#elif HAVE_SELECT
- if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0
- && FD_ISSET(fd, &set))
- result |= 2;
- if ((mode & 1)
- && FD_ISSET(SP->_ifd, &set))
- result |= 1;
+ if ((mode & 2)
+ && (fd = SP->_mouse_fd) >= 0
+ && FD_ISSET(fd, &set))
+ result |= 2;
+ if ((mode & 1)
+ && FD_ISSET(SP->_ifd, &set))
+ result |= 1;
#endif
- }
- else
- result = 0;
- }
+ } else
+ result = 0;
+ }
- return (result);
+ return (result);
}
diff --git a/contrib/ncurses/ncurses/tty/lib_vidattr.c b/contrib/ncurses/ncurses/tty/lib_vidattr.c
index 7cff22ec4b43..5022cbdde78a 100644
--- a/contrib/ncurses/ncurses/tty/lib_vidattr.c
+++ b/contrib/ncurses/ncurses/tty/lib_vidattr.c
@@ -64,7 +64,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_vidattr.c,v 1.27 2000/04/29 23:25:27 tom Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.33 2000/10/09 22:45:29 tom Exp $")
#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
@@ -78,7 +78,7 @@ MODULE_ID("$Id: lib_vidattr.c,v 1.27 2000/04/29 23:25:27 tom Exp $")
#define SetColorsIf(why,old_attr) \
if (can_color && (why)) { \
int old_pair = PAIR_NUMBER(old_attr); \
- T(("old pair = %d -- new pair = %d", old_pair, pair)); \
+ TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \
if ((pair != old_pair) \
|| (fix_pair0 && (pair == 0)) \
|| (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
@@ -95,7 +95,7 @@ vidputs(attr_t newmode, int (*outc) (int))
bool reverse = FALSE;
bool used_ncv = FALSE;
bool can_color = (SP == 0 || SP->_coloron);
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
#else
#define fix_pair0 FALSE
@@ -107,7 +107,7 @@ vidputs(attr_t newmode, int (*outc) (int))
if (SP)
previous_attr = SP->_current_attr;
- T(("previous attribute was %s", _traceattr(previous_attr)));
+ TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(previous_attr)));
#if !USE_XMC_SUPPORT
if ((SP != 0)
@@ -120,36 +120,29 @@ vidputs(attr_t newmode, int (*outc) (int))
* attributes, use the colors in preference.
*/
if (((newmode & A_COLOR) != 0
- || fix_pair0)
+ || fix_pair0)
&& (no_color_video > 0)) {
- /* *INDENT-OFF* */
- static const struct {
- attr_t video;
- unsigned bit;
- } table[] = {
- { A_STANDOUT, 1 },
- { A_UNDERLINE, 2 },
- { A_REVERSE, 4 },
- { A_BLINK, 8 },
- { A_DIM, 16 },
- { A_BOLD, 32 },
- { A_INVIS, 64 },
- { A_PROTECT, 128 },
- { A_ALTCHARSET, 256 },
- };
- /* *INDENT-ON* */
-
- size_t n;
- for (n = 0; n < SIZEOF(table); n++) {
- if ((table[n].bit & no_color_video)
- && (table[n].video & newmode)) {
- used_ncv = TRUE;
- if (table[n].video == A_REVERSE)
- reverse = TRUE;
- else
- newmode &= ~table[n].video;
- }
+ /*
+ * If we had chosen the A_xxx definitions to correspond to the
+ * no_color_video mask, we could simply shift it up and mask off the
+ * attributes. But we did not (actually copied Solaris' definitions).
+ * However, this is still simpler/faster than a lookup table.
+ *
+ * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK,
+ * A_DIM, A_BOLD which are 1:1 with no_color_video. The bits that
+ * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and
+ * A_ALTCHARSET (256) down 2 to line up. We use the NCURSES_BITS
+ * macro so this will work properly for the wide-character layout.
+ */
+ attr_t mask = NCURSES_BITS((no_color_video & 63)
+ | ((no_color_video & 192) << 1)
+ | ((no_color_video & 256) >> 2), 8);
+
+ if (mask & A_REVERSE && newmode & A_REVERSE) {
+ reverse = TRUE;
+ mask &= ~A_REVERSE;
}
+ newmode &= ~mask;
}
if (newmode == previous_attr)
@@ -172,7 +165,16 @@ vidputs(attr_t newmode, int (*outc) (int))
previous_attr &= ~A_ALTCHARSET;
}
if (previous_attr) {
- doPut(exit_attribute_mode);
+ if (exit_attribute_mode) {
+ doPut(exit_attribute_mode);
+ } else {
+ if (!SP || SP->_use_rmul) {
+ TurnOff(A_UNDERLINE, exit_underline_mode);
+ }
+ if (!SP || SP->_use_rmso) {
+ TurnOff(A_STANDOUT, exit_standout_mode);
+ }
+ }
previous_attr &= ~A_COLOR;
}
@@ -181,21 +183,21 @@ vidputs(attr_t newmode, int (*outc) (int))
if (turn_on || turn_off) {
TPUTS_TRACE("set_attributes");
tputs(tparm(set_attributes,
- (newmode & A_STANDOUT) != 0,
- (newmode & A_UNDERLINE) != 0,
- (newmode & A_REVERSE) != 0,
- (newmode & A_BLINK) != 0,
- (newmode & A_DIM) != 0,
- (newmode & A_BOLD) != 0,
- (newmode & A_INVIS) != 0,
- (newmode & A_PROTECT) != 0,
- (newmode & A_ALTCHARSET) != 0), 1, outc);
+ (newmode & A_STANDOUT) != 0,
+ (newmode & A_UNDERLINE) != 0,
+ (newmode & A_REVERSE) != 0,
+ (newmode & A_BLINK) != 0,
+ (newmode & A_DIM) != 0,
+ (newmode & A_BOLD) != 0,
+ (newmode & A_INVIS) != 0,
+ (newmode & A_PROTECT) != 0,
+ (newmode & A_ALTCHARSET) != 0), 1, outc);
previous_attr &= ~A_COLOR;
}
SetColorsIf((pair != 0) || fix_pair0, previous_attr);
} else {
- T(("turning %s off", _traceattr(turn_off)));
+ TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
@@ -214,7 +216,7 @@ vidputs(attr_t newmode, int (*outc) (int))
}
SetColorsIf((pair != 0) || fix_pair0, previous_attr);
- T(("turning %s on", _traceattr(turn_on)));
+ TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
/* *INDENT-OFF* */
TurnOn(A_ALTCHARSET, enter_alt_charset_mode);
TurnOn(A_BLINK, enter_blink_mode);
@@ -259,6 +261,7 @@ termattrs(void)
{
chtype attrs = A_NORMAL;
+ T((T_CALLED("termattrs()")));
if (enter_alt_charset_mode)
attrs |= A_ALTCHARSET;
@@ -289,5 +292,5 @@ termattrs(void)
if (SP->_coloron)
attrs |= A_COLOR;
- return (attrs);
+ returnChar(attrs);
}
diff --git a/contrib/ncurses/ncurses/tty/tty_update.c b/contrib/ncurses/ncurses/tty/tty_update.c
index b8670cd15f1d..298c11ed0a21 100644
--- a/contrib/ncurses/ncurses/tty/tty_update.c
+++ b/contrib/ncurses/ncurses/tty/tty_update.c
@@ -70,7 +70,7 @@
#include <term.h>
-MODULE_ID("$Id: tty_update.c,v 1.139 2000/06/24 23:45:17 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.146 2000/10/07 01:11:44 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -112,15 +112,24 @@ position_check(int expected_y, int expected_x, char *legend)
/* check to see if the real cursor position matches the virtual */
{
char buf[20];
+ char *s;
int y, x;
if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
return;
+ _nc_flush();
memset(buf, '\0', sizeof(buf));
putp("\033[6n"); /* only works on ANSI-compatibles */
_nc_flush();
- (void) read(0, buf, sizeof(buf) - 1);
+ *(s = buf) = 0;
+ do {
+ int ask = sizeof(buf) - 1 - (s - buf);
+ int got = read(0, s, ask);
+ if (got == 0)
+ break;
+ s += got;
+ } while (strchr(buf, 'R') == 0);
_tracef("probe returned %s", _nc_visbuf(buf));
/* try to interpret as a position report */
@@ -133,8 +142,9 @@ position_check(int expected_y, int expected_x, char *legend)
expected_y = y - 1;
if (y - 1 != expected_y || x - 1 != expected_x) {
beep();
+ tputs(tparm("\033[%d;%dH", expected_y + 1, expected_x + 1), 1, _nc_outch);
_tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
- y - 1, x - 1, expected_y, expected_x, legend);
+ y - 1, x - 1, expected_y, expected_x, legend);
} else {
_tracef("position matches OK in %s", legend);
}
@@ -156,7 +166,7 @@ GoTo(int const row, int const col)
chtype oldattr = SP->_current_attr;
TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
- row, col, SP->_cursrow, SP->_curscol));
+ row, col, SP->_cursrow, SP->_curscol));
position_check(SP->_cursrow, SP->_curscol, "GoTo");
@@ -168,7 +178,7 @@ GoTo(int const row, int const col)
if ((oldattr & A_ALTCHARSET)
|| (oldattr && !move_standout_mode)) {
TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
- oldattr, _traceattr(oldattr)));
+ oldattr, _traceattr(oldattr)));
vidattr(A_NORMAL);
}
@@ -187,8 +197,8 @@ PutAttrChar(chtype ch)
ch = ('`' | AttrOf(ch));
TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
- _tracechtype(ch),
- SP->_cursrow, SP->_curscol));
+ _tracechtype(ch),
+ SP->_cursrow, SP->_curscol));
UpdateAttrs(ch);
data = TextOf(ch);
if (SP->_outch != 0) {
@@ -295,7 +305,7 @@ PutCharLR(chtype const ch)
TPUTS_TRACE("enter_am_mode");
putp(enter_am_mode);
} else if ((enter_insert_mode && exit_insert_mode)
- || insert_character || parm_ich) {
+ || insert_character || parm_ich) {
GoTo(screen_lines - 1, screen_columns - 2);
callPutChar(ch);
GoTo(screen_lines - 1, screen_columns - 2);
@@ -361,7 +371,7 @@ can_clear_with(chtype ch)
if (!back_color_erase && SP->_coloron) {
if (ch & A_COLOR)
return FALSE;
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (!SP->_default_color)
return FALSE;
if (SP->_default_fg != C_MASK || SP->_default_bg != C_MASK)
@@ -427,10 +437,11 @@ EmitRange(const chtype * ntext, int num)
* don't bother moving cursor, since it can be the
* last update on the line.
*/
- if (runcount < num)
+ if (runcount < num) {
GoTo(SP->_cursrow, SP->_curscol + runcount);
- else
+ } else {
return 1; /* cursor stays in the middle */
+ }
} else if (repeat_char && runcount > SP->_rep_cost) {
bool wrap_possible = (SP->_curscol + runcount >= screen_columns);
int rep_count = runcount;
@@ -469,15 +480,15 @@ EmitRange(const chtype * ntext, int num)
*/
static int
PutRange(
- const chtype * otext,
- const chtype * ntext,
- int row,
- int first, int last)
+ const chtype * otext,
+ const chtype * ntext,
+ int row,
+ int first, int last)
{
int j, run;
TR(TRACE_CHARPUT, ("PutRange(%p, %p, %d, %d, %d)",
- otext, ntext, row, first, last));
+ otext, ntext, row, first, last));
if (otext != ntext
&& (last - first + 1) > SP->_inline_cost) {
@@ -597,8 +608,8 @@ doupdate(void)
continue;
}
- T(("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
- T(("...to %s", _traceattr(turnon)));
+ TR(TRACE_ATTRS, ("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
+ TR(TRACE_ATTRS, ("...to %s", _traceattr(turnon)));
/*
* If the attribute change location is a blank with a
@@ -628,15 +639,17 @@ doupdate(void)
for (; n < screen_columns; n++) {
if (AttrOf(newscr->_line[m].text[n]) == rattr) {
end_onscreen = TRUE;
- T(("Range attributed with %s ends at (%d, %d)",
- _traceattr(turnon), m, n));
+ TR(TRACE_ATTRS,
+ ("Range attributed with %s ends at (%d, %d)",
+ _traceattr(turnon), m, n));
goto foundit;
}
}
n = 0;
}
- T(("Range attributed with %s ends offscreen",
- _traceattr(turnon)));
+ TR(TRACE_ATTRS,
+ ("Range attributed with %s ends offscreen",
+ _traceattr(turnon)));
foundit:;
if (end_onscreen) {
@@ -649,8 +662,8 @@ doupdate(void)
* of span.
*/
while (n >= 0
- && TextOf(lastline[n]) == ' '
- && SAFE(AttrOf(lastline[n])))
+ && TextOf(lastline[n]) == ' '
+ && SAFE(AttrOf(lastline[n])))
lastline[n--] &= ~turnon;
/* check that there's enough room at end of span */
@@ -665,8 +678,9 @@ doupdate(void)
if (failed) {
int p, q = j;
- T(("Clearing %s beginning at (%d, %d)",
- _traceattr(turnon), i, j));
+ TR(TRACE_ATTRS,
+ ("Clearing %s beginning at (%d, %d)",
+ _traceattr(turnon), i, j));
/* turn off new attributes over span */
for (p = i; p < screen_lines; p++) {
@@ -679,8 +693,9 @@ doupdate(void)
}
foundend:;
} else {
- T(("Cookie space for %s found before (%d, %d)",
- _traceattr(turnon), i, j));
+ TR(TRACE_ATTRS,
+ ("Cookie space for %s found before (%d, %d)",
+ _traceattr(turnon), i, j));
/*
* back up the start of range so there's room
@@ -706,7 +721,7 @@ doupdate(void)
nonempty = 0;
if (curscr->_clear || newscr->_clear) { /* force refresh ? */
- T(("clearing and updating from scratch"));
+ TR(TRACE_UPDATE, ("clearing and updating from scratch"));
ClrUpdate();
curscr->_clear = FALSE; /* reset flag */
newscr->_clear = FALSE; /* reset flag */
@@ -724,7 +739,7 @@ doupdate(void)
nonempty = ClrBottom(nonempty);
- T(("Transforming lines, nonempty %d", nonempty));
+ TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
for (i = 0; i < nonempty; i++) {
/*
* Here is our line-breakout optimization.
@@ -785,10 +800,10 @@ doupdate(void)
#if USE_TRACE_TIMES
(void) times(&after);
TR(TRACE_TIMES,
- ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
- _nc_outchars,
- after.tms_stime - before.tms_stime,
- after.tms_utime - before.tms_utime));
+ ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
+ _nc_outchars,
+ after.tms_stime - before.tms_stime,
+ after.tms_utime - before.tms_utime));
#endif /* USE_TRACE_TIMES */
_nc_signal_handler(TRUE);
@@ -832,11 +847,11 @@ ClrUpdate(void)
chtype blank = ClrBlank(stdscr);
int nonempty = min(screen_lines, newscr->_maxy + 1);
- T(("ClrUpdate() called"));
+ TR(TRACE_UPDATE, ("ClrUpdate() called"));
ClearScreen(blank);
- T(("updating screen from scratch"));
+ TR(TRACE_UPDATE, ("updating screen from scratch"));
nonempty = ClrBottom(nonempty);
@@ -856,14 +871,15 @@ ClrToEOL(chtype blank, bool needclear)
int j;
if (curscr != 0
- && SP->_cursrow >= 0
- && SP->_curscol >= 0) {
+ && SP->_cursrow >= 0) {
for (j = SP->_curscol; j < screen_columns; j++) {
- chtype *cp = &(curscr->_line[SP->_cursrow].text[j]);
+ if (j >= 0) {
+ chtype *cp = &(curscr->_line[SP->_cursrow].text[j]);
- if (*cp != blank) {
- *cp = blank;
- needclear = TRUE;
+ if (*cp != blank) {
+ *cp = blank;
+ needclear = TRUE;
+ }
}
}
} else {
@@ -897,11 +913,9 @@ ClrToEOS(chtype blank)
row = SP->_cursrow;
col = SP->_curscol;
- {
- UpdateAttrs(blank);
- TPUTS_TRACE("clr_eos");
- tputs(clr_eos, screen_lines - row, _nc_outch);
- }
+ UpdateAttrs(blank);
+ TPUTS_TRACE("clr_eos");
+ tputs(clr_eos, screen_lines - row, _nc_outch);
while (col < screen_columns)
curscr->_line[row].text[col++] = blank;
@@ -922,53 +936,40 @@ ClrToEOS(chtype blank)
static int
ClrBottom(int total)
{
- static chtype *tstLine;
- static size_t lenLine;
-
int row;
- size_t col;
+ int col;
int top = total;
int last = min(screen_columns, newscr->_maxx + 1);
- size_t length = sizeof(chtype) * last;
- chtype blank = newscr->_line[total - 1].text[last - 1]; /* lower right char */
-
- if (!clr_eos || !can_clear_with(blank))
- return total;
-
- if ((tstLine == 0) || (last > (int) lenLine)) {
- tstLine = typeRealloc(chtype, last, tstLine);
- if (tstLine == 0)
- return total;
- lenLine = last;
- tstLine[0] = ~blank; /* force the fill below */
- }
- if (tstLine[0] != blank) {
- for (col = 0; col < lenLine; col++)
- tstLine[col] = blank;
- }
+ chtype blank = ClrBlank(stdscr);
+ bool ok;
- for (row = total - 1; row >= 0; row--) {
- if (memcmp(tstLine, newscr->_line[row].text, length))
- break;
- if (memcmp(tstLine, curscr->_line[row].text, length))
- top = row;
- }
+ if (clr_eos && can_clear_with(blank)) {
- /* don't use clr_eos for just one line if clr_eol available */
- if (top < total - 1 || (top < total && !clr_eol && !clr_bol)) {
- GoTo(top, 0);
- ClrToEOS(blank);
- total = top;
- if (SP->oldhash && SP->newhash) {
- for (row = top; row < screen_lines; row++)
- SP->oldhash[row] = SP->newhash[row];
+ for (row = total - 1; row >= 0; row--) {
+ for (col = 0, ok = TRUE; ok && col < last; col++) {
+ ok = (newscr->_line[row].text[col] == blank);
+ }
+ if (!ok)
+ break;
+
+ for (col = 0; ok && col < last; col++) {
+ ok = (curscr->_line[row].text[col] == blank);
+ }
+ if (!ok)
+ top = row;
+ }
+
+ /* don't use clr_eos for just one line if clr_eol available */
+ if (top < total - 1 || (top < total && !clr_eol && !clr_bol)) {
+ GoTo(top, 0);
+ ClrToEOS(blank);
+ total = top;
+ if (SP->oldhash && SP->newhash) {
+ for (row = top; row < screen_lines; row++)
+ SP->oldhash[row] = SP->newhash[row];
+ }
}
}
-#if NO_LEAKS
- if (tstLine != 0) {
- FreeAndNull(tstLine);
- }
-#endif
return total;
}
@@ -999,7 +1000,7 @@ TransformLine(int const lineno)
int n;
bool attrchanged = FALSE;
- T(("TransformLine(%d) called", lineno));
+ TR(TRACE_UPDATE, ("TransformLine(%d) called", lineno));
/* copy new hash value to old one */
if (SP->oldhash && SP->newhash)
@@ -1081,11 +1082,11 @@ TransformLine(int const lineno)
*/
if (TextOf(newLine[n]) == ' '
&& ((n > 0
- && xmc_turn_on(newLine[n - 1], newLine[n]))
+ && xmc_turn_on(newLine[n - 1], newLine[n]))
|| (n == 0
&& lineno > 0
&& xmc_turn_on(NEW(lineno - 1, screen_columns - 1),
- newLine[n])))) {
+ newLine[n])))) {
n = m;
}
@@ -1097,7 +1098,7 @@ TransformLine(int const lineno)
*/
if (TextOf(newLine[n]) != ' '
&& ((n + 1 < screen_columns
- && xmc_turn_off(newLine[n], newLine[n + 1]))
+ && xmc_turn_off(newLine[n], newLine[n + 1]))
|| (n + 1 >= screen_columns
&& lineno + 1 < screen_lines
&& xmc_turn_off(newLine[n], NEW(lineno + 1, 0))))) {
@@ -1112,7 +1113,7 @@ TransformLine(int const lineno)
/* find the first differing character */
while (firstChar < screen_columns &&
- newLine[firstChar] == oldLine[firstChar])
+ newLine[firstChar] == oldLine[firstChar])
firstChar++;
/* if there wasn't one, we're done */
@@ -1158,15 +1159,15 @@ TransformLine(int const lineno)
nLastChar = screen_columns - 1;
while (nLastChar > firstChar
- && newLine[nLastChar] == oldLine[nLastChar])
+ && newLine[nLastChar] == oldLine[nLastChar])
nLastChar--;
if (nLastChar >= firstChar) {
GoTo(lineno, firstChar);
PutRange(oldLine, newLine, lineno, firstChar, nLastChar);
memcpy(oldLine + firstChar,
- newLine + firstChar,
- (nLastChar - firstChar + 1) * sizeof(chtype));
+ newLine + firstChar,
+ (nLastChar - firstChar + 1) * sizeof(chtype));
}
return;
}
@@ -1188,8 +1189,8 @@ TransformLine(int const lineno)
PutChar(newLine[firstChar]);
ClrToEOL(blank, FALSE);
} else if ((nLastChar != oLastChar)
- && (newLine[nLastChar] != oldLine[oLastChar]
- || !(_nc_idcok && has_ic()))) {
+ && (newLine[nLastChar] != oldLine[oLastChar]
+ || !(_nc_idcok && has_ic()))) {
GoTo(lineno, firstChar);
if ((oLastChar - nLastChar) > SP->_el_cost) {
if (PutRange(oldLine, newLine, lineno, firstChar, nLastChar))
@@ -1234,7 +1235,7 @@ TransformLine(int const lineno)
if (DelCharCost(oLastChar - nLastChar)
> SP->_el_cost + nLastNonblank - (n + 1)) {
if (PutRange(oldLine, newLine, lineno,
- n + 1, nLastNonblank))
+ n + 1, nLastNonblank))
GoTo(lineno, nLastNonblank + 1);
ClrToEOL(blank, FALSE);
} else {
@@ -1256,8 +1257,8 @@ TransformLine(int const lineno)
/* update the code's internal representation */
if (screen_columns > firstChar)
memcpy(oldLine + firstChar,
- newLine + firstChar,
- (screen_columns - firstChar) * sizeof(chtype));
+ newLine + firstChar,
+ (screen_columns - firstChar) * sizeof(chtype));
}
/*
@@ -1273,9 +1274,9 @@ ClearScreen(chtype blank)
int i, j;
bool fast_clear = (clear_screen || clr_eos || clr_eol);
- T(("ClearScreen() called"));
+ TR(TRACE_UPDATE, ("ClearScreen() called"));
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (SP->_coloron
&& !SP->_default_color) {
_nc_do_color(COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
@@ -1302,18 +1303,18 @@ ClearScreen(chtype blank)
} else if (clr_eol) {
SP->_cursrow = SP->_curscol = -1;
+ UpdateAttrs(blank);
for (i = 0; i < screen_lines; i++) {
GoTo(i, 0);
- UpdateAttrs(blank);
TPUTS_TRACE("clr_eol");
putp(clr_eol);
}
GoTo(0, 0);
}
} else {
+ UpdateAttrs(blank);
for (i = 0; i < screen_lines; i++) {
GoTo(i, 0);
- UpdateAttrs(blank);
for (j = 0; j < screen_columns; j++)
PutChar(blank);
}
@@ -1325,7 +1326,7 @@ ClearScreen(chtype blank)
curscr->_line[i].text[j] = blank;
}
- T(("screen cleared"));
+ TR(TRACE_UPDATE, ("screen cleared"));
}
/*
@@ -1338,7 +1339,7 @@ ClearScreen(chtype blank)
static void
InsStr(chtype * line, int count)
{
- T(("InsStr(%p,%d) called", line, count));
+ TR(TRACE_UPDATE, ("InsStr(%p,%d) called", line, count));
/* Prefer parm_ich as it has the smallest cost - no need to shift
* the whole line on each character. */
@@ -1393,7 +1394,8 @@ DelChar(int count)
{
int n;
- T(("DelChar(%d) called, position = (%d,%d)", count, newscr->_cury, newscr->_curx));
+ TR(TRACE_UPDATE, ("DelChar(%d) called, position = (%d,%d)", count,
+ newscr->_cury, newscr->_curx));
if (parm_dch) {
TPUTS_TRACE("parm_dch");
@@ -1494,7 +1496,7 @@ scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtype blank)
} else
return ERR;
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (FILL_BCE()) {
for (i = 0; i < n; i++) {
GoTo(bot - i, 0);
@@ -1550,7 +1552,7 @@ scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chtype blank)
} else
return ERR;
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (FILL_BCE()) {
for (i = 0; i < n; i++) {
GoTo(top + i, 0);
@@ -1630,18 +1632,11 @@ _nc_scrolln(int n, int top, int bot, int maxy)
* Explicitly clear if stuff pushed off top of region might
* be saved by the terminal.
*/
- if (non_dest_scroll_region || (memory_above && top == 0)) {
- for (i = 0; i < n; i++) {
- GoTo(i, 0);
- ClrToEOL(BLANK, FALSE);
- }
- }
-
res = scroll_csr_forward(n, top, bot, 0, maxy, blank);
if (res == ERR && change_scroll_region) {
if ((((n == 1 && scroll_forward) || parm_index)
- && (SP->_cursrow == bot || SP->_cursrow == bot - 1))
+ && (SP->_cursrow == bot || SP->_cursrow == bot - 1))
&& save_cursor && restore_cursor) {
cursor_saved = TRUE;
TPUTS_TRACE("save_cursor");
@@ -1665,23 +1660,24 @@ _nc_scrolln(int n, int top, int bot, int maxy)
if (res == ERR && _nc_idlok)
res = scroll_idl(n, top, bot - n + 1, blank);
- } else { /* (n < 0) - scroll down (backward) */
+
/*
- * Do explicit clear to end of region if it's possible that the
- * terminal might hold on to stuff we push off the end.
+ * Clear the newly shifted-in text.
*/
- if (non_dest_scroll_region || (memory_below && bot == maxy)) {
+ if (res != ERR
+ && (non_dest_scroll_region || (memory_below && bot == maxy))) {
if (bot == maxy && clr_eos) {
- GoTo(maxy + n, 0);
+ GoTo(bot - n, 0);
ClrToEOS(BLANK);
- } else if (clr_eol) {
- for (i = 0; i < -n; i++) {
- GoTo(maxy + n + i, 0);
+ } else {
+ for (i = 0; i < n; i++) {
+ GoTo(bot - i, 0);
ClrToEOL(BLANK, FALSE);
}
}
}
+ } else { /* (n < 0) - scroll down (backward) */
res = scroll_csr_backward(-n, top, bot, 0, maxy, blank);
if (res == ERR && change_scroll_region) {
@@ -1709,6 +1705,17 @@ _nc_scrolln(int n, int top, int bot, int maxy)
if (res == ERR && _nc_idlok)
res = scroll_idl(-n, bot + n + 1, top, blank);
+
+ /*
+ * Clear the newly shifted-in text.
+ */
+ if (res != ERR
+ && (non_dest_scroll_region || (memory_above && top == 0))) {
+ for (i = 0; i < -n; i++) {
+ GoTo(i + top, 0);
+ ClrToEOL(BLANK, FALSE);
+ }
+ }
}
if (res == ERR)
@@ -1759,7 +1766,7 @@ void
_nc_screen_wrap(void)
{
UpdateAttrs(A_NORMAL);
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (SP->_coloron
&& !SP->_default_color) {
SP->_default_color = TRUE;
@@ -1786,7 +1793,7 @@ _nc_do_xmc_glitch(attr_t previous)
SP->_curscol += magic_cookie_glitch;
if (SP->_curscol >= SP->_columns)
wrap_cursor();
- T(("bumped to %d,%d after cookie", SP->_cursrow, SP->_curscol));
+ TR(TRACE_UPDATE, ("bumped to %d,%d after cookie", SP->_cursrow, SP->_curscol));
}
chg >>= 1;
}