aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2000-07-03 09:24:12 +0000
committerPeter Wemm <peter@FreeBSD.org>2000-07-03 09:24:12 +0000
commit15589c42fa2774d2f8ee650f4f31eb8d3a861316 (patch)
tree27e79485df3c9195e6fe58960df47f675f41f1e9 /contrib/ncurses/ncurses
parent6b9085fd58b7602b14be0cd2059285baa764a7ee (diff)
downloadsrc-15589c42fa2774d2f8ee650f4f31eb8d3a861316.tar.gz
src-15589c42fa2774d2f8ee650f4f31eb8d3a861316.zip
Import the most recent ncurses 5.1 prerelease (20000701).
Mostly this is intended to resolve the trace() badness once and for all. Obtained from: ftp://dickey.his.com/ncurses/
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=62449
Diffstat (limited to 'contrib/ncurses/ncurses')
-rw-r--r--contrib/ncurses/ncurses/Makefile.in9
-rw-r--r--contrib/ncurses/ncurses/base/MKunctrl.awk4
-rw-r--r--contrib/ncurses/ncurses/base/lib_addch.c353
-rw-r--r--contrib/ncurses/ncurses/base/lib_addstr.c88
-rw-r--r--contrib/ncurses/ncurses/base/lib_box.c137
-rw-r--r--contrib/ncurses/ncurses/base/lib_clrbot.c47
-rw-r--r--contrib/ncurses/ncurses/base/lib_clreol.c78
-rw-r--r--contrib/ncurses/ncurses/base/lib_color.c589
-rw-r--r--contrib/ncurses/ncurses/base/lib_dft_fgbg.c43
-rw-r--r--contrib/ncurses/ncurses/base/lib_freeall.c123
-rw-r--r--contrib/ncurses/ncurses/base/lib_getch.c565
-rw-r--r--contrib/ncurses/ncurses/base/lib_hline.c49
-rw-r--r--contrib/ncurses/ncurses/base/lib_insstr.c56
-rw-r--r--contrib/ncurses/ncurses/base/lib_mouse.c484
-rw-r--r--contrib/ncurses/ncurses/base/lib_move.c32
-rw-r--r--contrib/ncurses/ncurses/base/lib_newterm.c227
-rw-r--r--contrib/ncurses/ncurses/base/lib_newwin.c395
-rw-r--r--contrib/ncurses/ncurses/base/lib_nl.c32
-rw-r--r--contrib/ncurses/ncurses/base/lib_pad.c408
-rw-r--r--contrib/ncurses/ncurses/base/lib_refresh.c236
-rw-r--r--contrib/ncurses/ncurses/base/lib_scroll.c124
-rw-r--r--contrib/ncurses/ncurses/base/lib_scrreg.c34
-rw-r--r--contrib/ncurses/ncurses/base/lib_set_term.c472
-rw-r--r--contrib/ncurses/ncurses/base/lib_slk.c6
-rw-r--r--contrib/ncurses/ncurses/base/lib_vline.c55
-rw-r--r--contrib/ncurses/ncurses/base/version.c7
-rw-r--r--contrib/ncurses/ncurses/base/wresize.c217
-rw-r--r--contrib/ncurses/ncurses/curses.priv.h85
-rw-r--r--contrib/ncurses/ncurses/llib-lncurses27
-rw-r--r--contrib/ncurses/ncurses/modules10
-rw-r--r--contrib/ncurses/ncurses/tinfo/add_tries.c131
-rw-r--r--contrib/ncurses/ncurses/tinfo/alloc_entry.c216
-rw-r--r--contrib/ncurses/ncurses/tinfo/alloc_ttype.c188
-rw-r--r--contrib/ncurses/ncurses/tinfo/captoinfo.c604
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_error.c10
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_parse.c423
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_scan.c904
-rw-r--r--contrib/ncurses/ncurses/tinfo/free_ttype.c3
-rw-r--r--contrib/ncurses/ncurses/tinfo/init_keytry.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_acs.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_cur_term.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_napms.c49
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_options.c286
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_raw.c199
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_setup.c450
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termcap.c148
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_ti.c94
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tputs.c389
-rw-r--r--contrib/ncurses/ncurses/tinfo/make_keys.c4
-rw-r--r--contrib/ncurses/ncurses/tinfo/parse_entry.c481
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_entry.c387
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_termcap.c1424
-rw-r--r--contrib/ncurses/ncurses/tinfo/write_entry.c652
-rw-r--r--contrib/ncurses/ncurses/trace/lib_trace.c258
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracebits.c193
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracechr.c24
-rw-r--r--contrib/ncurses/ncurses/tty/hashmap.c4
-rw-r--r--contrib/ncurses/ncurses/tty/lib_mvcur.c683
-rw-r--r--contrib/ncurses/ncurses/tty/lib_tstp.c3
-rw-r--r--contrib/ncurses/ncurses/tty/lib_twait.c7
-rw-r--r--contrib/ncurses/ncurses/tty/lib_vidattr.c331
-rw-r--r--contrib/ncurses/ncurses/tty/tty_display.h9
-rw-r--r--contrib/ncurses/ncurses/tty/tty_update.c1883
63 files changed, 7914 insertions, 7533 deletions
diff --git a/contrib/ncurses/ncurses/Makefile.in b/contrib/ncurses/ncurses/Makefile.in
index bed5ee95d2c2..41b66f69732b 100644
--- a/contrib/ncurses/ncurses/Makefile.in
+++ b/contrib/ncurses/ncurses/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.63 1999/09/01 22:35:53 tom Exp $
+# $Id: Makefile.in,v 1.66 2000/05/28 01:39:56 tom Exp $
##############################################################################
-# Copyright (c) 1998 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 "Software"), #
@@ -129,7 +129,7 @@ AUTO_SRC = \
./names.c \
./unctrl.c
-TEST_DEPS = @LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
+TEST_DEPS = ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
TEST_ARGS = -L../lib -lncurses@DFT_ARG_SUFFIX@
TEST_LDFLAGS = @LD_MODEL@ $(TEST_ARGS) @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
@@ -145,7 +145,8 @@ tinfo = $(srcdir)/tinfo
trace = $(srcdir)/trace
################################################################################
-all :: $(AUTO_SRC) ../lib $(LIBRARIES)
+all \
+libs :: $(AUTO_SRC) ../lib $(LIBRARIES)
sources: $(AUTO_SRC)
diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk
index 0f4419242a99..3d5b25637d75 100644
--- a/contrib/ncurses/ncurses/base/MKunctrl.awk
+++ b/contrib/ncurses/ncurses/base/MKunctrl.awk
@@ -1,4 +1,4 @@
-# $Id: MKunctrl.awk,v 1.6 1998/06/06 18:18:07 tom Exp $
+# $Id: MKunctrl.awk,v 1.7 2000/04/01 19:49:26 tom Exp $
##############################################################################
# Copyright (c) 1998 Free Software Foundation, Inc. #
# #
@@ -50,6 +50,8 @@ END {
printf "\"^\\%03o\"", ch + 64
} else if (ch == 127) {
printf "\"^?\""
+ } else if (ch >= 128 && ch < 160) {
+ printf "\"~\\%03o\"", ch - 64
} else {
printf "\"\\%03o\"", ch
gap = gap " "
diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c
index 101d75ef29a9..69c17c34709b 100644
--- a/contrib/ncurses/ncurses/base/lib_addch.c
+++ b/contrib/ncurses/ncurses/base/lib_addch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.42 1999/07/24 20:01:05 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.44 2000/05/20 21:13:11 tom Exp $")
/*
* Ugly microtweaking alert. Everything from here to end of module is
@@ -56,40 +56,40 @@ MODULE_ID("$Id: lib_addch.c,v 1.42 1999/07/24 20:01:05 tom Exp $")
/* Return bit mask for clearing color pair number if given ch has color */
#define COLOR_MASK(ch) (~(chtype)((ch)&A_COLOR?A_COLOR:0))
-static inline chtype render_char(WINDOW *win, chtype ch)
+static inline chtype
+render_char(WINDOW *win, chtype ch)
/* compute a rendition of the given char correct for the current context */
{
- chtype a = win->_attrs;
-
- if (ch == ' ')
- {
- /* color in attrs has precedence over bkgd */
- ch = a | (win->_bkgd & COLOR_MASK(a));
- }
- else
- {
- /* color in attrs has precedence over bkgd */
- a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a);
- /* color in ch has precedence */
- ch |= (a & COLOR_MASK(ch));
- }
-
- TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd,
- win->_attrs, ch));
-
- return(ch);
+ chtype a = win->_attrs;
+
+ if (ch == ' ') {
+ /* color in attrs has precedence over bkgd */
+ ch = a | (win->_bkgd & COLOR_MASK(a));
+ } else {
+ /* color in attrs has precedence over bkgd */
+ a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a);
+ /* color in ch has precedence */
+ ch |= (a & COLOR_MASK(ch));
+ }
+
+ TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd,
+ win->_attrs, ch));
+
+ return (ch);
}
-chtype _nc_background(WINDOW *win)
+chtype
+_nc_background(WINDOW *win)
/* make render_char() visible while still allowing us to inline it below */
{
- return (win->_bkgd);
+ return (win->_bkgd);
}
-chtype _nc_render(WINDOW *win, chtype ch)
+chtype
+_nc_render(WINDOW *win, chtype ch)
/* make render_char() visible while still allowing us to inline it below */
{
- return render_char(win, ch);
+ return render_char(win, ch);
}
/* check if position is legal; if not, return error */
@@ -105,149 +105,152 @@ chtype _nc_render(WINDOW *win, chtype ch)
return(ERR); \
}
#else
-#define CHECK_POSITION(win, x, y) /* nothing */
+#define CHECK_POSITION(win, x, y) /* nothing */
#endif
-static inline
-int waddch_literal(WINDOW *win, chtype ch)
+static inline int
+waddch_literal(WINDOW *win, chtype ch)
{
- int x;
- struct ldat *line;
+ int x;
+ struct ldat *line;
+
+ x = win->_curx;
+
+ CHECK_POSITION(win, x, win->_cury);
+
+ /*
+ * If we're trying to add a character at the lower-right corner more
+ * than once, fail. (Moving the cursor will clear the flag).
+ */
+#if 0 /* Solaris 2.6 allows updating the corner more than once */
+ if (win->_flags & _WRAPPED) {
+ if (x >= win->_maxx)
+ return (ERR);
+ win->_flags &= ~_WRAPPED;
+ }
+#endif
+
+ ch = render_char(win, ch);
+ TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
- x = win->_curx;
+ line = win->_line + win->_cury;
- CHECK_POSITION(win, x, win->_cury);
+ CHANGED_CELL(line, x);
+ line->text[x++] = ch;
+
+ TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch)));
+ if (x > win->_maxx) {
/*
- * If we're trying to add a character at the lower-right corner more
- * than once, fail. (Moving the cursor will clear the flag).
+ * The _WRAPPED flag is useful only for telling an application that
+ * we've just wrapped the cursor. We don't do anything with this flag
+ * except set it when wrapping, and clear it whenever we move the
+ * cursor. If we try to wrap at the lower-right corner of a window, we
+ * cannot move the cursor (since that wouldn't be legal). So we return
+ * an error (which is what SVr4 does). Unlike SVr4, we can
+ * successfully add a character to the lower-right corner (Solaris 2.6
+ * does this also, however).
*/
- if (win->_flags & _WRAPPED) {
- if (x >= win->_maxx)
- return (ERR);
- win->_flags &= ~_WRAPPED;
- }
-
- ch = render_char(win, ch);
- TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
-
- line = win->_line+win->_cury;
-
- CHANGED_CELL(line,x);
-
- line->text[x++] = ch;
-
- TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch)));
- if (x > win->_maxx) {
- /*
- * The _WRAPPED flag is useful only for telling an application
- * that we've just wrapped the cursor. We don't do anything
- * with this flag except set it when wrapping, and clear it
- * whenever we move the cursor. If we try to wrap at the
- * lower-right corner of a window, we cannot move the cursor
- * (since that wouldn't be legal). So we return an error
- * (which is what SVr4 does). Unlike SVr4, we can successfully
- * add a character to the lower-right corner.
- */
- win->_flags |= _WRAPPED;
- if (++win->_cury > win->_regbottom) {
- win->_cury = win->_regbottom;
- win->_curx = win->_maxx;
- if (!win->_scroll)
- return (ERR);
- scroll(win);
- }
- win->_curx = 0;
- return (OK);
+ win->_flags |= _WRAPPED;
+ if (++win->_cury > win->_regbottom) {
+ win->_cury = win->_regbottom;
+ win->_curx = win->_maxx;
+ if (!win->_scroll)
+ return (ERR);
+ scroll(win);
}
- win->_curx = x;
- return OK;
+ win->_curx = 0;
+ return (OK);
+ }
+ win->_curx = x;
+ return OK;
}
-static inline
-int waddch_nosync(WINDOW *win, const chtype ch)
+static inline int
+waddch_nosync(WINDOW *win, const chtype ch)
/* the workhorse function -- add a character to the given window */
{
- int x, y;
- int t = 0;
- const char *s = 0;
-
- if ((ch & A_ALTCHARSET)
- || ((t = TextOf(ch)) > 127)
- || ((s = unctrl(t))[1] == 0))
- return waddch_literal(win, ch);
-
- x = win->_curx;
- y = win->_cury;
-
- switch (t) {
- case '\t':
- x += (TABSIZE-(x%TABSIZE));
-
- /*
- * Space-fill the tab on the bottom line so that we'll get the
- * "correct" cursor position.
- */
- if ((! win->_scroll && (y == win->_regbottom))
- || (x <= win->_maxx)) {
- chtype blank = (' ' | AttrOf(ch));
- while (win->_curx < x) {
- if (waddch_literal(win, blank) == ERR)
- return(ERR);
- }
- break;
- } else {
- wclrtoeol(win);
- win->_flags |= _WRAPPED;
- if (++y > win->_regbottom) {
- x = win->_maxx;
- y--;
- if (win->_scroll) {
- scroll(win);
- x = 0;
- }
- } else {
- x = 0;
- }
- }
- break;
- case '\n':
- wclrtoeol(win);
- if (++y > win->_regbottom) {
- y--;
- if (win->_scroll)
- scroll(win);
- else
- return (ERR);
+ int x, y;
+ int t = 0;
+ const char *s = 0;
+
+ if ((ch & A_ALTCHARSET)
+ || ((t = TextOf(ch)) > 127)
+ || ((s = unctrl(t))[1] == 0))
+ return waddch_literal(win, ch);
+
+ x = win->_curx;
+ y = win->_cury;
+
+ switch (t) {
+ case '\t':
+ x += (TABSIZE - (x % TABSIZE));
+
+ /*
+ * Space-fill the tab on the bottom line so that we'll get the
+ * "correct" cursor position.
+ */
+ if ((!win->_scroll && (y == win->_regbottom))
+ || (x <= win->_maxx)) {
+ chtype blank = (' ' | AttrOf(ch));
+ while (win->_curx < x) {
+ if (waddch_literal(win, blank) == ERR)
+ return (ERR);
+ }
+ break;
+ } else {
+ wclrtoeol(win);
+ win->_flags |= _WRAPPED;
+ if (++y > win->_regbottom) {
+ x = win->_maxx;
+ y--;
+ if (win->_scroll) {
+ scroll(win);
+ x = 0;
}
- /* FALLTHRU */
- case '\r':
+ } else {
x = 0;
- win->_flags &= ~_WRAPPED;
- break;
- case '\b':
- if (x == 0)
- return (OK);
- x--;
- win->_flags &= ~_WRAPPED;
- break;
- default:
- while (*s)
- if (waddch_literal(win, (*s++)|AttrOf(ch)) == ERR)
- return ERR;
- return(OK);
+ }
}
-
- win->_curx = x;
- win->_cury = y;
-
- return(OK);
+ break;
+ case '\n':
+ wclrtoeol(win);
+ if (++y > win->_regbottom) {
+ y--;
+ if (win->_scroll)
+ scroll(win);
+ else
+ return (ERR);
+ }
+ /* FALLTHRU */
+ case '\r':
+ x = 0;
+ win->_flags &= ~_WRAPPED;
+ break;
+ case '\b':
+ if (x == 0)
+ return (OK);
+ x--;
+ win->_flags &= ~_WRAPPED;
+ break;
+ default:
+ while (*s)
+ if (waddch_literal(win, (*s++) | AttrOf(ch)) == ERR)
+ return ERR;
+ return (OK);
+ }
+
+ win->_curx = x;
+ win->_cury = y;
+
+ return (OK);
}
-int _nc_waddch_nosync(WINDOW *win, const chtype c)
+int
+_nc_waddch_nosync(WINDOW *win, const chtype c)
/* export copy of waddch_nosync() so the string-put functions can use it */
{
- return(waddch_nosync(win, c));
+ return (waddch_nosync(win, c));
}
/*
@@ -258,36 +261,38 @@ int _nc_waddch_nosync(WINDOW *win, const chtype c)
/* These are actual entry points */
-int waddch(WINDOW *win, const chtype ch)
+int
+waddch(WINDOW *win, const chtype ch)
{
- int code = ERR;
+ int code = ERR;
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, _tracechtype(ch)));
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win,
+ _tracechtype(ch)));
- if (win && (waddch_nosync(win, ch) != ERR))
- {
- _nc_synchook(win);
- code = OK;
- }
+ if (win && (waddch_nosync(win, ch) != ERR)) {
+ _nc_synchook(win);
+ code = OK;
+ }
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code));
- return(code);
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
+ return (code);
}
-int wechochar(WINDOW *win, const chtype ch)
+int
+wechochar(WINDOW *win, const chtype ch)
{
- int code = ERR;
-
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, _tracechtype(ch)));
-
- if (win && (waddch_nosync(win, ch) != ERR))
- {
- bool save_immed = win->_immed;
- win->_immed = TRUE;
- _nc_synchook(win);
- win->_immed = save_immed;
- code = OK;
- }
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code));
- return(code);
+ int code = ERR;
+
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win,
+ _tracechtype(ch)));
+
+ if (win && (waddch_nosync(win, ch) != ERR)) {
+ bool save_immed = win->_immed;
+ win->_immed = TRUE;
+ _nc_synchook(win);
+ win->_immed = save_immed;
+ code = OK;
+ }
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
+ return (code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_addstr.c b/contrib/ncurses/ncurses/base/lib_addstr.c
index 9ac55e42aba7..0a72165910f3 100644
--- a/contrib/ncurses/ncurses/base/lib_addstr.c
+++ b/contrib/ncurses/ncurses/base/lib_addstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -40,64 +40,64 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_addstr.c,v 1.16 1998/06/28 00:38:29 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.17 2000/04/29 21:15:55 tom Exp $")
int
waddnstr(WINDOW *win, const char *const astr, int n)
{
-unsigned const char *str = (unsigned const char *)astr;
-int code = ERR;
+ unsigned const char *str = (unsigned const char *) astr;
+ int code = ERR;
- 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, ("str is not null"));
- code = OK;
- if (n < 0)
- n = (int)strlen(astr);
-
- while((n-- > 0) && (*str != '\0')) {
+ 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, ("str is not null"));
+ code = OK;
+ if (n < 0)
+ n = (int) strlen(astr);
+
+ while ((n-- > 0) && (*str != '\0')) {
TR(TRACE_VIRTPUT, ("*str = %#x", *str));
- if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) {
- code = ERR;
- break;
+ if (_nc_waddch_nosync(win, (chtype) * str++) == ERR) {
+ code = ERR;
+ break;
}
- }
- _nc_synchook(win);
}
- TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
- returnCode(code);
+ _nc_synchook(win);
+ }
+ TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
+ returnCode(code);
}
int
-waddchnstr(WINDOW *win, const chtype *const astr, int n)
+waddchnstr(WINDOW *win, const chtype * const astr, int n)
{
-short y = win->_cury;
-short x = win->_curx;
-int code = OK;
-struct ldat *line;
+ NCURSES_SIZE_T y = win->_cury;
+ NCURSES_SIZE_T x = win->_curx;
+ int code = OK;
+ struct ldat *line;
- T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
+ T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
- if (!win)
- returnCode(ERR);
+ if (!win)
+ returnCode(ERR);
- if (n < 0) {
- const chtype *str;
- n = 0;
- for (str=(const chtype *)astr; *str!=0; str++)
- n++;
- }
- if (n > win->_maxx - x + 1)
- n = win->_maxx - x + 1;
- if (n == 0)
- returnCode(code);
+ if (n < 0) {
+ const chtype *str;
+ n = 0;
+ for (str = (const chtype *) astr; *str != 0; str++)
+ n++;
+ }
+ if (n > win->_maxx - x + 1)
+ n = win->_maxx - x + 1;
+ if (n == 0)
+ returnCode(code);
- line = &(win->_line[y]);
- memcpy(line->text+x, astr, n*sizeof(*astr));
- CHANGED_RANGE(line, x, x+n-1);
+ line = &(win->_line[y]);
+ memcpy(line->text + x, astr, n * sizeof(*astr));
+ CHANGED_RANGE(line, x, x + n - 1);
- _nc_synchook(win);
- returnCode(code);
+ _nc_synchook(win);
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_box.c b/contrib/ncurses/ncurses/base/lib_box.c
index bcd96416f954..8a682585b560 100644
--- a/contrib/ncurses/ncurses/base/lib_box.c
+++ b/contrib/ncurses/ncurses/base/lib_box.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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_box.c
**
@@ -42,69 +40,80 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_box.c,v 1.10 1998/02/11 12:13:56 tom Exp $")
+MODULE_ID("$Id: lib_box.c,v 1.11 2000/04/29 21:12:37 tom Exp $")
-int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
- chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
+int
+wborder(WINDOW *win,
+ chtype ls, chtype rs, chtype ts, chtype bs,
+ chtype tl, chtype tr, chtype bl, chtype br)
{
-short i;
-short endx, endy;
+ NCURSES_SIZE_T i;
+ NCURSES_SIZE_T endx, endy;
T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
- win,
- _tracechtype2(1,ls),
- _tracechtype2(2,rs),
- _tracechtype2(3,ts),
- _tracechtype2(4,bs),
- _tracechtype2(5,tl),
- _tracechtype2(6,tr),
- _tracechtype2(7,bl),
- _tracechtype2(8,br)));
-
- if (!win)
- returnCode(ERR);
-
- if (ls == 0) ls = ACS_VLINE;
- if (rs == 0) rs = ACS_VLINE;
- if (ts == 0) ts = ACS_HLINE;
- if (bs == 0) bs = ACS_HLINE;
- if (tl == 0) tl = ACS_ULCORNER;
- if (tr == 0) tr = ACS_URCORNER;
- if (bl == 0) bl = ACS_LLCORNER;
- if (br == 0) br = ACS_LRCORNER;
-
- ls = _nc_render(win, ls);
- rs = _nc_render(win, rs);
- ts = _nc_render(win, ts);
- bs = _nc_render(win, bs);
- tl = _nc_render(win, tl);
- tr = _nc_render(win, tr);
- bl = _nc_render(win, bl);
- br = _nc_render(win, br);
-
- T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", ls, rs, ts, bs, tl, tr, bl, br));
-
- endx = win->_maxx;
- endy = win->_maxy;
-
- for (i = 0; i <= endx; i++) {
- win->_line[0].text[i] = ts;
- win->_line[endy].text[i] = bs;
- }
- win->_line[endy].firstchar = win->_line[0].firstchar = 0;
- win->_line[endy].lastchar = win->_line[0].lastchar = endx;
-
- for (i = 0; i <= endy; i++) {
- win->_line[i].text[0] = ls;
- win->_line[i].text[endx] = rs;
- win->_line[i].firstchar = 0;
- win->_line[i].lastchar = endx;
- }
- win->_line[0].text[0] = tl;
- win->_line[0].text[endx] = tr;
- win->_line[endy].text[0] = bl;
- win->_line[endy].text[endx] = br;
-
- _nc_synchook(win);
- returnCode(OK);
+ win,
+ _tracechtype2(1, ls),
+ _tracechtype2(2, rs),
+ _tracechtype2(3, ts),
+ _tracechtype2(4, bs),
+ _tracechtype2(5, tl),
+ _tracechtype2(6, tr),
+ _tracechtype2(7, bl),
+ _tracechtype2(8, br)));
+
+ if (!win)
+ returnCode(ERR);
+
+ if (ls == 0)
+ ls = ACS_VLINE;
+ if (rs == 0)
+ rs = ACS_VLINE;
+ if (ts == 0)
+ ts = ACS_HLINE;
+ if (bs == 0)
+ bs = ACS_HLINE;
+ if (tl == 0)
+ tl = ACS_ULCORNER;
+ if (tr == 0)
+ tr = ACS_URCORNER;
+ if (bl == 0)
+ bl = ACS_LLCORNER;
+ if (br == 0)
+ br = ACS_LRCORNER;
+
+ ls = _nc_render(win, ls);
+ rs = _nc_render(win, rs);
+ ts = _nc_render(win, ts);
+ bs = _nc_render(win, bs);
+ tl = _nc_render(win, tl);
+ tr = _nc_render(win, tr);
+ bl = _nc_render(win, bl);
+ br = _nc_render(win, br);
+
+ T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx",
+ ls, rs, ts, bs, tl, tr, bl, br));
+
+ endx = win->_maxx;
+ endy = win->_maxy;
+
+ for (i = 0; i <= endx; i++) {
+ win->_line[0].text[i] = ts;
+ win->_line[endy].text[i] = bs;
+ }
+ win->_line[endy].firstchar = win->_line[0].firstchar = 0;
+ win->_line[endy].lastchar = win->_line[0].lastchar = endx;
+
+ for (i = 0; i <= endy; i++) {
+ win->_line[i].text[0] = ls;
+ win->_line[i].text[endx] = rs;
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = endx;
+ }
+ win->_line[0].text[0] = tl;
+ win->_line[0].text[endx] = tr;
+ win->_line[endy].text[0] = bl;
+ win->_line[endy].text[endx] = br;
+
+ _nc_synchook(win);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_clrbot.c b/contrib/ncurses/ncurses/base/lib_clrbot.c
index cec34161acef..d1e243f37ffd 100644
--- a/contrib/ncurses/ncurses/base/lib_clrbot.c
+++ b/contrib/ncurses/ncurses/base/lib_clrbot.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -40,36 +40,37 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_clrbot.c,v 1.14 1998/06/28 00:36:26 tom Exp $")
+MODULE_ID("$Id: lib_clrbot.c,v 1.15 2000/04/29 21:15:26 tom Exp $")
-int wclrtobot(WINDOW *win)
+int
+wclrtobot(WINDOW *win)
{
-int code = ERR;
+ int code = ERR;
- T((T_CALLED("wclrtobot(%p)"), win));
+ T((T_CALLED("wclrtobot(%p)"), win));
- if (win) {
- short y;
- short startx = win->_curx;
- chtype blank = _nc_background(win);
+ if (win) {
+ NCURSES_SIZE_T y;
+ NCURSES_SIZE_T startx = win->_curx;
+ chtype blank = _nc_background(win);
- T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx));
+ T(("clearing from y = %d to y = %d with maxx = %d",
+ win->_cury, win->_maxy, win->_maxx));
- for (y = win->_cury; y <= win->_maxy; y++) {
- struct ldat *line = &(win->_line[y]);
- chtype *ptr = &(line->text[startx]);
- chtype *end = &(line->text[win->_maxx]);
+ for (y = win->_cury; y <= win->_maxy; y++) {
+ struct ldat *line = &(win->_line[y]);
+ chtype *ptr = &(line->text[startx]);
+ chtype *end = &(line->text[win->_maxx]);
- CHANGED_TO_EOL(line, startx, win->_maxx);
+ CHANGED_TO_EOL(line, startx, win->_maxx);
- while (ptr <= end)
- *ptr++ = blank;
+ while (ptr <= end)
+ *ptr++ = blank;
- startx = 0;
- }
- _nc_synchook(win);
- code = OK;
+ startx = 0;
}
- returnCode(code);
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
}
-
diff --git a/contrib/ncurses/ncurses/base/lib_clreol.c b/contrib/ncurses/ncurses/base/lib_clreol.c
index 0c7522278e38..a5d067cbfd5f 100644
--- a/contrib/ncurses/ncurses/base/lib_clreol.c
+++ b/contrib/ncurses/ncurses/base/lib_clreol.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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_clreol.c
**
@@ -41,51 +40,52 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_clreol.c,v 1.15 1998/06/28 00:32:20 tom Exp $")
+MODULE_ID("$Id: lib_clreol.c,v 1.16 2000/04/29 21:14:54 tom Exp $")
-int wclrtoeol(WINDOW *win)
+int
+wclrtoeol(WINDOW *win)
{
-int code = ERR;
+ int code = ERR;
- T((T_CALLED("wclrtoeol(%p)"), win));
+ T((T_CALLED("wclrtoeol(%p)"), win));
- if (win) {
- chtype blank;
- chtype *ptr, *end;
- struct ldat *line;
- short y = win->_cury;
- short x = win->_curx;
+ if (win) {
+ chtype blank;
+ chtype *ptr, *end;
+ struct ldat *line;
+ NCURSES_SIZE_T y = win->_cury;
+ NCURSES_SIZE_T x = win->_curx;
- /*
- * If we have just wrapped the cursor, the clear applies to the
- * new line, unless we are at the lower right corner.
- */
- if (win->_flags & _WRAPPED
- && y < win->_maxy) {
- win->_flags &= ~_WRAPPED;
- }
+ /*
+ * If we have just wrapped the cursor, the clear applies to the
+ * new line, unless we are at the lower right corner.
+ */
+ if (win->_flags & _WRAPPED
+ && y < win->_maxy) {
+ win->_flags &= ~_WRAPPED;
+ }
- /*
- * There's no point in clearing if we're not on a legal
- * position, either.
- */
- if (win->_flags & _WRAPPED
- || y > win->_maxy
- || x > win->_maxx)
- returnCode(ERR);
+ /*
+ * There's no point in clearing if we're not on a legal
+ * position, either.
+ */
+ if (win->_flags & _WRAPPED
+ || y > win->_maxy
+ || x > win->_maxx)
+ returnCode(ERR);
- blank = _nc_background(win);
- line = &win->_line[y];
- CHANGED_TO_EOL(line, x, win->_maxx);
+ blank = _nc_background(win);
+ line = &win->_line[y];
+ CHANGED_TO_EOL(line, x, win->_maxx);
- ptr = &(line->text[x]);
- end = &(line->text[win->_maxx]);
+ ptr = &(line->text[x]);
+ end = &(line->text[win->_maxx]);
- while (ptr <= end)
- *ptr++ = blank;
+ while (ptr <= end)
+ *ptr++ = blank;
- _nc_synchook(win);
- code = OK;
- }
- returnCode(code);
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c
index 297a14c36d6e..71bee42487cd 100644
--- a/contrib/ncurses/ncurses/base/lib_color.c
+++ b/contrib/ncurses/ncurses/base/lib_color.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -34,22 +34,22 @@
/* lib_color.c
*
* Handles color emulation of SYS V curses
- *
*/
#include <curses.priv.h>
#include <term.h>
+#include <tic.h>
-MODULE_ID("$Id: lib_color.c,v 1.36 1999/10/03 00:20:37 Philippe.Blain Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.51 2000/05/20 20:09:22 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
- * hystorical reasons. So we assign them in start_color() and also in
+ * historical reasons. So we assign them in start_color() and also in
* set_term()'s screen-switching logic.
*/
-int COLOR_PAIRS;
-int COLORS;
+int COLOR_PAIRS = 0;
+int COLORS = 0;
/*
* Given a RGB range of 0..1000, we'll normally set the individual values
@@ -57,141 +57,179 @@ int COLORS;
*/
#define RGB_ON 680
#define RGB_OFF 0
-
+/* *INDENT-OFF* */
static const color_t cga_palette[] =
{
- /* R G B */
- {RGB_OFF, RGB_OFF, RGB_OFF}, /* COLOR_BLACK */
- {RGB_ON, RGB_OFF, RGB_OFF}, /* COLOR_RED */
- {RGB_OFF, RGB_ON, RGB_OFF}, /* COLOR_GREEN */
- {RGB_ON, RGB_ON, RGB_OFF}, /* COLOR_YELLOW */
- {RGB_OFF, RGB_OFF, RGB_ON}, /* COLOR_BLUE */
- {RGB_ON, RGB_OFF, RGB_ON}, /* COLOR_MAGENTA */
- {RGB_OFF, RGB_ON, RGB_ON}, /* COLOR_CYAN */
- {RGB_ON, RGB_ON, RGB_ON}, /* COLOR_WHITE */
+ /* R G B */
+ {RGB_OFF, RGB_OFF, RGB_OFF}, /* COLOR_BLACK */
+ {RGB_ON, RGB_OFF, RGB_OFF}, /* COLOR_RED */
+ {RGB_OFF, RGB_ON, RGB_OFF}, /* COLOR_GREEN */
+ {RGB_ON, RGB_ON, RGB_OFF}, /* COLOR_YELLOW */
+ {RGB_OFF, RGB_OFF, RGB_ON}, /* COLOR_BLUE */
+ {RGB_ON, RGB_OFF, RGB_ON}, /* COLOR_MAGENTA */
+ {RGB_OFF, RGB_ON, RGB_ON}, /* COLOR_CYAN */
+ {RGB_ON, RGB_ON, RGB_ON}, /* COLOR_WHITE */
};
+
static const color_t hls_palette[] =
{
- /* H L S */
- {0, 0, 0}, /* COLOR_BLACK */
- {120, 50, 100}, /* COLOR_RED */
- {240, 50, 100}, /* COLOR_GREEN */
- {180, 50, 100}, /* COLOR_YELLOW */
- {330, 50, 100}, /* COLOR_BLUE */
- {60, 50, 100}, /* COLOR_MAGENTA */
- {300, 50, 100}, /* COLOR_CYAN */
- {0, 50, 100}, /* COLOR_WHITE */
+ /* H L S */
+ { 0, 0, 0}, /* COLOR_BLACK */
+ { 120, 50, 100}, /* COLOR_RED */
+ { 240, 50, 100}, /* COLOR_GREEN */
+ { 180, 50, 100}, /* COLOR_YELLOW */
+ { 330, 50, 100}, /* COLOR_BLUE */
+ { 60, 50, 100}, /* COLOR_MAGENTA */
+ { 300, 50, 100}, /* COLOR_CYAN */
+ { 0, 50, 100}, /* COLOR_WHITE */
};
+/* *INDENT-ON* */
+
+#ifdef 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.
+ */
+static int
+default_fg(void)
+{
+ return (SP != 0) ? SP->_default_fg : COLOR_WHITE;
+}
+
+static int
+default_bg(void)
+{
+ return SP != 0 ? SP->_default_bg : COLOR_BLACK;
+}
+#else
+#define default_fg() COLOR_WHITE
+#define default_bg() COLOR_BLACK
+#endif
/*
* SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly
* to maintain compatibility with a pre-ANSI scheme. The same scheme is
* also used in the FreeBSD syscons.
*/
-static int toggled_colors(int c)
+static int
+toggled_colors(int c)
{
if (c < 16) {
static const int table[] =
- { 0, 4, 2, 6, 1, 5, 3, 7,
- 8, 12, 10, 14, 9, 13, 11, 15};
+ {0, 4, 2, 6, 1, 5, 3, 7,
+ 8, 12, 10, 14, 9, 13, 11, 15};
c = table[c];
}
return c;
}
-static void set_background_color(int bg, int (*outc)(int))
+static void
+set_background_color(int bg, int (*outc) (int))
{
- if (set_a_background)
- {
- TPUTS_TRACE("set_a_background");
- tputs(tparm(set_a_background, bg), 1, outc);
- }
- else
- {
- TPUTS_TRACE("set_background");
- tputs(tparm(set_background, toggled_colors(bg)), 1, outc);
- }
+ if (set_a_background) {
+ TPUTS_TRACE("set_a_background");
+ tputs(tparm(set_a_background, bg), 1, outc);
+ } else {
+ TPUTS_TRACE("set_background");
+ tputs(tparm(set_background, toggled_colors(bg)), 1, outc);
+ }
}
-static void set_foreground_color(int fg, int (*outc)(int))
+static void
+set_foreground_color(int fg, int (*outc) (int))
{
- if (set_a_foreground)
- {
- TPUTS_TRACE("set_a_foreground");
- tputs(tparm(set_a_foreground, fg), 1, outc);
- }
- else
- {
- TPUTS_TRACE("set_foreground");
- tputs(tparm(set_foreground, toggled_colors(fg)), 1, outc);
- }
+ if (set_a_foreground) {
+ TPUTS_TRACE("set_a_foreground");
+ tputs(tparm(set_a_foreground, fg), 1, outc);
+ } else {
+ TPUTS_TRACE("set_foreground");
+ tputs(tparm(set_foreground, toggled_colors(fg)), 1, outc);
+ }
}
-static bool set_original_colors(void)
+static bool
+set_original_colors(void)
{
- if (orig_pair != 0) {
- TPUTS_TRACE("orig_pair");
- putp(orig_pair);
- return TRUE;
- }
- else if (orig_colors != NULL)
- {
- TPUTS_TRACE("orig_colors");
- putp(orig_colors);
- return TRUE;
- }
- return FALSE;
+ if (orig_pair != 0) {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ return TRUE;
+ } else if (orig_colors != NULL) {
+ TPUTS_TRACE("orig_colors");
+ putp(orig_colors);
+ return TRUE;
+ }
+ return FALSE;
}
-int start_color(void)
+int
+start_color(void)
{
- T((T_CALLED("start_color()")));
+ int n;
+ const color_t *tp;
+
+ T((T_CALLED("start_color()")));
- if (set_original_colors() != TRUE)
- {
- set_foreground_color(COLOR_WHITE, _nc_outch);
- set_background_color(COLOR_BLACK, _nc_outch);
+ if (set_original_colors() != TRUE) {
+ set_foreground_color(default_fg(), _nc_outch);
+ set_background_color(default_bg(), _nc_outch);
+ }
+
+ if (VALID_NUMERIC(max_pairs))
+ COLOR_PAIRS = SP->_pair_count = max_pairs;
+ else
+ returnCode(ERR);
+ if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
+ returnCode(ERR);
+ SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
+ if (VALID_NUMERIC(max_colors))
+ COLORS = SP->_color_count = max_colors;
+ else
+ returnCode(ERR);
+ SP->_coloron = 1;
+
+ if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
+ returnCode(ERR);
+ tp = (hue_lightness_saturation) ? hls_palette : cga_palette;
+ for (n = 0; n < COLORS; n++) {
+ if (n < 8) {
+ SP->_color_table[n] = tp[n];
+ } else {
+ SP->_color_table[n] = tp[n % 8];
+ if (hue_lightness_saturation) {
+ SP->_color_table[n].green = 100;
+ } else {
+ if (SP->_color_table[n].red)
+ SP->_color_table[n].red = 1000;
+ if (SP->_color_table[n].green)
+ SP->_color_table[n].green = 1000;
+ if (SP->_color_table[n].blue)
+ SP->_color_table[n].blue = 1000;
+ }
}
+ }
- if (max_pairs != -1)
- COLOR_PAIRS = SP->_pair_count = max_pairs;
- else
- returnCode(ERR);
- if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
- returnCode(ERR);
- SP->_color_pairs[0] = PAIR_OF(COLOR_WHITE, COLOR_BLACK);
- if (max_colors != -1)
- COLORS = SP->_color_count = max_colors;
- else
- returnCode(ERR);
- SP->_coloron = 1;
-
- if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
- returnCode(ERR);
- if (hue_lightness_saturation)
- memcpy(SP->_color_table, hls_palette, sizeof(color_t) * COLORS);
- else
- memcpy(SP->_color_table, cga_palette, sizeof(color_t) * COLORS);
-
- T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
-
- returnCode(OK);
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
+
+ returnCode(OK);
}
/* This function was originally written by Daniel Weaver <danw@znyx.com> */
-static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
+static void
+rgb2hls(short r, short g, short b, short *h, short *l, short *s)
/* convert RGB to HLS system */
{
short min, max, t;
- if ((min = g < r ? g : r) > b) min = b;
- if ((max = g > r ? g : r) < b) max = b;
+ if ((min = g < r ? g : r) > b)
+ min = b;
+ if ((max = g > r ? g : r) < b)
+ max = b;
/* calculate lightness */
*l = (min + max) / 20;
- if (min == max) /* black, white and all shades of gray */
- {
+ if (min == max) { /* black, white and all shades of gray */
*h = 0;
*s = 0;
return;
@@ -200,16 +238,16 @@ static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
/* calculate saturation */
if (*l < 50)
*s = ((max - min) * 100) / (max + min);
- else *s = ((max - min) * 100) / (2000 - max - min);
+ else
+ *s = ((max - min) * 100) / (2000 - max - min);
/* calculate hue */
if (r == max)
t = 120 + ((g - b) * 60) / (max - min);
+ else if (g == max)
+ t = 240 + ((b - r) * 60) / (max - min);
else
- if (g == max)
- t = 240 + ((b - r) * 60) / (max - min);
- else
- t = 360 + ((r - g) * 60) / (max - min);
+ t = 360 + ((r - g) * 60) / (max - min);
*h = t % 360;
}
@@ -218,212 +256,227 @@ static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
* Extension (1997/1/18) - Allow negative f/b values to set default color
* values.
*/
-int init_pair(short pair, short f, short b)
+int
+init_pair(short pair, short f, short b)
{
- unsigned result;
-
- T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
-
- if ((pair < 1) || (pair >= COLOR_PAIRS))
- returnCode(ERR);
- if (SP->_default_color)
- {
- if (f < 0)
- f = C_MASK;
- if (b < 0)
- b = C_MASK;
- if (f >= COLORS && f != C_MASK)
- returnCode(ERR);
- if (b >= COLORS && b != C_MASK)
- returnCode(ERR);
- }
- else
+ unsigned result;
+
+ T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
+
+ if ((pair < 0) || (pair >= COLOR_PAIRS))
+ returnCode(ERR);
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_default_color) {
+ if (f < 0)
+ f = C_MASK;
+ if (b < 0)
+ b = C_MASK;
+ if (f >= COLORS && f != C_MASK)
+ returnCode(ERR);
+ if (b >= COLORS && b != C_MASK)
+ returnCode(ERR);
+ } else
+#endif
+ {
if ((f < 0) || (f >= COLORS)
- || (b < 0) || (b >= COLORS))
- returnCode(ERR);
-
- /*
- * When a pair's content is changed, replace its colors (if pair was
- * initialized before a screen update is performed replacing original
- * pair colors with the new ones).
- */
- result = PAIR_OF(f,b);
- if (SP->_color_pairs[pair] != 0
- && SP->_color_pairs[pair] != result) {
- int y, x;
- attr_t z = COLOR_PAIR(pair);
-
- for (y = 0; y <= curscr->_maxy; y++) {
- struct ldat *ptr = &(curscr->_line[y]);
- bool changed = FALSE;
- for (x = 0; x <= curscr->_maxx; x++) {
- if ((ptr->text[x] & A_COLOR) == z) {
- /* Set the old cell to zero to ensure it will be
- updated on the next doupdate() */
- ptr->text[x] = 0;
- CHANGED_CELL(ptr,x);
- changed = TRUE;
- }
+ || (b < 0) || (b >= COLORS)
+ || (pair < 1))
+ returnCode(ERR);
+ }
+
+ /*
+ * When a pair's content is changed, replace its colors (if pair was
+ * initialized before a screen update is performed replacing original
+ * pair colors with the new ones).
+ */
+ result = PAIR_OF(f, b);
+ if (SP->_color_pairs[pair] != 0
+ && SP->_color_pairs[pair] != result) {
+ int y, x;
+ attr_t z = COLOR_PAIR(pair);
+
+ for (y = 0; y <= curscr->_maxy; y++) {
+ struct ldat *ptr = &(curscr->_line[y]);
+ bool changed = FALSE;
+ for (x = 0; x <= curscr->_maxx; x++) {
+ if ((ptr->text[x] & A_COLOR) == z) {
+ /* Set the old cell to zero to ensure it will be
+ updated on the next doupdate() */
+ ptr->text[x] = 0;
+ CHANGED_CELL(ptr, x);
+ changed = TRUE;
}
- if (changed)
- _nc_make_oldhash(y);
}
+ if (changed)
+ _nc_make_oldhash(y);
}
- SP->_color_pairs[pair] = result;
-
- if (initialize_pair)
- {
- const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
-
- T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
-
- if (initialize_pair)
- {
- TPUTS_TRACE("initialize_pair");
- putp(tparm(initialize_pair,
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
- }
+ }
+ SP->_color_pairs[pair] = result;
+ if ((int) (SP->_current_attr & A_COLOR) == COLOR_PAIR(pair))
+ SP->_current_attr |= A_COLOR; /* force attribute update */
+
+ if (initialize_pair) {
+ const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
+
+ T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
+
+ if (initialize_pair) {
+ TPUTS_TRACE("initialize_pair");
+ putp(tparm(initialize_pair,
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
}
+ }
- returnCode(OK);
+ returnCode(OK);
}
-int init_color(short color, short r, short g, short b)
+int
+init_color(short color, short r, short g, short b)
{
- T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
-
- if (initialize_color == NULL)
- returnCode(ERR);
-
- if (color < 0 || color >= COLORS)
- returnCode(ERR);
- if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
- returnCode(ERR);
-
- if (hue_lightness_saturation)
- rgb2hls(r, g, b,
- &SP->_color_table[color].red,
- &SP->_color_table[color].green,
- &SP->_color_table[color].blue);
- else
- {
- SP->_color_table[color].red = r;
- SP->_color_table[color].green = g;
- SP->_color_table[color].blue = b;
- }
+ T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
- if (initialize_color)
- {
- TPUTS_TRACE("initialize_color");
- putp(tparm(initialize_color, color, r, g, b));
- }
- returnCode(OK);
+ if (initialize_color == NULL)
+ returnCode(ERR);
+
+ if (color < 0 || color >= COLORS)
+ returnCode(ERR);
+ if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
+ returnCode(ERR);
+
+ if (hue_lightness_saturation)
+ rgb2hls(r, g, b,
+ &SP->_color_table[color].red,
+ &SP->_color_table[color].green,
+ &SP->_color_table[color].blue);
+ else {
+ SP->_color_table[color].red = r;
+ SP->_color_table[color].green = g;
+ SP->_color_table[color].blue = b;
+ }
+
+ if (initialize_color) {
+ TPUTS_TRACE("initialize_color");
+ putp(tparm(initialize_color, color, r, g, b));
+ }
+ returnCode(OK);
}
-bool can_change_color(void)
+bool
+can_change_color(void)
{
- T((T_CALLED("can_change_color()")));
- returnCode ((can_change != 0) ? TRUE : FALSE);
+ T((T_CALLED("can_change_color()")));
+ returnCode((can_change != 0) ? TRUE : FALSE);
}
-bool has_colors(void)
+bool
+has_colors(void)
{
- T((T_CALLED("has_colors()")));
- returnCode (((max_colors != -1) && (max_pairs != -1)
- && (((set_foreground != NULL)
- && (set_background != NULL))
- || ((set_a_foreground != NULL)
- && (set_a_background != NULL))
- || set_color_pair)) ? TRUE : FALSE);
+ T((T_CALLED("has_colors()")));
+ returnCode((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs)
+ && (((set_foreground != NULL)
+ && (set_background != NULL))
+ || ((set_a_foreground != NULL)
+ && (set_a_background != NULL))
+ || set_color_pair)) ? TRUE : FALSE);
}
-int color_content(short color, short *r, short *g, short *b)
+int
+color_content(short color, short *r, short *g, short *b)
{
T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
if (color < 0 || color >= COLORS)
returnCode(ERR);
- if (r) *r = SP->_color_table[color].red;
- if (g) *g = SP->_color_table[color].green;
- if (b) *b = SP->_color_table[color].blue;
+ if (r)
+ *r = SP->_color_table[color].red;
+ if (g)
+ *g = SP->_color_table[color].green;
+ if (b)
+ *b = SP->_color_table[color].blue;
returnCode(OK);
}
-int pair_content(short pair, short *f, short *b)
+int
+pair_content(short pair, short *f, short *b)
{
- T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
+ T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
- if ((pair < 0) || (pair >= COLOR_PAIRS))
- returnCode(ERR);
- if (f) *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
- if (b) *b = (SP->_color_pairs[pair] & C_MASK);
+ if ((pair < 0) || (pair >= COLOR_PAIRS))
+ returnCode(ERR);
+ if (f)
+ *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
+ if (b)
+ *b = (SP->_color_pairs[pair] & C_MASK);
- returnCode(OK);
+ returnCode(OK);
}
-void _nc_do_color(int pair, bool reverse, int (*outc)(int))
+void
+_nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
{
- short fg, bg;
+ NCURSES_COLOR_T fg = C_MASK, bg = C_MASK;
+ NCURSES_COLOR_T old_fg, old_bg;
- if (pair == 0)
- {
- if (orig_pair)
- {
- TPUTS_TRACE("orig_pair");
- tputs(orig_pair, 1, outc);
- }
- else if (set_color_pair)
- {
+ if (pair < 0 || pair >= COLOR_PAIRS) {
+ return;
+ } else if (pair != 0) {
+ if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
tputs(tparm(set_color_pair, pair), 1, outc);
- }
- else
- {
- set_foreground_color(COLOR_WHITE, outc);
- set_background_color(COLOR_BLACK, outc);
+ return;
+ } else if (SP != 0) {
+ pair_content(pair, &fg, &bg);
}
}
- else
- {
- if (set_color_pair)
- {
- TPUTS_TRACE("set_color_pair");
- tputs(tparm(set_color_pair, pair), 1, outc);
+
+ if (old_pair >= 0 && SP != 0) {
+ 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
+ /*
+ * A minor optimization - but extension. If "AX" is specified in
+ * the terminal description, treat it as screen's indicator of ECMA
+ * SGR 39 and SGR 49, and assume the two sequences are independent.
+ */
+ if (SP->_has_sgr_39_49 && old_bg == C_MASK && old_fg != C_MASK) {
+ tputs("\033[39m", 1, outc);
+ } else if (SP->_has_sgr_39_49 && old_fg == C_MASK && old_bg != C_MASK) {
+ tputs("\033[49m", 1, outc);
+ } else
+#endif
+ set_original_colors();
}
- else
- {
- pair_content(pair, &fg, &bg);
- if (reverse) {
- short xx = fg;
- fg = bg;
- bg = xx;
- }
+ } else {
+ set_original_colors();
+ if (old_pair < 0)
+ return;
+ }
- T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+#ifdef NCURSES_EXT_FUNCS
+ if (fg == C_MASK)
+ fg = default_fg();
+ if (bg == C_MASK)
+ bg = default_bg();
+#endif
+
+ if (reverse) {
+ NCURSES_COLOR_T xx = fg;
+ fg = bg;
+ bg = xx;
+ }
- if (fg == C_MASK || bg == C_MASK)
- {
- if (set_original_colors() != TRUE)
- {
- if (fg == C_MASK)
- set_foreground_color(COLOR_WHITE, outc);
- if (bg == C_MASK)
- set_background_color(COLOR_BLACK, outc);
- }
- }
- if (fg != C_MASK)
- {
- set_foreground_color(fg, outc);
- }
- if (bg != C_MASK)
- {
- set_background_color(bg, outc);
- }
- }
+ T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+
+ if (fg != C_MASK) {
+ set_foreground_color(fg, outc);
+ }
+ if (bg != C_MASK) {
+ set_background_color(bg, outc);
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
index a2dfbd218f74..19d75477b140 100644
--- a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
+++ b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -27,34 +27,45 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997,1999 *
****************************************************************************/
+
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.3 1998/02/11 12:13:54 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.11 2000/05/07 01:26:06 tom Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
- * it is black on white. This is an extension to XSI curses.
- *
- * Invoke this function after 'start_color()'.
+ * it is white on black. This is an extension to XSI curses.
*/
int
use_default_colors(void)
{
- T((T_CALLED("use_default_colors()")));
+ T((T_CALLED("use_default_colors()")));
+ returnCode(assume_default_colors(C_MASK, C_MASK));
+}
- if (!SP->_coloron)
- returnCode(ERR);
+/*
+ * Modify the behavior of color-pair 0 so that the library assumes that it
+ * is something specific, possibly not white on black.
+ */
+int
+assume_default_colors(int fg, int bg)
+{
+ T((T_CALLED("assume_default_colors(%d,%d)"), fg, bg));
- if (!orig_pair && !orig_colors)
- returnCode(ERR);
+ if (!orig_pair && !orig_colors)
+ returnCode(ERR);
- if (initialize_pair) /* don't know how to handle this */
- returnCode(ERR);
+ if (initialize_pair) /* don't know how to handle this */
+ returnCode(ERR);
- SP->_default_color = TRUE;
- SP->_color_pairs[0] = PAIR_OF(C_MASK, C_MASK);
- returnCode(OK);
+ SP->_default_color = (fg != COLOR_WHITE) || (bg != COLOR_BLACK);
+ 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;
+ if (SP->_color_pairs != 0)
+ init_pair(0, fg, bg);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c
index 324e7a282741..28f0e5f9f425 100644
--- a/contrib/ncurses/ncurses/base/lib_freeall.c
+++ b/contrib/ncurses/ncurses/base/lib_freeall.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 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,94 +39,101 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$Id: lib_freeall.c,v 1.15 1999/10/22 21:40:10 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.16 1999/11/28 01:34:11 tom Exp $")
-static void free_slk(SLK *p)
+static void
+free_slk(SLK *p)
{
- if (p != 0) {
- FreeIfNeeded(p->ent);
- FreeIfNeeded(p->buffer);
- free(p);
- }
+ if (p != 0) {
+ FreeIfNeeded(p->ent);
+ FreeIfNeeded(p->buffer);
+ free(p);
+ }
}
-static void free_tries(struct tries *p)
+static void
+free_tries(struct tries *p)
{
- struct tries *q;
-
- while (p != 0) {
- q = p->sibling;
- if (p->child != 0)
- free_tries(p->child);
- free(p);
- p = q;
- }
+ struct tries *q;
+
+ while (p != 0) {
+ q = p->sibling;
+ if (p->child != 0)
+ free_tries(p->child);
+ free(p);
+ p = q;
+ }
}
/*
* Free all ncurses data. This is used for testing only (there's no practical
* use for it as an extension).
*/
-void _nc_freeall(void)
+void
+_nc_freeall(void)
{
- WINDOWLIST *p, *q;
+ WINDOWLIST *p, *q;
#if NO_LEAKS
- _nc_free_tparm();
+ _nc_free_tparm();
#endif
+ if (SP != 0) {
while (_nc_windows != 0) {
- /* Delete only windows that're not a parent */
- for (p = _nc_windows; p != 0; p = p->next) {
- bool found = FALSE;
-
- for (q = _nc_windows; q != 0; q = q->next) {
- if ((p != q)
- && (q->win->_flags & _SUBWIN)
- && (p->win == q->win->_parent)) {
- found = TRUE;
- break;
- }
- }
-
- if (!found) {
- delwin(p->win);
- break;
- }
+ /* Delete only windows that're not a parent */
+ for (p = _nc_windows; p != 0; p = p->next) {
+ bool found = FALSE;
+
+ for (q = _nc_windows; q != 0; q = q->next) {
+ if ((p != q)
+ && (q->win->_flags & _SUBWIN)
+ && (p->win == q->win->_parent)) {
+ found = TRUE;
+ break;
+ }
}
+
+ if (!found) {
+ delwin(p->win);
+ break;
+ }
+ }
}
- if (SP != 0) {
- free_tries (SP->_keytry);
- free_tries (SP->_key_ok);
- free_slk(SP->_slk);
- FreeIfNeeded(SP->_color_pairs);
- FreeIfNeeded(SP->_color_table);
+ free_tries(SP->_keytry);
+ free_tries(SP->_key_ok);
+ free_slk(SP->_slk);
+ FreeIfNeeded(SP->_color_pairs);
+ FreeIfNeeded(SP->_color_table);
#if !BROKEN_LINKER
- FreeAndNull(SP);
+ FreeAndNull(SP);
#endif
- }
-
- if (cur_term != 0) {
- _nc_free_termtype(&(cur_term->type));
- free(cur_term);
- }
+ }
+ if (cur_term != 0) {
+ _nc_free_termtype(&(cur_term->type));
+ free(cur_term);
+ }
#ifdef TRACE
- (void) _nc_trace_buf(-1, 0);
+ (void) _nc_trace_buf(-1, 0);
#endif
#if HAVE_LIBDBMALLOC
- malloc_dump(malloc_errfd);
+ malloc_dump(malloc_errfd);
#elif HAVE_LIBDMALLOC
#elif HAVE_PURIFY
- purify_all_inuse();
+ purify_all_inuse();
#endif
}
-void _nc_free_and_exit(int code)
+void
+_nc_free_and_exit(int code)
{
- _nc_freeall();
- exit(code);
+ _nc_freeall();
+ exit(code);
}
+
#else
-void _nc_freeall(void) { }
+void
+_nc_freeall(void)
+{
+}
#endif
diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c
index b740885b8166..7ab4b5085c75 100644
--- a/contrib/ncurses/ncurses/base/lib_getch.c
+++ b/contrib/ncurses/ncurses/base/lib_getch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -40,143 +40,154 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.43 1999/03/08 02:35:10 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.47 2000/05/28 01:12:51 tom Exp $")
#include <fifo_defs.h>
-int ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
+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->_checkfd, &fdset);
- if (SP->_mouse_fd >= 0) {
- FD_SET(SP->_mouse_fd, &fdset);
- if (SP->_mouse_fd > SP->_checkfd)
- nums = SP->_mouse_fd+1;
- }
- if (select(nums, &fdset, NULL, NULL, NULL) >= 0) {
- int n;
-
- if (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;
+ 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 */
+#endif /* USE_EMX_MOUSE */
-static inline int fifo_peek(void)
+static inline int
+fifo_peek(void)
{
- int ch = SP->_fifo[peek];
- T(("peeking at %d", peek));
+ int ch = SP->_fifo[peek];
+ T(("peeking at %d", peek));
- p_inc();
- return ch;
+ p_inc();
+ return ch;
}
-
-static inline int fifo_pull(void)
+static inline int
+fifo_pull(void)
{
-int ch;
- ch = SP->_fifo[head];
- T(("pulling %d from %d", ch, head));
+ int ch;
+ ch = SP->_fifo[head];
+ T(("pulling %d from %d", ch, head));
- if (peek == head)
- {
- h_inc();
- peek = head;
- }
- else
- h_inc();
+ if (peek == head) {
+ h_inc();
+ peek = head;
+ } else
+ h_inc();
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
+ if (_nc_tracing & TRACE_IEVENT)
+ _nc_fifo_dump();
#endif
- return ch;
+ return ch;
}
-static inline int fifo_push(void)
+static inline int
+fifo_push(void)
{
-int n;
-unsigned int ch;
+ int n;
+ unsigned int ch;
- if (tail == -1) return ERR;
+ if (tail == -1)
+ return ERR;
#ifdef HIDE_EINTR
-again:
- errno = 0;
+ again:
+ errno = 0;
#endif
#if USE_GPM_SUPPORT
- if ((SP->_mouse_fd >= 0)
- && (_nc_timed_wait(3, -1, (int *)0) & 2))
- {
- SP->_mouse_event(SP);
- ch = KEY_MOUSE;
- n = 1;
- } else
+ if ((SP->_mouse_fd >= 0)
+ && (_nc_timed_wait(3, -1, (int *) 0) & 2)) {
+ SP->_mouse_event(SP);
+ ch = KEY_MOUSE;
+ n = 1;
+ } else
#endif
- {
- unsigned char c2=0;
+ {
+ unsigned char c2 = 0;
#ifdef USE_EMX_MOUSE
- n = kbd_mouse_read(&c2);
+ n = kbd_mouse_read(&c2);
#else
- n = read(SP->_ifd, &c2, 1);
+ n = read(SP->_ifd, &c2, 1);
#endif
- ch = c2 & 0xff;
- }
+ ch = c2 & 0xff;
+ }
#ifdef HIDE_EINTR
- /*
- * Under System V curses with non-restarting signals, getch() returns
- * with value ERR when a handled signal keeps it from completing.
- * If signals restart system calls, OTOH, the signal is invisible
- * except to its handler.
- *
- * We don't want this difference to show. This piece of code
- * tries to make it look like we always have restarting signals.
- */
- if (n <= 0 && errno == EINTR)
- goto again;
+ /*
+ * Under System V curses with non-restarting signals, getch() returns
+ * with value ERR when a handled signal keeps it from completing.
+ * If signals restart system calls, OTOH, the signal is invisible
+ * except to its handler.
+ *
+ * We don't want this difference to show. This piece of code
+ * tries to make it look like we always have restarting signals.
+ */
+ if (n <= 0 && errno == EINTR)
+ goto again;
#endif
- if ((n == -1) || (n == 0))
- {
- T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
- return ERR;
- }
- T(("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));
+ if ((n == -1) || (n == 0)) {
+ T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
+ return ERR;
+ }
+ T(("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));
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
+ if (_nc_tracing & TRACE_IEVENT)
+ _nc_fifo_dump();
#endif
- return ch;
+ return ch;
}
-static inline void fifo_clear(void)
+static inline void
+fifo_clear(void)
{
-int i;
- for (i = 0; i < FIFO_SIZE; i++)
- SP->_fifo[i] = 0;
- head = -1; tail = peek = 0;
+ int i;
+ for (i = 0; i < FIFO_SIZE; i++)
+ SP->_fifo[i] = 0;
+ head = -1;
+ tail = peek = 0;
}
static int kgetch(WINDOW *);
@@ -188,147 +199,158 @@ static int kgetch(WINDOW *);
int
wgetch(WINDOW *win)
{
-int ch;
+ int ch;
- T((T_CALLED("wgetch(%p)"), win));
+ T((T_CALLED("wgetch(%p)"), win));
- if (!win)
- returnCode(ERR);
+ if (!win)
+ returnCode(ERR);
- if (cooked_key_in_fifo())
- {
- if (wgetch_should_refresh(win))
- wrefresh(win);
+ if (cooked_key_in_fifo()) {
+ if (wgetch_should_refresh(win))
+ wrefresh(win);
- ch = fifo_pull();
- T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch));)
- returnCode(ch);
- }
+ ch = fifo_pull();
+ T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch)));
+ returnCode(ch);
+ }
- /*
- * Handle cooked mode. Grab a string from the screen,
- * stuff its contents in the FIFO queue, and pop off
- * the first character to return it.
- */
- if (head == -1 && !SP->_raw && !SP->_cbreak)
- {
- char buf[MAXCOLUMNS], *sp;
+ /*
+ * Handle cooked mode. Grab a string from the screen,
+ * stuff its contents in the FIFO queue, and pop off
+ * the first character to return it.
+ */
+ if (head == -1 && !SP->_raw && !SP->_cbreak) {
+ char buf[MAXCOLUMNS], *sp;
- T(("filling queue in cooked mode"));
+ T(("filling queue in cooked mode"));
- wgetnstr(win, buf, MAXCOLUMNS);
+ wgetnstr(win, buf, MAXCOLUMNS);
- /* ungetch in reverse order */
- ungetch('\n');
- for (sp = buf+strlen(buf); sp>buf; sp--)
- ungetch(sp[-1]);
+ /* ungetch in reverse order */
+ ungetch('\n');
+ for (sp = buf + strlen(buf); sp > buf; sp--)
+ ungetch(sp[-1]);
- returnCode(fifo_pull());
- }
+ returnCode(fifo_pull());
+ }
- if (wgetch_should_refresh(win))
- wrefresh(win);
+ if (wgetch_should_refresh(win))
+ wrefresh(win);
- if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1))
- {
- int delay;
+ if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
+ int delay;
- T(("timed delay in wgetch()"));
- if (SP->_cbreak > 1)
- delay = (SP->_cbreak - 1) * 100;
- else
- delay = win->_delay;
+ T(("timed delay in wgetch()"));
+ if (SP->_cbreak > 1)
+ delay = (SP->_cbreak - 1) * 100;
+ else
+ delay = win->_delay;
- T(("delay is %d milliseconds", delay));
+ T(("delay is %d milliseconds", delay));
- if (head == -1) /* fifo is empty */
- if (!_nc_timed_wait(3, delay, (int *)0))
- returnCode(ERR);
- /* else go on to read data available */
- }
+ if (head == -1) /* fifo is empty */
+ if (!_nc_timed_wait(3, delay, (int *) 0))
+ returnCode(ERR);
+ /* else go on to read data available */
+ }
- if (win->_use_keypad)
- {
- /*
- * This is tricky. We only want to get special-key
- * events one at a time. But we want to accumulate
- * mouse events until either (a) the mouse logic tells
- * us it's picked up a complete gesture, or (b)
- * there's a detectable time lapse after one.
- *
- * Note: if the mouse code starts failing to compose
- * press/release events into clicks, you should probably
- * increase the wait with mouseinterval().
- */
- int runcount = 0;
-
- do {
- ch = kgetch(win);
- if (ch == KEY_MOUSE)
- {
- ++runcount;
- if (SP->_mouse_inline(SP))
- break;
- }
- } while
- (ch == KEY_MOUSE
- && (_nc_timed_wait(3, SP->_maxclick, (int *)0)
- || !SP->_mouse_parse(runcount)));
- if (runcount > 0 && ch != KEY_MOUSE)
- {
- /* mouse event sequence ended by keystroke, push it */
- ungetch(ch);
- ch = KEY_MOUSE;
- }
- } else {
- if (head == -1)
- fifo_push();
- ch = fifo_pull();
+ if (win->_use_keypad) {
+ /*
+ * This is tricky. We only want to get special-key
+ * events one at a time. But we want to accumulate
+ * mouse events until either (a) the mouse logic tells
+ * us it's picked up a complete gesture, or (b)
+ * there's a detectable time lapse after one.
+ *
+ * Note: if the mouse code starts failing to compose
+ * press/release events into clicks, you should probably
+ * increase the wait with mouseinterval().
+ */
+ int runcount = 0;
+
+ do {
+ ch = kgetch(win);
+ if (ch == KEY_MOUSE) {
+ ++runcount;
+ if (SP->_mouse_inline(SP))
+ break;
+ }
+ } while
+ (ch == KEY_MOUSE
+ && (_nc_timed_wait(3, SP->_maxclick, (int *) 0)
+ || !SP->_mouse_parse(runcount)));
+ if (runcount > 0 && ch != KEY_MOUSE) {
+ /* mouse event sequence ended by keystroke, push it */
+ ungetch(ch);
+ ch = KEY_MOUSE;
}
+ } else {
+ if (head == -1)
+ fifo_push();
+ ch = fifo_pull();
+ }
- if (ch == ERR)
- {
+ if (ch == ERR) {
#if USE_SIZECHANGE
- if(SP->_sig_winch)
- {
- _nc_update_screensize();
- /* resizeterm can push KEY_RESIZE */
- if(cooked_key_in_fifo())
- {
- ch = fifo_pull();
- T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch));)
- returnCode(ch);
- }
+ if (SP->_sig_winch) {
+ _nc_update_screensize();
+ /* resizeterm can push KEY_RESIZE */
+ if (cooked_key_in_fifo()) {
+ ch = fifo_pull();
+ T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch)));
+ returnCode(ch);
}
-#endif
- T(("wgetch returning ERR"));
- returnCode(ERR);
}
-
- /*
- * Simulate ICRNL mode
- */
- if ((ch == '\r') && SP->_nl)
- ch = '\n';
-
- /* Strip 8th-bit if so desired. We do this only for characters that
- * are in the range 128-255, to provide compatibility with terminals
- * that display only 7-bit characters. Note that 'ch' may be a
- * function key at this point, so we mustn't strip _those_.
- */
- if ((ch < KEY_MIN) && (ch & 0x80))
- if (!SP->_use_meta)
- ch &= 0x7f;
-
- if (SP->_echo && ch < KEY_MIN && !(win->_flags & _ISPAD))
- wechochar(win, (chtype)ch);
-
- T(("wgetch returning : %#x = %s", ch, _trace_key(ch)));
-
- returnCode(ch);
+#endif
+ T(("wgetch returning ERR"));
+ returnCode(ERR);
+ }
+
+ /*
+ * If echo() is in effect, display the printable version of the
+ * key on the screen. Carriage return and backspace are treated
+ * specially by Solaris curses:
+ *
+ * If carriage return is defined as a function key in the
+ * terminfo, e.g., kent, then Solaris may return either ^J (or ^M
+ * if nonl() is set) or KEY_ENTER depending on the echo() mode.
+ * We echo before translating carriage return based on nonl(),
+ * since the visual result simply moves the cursor to column 0.
+ *
+ * Backspace is a different matter. Solaris curses does not
+ * translate it to KEY_BACKSPACE if kbs=^H. This does not depend
+ * on the stty modes, but appears to be a hardcoded special case.
+ * This is a difference from ncurses, which uses the terminfo entry.
+ * However, we provide the same visual result as Solaris, moving the
+ * cursor to the left.
+ */
+ if (SP->_echo && !(win->_flags & _ISPAD)) {
+ chtype backup = (ch == KEY_BACKSPACE) ? '\b' : ch;
+ if (backup < KEY_MIN)
+ wechochar(win, backup);
+ }
+
+ /*
+ * Simulate ICRNL mode
+ */
+ if ((ch == '\r') && SP->_nl)
+ ch = '\n';
+
+ /* Strip 8th-bit if so desired. We do this only for characters that
+ * are in the range 128-255, to provide compatibility with terminals
+ * that display only 7-bit characters. Note that 'ch' may be a
+ * function key at this point, so we mustn't strip _those_.
+ */
+ if ((ch < KEY_MIN) && (ch & 0x80))
+ if (!SP->_use_meta)
+ ch &= 0x7f;
+
+ T(("wgetch returning : %#x = %s", ch, _trace_key(ch)));
+
+ returnCode(ch);
}
-
/*
** int
** kgetch()
@@ -347,68 +369,63 @@ int ch;
static int
kgetch(WINDOW *win GCC_UNUSED)
{
-struct tries *ptr;
-int ch = 0;
-int timeleft = ESCDELAY;
-
- TR(TRACE_IEVENT, ("kgetch(%p) called", win));
-
- ptr = SP->_keytry;
-
- for(;;)
- {
- if (!raw_key_in_fifo())
- {
- if(fifo_push() == ERR)
- {
- peek = head; /* the keys stay uninterpreted */
- return ERR;
- }
- }
- ch = fifo_peek();
- if (ch >= KEY_MIN)
- {
- peek = head;
- /* assume the key is the last in fifo */
- t_dec(); /* remove the key */
- return ch;
- }
-
- TR(TRACE_IEVENT, ("ch: %s", _trace_key((unsigned char)ch)));
- while ((ptr != NULL) && (ptr->ch != (unsigned char)ch))
- ptr = ptr->sibling;
+ struct tries *ptr;
+ int ch = 0;
+ int timeleft = ESCDELAY;
+
+ TR(TRACE_IEVENT, ("kgetch(%p) called", win));
+
+ ptr = SP->_keytry;
+
+ for (;;) {
+ if (!raw_key_in_fifo()) {
+ if (fifo_push() == ERR) {
+ peek = head; /* the keys stay uninterpreted */
+ return ERR;
+ }
+ }
+ ch = fifo_peek();
+ if (ch >= KEY_MIN) {
+ peek = head;
+ /* assume the key is the last in fifo */
+ t_dec(); /* remove the key */
+ return ch;
+ }
+
+ TR(TRACE_IEVENT, ("ch: %s", _trace_key((unsigned char) ch)));
+ while ((ptr != NULL) && (ptr->ch != (unsigned char) ch))
+ ptr = ptr->sibling;
#ifdef TRACE
- if (ptr == NULL)
- {TR(TRACE_IEVENT, ("ptr is null"));}
- else
- TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
- ptr, ptr->ch, ptr->value));
+ if (ptr == NULL) {
+ TR(TRACE_IEVENT, ("ptr is null"));
+ } else
+ TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
+ ptr, ptr->ch, ptr->value));
#endif /* TRACE */
- if (ptr == NULL)
- break;
-
- if (ptr->value != 0) { /* sequence terminated */
- TR(TRACE_IEVENT, ("end of sequence"));
- if (peek == tail)
- fifo_clear();
- else
- head = peek;
- return(ptr->value);
- }
-
- ptr = ptr->child;
-
- if (!raw_key_in_fifo())
- {
- TR(TRACE_IEVENT, ("waiting for rest of sequence"));
- if (!_nc_timed_wait(3, timeleft, &timeleft)) {
- TR(TRACE_IEVENT, ("ran out of time"));
- break;
- }
- }
+ if (ptr == NULL)
+ break;
+
+ if (ptr->value != 0) { /* sequence terminated */
+ TR(TRACE_IEVENT, ("end of sequence"));
+ if (peek == tail)
+ fifo_clear();
+ else
+ head = peek;
+ return (ptr->value);
}
- ch = fifo_pull();
- peek = head;
- return ch;
+
+ ptr = ptr->child;
+
+ if (!raw_key_in_fifo()) {
+ TR(TRACE_IEVENT, ("waiting for rest of sequence"));
+ if (!_nc_timed_wait(3, timeleft, &timeleft)) {
+ TR(TRACE_IEVENT, ("ran out of time"));
+ break;
+ }
+ }
+ }
+ ch = fifo_pull();
+ peek = head;
+ return ch;
}
diff --git a/contrib/ncurses/ncurses/base/lib_hline.c b/contrib/ncurses/ncurses/base/lib_hline.c
index 3b0a602eeee9..71d6b140424c 100644
--- a/contrib/ncurses/ncurses/base/lib_hline.c
+++ b/contrib/ncurses/ncurses/base/lib_hline.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_hline.c
**
@@ -42,35 +40,36 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_hline.c,v 1.4 1998/06/28 00:11:01 tom Exp $")
+MODULE_ID("$Id: lib_hline.c,v 1.5 2000/04/29 21:14:30 tom Exp $")
-int whline(WINDOW *win, chtype ch, int n)
+int
+whline(WINDOW *win, chtype ch, int n)
{
-int code = ERR;
-short start;
-short end;
+ int code = ERR;
+ NCURSES_SIZE_T start;
+ NCURSES_SIZE_T end;
- T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n));
+ T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n));
- if (win) {
- struct ldat *line = &(win->_line[win->_cury]);
+ if (win) {
+ struct ldat *line = &(win->_line[win->_cury]);
- start = win->_curx;
- end = start + n - 1;
- if (end > win->_maxx)
- end = win->_maxx;
+ start = win->_curx;
+ end = start + n - 1;
+ if (end > win->_maxx)
+ end = win->_maxx;
- CHANGED_RANGE(line, start, end);
+ CHANGED_RANGE(line, start, end);
- if (ch == 0)
- ch = ACS_HLINE;
- ch = _nc_render(win, ch);
+ if (ch == 0)
+ ch = ACS_HLINE;
+ ch = _nc_render(win, ch);
- while ( end >= start) {
- line->text[end] = ch;
- end--;
- }
- code = OK;
+ while (end >= start) {
+ line->text[end] = ch;
+ end--;
}
- returnCode(code);
+ code = OK;
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_insstr.c b/contrib/ncurses/ncurses/base/lib_insstr.c
index cba147318b8e..a2275f9457b6 100644
--- a/contrib/ncurses/ncurses/base/lib_insstr.c
+++ b/contrib/ncurses/ncurses/base/lib_insstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_insstr.c
**
@@ -43,39 +41,41 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_insstr.c,v 1.13 1999/03/14 00:27:21 tom Exp $")
+MODULE_ID("$Id: lib_insstr.c,v 1.14 2000/04/29 21:16:41 tom Exp $")
-int winsnstr(WINDOW *win, const char *s, int n)
+int
+winsnstr(WINDOW *win, const char *s, int n)
{
-int code = ERR;
-short oy;
-short ox ;
-const unsigned char *str = (const unsigned char *)s;
-const unsigned char *cp;
+ int code = ERR;
+ NCURSES_SIZE_T oy;
+ NCURSES_SIZE_T ox;
+ const unsigned char *str = (const unsigned char *) s;
+ const unsigned char *cp;
- T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n));
+ T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n));
- if (win && str) {
- oy = win->_cury; ox = win->_curx;
- for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
+ if (win && str) {
+ oy = win->_cury;
+ ox = win->_curx;
+ for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b')
- _nc_waddch_nosync(win, (chtype)(*cp));
+ _nc_waddch_nosync(win, (chtype) (*cp));
else if (is7bits(*cp) && iscntrl(*cp)) {
- winsch(win, ' ' + (chtype)(*cp));
- winsch(win, '^');
- win->_curx += 2;
+ winsch(win, ' ' + (chtype) (*cp));
+ winsch(win, '^');
+ win->_curx += 2;
} else {
- winsch(win, (chtype)(*cp));
- win->_curx++;
+ winsch(win, (chtype) (*cp));
+ win->_curx++;
}
if (win->_curx > win->_maxx)
- win->_curx = win->_maxx;
- }
-
- win->_curx = ox;
- win->_cury = oy;
- _nc_synchook(win);
- code = OK;
+ win->_curx = win->_maxx;
}
- returnCode(code);
+
+ win->_curx = ox;
+ win->_cury = oy;
+ _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 d34d48342e4f..59db16d1aea6 100644
--- a/contrib/ncurses/ncurses/base/lib_mouse.c
+++ b/contrib/ncurses/ncurses/base/lib_mouse.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 *
@@ -64,8 +64,7 @@
*/
#ifdef __EMX__
-# include "io.h"
-# include "fcntl.h"
+# include <io.h>
# define INCL_DOS
# define INCL_VIO
# define INCL_KBD
@@ -85,13 +84,13 @@
#endif
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.45 1999/10/22 21:39:02 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.52 2000/06/29 23:02:26 tom Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
#define INVALID_EVENT -1
-static int mousetype;
+static int mousetype;
#define M_XTERM -1 /* use xterm's mouse tracking? */
#define M_NONE 0 /* no mouse device */
#define M_GPM 1 /* use GPM */
@@ -104,7 +103,7 @@ static Gpm_Connect gpm_connect;
#endif
#endif
-static mmask_t eventmask; /* current event mask */
+static mmask_t eventmask; /* current event mask */
static bool _nc_mouse_parse(int);
static void _nc_mouse_resume(SCREEN *);
@@ -116,22 +115,23 @@ static void _nc_mouse_wrap(SCREEN *);
* wgetch() may refer to the size and call _nc_mouse_parse() before circular
* list overflow.
*/
-static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
-static MEVENT *eventp = events; /* next free slot in event queue */
+static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
+static MEVENT *eventp = events; /* next free slot in event queue */
#define NEXT(ep) ((ep == events + EV_MAX - 1) ? events : ep + 1)
#define PREV(ep) ((ep == events) ? events + EV_MAX - 1 : ep - 1)
#ifdef TRACE
-static void _trace_slot(const char *tag)
+static void
+_trace_slot(const char *tag)
{
- MEVENT *ep;
+ MEVENT *ep;
- _tracef(tag);
+ _tracef(tag);
- for (ep = events; ep < events + EV_MAX; ep++)
- _tracef("mouse event queue slot %ld = %s",
- (long) (ep - events),
- _tracemouse(ep));
+ for (ep = events; ep < events + EV_MAX; ep++)
+ _tracef("mouse event queue slot %ld = %s",
+ (long) (ep - events),
+ _tracemouse(ep));
}
#endif
@@ -143,8 +143,8 @@ static void _trace_slot(const char *tag)
static int mouse_wfd;
static int mouse_thread;
static int mouse_activated;
-static char mouse_buttons[] = { 0, 1, 3, 2};
-
+static char mouse_buttons[] =
+{0, 1, 3, 2};
# define M_FD(sp) sp->_mouse_fd
@@ -174,34 +174,34 @@ mouse_server(unsigned long ignored GCC_UNUSED)
unsigned long ignore;
/* open the handle for the mouse */
- if (MouOpen(NULL,&hmou) == 0) {
+ if (MouOpen(NULL, &hmou) == 0) {
- if (MouSetEventMask(&mask,hmou) == 0
- && MouDrawPtr(hmou) == 0) {
+ if (MouSetEventMask(&mask, hmou) == 0
+ && MouDrawPtr(hmou) == 0) {
for (;;) {
/* sit and wait on the event queue */
- if (MouReadEventQue(&mouev,&fWait,hmou))
- break;
+ if (MouReadEventQue(&mouev, &fWait, hmou))
+ break;
if (!mouse_activated)
goto finish;
/*
* OS/2 numbers a 3-button mouse inconsistently from other
* platforms:
- * 1 = left
- * 2 = right
- * 3 = middle.
+ * 1 = left
+ * 2 = right
+ * 3 = middle.
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
- write_event(mouev.fs & MOUSE_BN1_DOWN,
- mouse_buttons[1], mouev.col, mouev.row);
+ write_event(mouev.fs & MOUSE_BN1_DOWN,
+ 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);
+ write_event(mouev.fs & MOUSE_BN2_DOWN,
+ 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);
+ write_event(mouev.fs & MOUSE_BN3_DOWN,
+ mouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
@@ -211,11 +211,11 @@ mouse_server(unsigned long ignored GCC_UNUSED)
DosWrite(2, errmess, strlen(errmess), &ignore);
MouClose(hmou);
}
- DosExit(EXIT_THREAD, 0L );
+ DosExit(EXIT_THREAD, 0L);
}
static void
server_state(const int state)
-{ /* It would be nice to implement pointer-off and stop looping... */
+{ /* It would be nice to implement pointer-off and stop looping... */
mouse_activated = state;
}
@@ -223,44 +223,30 @@ server_state(const int state)
static int initialized;
-static void _nc_mouse_init(void)
-/* initialize the mouse */
+static void
+initialize_mousetype(void)
{
- int i;
-
- if (initialized) {
- return;
- }
- initialized = TRUE;
-
- TR(MY_TRACE, ("_nc_mouse_init() called"));
-
- for (i = 0; i < EV_MAX; i++)
- events[i].id = INVALID_EVENT;
-
- /* we know how to recognize mouse events under xterm */
- if (key_mouse != 0
- && getenv("DISPLAY") != 0)
- mousetype = M_XTERM;
+ static const char *xterm_kmous = "\033[M";
+ /* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
- else if (!strncmp(cur_term->type.term_names, "linux", 5))
- {
- /* GPM: initialize connection to gpm server */
- gpm_connect.eventMask = GPM_DOWN|GPM_UP;
- gpm_connect.defaultMask = ~(gpm_connect.eventMask|GPM_HARD);
- gpm_connect.minMod = 0;
- gpm_connect.maxMod = ~((1<<KG_SHIFT)|(1<<KG_SHIFTL)|(1<<KG_SHIFTR));
- if (Gpm_Open (&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
- mousetype = M_GPM;
- SP->_mouse_fd = gpm_fd;
- }
+ /* GPM: initialize connection to gpm server */
+ gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ gpm_connect.defaultMask = ~(gpm_connect.eventMask | GPM_HARD);
+ gpm_connect.minMod = 0;
+ gpm_connect.maxMod = ~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR));
+ if (Gpm_Open(&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
+ mousetype = M_GPM;
+ SP->_mouse_fd = gpm_fd;
+ return;
}
#endif
/* OS/2 VIO */
#ifdef USE_EMX_MOUSE
- if (!mouse_thread && mousetype != M_XTERM && key_mouse) {
+ if (!mouse_thread
+ && strstr(cur_term->type.term_names, "xterm") == 0
+ && key_mouse) {
int handles[2];
if (pipe(handles) < 0) {
perror("mouse pipe error");
@@ -283,19 +269,53 @@ static void _nc_mouse_init(void)
setmode(handles[0], O_BINARY);
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);
- if (rc)
+ rc = DosCreateThread((unsigned long *) &mouse_thread,
+ mouse_server, 0, 0, 8192);
+ if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
- else
+ } else {
mousetype = M_XTERM;
+ return;
+ }
}
}
#endif
- T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ /* we know how to recognize mouse events under "xterm" */
+ if (key_mouse != 0) {
+ if (!strcmp(key_mouse, xterm_kmous)) {
+ mousetype = M_XTERM;
+ return;
+ }
+ } else if (strstr(cur_term->type.term_names, "xterm") != 0) {
+ (void) _nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE);
+ mousetype = M_XTERM;
+ return;
+ }
+}
+
+static void
+_nc_mouse_init(void)
+/* initialize the mouse */
+{
+ int i;
+
+ if (!initialized) {
+ initialized = TRUE;
+
+ TR(MY_TRACE, ("_nc_mouse_init() called"));
+
+ for (i = 0; i < EV_MAX; i++)
+ events[i].id = INVALID_EVENT;
+
+ initialize_mousetype();
+
+ T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ }
}
-static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
+static bool
+_nc_mouse_event(SCREEN * sp GCC_UNUSED)
/* query to see if there is a pending mouse event */
{
#if USE_GPM_SUPPORT
@@ -303,23 +323,27 @@ static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
Gpm_Event ev;
if (gpm_fd >= 0
- && _nc_timed_wait(2, 0, (int *)0)
- && Gpm_GetEvent(&ev) == 1)
- {
+ && (_nc_timed_wait(3, 0, (int *) 0) & 2) != 0
+ && Gpm_GetEvent(&ev) == 1) {
eventp->id = 0; /* there's only one mouse... */
eventp->bstate = 0;
- switch (ev.type & 0x0f)
- {
- case(GPM_DOWN):
- if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_PRESSED;
- if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_PRESSED;
- if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_PRESSED;
+ switch (ev.type & 0x0f) {
+ case (GPM_DOWN):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_PRESSED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_PRESSED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_PRESSED;
break;
- case(GPM_UP):
- if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_RELEASED;
- if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_RELEASED;
- if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_RELEASED;
+ case (GPM_UP):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_RELEASED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_RELEASED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_RELEASED;
break;
default:
break;
@@ -336,20 +360,20 @@ static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
#endif
/* xterm: never have to query, mouse events are in the keyboard stream */
- return(FALSE); /* no event waiting */
+ return (FALSE); /* no event waiting */
}
-static bool _nc_mouse_inline(SCREEN *sp)
+static bool
+_nc_mouse_inline(SCREEN * sp)
/* mouse report received in the keyboard stream -- parse its info */
{
TR(MY_TRACE, ("_nc_mouse_inline() called"));
- if (mousetype == M_XTERM)
- {
- unsigned char kbuf[4];
- MEVENT *prev;
- size_t grabbed;
- int res;
+ if (mousetype == M_XTERM) {
+ unsigned char kbuf[4];
+ MEVENT *prev;
+ size_t grabbed;
+ int res;
/* This code requires that your xterm entry contain the kmous
* capability and that it be set to the \E[M documented in the
@@ -381,28 +405,27 @@ static bool _nc_mouse_inline(SCREEN *sp)
* single clist item. It always does under Linux but often
* fails to under Solaris.
*/
- for (grabbed = 0; grabbed < 3; grabbed += res)
- {
+ for (grabbed = 0; grabbed < 3; grabbed += res) {
- /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
+ /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
#ifdef USE_EMX_MOUSE
- res = read( M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
+ res = read(M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
#else
- res = read(sp->_ifd, kbuf + grabbed, 3-grabbed);
+ res = read(sp->_ifd, kbuf + grabbed, 3 - grabbed);
#endif
- if (res == -1)
- break;
+ if (res == -1)
+ break;
}
kbuf[3] = '\0';
- TR(TRACE_IEVENT, ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+ TR(TRACE_IEVENT,
+ ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
eventp->id = 0; /* there's only one mouse... */
/* processing code goes here */
eventp->bstate = 0;
- switch (kbuf[0] & 0x3)
- {
+ switch (kbuf[0] & 0x3) {
case 0x0:
eventp->bstate = BUTTON1_PRESSED;
#ifdef USE_EMX_MOUSE
@@ -434,8 +457,8 @@ static bool _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
@@ -444,11 +467,11 @@ static bool _nc_mouse_inline(SCREEN *sp)
*/
prev = PREV(eventp);
if (!(prev->bstate & BUTTON1_PRESSED))
- eventp->bstate &=~ BUTTON1_RELEASED;
+ eventp->bstate &= ~BUTTON1_RELEASED;
if (!(prev->bstate & BUTTON2_PRESSED))
- eventp->bstate &=~ BUTTON2_RELEASED;
+ eventp->bstate &= ~BUTTON2_RELEASED;
if (!(prev->bstate & BUTTON3_PRESSED))
- eventp->bstate &=~ BUTTON3_RELEASED;
+ eventp->bstate &= ~BUTTON3_RELEASED;
break;
}
@@ -464,21 +487,23 @@ static bool _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",
+ TR(MY_TRACE,
+ ("_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);
-#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
- return(TRUE);
+#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
+ return (TRUE);
#endif
}
- return(FALSE);
+ return (FALSE);
}
-static void mouse_activate(bool on)
+static void
+mouse_activate(bool on)
{
if (!on && !initialized)
return;
@@ -508,11 +533,11 @@ static void mouse_activate(bool on)
/* Make runtime binding to cut down on object size of applications that
* do not use the mouse (e.g., 'clear').
*/
- SP->_mouse_event = _nc_mouse_event;
+ SP->_mouse_event = _nc_mouse_event;
SP->_mouse_inline = _nc_mouse_inline;
- SP->_mouse_parse = _nc_mouse_parse;
+ SP->_mouse_parse = _nc_mouse_parse;
SP->_mouse_resume = _nc_mouse_resume;
- SP->_mouse_wrap = _nc_mouse_wrap;
+ SP->_mouse_wrap = _nc_mouse_wrap;
} else {
@@ -540,12 +565,13 @@ static void mouse_activate(bool on)
*
**************************************************************************/
-static bool _nc_mouse_parse(int runcount)
+static bool
+_nc_mouse_parse(int runcount)
/* parse a run of atomic mouse events into a gesture */
{
- MEVENT *ep, *runp, *next, *prev = PREV(eventp);
- int n;
- bool merge;
+ MEVENT *ep, *runp, *next, *prev = PREV(eventp);
+ int n;
+ bool merge;
TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
@@ -570,14 +596,14 @@ static bool _nc_mouse_parse(int runcount)
* button basis, as long as the device-dependent mouse code puts stuff
* on the queue in MEVENT format.
*/
- if (runcount == 1)
- {
- TR(MY_TRACE, ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ if (runcount == 1) {
+ TR(MY_TRACE,
+ ("_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;
+ ? ((prev->bstate & eventmask) ? TRUE : FALSE)
+ : FALSE;
}
/* find the start of the run */
@@ -587,12 +613,11 @@ static bool _nc_mouse_parse(int runcount)
}
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ 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,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -600,36 +625,31 @@ static bool _nc_mouse_parse(int runcount)
/* first pass; merge press/release pairs */
do {
merge = FALSE;
- for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
- {
+ for (ep = runp; next = NEXT(ep), next != eventp; ep = next) {
if (ep->x == next->x && ep->y == next->y
- && (ep->bstate & (BUTTON1_PRESSED|BUTTON2_PRESSED|BUTTON3_PRESSED))
+ && (ep->bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED))
&& (!(ep->bstate & BUTTON1_PRESSED)
== !(next->bstate & BUTTON1_RELEASED))
&& (!(ep->bstate & BUTTON2_PRESSED)
== !(next->bstate & BUTTON2_RELEASED))
&& (!(ep->bstate & BUTTON3_PRESSED)
== !(next->bstate & BUTTON3_RELEASED))
- )
- {
+ ) {
if ((eventmask & BUTTON1_CLICKED)
- && (ep->bstate & BUTTON1_PRESSED))
- {
- ep->bstate &=~ BUTTON1_PRESSED;
+ && (ep->bstate & BUTTON1_PRESSED)) {
+ ep->bstate &= ~BUTTON1_PRESSED;
ep->bstate |= BUTTON1_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_CLICKED)
- && (ep->bstate & BUTTON2_PRESSED))
- {
- ep->bstate &=~ BUTTON2_PRESSED;
+ && (ep->bstate & BUTTON2_PRESSED)) {
+ ep->bstate &= ~BUTTON2_PRESSED;
ep->bstate |= BUTTON2_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_CLICKED)
- && (ep->bstate & BUTTON3_PRESSED))
- {
- ep->bstate &=~ BUTTON3_PRESSED;
+ && (ep->bstate & BUTTON3_PRESSED)) {
+ ep->bstate &= ~BUTTON3_PRESSED;
ep->bstate |= BUTTON3_CLICKED;
merge = TRUE;
}
@@ -641,12 +661,11 @@ static bool _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ 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,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -668,12 +687,11 @@ static bool _nc_mouse_parse(int runcount)
* which would get us into portability trouble.
*/
do {
- MEVENT *follower;
+ MEVENT *follower;
merge = FALSE;
for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
- if (ep->id != INVALID_EVENT)
- {
+ if (ep->id != INVALID_EVENT) {
if (next->id != INVALID_EVENT)
continue;
follower = NEXT(next);
@@ -684,26 +702,22 @@ static bool _nc_mouse_parse(int runcount)
if ((ep->bstate &
(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
&& (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
- {
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED))
- {
- follower->bstate &=~ BUTTON1_CLICKED;
+ && (follower->bstate & BUTTON1_CLICKED)) {
+ follower->bstate &= ~BUTTON1_CLICKED;
follower->bstate |= BUTTON1_DOUBLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED))
- {
- follower->bstate &=~ BUTTON2_CLICKED;
+ && (follower->bstate & BUTTON2_CLICKED)) {
+ follower->bstate &= ~BUTTON2_CLICKED;
follower->bstate |= BUTTON2_DOUBLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED))
- {
- follower->bstate &=~ BUTTON3_CLICKED;
+ && (follower->bstate & BUTTON3_CLICKED)) {
+ follower->bstate &= ~BUTTON3_CLICKED;
follower->bstate |= BUTTON3_DOUBLE_CLICKED;
merge = TRUE;
}
@@ -714,29 +728,25 @@ static bool _nc_mouse_parse(int runcount)
/* merge double-click events forward */
if ((ep->bstate &
(BUTTON1_DOUBLE_CLICKED
- | BUTTON2_DOUBLE_CLICKED
- | BUTTON3_DOUBLE_CLICKED))
+ | BUTTON2_DOUBLE_CLICKED
+ | BUTTON3_DOUBLE_CLICKED))
&& (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
- {
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED))
- {
- follower->bstate &=~ BUTTON1_CLICKED;
+ && (follower->bstate & BUTTON1_CLICKED)) {
+ follower->bstate &= ~BUTTON1_CLICKED;
follower->bstate |= BUTTON1_TRIPLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED))
- {
- follower->bstate &=~ BUTTON2_CLICKED;
+ && (follower->bstate & BUTTON2_CLICKED)) {
+ follower->bstate &= ~BUTTON2_CLICKED;
follower->bstate |= BUTTON2_TRIPLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED))
- {
- follower->bstate &=~ BUTTON3_CLICKED;
+ && (follower->bstate & BUTTON3_CLICKED)) {
+ follower->bstate &= ~BUTTON3_CLICKED;
follower->bstate |= BUTTON3_TRIPLE_CLICKED;
merge = TRUE;
}
@@ -748,12 +758,11 @@ static bool _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ 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,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -766,28 +775,28 @@ static bool _nc_mouse_parse(int runcount)
if (prev->id == INVALID_EVENT || !(prev->bstate & eventmask)) {
eventp = prev;
}
-
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ 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,
+ (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)));
+ TR(MY_TRACE,
+ ("_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? */
- return(PREV(eventp)->id != INVALID_EVENT);
+ return (PREV(eventp)->id != INVALID_EVENT);
}
-static void _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
+static void
+_nc_mouse_wrap(SCREEN * sp GCC_UNUSED)
/* release mouse -- called by endwin() before shellout/exit */
{
TR(MY_TRACE, ("_nc_mouse_wrap() called"));
@@ -799,13 +808,14 @@ static void _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
break;
#if USE_GPM_SUPPORT
/* GPM: pass all mouse events to next client */
- case M_GPM:
- break;
+ case M_GPM:
+ break;
#endif
}
}
-static void _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
+static void
+_nc_mouse_resume(SCREEN * sp GCC_UNUSED)
/* re-connect to mouse -- called by doupdate() after shellout */
{
TR(MY_TRACE, ("_nc_mouse_resume() called"));
@@ -823,22 +833,22 @@ static void _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
*
**************************************************************************/
-int getmouse(MEVENT *aevent)
+int
+getmouse(MEVENT * aevent)
/* grab a copy of the current mouse event */
{
T((T_CALLED("getmouse(%p)"), aevent));
- if (aevent && (mousetype != M_NONE))
- {
+ if (aevent && (mousetype != M_NONE)) {
/* compute the current-event pointer */
- MEVENT *prev = PREV(eventp);
+ MEVENT *prev = PREV(eventp);
/* copy the event we find there */
*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);
@@ -846,7 +856,8 @@ int getmouse(MEVENT *aevent)
returnCode(ERR);
}
-int ungetmouse(MEVENT *aevent)
+int
+ungetmouse(MEVENT * aevent)
/* enqueue a synthesized mouse event to be seen by the next wgetch() */
{
/* stick the given event in the next-free slot */
@@ -859,7 +870,8 @@ int ungetmouse(MEVENT *aevent)
return ungetch(KEY_MOUSE);
}
-mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
+mmask_t
+mousemask(mmask_t newmask, mmask_t * oldmask)
/* set the mouse event mask */
{
mmask_t result = 0;
@@ -873,16 +885,15 @@ mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
returnCode(0);
_nc_mouse_init();
- if ( mousetype != M_NONE )
- {
+ 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);
@@ -892,21 +903,22 @@ mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
returnCode(result);
}
-bool wenclose(const WINDOW *win, int y, int x)
+bool
+wenclose(const WINDOW *win, int y, int x)
/* check to see if given window encloses given screen location */
{
- if (win)
- {
+ 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;
}
-int mouseinterval(int maxclick)
+int
+mouseinterval(int maxclick)
/* set the maximum mouse interval within which to recognize a click */
{
int oldval;
@@ -919,46 +931,44 @@ int mouseinterval(int maxclick)
oldval = DEFAULT_MAXCLICK;
}
- return(oldval);
+ return (oldval);
}
/* This may be used by other routines to ask for the existence of mouse
support */
-int _nc_has_mouse(void) {
- return (mousetype==M_NONE ? 0:1);
+int
+_nc_has_mouse(void)
+{
+ return (mousetype == M_NONE ? 0 : 1);
}
-bool wmouse_trafo(const WINDOW* win, int* pY, int* pX, bool to_screen)
+bool
+wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
{
- bool result = FALSE;
-
- if (win && pY && pX)
- {
- int y = *pY; int x = *pX;
-
- if (to_screen)
- {
- y += win->_begy + win->_yoffset;
- x += win->_begx;
- if (wenclose(win,y,x))
- result = TRUE;
- }
- else
- {
- if (wenclose(win,y,x))
- {
- y -= (win->_begy + win->_yoffset);
- x -= win->_begx;
- result = TRUE;
+ bool result = FALSE;
+
+ if (win && pY && pX) {
+ int y = *pY;
+ int x = *pX;
+
+ if (to_screen) {
+ y += win->_begy + win->_yoffset;
+ x += win->_begx;
+ if (wenclose(win, y, x))
+ result = TRUE;
+ } else {
+ if (wenclose(win, y, x)) {
+ y -= (win->_begy + win->_yoffset);
+ x -= win->_begx;
+ result = TRUE;
}
}
- if (result)
- {
- *pX = x;
- *pY = y;
+ if (result) {
+ *pX = x;
+ *pY = y;
}
}
- return(result);
+ return (result);
}
/* lib_mouse.c ends here */
diff --git a/contrib/ncurses/ncurses/base/lib_move.c b/contrib/ncurses/ncurses/base/lib_move.c
index 6f5bddff33ea..68415d6e620d 100644
--- a/contrib/ncurses/ncurses/base/lib_move.c
+++ b/contrib/ncurses/ncurses/base/lib_move.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> *
****************************************************************************/
-
/*
** lib_move.c
**
@@ -41,23 +40,22 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_move.c,v 1.8 1998/02/11 12:13:53 tom Exp $")
+MODULE_ID("$Id: lib_move.c,v 1.9 2000/04/29 21:11:19 tom Exp $")
int
wmove(WINDOW *win, int y, int x)
{
- T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
-
- if (win &&
- x >= 0 && x <= win->_maxx &&
- y >= 0 && y <= win->_maxy)
- {
- win->_curx = (short)x;
- win->_cury = (short)y;
-
- win->_flags &= ~_WRAPPED;
- win->_flags |= _HASMOVED;
- returnCode(OK);
- } else
- returnCode(ERR);
+ T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
+
+ if (win &&
+ x >= 0 && x <= win->_maxx &&
+ y >= 0 && y <= win->_maxy) {
+ win->_curx = (NCURSES_SIZE_T) x;
+ win->_cury = (NCURSES_SIZE_T) y;
+
+ win->_flags &= ~_WRAPPED;
+ win->_flags |= _HASMOVED;
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c
index 9a4919bf5292..08e35cf50182 100644
--- a/contrib/ncurses/ncurses/base/lib_newterm.c
+++ b/contrib/ncurses/ncurses/base/lib_newterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_newterm.c
**
@@ -46,11 +44,12 @@
#define _POSIX_SOURCE
#endif
-#include <term.h> /* clear_screen, cup & friends, cur_term */
+#include <term.h> /* clear_screen, cup & friends, cur_term */
+#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.41 1999/07/24 20:07:48 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.46 2000/07/01 22:26:22 tom Exp $")
-#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
+#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
#endif
@@ -62,20 +61,21 @@ MODULE_ID("$Id: lib_newterm.c,v 1.41 1999/07/24 20:07:48 tom Exp $")
* The newterm function also initializes terminal settings, and since initscr
* is supposed to behave as if it calls newterm, we do it here.
*/
-static inline int _nc_initscr(void)
+static inline int
+_nc_initscr(void)
{
- /* for extended XPG4 conformance requires cbreak() at this point */
- /* (SVr4 curses does this anyway) */
- cbreak();
+ /* for extended XPG4 conformance requires cbreak() at this point */
+ /* (SVr4 curses does this anyway) */
+ cbreak();
#ifdef TERMIOS
- cur_term->Nttyb.c_lflag &= ~(ECHO|ECHONL);
- cur_term->Nttyb.c_iflag &= ~(ICRNL|INLCR|IGNCR);
- cur_term->Nttyb.c_oflag &= ~(ONLCR);
+ cur_term->Nttyb.c_lflag &= ~(ECHO | ECHONL);
+ cur_term->Nttyb.c_iflag &= ~(ICRNL | INLCR | IGNCR);
+ cur_term->Nttyb.c_oflag &= ~(ONLCR);
#else
- cur_term->Nttyb.sg_flags &= ~(ECHO|CRMOD);
+ cur_term->Nttyb.sg_flags &= ~(ECHO | CRMOD);
#endif
- return _nc_set_tty_mode(&cur_term->Nttyb);
+ return _nc_set_tty_mode(&cur_term->Nttyb);
}
/*
@@ -86,121 +86,138 @@ static inline int _nc_initscr(void)
*/
static int filter_mode = FALSE;
-void filter(void)
+void
+filter(void)
{
filter_mode = TRUE;
}
-SCREEN * newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
+SCREEN *
+newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
{
-int errret;
-int slk_format = _nc_slk_format;
-SCREEN* current;
+ int errret;
+ int slk_format = _nc_slk_format;
+ SCREEN *current;
#ifdef TRACE
-int t = _nc_getenv_num("NCURSES_TRACE");
+ int t = _nc_getenv_num("NCURSES_TRACE");
- if (t >= 0)
- trace(t);
+ if (t >= 0)
+ trace(t);
#endif
- T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
+ T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
- /* this loads the capability entry, then sets LINES and COLS */
- if (setupterm(name, fileno(ofp), &errret) == ERR)
- return 0;
+ /* this loads the capability entry, then sets LINES and COLS */
+ if (setupterm(name, fileno(ofp), &errret) == ERR)
+ return 0;
- /* implement filter mode */
- if (filter_mode) {
- LINES = 1;
+ /* implement filter mode */
+ if (filter_mode) {
+ LINES = 1;
- if (init_tabs != -1)
- TABSIZE = init_tabs;
- else
- TABSIZE = 8;
+ if (VALID_NUMERIC(init_tabs))
+ TABSIZE = init_tabs;
+ else
+ TABSIZE = 8;
- T(("TABSIZE = %d", TABSIZE));
+ T(("TABSIZE = %d", TABSIZE));
- clear_screen = 0;
- cursor_down = parm_down_cursor = 0;
- cursor_address = 0;
- cursor_up = parm_up_cursor = 0;
- row_address = 0;
+ clear_screen = 0;
+ cursor_down = parm_down_cursor = 0;
+ cursor_address = 0;
+ cursor_up = parm_up_cursor = 0;
+ row_address = 0;
- cursor_home = carriage_return;
- }
+ cursor_home = carriage_return;
+ }
- /* If we must simulate soft labels, grab off the line to be used.
- We assume that we must simulate, if it is none of the standard
- formats (4-4 or 3-2-3) for which there may be some hardware
- support. */
- if (num_labels <= 0 || !SLK_STDFMT(slk_format))
- if (slk_format)
- {
- if (ERR==_nc_ripoffline(-SLK_LINES(slk_format),
- _nc_slk_initialize))
- return 0;
- }
- /* this actually allocates the screen structure, and saves the
- * original terminal settings.
- */
- current = SP;
- _nc_set_screen(0);
- if (_nc_setupscreen(LINES, COLS, ofp) == ERR) {
- _nc_set_screen(current);
+ /* If we must simulate soft labels, grab off the line to be used.
+ We assume that we must simulate, if it is none of the standard
+ formats (4-4 or 3-2-3) for which there may be some hardware
+ support. */
+ if (num_labels <= 0 || !SLK_STDFMT(slk_format))
+ if (slk_format) {
+ if (ERR == _nc_ripoffline(-SLK_LINES(slk_format),
+ _nc_slk_initialize))
return 0;
}
-
- /* if the terminal type has real soft labels, set those up */
- if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
- _nc_slk_initialize(stdscr, COLS);
-
- SP->_ifd = fileno(ifp);
- SP->_checkfd = fileno(ifp);
- typeahead(fileno(ifp));
+ /* this actually allocates the screen structure, and saves the
+ * original terminal settings.
+ */
+ current = SP;
+ _nc_set_screen(0);
+ if (_nc_setupscreen(LINES, COLS, ofp) == ERR) {
+ _nc_set_screen(current);
+ return 0;
+ }
+
+ /* if the terminal type has real soft labels, set those up */
+ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
+ _nc_slk_initialize(stdscr, COLS);
+
+ SP->_ifd = fileno(ifp);
+ SP->_checkfd = fileno(ifp);
+ typeahead(fileno(ifp));
#ifdef TERMIOS
- SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
- !(cur_term->Ottyb.c_iflag & ISTRIP));
+ SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
+ !(cur_term->Ottyb.c_iflag & ISTRIP));
#else
- SP->_use_meta = FALSE;
+ SP->_use_meta = FALSE;
#endif
- SP->_endwin = FALSE;
-
- /* Check whether we can optimize scrolling under dumb terminals in case
- * we do not have any of these capabilities, scrolling optimization
- * will be useless.
- */
- SP->_scrolling = ((scroll_forward && scroll_reverse) ||
- ((parm_rindex || parm_insert_line || insert_line) &&
- (parm_index || parm_delete_line || delete_line)));
-
- baudrate(); /* sets a field in the SP structure */
-
- SP->_keytry = 0;
-
- /*
- * Check for mismatched graphic-rendition capabilities. Most SVr4
- * terminfo trees contain entries that have rmul or rmso equated to
- * sgr0 (Solaris curses copes with those entries). We do this only for
- * curses, since many termcap applications assume that smso/rmso and
- * smul/rmul are paired, and will not function properly if we remove
- * rmso or rmul. Curses applications shouldn't be looking at this
- * detail.
- */
+ SP->_endwin = FALSE;
+
+ /* Check whether we can optimize scrolling under dumb terminals in case
+ * we do not have any of these capabilities, scrolling optimization
+ * will be useless.
+ */
+ SP->_scrolling = ((scroll_forward && scroll_reverse) ||
+ ((parm_rindex || parm_insert_line || insert_line) &&
+ (parm_index || parm_delete_line || delete_line)));
+
+ baudrate(); /* sets a field in the SP structure */
+
+ SP->_keytry = 0;
+
+ /*
+ * Check for mismatched graphic-rendition capabilities. Most SVr4
+ * terminfo trees contain entries that have rmul or rmso equated to
+ * sgr0 (Solaris curses copes with those entries). We do this only for
+ * curses, since many termcap applications assume that smso/rmso and
+ * smul/rmul are paired, and will not function properly if we remove
+ * rmso or rmul. Curses applications shouldn't be looking at this
+ * detail.
+ */
#define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
- SP->_use_rmso = SGR0_TEST(exit_standout_mode);
- SP->_use_rmul = SGR0_TEST(exit_underline_mode);
+ SP->_use_rmso = SGR0_TEST(exit_standout_mode);
+ SP->_use_rmul = SGR0_TEST(exit_underline_mode);
+
+#ifdef 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) {
+ SP->_outch = _nc_utf8_outch;
+ }
+ }
+#endif
- /* compute movement costs so we can do better move optimization */
- _nc_mvcur_init();
+ /* compute movement costs so we can do better move optimization */
+ _nc_mvcur_init();
- /* initialize terminal to a sane state */
- _nc_screen_init();
+ /* initialize terminal to a sane state */
+ _nc_screen_init();
- /* Initialize the terminal line settings. */
- _nc_initscr();
+ /* Initialize the terminal line settings. */
+ _nc_initscr();
- _nc_signal_handler(TRUE);
+ _nc_signal_handler(TRUE);
- T((T_RETURN("%p"), SP));
- return(SP);
+ T((T_RETURN("%p"), SP));
+ return (SP);
}
diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c
index d7fc02b3216e..ececa58a314d 100644
--- a/contrib/ncurses/ncurses/base/lib_newwin.c
+++ b/contrib/ncurses/ncurses/base/lib_newwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_newwin.c
**
@@ -42,230 +40,247 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.21 1999/10/03 00:42:03 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.24 2000/04/29 18:49:51 tom Exp $")
-void _nc_freewin(WINDOW *win)
+void
+_nc_freewin(WINDOW *win)
{
-WINDOWLIST *p, *q;
-int i;
-
- if (win != 0) {
- for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
- if (p->win == win) {
- if (q == 0)
- _nc_windows = p->next;
- else
- q->next = p->next;
- free(p);
-
- if (! (win->_flags & _SUBWIN)) {
- for (i = 0; i <= win->_maxy && win->_line[i].text; i++)
- FreeIfNeeded(win->_line[i].text);
- }
- free(win->_line);
- free(win);
-
- if (win == curscr) curscr = 0;
- if (win == stdscr) stdscr = 0;
- if (win == newscr) newscr = 0;
-
- T(("...deleted win=%p", win));
- break;
- }
+ WINDOWLIST *p, *q;
+ int i;
+
+ if (win != 0) {
+ for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
+ if (p->win == win) {
+ if (q == 0)
+ _nc_windows = p->next;
+ else
+ q->next = p->next;
+ free(p);
+
+ if (!(win->_flags & _SUBWIN)) {
+ for (i = 0; i <= win->_maxy; i++)
+ FreeIfNeeded(win->_line[i].text);
}
+ free(win->_line);
+ free(win);
+
+ if (win == curscr)
+ curscr = 0;
+ if (win == stdscr)
+ stdscr = 0;
+ if (win == newscr)
+ newscr = 0;
+
+ T(("...deleted win=%p", win));
+ break;
+ }
}
+ }
}
-WINDOW * newwin(int num_lines, int num_columns, int begy, int begx)
+WINDOW *
+newwin(int num_lines, int num_columns, int begy, int begx)
{
-WINDOW *win;
-chtype *ptr;
-int i;
+ WINDOW *win;
+ chtype *ptr;
+ int i;
- T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
+ T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
- if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0)
- returnWin(0);
+ if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0)
+ returnWin(0);
- if (num_lines == 0)
- num_lines = SP->_lines_avail - begy;
- if (num_columns == 0)
- num_columns = screen_columns - begx;
+ if (num_lines == 0)
+ num_lines = SP->_lines_avail - begy;
+ if (num_columns == 0)
+ num_columns = screen_columns - begx;
- if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
- returnWin(0);
+ if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
+ returnWin(0);
- if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
- returnWin(0);
+ if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
+ returnWin(0);
- for (i = 0; i < num_lines; i++) {
- if ((win->_line[i].text = typeCalloc(chtype, (unsigned)num_columns)) == 0) {
- _nc_freewin(win);
- returnWin(0);
- }
- for (ptr = win->_line[i].text; ptr < win->_line[i].text + num_columns; )
- *ptr++ = ' ';
+ for (i = 0; i < num_lines; i++) {
+ win->_line[i].text = typeCalloc(chtype, (unsigned) num_columns);
+ if (win->_line[i].text == 0) {
+ _nc_freewin(win);
+ returnWin(0);
}
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text +
+ num_columns;)
+ *ptr++ = ' ';
+ }
- T(("newwin: returned window is %p", win));
+ T(("newwin: returned window is %p", win));
- returnWin(win);
+ returnWin(win);
}
-WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
+WINDOW *
+derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
{
-WINDOW *win;
-int i;
-int flags = _SUBWIN;
+ WINDOW *win;
+ int i;
+ int flags = _SUBWIN;
- T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns, begy, begx));
+ T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns,
+ begy, begx));
- /*
- ** make sure window fits inside the original one
- */
- if ( begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0)
- returnWin(0);
- if ( begy + num_lines > orig->_maxy + 1
- || begx + num_columns > orig->_maxx + 1)
- returnWin(0);
+ /*
+ ** make sure window fits inside the original one
+ */
+ if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0)
+ returnWin(0);
+ if (begy + num_lines > orig->_maxy + 1
+ || begx + num_columns > orig->_maxx + 1)
+ returnWin(0);
- if (num_lines == 0)
- num_lines = orig->_maxy + 1 - begy;
+ if (num_lines == 0)
+ num_lines = orig->_maxy + 1 - begy;
- if (num_columns == 0)
- num_columns = orig->_maxx + 1 - begx;
+ if (num_columns == 0)
+ num_columns = orig->_maxx + 1 - begx;
- if (orig->_flags & _ISPAD)
- flags |= _ISPAD;
+ if (orig->_flags & _ISPAD)
+ flags |= _ISPAD;
- if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx, flags)) == 0)
- returnWin(0);
+ if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy,
+ orig->_begx + begx, flags)) == 0)
+ returnWin(0);
- win->_pary = begy;
- win->_parx = begx;
- win->_attrs = orig->_attrs;
- win->_bkgd = orig->_bkgd;
+ win->_pary = begy;
+ win->_parx = begx;
+ win->_attrs = orig->_attrs;
+ win->_bkgd = orig->_bkgd;
- for (i = 0; i < num_lines; i++)
- win->_line[i].text = &orig->_line[begy++].text[begx];
+ for (i = 0; i < num_lines; i++)
+ win->_line[i].text = &orig->_line[begy++].text[begx];
- win->_parent = orig;
+ win->_parent = orig;
- T(("derwin: returned window is %p", win));
+ T(("derwin: returned window is %p", win));
- returnWin(win);
+ returnWin(win);
}
-
-WINDOW *subwin(WINDOW *w, int l, int c, int y, int x)
+WINDOW *
+subwin(WINDOW *w, int l, int c, int y, int x)
{
- T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x));
- T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
+ T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x));
+ T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
+
+ returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx));
+}
- returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx));
+static bool
+dimension_limit(int value)
+{
+ NCURSES_SIZE_T test = value;
+ return (test == value && value > 0);
}
WINDOW *
_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
{
-int i;
-WINDOWLIST *wp;
-WINDOW *win;
-bool is_pad = (flags & _ISPAD);
-
- T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
-
- if (num_lines <= 0 || num_columns <= 0)
- return 0;
-
- if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
- return 0;
-
- if ((win = typeCalloc(WINDOW, 1)) == 0)
- return 0;
-
- if ((win->_line = typeCalloc(struct ldat, ((unsigned)num_lines))) == 0) {
- free(win);
- return 0;
- }
-
- win->_curx = 0;
- win->_cury = 0;
- win->_maxy = num_lines - 1;
- win->_maxx = num_columns - 1;
- win->_begy = begy;
- win->_begx = begx;
- win->_yoffset = SP->_topstolen;
-
- win->_flags = flags;
- win->_attrs = A_NORMAL;
- win->_bkgd = BLANK;
-
- win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns == screen_columns);
- win->_idlok = FALSE;
- win->_idcok = TRUE;
- win->_scroll = FALSE;
- win->_leaveok = FALSE;
- win->_use_keypad = FALSE;
- win->_delay = -1;
- win->_immed = FALSE;
- win->_sync = 0;
- win->_parx = -1;
- win->_pary = -1;
- win->_parent = 0;
-
- win->_regtop = 0;
- win->_regbottom = num_lines - 1;
-
- win->_pad._pad_y = -1;
- win->_pad._pad_x = -1;
- win->_pad._pad_top = -1;
- win->_pad._pad_bottom = -1;
- win->_pad._pad_left = -1;
- win->_pad._pad_right = -1;
-
- for (i = 0; i < num_lines; i++)
- {
- /*
- * This used to do
- *
- * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE;
- *
- * which marks the whole window unchanged. That's how
- * SVr1 curses did it, but SVr4 curses marks the whole new
- * window changed.
- *
- * With the old SVr1-like code, say you have stdscr full of
- * characters, then create a new window with newwin(),
- * then do a printw(win, "foo ");, the trailing spaces are
- * completely ignored by the following refreshes. So, you
- * get "foojunkjunk" on the screen instead of "foo " as
- * you actually intended.
- *
- * SVr4 doesn't do this. Instead the spaces are actually written.
- * So that's how we want ncurses to behave.
- */
- win->_line[i].firstchar = 0;
- win->_line[i].lastchar = num_columns-1;
-
- if_USE_SCROLL_HINTS(win->_line[i].oldindex = i);
- }
-
- if (!is_pad && (begx + num_columns == screen_columns)) {
- win->_flags |= _ENDLINE;
-
- if (begx == 0 && num_lines == screen_lines && begy == 0)
- win->_flags |= _FULLWIN;
-
- if (begy + num_lines == screen_lines)
- win->_flags |= _SCROLLWIN;
- }
-
- wp->next = _nc_windows;
- wp->win = win;
- _nc_windows = wp;
-
- T((T_CREATE("window %p"), win));
-
- return(win);
+ int i;
+ WINDOWLIST *wp;
+ WINDOW *win;
+ bool is_pad = (flags & _ISPAD);
+
+ T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+
+ if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
+ return 0;
+
+ if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
+ return 0;
+
+ if ((win = typeCalloc(WINDOW, 1)) == 0)
+ return 0;
+
+ if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) {
+ free(win);
+ return 0;
+ }
+
+ win->_curx = 0;
+ win->_cury = 0;
+ win->_maxy = num_lines - 1;
+ win->_maxx = num_columns - 1;
+ win->_begy = begy;
+ win->_begx = begx;
+ win->_yoffset = SP->_topstolen;
+
+ win->_flags = flags;
+ win->_attrs = A_NORMAL;
+ win->_bkgd = BLANK;
+
+ win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns
+ == screen_columns);
+ win->_idlok = FALSE;
+ win->_idcok = TRUE;
+ win->_scroll = FALSE;
+ win->_leaveok = FALSE;
+ win->_use_keypad = FALSE;
+ win->_delay = -1;
+ win->_immed = FALSE;
+ win->_sync = 0;
+ win->_parx = -1;
+ win->_pary = -1;
+ win->_parent = 0;
+
+ win->_regtop = 0;
+ win->_regbottom = num_lines - 1;
+
+ win->_pad._pad_y = -1;
+ win->_pad._pad_x = -1;
+ win->_pad._pad_top = -1;
+ win->_pad._pad_bottom = -1;
+ win->_pad._pad_left = -1;
+ win->_pad._pad_right = -1;
+
+ for (i = 0; i < num_lines; i++) {
+ /*
+ * This used to do
+ *
+ * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE;
+ *
+ * which marks the whole window unchanged. That's how
+ * SVr1 curses did it, but SVr4 curses marks the whole new
+ * window changed.
+ *
+ * With the old SVr1-like code, say you have stdscr full of
+ * characters, then create a new window with newwin(),
+ * then do a printw(win, "foo ");, the trailing spaces are
+ * completely ignored by the following refreshes. So, you
+ * get "foojunkjunk" on the screen instead of "foo " as
+ * you actually intended.
+ *
+ * SVr4 doesn't do this. Instead the spaces are actually written.
+ * So that's how we want ncurses to behave.
+ */
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = num_columns - 1;
+
+ if_USE_SCROLL_HINTS(win->_line[i].oldindex = i);
+ }
+
+ if (!is_pad && (begx + num_columns == screen_columns)) {
+ win->_flags |= _ENDLINE;
+
+ if (begx == 0 && num_lines == screen_lines && begy == 0)
+ win->_flags |= _FULLWIN;
+
+ if (begy + num_lines == screen_lines)
+ win->_flags |= _SCROLLWIN;
+ }
+
+ wp->next = _nc_windows;
+ wp->win = win;
+ _nc_windows = wp;
+
+ T((T_CREATE("window %p"), win));
+
+ return (win);
}
diff --git a/contrib/ncurses/ncurses/base/lib_nl.c b/contrib/ncurses/ncurses/base/lib_nl.c
index 75d4a638148d..bfaffdefda5a 100644
--- a/contrib/ncurses/ncurses/base/lib_nl.c
+++ b/contrib/ncurses/ncurses/base/lib_nl.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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> *
****************************************************************************/
-
/*
* nl.c
*
@@ -43,37 +42,38 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_nl.c,v 1.4 1999/10/22 22:31:51 tom Exp $")
+MODULE_ID("$Id: lib_nl.c,v 1.6 2000/02/13 00:59:39 tom Exp $")
#ifdef __EMX__
#include <io.h>
-#include <fcntl.h>
#endif
-int nl(void)
+int
+nl(void)
{
- T((T_CALLED("nl()")));
+ T((T_CALLED("nl()")));
- SP->_nl = TRUE;
+ SP->_nl = TRUE;
#ifdef __EMX__
- _nc_flush();
- _fsetmode(NC_OUTPUT, "t");
+ _nc_flush();
+ _fsetmode(NC_OUTPUT, "t");
#endif
- returnCode(OK);
+ returnCode(OK);
}
-int nonl(void)
+int
+nonl(void)
{
- T((T_CALLED("nonl()")));
+ T((T_CALLED("nonl()")));
- SP->_nl = FALSE;
+ SP->_nl = FALSE;
#ifdef __EMX__
- _nc_flush();
- _fsetmode(NC_OUTPUT, "b");
+ _nc_flush();
+ _fsetmode(NC_OUTPUT, "b");
#endif
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_pad.c b/contrib/ncurses/ncurses/base/lib_pad.c
index d4e341c05c75..af7dd3b50194 100644
--- a/contrib/ncurses/ncurses/base/lib_pad.c
+++ b/contrib/ncurses/ncurses/base/lib_pad.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> *
****************************************************************************/
-
/*
* lib_pad.c
* newpad -- create a new pad
@@ -41,240 +40,253 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_pad.c,v 1.27 1998/06/28 00:10:16 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.29 2000/04/29 21:19:44 tom Exp $")
-WINDOW *newpad(int l, int c)
+WINDOW *
+newpad(int l, int c)
{
-WINDOW *win;
-chtype *ptr;
-int i;
+ WINDOW *win;
+ chtype *ptr;
+ int i;
- T((T_CALLED("newpad(%d, %d)"), l, c));
+ T((T_CALLED("newpad(%d, %d)"), l, c));
- if (l <= 0 || c <= 0)
- returnWin(0);
+ if (l <= 0 || c <= 0)
+ returnWin(0);
- if ((win = _nc_makenew(l,c,0,0,_ISPAD)) == NULL)
- returnWin(0);
+ if ((win = _nc_makenew(l, c, 0, 0, _ISPAD)) == NULL)
+ returnWin(0);
- for (i = 0; i < l; i++) {
- if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX);
- if ((win->_line[i].text = typeCalloc(chtype, ((size_t)c))) == 0) {
- _nc_freewin(win);
- returnWin(0);
- }
- for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; )
- *ptr++ = ' ';
+ for (i = 0; i < l; i++) {
+ if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX);
+ if ((win->_line[i].text = typeCalloc(chtype, ((size_t) c))) == 0) {
+ _nc_freewin(win);
+ returnWin(0);
}
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text + c;)
+ *ptr++ = ' ';
+ }
- returnWin(win);
+ returnWin(win);
}
-WINDOW *subpad(WINDOW *orig, int l, int c, int begy, int begx)
+WINDOW *
+subpad(WINDOW *orig, int l, int c, int begy, int begx)
{
-WINDOW *win = (WINDOW *)0;
+ WINDOW *win = (WINDOW *) 0;
- T((T_CALLED("subpad(%d, %d)"), l, c));
+ T((T_CALLED("subpad(%d, %d)"), l, c));
- if (orig) {
- if (!(orig->_flags & _ISPAD) || ((win = derwin(orig, l, c, begy, begx)) == NULL))
+ if (orig) {
+ if (!(orig->_flags & _ISPAD)
+ || ((win = derwin(orig, l, c, begy, begx)) == NULL))
returnWin(0);
- }
- returnWin(win);
+ }
+ returnWin(win);
}
-int prefresh(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+int
+prefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
{
- T((T_CALLED("prefresh()")));
- if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) != ERR
- && doupdate() != ERR) {
- returnCode(OK);
- }
- returnCode(ERR);
+ T((T_CALLED("prefresh()")));
+ if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow,
+ smaxcol) != ERR
+ && doupdate() != ERR) {
+ returnCode(OK);
+ }
+ returnCode(ERR);
}
-int pnoutrefresh(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+int
+pnoutrefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
{
-const int my_len = 2; /* parameterize the threshold for hardscroll */
-short i, j;
-short m, n;
-short pmaxrow;
-short pmaxcol;
-short displaced;
-bool wide;
-
- T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"),
- win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
-
- if (win == 0)
- returnCode(ERR);
-
- if (!(win->_flags & _ISPAD))
- returnCode(ERR);
+ const int my_len = 2; /* parameterize the threshold for hardscroll */
+ NCURSES_SIZE_T i, j;
+ NCURSES_SIZE_T m, n;
+ NCURSES_SIZE_T pmaxrow;
+ NCURSES_SIZE_T pmaxcol;
+ NCURSES_SIZE_T displaced;
+ bool wide;
+
+ T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"),
+ win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
+
+ if (win == 0)
+ returnCode(ERR);
- /* negative values are interpreted as zero */
- if (pminrow < 0) pminrow = 0;
- if (pmincol < 0) pmincol = 0;
- if (sminrow < 0) sminrow = 0;
- if (smincol < 0) smincol = 0;
+ if (!(win->_flags & _ISPAD))
+ returnCode(ERR);
+ /* negative values are interpreted as zero */
+ if (pminrow < 0)
+ pminrow = 0;
+ if (pmincol < 0)
+ pmincol = 0;
+ if (sminrow < 0)
+ sminrow = 0;
+ if (smincol < 0)
+ smincol = 0;
+
+ pmaxrow = pminrow + smaxrow - sminrow;
+ pmaxcol = pmincol + smaxcol - smincol;
+
+ T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
+ T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+
+ /*
+ * Trim the caller's screen size back to the actual limits.
+ */
+ if (pmaxrow > win->_maxy) {
+ smaxrow -= (pmaxrow - win->_maxy);
pmaxrow = pminrow + smaxrow - sminrow;
+ }
+ if (pmaxcol > win->_maxx) {
+ smaxcol -= (pmaxcol - win->_maxx);
pmaxcol = pmincol + smaxcol - smincol;
+ }
- T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
- T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+ if (smaxrow > screen_lines
+ || smaxcol > screen_columns
+ || sminrow > smaxrow
+ || smincol > smaxcol)
+ returnCode(ERR);
- /*
- * Trim the caller's screen size back to the actual limits.
- */
- if (pmaxrow > win->_maxy) {
- smaxrow -= (pmaxrow - win->_maxy);
- pmaxrow = pminrow + smaxrow - sminrow;
- }
- if (pmaxcol > win->_maxx) {
- smaxcol -= (pmaxcol - win->_maxx);
- pmaxcol = pmincol + smaxcol - smincol;
+ T(("pad being refreshed"));
+
+ if (win->_pad._pad_y >= 0) {
+ displaced = pminrow - win->_pad._pad_y
+ - (sminrow - win->_pad._pad_top);
+ T(("pad being shifted by %d line(s)", displaced));
+ } else
+ displaced = 0;
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the pad to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the pad "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (smincol < my_len && smaxcol > (newscr->_maxx - my_len));
+
+ for (i = pminrow, m = sminrow + win->_yoffset;
+ i <= pmaxrow && m <= newscr->_maxy;
+ i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
+
+ for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+ CHANGED_CELL(nline, n);
+ }
}
- if (smaxrow > screen_lines
- || smaxcol > screen_columns
- || sminrow > smaxrow
- || smincol > smaxcol)
- returnCode(ERR);
-
- T(("pad being refreshed"));
-
- if (win->_pad._pad_y >= 0) {
- displaced = pminrow - win->_pad._pad_y
- -(sminrow - win->_pad._pad_top);
- T(("pad being shifted by %d line(s)", displaced));
- } else
- displaced = 0;
-
- /*
- * For pure efficiency, we'd want to transfer scrolling information
- * from the pad to newscr whenever the window is wide enough that
- * its update will dominate the cost of the update for the horizontal
- * band of newscr that it occupies. Unfortunately, this threshold
- * tends to be complex to estimate, and in any case scrolling the
- * whole band and rewriting the parts outside win's image would look
- * really ugly. So. What we do is consider the pad "wide" if it
- * either (a) occupies the whole width of newscr, or (b) occupies
- * all but at most one column on either vertical edge of the screen
- * (this caters to fussy people who put boxes around full-screen
- * windows). Note that changing this formula will not break any code,
- * merely change the costs of various update cases.
- */
- wide = (smincol < my_len && smaxcol > (newscr->_maxx - my_len));
-
- for (i = pminrow, m = sminrow + win->_yoffset;
- i <= pmaxrow && m <= newscr->_maxy;
- i++, m++) {
- register struct ldat *nline = &newscr->_line[m];
- register struct ldat *oline = &win->_line[i];
-
- for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
- if (oline->text[j] != nline->text[n]) {
- nline->text[n] = oline->text[j];
- CHANGED_CELL(nline,n);
- }
- }
-
#if USE_SCROLL_HINTS
- if (wide) {
- int nind = m + displaced;
- if (oline->oldindex < 0
- || nind < sminrow
- || nind > smaxrow) {
+ if (wide) {
+ int nind = m + displaced;
+ if (oline->oldindex < 0
+ || nind < sminrow
+ || nind > smaxrow) {
+ nind = _NEWINDEX;
+ } else if (displaced) {
+ register struct ldat *pline = &curscr->_line[nind];
+ for (j = 0; j <= my_len; j++) {
+ int k = newscr->_maxx - j;
+ if (pline->text[j] != nline->text[j]
+ || pline->text[k] != nline->text[k]) {
nind = _NEWINDEX;
- } else if (displaced) {
- register struct ldat *pline = &curscr->_line[nind];
- for (j = 0; j <= my_len; j++) {
- int k = newscr->_maxx - j;
- if (pline->text[j] != nline->text[j]
- || pline->text[k] != nline->text[k]) {
- nind = _NEWINDEX;
- break;
- }
- }
+ break;
}
-
- nline->oldindex = nind;
}
-#endif /* USE_SCROLL_HINTS */
- oline->firstchar = oline->lastchar = _NOCHANGE;
- if_USE_SCROLL_HINTS(oline->oldindex = i);
- }
+ }
- /*
- * Clean up debris from scrolling or resizing the pad, so we do not
- * accidentally pick up the index value during the next call to this
- * procedure. The only rows that should have an index value are those
- * that are displayed during this cycle.
- */
+ nline->oldindex = nind;
+ }
+#endif /* USE_SCROLL_HINTS */
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ if_USE_SCROLL_HINTS(oline->oldindex = i);
+ }
+
+ /*
+ * Clean up debris from scrolling or resizing the pad, so we do not
+ * accidentally pick up the index value during the next call to this
+ * procedure. The only rows that should have an index value are those
+ * that are displayed during this cycle.
+ */
#if USE_SCROLL_HINTS
- for (i = pminrow-1; (i >= 0) && (win->_line[i].oldindex >= 0); i--)
- win->_line[i].oldindex = _NEWINDEX;
- for (i = pmaxrow+1; (i <= win->_maxy) && (win->_line[i].oldindex >= 0); i++)
- win->_line[i].oldindex = _NEWINDEX;
+ for (i = pminrow - 1; (i >= 0) && (win->_line[i].oldindex >= 0); i--)
+ win->_line[i].oldindex = _NEWINDEX;
+ for (i = pmaxrow + 1; (i <= win->_maxy)
+ && (win->_line[i].oldindex >= 0); i++)
+ win->_line[i].oldindex = _NEWINDEX;
#endif
- win->_begx = smincol;
- win->_begy = sminrow;
+ win->_begx = smincol;
+ win->_begy = sminrow;
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ /*
+ * Use the pad's current position, if it will be visible.
+ * If not, don't do anything; it's not an error.
+ */
+ if (win->_leaveok == FALSE
+ && win->_cury >= pminrow
+ && win->_curx >= pmincol
+ && win->_cury <= pmaxrow
+ && win->_curx <= pmaxcol) {
+ newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset;
+ newscr->_curx = win->_curx - pmincol + win->_begx;
+ }
+ newscr->_leaveok = win->_leaveok;
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Update our cache of the line-numbers that we displayed from the pad.
+ * We will use this on subsequent calls to this function to derive
+ * values to stuff into 'oldindex[]' -- for scrolling optimization.
+ */
+ win->_pad._pad_y = pminrow;
+ win->_pad._pad_x = pmincol;
+ win->_pad._pad_top = sminrow;
+ win->_pad._pad_left = smincol;
+ win->_pad._pad_bottom = smaxrow;
+ win->_pad._pad_right = smaxcol;
+
+ returnCode(OK);
+}
- if (win->_clear) {
- win->_clear = FALSE;
- newscr->_clear = TRUE;
- }
+int
+pechochar(WINDOW *pad, const chtype ch)
+{
+ T((T_CALLED("pechochar(%p, %s)"), pad, _tracechtype(ch)));
- /*
- * Use the pad's current position, if it will be visible.
- * If not, don't do anything; it's not an error.
- */
- if (win->_leaveok == FALSE
- && win->_cury >= pminrow
- && win->_curx >= pmincol
- && win->_cury <= pmaxrow
- && win->_curx <= pmaxcol) {
- newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset;
- newscr->_curx = win->_curx - pmincol + win->_begx;
- }
- win->_flags &= ~_HASMOVED;
-
- /*
- * Update our cache of the line-numbers that we displayed from the pad.
- * We will use this on subsequent calls to this function to derive
- * values to stuff into 'oldindex[]' -- for scrolling optimization.
- */
- win->_pad._pad_y = pminrow;
- win->_pad._pad_x = pmincol;
- win->_pad._pad_top = sminrow;
- win->_pad._pad_left = smincol;
- win->_pad._pad_bottom = smaxrow;
- win->_pad._pad_right = smaxcol;
+ if (pad == 0)
+ returnCode(ERR);
- returnCode(OK);
-}
+ if (!(pad->_flags & _ISPAD))
+ returnCode(wechochar(pad, ch));
-int pechochar(WINDOW *pad, const chtype ch)
-{
- T((T_CALLED("pechochar(%p, %s)"), pad, _tracechtype(ch)));
-
- if (pad == 0)
- returnCode(ERR);
-
- if (!(pad->_flags & _ISPAD))
- returnCode(wechochar(pad,ch));
-
- waddch(pad, ch);
- prefresh(pad, pad->_pad._pad_y,
- pad->_pad._pad_x,
- pad->_pad._pad_top,
- pad->_pad._pad_left,
- pad->_pad._pad_bottom,
- pad->_pad._pad_right);
-
- returnCode(OK);
+ waddch(pad, ch);
+ prefresh(pad, pad->_pad._pad_y,
+ pad->_pad._pad_x,
+ pad->_pad._pad_top,
+ pad->_pad._pad_left,
+ pad->_pad._pad_bottom,
+ pad->_pad._pad_right);
+
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_refresh.c b/contrib/ncurses/ncurses/base/lib_refresh.c
index 88e3b75a56a1..910664b0187a 100644
--- a/contrib/ncurses/ncurses/base/lib_refresh.c
+++ b/contrib/ncurses/ncurses/base/lib_refresh.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* lib_refresh.c
*
@@ -42,142 +40,144 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_refresh.c,v 1.24 1999/07/31 11:36:37 juergen Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.25 2000/04/29 21:17:08 tom Exp $")
-int wrefresh(WINDOW *win)
+int
+wrefresh(WINDOW *win)
{
-int code;
-
- T((T_CALLED("wrefresh(%p)"), win));
-
- if (win == curscr) {
- curscr->_clear = TRUE;
- code = doupdate();
- } else if ((code = wnoutrefresh(win)) == OK) {
- if (win->_clear)
- newscr->_clear = TRUE;
- code = doupdate();
- /*
- * Reset the clearok() flag in case it was set for the special
- * case in hardscroll.c (if we don't reset it here, we'll get 2
- * refreshes because the flag is copied from stdscr to newscr).
- * Resetting the flag shouldn't do any harm, anyway.
- */
- win->_clear = FALSE;
- }
- returnCode(code);
-}
-
-int wnoutrefresh(WINDOW *win)
-{
-short limit_x;
-short i, j;
-short begx;
-short begy;
-short m, n;
-bool wide;
-
- T((T_CALLED("wnoutrefresh(%p)"), win));
-#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
- _tracedump("...win", win);
-#endif /* TRACE */
-
- /*
- * This function will break badly if we try to refresh a pad.
- */
- if ((win == 0)
- || (win->_flags & _ISPAD))
- returnCode(ERR);
+ int code;
- /* put them here so "win == 0" won't break our code */
- begx = win->_begx;
- begy = win->_begy;
-
- newscr->_bkgd = win->_bkgd;
- newscr->_attrs = win->_attrs;
-
- /* merge in change information from all subwindows of this window */
- wsyncdown(win);
+ T((T_CALLED("wrefresh(%p)"), win));
+ if (win == curscr) {
+ curscr->_clear = TRUE;
+ code = doupdate();
+ } else if ((code = wnoutrefresh(win)) == OK) {
+ if (win->_clear)
+ newscr->_clear = TRUE;
+ code = doupdate();
/*
- * For pure efficiency, we'd want to transfer scrolling information
- * from the window to newscr whenever the window is wide enough that
- * its update will dominate the cost of the update for the horizontal
- * band of newscr that it occupies. Unfortunately, this threshold
- * tends to be complex to estimate, and in any case scrolling the
- * whole band and rewriting the parts outside win's image would look
- * really ugly. So. What we do is consider the window "wide" if it
- * either (a) occupies the whole width of newscr, or (b) occupies
- * all but at most one column on either vertical edge of the screen
- * (this caters to fussy people who put boxes around full-screen
- * windows). Note that changing this formula will not break any code,
- * merely change the costs of various update cases.
+ * Reset the clearok() flag in case it was set for the special
+ * case in hardscroll.c (if we don't reset it here, we'll get 2
+ * refreshes because the flag is copied from stdscr to newscr).
+ * Resetting the flag shouldn't do any harm, anyway.
*/
- wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
-
- win->_flags &= ~_HASMOVED;
+ win->_clear = FALSE;
+ }
+ returnCode(code);
+}
- /*
- * Microtweaking alert! This double loop is one of the genuine
- * hot spots in the code. Even gcc doesn't seem to do enough
- * common-subexpression chunking to make it really tense,
- * so we'll force the issue.
- */
+int
+wnoutrefresh(WINDOW *win)
+{
+ NCURSES_SIZE_T limit_x;
+ NCURSES_SIZE_T i, j;
+ NCURSES_SIZE_T begx;
+ NCURSES_SIZE_T begy;
+ NCURSES_SIZE_T m, n;
+ bool wide;
+
+ T((T_CALLED("wnoutrefresh(%p)"), win));
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("...win", win);
+#endif /* TRACE */
- /* limit(n) */
+ /*
+ * This function will break badly if we try to refresh a pad.
+ */
+ if ((win == 0)
+ || (win->_flags & _ISPAD))
+ returnCode(ERR);
+
+ /* put them here so "win == 0" won't break our code */
+ begx = win->_begx;
+ begy = win->_begy;
+
+ newscr->_bkgd = win->_bkgd;
+ newscr->_attrs = win->_attrs;
+
+ /* merge in change information from all subwindows of this window */
+ wsyncdown(win);
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the window to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the window "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
+
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Microtweaking alert! This double loop is one of the genuine
+ * hot spots in the code. Even gcc doesn't seem to do enough
+ * common-subexpression chunking to make it really tense,
+ * so we'll force the issue.
+ */
+
+ /* limit(n) */
+ limit_x = win->_maxx;
+ /* limit(j) */
+ if (limit_x > win->_maxx)
limit_x = win->_maxx;
- /* limit(j) */
- if (limit_x > win->_maxx)
- limit_x = win->_maxx;
-
- for (i = 0, m = begy + win->_yoffset;
- i <= win->_maxy && m <= newscr->_maxy;
- i++, m++) {
- register struct ldat *nline = &newscr->_line[m];
- register struct ldat *oline = &win->_line[i];
- if (oline->firstchar != _NOCHANGE) {
- int last = oline->lastchar;
+ for (i = 0, m = begy + win->_yoffset;
+ i <= win->_maxy && m <= newscr->_maxy;
+ i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
- if (last > limit_x)
- last = limit_x;
+ if (oline->firstchar != _NOCHANGE) {
+ int last = oline->lastchar;
- for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
- if (oline->text[j] != nline->text[n]) {
- nline->text[n] = oline->text[j];
- CHANGED_CELL(nline, n);
- }
- }
+ if (last > limit_x)
+ last = limit_x;
+ for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+ CHANGED_CELL(nline, n);
}
+ }
+ }
#if USE_SCROLL_HINTS
- if (wide) {
- int oind = oline->oldindex;
+ if (wide) {
+ int oind = oline->oldindex;
- nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind + win->_yoffset;
- }
+ nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind
+ + win->_yoffset;
+ }
#endif /* USE_SCROLL_HINTS */
- oline->firstchar = oline->lastchar = _NOCHANGE;
- if_USE_SCROLL_HINTS(oline->oldindex = i);
- }
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ if_USE_SCROLL_HINTS(oline->oldindex = i);
+ }
- if (win->_clear) {
- win->_clear = FALSE;
- newscr->_clear = TRUE;
- }
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ if (!win->_leaveok) {
+ newscr->_cury = win->_cury + win->_begy + win->_yoffset;
+ newscr->_curx = win->_curx + win->_begx;
+ }
+ newscr->_leaveok = win->_leaveok;
- if (! win->_leaveok) {
- newscr->_cury = win->_cury + win->_begy + win->_yoffset;
- newscr->_curx = win->_curx + win->_begx;
- }
- newscr->_leaveok = win->_leaveok;
-
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
- _tracedump("newscr", newscr);
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("newscr", newscr);
#endif /* TRACE */
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_scroll.c b/contrib/ncurses/ncurses/base/lib_scroll.c
index 197bb221a07c..c2e3831da255 100644
--- a/contrib/ncurses/ncurses/base/lib_scroll.c
+++ b/contrib/ncurses/ncurses/base/lib_scroll.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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_scroll.c
**
@@ -44,75 +42,79 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_scroll.c,v 1.16 1998/02/11 12:13:55 tom Exp $")
+MODULE_ID("$Id: lib_scroll.c,v 1.17 2000/04/29 21:10:51 tom Exp $")
-void _nc_scroll_window(WINDOW *win, int const n, short const top, short const bottom, chtype blank)
+void
+_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top,
+ NCURSES_SIZE_T const bottom, chtype blank)
{
-int line, j;
-size_t to_copy = (size_t)(sizeof(chtype) * (win->_maxx + 1));
-
- TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top,bottom));
-
- /*
- * This used to do a line-text pointer-shuffle instead of text copies.
- * That (a) doesn't work when the window is derived and doesn't have
- * its own storage, (b) doesn't save you a lot on modern machines
- * anyway. Your typical memcpy implementations are coded in
- * assembler using a tight BLT loop; for the size of copies we're
- * talking here, the total execution time is dominated by the one-time
- * setup cost. So there is no point in trying to be excessively
- * clever -- esr.
- */
-
- /* shift n lines downwards */
- if (n < 0) {
- for (line = bottom; line >= top-n; line--) {
- memcpy(win->_line[line].text,
- win->_line[line+n].text,
- to_copy);
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex);
- }
- for (line = top; line < top-n; line++) {
- for (j = 0; j <= win->_maxx; j ++)
- win->_line[line].text[j] = blank;
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
- }
- }
-
- /* shift n lines upwards */
- if (n > 0) {
- for (line = top; line <= bottom-n; line++) {
- memcpy(win->_line[line].text,
- win->_line[line+n].text,
- to_copy);
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex);
- }
- for (line = bottom; line > bottom-n; line--) {
- for (j = 0; j <= win->_maxx; j ++)
- win->_line[line].text[j] = blank;
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
- }
+ int line, j;
+ size_t to_copy = (size_t) (sizeof(chtype) * (win->_maxx + 1));
+
+ TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top, bottom));
+
+ /*
+ * This used to do a line-text pointer-shuffle instead of text copies.
+ * That (a) doesn't work when the window is derived and doesn't have
+ * its own storage, (b) doesn't save you a lot on modern machines
+ * anyway. Your typical memcpy implementations are coded in
+ * assembler using a tight BLT loop; for the size of copies we're
+ * talking here, the total execution time is dominated by the one-time
+ * setup cost. So there is no point in trying to be excessively
+ * clever -- esr.
+ */
+
+ /* shift n lines downwards */
+ if (n < 0) {
+ for (line = bottom; line >= top - n; line--) {
+ memcpy(win->_line[line].text,
+ win->_line[line + n].text,
+ to_copy);
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line
+ + n].oldindex);
+ }
+ for (line = top; line < top - n; line++) {
+ for (j = 0; j <= win->_maxx; j++)
+ win->_line[line].text[j] = blank;
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
+ }
+ }
+
+ /* shift n lines upwards */
+ if (n > 0) {
+ for (line = top; line <= bottom - n; line++) {
+ memcpy(win->_line[line].text,
+ win->_line[line + n].text,
+ to_copy);
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line
+ + n].oldindex);
+ }
+ for (line = bottom; line > bottom - n; line--) {
+ for (j = 0; j <= win->_maxx; j++)
+ win->_line[line].text[j] = blank;
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
}
- touchline(win, top, bottom-top+1);
+ }
+ touchline(win, top, bottom - top + 1);
}
int
wscrl(WINDOW *win, int n)
{
- T((T_CALLED("wscrl(%p,%d)"), win, n));
+ T((T_CALLED("wscrl(%p,%d)"), win, n));
- if (!win || !win->_scroll)
- returnCode(ERR);
+ if (!win || !win->_scroll)
+ returnCode(ERR);
- if (n == 0)
- returnCode(OK);
+ if (n == 0)
+ returnCode(OK);
- if ((n > (win->_regbottom - win->_regtop)) ||
- (-n > (win->_regbottom - win->_regtop)))
- returnCode(ERR);
+ if ((n > (win->_regbottom - win->_regtop)) ||
+ (-n > (win->_regbottom - win->_regtop)))
+ returnCode(ERR);
- _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win));
+ _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win));
- _nc_synchook(win);
- returnCode(OK);
+ _nc_synchook(win);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_scrreg.c b/contrib/ncurses/ncurses/base/lib_scrreg.c
index ddeab2498bfd..b47c047f4623 100644
--- a/contrib/ncurses/ncurses/base/lib_scrreg.c
+++ b/contrib/ncurses/ncurses/base/lib_scrreg.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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_scrreg.c
**
@@ -42,21 +40,21 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_scrreg.c,v 1.7 1998/02/11 12:13:53 tom Exp $")
+MODULE_ID("$Id: lib_scrreg.c,v 1.8 2000/04/29 21:13:04 tom Exp $")
-int wsetscrreg(WINDOW *win, int top, int bottom)
+int
+wsetscrreg(WINDOW *win, int top, int bottom)
{
- T((T_CALLED("wsetscrreg(%p,%d,%d)"), win, top, bottom));
-
- if (win &&
- top >= 0 && top <= win->_maxy &&
- bottom >= 0 && bottom <= win->_maxy &&
- bottom > top)
- {
- win->_regtop = (short)top;
- win->_regbottom = (short)bottom;
-
- returnCode(OK);
- } else
- returnCode(ERR);
+ T((T_CALLED("wsetscrreg(%p,%d,%d)"), win, top, bottom));
+
+ if (win &&
+ top >= 0 && top <= win->_maxy &&
+ bottom >= 0 && bottom <= win->_maxy &&
+ bottom > top) {
+ win->_regtop = (NCURSES_SIZE_T) top;
+ win->_regbottom = (NCURSES_SIZE_T) bottom;
+
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c
index 443236cf9cda..b4d547fcf514 100644
--- a/contrib/ncurses/ncurses/base/lib_set_term.c
+++ b/contrib/ncurses/ncurses/base/lib_set_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -40,276 +40,352 @@
#include <curses.priv.h>
-#include <term.h> /* cur_term */
+#include <term.h> /* cur_term */
+#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.46 1999/07/24 20:05:49 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.55 2000/07/02 00:22:18 tom Exp $")
-SCREEN * set_term(SCREEN *screenp)
+SCREEN *
+set_term(SCREEN * screenp)
{
-SCREEN *oldSP;
+ SCREEN *oldSP;
- T((T_CALLED("set_term(%p)"), screenp));
+ T((T_CALLED("set_term(%p)"), screenp));
- oldSP = SP;
- _nc_set_screen(screenp);
+ oldSP = SP;
+ _nc_set_screen(screenp);
- set_curterm(SP->_term);
- curscr = SP->_curscr;
- newscr = SP->_newscr;
- stdscr = SP->_stdscr;
- COLORS = SP->_color_count;
- COLOR_PAIRS = SP->_pair_count;
- memcpy(acs_map, SP->_acs_map, sizeof(chtype)*ACS_LEN);
+ set_curterm(SP->_term);
+ curscr = SP->_curscr;
+ newscr = SP->_newscr;
+ stdscr = SP->_stdscr;
+ COLORS = SP->_color_count;
+ COLOR_PAIRS = SP->_pair_count;
+ memcpy(acs_map, SP->_acs_map, sizeof(chtype) * ACS_LEN);
- T((T_RETURN("%p"), oldSP));
- return(oldSP);
+ T((T_RETURN("%p"), oldSP));
+ return (oldSP);
}
-static void _nc_free_keytry(struct tries *kt)
+static void
+_nc_free_keytry(struct tries *kt)
{
- if (kt != 0) {
- _nc_free_keytry(kt->child);
- _nc_free_keytry(kt->sibling);
- free(kt);
- }
+ if (kt != 0) {
+ _nc_free_keytry(kt->child);
+ _nc_free_keytry(kt->sibling);
+ free(kt);
+ }
}
/*
* Free the storage associated with the given SCREEN sp.
*/
-void delscreen(SCREEN *sp)
+void
+delscreen(SCREEN * sp)
{
- SCREEN **scan = &_nc_screen_chain;
+ SCREEN **scan = &_nc_screen_chain;
- T((T_CALLED("delscreen(%p)"), sp));
+ T((T_CALLED("delscreen(%p)"), sp));
- while(*scan)
- {
- if (*scan == sp)
- {
- *scan = sp->_next_screen;
- break;
- }
- scan = &(*scan)->_next_screen;
+ while (*scan) {
+ if (*scan == sp) {
+ *scan = sp->_next_screen;
+ break;
}
+ scan = &(*scan)->_next_screen;
+ }
+
+ _nc_freewin(sp->_curscr);
+ _nc_freewin(sp->_newscr);
+ _nc_freewin(sp->_stdscr);
+ _nc_free_keytry(sp->_keytry);
+ _nc_free_keytry(sp->_key_ok);
+
+ FreeIfNeeded(sp->_color_table);
+ FreeIfNeeded(sp->_color_pairs);
+
+ FreeIfNeeded(sp->oldhash);
+ FreeIfNeeded(sp->newhash);
+
+ del_curterm(sp->_term);
+
+ /*
+ * If the associated output stream has been closed, we can discard the
+ * set-buffer. Limit the error check to EBADF, since fflush may fail
+ * for other reasons than trying to operate upon a closed stream.
+ */
+ if (sp->_ofp != 0
+ && sp->_setbuf != 0
+ && fflush(sp->_ofp) != 0
+ && errno == EBADF) {
+ free(sp->_setbuf);
+ }
+
+ free(sp);
+
+ /*
+ * If this was the current screen, reset everything that the
+ * application might try to use (except cur_term, which may have
+ * multiple references in different screens).
+ */
+ if (sp == SP) {
+ curscr = 0;
+ newscr = 0;
+ stdscr = 0;
+ COLORS = 0;
+ COLOR_PAIRS = 0;
+ _nc_set_screen(0);
+ }
+ returnVoid;
+}
- _nc_freewin(sp->_curscr);
- _nc_freewin(sp->_newscr);
- _nc_freewin(sp->_stdscr);
- _nc_free_keytry(sp->_keytry);
- _nc_free_keytry(sp->_key_ok);
-
- FreeIfNeeded(sp->_color_table);
- FreeIfNeeded(sp->_color_pairs);
+static ripoff_t rippedoff[5];
+static ripoff_t *rsp = rippedoff;
+#define N_RIPS SIZEOF(rippedoff)
- FreeIfNeeded(sp->oldhash);
- FreeIfNeeded(sp->newhash);
+static bool
+no_mouse_event(SCREEN * sp GCC_UNUSED)
+{
+ return FALSE;
+}
- del_curterm(sp->_term);
+static bool
+no_mouse_inline(SCREEN * sp GCC_UNUSED)
+{
+ return FALSE;
+}
- free(sp);
+static bool
+no_mouse_parse(int code GCC_UNUSED)
+{
+ return TRUE;
+}
- /*
- * If this was the current screen, reset everything that the
- * application might try to use (except cur_term, which may have
- * multiple references in different screens).
- */
- if (sp == SP) {
- curscr = 0;
- newscr = 0;
- stdscr = 0;
- COLORS = 0;
- COLOR_PAIRS = 0;
- _nc_set_screen(0);
- }
- returnVoid;
+static void
+no_mouse_resume(SCREEN * sp GCC_UNUSED)
+{
}
-static ripoff_t rippedoff[5];
-static ripoff_t *rsp = rippedoff;
-#define N_RIPS SIZEOF(rippedoff)
+static void
+no_mouse_wrap(SCREEN * sp GCC_UNUSED)
+{
+}
-static bool no_mouse_event (SCREEN *sp GCC_UNUSED) { return FALSE; }
-static bool no_mouse_inline(SCREEN *sp GCC_UNUSED) { return FALSE; }
-static bool no_mouse_parse (int code GCC_UNUSED) { return TRUE; }
-static void no_mouse_resume(SCREEN *sp GCC_UNUSED) { }
-static void no_mouse_wrap (SCREEN *sp GCC_UNUSED) { }
+#if defined(NCURSES_EXT_FUNCS) && defined(USE_COLORFGBG)
+static char *
+extract_fgbg(char *src, int *result)
+{
+ char *dst = 0;
+ long value = strtol(src, &dst, 0);
+
+ if (dst == 0) {
+ dst = src;
+ } else if (value >= 0) {
+ *result = value % max_colors;
+ }
+ while (*dst != 0 && *dst != ';')
+ dst++;
+ if (*dst == ';')
+ dst++;
+ return dst;
+}
+#endif
-int _nc_setupscreen(short slines, short const scolumns, FILE *output)
+int
+_nc_setupscreen(short slines, short const scolumns, FILE * output)
/* OS-independent screen initializations */
{
-int bottom_stolen = 0;
-size_t i;
-
- assert(SP==0); /* has been reset in newterm() ! */
- if (!_nc_alloc_screen())
- return ERR;
-
- SP->_next_screen = _nc_screen_chain;
- _nc_screen_chain = SP;
-
- _nc_set_buffer(output, TRUE);
- SP->_term = cur_term;
- SP->_lines = slines;
- SP->_lines_avail = slines;
- SP->_columns = scolumns;
- SP->_cursrow = -1;
- SP->_curscol = -1;
- SP->_nl = TRUE;
- SP->_raw = FALSE;
- SP->_cbreak = 0;
- SP->_echo = TRUE;
- SP->_fifohead = -1;
- SP->_endwin = TRUE;
- SP->_ofp = output;
- SP->_cursor = -1; /* cannot know real cursor shape */
+ int bottom_stolen = 0;
+ size_t i;
+
+ assert(SP == 0); /* has been reset in newterm() ! */
+ if (!_nc_alloc_screen())
+ return ERR;
+
+ SP->_next_screen = _nc_screen_chain;
+ _nc_screen_chain = SP;
+
+ _nc_set_buffer(output, TRUE);
+ SP->_term = cur_term;
+ SP->_lines = slines;
+ SP->_lines_avail = slines;
+ SP->_columns = scolumns;
+ SP->_cursrow = -1;
+ SP->_curscol = -1;
+ SP->_nl = TRUE;
+ SP->_raw = FALSE;
+ SP->_cbreak = 0;
+ SP->_echo = TRUE;
+ SP->_fifohead = -1;
+ SP->_endwin = TRUE;
+ SP->_ofp = output;
+ SP->_cursor = -1; /* cannot know real cursor shape */
#ifdef NCURSES_NO_PADDING
- SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
+ SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
+ SP->_no_padding ? " not" : ""));
#endif
-
- SP->_maxclick = DEFAULT_MAXCLICK;
- SP->_mouse_event = no_mouse_event;
- SP->_mouse_inline = no_mouse_inline;
- SP->_mouse_parse = no_mouse_parse;
- SP->_mouse_resume = no_mouse_resume;
- SP->_mouse_wrap = no_mouse_wrap;
- SP->_mouse_fd = -1;
-
- /* initialize the panel hooks */
- SP->_panelHook.top_panel = (struct panel*)0;
- SP->_panelHook.bottom_panel = (struct panel*)0;
- SP->_panelHook.stdscr_pseudo_panel = (struct panel*)0;
-
+#ifdef NCURSES_EXT_FUNCS
+ SP->_default_color = FALSE;
+ SP->_has_sgr_39_49 = FALSE;
+ SP->_default_fg = COLOR_WHITE;
+ SP->_default_bg = COLOR_BLACK;
+#ifdef 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
+ * color to that value plus 8. We'll only use the non-bold color for now -
+ * decide later if it is worth having default attributes as well.
+ */
+ if (getenv("COLORFGBG") != 0) {
+ char *p = getenv("COLORFGBG");
+ p = extract_fgbg(p, &(SP->_default_fg));
+ p = extract_fgbg(p, &(SP->_default_bg));
+ }
+#endif
+#endif /* NCURSES_EXT_FUNCS */
+
+ SP->_maxclick = DEFAULT_MAXCLICK;
+ SP->_mouse_event = no_mouse_event;
+ SP->_mouse_inline = no_mouse_inline;
+ SP->_mouse_parse = no_mouse_parse;
+ SP->_mouse_resume = no_mouse_resume;
+ SP->_mouse_wrap = no_mouse_wrap;
+ SP->_mouse_fd = -1;
+
+ /* initialize the panel hooks */
+ SP->_panelHook.top_panel = (struct panel *) 0;
+ SP->_panelHook.bottom_panel = (struct panel *) 0;
+ SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
+
+ /*
+ * If we've no magic cookie support, we suppress attributes that xmc
+ * would affect, i.e., the attributes that affect the rendition of a
+ * space. Note that this impacts the alternate character set mapping
+ * as well.
+ */
+ if (magic_cookie_glitch > 0) {
+
+ SP->_xmc_triggers = termattrs() & (
+ A_ALTCHARSET |
+ A_BLINK |
+ A_BOLD |
+ A_REVERSE |
+ A_STANDOUT |
+ A_UNDERLINE
+ );
+ SP->_xmc_suppress = SP->_xmc_triggers & (chtype) ~ (A_BOLD);
+
+ T(("magic cookie attributes %s", _traceattr(SP->_xmc_suppress)));
+#if USE_XMC_SUPPORT
/*
- * If we've no magic cookie support, we suppress attributes that xmc
- * would affect, i.e., the attributes that affect the rendition of a
- * space. Note that this impacts the alternate character set mapping
- * as well.
+ * To keep this simple, suppress all of the optimization hooks
+ * except for clear_screen and the cursor addressing.
*/
- if (magic_cookie_glitch > 0) {
-
- SP->_xmc_triggers = termattrs() & (
- A_ALTCHARSET |
- A_BLINK |
- A_BOLD |
- A_REVERSE |
- A_STANDOUT |
- A_UNDERLINE
- );
- SP->_xmc_suppress = SP->_xmc_triggers & (chtype)~(A_BOLD);
-
- T(("magic cookie attributes %s", _traceattr(SP->_xmc_suppress)));
-#if USE_XMC_SUPPORT
- /*
- * To keep this simple, suppress all of the optimization hooks
- * except for clear_screen and the cursor addressing.
- */
- clr_eol = 0;
- clr_eos = 0;
- set_attributes = 0;
+ clr_eol = 0;
+ clr_eos = 0;
+ set_attributes = 0;
#else
- magic_cookie_glitch = -1;
- acs_chars = 0;
+ magic_cookie_glitch = ABSENT_NUMERIC;
+ acs_chars = 0;
#endif
- }
- _nc_init_acs();
- memcpy(SP->_acs_map, acs_map, sizeof(chtype)*ACS_LEN);
+ }
+ _nc_init_acs();
+ memcpy(SP->_acs_map, acs_map, sizeof(chtype) * ACS_LEN);
- _nc_idcok = TRUE;
- _nc_idlok = FALSE;
+ _nc_idcok = TRUE;
+ _nc_idlok = FALSE;
- _nc_windows = 0; /* no windows yet */
+ _nc_windows = 0; /* no windows yet */
- SP->oldhash = 0;
- SP->newhash = 0;
+ SP->oldhash = 0;
+ SP->newhash = 0;
- T(("creating newscr"));
- if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ T(("creating newscr"));
+ if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
+ return ERR;
- T(("creating curscr"));
- if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ T(("creating curscr"));
+ if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
+ return ERR;
- SP->_newscr = newscr;
- SP->_curscr = curscr;
+ SP->_newscr = newscr;
+ SP->_curscr = curscr;
#if USE_SIZECHANGE
- SP->_resize = resizeterm;
+ SP->_resize = resizeterm;
#endif
- newscr->_clear = TRUE;
- curscr->_clear = FALSE;
-
- for (i=0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
- if (rsp->hook) {
- WINDOW *w;
- int count = (rsp->line < 0) ? -rsp->line : rsp->line;
-
- if (rsp->line < 0) {
- w = newwin(count,scolumns,SP->_lines_avail - count,0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- bottom_stolen += count;
- }
- else
+ newscr->_clear = TRUE;
+ curscr->_clear = FALSE;
+
+ for (i = 0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
+ if (rsp->hook) {
+ WINDOW *w;
+ int count = (rsp->line < 0) ? -rsp->line : rsp->line;
+
+ if (rsp->line < 0) {
+ w = newwin(count, scolumns, SP->_lines_avail - count, 0);
+ if (w) {
+ rsp->w = w;
+ rsp->hook(w, scolumns);
+ bottom_stolen += count;
+ } else
return ERR;
- } else {
- w = newwin(count,scolumns, 0, 0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- SP->_topstolen += count;
- }
- else
+ } else {
+ w = newwin(count, scolumns, 0, 0);
+ if (w) {
+ rsp->w = w;
+ rsp->hook(w, scolumns);
+ SP->_topstolen += count;
+ } else
return ERR;
- }
- SP->_lines_avail -= count;
- }
- rsp->line = 0;
+ }
+ SP->_lines_avail -= count;
}
- /* reset the stack */
- rsp = rippedoff;
+ rsp->line = 0;
+ }
+ /* reset the stack */
+ rsp = rippedoff;
- T(("creating stdscr"));
- assert ((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
- if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
- return ERR;
- SP->_stdscr = stdscr;
+ T(("creating stdscr"));
+ assert((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
+ if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
+ return ERR;
+ SP->_stdscr = stdscr;
- def_shell_mode();
- def_prog_mode();
+ def_shell_mode();
+ def_prog_mode();
- return OK;
+ return OK;
}
/* The internal implementation interprets line as the number of
lines to rip off from the top or bottom.
*/
int
-_nc_ripoffline(int line, int (*init)(WINDOW *,int))
+_nc_ripoffline(int line, int (*init) (WINDOW *, int))
{
if (line == 0)
- return(OK);
+ return (OK);
if (rsp >= rippedoff + N_RIPS)
- return(ERR);
+ return (ERR);
rsp->line = line;
rsp->hook = init;
- rsp->w = 0;
+ rsp->w = 0;
rsp++;
- return(OK);
+ return (OK);
}
int
-ripoffline(int line, int (*init)(WINDOW *, int))
+ripoffline(int line, int (*init) (WINDOW *, int))
{
T((T_CALLED("ripoffline(%d,%p)"), line, init));
if (line == 0)
returnCode(OK);
- returnCode(_nc_ripoffline ((line<0) ? -1 : 1, init));
+ returnCode(_nc_ripoffline((line < 0) ? -1 : 1, init));
}
diff --git a/contrib/ncurses/ncurses/base/lib_slk.c b/contrib/ncurses/ncurses/base/lib_slk.c
index 9b9b09a4d064..21eae687c67f 100644
--- a/contrib/ncurses/ncurses/base/lib_slk.c
+++ b/contrib/ncurses/ncurses/base/lib_slk.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 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,13 +41,13 @@
#include <ctype.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slk.c,v 1.16 1999/03/03 23:44:22 juergen Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.17 1999/10/30 23:00:16 tom Exp $")
/*
* We'd like to move these into the screen context structure, but cannot,
* because slk_init() is called before initscr()/newterm().
*/
-int _nc_slk_format; /* one more than format specified in slk_init() */
+int _nc_slk_format = 0; /* one more than format specified in slk_init() */
/*
* Paint the info line for the PC style SLK emulation.
diff --git a/contrib/ncurses/ncurses/base/lib_vline.c b/contrib/ncurses/ncurses/base/lib_vline.c
index 007ef55cd3ba..e48b864f497d 100644
--- a/contrib/ncurses/ncurses/base/lib_vline.c
+++ b/contrib/ncurses/ncurses/base/lib_vline.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_vline.c
**
@@ -42,36 +40,37 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_vline.c,v 1.4 1998/06/28 00:10:12 tom Exp $")
+MODULE_ID("$Id: lib_vline.c,v 1.5 2000/04/29 21:14:11 tom Exp $")
-int wvline(WINDOW *win, chtype ch, int n)
+int
+wvline(WINDOW *win, chtype ch, int n)
{
-int code = ERR;
-short row, col;
-short end;
+ int code = ERR;
+ NCURSES_SIZE_T row, col;
+ NCURSES_SIZE_T end;
- T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n));
+ T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n));
- if (win) {
- row = win->_cury;
- col = win->_curx;
- end = row + n - 1;
- if (end > win->_maxy)
- end = win->_maxy;
+ if (win) {
+ row = win->_cury;
+ col = win->_curx;
+ end = row + n - 1;
+ if (end > win->_maxy)
+ end = win->_maxy;
- if (ch == 0)
- ch = ACS_VLINE;
- ch = _nc_render(win, ch);
+ if (ch == 0)
+ ch = ACS_VLINE;
+ ch = _nc_render(win, ch);
- while(end >= row) {
- struct ldat *line = &(win->_line[end]);
- line->text[col] = ch;
- CHANGED_CELL(line, col);
- end--;
- }
-
- _nc_synchook(win);
- code = OK;
+ while (end >= row) {
+ struct ldat *line = &(win->_line[end]);
+ line->text[col] = ch;
+ CHANGED_CELL(line, col);
+ end--;
}
- returnCode(code);
+
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/version.c b/contrib/ncurses/ncurses/base/version.c
index 74d46ae9efa4..a2fe4d86d650 100644
--- a/contrib/ncurses/ncurses/base/version.c
+++ b/contrib/ncurses/ncurses/base/version.c
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: version.c,v 1.1 1999/10/23 13:28:49 tom Exp $")
+MODULE_ID("$Id: version.c,v 1.2 1999/12/04 21:27:23 tom Exp $")
const char *
curses_version(void)
@@ -40,9 +40,8 @@ curses_version(void)
static char my_version[80];
T((T_CALLED("curses_version()")));
- sprintf(my_version, "ncurses %d.%d.%d",
- NCURSES_VERSION_MAJOR,
- NCURSES_VERSION_MINOR,
+ sprintf(my_version, "ncurses %s.%d",
+ NCURSES_VERSION,
NCURSES_VERSION_PATCH);
returnPtr(my_version);
}
diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c
index 1b91476cbfd3..8121ff154dd5 100644
--- a/contrib/ncurses/ncurses/base/wresize.c
+++ b/contrib/ncurses/ncurses/base/wresize.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.12 1999/02/27 18:57:31 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.16 2000/03/05 00:14:35 tom Exp $")
/*
* Reallocate a curses WINDOW struct to either shrink or grow to the specified
@@ -47,120 +47,133 @@ MODULE_ID("$Id: wresize.c,v 1.12 1999/02/27 18:57:31 tom Exp $")
int
wresize(WINDOW *win, int ToLines, int ToCols)
{
- register int row;
- int size_x, size_y;
- struct ldat *pline;
- chtype blank;
+ register int row;
+ int size_x, size_y;
+ struct ldat *pline;
+ chtype blank;
#ifdef TRACE
- T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
- if (win) {
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
+ T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
+ if (win) {
+ TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
+ win->_begy, win->_begx,
+ win->_maxy, win->_maxx,
+ win->_regtop, win->_regbottom));
+ if (_nc_tracing & TRACE_UPDATE)
_tracedump("...before", win);
- }
+ }
#endif
- if (!win || --ToLines < 0 || --ToCols < 0)
- returnCode(ERR);
+ if (!win || --ToLines < 0 || --ToCols < 0)
+ returnCode(ERR);
- size_x = win->_maxx;
- size_y = win->_maxy;
+ size_x = win->_maxx;
+ size_y = win->_maxy;
- if (ToLines == size_y
- && ToCols == size_x)
- returnCode(OK);
-
- pline = (win->_flags & _SUBWIN) ? win->_parent->_line : 0;
+ if (ToLines == size_y
+ && ToCols == size_x)
+ returnCode(OK);
+ if ((win->_flags & _SUBWIN)) {
/*
- * If the number of lines has changed, adjust the size of the overall
- * vector:
+ * Check if the new limits will fit into the parent window's size. If
+ * not, do not resize. We could adjust the location of the subwindow,
+ * but the application may not like that.
*/
- if (ToLines != size_y) {
- if (! (win->_flags & _SUBWIN)) {
- for (row = ToLines+1; row <= size_y; row++)
- free((char *)(win->_line[row].text));
- }
-
- win->_line = ld_ALLOC(win->_line, ToLines+1);
- if (win->_line == 0)
- returnCode(ERR);
-
- for (row = size_y+1; row <= ToLines; row++) {
- win->_line[row].text = 0;
- win->_line[row].firstchar = 0;
- win->_line[row].lastchar = ToCols;
- if ((win->_flags & _SUBWIN)) {
- win->_line[row].text =
- &pline[win->_begy + row].text[win->_begx];
- }
- }
+ if (win->_pary + ToLines > win->_parent->_maxy
+ || win->_parx + ToCols > win->_parent->_maxx) {
+ returnCode(ERR);
}
-
- /*
- * Adjust the width of the columns:
- */
- blank = _nc_background(win);
- for (row = 0; row <= ToLines; row++) {
- chtype *s = win->_line[row].text;
- int begin = (s == 0) ? 0 : size_x + 1;
- int end = ToCols;
-
- if_USE_SCROLL_HINTS(win->_line[row].oldindex = row);
-
- if (ToCols != size_x || s == 0) {
- if (! (win->_flags & _SUBWIN)) {
- win->_line[row].text = s = c_ALLOC(s, ToCols+1);
- if (win->_line[row].text == 0)
- returnCode(ERR);
- } else if (s == 0) {
- win->_line[row].text = s =
- &pline[win->_begy + row].text[win->_begx];
- }
-
- if (end >= begin) { /* growing */
- if (win->_line[row].firstchar < begin)
- win->_line[row].firstchar = begin;
- win->_line[row].lastchar = ToCols;
- do {
- s[end] = blank;
- } while (--end >= begin);
- } else { /* shrinking */
- win->_line[row].firstchar = 0;
- win->_line[row].lastchar = ToCols;
- }
- }
+ pline = win->_parent->_line;
+ } else {
+ pline = 0;
+ }
+
+ /*
+ * If the number of lines has changed, adjust the size of the overall
+ * vector:
+ */
+ if (ToLines != size_y) {
+ if (!(win->_flags & _SUBWIN)) {
+ for (row = ToLines + 1; row <= size_y; row++)
+ free((char *) (win->_line[row].text));
}
- /*
- * Finally, adjust the parameters showing screen size and cursor
- * position:
- */
- win->_maxx = ToCols;
- win->_maxy = ToLines;
-
- if (win->_regtop > win->_maxy)
- win->_regtop = win->_maxy;
- if (win->_regbottom > win->_maxy
- || win->_regbottom == size_y)
- win->_regbottom = win->_maxy;
-
- if (win->_curx > win->_maxx)
- win->_curx = win->_maxx;
- if (win->_cury > win->_maxy)
- win->_cury = win->_maxy;
+ win->_line = ld_ALLOC(win->_line, ToLines + 1);
+ if (win->_line == 0)
+ returnCode(ERR);
+
+ for (row = size_y + 1; row <= ToLines; row++) {
+ win->_line[row].text = 0;
+ win->_line[row].firstchar = 0;
+ win->_line[row].lastchar = ToCols;
+ if ((win->_flags & _SUBWIN)) {
+ win->_line[row].text =
+ &pline[win->_pary + row].text[win->_parx];
+ }
+ }
+ }
+
+ /*
+ * Adjust the width of the columns:
+ */
+ blank = _nc_background(win);
+ for (row = 0; row <= ToLines; row++) {
+ chtype *s = win->_line[row].text;
+ int begin = (s == 0) ? 0 : size_x + 1;
+ int end = ToCols;
+
+ if_USE_SCROLL_HINTS(win->_line[row].oldindex = row);
+
+ if (ToCols != size_x || s == 0) {
+ if (!(win->_flags & _SUBWIN)) {
+ win->_line[row].text = s = c_ALLOC(s, ToCols + 1);
+ if (win->_line[row].text == 0)
+ returnCode(ERR);
+ } else if (s == 0) {
+ win->_line[row].text = s =
+ &pline[win->_pary + row].text[win->_parx];
+ }
+
+ if (end >= begin) { /* growing */
+ if (win->_line[row].firstchar < begin)
+ win->_line[row].firstchar = begin;
+ win->_line[row].lastchar = ToCols;
+ do {
+ s[end] = blank;
+ } while (--end >= begin);
+ } else { /* shrinking */
+ win->_line[row].firstchar = 0;
+ win->_line[row].lastchar = ToCols;
+ }
+ }
+ }
+
+ /*
+ * Finally, adjust the parameters showing screen size and cursor
+ * position:
+ */
+ win->_maxx = ToCols;
+ win->_maxy = ToLines;
+
+ if (win->_regtop > win->_maxy)
+ win->_regtop = win->_maxy;
+ if (win->_regbottom > win->_maxy
+ || win->_regbottom == size_y)
+ win->_regbottom = win->_maxy;
+
+ if (win->_curx > win->_maxx)
+ win->_curx = win->_maxx;
+ if (win->_cury > win->_maxy)
+ win->_cury = win->_maxy;
#ifdef TRACE
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
- _tracedump("...after:", win);
+ TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
+ win->_begy, win->_begx,
+ win->_maxy, win->_maxx,
+ win->_regtop, win->_regbottom));
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("...after:", win);
#endif
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/curses.priv.h b/contrib/ncurses/ncurses/curses.priv.h
index 76a923059e76..d3d5f296ef8b 100644
--- a/contrib/ncurses/ncurses/curses.priv.h
+++ b/contrib/ncurses/ncurses/curses.priv.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -33,7 +33,7 @@
/*
- * $Id: curses.priv.h,v 1.144 1999/10/22 23:15:37 tom Exp $
+ * $Id: curses.priv.h,v 1.162 2000/06/24 21:06:10 tom Exp $
*
* curses.priv.h
*
@@ -97,8 +97,13 @@ extern int errno;
#include <nc_panel.h>
/* Some systems have a broken 'select()', but workable 'poll()'. Use that */
-#if HAVE_POLL && HAVE_SYS_STROPTS_H && HAVE_POLL_H
+#if HAVE_WORKING_POLL
#define USE_FUNC_POLL 1
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#else
+#include <sys/poll.h>
+#endif
#else
#define USE_FUNC_POLL 0
#endif
@@ -305,7 +310,7 @@ struct screen {
int _cuu_cost; /* cost of (parm_cursor_up) */
int _hpa_cost; /* cost of (column_address) */
int _vpa_cost; /* cost of (row_address) */
- /* used in lib_doupdate.c, must be chars */
+ /* used in tty_update.c, must be chars */
int _ed_cost; /* cost of (clr_eos) */
int _el_cost; /* cost of (clr_eol) */
int _el1_cost; /* cost of (clr_bol) */
@@ -317,6 +322,8 @@ struct screen {
int _rep_cost; /* cost of (repeat_char) */
int _hpa_ch_cost; /* cost of (column_address) */
int _cup_ch_cost; /* cost of (cursor_address) */
+ int _cuf_ch_cost; /* cost of (parm_cursor_right) */
+ int _inline_cost; /* cost of inline-move */
int _smir_cost; /* cost of (enter_insert_mode) */
int _rmir_cost; /* cost of (exit_insert_mode) */
int _ip_cost; /* cost of (insert_padding) */
@@ -332,7 +339,12 @@ 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 */
- int _default_color; /* use default colors */
+#ifdef 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 */
+ int _default_bg; /* assumed default background */
+#endif
chtype _xmc_suppress; /* attributes to suppress if xmc */
chtype _xmc_triggers; /* attributes to process if xmc */
chtype _acs_map[ACS_LEN];
@@ -390,6 +402,7 @@ struct screen {
unsigned long *oldhash, *newhash;
bool _cleanup; /* cleanup after int/quit signal */
+ int (*_outch)(int); /* output handler if not putc */
};
extern SCREEN *_nc_screen_chain;
@@ -454,6 +467,14 @@ typedef struct {
#define F_OK 0 /* Test for existence. */
#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h> /* may define O_BINARY */
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#define TextOf(c) ((c) & (chtype)A_CHARTEXT)
#define AttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
@@ -484,10 +505,12 @@ typedef struct {
line->lastchar = end
#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
-#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type))
-#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type))
-#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type))
-#define FreeIfNeeded(p) if(p != 0) free(p)
+
+#define FreeIfNeeded(p) if ((p) != 0) free(p)
+
+/* FreeAndNull() is not a comma-separated expression because some compilers
+ * do not accept a mixture of void with values.
+ */
#define FreeAndNull(p) free(p); p = 0
#include <nc_alloc.h>
@@ -540,15 +563,15 @@ extern const char *_nc_visbuf2(int, const char *);
#define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
-#define toggle_attr_on(S,at) \
+#define toggle_attr_on(S,at) {\
if (PAIR_NUMBER(at) > 0)\
(S) = ((S) & ALL_BUT_COLOR) | (at);\
else\
(S) |= (at);\
- T(("new attribute is %s", _traceattr((S))))
+ T(("new attribute is %s", _traceattr((S))));}
-#define toggle_attr_off(S,at) \
+#define toggle_attr_off(S,at) {\
if (IGNORE_COLOR_OFF == TRUE) {\
if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
(S) &= ~(at);\
@@ -560,7 +583,7 @@ extern const char *_nc_visbuf2(int, const char *);
else /* leave color alone */\
(S) &= ~(at);\
}\
- T(("new attribute is %s", _traceattr((S))));
+ T(("new attribute is %s", _traceattr((S))));}
#define DelCharCost(count) \
((parm_dch != 0) \
@@ -593,19 +616,10 @@ extern const char *_nc_visbuf2(int, const char *);
}
#else
#define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) \
- vidattr(AttrOf(c));
+ vidattr(AttrOf(c))
#endif
-/*
- * Check whether the given character can be output by clearing commands. This
- * includes test for being a space and not including any 'bad' attributes, such
- * as A_REVERSE. All attribute flags which don't affect appearance of a space
- * or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
- */
-#define can_clear_with(ch) \
- ((ch & ~(NONBLANK_ATTR|(back_color_erase ? A_COLOR:0))) == BLANK)
-
-#ifdef NCURSES_EXPANDED
+#if defined(NCURSES_EXPANDED) && defined(NCURSES_EXT_FUNCS)
#undef toggle_attr_on
#define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
@@ -615,10 +629,6 @@ extern void _nc_toggle_attr_on(attr_t *, attr_t);
#define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at)
extern void _nc_toggle_attr_off(attr_t *, attr_t);
-#undef can_clear_with
-#define can_clear_with(ch) _nc_can_clear_with(ch)
-extern int _nc_can_clear_with(chtype);
-
#undef DelCharCost
#define DelCharCost(count) _nc_DelCharCost(count)
extern int _nc_DelCharCost(int);
@@ -641,13 +651,6 @@ extern void _nc_expanded(void);
#define getcwd(buf,len) getwd(buf)
#endif
-/* doalloc.c */
-extern void *_nc_doalloc(void *, size_t);
-#if !HAVE_STRDUP
-#define strdup _nc_strdup
-extern char *_nc_strdup(const char *);
-#endif
-
/* doupdate.c */
#if USE_XMC_SUPPORT
extern void _nc_do_xmc_glitch(attr_t);
@@ -687,7 +690,7 @@ extern int _nc_has_mouse(void);
extern char * _nc_printf_string(const char *fmt, va_list ap);
/* tries.c */
-extern void _nc_add_to_try(struct tries **tree, char *str, unsigned short code);
+extern void _nc_add_to_try(struct tries **tree, const char *str, unsigned short code);
extern char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len);
extern int _nc_remove_key(struct tries **tree, unsigned short code);
extern int _nc_remove_string(struct tries **tree, char *string);
@@ -707,18 +710,19 @@ extern int _nc_outch(int);
extern int _nc_setupscreen(short, short const, FILE *);
extern int _nc_timed_wait(int, int, int *);
extern int _nc_waddch_nosync(WINDOW *, const chtype);
-extern void _nc_do_color(int, bool, int (*)(int));
+extern void _nc_do_color(int, int, bool, int (*)(int));
extern void _nc_freeall(void);
extern void _nc_freewin(WINDOW *win);
extern void _nc_hash_map(void);
extern void _nc_init_keytry(void);
extern void _nc_keep_tic_dir(const char *);
extern void _nc_make_oldhash(int i);
+extern void _nc_flush(void);
extern void _nc_outstr(const char *str);
extern void _nc_scroll_oldhash(int n, int top, int bot);
extern void _nc_scroll_optimize(void);
extern void _nc_scroll_window(WINDOW *, int const, short const, short const, chtype);
-extern void _nc_set_buffer(FILE *ofp, bool buffered);
+extern void _nc_set_buffer(FILE *, bool);
extern void _nc_signal_handler(bool);
extern void _nc_synchook(WINDOW *win);
extern void _nc_trace_tries(struct tries *tree);
@@ -727,6 +731,10 @@ extern void _nc_trace_tries(struct tries *tree);
extern void _nc_update_screensize(void);
#endif
+#ifdef USE_WIDEC_SUPPORT
+extern int _nc_utf8_outch(int);
+#endif
+
/* scroll indices */
extern int *_nc_oldnums;
@@ -737,7 +745,6 @@ extern int *_nc_oldnums;
_nc_set_buffer(SP->_ofp, flag)
#define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
-#define _nc_flush() (void)fflush(NC_OUTPUT)
/*
* On systems with a broken linker, define 'SP' as a function to force the
diff --git a/contrib/ncurses/ncurses/llib-lncurses b/contrib/ncurses/ncurses/llib-lncurses
index 83a1e0e7d348..4ea7899429f0 100644
--- a/contrib/ncurses/ncurses/llib-lncurses
+++ b/contrib/ncurses/ncurses/llib-lncurses
@@ -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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,1998,1999 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1996-2000 *
****************************************************************************/
/* LINTLIBRARY */
@@ -196,6 +196,8 @@ int wclrtoeol(
/* ./base/lib_color.c */
+#include <tic.h>
+
#undef COLOR_PAIRS
int COLOR_PAIRS;
#undef COLORS
@@ -446,6 +448,10 @@ int echochar(
const chtype z)
{ return(*(int *)0); }
+#undef erase
+int erase(void)
+ { return(*(int *)0); }
+
#undef getbkgd
chtype getbkgd(
WINDOW *z)
@@ -1059,8 +1065,6 @@ int winchnstr(
/* ./base/lib_initscr.c */
-#include <tic.h>
-
#undef initscr
WINDOW *initscr(void)
{ return(*(WINDOW **)0); }
@@ -1936,6 +1940,12 @@ int keyok(
int use_default_colors(void)
{ return(*(int *)0); }
+#undef assume_default_colors
+int assume_default_colors(
+ int fg,
+ int bg)
+ { return(*(int *)0); }
+
/* ./base/lib_freeall.c */
#include <term_entry.h>
@@ -2191,7 +2201,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entries
void _nc_free_entries(
- ENTRY *head)
+ ENTRY *headp)
{ /* void */ }
#undef _nc_entry_match
@@ -2665,8 +2675,6 @@ int tputs(
/* ./trace/lib_trace.c */
-#include <fcntl.h>
-
#undef _nc_tracing
unsigned _nc_tracing;
@@ -2790,7 +2798,10 @@ int _nc_capcmp(
const char *t)
{ return(*(int *)0); }
-typedef struct {const char *from; const char *to;} assoc;
+typedef struct {
+ const char *from;
+ const char *to;
+} assoc;
/* ./tinfo/read_entry.c */
diff --git a/contrib/ncurses/ncurses/modules b/contrib/ncurses/ncurses/modules
index 4b9c5dfecefb..12ed6a5f6aba 100644
--- a/contrib/ncurses/ncurses/modules
+++ b/contrib/ncurses/ncurses/modules
@@ -1,6 +1,6 @@
-# $Id: modules,v 1.70 1999/10/23 12:39:12 tom Exp $
+# $Id: modules,v 1.72 2000/02/13 01:03:28 tom Exp $
##############################################################################
-# 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 "Software"), #
@@ -27,7 +27,7 @@
# authorization. #
##############################################################################
#
-# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,1998
+# Author: Thomas E. Dickey <dickey@clark.net> 1996-1998
#
@ base
@@ -165,7 +165,7 @@ lib_napms lib $(tinfo)
lib_options lib $(tinfo) ../include/term.h
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
+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_ti lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
lib_tparm lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
@@ -177,7 +177,7 @@ lib_ttyflags lib $(tinfo) ../include/term.h
lib_twait lib $(serial)
name_match lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
names lib .
-parse_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h ../include/parametrized.h
+parse_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h ../include/parametrized.h $(INCDIR)/capdefaults.c
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)
diff --git a/contrib/ncurses/ncurses/tinfo/add_tries.c b/contrib/ncurses/ncurses/tinfo/add_tries.c
index 95a9e965c5a7..601fb663b7b6 100644
--- a/contrib/ncurses/ncurses/tinfo/add_tries.c
+++ b/contrib/ncurses/ncurses/tinfo/add_tries.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,86 +39,87 @@
#include <curses.priv.h>
-MODULE_ID("$Id: add_tries.c,v 1.1 1998/11/08 00:04:18 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.2 2000/03/18 22:23:56 tom Exp $")
#define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
#define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
-void _nc_add_to_try(struct tries **tree, char *str, unsigned short code)
+void
+_nc_add_to_try(struct tries **tree, const char *str, unsigned short code)
{
- static bool out_of_memory = FALSE;
- struct tries *ptr, *savedptr;
- unsigned char *txt = (unsigned char *)str;
-
- if (txt == 0 || *txt == '\0' || out_of_memory || code == 0)
- return;
-
- if ((*tree) != 0) {
- ptr = savedptr = (*tree);
-
- for (;;) {
- unsigned char cmp = *txt;
-
- while (!CMP_TRY(ptr->ch, cmp)
- && ptr->sibling != 0)
- ptr = ptr->sibling;
-
- if (CMP_TRY(ptr->ch, cmp)) {
- if (*(++txt) == '\0') {
- ptr->value = code;
- return;
- }
- if (ptr->child != 0)
- ptr = ptr->child;
- else
- break;
- } else {
- if ((ptr->sibling = typeCalloc(struct tries,1)) == 0) {
- out_of_memory = TRUE;
- return;
- }
-
- savedptr = ptr = ptr->sibling;
- SET_TRY(ptr,txt);
- ptr->value = 0;
-
- break;
- }
- } /* end for (;;) */
- } else { /* (*tree) == 0 :: First sequence to be added */
- savedptr = ptr = (*tree) = typeCalloc(struct tries,1);
-
- if (ptr == 0) {
- out_of_memory = TRUE;
- return;
+ static bool out_of_memory = FALSE;
+ struct tries *ptr, *savedptr;
+ unsigned const char *txt = (unsigned const char *) str;
+
+ if (txt == 0 || *txt == '\0' || out_of_memory || code == 0)
+ return;
+
+ if ((*tree) != 0) {
+ ptr = savedptr = (*tree);
+
+ for (;;) {
+ unsigned char cmp = *txt;
+
+ while (!CMP_TRY(ptr->ch, cmp)
+ && ptr->sibling != 0)
+ ptr = ptr->sibling;
+
+ if (CMP_TRY(ptr->ch, cmp)) {
+ if (*(++txt) == '\0') {
+ ptr->value = code;
+ return;
+ }
+ if (ptr->child != 0)
+ ptr = ptr->child;
+ else
+ break;
+ } else {
+ if ((ptr->sibling = typeCalloc(struct tries, 1)) == 0) {
+ out_of_memory = TRUE;
+ return;
}
- SET_TRY(ptr,txt);
+ savedptr = ptr = ptr->sibling;
+ SET_TRY(ptr, txt);
ptr->value = 0;
+
+ break;
+ }
+ } /* end for (;;) */
+ } else { /* (*tree) == 0 :: First sequence to be added */
+ savedptr = ptr = (*tree) = typeCalloc(struct tries, 1);
+
+ if (ptr == 0) {
+ out_of_memory = TRUE;
+ return;
}
- /* at this point, we are adding to the try. ptr->child == 0 */
+ SET_TRY(ptr, txt);
+ ptr->value = 0;
+ }
- while (*txt) {
- ptr->child = typeCalloc(struct tries,1);
+ /* at this point, we are adding to the try. ptr->child == 0 */
- ptr = ptr->child;
+ while (*txt) {
+ ptr->child = typeCalloc(struct tries, 1);
- if (ptr == 0) {
- out_of_memory = TRUE;
+ ptr = ptr->child;
- while ((ptr = savedptr) != 0) {
- savedptr = ptr->child;
- free(ptr);
- }
+ if (ptr == 0) {
+ out_of_memory = TRUE;
- return;
- }
+ while ((ptr = savedptr) != 0) {
+ savedptr = ptr->child;
+ free(ptr);
+ }
- SET_TRY(ptr,txt);
- ptr->value = 0;
+ return;
}
- ptr->value = code;
- return;
+ SET_TRY(ptr, txt);
+ ptr->value = 0;
+ }
+
+ ptr->value = code;
+ return;
}
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_entry.c b/contrib/ncurses/ncurses/tinfo/alloc_entry.c
index 570b48a9af80..17489372e464 100644
--- a/contrib/ncurses/ncurses/tinfo/alloc_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/alloc_entry.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> *
****************************************************************************/
-
/*
* alloc_entry.c -- allocation functions for terminfo entries
*
@@ -48,149 +47,152 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: alloc_entry.c,v 1.30 1999/03/01 02:03:45 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.32 2000/03/12 00:16:31 tom Exp $")
#define ABSENT_OFFSET -1
#define CANCELLED_OFFSET -2
#define MAX_STRTAB 4096 /* documented maximum entry size */
-static char stringbuf[MAX_STRTAB]; /* buffer for string capabilities */
-static size_t next_free; /* next free character in stringbuf */
+static char stringbuf[MAX_STRTAB]; /* buffer for string capabilities */
+static size_t next_free; /* next free character in stringbuf */
-void _nc_init_entry(TERMTYPE *const tp)
+void
+_nc_init_entry(TERMTYPE * const tp)
/* initialize a terminal type data block */
{
-int i;
+ int i;
#if NCURSES_XNAMES
- tp->num_Booleans = BOOLCOUNT;
- tp->num_Numbers = NUMCOUNT;
- tp->num_Strings = STRCOUNT;
- tp->ext_Booleans = 0;
- tp->ext_Numbers = 0;
- tp->ext_Strings = 0;
+ tp->num_Booleans = BOOLCOUNT;
+ tp->num_Numbers = NUMCOUNT;
+ tp->num_Strings = STRCOUNT;
+ tp->ext_Booleans = 0;
+ tp->ext_Numbers = 0;
+ tp->ext_Strings = 0;
#endif
- if (tp->Booleans == 0)
- tp->Booleans = typeMalloc(char,BOOLCOUNT);
- if (tp->Numbers == 0)
- tp->Numbers = typeMalloc(short,NUMCOUNT);
- if (tp->Strings == 0)
- tp->Strings = typeMalloc(char *,STRCOUNT);
+ if (tp->Booleans == 0)
+ tp->Booleans = typeMalloc(char, BOOLCOUNT);
+ if (tp->Numbers == 0)
+ tp->Numbers = typeMalloc(short, NUMCOUNT);
+ if (tp->Strings == 0)
+ tp->Strings = typeMalloc(char *, STRCOUNT);
- for_each_boolean(i,tp)
- tp->Booleans[i] = FALSE;
+ for_each_boolean(i, tp)
+ tp->Booleans[i] = FALSE;
- for_each_number(i,tp)
- tp->Numbers[i] = ABSENT_NUMERIC;
+ for_each_number(i, tp)
+ tp->Numbers[i] = ABSENT_NUMERIC;
- for_each_string(i,tp)
- tp->Strings[i] = ABSENT_STRING;
+ for_each_string(i, tp)
+ tp->Strings[i] = ABSENT_STRING;
- next_free = 0;
+ next_free = 0;
}
-ENTRY *_nc_copy_entry(ENTRY *oldp)
+ENTRY *
+_nc_copy_entry(ENTRY * oldp)
{
- ENTRY *newp = typeCalloc(ENTRY,1);
+ ENTRY *newp = typeCalloc(ENTRY, 1);
- if (newp != 0) {
- *newp = *oldp;
- _nc_copy_termtype(&(newp->tterm), &(oldp->tterm));
- }
- return newp;
+ if (newp != 0) {
+ *newp = *oldp;
+ _nc_copy_termtype(&(newp->tterm), &(oldp->tterm));
+ }
+ return newp;
}
-char *_nc_save_str(const char *const string)
+char *
+_nc_save_str(const char *const string)
/* save a copy of string in the string buffer */
{
-size_t old_next_free = next_free;
-size_t len = strlen(string) + 1;
-
- if (next_free + len < MAX_STRTAB)
- {
- strcpy(&stringbuf[next_free], string);
- DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
- DEBUG(7, ("at location %d", (int) next_free));
- next_free += len;
- }
- return(stringbuf + old_next_free);
+ size_t old_next_free = next_free;
+ size_t len = strlen(string) + 1;
+
+ if (next_free + len < MAX_STRTAB) {
+ strcpy(&stringbuf[next_free], string);
+ DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
+ DEBUG(7, ("at location %d", (int) next_free));
+ next_free += len;
+ }
+ return (stringbuf + old_next_free);
}
-void _nc_wrap_entry(ENTRY *const ep)
+void
+_nc_wrap_entry(ENTRY * const ep)
/* copy the string parts to allocated storage, preserving pointers to it */
{
-int offsets[MAX_ENTRY_SIZE/2], useoffsets[MAX_USES];
-int i, n;
-TERMTYPE *tp = &(ep->tterm);
-
- n = tp->term_names - stringbuf;
- for_each_string(i, &(ep->tterm)) {
- if (tp->Strings[i] == ABSENT_STRING)
- offsets[i] = ABSENT_OFFSET;
- else if (tp->Strings[i] == CANCELLED_STRING)
- offsets[i] = CANCELLED_OFFSET;
- else
- offsets[i] = tp->Strings[i] - stringbuf;
- }
+ int offsets[MAX_ENTRY_SIZE / 2], useoffsets[MAX_USES];
+ int i, n;
+ TERMTYPE *tp = &(ep->tterm);
+
+ n = tp->term_names - stringbuf;
+ for_each_string(i, &(ep->tterm)) {
+ if (tp->Strings[i] == ABSENT_STRING)
+ offsets[i] = ABSENT_OFFSET;
+ else if (tp->Strings[i] == CANCELLED_STRING)
+ offsets[i] = CANCELLED_OFFSET;
+ else
+ offsets[i] = tp->Strings[i] - stringbuf;
+ }
- for (i=0; i < ep->nuses; i++) {
- if (ep->uses[i].parent == (void *)0)
- useoffsets[i] = ABSENT_OFFSET;
- else
- useoffsets[i] = (char *)(ep->uses[i].parent) - stringbuf;
- }
+ for (i = 0; i < ep->nuses; i++) {
+ if (ep->uses[i].name == 0)
+ useoffsets[i] = ABSENT_OFFSET;
+ else
+ useoffsets[i] = ep->uses[i].name - stringbuf;
+ }
- if ((tp->str_table = typeMalloc(char, next_free)) == (char *)0)
- _nc_err_abort("Out of memory");
- (void) memcpy(tp->str_table, stringbuf, next_free);
-
- tp->term_names = tp->str_table + n;
- for_each_string(i, &(ep->tterm)) {
- if (offsets[i] == ABSENT_OFFSET)
- tp->Strings[i] = ABSENT_STRING;
- else if (offsets[i] == CANCELLED_OFFSET)
- tp->Strings[i] = CANCELLED_STRING;
- else
- tp->Strings[i] = tp->str_table + offsets[i];
- }
+ if ((tp->str_table = typeMalloc(char, next_free)) == (char *) 0)
+ _nc_err_abort("Out of memory");
+ (void) memcpy(tp->str_table, stringbuf, next_free);
+
+ tp->term_names = tp->str_table + n;
+ for_each_string(i, &(ep->tterm)) {
+ if (offsets[i] == ABSENT_OFFSET)
+ tp->Strings[i] = ABSENT_STRING;
+ else if (offsets[i] == CANCELLED_OFFSET)
+ tp->Strings[i] = CANCELLED_STRING;
+ else
+ tp->Strings[i] = tp->str_table + offsets[i];
+ }
#if NCURSES_XNAMES
- if ((n = NUM_EXT_NAMES(tp)) != 0) {
- unsigned length = 0;
- for (i = 0; i < n; i++) {
- length += strlen(tp->ext_Names[i]) + 1;
- offsets[i] = tp->ext_Names[i] - stringbuf;
- }
- if ((tp->ext_str_table = typeMalloc(char, length)) == 0)
- _nc_err_abort("Out of memory");
- for (i = 0, length = 0; i < n; i++) {
- tp->ext_Names[i] = tp->ext_str_table + length;
- strcpy(tp->ext_Names[i], stringbuf + offsets[i]);
- length += strlen(tp->ext_Names[i]) + 1;
- }
+ if ((n = NUM_EXT_NAMES(tp)) != 0) {
+ unsigned length = 0;
+ for (i = 0; i < n; i++) {
+ length += strlen(tp->ext_Names[i]) + 1;
+ offsets[i] = tp->ext_Names[i] - stringbuf;
+ }
+ if ((tp->ext_str_table = typeMalloc(char, length)) == 0)
+ _nc_err_abort("Out of memory");
+ for (i = 0, length = 0; i < n; i++) {
+ tp->ext_Names[i] = tp->ext_str_table + length;
+ strcpy(tp->ext_Names[i], stringbuf + offsets[i]);
+ length += strlen(tp->ext_Names[i]) + 1;
}
+ }
#endif
- for (i=0; i < ep->nuses; i++) {
- if (useoffsets[i] == ABSENT_OFFSET)
- ep->uses[i].parent = (void *)0;
- else
- ep->uses[i].parent = (char *)(tp->str_table + useoffsets[i]);
- }
+ for (i = 0; i < ep->nuses; i++) {
+ if (useoffsets[i] == ABSENT_OFFSET)
+ ep->uses[i].name = 0;
+ else
+ ep->uses[i].name = (tp->str_table + useoffsets[i]);
+ }
}
-void _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
+void
+_nc_merge_entry(TERMTYPE * const to, TERMTYPE * const from)
/* merge capabilities from `from' entry into `to' entry */
{
- int i;
+ int i;
#if NCURSES_XNAMES
_nc_align_termtype(to, from);
#endif
- for_each_boolean(i, from)
- {
- int mergebool = from->Booleans[i];
+ for_each_boolean(i, from) {
+ int mergebool = from->Booleans[i];
if (mergebool == CANCELLED_BOOLEAN)
to->Booleans[i] = FALSE;
@@ -198,9 +200,8 @@ void _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
to->Booleans[i] = mergebool;
}
- for_each_number(i, from)
- {
- int mergenum = from->Numbers[i];
+ for_each_number(i, from) {
+ int mergenum = from->Numbers[i];
if (mergenum == CANCELLED_NUMERIC)
to->Numbers[i] = ABSENT_NUMERIC;
@@ -213,9 +214,8 @@ void _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
* storage. This is OK right now, but will be a problem if we
* we ever want to deallocate entries.
*/
- for_each_string(i, from)
- {
- char *mergestring = from->Strings[i];
+ for_each_string(i, from) {
+ char *mergestring = from->Strings[i];
if (mergestring == CANCELLED_STRING)
to->Strings[i] = ABSENT_STRING;
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
index a1bf9b0733f0..660381a32b5f 100644
--- a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/alloc_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 *
@@ -30,7 +30,6 @@
* Author: Thomas E. Dickey <dickey@clark.net> 1999 *
****************************************************************************/
-
/*
* align_ttype.c -- functions for TERMTYPE
*
@@ -44,14 +43,15 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: alloc_ttype.c,v 1.6 1999/03/01 22:10:44 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.8 2000/03/25 17:03:11 tom Exp $")
#if NCURSES_XNAMES
/*
* Merge the a/b lists into dst. Both a/b are sorted (see _nc_extend_names()),
* so we do not have to worry about order dependencies.
*/
-static int merge_names(char **dst, char **a, int na, char **b, int nb)
+static int
+merge_names(char **dst, char **a, int na, char **b, int nb)
{
int n = 0;
while (na && nb) {
@@ -78,7 +78,8 @@ static int merge_names(char **dst, char **a, int na, char **b, int nb)
return n;
}
-static bool find_name(char **table, int length, char *name)
+static bool
+find_name(char **table, int length, char *name)
{
while (length-- > 0) {
if (!strcmp(*table++, name)) {
@@ -90,7 +91,9 @@ static bool find_name(char **table, int length, char *name)
return FALSE;
}
-static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int ext_Numbers, int ext_Strings)
+static void
+realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
+ ext_Numbers, int ext_Strings)
{
int n, m, base;
int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
@@ -98,9 +101,9 @@ static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int e
if (to->ext_Booleans != ext_Booleans) {
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--) {
+ for (n = to->ext_Booleans - 1,
+ 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 {
@@ -112,24 +115,24 @@ static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int e
if (to->ext_Numbers != ext_Numbers) {
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--) {
- if (find_name(to->ext_Names, limit, ext_Names[m+ext_Booleans])) {
+ for (n = to->ext_Numbers - 1,
+ 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 {
to->Numbers[base + m] = ABSENT_NUMERIC;
}
}
- to->ext_Numbers = ext_Numbers;
+ to->ext_Numbers = ext_Numbers;
}
if (to->ext_Strings != ext_Strings) {
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--) {
- if (find_name(to->ext_Names, limit, ext_Names[m+ext_Booleans+ext_Numbers])) {
+ 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--) {
+ if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans + ext_Numbers])) {
to->Strings[base + m] = to->Strings[base + n--];
} else {
to->Strings[base + m] = ABSENT_STRING;
@@ -142,7 +145,8 @@ static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int e
/*
* Returns the first index in ext_Names[] for the given token-type
*/
-static int _nc_first_ext_name(TERMTYPE *tp, int token_type)
+static int
+_nc_first_ext_name(TERMTYPE * tp, int token_type)
{
int first;
@@ -166,20 +170,21 @@ static int _nc_first_ext_name(TERMTYPE *tp, int token_type)
/*
* Returns the last index in ext_Names[] for the given token-type
*/
-static int _nc_last_ext_name(TERMTYPE *tp, int token_type)
+static int
+_nc_last_ext_name(TERMTYPE * tp, int token_type)
{
int last;
switch (token_type) {
case BOOLEAN:
- last = tp->ext_Booleans;
+ last = tp->ext_Booleans;
break;
case NUMBER:
- last = tp->ext_Booleans + tp->ext_Numbers;
+ last = tp->ext_Booleans + tp->ext_Numbers;
break;
default:
case STRING:
- last = NUM_EXT_NAMES(tp);
+ last = NUM_EXT_NAMES(tp);
break;
}
return last;
@@ -188,11 +193,12 @@ static int _nc_last_ext_name(TERMTYPE *tp, int token_type)
/*
* Lookup an entry from extended-names, returning -1 if not found
*/
-static int _nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
+static int
+_nc_find_ext_name(TERMTYPE * tp, char *name, int token_type)
{
unsigned j;
unsigned first = _nc_first_ext_name(tp, token_type);
- unsigned last = _nc_last_ext_name(tp, token_type);
+ unsigned last = _nc_last_ext_name(tp, token_type);
for (j = first; j < last; j++) {
if (!strcmp(name, tp->ext_Names[j])) {
@@ -206,7 +212,8 @@ static int _nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
* Translate an index into ext_Names[] into the corresponding index into data
* (e.g., Booleans[]).
*/
-static int _nc_ext_data_index(TERMTYPE *tp, int n, int token_type)
+static int
+_nc_ext_data_index(TERMTYPE * tp, int n, int token_type)
{
switch (token_type) {
case BOOLEAN:
@@ -214,12 +221,12 @@ static int _nc_ext_data_index(TERMTYPE *tp, int n, int token_type)
break;
case NUMBER:
n += (tp->num_Numbers - tp->ext_Numbers)
- - (tp->ext_Booleans);
+ - (tp->ext_Booleans);
break;
default:
case STRING:
n += (tp->num_Strings - tp->ext_Strings)
- - (tp->ext_Booleans + tp->ext_Numbers);
+ - (tp->ext_Booleans + tp->ext_Numbers);
}
return n;
}
@@ -228,7 +235,8 @@ static int _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 _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
+static void
+_nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
{
int j;
int first, last;
@@ -236,28 +244,28 @@ static void _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
if ((first = _nc_find_ext_name(tp, name, token_type)) >= 0) {
last = NUM_EXT_NAMES(tp) - 1;
for (j = first; j < last; j++) {
- tp->ext_Names[j] = tp->ext_Names[j+1];
+ tp->ext_Names[j] = tp->ext_Names[j + 1];
}
first = _nc_ext_data_index(tp, first, token_type);
switch (token_type) {
case BOOLEAN:
last = tp->num_Booleans - 1;
for (j = first; j < last; j++)
- tp->Booleans[j] = tp->Booleans[j+1];
+ tp->Booleans[j] = tp->Booleans[j + 1];
tp->ext_Booleans -= 1;
tp->num_Booleans -= 1;
break;
case NUMBER:
last = tp->num_Numbers - 1;
for (j = first; j < last; j++)
- tp->Numbers[j] = tp->Numbers[j+1];
+ tp->Numbers[j] = tp->Numbers[j + 1];
tp->ext_Numbers -= 1;
tp->num_Numbers -= 1;
break;
case STRING:
last = tp->num_Strings - 1;
for (j = first; j < last; j++)
- tp->Strings[j] = tp->Strings[j+1];
+ tp->Strings[j] = tp->Strings[j + 1];
tp->ext_Strings -= 1;
tp->num_Strings -= 1;
break;
@@ -269,10 +277,11 @@ static void _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
* Adjust tables to insert an extended name, making room for new data. The
* index into the corresponding data array is returned.
*/
-static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
+static int
+_nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
{
unsigned first = _nc_first_ext_name(tp, token_type);
- unsigned last = _nc_last_ext_name(tp, token_type);
+ unsigned last = _nc_last_ext_name(tp, token_type);
unsigned total = NUM_EXT_NAMES(tp) + 1;
unsigned j, k;
@@ -287,8 +296,8 @@ static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
}
tp->ext_Names = typeRealloc(char *, total, tp->ext_Names);
- for (k = total-1; k > j; k--)
- tp->ext_Names[k] = tp->ext_Names[k-1];
+ for (k = total - 1; k > j; k--)
+ tp->ext_Names[k] = tp->ext_Names[k - 1];
tp->ext_Names[j] = name;
j = _nc_ext_data_index(tp, j, token_type);
@@ -297,22 +306,22 @@ static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
tp->ext_Booleans += 1;
tp->num_Booleans += 1;
tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
- for (k = tp->num_Booleans-1; k > j; k--)
- tp->Booleans[k] = tp->Booleans[k-1];
+ for (k = tp->num_Booleans - 1; k > j; k--)
+ tp->Booleans[k] = tp->Booleans[k - 1];
break;
case NUMBER:
tp->ext_Numbers += 1;
tp->num_Numbers += 1;
tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
- for (k = tp->num_Numbers-1; k > j; k--)
- tp->Numbers[k] = tp->Numbers[k-1];
+ for (k = tp->num_Numbers - 1; k > j; k--)
+ tp->Numbers[k] = tp->Numbers[k - 1];
break;
case STRING:
tp->ext_Strings += 1;
tp->num_Strings += 1;
tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
- for (k = tp->num_Strings-1; k > j; k--)
- tp->Strings[k] = tp->Strings[k-1];
+ for (k = tp->num_Strings - 1; k > j; k--)
+ tp->Strings[k] = tp->Strings[k - 1];
break;
}
return j;
@@ -323,13 +332,14 @@ static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
* as a boolean or number. We'll get this as a special case when we get a
* cancellation of a name that is inherited from another entry.
*/
-static void adjust_cancels(TERMTYPE *to, TERMTYPE *from)
+static void
+adjust_cancels(TERMTYPE * to, TERMTYPE * from)
{
int first = to->ext_Booleans + to->ext_Numbers;
- int last = first + to->ext_Strings;
+ int last = first + to->ext_Strings;
int j, k;
- for (j = first; j < last; ) {
+ for (j = first; j < last;) {
char *name = to->ext_Names[j];
unsigned j_str = to->num_Strings - first - to->ext_Strings;
@@ -338,7 +348,8 @@ static void adjust_cancels(TERMTYPE *to, TERMTYPE *from)
_nc_del_ext_name(to, name, STRING);
k = _nc_ins_ext_name(to, name, BOOLEAN);
to->Booleans[k] = FALSE;
- } else if ((k = _nc_find_ext_name(from, to->ext_Names[j], NUMBER)) >= 0) {
+ } 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;
@@ -349,7 +360,8 @@ static void adjust_cancels(TERMTYPE *to, TERMTYPE *from)
}
}
-void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
+void
+_nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
{
int na = NUM_EXT_NAMES(to);
int nb = NUM_EXT_NAMES(from);
@@ -358,13 +370,14 @@ void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
char **ext_Names;
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));
+ DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names,
+ nb, from->term_names));
if (na != 0 || nb != 0) {
if ((na == nb) /* check if the arrays are equivalent */
- && (to->ext_Booleans == from->ext_Booleans)
- && (to->ext_Numbers == from->ext_Numbers)
- && (to->ext_Strings == from->ext_Strings)) {
+ &&(to->ext_Booleans == from->ext_Booleans)
+ && (to->ext_Numbers == from->ext_Numbers)
+ && (to->ext_Strings == from->ext_Strings)) {
for (n = 0, same = TRUE; n < na; n++) {
if (strcmp(to->ext_Names[n], from->ext_Names[n])) {
same = FALSE;
@@ -380,7 +393,7 @@ void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
* into it, updating to's counts for booleans, etc. Fortunately we do
* this only for the terminfo compiler (tic) and comparer (infocmp).
*/
- ext_Names = typeMalloc(char *, na+nb);
+ ext_Names = typeMalloc(char *, na + nb);
if (to->ext_Strings && (from->ext_Booleans + from->ext_Numbers))
adjust_cancels(to, from);
@@ -389,62 +402,65 @@ void _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);
- 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);
- 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,
+ 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);
+ 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);
/*
* Now we must reallocate the Booleans, etc., to allow the data to be
* overlaid.
*/
if (na != (ext_Booleans + ext_Numbers + ext_Strings)) {
realign_data(to, ext_Names, ext_Booleans, ext_Numbers, ext_Strings);
- free(to->ext_Names);
+ 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));
+ DEBUG(2, ("realigned %d extended names for '%s' (to)",
+ NUM_EXT_NAMES(to), to->term_names));
}
if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) {
nb = (ext_Booleans + ext_Numbers + ext_Strings);
realign_data(from, ext_Names, ext_Booleans, ext_Numbers, ext_Strings);
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));
+ DEBUG(2, ("realigned %d extended names for '%s' (from)",
+ NUM_EXT_NAMES(from), from->term_names));
}
}
}
#endif
-void _nc_copy_termtype(TERMTYPE *dst, TERMTYPE *src)
+void
+_nc_copy_termtype(TERMTYPE * dst, TERMTYPE * src)
{
int i;
- *dst = *src; /* ...to copy the sizes and string-tables */
- dst->Booleans = typeMalloc(char, NUM_BOOLEANS(dst));
- dst->Numbers = typeMalloc(short, NUM_NUMBERS(dst));
- dst->Strings = typeMalloc(char *, NUM_STRINGS(dst));
+ *dst = *src; /* ...to copy the sizes and string-tables */
+ dst->Booleans = typeMalloc(char, NUM_BOOLEANS(dst));
+ dst->Numbers = typeMalloc(short, NUM_NUMBERS(dst));
+ dst->Strings = typeMalloc(char *, NUM_STRINGS(dst));
/* FIXME: use memcpy for these and similar loops */
- for_each_boolean(i,dst)
+ for_each_boolean(i, dst)
dst->Booleans[i] = src->Booleans[i];
- for_each_number(i,dst)
+ for_each_number(i, dst)
dst->Numbers[i] = src->Numbers[i];
- for_each_string(i,dst)
+ for_each_string(i, dst)
dst->Strings[i] = src->Strings[i];
/* FIXME: we probably should also copy str_table and ext_str_table,
@@ -455,6 +471,8 @@ void _nc_copy_termtype(TERMTYPE *dst, TERMTYPE *src)
if ((i = NUM_EXT_NAMES(src)) != 0) {
dst->ext_Names = typeMalloc(char *, i);
memcpy(dst->ext_Names, src->ext_Names, i * sizeof(char *));
+ } else {
+ dst->ext_Names = 0;
}
#endif
diff --git a/contrib/ncurses/ncurses/tinfo/captoinfo.c b/contrib/ncurses/ncurses/tinfo/captoinfo.c
index d0881ecd4792..da1382683942 100644
--- a/contrib/ncurses/ncurses/tinfo/captoinfo.c
+++ b/contrib/ncurses/ncurses/tinfo/captoinfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* captoinfo.c --- conversion between termcap and terminfo formats
*
@@ -94,10 +92,9 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: captoinfo.c,v 1.24 1999/07/24 20:06:13 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.37 2000/04/01 20:07:34 tom Exp $")
#define MAX_PUSHED 16 /* max # args we can push onto the stack */
-#define MAX_ENTRY 2048 /* maximum chars in a translated capability */
static int stack[MAX_PUSHED]; /* the stack */
static int stackptr; /* the next empty place on the stack */
@@ -108,43 +105,47 @@ static int seenr; /* seen a %r */
static int param; /* current parameter */
static char *dp; /* pointer to end of the converted string */
-static char *my_string;
+static char *my_string;
static size_t my_length;
-static char *init_string(void)
+static char *
+init_string(void)
/* initialize 'my_string', 'my_length' */
{
- if (my_string == 0)
- my_string = typeMalloc(char, my_length = 256);
- if (my_string == 0)
- _nc_err_abort("Out of memory");
+ if (my_string == 0)
+ my_string = typeMalloc(char, my_length = 256);
+ if (my_string == 0)
+ _nc_err_abort("Out of memory");
- *my_string = '\0';
- return my_string;
+ *my_string = '\0';
+ return my_string;
}
-static char *save_string(char *d, const char *const s)
+static char *
+save_string(char *d, const char *const s)
{
- size_t have = (d - my_string);
- size_t need = have + strlen(s) + 2;
- if (need > my_length) {
- my_string = (char *)realloc(my_string, my_length = (need + need));
- if (my_string == 0)
- _nc_err_abort("Out of memory");
- d = my_string + have;
- }
- (void) strcpy(d, s);
- return d + strlen(d);
+ size_t have = (d - my_string);
+ size_t need = have + strlen(s) + 2;
+ if (need > my_length) {
+ my_string = (char *) realloc(my_string, my_length = (need + need));
+ if (my_string == 0)
+ _nc_err_abort("Out of memory");
+ d = my_string + have;
+ }
+ (void) strcpy(d, s);
+ return d + strlen(d);
}
-static inline char *save_char(char *s, char c)
+static inline char *
+save_char(char *s, char c)
{
- static char temp[2];
- temp[0] = c;
- return save_string(s, temp);
+ static char temp[2];
+ temp[0] = c;
+ return save_string(s, temp);
}
-static void push(void)
+static void
+push(void)
/* push onstack on to the stack */
{
if (stackptr > MAX_PUSHED)
@@ -153,7 +154,8 @@ static void push(void)
stack[stackptr++] = onstack;
}
-static void pop(void)
+static void
+pop(void)
/* pop the top of the stack into onstack */
{
if (stackptr == 0) {
@@ -161,21 +163,21 @@ static void pop(void)
_nc_warning("I'm confused");
else
onstack = 0;
- }
- else
+ } else
onstack = stack[--stackptr];
param++;
}
-static int cvtchar(register const char *sp)
+static int
+cvtchar(register const char *sp)
/* convert a character to a terminfo push */
{
unsigned char c = 0;
int len;
- switch(*sp) {
+ switch (*sp) {
case '\\':
- switch(*++sp) {
+ switch (*++sp) {
case '\'':
case '$':
case '\\':
@@ -192,8 +194,7 @@ static int cvtchar(register const char *sp)
case '2':
case '3':
len = 1;
- while (isdigit(*sp))
- {
+ while (isdigit(*sp)) {
c = 8 * c + (*sp++ - '0');
len++;
}
@@ -213,65 +214,68 @@ static int cvtchar(register const char *sp)
len = 1;
}
if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') {
- *dp++ = '%'; *dp++ = '\''; *dp++ = c; *dp++ = '\'';
+ dp = save_string(dp, "%\'");
+ dp = save_char(dp, c);
+ dp = save_char(dp, '\'');
} else {
- *dp++ = '%'; *dp++ = '{';
+ dp = save_string(dp, "%{");
if (c > 99)
- *dp++ = c / 100 + '0';
+ dp = save_char(dp, c / 100 + '0');
if (c > 9)
- *dp++ = ((int)(c / 10)) % 10 + '0';
- *dp++ = c % 10 + '0';
- *dp++ = '}';
+ dp = save_char(dp, ((int) (c / 10)) % 10 + '0');
+ dp = save_char(dp, c % 10 + '0');
+ dp = save_char(dp, '}');
}
return len;
}
-static void getparm(int parm, int n)
+static void
+getparm(int parm, int n)
/* push n copies of param on the terminfo stack if not already there */
{
- if (seenr) {
- if (parm == 1)
- parm = 2;
- else if (parm == 2)
- parm = 1;
- }
- if (onstack == parm) {
- if (n > 1) {
- _nc_warning("string may not be optimal");
- *dp++ = '%'; *dp++ = 'P'; *dp++ = 'a';
- while(n--) {
- *dp++ = '%'; *dp++ = 'g'; *dp++ = 'a';
- }
- }
- return;
+ if (seenr) {
+ if (parm == 1)
+ parm = 2;
+ else if (parm == 2)
+ parm = 1;
+ }
+ if (onstack == parm) {
+ if (n > 1) {
+ _nc_warning("string may not be optimal");
+ dp = save_string(dp, "%Pa");
+ while (n--) {
+ dp = save_string(dp, "%ga");
+ }
}
- if (onstack != 0)
- push();
+ return;
+ }
+ if (onstack != 0)
+ push();
- onstack = parm;
+ onstack = parm;
- while(n--) { /* %p0 */
- *dp++ = '%'; *dp++ = 'p'; *dp++ = '0' + parm;
- }
+ while (n--) {
+ dp = save_string(dp, "%p");
+ dp = save_char(dp, '0' + parm);
+ }
- if (seenn && parm < 3) { /* %{96}%^ */
- *dp++ = '%'; *dp++ = '{'; *dp++ = '9'; *dp++ = '6'; *dp++ = '}';
- *dp++ = '%'; *dp++ = '^';
- }
+ if (seenn && parm < 3) {
+ dp = save_string(dp, "%{96}%^");
+ }
- if (seenm && parm < 3) { /* %{127}%^ */
- *dp++ = '%'; *dp++ = '{'; *dp++ = '1'; *dp++ = '2'; *dp++ = '7';
- *dp++ = '}'; *dp++ = '%'; *dp++ = '^';
- }
+ if (seenm && parm < 3) {
+ dp = save_string(dp, "%{127}%^");
+ }
}
-char *_nc_captoinfo(
+char *
+_nc_captoinfo(
/* convert a termcap string to terminfo format */
-register const char *cap, /* relevant terminfo capability index */
-register const char *s, /* string value of the capability */
-int const parametrized) /* do % translations if 1, pad translations if >=0 */
+ register const char *cap, /* relevant terminfo capability index */
+ register const char *s, /* string value of the capability */
+ int const parametrized /* do % translations if 1, pad translations if >=0 */
+)
{
- static char line[MAX_ENTRY];
const char *capstart;
stackptr = 0;
@@ -281,27 +285,29 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
seenr = 0;
param = 1;
- dp = line;
+ dp = init_string();
/* skip the initial padding (if we haven't been told not to) */
capstart = 0;
if (s == 0)
s = "";
if (parametrized >= 0 && isdigit(*s))
- for (capstart = s; ; s++)
+ for (capstart = s;; s++)
if (!(isdigit(*s) || *s == '*' || *s == '.'))
break;
- while(*s != '\0') {
- switch(*s) {
+ while (*s != '\0') {
+ switch (*s) {
case '%':
s++;
if (parametrized < 1) {
- *dp++ = '%';
+ dp = save_char(dp, '%');
break;
}
- switch(*s++) {
- case '%': *dp++ = '%'; break;
+ switch (*s++) {
+ case '%':
+ dp = save_char(dp, '%');
+ break;
case 'r':
if (seenr++ == 1) {
_nc_warning("saw %%r twice in %s", cap);
@@ -317,37 +323,33 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
_nc_warning("saw %%n twice in %s", cap);
}
break;
- case 'i': *dp++ = '%'; *dp++ = 'i'; break;
+ case 'i':
+ dp = save_string(dp, "%i");
+ break;
case '6':
case 'B':
- getparm(param, 2);
- /* %{6}%*%+ */
- *dp++ = '%'; *dp++ = '{'; *dp++ = '6';
- *dp++ = '}'; *dp++ = '%'; *dp++ = '*';
- *dp++ = '%'; *dp++ = '+';
+ getparm(param, 1);
+ dp = save_string(dp, "%{10}%/%{16}%*");
+ getparm(param, 1);
+ dp = save_string(dp, "%{10}%m%+");
break;
case '8':
case 'D':
getparm(param, 2);
- /* %{2}%*%- */
- *dp++ = '%'; *dp++ = '{'; *dp++ = '2';
- *dp++ = '}'; *dp++ = '%'; *dp++ = '*';
- *dp++ = '%'; *dp++ = '-';
+ dp = save_string(dp, "%{2}%*%-");
break;
case '>':
getparm(param, 2);
/* %?%{x}%>%t%{y}%+%; */
- *dp++ = '%'; *dp++ = '?';
+ dp = save_string(dp, "%?");
s += cvtchar(s);
- *dp++ = '%'; *dp++ = '>';
- *dp++ = '%'; *dp++ = 't';
+ dp = save_string(dp, "%>%t");
s += cvtchar(s);
- *dp++ = '%'; *dp++ = '+';
- *dp++ = '%'; *dp++ = ';';
+ dp = save_string(dp, "%+%;");
break;
case 'a':
if ((*s == '=' || *s == '+' || *s == '-'
- || *s == '*' || *s == '/')
+ || *s == '*' || *s == '/')
&& (s[1] == 'p' || s[1] == 'c')
&& s[2] != '\0') {
int l;
@@ -363,18 +365,18 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
l++;
} else
l += cvtchar(s + 2);
- switch(*s) {
+ switch (*s) {
case '+':
- *dp++ = '%'; *dp++ = '+';
+ dp = save_string(dp, "%+");
break;
case '-':
- *dp++ = '%'; *dp++ = '-';
+ dp = save_string(dp, "%-");
break;
case '*':
- *dp++ = '%'; *dp++ = '*';
+ dp = save_string(dp, "%*");
break;
case '/':
- *dp++ = '%'; *dp++ = '/';
+ dp = save_string(dp, "%/");
break;
case '=':
if (seenr) {
@@ -384,8 +386,7 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
onstack = 1;
else
onstack = param;
- }
- else
+ } else
onstack = param;
break;
}
@@ -394,39 +395,37 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
}
getparm(param, 1);
s += cvtchar(s);
- *dp++ = '%'; *dp++ = '+';
+ dp = save_string(dp, "%+");
break;
case '+':
getparm(param, 1);
s += cvtchar(s);
- *dp++ = '%'; *dp++ = '+';
- *dp++ = '%'; *dp++ = 'c';
+ dp = save_string(dp, "%+%c");
pop();
break;
case 's':
#ifdef WATERLOO
s += cvtchar(s);
getparm(param, 1);
- *dp++ = '%'; *dp++ = '-';
+ dp = save_string(dp, "%-");
#else
getparm(param, 1);
- *dp++ = '%'; *dp++ = 's';
+ dp = save_string(dp, "%s");
pop();
#endif /* WATERLOO */
break;
case '-':
s += cvtchar(s);
getparm(param, 1);
- *dp++ = '%'; *dp++ = '-';
- *dp++ = '%'; *dp++ = 'c';
+ dp = save_string(dp, "%-%c");
pop();
break;
case '.':
getparm(param, 1);
- *dp++ = '%'; *dp++ = 'c';
+ dp = save_string(dp, "%c");
pop();
break;
- case '0': /* not clear any of the historical termcaps did this */
+ case '0': /* not clear any of the historical termcaps did this */
if (*s == '3')
goto see03;
else if (*s != '2')
@@ -434,19 +433,18 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
/* FALLTHRU */
case '2':
getparm(param, 1);
- *dp++ = '%'; /* *dp++ = '0'; */
- *dp++ = '2'; *dp++ = 'd';
+ dp = save_string(dp, "%2d");
pop();
break;
- case '3': see03:
+ case '3':
+ see03:
getparm(param, 1);
- *dp++ = '%'; /* *dp++ = '0'; */
- *dp++ = '3'; *dp++ = 'd';
+ dp = save_string(dp, "%3d");
pop();
break;
case 'd':
getparm(param, 1);
- *dp++ = '%'; *dp++ = 'd';
+ dp = save_string(dp, "%d");
pop();
break;
case 'f':
@@ -456,61 +454,82 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
param--;
break;
case '\\':
- *dp++ = '%';
- *dp++ = '\\';
+ dp = save_string(dp, "%\\");
break;
- default: invalid:
- *dp++ = '%';
+ default:
+ invalid:
+ dp = save_char(dp, '%');
s--;
- _nc_warning("unknown %% code %s in %s",
- _tracechar(*s), cap);
+ _nc_warning("unknown %% code %s (%#x) in %s",
+ unctrl(*s), (*s) & 0xff, cap);
break;
}
break;
#ifdef REVISIBILIZE
case '\\':
- *dp++ = *s++; *dp++ = *s++; break;
+ dp = save_char(dp, *s++);
+ dp = save_char(dp, *s++);
+ break;
case '\n':
- *dp++ = '\\'; *dp++ = 'n'; s++; break;
+ dp = save_string(dp, "\\n");
+ s++;
+ break;
case '\t':
- *dp++ = '\\'; *dp++ = 't'; s++; break;
+ dp = save_string(dp, "\\t");
+ s++;
+ break;
case '\r':
- *dp++ = '\\'; *dp++ = 'r'; s++; break;
+ dp = save_string(dp, "\\r");
+ s++;
+ break;
case '\200':
- *dp++ = '\\'; *dp++ = '0'; s++; break;
+ dp = save_string(dp, "\\0");
+ s++;
+ break;
case '\f':
- *dp++ = '\\'; *dp++ = 'f'; s++; break;
+ dp = save_string(dp, "\\f");
+ s++;
+ break;
case '\b':
- *dp++ = '\\'; *dp++ = 'b'; s++; break;
+ dp = save_string(dp, "\\b");
+ s++;
+ break;
case ' ':
- *dp++ = '\\'; *dp++ = 's'; s++; break;
+ dp = save_string(dp, "\\s");
+ s++;
+ break;
case '^':
- *dp++ = '\\'; *dp++ = '^'; s++; break;
+ dp = save_string(dp, "\\^");
+ s++;
+ break;
case ':':
- *dp++ = '\\'; *dp++ = ':'; s++; break;
+ dp = save_string(dp, "\\:");
+ s++;
+ break;
case ',':
- *dp++ = '\\'; *dp++ = ','; s++; break;
+ dp = save_string(dp, "\\,");
+ s++;
+ break;
default:
if (*s == '\033') {
- *dp++ = '\\';
- *dp++ = 'E';
+ dp = save_string(dp, "\\E");
s++;
} else if (*s > 0 && *s < 32) {
- *dp++ = '^';
- *dp++ = *s + '@';
+ dp = save_char(dp, '^');
+ dp = save_char(dp, *s + '@');
s++;
} else if (*s <= 0 || *s >= 127) {
- *dp++ = '\\';
- *dp++ = ((*s & 0300) >> 6) + '0';
- *dp++ = ((*s & 0070) >> 3) + '0';
- *dp++ = (*s & 0007) + '0';
+ dp = save_char(dp, '\\');
+ dp = save_char(dp, ((*s & 0300) >> 6) + '0');
+ dp = save_char(dp, ((*s & 0070) >> 3) + '0');
+ dp = save_char(dp, (*s & 0007) + '0');
s++;
} else
- *dp++ = *s++;
+ dp = save_char(dp, *s++);
break;
#else
default:
- *dp++ = *s++;
+ dp = save_char(dp, *s++);
break;
#endif
}
@@ -520,21 +539,76 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
* Now, if we stripped off some leading padding, add it at the end
* of the string as mandatory padding.
*/
- if (capstart)
- {
- *dp++ = '$';
- *dp++ = '<';
- for (s = capstart; ; s++)
+ if (capstart) {
+ dp = save_string(dp, "$<");
+ for (s = capstart;; s++)
if (isdigit(*s) || *s == '*' || *s == '.')
- *dp++ = *s;
+ dp = save_char(dp, *s);
else
break;
- *dp++ = '/';
- *dp++ = '>';
+ dp = save_string(dp, "/>");
+ }
+
+ (void) save_char(dp, '\0');
+ return (my_string);
+}
+
+/*
+ * Check for an expression that corresponds to "%B" (BCD):
+ * (parameter / 10) * 16 + (parameter % 10)
+ */
+static int
+bcd_expression(const char *str)
+{
+ /* leave this non-const for HPUX */
+ static char fmt[] = "%%p%c%%{10}%%/%%{16}%%*%%p%c%%{10}%%m%%+";
+ int len = 0;
+ char ch1, ch2;
+
+ if (sscanf(str, fmt, &ch1, &ch2) == 2
+ && isdigit(ch1)
+ && isdigit(ch2)
+ && (ch1 == ch2)) {
+ len = 28;
+#ifndef NDEBUG
+ {
+ char buffer[80];
+ int tst;
+ sprintf(buffer, fmt, ch1, ch2);
+ tst = strlen(buffer) - 1;
+ assert(len == tst);
+ }
+#endif
}
+ return len;
+}
+
+static char *
+save_tc_char(char *bufptr, int c1)
+{
+ char temp[80];
- *dp = '\0';
- return(line);
+ if (is7bits(c1) && isprint(c1)) {
+ if (c1 == ':' || c1 == '\\')
+ bufptr = save_char(bufptr, '\\');
+ bufptr = save_char(bufptr, c1);
+ } else {
+ if (c1 == (c1 & 0x1f)) /* iscntrl() returns T on 255 */
+ (void) strcpy(temp, unctrl(c1));
+ else
+ (void) sprintf(temp, "\\%03o", c1);
+ bufptr = save_string(bufptr, temp);
+ }
+ return bufptr;
+}
+
+static char *
+save_tc_inequality(char *bufptr, int c1, int c2)
+{
+ bufptr = save_string(bufptr, "%>");
+ bufptr = save_tc_char(bufptr, c1);
+ bufptr = save_tc_char(bufptr, c2);
+ return bufptr;
}
/*
@@ -555,23 +629,25 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
* %m exclusive-or all parameters with 0177 (not in 4.4BSD)
*/
-char *_nc_infotocap(
+char *
+_nc_infotocap(
/* convert a terminfo string to termcap format */
-register const char *cap GCC_UNUSED, /* relevant termcap capability index */
-register const char *str, /* string value of the capability */
-int const parametrized) /* do % translations if 1, pad translations if >=0 */
+ register const char *cap GCC_UNUSED, /* relevant termcap capability index */
+ register const char *str, /* string value of the capability */
+ int const parametrized /* do % translations if 1, pad translations if >=0 */
+)
{
- int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
+ int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
const char *padding;
const char *trimmed = 0;
char ch1 = 0, ch2 = 0;
char *bufptr = init_string();
- char temp[256];
+ int len;
+ bool syntax_error = FALSE;
/* we may have to move some trailing mandatory padding up front */
padding = str + strlen(str) - 1;
- if (*padding == '>' && *--padding == '/')
- {
+ if (*padding == '>' && *--padding == '/') {
--padding;
while (isdigit(*padding) || *padding == '.' || *padding == '*')
padding--;
@@ -583,101 +659,62 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
bufptr = save_char(bufptr, *padding++);
}
- for (; *str && str != trimmed; str++)
- {
- int c1, c2;
- char *cp = 0;
+ for (; *str && str != trimmed; str++) {
+ int c1, c2;
+ char *cp = 0;
- if (str[0] == '\\' && (str[1] == '^' || str[1] == ','))
- {
+ if (str[0] == '\\' && (str[1] == '^' || str[1] == ',')) {
bufptr = save_char(bufptr, *++str);
- }
- else if (str[0] == '$' && str[1] == '<') /* discard padding */
- {
+ } else if (str[0] == '$' && str[1] == '<') { /* discard padding */
str += 2;
- while (isdigit(*str) || *str == '.' || *str == '*' || *str == '/' || *str == '>')
+ while (isdigit(*str) || *str == '.' || *str == '*' || *str ==
+ '/' || *str == '>')
str++;
--str;
- }
- else if (*str != '%' || (parametrized < 1))
+ } else if (str[0] == '%' && str[1] == '%') { /* escaped '%' */
+ bufptr = save_string(bufptr, "%%");
+ } else if (*str != '%' || (parametrized < 1)) {
bufptr = save_char(bufptr, *str);
- else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1,&c2) == 2)
- {
+ } else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1, &c2) == 2) {
str = strchr(str, ';');
- (void) sprintf(temp, "%%>%s%s", unctrl(c1), unctrl(c2));
- bufptr = save_string(bufptr, temp);
- }
- else if (sscanf(str, "%%?%%{%d}%%>%%t%%'%c'%%+%%;", &c1,&ch2) == 2)
- {
+ bufptr = save_tc_inequality(bufptr, c1, c2);
+ } else if (sscanf(str, "%%?%%{%d}%%>%%t%%'%c'%%+%%;", &c1, &ch2) == 2) {
str = strchr(str, ';');
- (void) sprintf(temp, "%%>%s%c", unctrl(c1), ch2);
- bufptr = save_string(bufptr, temp);
- }
- else if (sscanf(str, "%%?%%'%c'%%>%%t%%{%d}%%+%%;", &ch1,&c2) == 2)
- {
+ bufptr = save_tc_inequality(bufptr, c1, c2);
+ } else if (sscanf(str, "%%?%%'%c'%%>%%t%%{%d}%%+%%;", &ch1, &c2) == 2) {
str = strchr(str, ';');
- (void) sprintf(temp, "%%>%c%c", ch1, c2);
- bufptr = save_string(bufptr, temp);
- }
- else if (sscanf(str, "%%?%%'%c'%%>%%t%%'%c'%%+%%;", &ch1, &ch2) == 2)
- {
+ bufptr = save_tc_inequality(bufptr, c1, c2);
+ } else if (sscanf(str, "%%?%%'%c'%%>%%t%%'%c'%%+%%;", &ch1, &ch2) == 2) {
str = strchr(str, ';');
- (void) sprintf(temp, "%%>%c%c", ch1, ch2);
- bufptr = save_string(bufptr, temp);
- }
- else if (strncmp(str, "%{6}%*%+", 8) == 0)
- {
- str += 7;
- (void) sprintf(temp, "%%B");
- bufptr = save_string(bufptr, temp);
- }
- else if ((sscanf(str, "%%{%d}%%+%%c", &c1) == 1
- || sscanf(str, "%%'%c'%%+%%c", &ch1) == 1)
- && (cp = strchr(str, '+')))
- {
+ bufptr = save_tc_inequality(bufptr, c1, c2);
+ } else if ((len = bcd_expression(str)) != 0) {
+ str += len;
+ bufptr = save_string(bufptr, "%B");
+ } else if ((sscanf(str, "%%{%d}%%+%%c", &c1) == 1
+ || sscanf(str, "%%'%c'%%+%%c", &ch1) == 1)
+ && (cp = strchr(str, '+'))) {
str = cp + 2;
- bufptr = save_char(bufptr, '%');
- bufptr = save_char(bufptr, '+');
+ bufptr = save_string(bufptr, "%+");
if (ch1)
c1 = ch1;
- if (is7bits(c1) && isprint(c1))
- bufptr = save_char(bufptr, (char)c1);
- else
- {
- if (c1 == (c1 & 0x1f)) /* iscntrl() returns T on 255 */
- (void) strcpy(temp, unctrl(c1));
- else
- (void) sprintf(temp, "\\%03o", c1);
- bufptr = save_string(bufptr, temp);
- }
+ bufptr = save_tc_char(bufptr, c1);
}
- else if (strncmp(str, "%{2}%*%-", 8) == 0)
- {
+ /* FIXME: this "works" for 'delta' */
+ else if (strncmp(str, "%{2}%*%-", 8) == 0) {
str += 7;
- (void) sprintf(temp, "%%D");
- bufptr = save_string(bufptr, temp);
- }
- else if (strncmp(str, "%{96}%^", 7) == 0)
- {
+ bufptr = save_string(bufptr, "%D");
+ } else if (strncmp(str, "%{96}%^", 7) == 0) {
str += 6;
- if (saw_m++ == 0)
- {
- (void) sprintf(temp, "%%n");
- bufptr = save_string(bufptr, temp);
+ if (saw_m++ == 0) {
+ bufptr = save_string(bufptr, "%n");
}
- }
- else if (strncmp(str, "%{127}%^", 8) == 0)
- {
+ } else if (strncmp(str, "%{127}%^", 8) == 0) {
str += 7;
- if (saw_n++ == 0)
- {
- (void) sprintf(temp, "%%m");
- bufptr = save_string(bufptr, temp);
+ if (saw_n++ == 0) {
+ bufptr = save_string(bufptr, "%m");
}
- }
- else
- {
+ } else { /* cm-style format element */
str++;
switch (*str) {
case '%':
@@ -697,90 +734,80 @@ int const parametrized) /* do % translations if 1, pad translations if >=0 */
bufptr = save_char(bufptr, '%');
while (isdigit(*str))
bufptr = save_char(bufptr, *str++);
- if (*str == 'd')
- str++;
- else
- _nc_warning("numeric prefix is missing trailing d in %s",
- cap);
- --str;
+ if (strchr("doxX.", *str)) {
+ if (*str != 'd') /* termcap doesn't have octal, hex */
+ return 0;
+ }
break;
case 'd':
- bufptr = save_char(bufptr, '%');
- bufptr = save_char(bufptr, 'd');
+ bufptr = save_string(bufptr, "%d");
break;
case 'c':
- bufptr = save_char(bufptr, '%');
- bufptr = save_char(bufptr, '.');
+ bufptr = save_string(bufptr, "%.");
break;
- /*
- * %s isn't in termcap, but it's convenient to pass it through
- * so we can represent things like terminfo pfkey strings in
- * termcap notation.
- */
+ /*
+ * %s isn't in termcap, but it's convenient to pass it through
+ * so we can represent things like terminfo pfkey strings in
+ * termcap notation.
+ */
case 's':
- bufptr = save_char(bufptr, '%');
- bufptr = save_char(bufptr, 's');
+ bufptr = save_string(bufptr, "%s");
break;
case 'p':
str++;
if (*str == '1')
seenone = 1;
- else if (*str == '2')
- {
- if (!seenone && !seentwo)
- {
- bufptr = save_char(bufptr, '%');
- bufptr = save_char(bufptr, 'r');
+ else if (*str == '2') {
+ if (!seenone && !seentwo) {
+ bufptr = save_string(bufptr, "%r");
seentwo++;
}
- }
- else if (*str >= '3')
- return(0);
+ } else if (*str >= '3')
+ return (0);
break;
case 'i':
- bufptr = save_char(bufptr, '%');
- bufptr = save_char(bufptr, 'i');
+ bufptr = save_string(bufptr, "%i");
break;
default:
- return(0);
-
- } /* endswitch (*str) */
- } /* endelse (*str == '%') */
+ bufptr = save_char(bufptr, *str);
+ syntax_error = TRUE;
+ break;
+ } /* endswitch (*str) */
+ } /* endelse (*str == '%') */
if (*str == '\0')
break;
- } /* endwhile (*str) */
+ } /* endwhile (*str) */
- return(my_string);
+ return (syntax_error ? NULL : my_string);
}
#ifdef MAIN
int curr_line;
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
int c, tc = FALSE;
while ((c = getopt(argc, argv, "c")) != EOF)
- switch (c)
- {
+ switch (c) {
case 'c':
tc = TRUE;
break;
}
curr_line = 0;
- for (;;)
- {
- char buf[BUFSIZ];
+ for (;;) {
+ char buf[BUFSIZ];
++curr_line;
if (fgets(buf, sizeof(buf), stdin) == 0)
@@ -788,20 +815,17 @@ int main(int argc, char *argv[])
buf[strlen(buf) - 1] = '\0';
_nc_set_source(buf);
- if (tc)
- {
- char *cp = _nc_infotocap("to termcap", buf, 1);
+ if (tc) {
+ char *cp = _nc_infotocap("to termcap", buf, 1);
if (cp)
(void) fputs(cp, stdout);
- }
- else
+ } else
(void) fputs(_nc_captoinfo("to terminfo", buf, 1), stdout);
(void) putchar('\n');
}
- return(0);
+ return (0);
}
#endif /* MAIN */
/* captoinfo.c ends here */
-
diff --git a/contrib/ncurses/ncurses/tinfo/comp_error.c b/contrib/ncurses/ncurses/tinfo/comp_error.c
index 2b2d503013c0..3767063da0a6 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_error.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_error.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 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,11 +41,11 @@
#include <tic.h>
-MODULE_ID("$Id: comp_error.c,v 1.16 1998/08/01 23:39:51 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.17 1999/10/30 23:00:16 tom Exp $")
-bool _nc_suppress_warnings;
-int _nc_curr_line; /* current line # in input */
-int _nc_curr_col; /* current column # in input */
+bool _nc_suppress_warnings = FALSE;
+int _nc_curr_line = 0; /* current line # in input */
+int _nc_curr_col = 0; /* current column # in input */
static const char *sourcename;
static char termtype[MAX_NAME_SIZE+1];
diff --git a/contrib/ncurses/ncurses/tinfo/comp_parse.c b/contrib/ncurses/ncurses/tinfo/comp_parse.c
index be419ca3e790..ca58bb5746e7 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_parse.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_parse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* comp_parse.c -- parser driver loop and use handling.
*
@@ -54,10 +52,10 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: comp_parse.c,v 1.34 1999/02/27 22:13:02 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.40 2000/04/15 16:57:08 tom Exp $")
static void sanity_check(TERMTYPE *);
-void (*_nc_check_termtype)(TERMTYPE *) = sanity_check;
+void (*_nc_check_termtype) (TERMTYPE *) = sanity_check;
/****************************************************************************
*
@@ -80,31 +78,32 @@ void (*_nc_check_termtype)(TERMTYPE *) = sanity_check;
* _nc_head _nc_tail
*/
-ENTRY *_nc_head, *_nc_tail;
+ENTRY *_nc_head = 0, *_nc_tail = 0;
-static void enqueue(ENTRY *ep)
+static void
+enqueue(ENTRY * ep)
/* add an entry to the in-core list */
{
- ENTRY *newp = _nc_copy_entry(ep);
+ ENTRY *newp = _nc_copy_entry(ep);
- if (newp == NULL)
- _nc_err_abort("Out of memory");
+ if (newp == 0)
+ _nc_err_abort("Out of memory");
- newp->last = _nc_tail;
- _nc_tail = newp;
+ newp->last = _nc_tail;
+ _nc_tail = newp;
- newp->next = (ENTRY *)NULL;
- if (newp->last)
- newp->last->next = newp;
+ newp->next = 0;
+ if (newp->last)
+ newp->last->next = newp;
}
-void _nc_free_entries(ENTRY *head)
+void
+_nc_free_entries(ENTRY * headp)
/* free the allocated storage consumed by list entries */
{
- ENTRY *ep, *next;
+ ENTRY *ep, *next;
- for (ep = head; ep; ep = next)
- {
+ for (ep = headp; ep; ep = next) {
/*
* This conditional lets us disconnect storage from the list.
* To do this, copy an entry out of the list, then null out
@@ -116,27 +115,28 @@ void _nc_free_entries(ENTRY *head)
next = ep->next;
free(ep);
- if (ep == _nc_head) _nc_head = 0;
- if (ep == _nc_tail) _nc_tail = 0;
+ if (ep == _nc_head)
+ _nc_head = 0;
+ if (ep == _nc_tail)
+ _nc_tail = 0;
}
}
-bool _nc_entry_match(char *n1, char *n2)
+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 *pstart, *qstart, *pend, *qend;
+ char nc1[MAX_NAME_SIZE + 1], nc2[MAX_NAME_SIZE + 1];
- if (strchr(n1, '|') == NULL)
- {
+ if (strchr(n1, '|') == 0) {
(void) strncpy(nc1, n1, sizeof(nc1) - 2);
nc1[sizeof(nc1) - 2] = '\0';
(void) strcat(nc1, "|");
n1 = nc1;
}
- if (strchr(n2, '|') == NULL)
- {
+ if (strchr(n2, '|') == 0) {
(void) strncpy(nc2, n2, sizeof(nc2) - 2);
nc2[sizeof(nc2) - 2] = '\0';
(void) strcat(nc2, "|");
@@ -145,11 +145,11 @@ bool _nc_entry_match(char *n1, char *n2)
for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1)
for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1)
- if ((pend-pstart == qend-qstart)
- && memcmp(pstart, qstart, (size_t)(pend-pstart)) == 0)
- return(TRUE);
+ if ((pend - pstart == qend - qstart)
+ && memcmp(pstart, qstart, (size_t) (pend - pstart)) == 0)
+ return (TRUE);
- return(FALSE);
+ return (FALSE);
}
/****************************************************************************
@@ -158,21 +158,24 @@ bool _nc_entry_match(char *n1, char *n2)
*
****************************************************************************/
-void _nc_read_entry_source(FILE *fp, char *buf,
- int literal, bool silent,
- bool (*hook)(ENTRY *))
+void
+_nc_read_entry_source(FILE * fp, char *buf,
+ int literal, bool silent,
+ bool(*hook) (ENTRY *))
/* slurp all entries in the given file into core */
{
- ENTRY thisentry;
- bool oldsuppress = _nc_suppress_warnings;
- int immediate = 0;
+ ENTRY thisentry;
+ bool oldsuppress = _nc_suppress_warnings;
+ int immediate = 0;
if (silent)
_nc_suppress_warnings = TRUE; /* shut the lexer up, too */
- memset(&thisentry, 0, sizeof(thisentry));
- for (_nc_reset_input(fp, buf); _nc_parse_entry(&thisentry, literal, silent) != ERR; )
- {
+ _nc_reset_input(fp, buf);
+ for (;;) {
+ memset(&thisentry, 0, sizeof(thisentry));
+ if (_nc_parse_entry(&thisentry, literal, silent) == ERR)
+ break;
if (!isalnum(thisentry.tterm.term_names[0]))
_nc_err_abort("terminal names must start with letter or digit");
@@ -181,14 +184,13 @@ void _nc_read_entry_source(FILE *fp, char *buf,
* use references to disk, so as to avoid chewing up a lot of
* core when the resolution code could fetch entries off disk.
*/
- if (hook != NULLHOOK && (*hook)(&thisentry))
+ if (hook != NULLHOOK && (*hook) (&thisentry))
immediate++;
else
enqueue(&thisentry);
}
- if (_nc_tail)
- {
+ if (_nc_tail) {
/* set up the head pointer */
for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last)
continue;
@@ -204,12 +206,13 @@ void _nc_read_entry_source(FILE *fp, char *buf,
_nc_suppress_warnings = oldsuppress;
}
-int _nc_resolve_uses(void)
+int
+_nc_resolve_uses(bool fullresolve)
/* try to resolve all use capabilities */
{
- ENTRY *qp, *rp, *lastread = NULL;
- bool keepgoing;
- int i, j, unresolved, total_unresolved, multiples;
+ ENTRY *qp, *rp, *lastread = 0;
+ bool keepgoing;
+ int i, j, unresolved, total_unresolved, multiples;
DEBUG(2, ("RESOLUTION BEGINNING"));
@@ -217,48 +220,41 @@ int _nc_resolve_uses(void)
* Check for multiple occurrences of the same name.
*/
multiples = 0;
- for_entry_list(qp)
- {
+ for_entry_list(qp) {
int matchcount = 0;
for_entry_list(rp)
if (qp > rp
- && _nc_entry_match(qp->tterm.term_names, rp->tterm.term_names))
- {
- matchcount++;
- if (matchcount == 1)
- {
- (void) fprintf(stderr, "Name collision between %s",
- _nc_first_name(qp->tterm.term_names));
- multiples++;
- }
- if (matchcount >= 1)
- (void) fprintf(stderr, " %s", _nc_first_name(rp->tterm.term_names));
+ && _nc_entry_match(qp->tterm.term_names, rp->tterm.term_names)) {
+ matchcount++;
+ if (matchcount == 1) {
+ (void) fprintf(stderr, "Name collision between %s",
+ _nc_first_name(qp->tterm.term_names));
+ multiples++;
}
+ if (matchcount >= 1)
+ (void) fprintf(stderr, " %s", _nc_first_name(rp->tterm.term_names));
+ }
if (matchcount >= 1)
(void) putc('\n', stderr);
}
if (multiples > 0)
- return(FALSE);
+ return (FALSE);
DEBUG(2, ("NO MULTIPLE NAME OCCURRENCES"));
/*
- * First resolution stage: replace names in use arrays with entry
- * pointers. By doing this, we avoid having to do the same name
- * match once for each time a use entry is itself unresolved.
+ * First resolution stage: compute link pointers corresponding to names.
*/
total_unresolved = 0;
_nc_curr_col = -1;
- for_entry_list(qp)
- {
+ for_entry_list(qp) {
unresolved = 0;
- for (i = 0; i < qp->nuses; i++)
- {
- bool foundit;
- char *child = _nc_first_name(qp->tterm.term_names);
- char *lookfor = (char *)(qp->uses[i].parent);
- long lookline = qp->uses[i].line;
+ for (i = 0; i < qp->nuses; i++) {
+ bool foundit;
+ char *child = _nc_first_name(qp->tterm.term_names);
+ char *lookfor = qp->uses[i].name;
+ long lookline = qp->uses[i].line;
foundit = FALSE;
@@ -267,146 +263,142 @@ int _nc_resolve_uses(void)
/* first, try to resolve from in-core records */
for_entry_list(rp)
if (rp != qp
- && _nc_name_match(rp->tterm.term_names, lookfor, "|"))
- {
- DEBUG(2, ("%s: resolving use=%s (in core)",
- child, lookfor));
+ && _nc_name_match(rp->tterm.term_names, lookfor, "|")) {
+ DEBUG(2, ("%s: resolving use=%s (in core)",
+ child, lookfor));
- qp->uses[i].parent = rp;
- foundit = TRUE;
- }
+ qp->uses[i].link = rp;
+ foundit = TRUE;
+ }
/* if that didn't work, try to merge in a compiled entry */
- if (!foundit)
- {
- TERMTYPE thisterm;
- char filename[PATH_MAX];
+ if (!foundit) {
+ TERMTYPE thisterm;
+ char filename[PATH_MAX];
memset(&thisterm, 0, sizeof(thisterm));
- if (_nc_read_entry(lookfor, filename, &thisterm) == 1)
- {
+ if (_nc_read_entry(lookfor, filename, &thisterm) == 1) {
DEBUG(2, ("%s: resolving use=%s (compiled)",
- child, lookfor));
+ child, lookfor));
- rp = typeMalloc(ENTRY,1);
- if (rp == NULL)
+ rp = typeMalloc(ENTRY, 1);
+ if (rp == 0)
_nc_err_abort("Out of memory");
rp->tterm = thisterm;
rp->nuses = 0;
rp->next = lastread;
lastread = rp;
- qp->uses[i].parent = rp;
+ qp->uses[i].link = rp;
foundit = TRUE;
}
}
/* no good, mark this one unresolvable and complain */
- if (!foundit)
- {
+ if (!foundit) {
unresolved++;
total_unresolved++;
_nc_curr_line = lookline;
_nc_warning("resolution of use=%s failed", lookfor);
- qp->uses[i].parent = (ENTRY *)NULL;
+ qp->uses[i].link = 0;
}
}
}
- if (total_unresolved)
- {
+ if (total_unresolved) {
/* free entries read in off disk */
_nc_free_entries(lastread);
- return(FALSE);
+ return (FALSE);
}
DEBUG(2, ("NAME RESOLUTION COMPLETED OK"));
/*
- * OK, at this point all (char *) references have been successfully
- * replaced by (ENTRY *) pointers. Time to do the actual merges.
+ * OK, at this point all (char *) references in `name' mwmbers
+ * have been successfully converred to (ENTRY *) pointers in
+ * `link' members. Time to do the actual merges.
*/
- do {
- TERMTYPE merged;
-
- keepgoing = FALSE;
-
- for_entry_list(qp)
- {
- if (qp->nuses > 0)
- {
- DEBUG(2, ("%s: attempting merge", _nc_first_name(qp->tterm.term_names)));
- /*
- * If any of the use entries we're looking for is
- * incomplete, punt. We'll catch this entry on a
- * subsequent pass.
- */
- for (i = 0; i < qp->nuses; i++)
- if (((ENTRY *)qp->uses[i].parent)->nuses)
- {
- DEBUG(2, ("%s: use entry %d unresolved",
- _nc_first_name(qp->tterm.term_names), i));
- goto incomplete;
- }
-
- /*
- * First, make sure there's no garbage in the merge block.
- * as a side effect, copy into the merged entry the name
- * field and string table pointer.
- */
- _nc_copy_termtype(&merged, &(qp->tterm));
-
- /*
- * Now merge in each use entry in the proper
- * (reverse) order.
- */
- for (; qp->nuses; qp->nuses--)
- _nc_merge_entry(&merged,
- &((ENTRY *)qp->uses[qp->nuses-1].parent)->tterm);
-
- /*
- * Now merge in the original entry.
- */
- _nc_merge_entry(&merged, &qp->tterm);
-
- /*
- * Replace the original entry with the merged one.
- */
- FreeIfNeeded(qp->tterm.Booleans);
- FreeIfNeeded(qp->tterm.Numbers);
- FreeIfNeeded(qp->tterm.Strings);
- qp->tterm = merged;
-
- /*
- * We know every entry is resolvable because name resolution
- * didn't bomb. So go back for another pass.
- */
- /* FALLTHRU */
- incomplete:
- keepgoing = TRUE;
+ if (fullresolve) {
+ do {
+ TERMTYPE merged;
+
+ keepgoing = FALSE;
+
+ for_entry_list(qp) {
+ if (qp->nuses > 0) {
+ DEBUG(2, ("%s: attempting merge",
+ _nc_first_name(qp->tterm.term_names)));
+ /*
+ * If any of the use entries we're looking for is
+ * incomplete, punt. We'll catch this entry on a
+ * subsequent pass.
+ */
+ for (i = 0; i < qp->nuses; i++)
+ if (qp->uses[i].link->nuses) {
+ DEBUG(2, ("%s: use entry %d unresolved",
+ _nc_first_name(qp->tterm.term_names), i));
+ goto incomplete;
+ }
+
+ /*
+ * First, make sure there's no garbage in the
+ * merge block. as a side effect, copy into
+ * the merged entry the name field and string
+ * table pointer.
+ */
+ _nc_copy_termtype(&merged, &(qp->tterm));
+
+ /*
+ * Now merge in each use entry in the proper
+ * (reverse) order.
+ */
+ for (; qp->nuses; qp->nuses--)
+ _nc_merge_entry(&merged,
+ &qp->uses[qp->nuses - 1].link->tterm);
+
+ /*
+ * Now merge in the original entry.
+ */
+ _nc_merge_entry(&merged, &qp->tterm);
+
+ /*
+ * Replace the original entry with the merged one.
+ */
+ FreeIfNeeded(qp->tterm.Booleans);
+ FreeIfNeeded(qp->tterm.Numbers);
+ FreeIfNeeded(qp->tterm.Strings);
+ qp->tterm = merged;
+
+ /*
+ * We know every entry is resolvable because name resolution
+ * didn't bomb. So go back for another pass.
+ */
+ /* FALLTHRU */
+ incomplete:
+ keepgoing = TRUE;
+ }
}
- }
- } while
- (keepgoing);
+ } while
+ (keepgoing);
- DEBUG(2, ("MERGES COMPLETED OK"));
+ DEBUG(2, ("MERGES COMPLETED OK"));
- /*
- * The exit condition of the loop above is such that all entries
- * must now be resolved. Now handle cancellations. In a resolved
- * entry there should be no cancellation markers.
- */
- for_entry_list(qp)
- {
- for_each_boolean(j, &(qp->tterm))
- if (qp->tterm.Booleans[j] == CANCELLED_BOOLEAN)
- qp->tterm.Booleans[j] = FALSE;
- for_each_number(j, &(qp->tterm))
- if (qp->tterm.Numbers[j] == CANCELLED_NUMERIC)
+ /*
+ * The exit condition of the loop above is such that all entries
+ * must now be resolved. Now handle cancellations. In a resolved
+ * entry there should be no cancellation markers.
+ */
+ for_entry_list(qp) {
+ for_each_boolean(j, &(qp->tterm))
+ if (qp->tterm.Booleans[j] == CANCELLED_BOOLEAN)
+ qp->tterm.Booleans[j] = ABSENT_BOOLEAN;
+ for_each_number(j, &(qp->tterm))
+ if (qp->tterm.Numbers[j] == CANCELLED_NUMERIC)
qp->tterm.Numbers[j] = ABSENT_NUMERIC;
- for_each_string(j, &(qp->tterm))
- if (qp->tterm.Strings[j] == CANCELLED_STRING)
+ for_each_string(j, &(qp->tterm))
+ if (qp->tterm.Strings[j] == CANCELLED_STRING)
qp->tterm.Strings[j] = ABSENT_STRING;
+ }
}
/*
@@ -418,19 +410,18 @@ int _nc_resolve_uses(void)
DEBUG(2, ("RESOLUTION FINISHED"));
- if (_nc_check_termtype != 0)
- {
- _nc_curr_col = -1;
- for_entry_list(qp)
- {
- _nc_curr_line = qp->startline;
- _nc_set_type(_nc_first_name(qp->tterm.term_names));
- _nc_check_termtype(&qp->tterm);
+ if (fullresolve)
+ if (_nc_check_termtype != 0) {
+ _nc_curr_col = -1;
+ for_entry_list(qp) {
+ _nc_curr_line = qp->startline;
+ _nc_set_type(_nc_first_name(qp->tterm.term_names));
+ _nc_check_termtype(&qp->tterm);
+ }
+ DEBUG(2, ("SANITY CHECK FINISHED"));
}
- DEBUG(2, ("SANITY CHECK FINISHED"));
- }
- return(TRUE);
+ return (TRUE);
}
/*
@@ -442,14 +433,14 @@ int _nc_resolve_uses(void)
#undef CUR
#define CUR tp->
-static void sanity_check(TERMTYPE *tp)
+static void
+sanity_check(TERMTYPE * tp)
{
- if (!PRESENT(exit_attribute_mode))
- {
-#ifdef __UNUSED__ /* this casts too wide a net */
- bool terminal_entry = !strchr(tp->term_names, '+');
+ if (!PRESENT(exit_attribute_mode)) {
+#ifdef __UNUSED__ /* this casts too wide a net */
+ bool terminal_entry = !strchr(tp->term_names, '+');
if (terminal_entry &&
- (PRESENT(set_attributes)
+ (PRESENT(set_attributes)
|| PRESENT(enter_standout_mode)
|| PRESENT(enter_underline_mode)
|| PRESENT(enter_blink_mode)
@@ -460,31 +451,31 @@ static void sanity_check(TERMTYPE *tp)
|| PRESENT(enter_reverse_mode)))
_nc_warning("no exit_attribute_mode");
#endif /* __UNUSED__ */
- PAIRED(enter_standout_mode, exit_standout_mode)
- PAIRED(enter_underline_mode, exit_underline_mode)
+ PAIRED(enter_standout_mode, exit_standout_mode)
+ PAIRED(enter_underline_mode, exit_underline_mode)
}
- /* listed in structure-member order of first argument */
- PAIRED(enter_alt_charset_mode, exit_alt_charset_mode)
- ANDMISSING(enter_alt_charset_mode, acs_chars)
- ANDMISSING(exit_alt_charset_mode, acs_chars)
- ANDMISSING(enter_blink_mode, exit_attribute_mode)
- ANDMISSING(enter_bold_mode, exit_attribute_mode)
- PAIRED(exit_ca_mode, enter_ca_mode)
- PAIRED(enter_delete_mode, exit_delete_mode)
- ANDMISSING(enter_dim_mode, exit_attribute_mode)
- PAIRED(enter_insert_mode, exit_insert_mode)
- ANDMISSING(enter_secure_mode, exit_attribute_mode)
- ANDMISSING(enter_protected_mode, exit_attribute_mode)
- ANDMISSING(enter_reverse_mode, exit_attribute_mode)
- PAIRED(from_status_line, to_status_line)
- PAIRED(meta_off, meta_on)
-
- PAIRED(prtr_on, prtr_off)
- PAIRED(save_cursor, restore_cursor)
- PAIRED(enter_xon_mode, exit_xon_mode)
- PAIRED(enter_am_mode, exit_am_mode)
- ANDMISSING(label_off, label_on)
- PAIRED(display_clock, remove_clock)
- ANDMISSING(set_color_pair, initialize_pair)
+ /* listed in structure-member order of first argument */
+ PAIRED(enter_alt_charset_mode, exit_alt_charset_mode);
+ ANDMISSING(enter_alt_charset_mode, acs_chars);
+ ANDMISSING(exit_alt_charset_mode, acs_chars);
+ ANDMISSING(enter_blink_mode, exit_attribute_mode);
+ ANDMISSING(enter_bold_mode, exit_attribute_mode);
+ PAIRED(exit_ca_mode, enter_ca_mode);
+ PAIRED(enter_delete_mode, exit_delete_mode);
+ ANDMISSING(enter_dim_mode, exit_attribute_mode);
+ PAIRED(enter_insert_mode, exit_insert_mode);
+ ANDMISSING(enter_secure_mode, exit_attribute_mode);
+ ANDMISSING(enter_protected_mode, exit_attribute_mode);
+ ANDMISSING(enter_reverse_mode, exit_attribute_mode);
+ PAIRED(from_status_line, to_status_line);
+ PAIRED(meta_off, meta_on);
+
+ PAIRED(prtr_on, prtr_off);
+ PAIRED(save_cursor, restore_cursor);
+ PAIRED(enter_xon_mode, exit_xon_mode);
+ PAIRED(enter_am_mode, exit_am_mode);
+ ANDMISSING(label_off, label_on);
+ PAIRED(display_clock, remove_clock);
+ ANDMISSING(set_color_pair, initialize_pair);
}
diff --git a/contrib/ncurses/ncurses/tinfo/comp_scan.c b/contrib/ncurses/ncurses/tinfo/comp_scan.c
index 152930885ab7..8997e417ae57 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_scan.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -47,9 +47,10 @@
#include <curses.priv.h>
#include <ctype.h>
+#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$Id: comp_scan.c,v 1.34 1998/11/01 00:56:39 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.44 2000/06/10 21:59:21 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -59,11 +60,14 @@ MODULE_ID("$Id: comp_scan.c,v 1.34 1998/11/01 00:56:39 tom Exp $")
#define iswhite(ch) (ch == ' ' || ch == '\t')
-int _nc_syntax; /* termcap or terminfo? */
-long _nc_curr_file_pos; /* file offset of current line */
-long _nc_comment_start; /* start of comment range before name */
-long _nc_comment_end; /* end of comment range before name */
-long _nc_start_line; /* start line of current entry */
+int _nc_syntax = 0; /* termcap or terminfo? */
+long _nc_curr_file_pos = 0; /* file offset of current line */
+long _nc_comment_start = 0; /* start of comment range before name */
+long _nc_comment_end = 0; /* end of comment range before name */
+long _nc_start_line = 0; /* start line of current entry */
+
+struct token _nc_curr_token =
+{0, 0, 0};
/*****************************************************************************
*
@@ -74,21 +78,22 @@ long _nc_start_line; /* start line of current entry */
static bool first_column; /* See 'next_char()' below */
static char separator; /* capability separator */
static int pushtype; /* type of pushback token */
-static char pushname[MAX_NAME_SIZE+1];
+static char pushname[MAX_NAME_SIZE + 1];
-static int last_char(void);
-static int next_char(void);
+static int last_char(void);
+static int next_char(void);
static long stream_pos(void);
static bool end_of_stream(void);
static void push_back(char c);
/* Assume we may be looking at a termcap-style continuation */
-static inline int eat_escaped_newline(int ch)
+static inline int
+eat_escaped_newline(int ch)
{
- if (ch == '\\')
- while ((ch = next_char()) == '\n' || iswhite(ch))
- continue;
- return ch;
+ if (ch == '\\')
+ while ((ch = next_char()) == '\n' || iswhite(ch))
+ continue;
+ return ch;
}
/*
@@ -124,316 +129,306 @@ static inline int eat_escaped_newline(int ch)
*
*/
-int _nc_get_token(void)
+int
+_nc_get_token(void)
{
-static const char terminfo_punct[] = "@%&*!#";
-long number;
-int type;
-int ch;
-char * numchk;
-char numbuf[80];
-unsigned found;
-static char buffer[MAX_ENTRY_SIZE];
-char *ptr;
-int dot_flag = FALSE;
-long token_start;
-
- if (pushtype != NO_PUSHBACK)
- {
- int retval = pushtype;
-
- _nc_set_type(pushname);
- DEBUG(3, ("pushed-back token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
-
- pushtype = NO_PUSHBACK;
- pushname[0] = '\0';
-
- /* currtok wasn't altered by _nc_push_token() */
- return(retval);
- }
+ static const char terminfo_punct[] = "@%&*!#";
+ long number;
+ int type;
+ int ch;
+ char *numchk;
+ char numbuf[80];
+ unsigned found;
+ static char buffer[MAX_ENTRY_SIZE];
+ char *ptr;
+ int dot_flag = FALSE;
+ long token_start;
+
+ if (pushtype != NO_PUSHBACK) {
+ int retval = pushtype;
+
+ _nc_set_type(pushname);
+ DEBUG(3, ("pushed-back token: `%s', class %d",
+ _nc_curr_token.tk_name, pushtype));
- if (end_of_stream())
- return(EOF);
-
-start_token:
- token_start = stream_pos();
- while ((ch = next_char()) == '\n' || iswhite(ch))
- continue;
+ pushtype = NO_PUSHBACK;
+ pushname[0] = '\0';
- ch = eat_escaped_newline(ch);
+ /* currtok wasn't altered by _nc_push_token() */
+ return (retval);
+ }
- if (ch == EOF)
- type = EOF;
- else {
- /* if this is a termcap entry, skip a leading separator */
- if (separator == ':' && ch == ':')
- ch = next_char();
+ if (end_of_stream())
+ return (EOF);
- if (ch == '.') {
- dot_flag = TRUE;
- DEBUG(8, ("dot-flag set"));
+ start_token:
+ token_start = stream_pos();
+ while ((ch = next_char()) == '\n' || iswhite(ch))
+ continue;
- while ((ch = next_char())=='.' || iswhite(ch))
- continue;
- }
+ ch = eat_escaped_newline(ch);
- if (ch == EOF) {
- type = EOF;
- goto end_of_token;
- }
+ if (ch == EOF)
+ type = EOF;
+ else {
+ /* if this is a termcap entry, skip a leading separator */
+ if (separator == ':' && ch == ':')
+ ch = next_char();
- /* have to make some punctuation chars legal for terminfo */
- if (!isalnum(ch) && !strchr(terminfo_punct, (char)ch)) {
- _nc_warning("Illegal character (expected alphanumeric or %s) - %s",
- terminfo_punct, _tracechar((chtype)ch));
- _nc_panic_mode(separator);
- goto start_token;
- }
+ if (ch == '.'
+#ifdef NCURSES_EXT_FUNCS
+ && !_nc_disable_period
+#endif
+ ) {
+ dot_flag = TRUE;
+ DEBUG(8, ("dot-flag set"));
- ptr = buffer;
- *(ptr++) = ch;
-
- if (first_column) {
- char *desc;
-
- _nc_comment_start = token_start;
- _nc_comment_end = _nc_curr_file_pos;
- _nc_start_line = _nc_curr_line;
-
- _nc_syntax = ERR;
- while ((ch = next_char()) != '\n')
- {
- if (ch == EOF)
- _nc_err_abort("premature EOF");
- else if (ch == ':' && last_char() != ',')
- {
- _nc_syntax = SYN_TERMCAP;
- separator = ':';
- break;
- }
- else if (ch == ',')
- {
- _nc_syntax = SYN_TERMINFO;
- separator = ',';
- /*
- * Fall-through here is not an accident.
- * The idea is that if we see a comma, we
- * figure this is terminfo unless we
- * subsequently run into a colon -- but
- * we don't stop looking for that colon until
- * hitting a newline. This allows commas to
- * be embedded in description fields of
- * either syntax.
- */
- /* FALLTHRU */
- }
- else
- ch = eat_escaped_newline(ch);
-
- *ptr++ = ch;
- }
- ptr[0] = '\0';
- if (_nc_syntax == ERR)
- {
- /*
- * Grrr...what we ought to do here is barf,
- * complaining that the entry is malformed.
- * But because a couple of name fields in the
- * 8.2 termcap file end with |\, we just have
- * to assume it's termcap syntax.
- */
- _nc_syntax = SYN_TERMCAP;
- separator = ':';
- }
- else if (_nc_syntax == SYN_TERMINFO)
- {
- /* throw away trailing /, *$/ */
- for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--)
- continue;
- ptr[1] = '\0';
- }
+ while ((ch = next_char()) == '.' || iswhite(ch))
+ continue;
+ }
- /*
- * This is the soonest we have the terminal name
- * fetched. Set up for following warning messages.
- */
- ptr = strchr(buffer, '|');
- if (ptr == (char *)NULL)
- ptr = buffer + strlen(buffer);
- ch = *ptr;
- *ptr = '\0';
- _nc_set_type(buffer);
- *ptr = ch;
-
- /*
- * Compute the boundary between the aliases and the
- * description field for syntax-checking purposes.
- */
- desc = strrchr(buffer, '|');
- if (desc) {
- if (*desc == '\0')
- _nc_warning("empty longname field");
- else if (strchr(desc, ' ') == (char *)NULL)
- _nc_warning("older tic versions may treat the description field as an alias");
- }
- if (!desc)
- desc = buffer + strlen(buffer);
-
- /*
- * Whitespace in a name field other than the long name
- * can confuse rdist and some termcap tools. Slashes
- * are a no-no. Other special characters can be
- * dangerous due to shell expansion.
- */
- for (ptr = buffer; ptr < desc; ptr++)
- {
- if (isspace(*ptr))
- {
- _nc_warning("whitespace in name or alias field");
- break;
- }
- else if (*ptr == '/')
- {
- _nc_warning("slashes aren't allowed in names or aliases");
- break;
- }
- else if (strchr("$[]!*?", *ptr))
- {
- _nc_warning("dubious character `%c' in name or alias field", *ptr);
- break;
- }
- }
+ if (ch == EOF) {
+ type = EOF;
+ goto end_of_token;
+ }
- ptr = buffer;
+ /* have to make some punctuation chars legal for terminfo */
+ if (!isalnum(ch)
+#ifdef NCURSES_EXT_FUNCS
+ && !(ch == '.' && _nc_disable_period)
+#endif
+ && !strchr(terminfo_punct, (char) ch)) {
+ _nc_warning("Illegal character (expected alphanumeric or %s) - %s",
+ terminfo_punct, unctrl(ch));
+ _nc_panic_mode(separator);
+ goto start_token;
+ }
- _nc_curr_token.tk_name = buffer;
- type = NAMES;
- } else {
- while ((ch = next_char()) != EOF) {
- if (!isalnum(ch)) {
- if (_nc_syntax == SYN_TERMINFO) {
- if (ch != '_')
- break;
- } else { /* allow ';' for "k;" */
- if (ch != ';')
- break;
- }
- }
- *(ptr++) = ch;
- }
+ ptr = buffer;
+ *(ptr++) = ch;
- *ptr++ = '\0';
- switch (ch) {
- case ',':
- case ':':
- if (ch != separator)
- _nc_err_abort("Separator inconsistent with syntax");
- _nc_curr_token.tk_name = buffer;
- type = BOOLEAN;
- break;
- case '@':
- if ((ch = next_char()) != separator)
- _nc_warning("Missing separator after `%s', have %s",
- buffer, _tracechar((chtype)ch));
- _nc_curr_token.tk_name = buffer;
- type = CANCEL;
- break;
-
- case '#':
- found = 0;
- while (isalnum(ch = next_char())) {
- numbuf[found++] = ch;
- if (found >= sizeof(numbuf)-1)
- break;
- }
- numbuf[found] = '\0';
- number = strtol(numbuf, &numchk, 0);
- if (numchk == numbuf)
- _nc_warning("no value given for `%s'", buffer);
- if ((*numchk != '\0') || (ch != separator))
- _nc_warning("Missing separator");
- _nc_curr_token.tk_name = buffer;
- _nc_curr_token.tk_valnumber = number;
- type = NUMBER;
- break;
-
- case '=':
- ch = _nc_trans_string(ptr);
- if (ch != separator)
- _nc_warning("Missing separator");
- _nc_curr_token.tk_name = buffer;
- _nc_curr_token.tk_valstring = ptr;
- type = STRING;
- break;
-
- case EOF:
- type = EOF;
- break;
- default:
- /* just to get rid of the compiler warning */
- type = UNDEF;
- _nc_warning("Illegal character - %s",
- _tracechar((chtype)ch));
- }
- } /* end else (first_column == FALSE) */
- } /* end else (ch != EOF) */
+ if (first_column) {
+ char *desc;
-end_of_token:
+ _nc_comment_start = token_start;
+ _nc_comment_end = _nc_curr_file_pos;
+ _nc_start_line = _nc_curr_line;
-#ifdef TRACE
- if (dot_flag == TRUE)
- DEBUG(8, ("Commented out "));
-
- if (_nc_tracing & TRACE_IEVENT)
- {
- fprintf(stderr, "Token: ");
- switch (type)
- {
- case BOOLEAN:
- fprintf(stderr, "Boolean; name='%s'\n",
- _nc_curr_token.tk_name);
+ _nc_syntax = ERR;
+ while ((ch = next_char()) != '\n') {
+ if (ch == EOF)
+ _nc_err_abort("premature EOF");
+ else if (ch == ':' && last_char() != ',') {
+ _nc_syntax = SYN_TERMCAP;
+ separator = ':';
break;
+ } else if (ch == ',') {
+ _nc_syntax = SYN_TERMINFO;
+ separator = ',';
+ /*
+ * Fall-through here is not an accident.
+ * The idea is that if we see a comma, we
+ * figure this is terminfo unless we
+ * subsequently run into a colon -- but
+ * we don't stop looking for that colon until
+ * hitting a newline. This allows commas to
+ * be embedded in description fields of
+ * either syntax.
+ */
+ /* FALLTHRU */
+ } else
+ ch = eat_escaped_newline(ch);
+
+ *ptr++ = ch;
+ }
+ ptr[0] = '\0';
+ if (_nc_syntax == ERR) {
+ /*
+ * Grrr...what we ought to do here is barf,
+ * complaining that the entry is malformed.
+ * But because a couple of name fields in the
+ * 8.2 termcap file end with |\, we just have
+ * to assume it's termcap syntax.
+ */
+ _nc_syntax = SYN_TERMCAP;
+ separator = ':';
+ } else if (_nc_syntax == SYN_TERMINFO) {
+ /* throw away trailing /, *$/ */
+ for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--)
+ continue;
+ ptr[1] = '\0';
+ }
- case NUMBER:
- fprintf(stderr, "Number; name='%s', value=%d\n",
- _nc_curr_token.tk_name,
- _nc_curr_token.tk_valnumber);
+ /*
+ * This is the soonest we have the terminal name
+ * fetched. Set up for following warning messages.
+ */
+ ptr = strchr(buffer, '|');
+ if (ptr == (char *) NULL)
+ ptr = buffer + strlen(buffer);
+ ch = *ptr;
+ *ptr = '\0';
+ _nc_set_type(buffer);
+ *ptr = ch;
+
+ /*
+ * Compute the boundary between the aliases and the
+ * description field for syntax-checking purposes.
+ */
+ desc = strrchr(buffer, '|');
+ if (desc) {
+ if (*desc == '\0')
+ _nc_warning("empty longname field");
+ else if (strchr(desc, ' ') == (char *) NULL)
+ _nc_warning("older tic versions may treat the description field as an alias");
+ }
+ if (!desc)
+ desc = buffer + strlen(buffer);
+
+ /*
+ * Whitespace in a name field other than the long name
+ * can confuse rdist and some termcap tools. Slashes
+ * are a no-no. Other special characters can be
+ * dangerous due to shell expansion.
+ */
+ for (ptr = buffer; ptr < desc; ptr++) {
+ if (isspace(*ptr)) {
+ _nc_warning("whitespace in name or alias field");
break;
-
- case STRING:
- fprintf(stderr, "String; name='%s', value=%s\n",
- _nc_curr_token.tk_name,
- _nc_visbuf(_nc_curr_token.tk_valstring));
+ } else if (*ptr == '/') {
+ _nc_warning("slashes aren't allowed in names or aliases");
break;
-
- case CANCEL:
- fprintf(stderr, "Cancel; name='%s'\n",
- _nc_curr_token.tk_name);
+ } else if (strchr("$[]!*?", *ptr)) {
+ _nc_warning("dubious character `%c' in name or alias field", *ptr);
break;
+ }
+ }
- case NAMES:
+ ptr = buffer;
- fprintf(stderr, "Names; value='%s'\n",
- _nc_curr_token.tk_name);
- break;
+ _nc_curr_token.tk_name = buffer;
+ type = NAMES;
+ } else {
+ while ((ch = next_char()) != EOF) {
+ if (!isalnum(ch)) {
+ if (_nc_syntax == SYN_TERMINFO) {
+ if (ch != '_')
+ break;
+ } else { /* allow ';' for "k;" */
+ if (ch != ';')
+ break;
+ }
+ }
+ *(ptr++) = ch;
+ }
- case EOF:
- fprintf(stderr, "End of file\n");
- break;
+ *ptr++ = '\0';
+ switch (ch) {
+ case ',':
+ case ':':
+ if (ch != separator)
+ _nc_err_abort("Separator inconsistent with syntax");
+ _nc_curr_token.tk_name = buffer;
+ type = BOOLEAN;
+ break;
+ case '@':
+ if ((ch = next_char()) != separator)
+ _nc_warning("Missing separator after `%s', have %s",
+ buffer, unctrl(ch));
+ _nc_curr_token.tk_name = buffer;
+ type = CANCEL;
+ break;
- default:
- _nc_warning("Bad token type");
+ case '#':
+ found = 0;
+ while (isalnum(ch = next_char())) {
+ numbuf[found++] = ch;
+ if (found >= sizeof(numbuf) - 1)
+ break;
+ }
+ numbuf[found] = '\0';
+ number = strtol(numbuf, &numchk, 0);
+ if (numchk == numbuf)
+ _nc_warning("no value given for `%s'", buffer);
+ if ((*numchk != '\0') || (ch != separator))
+ _nc_warning("Missing separator");
+ _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_valnumber = number;
+ type = NUMBER;
+ break;
+
+ case '=':
+ ch = _nc_trans_string(ptr, buffer + sizeof(buffer));
+ if (ch != separator)
+ _nc_warning("Missing separator");
+ _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_valstring = ptr;
+ type = STRING;
+ break;
+
+ case EOF:
+ type = EOF;
+ break;
+ default:
+ /* just to get rid of the compiler warning */
+ type = UNDEF;
+ _nc_warning("Illegal character - %s", unctrl(ch));
}
+ } /* end else (first_column == FALSE) */
+ } /* end else (ch != EOF) */
+
+ end_of_token:
+
+#ifdef TRACE
+ if (dot_flag == TRUE)
+ DEBUG(8, ("Commented out "));
+
+ if (_nc_tracing >= DEBUG_LEVEL(7)) {
+ switch (type) {
+ case BOOLEAN:
+ _tracef("Token: Boolean; name='%s'",
+ _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);
+ break;
+
+ case STRING:
+ _tracef("Token: String; name='%s', value=%s",
+ _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);
+ break;
+
+ case NAMES:
+
+ _tracef("Token: Names; value='%s'",
+ _nc_curr_token.tk_name);
+ break;
+
+ case EOF:
+ _tracef("Token: End of file");
+ break;
+
+ default:
+ _nc_warning("Bad token type");
}
+ }
#endif
- if (dot_flag == TRUE) /* if commented out, use the next one */
- type = _nc_get_token();
+ if (dot_flag == TRUE) /* if commented out, use the next one */
+ type = _nc_get_token();
- DEBUG(3, ("token: `%s', class %d", _nc_curr_token.tk_name, type));
+ DEBUG(3, ("token: `%s', class %d", _nc_curr_token.tk_name, type));
- return(type);
+ return (type);
}
/*
@@ -456,120 +451,150 @@ end_of_token:
*/
char
-_nc_trans_string(char *ptr)
+_nc_trans_string(char *ptr, char *last)
{
-int count = 0;
-int number;
-int i, c;
-chtype ch, last_ch = '\0';
-bool ignored = FALSE;
-
- while ((ch = c = next_char()) != (chtype)separator && c != EOF) {
- if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
- break;
- if (ch == '^' && last_ch != '%') {
- ch = c = next_char();
- if (c == EOF)
- _nc_err_abort("Premature EOF");
-
- if (! (is7bits(ch) && isprint(ch))) {
- _nc_warning("Illegal ^ character - %s",
- _tracechar((unsigned char)ch));
- }
- if (ch == '?') {
- *(ptr++) = '\177';
- } else {
- if ((ch &= 037) == 0)
- ch = 128;
- *(ptr++) = (char)(ch);
- }
+ int count = 0;
+ int number;
+ int i, c;
+ chtype ch, last_ch = '\0';
+ bool ignored = FALSE;
+ bool long_warning = FALSE;
+
+ while ((ch = c = next_char()) != (chtype) separator && c != EOF) {
+ if (ptr == (last - 1))
+ break;
+ if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
+ break;
+ if (ch == '^' && last_ch != '%') {
+ ch = c = next_char();
+ if (c == EOF)
+ _nc_err_abort("Premature EOF");
+
+ if (!(is7bits(ch) && isprint(ch))) {
+ _nc_warning("Illegal ^ character - %s", unctrl(ch));
}
- else if (ch == '\\') {
- ch = c = next_char();
- if (c == EOF)
- _nc_err_abort("Premature EOF");
-
- if (ch >= '0' && ch <= '7') {
- number = ch - '0';
- for (i=0; i < 2; i++) {
- ch = c = next_char();
- if (c == EOF)
- _nc_err_abort("Premature EOF");
-
- if (c < '0' || c > '7') {
- if (isdigit(c)) {
- _nc_warning("Non-octal digit `%c' in \\ sequence", c);
- /* allow the digit; it'll do less harm */
- } else {
- push_back((char)c);
- break;
- }
+ if (ch == '?') {
+ *(ptr++) = '\177';
+ if (_nc_tracing)
+ _nc_warning("Allow ^? as synonym for \\177");
+ } else {
+ if ((ch &= 037) == 0)
+ ch = 128;
+ *(ptr++) = (char) (ch);
+ }
+ } else if (ch == '\\') {
+ ch = c = next_char();
+ if (c == EOF)
+ _nc_err_abort("Premature EOF");
+
+ if (ch >= '0' && ch <= '7') {
+ number = ch - '0';
+ for (i = 0; i < 2; i++) {
+ ch = c = next_char();
+ if (c == EOF)
+ _nc_err_abort("Premature EOF");
+
+ if (c < '0' || c > '7') {
+ if (isdigit(c)) {
+ _nc_warning("Non-octal digit `%c' in \\ sequence", c);
+ /* allow the digit; it'll do less harm */
+ } else {
+ push_back((char) c);
+ break;
}
-
- number = number * 8 + c - '0';
}
- if (number == 0)
- number = 0200;
- *(ptr++) = (char) number;
- } else {
- switch (c) {
- case 'E':
- case 'e': *(ptr++) = '\033'; break;
+ number = number * 8 + c - '0';
+ }
- case 'a': *(ptr++) = '\007'; break;
+ if (number == 0)
+ number = 0200;
+ *(ptr++) = (char) number;
+ } else {
+ switch (c) {
+ case 'E':
+ case 'e':
+ *(ptr++) = '\033';
+ break;
- case 'l':
- case 'n': *(ptr++) = '\n'; break;
+ case 'a':
+ *(ptr++) = '\007';
+ break;
- case 'r': *(ptr++) = '\r'; break;
+ case 'l':
+ case 'n':
+ *(ptr++) = '\n';
+ break;
- case 'b': *(ptr++) = '\010'; break;
+ case 'r':
+ *(ptr++) = '\r';
+ break;
- case 's': *(ptr++) = ' '; break;
+ case 'b':
+ *(ptr++) = '\010';
+ break;
- case 'f': *(ptr++) = '\014'; break;
+ case 's':
+ *(ptr++) = ' ';
+ break;
- case 't': *(ptr++) = '\t'; break;
+ case 'f':
+ *(ptr++) = '\014';
+ break;
- case '\\': *(ptr++) = '\\'; break;
+ case 't':
+ *(ptr++) = '\t';
+ break;
- case '^': *(ptr++) = '^'; break;
+ case '\\':
+ *(ptr++) = '\\';
+ break;
- case ',': *(ptr++) = ','; break;
+ case '^':
+ *(ptr++) = '^';
+ break;
- case ':': *(ptr++) = ':'; break;
+ case ',':
+ *(ptr++) = ',';
+ break;
- case '\n':
- continue;
+ case ':':
+ *(ptr++) = ':';
+ break;
- default:
- _nc_warning("Illegal character %s in \\ sequence",
- _tracechar((unsigned char)ch));
- *(ptr++) = (char)ch;
- } /* endswitch (ch) */
- } /* endelse (ch < '0' || ch > '7') */
- } /* end else if (ch == '\\') */
- else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
- /* newlines embedded in a terminfo string are ignored */
- ignored = TRUE;
- } else {
- *(ptr++) = (char)ch;
- }
+ case '\n':
+ continue;
- if (!ignored) {
- last_ch = ch;
- count ++;
- }
- ignored = FALSE;
+ default:
+ _nc_warning("Illegal character %s in \\ sequence",
+ unctrl(ch));
+ *(ptr++) = (char) ch;
+ } /* endswitch (ch) */
+ } /* endelse (ch < '0' || ch > '7') */
+ }
+ /* end else if (ch == '\\') */
+ else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
+ /* newlines embedded in a terminfo string are ignored */
+ ignored = TRUE;
+ } else {
+ *(ptr++) = (char) ch;
+ }
- if (count > MAXCAPLEN)
- _nc_warning("Very long string found. Missing separator?");
- } /* end while */
+ if (!ignored) {
+ last_ch = ch;
+ count++;
+ }
+ ignored = FALSE;
- *ptr = '\0';
+ if (count > MAXCAPLEN && !long_warning) {
+ _nc_warning("Very long string found. Missing separator?");
+ long_warning = TRUE;
+ }
+ } /* end while */
+
+ *ptr = '\0';
- return(ch);
+ return (ch);
}
/*
@@ -579,7 +604,8 @@ bool ignored = FALSE;
* get_token() call.
*/
-void _nc_push_token(int tokclass)
+void
+_nc_push_token(int tokclass)
{
/*
* This implementation is kind of bogus, it will fail if we ever do
@@ -591,23 +617,24 @@ void _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));
}
/*
* Panic mode error recovery - skip everything until a "ch" is found.
*/
-void _nc_panic_mode(char ch)
+void
+_nc_panic_mode(char ch)
{
- int c;
-
- for (;;) {
- c = next_char();
- if (c == ch)
- return;
- if (c == EOF)
- return;
- }
+ int c;
+
+ for (;;) {
+ c = next_char();
+ if (c == ch)
+ return;
+ if (c == EOF)
+ return;
+ }
}
/*****************************************************************************
@@ -630,16 +657,17 @@ static FILE *yyin; /* scanner's input file descriptor */
* non-null.
*/
-void _nc_reset_input(FILE *fp, char *buf)
+void
+_nc_reset_input(FILE * fp, char *buf)
{
- pushtype = NO_PUSHBACK;
- pushname[0] = '\0';
- yyin = fp;
- bufstart = bufptr = buf;
- _nc_curr_file_pos = 0L;
- if (fp != 0)
- _nc_curr_line = 0;
- _nc_curr_col = 0;
+ pushtype = NO_PUSHBACK;
+ pushname[0] = '\0';
+ yyin = fp;
+ bufstart = bufptr = buf;
+ _nc_curr_file_pos = 0L;
+ if (fp != 0)
+ _nc_curr_line = 0;
+ _nc_curr_col = 0;
}
/*
@@ -650,12 +678,12 @@ void _nc_reset_input(FILE *fp, char *buf)
static int
last_char(void)
{
- size_t len = strlen(bufptr);
- while (len--) {
- if (!isspace(bufptr[len]))
- return bufptr[len];
- }
- return 0;
+ size_t len = strlen(bufptr);
+ while (len--) {
+ if (!isspace(bufptr[len]))
+ return bufptr[len];
+ }
+ return 0;
}
/*
@@ -675,17 +703,14 @@ last_char(void)
static int
next_char(void)
{
- if (!yyin)
- {
+ if (!yyin) {
if (*bufptr == '\0')
- return(EOF);
+ return (EOF);
if (*bufptr == '\n') {
_nc_curr_line++;
_nc_curr_col = 0;
}
- }
- else if (!bufptr || !*bufptr)
- {
+ } else if (!bufptr || !*bufptr) {
/*
* In theory this could be recoded to do its I/O one
* character at a time, saving the buffer space. In
@@ -697,15 +722,15 @@ next_char(void)
size_t len;
do {
- _nc_curr_file_pos = ftell(yyin);
+ _nc_curr_file_pos = ftell(yyin);
- if ((bufstart = fgets(line, LEXBUFSIZ, yyin)) != NULL) {
- _nc_curr_line++;
- _nc_curr_col = 0;
- }
- bufptr = bufstart;
- } while
- (bufstart != NULL && line[0] == '#');
+ if ((bufstart = fgets(line, LEXBUFSIZ, yyin)) != NULL) {
+ _nc_curr_line++;
+ _nc_curr_col = 0;
+ }
+ bufptr = bufstart;
+ } while
+ (bufstart != NULL && line[0] == '#');
if (bufstart == NULL)
return (EOF);
@@ -718,10 +743,10 @@ next_char(void)
* files on OS/2, etc.
*/
if ((len = strlen(bufptr)) > 1) {
- if (bufptr[len-1] == '\n'
- && bufptr[len-2] == '\r') {
- bufptr[len-2] = '\n';
- bufptr[len-1] = '\0';
+ if (bufptr[len - 1] == '\n'
+ && bufptr[len - 2] == '\r') {
+ bufptr[len - 2] = '\n';
+ bufptr[len - 1] = '\0';
}
}
}
@@ -729,28 +754,31 @@ next_char(void)
first_column = (bufptr == bufstart);
_nc_curr_col++;
- return(*bufptr++);
+ return (*bufptr++);
}
-static void push_back(char c)
+static void
+push_back(char c)
/* push a character back onto the input stream */
{
if (bufptr == bufstart)
- _nc_syserr_abort("Can't backspace off beginning of line");
+ _nc_syserr_abort("Can't backspace off beginning of line");
*--bufptr = c;
}
-static long stream_pos(void)
+static long
+stream_pos(void)
/* return our current character position in the input stream */
{
return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
}
-static bool end_of_stream(void)
+static bool
+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 203ec89ed359..d9d9c0aa52e8 100644
--- a/contrib/ncurses/ncurses/tinfo/free_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/free_ttype.c
@@ -44,7 +44,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: free_ttype.c,v 1.2 1999/03/01 00:30:35 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.3 2000/03/19 02:03:07 tom Exp $")
void _nc_free_termtype(TERMTYPE *ptr)
{
@@ -62,6 +62,7 @@ void _nc_free_termtype(TERMTYPE *ptr)
#if NCURSES_XNAMES
bool _nc_user_definable = TRUE;
+bool _nc_disable_period = FALSE; /* used by tic -a option */
int use_extended_names(bool flag)
{
diff --git a/contrib/ncurses/ncurses/tinfo/init_keytry.c b/contrib/ncurses/ncurses/tinfo/init_keytry.c
index a720da181e5e..1134480f8def 100644
--- a/contrib/ncurses/ncurses/tinfo/init_keytry.c
+++ b/contrib/ncurses/ncurses/tinfo/init_keytry.c
@@ -32,7 +32,7 @@
/* cursor_visible,cursor_normal,cursor_invisible */
#include <tic.h> /* struct tinfo_fkeys */
-MODULE_ID("$Id: init_keytry.c,v 1.2 1999/09/11 17:32:57 Jeffrey.Honig Exp $")
+MODULE_ID("$Id: init_keytry.c,v 1.3 2000/03/12 02:55:50 Todd.C.Miller Exp $")
/*
** _nc_init_keytry()
@@ -41,7 +41,7 @@ MODULE_ID("$Id: init_keytry.c,v 1.2 1999/09/11 17:32:57 Jeffrey.Honig Exp $")
**
*/
-#ifdef BROKEN_LINKER
+#if BROKEN_LINKER
#undef _nc_tinfo_fkeys
#endif
@@ -51,7 +51,7 @@ MODULE_ID("$Id: init_keytry.c,v 1.2 1999/09/11 17:32:57 Jeffrey.Honig Exp $")
/* LINT_PREPRO
#endif*/
-#ifdef BROKEN_LINKER
+#if BROKEN_LINKER
struct tinfo_fkeys *_nc_tinfo_fkeysf(void)
{
return _nc_tinfo_fkeys;
diff --git a/contrib/ncurses/ncurses/tinfo/lib_acs.c b/contrib/ncurses/ncurses/tinfo/lib_acs.c
index d3c782e8e664..6f0779157413 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_acs.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_acs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 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 *
@@ -36,9 +36,9 @@
#include <curses.priv.h>
#include <term.h> /* ena_acs, acs_chars */
-MODULE_ID("$Id: lib_acs.c,v 1.15 1999/02/18 11:31:43 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.16 1999/10/30 23:00:16 tom Exp $")
-chtype acs_map[ACS_LEN];
+chtype acs_map[ACS_LEN] = { 0 };
void _nc_init_acs(void)
{
diff --git a/contrib/ncurses/ncurses/tinfo/lib_cur_term.c b/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
index 3250147c8066..7d0aa127d9db 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 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,9 +40,9 @@
#include <term_entry.h> /* TTY, cur_term */
#include <termcap.h> /* ospeed */
-MODULE_ID("$Id: lib_cur_term.c,v 1.8 1999/07/24 20:08:19 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.9 1999/10/30 23:00:16 tom Exp $")
-TERMINAL *cur_term;
+TERMINAL *cur_term = 0;
TERMINAL *set_curterm(TERMINAL *termp)
{
diff --git a/contrib/ncurses/ncurses/tinfo/lib_napms.c b/contrib/ncurses/ncurses/tinfo/lib_napms.c
index a85304bf1cb6..1bd5c647f029 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_napms.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_napms.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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_napms.c
*
@@ -43,9 +42,10 @@
#if HAVE_NANOSLEEP
#include <time.h>
+#if HAVE_SYS_TIME_H
+#include <sys/time.h> /* needed for MacOS X DP3 */
+#endif
#elif USE_FUNC_POLL
-#include <stropts.h>
-#include <poll.h>
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@@ -58,31 +58,32 @@
#endif
#endif
-MODULE_ID("$Id: lib_napms.c,v 1.6 1999/10/21 23:01:41 tom Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.9 2000/04/29 23:42:56 tom Exp $")
-int napms(int ms)
+int
+napms(int ms)
{
- T((T_CALLED("napms(%d)"), ms));
+ T((T_CALLED("napms(%d)"), ms));
#if HAVE_NANOSLEEP
- {
- struct timespec ts;
- ts.tv_sec = ms / 1000;
- ts.tv_nsec = (ms % 1000) * 1000000;
- nanosleep(&ts, NULL);
- }
+ {
+ struct timespec ts;
+ ts.tv_sec = ms / 1000;
+ ts.tv_nsec = (ms % 1000) * 1000000;
+ nanosleep(&ts, NULL);
+ }
#elif USE_FUNC_POLL
- {
- struct pollfd fds[1];
- poll(fds, 0, ms);
- }
+ {
+ struct pollfd fds[1];
+ poll(fds, 0, ms);
+ }
#elif HAVE_SELECT
- {
- struct timeval tval;
- tval.tv_sec = ms / 1000;
- tval.tv_usec = (ms % 1000) * 1000;
- select(0, NULL, NULL, NULL, &tval);
- }
+ {
+ struct timeval tval;
+ tval.tv_sec = ms / 1000;
+ tval.tv_usec = (ms % 1000) * 1000;
+ select(0, NULL, NULL, NULL, &tval);
+ }
#endif
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_options.c b/contrib/ncurses/ncurses/tinfo/lib_options.c
index 0bc14156d674..b58602af72bb 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_options.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_options.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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_options.c
**
@@ -41,168 +40,163 @@
#include <curses.priv.h>
-#include <term.h> /* keypad_xmit, keypad_local, meta_on, meta_off */
- /* cursor_visible,cursor_normal,cursor_invisible */
+#include <term.h>
-MODULE_ID("$Id: lib_options.c,v 1.36 1999/10/22 21:38:57 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.39 2000/03/12 00:19:11 tom Exp $")
-int idlok(WINDOW *win, bool flag)
+int
+idlok(WINDOW *win, bool flag)
{
- T((T_CALLED("idlok(%p,%d)"), win, flag));
+ T((T_CALLED("idlok(%p,%d)"), win, flag));
- if (win) {
- _nc_idlok = win->_idlok = flag && (has_il() || change_scroll_region);
- returnCode(OK);
- }
- else
- returnCode(ERR);
+ if (win) {
+ _nc_idlok = win->_idlok = (flag && (has_il() || change_scroll_region));
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
-
-void idcok(WINDOW *win, bool flag)
+void
+idcok(WINDOW *win, bool flag)
{
- T((T_CALLED("idcok(%p,%d)"), win, flag));
+ T((T_CALLED("idcok(%p,%d)"), win, flag));
- if (win)
- _nc_idcok = win->_idcok = flag && has_ic();
+ if (win)
+ _nc_idcok = win->_idcok = (flag && has_ic());
- returnVoid;
+ returnVoid;
}
-int halfdelay(int t)
+int
+halfdelay(int t)
{
- T((T_CALLED("halfdelay(%d)"), t));
+ T((T_CALLED("halfdelay(%d)"), t));
- if (t < 1 || t > 255)
- returnCode(ERR);
+ if (t < 1 || t > 255)
+ returnCode(ERR);
- cbreak();
- SP->_cbreak = t+1;
- returnCode(OK);
+ cbreak();
+ SP->_cbreak = t + 1;
+ returnCode(OK);
}
-int nodelay(WINDOW *win, bool flag)
+int
+nodelay(WINDOW *win, bool flag)
{
- T((T_CALLED("nodelay(%p,%d)"), win, flag));
+ T((T_CALLED("nodelay(%p,%d)"), win, flag));
- if (win) {
- if (flag == TRUE)
+ if (win) {
+ if (flag == TRUE)
win->_delay = 0;
- else win->_delay = -1;
- returnCode(OK);
- }
else
- returnCode(ERR);
+ win->_delay = -1;
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
-int notimeout(WINDOW *win, bool f)
+int
+notimeout(WINDOW *win, bool f)
{
- T((T_CALLED("notimout(%p,%d)"), win, f));
+ T((T_CALLED("notimout(%p,%d)"), win, f));
- if (win) {
- win->_notimeout = f;
- returnCode(OK);
- }
- else
- returnCode(ERR);
+ if (win) {
+ win->_notimeout = f;
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
-void wtimeout(WINDOW *win, int delay)
+void
+wtimeout(WINDOW *win, int delay)
{
- T((T_CALLED("wtimeout(%p,%d)"), win, delay));
+ T((T_CALLED("wtimeout(%p,%d)"), win, delay));
- if (win) {
- win->_delay = delay;
- }
+ if (win) {
+ win->_delay = delay;
+ }
}
-int keypad(WINDOW *win, bool flag)
+int
+keypad(WINDOW *win, bool flag)
{
- T((T_CALLED("keypad(%p,%d)"), win, flag));
+ T((T_CALLED("keypad(%p,%d)"), win, flag));
- if (win) {
- win->_use_keypad = flag;
- returnCode(_nc_keypad(flag));
- }
- else
- returnCode(ERR);
+ if (win) {
+ win->_use_keypad = flag;
+ returnCode(_nc_keypad(flag));
+ } else
+ returnCode(ERR);
}
-
-int meta(WINDOW *win GCC_UNUSED, bool flag)
+int
+meta(WINDOW *win GCC_UNUSED, bool flag)
{
- /* Ok, we stay relaxed and don't signal an error if win is NULL */
- T((T_CALLED("meta(%p,%d)"), win, flag));
-
- SP->_use_meta = flag;
-
- if (flag && meta_on)
- {
- TPUTS_TRACE("meta_on");
- putp(meta_on);
- }
- else if (! flag && meta_off)
- {
- TPUTS_TRACE("meta_off");
- putp(meta_off);
- }
- returnCode(OK);
+ /* Ok, we stay relaxed and don't signal an error if win is NULL */
+ T((T_CALLED("meta(%p,%d)"), win, flag));
+
+ SP->_use_meta = flag;
+
+ if (flag && meta_on) {
+ TPUTS_TRACE("meta_on");
+ putp(meta_on);
+ } else if (!flag && meta_off) {
+ TPUTS_TRACE("meta_off");
+ putp(meta_off);
+ }
+ returnCode(OK);
}
/* curs_set() moved here to narrow the kernel interface */
-int curs_set(int vis)
+int
+curs_set(int vis)
{
-int cursor = SP->_cursor;
-
- T((T_CALLED("curs_set(%d)"), vis));
-
- if (vis < 0 || vis > 2)
- returnCode(ERR);
-
- if (vis == cursor)
- returnCode(cursor);
-
- switch(vis) {
- case 2:
- if (cursor_visible)
- {
- TPUTS_TRACE("cursor_visible");
- putp(cursor_visible);
- }
- else
- returnCode(ERR);
- break;
- case 1:
- if (cursor_normal)
- {
- TPUTS_TRACE("cursor_normal");
- putp(cursor_normal);
- }
- else
- returnCode(ERR);
- break;
- case 0:
- if (cursor_invisible)
- {
- TPUTS_TRACE("cursor_invisible");
- putp(cursor_invisible);
- }
- else
- returnCode(ERR);
- break;
- }
- SP->_cursor = vis;
- _nc_flush();
-
- returnCode(cursor==-1 ? 1 : cursor);
+ int cursor = SP->_cursor;
+
+ T((T_CALLED("curs_set(%d)"), vis));
+
+ if (vis < 0 || vis > 2)
+ returnCode(ERR);
+
+ if (vis == cursor)
+ returnCode(cursor);
+
+ switch (vis) {
+ case 2:
+ if (cursor_visible) {
+ TPUTS_TRACE("cursor_visible");
+ putp(cursor_visible);
+ } else
+ returnCode(ERR);
+ break;
+ case 1:
+ if (cursor_normal) {
+ TPUTS_TRACE("cursor_normal");
+ putp(cursor_normal);
+ } else
+ returnCode(ERR);
+ break;
+ case 0:
+ if (cursor_invisible) {
+ TPUTS_TRACE("cursor_invisible");
+ putp(cursor_invisible);
+ } else
+ returnCode(ERR);
+ break;
+ }
+ SP->_cursor = vis;
+ _nc_flush();
+
+ returnCode(cursor == -1 ? 1 : cursor);
}
-int typeahead(int fd)
+int
+typeahead(int fd)
{
- T((T_CALLED("typeahead(%d)"), fd));
- SP->_checkfd = fd;
- returnCode(OK);
+ T((T_CALLED("typeahead(%d)"), fd));
+ SP->_checkfd = fd;
+ returnCode(OK);
}
/*
@@ -213,18 +207,20 @@ int typeahead(int fd)
*/
#ifdef NCURSES_EXT_FUNCS
-static int has_key_internal(int keycode, struct tries *tp)
+static int
+has_key_internal(int keycode, struct tries *tp)
{
if (tp == 0)
- return(FALSE);
+ return (FALSE);
else if (tp->value == keycode)
- return(TRUE);
+ return (TRUE);
else
- return(has_key_internal(keycode, tp->child)
- || has_key_internal(keycode, tp->sibling));
+ return (has_key_internal(keycode, tp->child)
+ || has_key_internal(keycode, tp->sibling));
}
-int has_key(int keycode)
+int
+has_key(int keycode)
{
T((T_CALLED("has_key(%d)"), keycode));
returnCode(has_key_internal(keycode, SP->_keytry));
@@ -238,24 +234,22 @@ int has_key(int keycode)
* flush, then the next wgetch may get the escape sequence that corresponds to
* the terminal state _before_ switching modes.
*/
-int _nc_keypad(bool flag)
+int
+_nc_keypad(bool flag)
{
- if (flag && keypad_xmit)
- {
- TPUTS_TRACE("keypad_xmit");
- putp(keypad_xmit);
- _nc_flush();
- }
- else if (! flag && keypad_local)
- {
- TPUTS_TRACE("keypad_local");
- putp(keypad_local);
- _nc_flush();
- }
-
- if (flag && !SP->_tried) {
- _nc_init_keytry();
- SP->_tried = TRUE;
- }
- return(OK);
+ if (flag && keypad_xmit) {
+ TPUTS_TRACE("keypad_xmit");
+ putp(keypad_xmit);
+ _nc_flush();
+ } else if (!flag && keypad_local) {
+ TPUTS_TRACE("keypad_local");
+ putp(keypad_local);
+ _nc_flush();
+ }
+
+ if (flag && !SP->_tried) {
+ _nc_init_keytry();
+ SP->_tried = TRUE;
+ }
+ return (OK);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_raw.c b/contrib/ncurses/ncurses/tinfo/lib_raw.c
index 61b422c1fb88..6033ed9c10c3 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_raw.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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> *
****************************************************************************/
-
/*
* raw.c
*
@@ -47,21 +46,20 @@
*/
#include <curses.priv.h>
-#include <term.h> /* cur_term */
+#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.3 1999/03/06 22:28:24 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.7 2000/02/13 01:01:26 tom Exp $")
#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#if HAVE_SYS_TERMIO_H
-#include <sys/termio.h> /* needed for ISC */
+#include <sys/termio.h> /* needed for ISC */
#endif
#ifdef __EMX__
#include <io.h>
-#include <fcntl.h>
#endif
#define COOKED_INPUT (IXON|BRKINT|PARMRK)
@@ -74,160 +72,165 @@ MODULE_ID("$Id: lib_raw.c,v 1.3 1999/03/06 22:28:24 tom Exp $")
#define AFTER(s)
#endif /* TRACE */
-int raw(void)
+int
+raw(void)
{
- T((T_CALLED("raw()")));
- if (SP != 0 && cur_term != 0) {
+ T((T_CALLED("raw()")));
+ if (SP != 0 && cur_term != 0) {
- SP->_raw = TRUE;
- SP->_cbreak = 1;
+ SP->_raw = TRUE;
+ SP->_cbreak = 1;
#ifdef __EMX__
- setmode(SP->_ifd, O_BINARY);
+ setmode(SP->_ifd, O_BINARY);
#endif
#ifdef TERMIOS
- BEFORE("raw");
- cur_term->Nttyb.c_lflag &= ~(ICANON|ISIG);
- cur_term->Nttyb.c_iflag &= ~(COOKED_INPUT);
- cur_term->Nttyb.c_cc[VMIN] = 1;
- cur_term->Nttyb.c_cc[VTIME] = 0;
- AFTER("raw");
+ BEFORE("raw");
+ cur_term->Nttyb.c_lflag &= ~(ICANON | ISIG | IEXTEN);
+ cur_term->Nttyb.c_iflag &= ~(COOKED_INPUT);
+ cur_term->Nttyb.c_cc[VMIN] = 1;
+ cur_term->Nttyb.c_cc[VTIME] = 0;
+ AFTER("raw");
#else
- cur_term->Nttyb.sg_flags |= RAW;
+ cur_term->Nttyb.sg_flags |= RAW;
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
- }
- returnCode(ERR);
+ returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ }
+ returnCode(ERR);
}
-int cbreak(void)
+int
+cbreak(void)
{
- T((T_CALLED("cbreak()")));
+ T((T_CALLED("cbreak()")));
- SP->_cbreak = 1;
+ SP->_cbreak = 1;
#ifdef __EMX__
- setmode(SP->_ifd, O_BINARY);
+ setmode(SP->_ifd, O_BINARY);
#endif
#ifdef TERMIOS
- BEFORE("cbreak");
- cur_term->Nttyb.c_lflag &= ~ICANON;
- cur_term->Nttyb.c_iflag &= ~ICRNL;
- cur_term->Nttyb.c_lflag |= ISIG;
- cur_term->Nttyb.c_cc[VMIN] = 1;
- cur_term->Nttyb.c_cc[VTIME] = 0;
- AFTER("cbreak");
+ BEFORE("cbreak");
+ cur_term->Nttyb.c_lflag &= ~ICANON;
+ cur_term->Nttyb.c_iflag &= ~ICRNL;
+ cur_term->Nttyb.c_lflag |= ISIG;
+ cur_term->Nttyb.c_cc[VMIN] = 1;
+ cur_term->Nttyb.c_cc[VTIME] = 0;
+ AFTER("cbreak");
#else
- cur_term->Nttyb.sg_flags |= CBREAK;
+ cur_term->Nttyb.sg_flags |= CBREAK;
#endif
- returnCode(_nc_set_tty_mode( &cur_term->Nttyb));
+ returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
}
-void qiflush(void)
+void
+qiflush(void)
{
- T((T_CALLED("qiflush()")));
+ T((T_CALLED("qiflush()")));
- /*
- * Note: this implementation may be wrong. See the comment under
- * intrflush().
- */
+ /*
+ * Note: this implementation may be wrong. See the comment under
+ * intrflush().
+ */
#ifdef TERMIOS
- BEFORE("qiflush");
- cur_term->Nttyb.c_lflag &= ~(NOFLSH);
- AFTER("qiflush");
- (void)_nc_set_tty_mode( &cur_term->Nttyb);
- returnVoid;
+ BEFORE("qiflush");
+ cur_term->Nttyb.c_lflag &= ~(NOFLSH);
+ AFTER("qiflush");
+ (void) _nc_set_tty_mode(&cur_term->Nttyb);
+ returnVoid;
#endif
}
-
-int noraw(void)
+int
+noraw(void)
{
- T((T_CALLED("noraw()")));
+ T((T_CALLED("noraw()")));
- SP->_raw = FALSE;
- SP->_cbreak = 0;
+ SP->_raw = FALSE;
+ SP->_cbreak = 0;
#ifdef __EMX__
- setmode(SP->_ifd, O_TEXT);
+ setmode(SP->_ifd, O_TEXT);
#endif
#ifdef TERMIOS
- BEFORE("noraw");
- cur_term->Nttyb.c_lflag |= ISIG|ICANON;
- cur_term->Nttyb.c_iflag |= COOKED_INPUT;
- AFTER("noraw");
+ BEFORE("noraw");
+ cur_term->Nttyb.c_lflag |= ISIG | ICANON |
+ (cur_term->Ottyb.c_lflag & IEXTEN);
+ cur_term->Nttyb.c_iflag |= COOKED_INPUT;
+ AFTER("noraw");
#else
- cur_term->Nttyb.sg_flags &= ~(RAW|CBREAK);
+ cur_term->Nttyb.sg_flags &= ~(RAW | CBREAK);
#endif
- returnCode(_nc_set_tty_mode( &cur_term->Nttyb));
+ returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
}
-
-int nocbreak(void)
+int
+nocbreak(void)
{
- T((T_CALLED("nocbreak()")));
+ T((T_CALLED("nocbreak()")));
- SP->_cbreak = 0;
+ SP->_cbreak = 0;
#ifdef __EMX__
- setmode(SP->_ifd, O_TEXT);
+ setmode(SP->_ifd, O_TEXT);
#endif
#ifdef TERMIOS
- BEFORE("nocbreak");
- cur_term->Nttyb.c_lflag |= ICANON;
- cur_term->Nttyb.c_iflag |= ICRNL;
- AFTER("nocbreak");
+ BEFORE("nocbreak");
+ cur_term->Nttyb.c_lflag |= ICANON;
+ cur_term->Nttyb.c_iflag |= ICRNL;
+ AFTER("nocbreak");
#else
- cur_term->Nttyb.sg_flags &= ~CBREAK;
+ cur_term->Nttyb.sg_flags &= ~CBREAK;
#endif
- returnCode(_nc_set_tty_mode( &cur_term->Nttyb));
+ returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
}
-void noqiflush(void)
+void
+noqiflush(void)
{
- T((T_CALLED("noqiflush()")));
+ T((T_CALLED("noqiflush()")));
- /*
- * Note: this implementation may be wrong. See the comment under
- * intrflush().
- */
+ /*
+ * Note: this implementation may be wrong. See the comment under
+ * intrflush().
+ */
#ifdef TERMIOS
- BEFORE("noqiflush");
- cur_term->Nttyb.c_lflag |= NOFLSH;
- AFTER("noqiflush");
- (void)_nc_set_tty_mode( &cur_term->Nttyb);
- returnVoid;
+ BEFORE("noqiflush");
+ cur_term->Nttyb.c_lflag |= NOFLSH;
+ AFTER("noqiflush");
+ (void) _nc_set_tty_mode(&cur_term->Nttyb);
+ returnVoid;
#endif
}
-int intrflush(WINDOW *win GCC_UNUSED, bool flag)
+int
+intrflush(WINDOW *win GCC_UNUSED, bool flag)
{
- T((T_CALLED("intrflush(%d)"), flag));
+ T((T_CALLED("intrflush(%d)"), flag));
- /*
- * This call does the same thing as the qiflush()/noqiflush()
- * pair. We know for certain that SVr3 intrflush() tweaks the
- * NOFLSH bit; on the other hand, the match (in the SVr4 man
- * pages) between the language describing NOFLSH in termio(7)
- * and the language describing qiflush()/noqiflush() in
- * curs_inopts(3x) is too exact to be coincidence.
- */
+ /*
+ * This call does the same thing as the qiflush()/noqiflush() pair. We
+ * know for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the
+ * other hand, the match (in the SVr4 man pages) between the language
+ * describing NOFLSH in termio(7) and the language describing
+ * qiflush()/noqiflush() in curs_inopts(3x) is too exact to be coincidence.
+ */
#ifdef TERMIOS
- BEFORE("intrflush");
- if (flag)
- cur_term->Nttyb.c_lflag &= ~(NOFLSH);
- else
- cur_term->Nttyb.c_lflag |= (NOFLSH);
- AFTER("intrflush");
- returnCode(_nc_set_tty_mode( &cur_term->Nttyb));
+ BEFORE("intrflush");
+ if (flag)
+ cur_term->Nttyb.c_lflag &= ~(NOFLSH);
+ else
+ cur_term->Nttyb.c_lflag |= (NOFLSH);
+ AFTER("intrflush");
+ returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
#else
- returnCode(ERR);
+ returnCode(ERR);
#endif
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_setup.c b/contrib/ncurses/ncurses/tinfo/lib_setup.c
index 64aa73fa8cf3..50c330eb5739 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_setup.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_setup.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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> *
****************************************************************************/
-
/*
* Terminal setup routines common to termcap and terminfo:
*
@@ -40,16 +39,16 @@
*/
#include <curses.priv.h>
-#include <tic.h> /* for MAX_NAME_SIZE */
+#include <tic.h> /* for MAX_NAME_SIZE */
#include <term_entry.h>
#if defined(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_setup.c,v 1.55 1999/08/21 23:06:08 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.59 2000/02/13 01:01:26 tom Exp $")
/****************************************************************************
*
@@ -95,120 +94,116 @@ static int _use_env = TRUE;
static void do_prototype(void);
-void use_env(bool f)
+void
+use_env(bool f)
{
- _use_env = f;
+ _use_env = f;
}
-int LINES, COLS, TABSIZE;
+int LINES = 0, COLS = 0, TABSIZE = 0;
-static void _nc_get_screensize(int *linep, int *colp)
+static void
+_nc_get_screensize(int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
{
- /* figure out the size of the screen */
- T(("screen size: terminfo lines = %d columns = %d", lines, columns));
+ /* figure out the size of the screen */
+ T(("screen size: terminfo lines = %d columns = %d", lines, columns));
- if (!_use_env)
- {
- *linep = (int)lines;
- *colp = (int)columns;
- }
- else /* usually want to query LINES and COLUMNS from environment */
- {
- int value;
+ if (!_use_env) {
+ *linep = (int) lines;
+ *colp = (int) columns;
+ } else { /* usually want to query LINES and COLUMNS from environment */
+ int value;
- *linep = *colp = 0;
+ *linep = *colp = 0;
- /* first, look for environment variables */
- if ((value = _nc_getenv_num("LINES")) > 0) {
- *linep = value;
- }
- if ((value = _nc_getenv_num("COLUMNS")) > 0) {
- *colp = value;
- }
- T(("screen size: environment LINES = %d COLUMNS = %d",*linep,*colp));
+ /* first, look for environment variables */
+ if ((value = _nc_getenv_num("LINES")) > 0) {
+ *linep = value;
+ }
+ if ((value = _nc_getenv_num("COLUMNS")) > 0) {
+ *colp = value;
+ }
+ T(("screen size: environment LINES = %d COLUMNS = %d", *linep, *colp));
#ifdef __EMX__
- if (*linep <= 0 || *colp <= 0)
- {
- int screendata[2];
- _scrsize(screendata);
- *colp = screendata[0];
- *linep = screendata[1];
- T(("EMX screen size: environment LINES = %d COLUMNS = %d",*linep,*colp));
- }
+ if (*linep <= 0 || *colp <= 0) {
+ int screendata[2];
+ _scrsize(screendata);
+ *colp = screendata[0];
+ *linep = screendata[1];
+ T(("EMX screen size: environment LINES = %d COLUMNS = %d",
+ *linep, *colp));
+ }
#endif
#if HAVE_SIZECHANGE
- /* if that didn't work, maybe we can try asking the OS */
- if (*linep <= 0 || *colp <= 0)
- {
- if (isatty(cur_term->Filedes))
- {
- STRUCT_WINSIZE size;
-
- errno = 0;
- do {
- if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) < 0
- && errno != EINTR)
- goto failure;
- } while
- (errno == EINTR);
-
- /*
- * Solaris lets users override either dimension with an
- * environment variable.
- */
- if (*linep <= 0)
- *linep = WINSIZE_ROWS(size);
- if (*colp <= 0)
- *colp = WINSIZE_COLS(size);
- }
- /* FALLTHRU */
- failure:;
+ /* if that didn't work, maybe we can try asking the OS */
+ if (*linep <= 0 || *colp <= 0) {
+ if (isatty(cur_term->Filedes)) {
+ STRUCT_WINSIZE size;
+
+ errno = 0;
+ do {
+ if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) < 0
+ && errno != EINTR)
+ goto failure;
+ } while
+ (errno == EINTR);
+
+ /*
+ * Solaris lets users override either dimension with an
+ * environment variable.
+ */
+ if (*linep <= 0)
+ *linep = WINSIZE_ROWS(size);
+ if (*colp <= 0)
+ *colp = WINSIZE_COLS(size);
}
+ /* FALLTHRU */
+ failure:;
+ }
#endif /* HAVE_SIZECHANGE */
- /* if we can't get dynamic info about the size, use static */
- if (*linep <= 0 || *colp <= 0)
- if (lines > 0 && columns > 0)
- {
- *linep = (int)lines;
- *colp = (int)columns;
- }
-
- /* the ultimate fallback, assume fixed 24x80 size */
- if (*linep <= 0 || *colp <= 0)
- {
- *linep = 24;
- *colp = 80;
+ /* if we can't get dynamic info about the size, use static */
+ if (*linep <= 0 || *colp <= 0)
+ if (lines > 0 && columns > 0) {
+ *linep = (int) lines;
+ *colp = (int) columns;
}
- /*
- * Put the derived values back in the screen-size caps, so
- * tigetnum() and tgetnum() will do the right thing.
- */
- lines = (short)(*linep);
- columns = (short)(*colp);
+ /* the ultimate fallback, assume fixed 24x80 size */
+ if (*linep <= 0 || *colp <= 0) {
+ *linep = 24;
+ *colp = 80;
}
- T(("screen size is %dx%d", *linep, *colp));
+ /*
+ * Put the derived values back in the screen-size caps, so
+ * tigetnum() and tgetnum() will do the right thing.
+ */
+ lines = (short) (*linep);
+ columns = (short) (*colp);
+ }
+
+ T(("screen size is %dx%d", *linep, *colp));
- if (init_tabs != -1)
- TABSIZE = (int)init_tabs;
- else
- TABSIZE = 8;
- T(("TABSIZE = %d", TABSIZE));
+ if (VALID_NUMERIC(init_tabs))
+ TABSIZE = (int) init_tabs;
+ else
+ TABSIZE = 8;
+ T(("TABSIZE = %d", TABSIZE));
}
#if USE_SIZECHANGE
-void _nc_update_screensize(void)
+void
+_nc_update_screensize(void)
{
- int my_lines, my_cols;
+ int my_lines, my_cols;
- _nc_get_screensize(&my_lines, &my_cols);
- if (SP != 0 && SP->_resize != 0)
- SP->_resize(my_lines, my_cols);
+ _nc_get_screensize(&my_lines, &my_cols);
+ if (SP != 0 && SP->_resize != 0)
+ SP->_resize(my_lines, my_cols);
}
#endif
@@ -235,52 +230,53 @@ void _nc_update_screensize(void)
}
#if USE_DATABASE
-static int grab_entry(const char *const tn, TERMTYPE *const tp)
+static int
+grab_entry(const char *const tn, TERMTYPE * const tp)
/* return 1 if entry found, 0 if not found, -1 if database not accessible */
{
- char filename[PATH_MAX];
- int status;
+ char filename[PATH_MAX];
+ int status;
- /*
- * $TERM shouldn't contain pathname delimiters.
- */
- if (strchr(tn, '/'))
- return 0;
+ /*
+ * $TERM shouldn't contain pathname delimiters.
+ */
+ if (strchr(tn, '/'))
+ return 0;
- if ((status = _nc_read_entry(tn, filename, tp)) != 1) {
+ if ((status = _nc_read_entry(tn, filename, tp)) != 1) {
#ifndef PURE_TERMINFO
- /*
- * Try falling back on the termcap file.
- * Note: allowing this call links the entire terminfo/termcap
- * compiler into the startup code. It's preferable to build a
- * real terminfo database and use that.
- */
- status = _nc_read_termcap_entry(tn, tp);
-#endif /* PURE_TERMINFO */
-
- }
-
/*
- * If we have an entry, force all of the cancelled strings to null
- * pointers so we don't have to test them in the rest of the library.
- * (The terminfo compiler bypasses this logic, since it must know if
- * a string is cancelled, for merging entries).
+ * Try falling back on the termcap file.
+ * Note: allowing this call links the entire terminfo/termcap
+ * compiler into the startup code. It's preferable to build a
+ * real terminfo database and use that.
*/
- if (status == 1) {
- int n;
- for_each_boolean(n,tp)
- if (!VALID_BOOLEAN(tp->Booleans[n]))
- tp->Booleans[n] = FALSE;
- for_each_string(n,tp)
- if (tp->Strings[n] == CANCELLED_STRING)
- tp->Strings[n] = ABSENT_STRING;
- }
- return(status);
+ status = _nc_read_termcap_entry(tn, tp);
+#endif /* PURE_TERMINFO */
+
+ }
+
+ /*
+ * If we have an entry, force all of the cancelled strings to null
+ * pointers so we don't have to test them in the rest of the library.
+ * (The terminfo compiler bypasses this logic, since it must know if
+ * a string is cancelled, for merging entries).
+ */
+ if (status == 1) {
+ int n;
+ for_each_boolean(n, tp)
+ if (!VALID_BOOLEAN(tp->Booleans[n]))
+ tp->Booleans[n] = FALSE;
+ for_each_string(n, tp)
+ if (tp->Strings[n] == CANCELLED_STRING)
+ tp->Strings[n] = ABSENT_STRING;
+ }
+ return (status);
}
#endif
-char ttytype[NAMESIZE];
+char ttytype[NAMESIZE] = "";
/*
* setupterm(termname, Filedes, errret)
@@ -290,107 +286,103 @@ char ttytype[NAMESIZE];
*
*/
-int setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
+int
+setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
{
-struct term *term_ptr;
-int status;
+ struct term *term_ptr;
+ int status;
- T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, errret));
+ T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, errret));
- if (tname == 0) {
- tname = getenv("TERM");
- if (tname == 0 || *tname == '\0') {
- ret_error0(-1, "TERM environment variable not set.\n");
- }
- }
- if (strlen(tname) > MAX_NAME_SIZE) {
- ret_error(-1, "TERM environment must be <= %d characters.\n",
- MAX_NAME_SIZE);
+ if (tname == 0) {
+ tname = getenv("TERM");
+ if (tname == 0 || *tname == '\0') {
+ ret_error0(-1, "TERM environment variable not set.\n");
}
+ }
+ if (strlen(tname) > MAX_NAME_SIZE) {
+ ret_error(-1, "TERM environment must be <= %d characters.\n",
+ MAX_NAME_SIZE);
+ }
- T(("your terminal name is %s", tname));
+ T(("your terminal name is %s", tname));
- term_ptr = typeCalloc(TERMINAL, 1);
+ term_ptr = typeCalloc(TERMINAL, 1);
- if (term_ptr == 0) {
- ret_error0(-1, "Not enough memory to create terminal structure.\n") ;
- }
+ if (term_ptr == 0) {
+ ret_error0(-1, "Not enough memory to create terminal structure.\n");
+ }
#if USE_DATABASE
- status = grab_entry(tname, &term_ptr->type);
+ status = grab_entry(tname, &term_ptr->type);
#else
- status = 0;
+ status = 0;
#endif
- /* try fallback list if entry on disk */
- if (status != 1)
- {
- const TERMTYPE *fallback = _nc_fallback(tname);
-
- if (fallback)
- {
- term_ptr->type = *fallback;
- status = 1;
- }
- }
-
- if (status == -1)
- {
- ret_error0(-1, "terminals database is inaccessible\n");
- }
- else if (status == 0)
- {
- ret_error(0, "'%s': unknown terminal type.\n", tname);
- }
-
- /*
- * Improve on SVr4 curses. If an application mixes curses and termcap
- * calls, it may call both initscr and tgetent. This is not really a
- * good thing to do, but can happen if someone tries using ncurses with
- * the readline library. The problem we are fixing is that when
- * tgetent calls setupterm, the resulting Ottyb struct in cur_term is
- * zeroed. A subsequent call to endwin uses the zeroed terminal
- * settings rather than the ones saved in initscr. So we check if
- * cur_term appears to contain terminal settings for the same output
- * file as our current call - and copy those terminal settings. (SVr4
- * curses does not do this, however applications that are working
- * around the problem will still work properly with this feature).
- */
- if (cur_term != 0) {
- if (cur_term->Filedes == Filedes)
- term_ptr->Ottyb = cur_term->Ottyb;
- }
-
- set_curterm(term_ptr);
-
- if (command_character && getenv("CC"))
- do_prototype();
-
- strncpy(ttytype, cur_term->type.term_names, NAMESIZE - 1);
- ttytype[NAMESIZE - 1] = '\0';
-
- /*
- * Allow output redirection. This is what SVr3 does.
- * If stdout is directed to a file, screen updates go
- * to standard error.
- */
- if (Filedes == STDOUT_FILENO && !isatty(Filedes))
- Filedes = STDERR_FILENO;
- cur_term->Filedes = Filedes;
-
- _nc_get_screensize(&LINES, &COLS);
-
- if (errret)
- *errret = 1;
+ /* try fallback list if entry on disk */
+ if (status != 1) {
+ const TERMTYPE *fallback = _nc_fallback(tname);
- T((T_CREATE("screen %s %dx%d"), tname, LINES, COLS));
-
- if (generic_type) {
- ret_error(0, "'%s': I need something more specific.\n", tname);
- }
- if (hard_copy) {
- ret_error(1, "'%s': I can't handle hardcopy terminals.\n", tname);
+ if (fallback) {
+ term_ptr->type = *fallback;
+ status = 1;
}
- returnCode(OK);
+ }
+
+ if (status == -1) {
+ ret_error0(-1, "terminals database is inaccessible\n");
+ } else if (status == 0) {
+ ret_error(0, "'%s': unknown terminal type.\n", tname);
+ }
+
+ /*
+ * Improve on SVr4 curses. If an application mixes curses and termcap
+ * calls, it may call both initscr and tgetent. This is not really a
+ * good thing to do, but can happen if someone tries using ncurses with
+ * the readline library. The problem we are fixing is that when
+ * tgetent calls setupterm, the resulting Ottyb struct in cur_term is
+ * zeroed. A subsequent call to endwin uses the zeroed terminal
+ * settings rather than the ones saved in initscr. So we check if
+ * cur_term appears to contain terminal settings for the same output
+ * file as our current call - and copy those terminal settings. (SVr4
+ * curses does not do this, however applications that are working
+ * around the problem will still work properly with this feature).
+ */
+ if (cur_term != 0) {
+ if (cur_term->Filedes == Filedes)
+ term_ptr->Ottyb = cur_term->Ottyb;
+ }
+
+ set_curterm(term_ptr);
+
+ if (command_character && getenv("CC"))
+ do_prototype();
+
+ strncpy(ttytype, cur_term->type.term_names, NAMESIZE - 1);
+ ttytype[NAMESIZE - 1] = '\0';
+
+ /*
+ * Allow output redirection. This is what SVr3 does.
+ * If stdout is directed to a file, screen updates go
+ * to standard error.
+ */
+ if (Filedes == STDOUT_FILENO && !isatty(Filedes))
+ Filedes = STDERR_FILENO;
+ cur_term->Filedes = Filedes;
+
+ _nc_get_screensize(&LINES, &COLS);
+
+ if (errret)
+ *errret = 1;
+
+ T((T_CREATE("screen %s %dx%d"), tname, LINES, COLS));
+
+ if (generic_type) {
+ ret_error(0, "'%s': I need something more specific.\n", tname);
+ }
+ if (hard_copy) {
+ ret_error(1, "'%s': I can't handle hardcopy terminals.\n", tname);
+ }
+ returnCode(OK);
}
/*
@@ -404,19 +396,19 @@ int status;
static void
do_prototype(void)
{
-int i;
-char CC;
-char proto;
-char *tmp;
-
- tmp = getenv("CC");
- CC = *tmp;
- proto = *command_character;
-
- for_each_string(i, &(cur_term->type)) {
- for (tmp = cur_term->type.Strings[i]; *tmp; tmp++) {
- if (*tmp == proto)
- *tmp = CC;
- }
+ int i;
+ char CC;
+ char proto;
+ char *tmp;
+
+ tmp = getenv("CC");
+ CC = *tmp;
+ proto = *command_character;
+
+ for_each_string(i, &(cur_term->type)) {
+ for (tmp = cur_term->type.Strings[i]; *tmp; tmp++) {
+ if (*tmp == proto)
+ *tmp = CC;
}
+ }
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_termcap.c b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
index 8238b368eea3..c47400132fa8 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -39,15 +39,15 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$Id: lib_termcap.c,v 1.29 1999/09/05 01:06:43 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.36 2000/02/13 01:01:26 tom Exp $")
/*
some of the code in here was contributed by:
Magnus Bengtsson, d6mbeng@dtek.chalmers.se
*/
-char *UP;
-char *BC;
+char *UP = 0;
+char *BC = 0;
/***************************************************************************
*
@@ -64,29 +64,30 @@ char *BC;
*
***************************************************************************/
-int tgetent(char *bufp GCC_UNUSED, const char *name)
+int
+tgetent(char *bufp GCC_UNUSED, const char *name)
{
-int errcode;
+ int errcode;
- T((T_CALLED("tgetent()")));
+ T((T_CALLED("tgetent()")));
- setupterm((NCURSES_CONST char *)name, STDOUT_FILENO, &errcode);
+ setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode);
- if (errcode == 1) {
+ if (errcode == 1) {
- if (cursor_left)
- if ((backspaces_with_bs = !strcmp(cursor_left, "\b")) == 0)
- backspace_if_not_bs = cursor_left;
+ if (cursor_left)
+ if ((backspaces_with_bs = !strcmp(cursor_left, "\b")) == 0)
+ backspace_if_not_bs = cursor_left;
- /* we're required to export these */
- if (pad_char != NULL)
- PC = pad_char[0];
- if (cursor_up != NULL)
- UP = cursor_up;
- if (backspace_if_not_bs != NULL)
- BC = backspace_if_not_bs;
+ /* we're required to export these */
+ if (pad_char != NULL)
+ PC = pad_char[0];
+ if (cursor_up != NULL)
+ UP = cursor_up;
+ if (backspace_if_not_bs != NULL)
+ BC = backspace_if_not_bs;
- (void) baudrate(); /* sets ospeed as a side-effect */
+ (void) baudrate(); /* sets ospeed as a side-effect */
/* LINT_PREPRO
#if 0*/
@@ -94,8 +95,8 @@ int errcode;
/* LINT_PREPRO
#endif*/
- }
- returnCode(errcode);
+ }
+ returnCode(errcode);
}
/***************************************************************************
@@ -107,22 +108,23 @@ int errcode;
*
***************************************************************************/
-int tgetflag(NCURSES_CONST char *id)
+int
+tgetflag(NCURSES_CONST char *id)
{
-int i;
-
- T((T_CALLED("tgetflag(%s)"), id));
- if (cur_term != 0) {
- TERMTYPE *tp = &(cur_term->type);
- for_each_boolean(i, tp) {
- const char *capname = ExtBoolname(tp, i, boolcodes);
- if (!strncmp(id, capname, 2)) {
- /* setupterm forces invalid booleans to false */
- returnCode(tp->Booleans[i]);
- }
+ int i;
+
+ T((T_CALLED("tgetflag(%s)"), id));
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_boolean(i, tp) {
+ const char *capname = ExtBoolname(tp, i, boolcodes);
+ if (!strncmp(id, capname, 2)) {
+ /* setupterm forces invalid booleans to false */
+ returnCode(tp->Booleans[i]);
}
}
- returnCode(0); /* Solaris does this */
+ }
+ returnCode(0); /* Solaris does this */
}
/***************************************************************************
@@ -134,23 +136,24 @@ int i;
*
***************************************************************************/
-int tgetnum(NCURSES_CONST char *id)
+int
+tgetnum(NCURSES_CONST char *id)
{
-int i;
-
- T((T_CALLED("tgetnum(%s)"), id));
- if (cur_term != 0) {
- TERMTYPE *tp = &(cur_term->type);
- for_each_number(i, tp) {
- const char *capname = ExtNumname(tp, i, numcodes);
- if (!strncmp(id, capname, 2)) {
- if (!VALID_NUMERIC(tp->Numbers[i]))
- return -1;
- returnCode(tp->Numbers[i]);
- }
+ int i;
+
+ T((T_CALLED("tgetnum(%s)"), id));
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_number(i, tp) {
+ const char *capname = ExtNumname(tp, i, numcodes);
+ if (!strncmp(id, capname, 2)) {
+ if (!VALID_NUMERIC(tp->Numbers[i]))
+ returnCode(ABSENT_NUMERIC);
+ returnCode(tp->Numbers[i]);
}
}
- returnCode(ERR);
+ }
+ returnCode(ABSENT_NUMERIC);
}
/***************************************************************************
@@ -162,30 +165,30 @@ int i;
*
***************************************************************************/
-char *tgetstr(NCURSES_CONST char *id, char **area)
+char *
+tgetstr(NCURSES_CONST char *id, char **area)
{
-int i;
-
- T((T_CALLED("tgetstr(%s,%p)"), id, area));
- if (cur_term != 0) {
- TERMTYPE *tp = &(cur_term->type);
- for_each_string(i, tp) {
- const char *capname = ExtStrname(tp, i, strcodes);
- T(("trying %s", capname));
- if (!strncmp(id, capname, 2)) {
- T(("found match : %s", _nc_visbuf(tp->Strings[i])));
- /* setupterm forces cancelled strings to null */
- if (area != 0
- && *area != 0
- && VALID_STRING(tp->Strings[i])) {
- (void) strcpy(*area, tp->Strings[i]);
- *area += strlen(*area) + 1;
- }
- returnPtr(tp->Strings[i]);
+ int i;
+
+ T((T_CALLED("tgetstr(%s,%p)"), id, area));
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_string(i, tp) {
+ const char *capname = ExtStrname(tp, i, strcodes);
+ if (!strncmp(id, capname, 2)) {
+ TR(TRACE_DATABASE,("found match : %s", _nc_visbuf(tp->Strings[i])));
+ /* setupterm forces canceled strings to null */
+ if (area != 0
+ && *area != 0
+ && VALID_STRING(tp->Strings[i])) {
+ (void) strcpy(*area, tp->Strings[i]);
+ *area += strlen(*area) + 1;
}
+ returnPtr(tp->Strings[i]);
}
}
- returnPtr(NULL);
+ }
+ returnPtr(NULL);
}
/*
@@ -197,8 +200,9 @@ int i;
*
*/
-char *tgoto(const char *string, int x, int y)
+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));
+ 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_ti.c b/contrib/ncurses/ncurses/tinfo/lib_ti.c
index 7b2b2f910f2d..def5ba6d5ea3 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_ti.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_ti.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,71 +31,73 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
#include <curses.priv.h>
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$Id: lib_ti.c,v 1.16 1999/02/28 23:11:28 tom Exp $")
+MODULE_ID("$Id: lib_ti.c,v 1.20 2000/02/13 01:01:26 tom Exp $")
-int tigetflag(NCURSES_CONST char *str)
+int
+tigetflag(NCURSES_CONST char *str)
{
-int i;
-
- T((T_CALLED("tigetflag(%s)"), str));
-
- if (cur_term != 0) {
- TERMTYPE *tp = &(cur_term->type);
- for_each_boolean(i,tp) {
- const char *capname = ExtBoolname(tp, i, boolnames);
- if (!strcmp(str, capname)) {
- /* setupterm forces invalid booleans to false */
- returnCode(tp->Booleans[i]);
- }
+ int i;
+
+ T((T_CALLED("tigetflag(%s)"), str));
+
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_boolean(i, tp) {
+ const char *capname = ExtBoolname(tp, i, boolnames);
+ if (!strcmp(str, capname)) {
+ /* setupterm forces invalid booleans to false */
+ returnCode(tp->Booleans[i]);
}
}
+ }
- returnCode(ABSENT_BOOLEAN);
+ returnCode(ABSENT_BOOLEAN);
}
-int tigetnum(NCURSES_CONST char *str)
+int
+tigetnum(NCURSES_CONST char *str)
{
-int i;
-
- T((T_CALLED("tigetnum(%s)"), str));
-
- if (cur_term != 0) {
- TERMTYPE *tp = &(cur_term->type);
- for_each_number(i, tp) {
- const char *capname = ExtNumname(tp, i, numnames);
- if (!strcmp(str, capname)) {
- if (!VALID_NUMERIC(tp->Numbers[i]))
- return -1;
- returnCode(tp->Numbers[i]);
- }
+ int i;
+
+ T((T_CALLED("tigetnum(%s)"), str));
+
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_number(i, tp) {
+ const char *capname = ExtNumname(tp, i, numnames);
+ if (!strcmp(str, capname)) {
+ if (!VALID_NUMERIC(tp->Numbers[i]))
+ returnCode(ABSENT_NUMERIC);
+ returnCode(tp->Numbers[i]);
}
}
+ }
- returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */
+ returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */
}
-char *tigetstr(NCURSES_CONST char *str)
+char *
+tigetstr(NCURSES_CONST char *str)
{
-int i;
-
- T((T_CALLED("tigetstr(%s)"), str));
-
- if (cur_term != 0) {
- TERMTYPE *tp = &(cur_term->type);
- for_each_string(i, tp) {
- const char *capname = ExtStrname(tp, i, strnames);
- if (!strcmp(str, capname)) {
- /* setupterm forces cancelled strings to null */
- returnPtr(tp->Strings[i]);
- }
+ int i;
+
+ T((T_CALLED("tigetstr(%s)"), str));
+
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_string(i, tp) {
+ const char *capname = ExtStrname(tp, i, strnames);
+ if (!strcmp(str, capname)) {
+ /* setupterm forces cancelled strings to null */
+ returnPtr(tp->Strings[i]);
}
}
+ }
- returnPtr(CANCELLED_STRING);
+ returnPtr(CANCELLED_STRING);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
index d3fd46276e6e..f17d8382e921 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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> *
****************************************************************************/
-
/*
* tputs.c
* delay_output()
@@ -42,210 +41,278 @@
#include <curses.priv.h>
#include <ctype.h>
-#include <term.h> /* padding_baud_rate, xon_xoff */
-#include <termcap.h> /* ospeed */
+#include <term.h> /* padding_baud_rate, xon_xoff */
+#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$Id: lib_tputs.c,v 1.41 1999/10/22 23:31:24 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.47 2000/05/27 23:08:41 tom Exp $")
-char PC; /* used by termcap library */
-speed_t ospeed; /* used by termcap library */
+char PC = 0; /* used by termcap library */
+speed_t ospeed = 0; /* used by termcap library */
-int _nc_nulls_sent; /* used by 'tack' program */
+int _nc_nulls_sent = 0; /* used by 'tack' program */
-static int (*my_outch)(int c) = _nc_outch;
+static int (*my_outch) (int c) = _nc_outch;
-int delay_output(int ms)
+int
+delay_output(int ms)
{
- T((T_CALLED("delay_output(%d)"), ms));
+ T((T_CALLED("delay_output(%d)"), ms));
- if (no_pad_char)
- napms(ms);
- else {
- register int nullcount;
+ if (no_pad_char) {
+ _nc_flush();
+ napms(ms);
+ } else {
+ register int nullcount;
- nullcount = (ms * _nc_baudrate(ospeed)) / 10000;
- for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
- my_outch(PC);
- if (my_outch == _nc_outch)
- _nc_flush();
- }
+ nullcount = (ms * _nc_baudrate(ospeed)) / 10000;
+ for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
+ my_outch(PC);
+ if (my_outch == _nc_outch)
+ _nc_flush();
+ }
- returnCode(OK);
+ returnCode(OK);
}
-int _nc_outch(int ch)
+void
+_nc_flush(void)
+{
+ (void)fflush(NC_OUTPUT);
+}
+
+int
+_nc_outch(int ch)
{
#ifdef TRACE
- _nc_outchars++;
+ _nc_outchars++;
#endif /* TRACE */
- if (SP != 0
- && SP->_cleanup) {
- char tmp = ch;
- /*
- * POSIX says write() is safe in a signal handler, but the
- * buffered I/O is not.
- */
- write(fileno(NC_OUTPUT), &tmp, 1);
- } else {
- putc(ch, NC_OUTPUT);
- }
- return OK;
+ if (SP != 0
+ && SP->_cleanup) {
+ char tmp = ch;
+ /*
+ * POSIX says write() is safe in a signal handler, but the
+ * buffered I/O is not.
+ */
+ write(fileno(NC_OUTPUT), &tmp, 1);
+ } else {
+ putc(ch, NC_OUTPUT);
+ }
+ return OK;
}
-int putp(const char *string)
+#ifdef USE_WIDEC_SUPPORT
+/*
+ * Reference: The Unicode Standard 2.0
+ *
+ * No surrogates supported (we're storing only one 16-bit Unicode value per
+ * cell).
+ */
+int
+_nc_utf8_outch(int ch)
{
- return tputs(string, 1, _nc_outch);
+ static const unsigned byteMask = 0xBF;
+ static const unsigned otherMark = 0x80;
+ static const unsigned firstMark[] =
+ {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
+
+ int result[7], *ptr;
+ int count = 0;
+
+ if (ch < 0x80)
+ count = 1;
+ else if (ch < 0x800)
+ count = 2;
+ else if (ch < 0x10000)
+ count = 3;
+ else if (ch < 0x200000)
+ count = 4;
+ else if (ch < 0x4000000)
+ count = 5;
+ else if (ch <= 0x7FFFFFFF)
+ count = 6;
+ else {
+ count = 2;
+ ch = 0xFFFD;
+ }
+ ptr = result + count;
+ switch (count) {
+ case 6:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 5:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 4:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 3:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 2:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 1:
+ *--ptr = (ch | firstMark[count]);
+ }
+ while (count--)
+ _nc_outch(*ptr++);
+ return OK;
}
+#endif
-int tputs(const char *string, int affcnt, int (*outc)(int))
+int
+putp(const char *string)
{
-bool always_delay;
-bool normal_delay;
-int number;
+ return tputs(string, 1, _nc_outch);
+}
+
+int
+tputs(const char *string, int affcnt, int (*outc) (int))
+{
+ bool always_delay;
+ bool normal_delay;
+ int number;
#ifdef BSD_TPUTS
-int trailpad;
+ int trailpad;
#endif /* BSD_TPUTS */
#ifdef TRACE
-char addrbuf[32];
-
- if (_nc_tracing & TRACE_TPUTS)
- {
- if (outc == _nc_outch)
- (void) strcpy(addrbuf, "_nc_outch");
- else
- (void) sprintf(addrbuf, "%p", outc);
- if (_nc_tputs_trace) {
- TR(TRACE_MAXIMUM, ("tputs(%s = %s, %d, %s) called", _nc_tputs_trace, _nc_visbuf(string), affcnt, addrbuf));
- }
- else {
- TR(TRACE_MAXIMUM, ("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf));
- }
- _nc_tputs_trace = (char *)NULL;
+ char addrbuf[32];
+
+ if (_nc_tracing & TRACE_TPUTS) {
+ if (outc == _nc_outch)
+ (void) strcpy(addrbuf, "_nc_outch");
+ else
+ (void) sprintf(addrbuf, "%p", outc);
+ if (_nc_tputs_trace) {
+ _tracef("tputs(%s = %s, %d, %s) called", _nc_tputs_trace,
+ _nc_visbuf(string), affcnt, addrbuf);
+ } else {
+ _tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf);
}
+ _nc_tputs_trace = (char *) NULL;
+ }
#endif /* TRACE */
-
- if (!VALID_STRING(string))
- return ERR;
- if (cur_term == 0) {
- always_delay = FALSE;
- normal_delay = TRUE;
- } else {
- always_delay = (string == bell) || (string == flash_screen);
- normal_delay =
- !xon_xoff
- && padding_baud_rate
+ if (!VALID_STRING(string))
+ return ERR;
+
+ if (cur_term == 0) {
+ always_delay = FALSE;
+ normal_delay = TRUE;
+ } else {
+ always_delay = (string == bell) || (string == flash_screen);
+ normal_delay =
+ !xon_xoff
+ && padding_baud_rate
#ifdef NCURSES_NO_PADDING
- && (SP == 0 || !(SP->_no_padding))
+ && (SP == 0 || !(SP->_no_padding))
#endif
- && (_nc_baudrate(ospeed) >= padding_baud_rate);
- }
+ && (_nc_baudrate(ospeed) >= padding_baud_rate);
+ }
#ifdef 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.
- */
- trailpad = 0;
- if (isdigit(*string)) {
+ /*
+ * This ugly kluge deals with the fact that some ancient BSD programs
+ * (like nethack) actually do the likes of tputs("50") to get delays.
+ */
+ trailpad = 0;
+ if (isdigit(*string)) {
+ while (isdigit(*string)) {
+ trailpad = trailpad * 10 + (*string - '0');
+ string++;
+ }
+ trailpad *= 10;
+ if (*string == '.') {
+ string++;
+ if (isdigit(*string)) {
+ trailpad += (*string - '0');
+ string++;
+ }
+ while (isdigit(*string))
+ string++;
+ }
+
+ if (*string == '*') {
+ trailpad *= affcnt;
+ string++;
+ }
+ }
+#endif /* BSD_TPUTS */
+
+ my_outch = outc; /* redirect delay_output() */
+ while (*string) {
+ if (*string != '$')
+ (*outc) (*string);
+ else {
+ string++;
+ if (*string != '<') {
+ (*outc) ('$');
+ if (*string)
+ (*outc) (*string);
+ } else {
+ bool mandatory;
+
+ string++;
+ if ((!isdigit(*string) && *string != '.') || !strchr(string, '>')) {
+ (*outc) ('$');
+ (*outc) ('<');
+ continue;
+ }
+
+ number = 0;
while (isdigit(*string)) {
- trailpad = trailpad * 10 + (*string - '0');
- string++;
+ number = number * 10 + (*string - '0');
+ string++;
}
- trailpad *= 10;
+ number *= 10;
if (*string == '.') {
+ string++;
+ if (isdigit(*string)) {
+ number += (*string - '0');
+ string++;
+ }
+ while (isdigit(*string))
string++;
- if (isdigit(*string)) {
- trailpad += (*string - '0');
- string++;
- }
- while (isdigit(*string))
- string++;
}
- if (*string == '*') {
- trailpad *= affcnt;
+ mandatory = FALSE;
+ while (*string == '*' || *string == '/') {
+ if (*string == '*') {
+ number *= affcnt;
+ string++;
+ } else { /* if (*string == '/') */
+ mandatory = TRUE;
string++;
+ }
}
- }
-#endif /* BSD_TPUTS */
- my_outch = outc; /* redirect delay_output() */
- while (*string) {
- if (*string != '$')
- (*outc)(*string);
- else {
- string++;
- if (*string != '<') {
- (*outc)('$');
- if (*string)
- (*outc)(*string);
- } else {
- bool mandatory;
-
- string++;
- if ((!isdigit(*string) && *string != '.') || !strchr(string, '>')) {
- (*outc)('$');
- (*outc)('<');
- continue;
- }
-
- number = 0;
- while (isdigit(*string)) {
- number = number * 10 + (*string - '0');
- string++;
- }
- number *= 10;
- if (*string == '.') {
- string++;
- if (isdigit(*string)) {
- number += (*string - '0');
- string++;
- }
- while (isdigit(*string))
- string++;
- }
-
- mandatory = FALSE;
- while (*string == '*' || *string == '/')
- {
- if (*string == '*') {
- number *= affcnt;
- string++;
- }
- else /* if (*string == '/') */ {
- mandatory = TRUE;
- string++;
- }
- }
-
- if (number > 0
- && (always_delay
- || normal_delay
- || mandatory))
- delay_output(number/10);
-
- } /* endelse (*string == '<') */
- } /* endelse (*string == '$') */
-
- if (*string == '\0')
- break;
+ if (number > 0
+ && (always_delay
+ || normal_delay
+ || mandatory))
+ delay_output(number / 10);
- string++;
- }
+ } /* endelse (*string == '<') */
+ } /* endelse (*string == '$') */
+
+ if (*string == '\0')
+ break;
+
+ string++;
+ }
#ifdef BSD_TPUTS
- /*
- * Emit any BSD-style prefix padding that we've accumulated now.
- */
- if (trailpad > 0
- && (always_delay || normal_delay))
- delay_output(trailpad/10);
+ /*
+ * Emit any BSD-style prefix padding that we've accumulated now.
+ */
+ if (trailpad > 0
+ && (always_delay || normal_delay))
+ delay_output(trailpad / 10);
#endif /* BSD_TPUTS */
- my_outch = _nc_outch;
- return OK;
+ my_outch = _nc_outch;
+ return OK;
}
diff --git a/contrib/ncurses/ncurses/tinfo/make_keys.c b/contrib/ncurses/ncurses/tinfo/make_keys.c
index a1fd1d0b66f8..703ca5de0fea 100644
--- a/contrib/ncurses/ncurses/tinfo/make_keys.c
+++ b/contrib/ncurses/ncurses/tinfo/make_keys.c
@@ -37,7 +37,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: make_keys.c,v 1.7 1999/09/11 17:32:57 Jeffrey.Honig Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.8 2000/03/12 02:55:50 Todd.C.Miller Exp $")
#include <names.c>
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
"",
"/* This file was generated by MAKE_KEYS */",
"",
- "#ifdef BROKEN_LINKER",
+ "#if BROKEN_LINKER",
"static",
"#endif",
"struct tinfo_fkeys _nc_tinfo_fkeys[] = {",
diff --git a/contrib/ncurses/ncurses/tinfo/parse_entry.c b/contrib/ncurses/ncurses/tinfo/parse_entry.c
index 07f3868e0b44..1aff562d0dd6 100644
--- a/contrib/ncurses/ncurses/tinfo/parse_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/parse_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 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> *
****************************************************************************/
-
/*
* parse_entry.c -- compile one terminfo or termcap entry
*
@@ -48,24 +47,23 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$Id: parse_entry.c,v 1.39 1999/03/01 02:28:51 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.44 2000/04/30 00:17:42 tom Exp $")
#ifdef LINT
-static short const parametrized[] = { 0 };
+static short const parametrized[] =
+{0};
#else
#include <parametrized.h>
#endif
-struct token _nc_curr_token;
-
-static void postprocess_termcap(TERMTYPE *, bool);
-static void postprocess_terminfo(TERMTYPE *);
-static struct name_table_entry const * lookup_fullname(const char *name);
+static void postprocess_termcap(TERMTYPE *, bool);
+static void postprocess_terminfo(TERMTYPE *);
+static struct name_table_entry const *lookup_fullname(const char *name);
#if NCURSES_XNAMES
-static struct name_table_entry const *
-_nc_extend_names(ENTRY *entryp, char *name, int token_type)
+static struct name_table_entry const *
+_nc_extend_names(ENTRY * entryp, char *name, int token_type)
{
static struct name_table_entry temp;
TERMTYPE *tp = &(entryp->tterm);
@@ -77,20 +75,20 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
switch (token_type) {
case BOOLEAN:
- first = 0;
- last = tp->ext_Booleans;
+ first = 0;
+ last = tp->ext_Booleans;
offset = tp->ext_Booleans;
tindex = tp->num_Booleans;
break;
case NUMBER:
- first = tp->ext_Booleans;
- last = tp->ext_Numbers + first;
+ first = tp->ext_Booleans;
+ last = tp->ext_Numbers + first;
offset = tp->ext_Booleans + tp->ext_Numbers;
tindex = tp->num_Numbers;
break;
case STRING:
- first = tp->ext_Booleans + tp->ext_Numbers;
- last = tp->ext_Strings + first;
+ first = tp->ext_Booleans + tp->ext_Numbers;
+ last = tp->ext_Strings + first;
offset = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
tindex = tp->num_Strings;
break;
@@ -98,7 +96,7 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
actual = NUM_EXT_NAMES(tp);
for (n = 0; n < actual; n++) {
if (!strcmp(name, tp->ext_Names[n])) {
- if (n > (unsigned)(tp->ext_Booleans + tp->ext_Numbers)) {
+ if (n > (unsigned) (tp->ext_Booleans + tp->ext_Numbers)) {
token_type = STRING;
} else if (n > tp->ext_Booleans) {
token_type = NUMBER;
@@ -125,9 +123,15 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
offset = n;
tindex = n - first;
switch (token_type) {
- case BOOLEAN: tindex += BOOLCOUNT; break;
- case NUMBER: tindex += NUMCOUNT; break;
- case STRING: tindex += STRCOUNT; break;
+ case BOOLEAN:
+ tindex += BOOLCOUNT;
+ break;
+ case NUMBER:
+ tindex += NUMCOUNT;
+ break;
+ case STRING:
+ tindex += STRCOUNT;
+ break;
}
break;
}
@@ -138,35 +142,35 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
tp->ext_Booleans += 1;
tp->num_Booleans += 1;
tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
- for (last = tp->num_Booleans-1; last > tindex; last--)
- tp->Booleans[last] = tp->Booleans[last-1];
+ for (last = tp->num_Booleans - 1; last > tindex; last--)
+ tp->Booleans[last] = tp->Booleans[last - 1];
break;
case NUMBER:
tp->ext_Numbers += 1;
tp->num_Numbers += 1;
tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
- for (last = tp->num_Numbers-1; last > tindex; last--)
- tp->Numbers[last] = tp->Numbers[last-1];
+ for (last = tp->num_Numbers - 1; last > tindex; last--)
+ tp->Numbers[last] = tp->Numbers[last - 1];
break;
case STRING:
tp->ext_Strings += 1;
tp->num_Strings += 1;
tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
- for (last = tp->num_Strings-1; last > tindex; last--)
- tp->Strings[last] = tp->Strings[last-1];
+ for (last = tp->num_Strings - 1; last > tindex; last--)
+ tp->Strings[last] = tp->Strings[last - 1];
break;
}
actual = NUM_EXT_NAMES(tp);
- tp->ext_Names = typeRealloc(char *, actual, tp->ext_Names);
+ tp->ext_Names = typeRealloc(char *, actual, tp->ext_Names);
while (--actual > offset)
- tp->ext_Names[actual] = tp->ext_Names[actual-1];
+ tp->ext_Names[actual] = tp->ext_Names[actual - 1];
tp->ext_Names[offset] = _nc_save_str(name);
}
- temp.nte_name = tp->ext_Names[offset];
- temp.nte_type = token_type;
+ temp.nte_name = tp->ext_Names[offset];
+ temp.nte_type = token_type;
temp.nte_index = tindex;
- temp.nte_link = -1;
+ temp.nte_link = -1;
return &temp;
}
@@ -191,16 +195,17 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
* push back token
*/
-int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
+int
+_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];
+ int token_type;
+ struct name_table_entry const *entry_ptr;
+ char *ptr, namecpy[MAX_NAME_SIZE + 1];
token_type = _nc_get_token();
if (token_type == EOF)
- return(EOF);
+ return (EOF);
if (token_type != NAMES)
_nc_err_abort("Entry does not start with terminal names in column one");
@@ -213,8 +218,7 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
/* junk the 2-character termcap name, if present */
ptr = _nc_curr_token.tk_name;
- if (ptr[2] == '|')
- {
+ if (ptr[2] == '|') {
ptr = _nc_curr_token.tk_name + 3;
_nc_curr_token.tk_name[2] = '\0';
}
@@ -233,30 +237,29 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
/* 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)
+ 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)
+ while ((ptr = strtok((char *) 0, "|")) != (char *) 0)
if (strlen(ptr) > MAX_ALIAS)
_nc_warning("alias `%s' may be too long", ptr);
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].parent = (void *)_nc_save_str(_nc_curr_token.tk_valstring);
+ entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
entryp->uses[entryp->nuses].line = _nc_curr_line;
entryp->nuses++;
} 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
@@ -266,43 +269,37 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
* making this case fast, aliased caps aren't common now
* and will get rarer.
*/
- if (entry_ptr == NOTFOUND)
- {
- const struct alias *ap;
+ if (entry_ptr == NOTFOUND) {
+ const struct alias *ap;
- if (_nc_syntax == SYN_TERMCAP)
- {
+ if (_nc_syntax == SYN_TERMCAP) {
for (ap = _nc_capalias_table; ap->from; ap++)
- if (strcmp(ap->from, _nc_curr_token.tk_name) == 0)
- {
- if (ap->to == (char *)0)
- {
+ 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);
+ _nc_warning("%s (%s termcap extension) aliased to %s",
+ ap->from, ap->source, ap->to);
break;
}
- }
- else /* if (_nc_syntax == SYN_TERMINFO) */
- {
+ } else { /* if (_nc_syntax == SYN_TERMINFO) */
for (ap = _nc_infoalias_table; ap->from; ap++)
- if (strcmp(ap->from, _nc_curr_token.tk_name) == 0)
- {
- if (ap->to == (char *)0)
- {
+ 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);
+ _nc_warning("%s (%s terminfo extension) aliased to %s",
+ ap->from, ap->source, ap->to);
break;
}
@@ -311,16 +308,17 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
}
}
}
-
#if NCURSES_XNAMES
/*
* If we have extended-names active, we will automatically
* define a name based on its context.
*/
if (entry_ptr == NOTFOUND
- && _nc_user_definable
- && (entry_ptr = _nc_extend_names(entryp, _nc_curr_token.tk_name, token_type)) != 0) {
- _nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
+ && _nc_user_definable
+ && (entry_ptr = _nc_extend_names(entryp,
+ _nc_curr_token.tk_name, token_type)) != 0) {
+ if (_nc_tracing >= DEBUG_LEVEL(1))
+ _nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
}
#endif /* NCURSES_XNAMES */
@@ -328,13 +326,12 @@ int _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;
}
/* deal with bad type/value combinations. */
- if (token_type != CANCEL && entry_ptr->nte_type != token_type)
- {
+ if (token_type != CANCEL && entry_ptr->nte_type != token_type) {
/*
* Nasty special cases here handle situations in which type
* information can resolve name clashes. Normal lookup
@@ -348,39 +345,36 @@ int _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))
+ 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)
+ else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING)
token_type = STRING;
/* we couldn't recover; skip this token */
- else
- {
- if (!silent)
- {
+ else {
+ if (!silent) {
const char *type_name;
- switch (entry_ptr->nte_type)
- {
+ switch (entry_ptr->nte_type) {
case BOOLEAN:
- type_name = "boolean";
- break;
+ type_name = "boolean";
+ break;
case STRING:
- type_name = "string";
- break;
+ type_name = "string";
+ break;
case NUMBER:
- type_name = "numeric";
- break;
+ type_name = "numeric";
+ break;
default:
- type_name = "unknown";
- break;
+ type_name = "unknown";
+ 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;
}
@@ -415,23 +409,23 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
case STRING:
ptr = _nc_curr_token.tk_valstring;
- if (_nc_syntax==SYN_TERMCAP)
+ 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;
default:
if (!silent)
_nc_warning("unknown token type");
- _nc_panic_mode((_nc_syntax==SYN_TERMCAP) ? ':' : ',');
+ _nc_panic_mode((_nc_syntax == SYN_TERMCAP) ? ':' : ',');
continue;
}
- } /* end else cur_token.name != "use" */
- nexttok:
- continue; /* cannot have a label w/o statement */
- } /* endwhile (not EOF and not NAMES) */
+ } /* end else cur_token.name != "use" */
+ nexttok:
+ continue; /* cannot have a label w/o statement */
+ } /* endwhile (not EOF and not NAMES) */
_nc_push_token(token_type);
_nc_set_type(_nc_first_name(entryp->tterm.term_names));
@@ -443,10 +437,9 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
* to be done before entry allocation is wrapped up.
*/
if (!literal) {
- if (_nc_syntax == SYN_TERMCAP)
- {
- bool has_base_entry = FALSE;
- int i;
+ if (_nc_syntax == SYN_TERMCAP) {
+ bool has_base_entry = FALSE;
+ int i;
/*
* Don't insert defaults if this is a `+' entry meant only
@@ -461,50 +454,49 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
* have picked up defaults via translation.
*/
for (i = 0; i < entryp->nuses; i++)
- if (!strchr((char *)entryp->uses[i].parent, '+'))
+ if (!strchr((char *) entryp->uses[i].name, '+'))
has_base_entry = TRUE;
postprocess_termcap(&entryp->tterm, has_base_entry);
- }
- else
+ } else
postprocess_terminfo(&entryp->tterm);
}
_nc_wrap_entry(entryp);
- return(OK);
+ return (OK);
}
-int _nc_capcmp(const char *s, const char *t)
+int
+_nc_capcmp(const char *s, const char *t)
/* compare two string capabilities, stripping out padding */
{
if (!s && !t)
- return(0);
+ return (0);
else if (!s || !t)
- return(1);
-
- for (;;)
- {
- if (s[0] == '$' && s[1] == '<')
- {
- for (s += 2; ; s++)
- if (!(isdigit(*s) || *s=='.' || *s=='*' || *s=='/' || *s=='>'))
+ return (1);
+
+ for (;;) {
+ if (s[0] == '$' && s[1] == '<') {
+ for (s += 2;; s++)
+ if (!(isdigit(*s) || *s == '.' || *s == '*' || *s == '/' ||
+ *s == '>'))
break;
}
- if (t[0] == '$' && t[1] == '<')
- {
- for (t += 2; ; t++)
- if (!(isdigit(*t) || *t=='.' || *t=='*' || *t=='/' || *t=='>'))
+ if (t[0] == '$' && t[1] == '<') {
+ for (t += 2;; t++)
+ if (!(isdigit(*t) || *t == '.' || *t == '*' || *t == '/' ||
+ *t == '>'))
break;
}
/* we've now pushed s and t past any padding they were pointing at */
if (*s == '\0' && *t == '\0')
- return(0);
+ return (0);
if (*s != *t)
- return(*t - *s);
+ return (*t - *s);
/* else *s == *t but one is not NUL, so continue */
s++, t++;
@@ -516,29 +508,32 @@ int _nc_capcmp(const char *s, const char *t)
* list. For each capability, we may assume there is a keycap that sends the
* string which is the value of that capability.
*/
-typedef struct {const char *from; const char *to;} assoc;
+typedef struct {
+ const char *from;
+ const char *to;
+} assoc;
static assoc const ko_xlate[] =
{
- {"al", "kil1"}, /* insert line key -> KEY_IL */
- {"bt", "kcbt"}, /* back tab -> KEY_BTAB */
- {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */
- {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */
- {"cl", "kclr"}, /* clear key -> KEY_CLEAR */
- {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */
- {"dc", "kdch1"}, /* delete char -> KEY_DC */
- {"dl", "kdl1"}, /* delete line -> KEY_DL */
- {"do", "kcud1"}, /* down key -> KEY_DOWN */
- {"ei", "krmir"}, /* exit insert key -> KEY_EIC */
- {"ho", "khome"}, /* home key -> KEY_HOME */
- {"ic", "kich1"}, /* insert char key -> KEY_IC */
- {"im", "kIC"}, /* insert-mode key -> KEY_SIC */
- {"le", "kcub1"}, /* le key -> KEY_LEFT */
- {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */
- {"nl", "kent"}, /* new line key -> KEY_ENTER */
- {"st", "khts"}, /* set-tab key -> KEY_STAB */
- {"ta", CANCELLED_STRING},
- {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */
- {(char *)0, (char *)0},
+ {"al", "kil1"}, /* insert line key -> KEY_IL */
+ {"bt", "kcbt"}, /* back tab -> KEY_BTAB */
+ {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */
+ {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */
+ {"cl", "kclr"}, /* clear key -> KEY_CLEAR */
+ {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */
+ {"dc", "kdch1"}, /* delete char -> KEY_DC */
+ {"dl", "kdl1"}, /* delete line -> KEY_DL */
+ {"do", "kcud1"}, /* down key -> KEY_DOWN */
+ {"ei", "krmir"}, /* exit insert key -> KEY_EIC */
+ {"ho", "khome"}, /* home key -> KEY_HOME */
+ {"ic", "kich1"}, /* insert char key -> KEY_IC */
+ {"im", "kIC"}, /* insert-mode key -> KEY_SIC */
+ {"le", "kcub1"}, /* le key -> KEY_LEFT */
+ {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */
+ {"nl", "kent"}, /* new line key -> KEY_ENTER */
+ {"st", "khts"}, /* set-tab key -> KEY_STAB */
+ {"ta", CANCELLED_STRING},
+ {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */
+ {(char *) 0, (char *) 0},
};
/*
@@ -569,7 +564,8 @@ static const char C_HT[] = "\t";
#define CUR tp->
static
-void postprocess_termcap(TERMTYPE *tp, bool has_base)
+void
+postprocess_termcap(TERMTYPE * tp, bool has_base)
{
char buf[MAX_LINE * 2 + 2];
@@ -582,8 +578,7 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
*/
/* if there was a tc entry, assume we picked up defaults via that */
- if (!has_base)
- {
+ if (!has_base) {
if (WANTED(init_3string) && termcap_init2)
init_3string = _nc_save_str(termcap_init2);
@@ -637,15 +632,15 @@ void 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);
+ 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);
} 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);
+ 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);
}
@@ -661,8 +656,7 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* These translations will *not* be inverted by tgetent().
*/
- if (!has_base)
- {
+ if (!has_base) {
/*
* We wait until now to decide if we've got a working cr because even
* one that doesn't work can be used for newline. Unfortunately the
@@ -698,13 +692,11 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
if (has_hardware_tabs == TRUE) {
if (init_tabs != 8 && init_tabs != ABSENT_NUMERIC)
_nc_warning("hardware tabs with a width other than 8: %d", init_tabs);
- else
- {
+ else {
if (tab && _nc_capcmp(tab, C_HT))
_nc_warning("hardware tabs with a non-^I tab string %s",
- _nc_visbuf(tab));
- else
- {
+ _nc_visbuf(tab));
+ else {
if (WANTED(tab))
tab = _nc_save_str(C_HT);
init_tabs = 8;
@@ -715,14 +707,13 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* Now translate the ko capability, if there is one. This
* isn't from mytinfo...
*/
- if (PRESENT(other_non_function_keys))
- {
- char *dp, *cp = strtok(other_non_function_keys, ",");
- struct name_table_entry const *from_ptr;
- struct name_table_entry const *to_ptr;
- assoc const *ap;
- char buf2[MAX_TERMINFO_LENGTH];
- bool foundim;
+ if (PRESENT(other_non_function_keys)) {
+ char *dp, *cp = strtok(other_non_function_keys, ",");
+ struct name_table_entry const *from_ptr;
+ struct name_table_entry const *to_ptr;
+ assoc const *ap;
+ char buf2[MAX_TERMINFO_LENGTH];
+ bool foundim;
/* we're going to use this for a special case later */
dp = strchr(other_non_function_keys, 'i');
@@ -733,30 +724,26 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
for (ap = ko_xlate; ap->from; ap++)
if (strcmp(ap->from, cp) == 0)
break;
- if (!ap->to)
- {
+ if (!ap->to) {
_nc_warning("unknown capability `%s' in ko string", cp);
continue;
- }
- else if (ap->to == CANCELLED_STRING) /* ignore it */
+ } else if (ap->to == CANCELLED_STRING) /* ignore it */
continue;
/* now we know we found a match in ko_table, so... */
from_ptr = _nc_find_entry(ap->from, _nc_cap_hash_table);
- to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
+ to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
if (!from_ptr || !to_ptr) /* should never happen! */
_nc_err_abort("ko translation table is invalid, I give up");
- if (WANTED(tp->Strings[from_ptr->nte_index]))
- {
+ if (WANTED(tp->Strings[from_ptr->nte_index])) {
_nc_warning("no value for ko capability %s", ap->from);
continue;
}
- if (tp->Strings[to_ptr->nte_index])
- {
+ if (tp->Strings[to_ptr->nte_index]) {
/* There's no point in warning about it if it's the same
* string; that's just an inefficiency.
*/
@@ -764,8 +751,8 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
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;
}
@@ -774,24 +761,21 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* stripping out padding.
*/
dp = buf2;
- for (cp = tp->Strings[from_ptr->nte_index]; *cp; cp++)
- {
- if (cp[0] == '$' && cp[1] == '<')
- {
+ for (cp = tp->Strings[from_ptr->nte_index]; *cp; cp++) {
+ if (cp[0] == '$' && cp[1] == '<') {
while (*cp && *cp != '>')
if (!*cp)
break;
- else
+ else
++cp;
- }
- else
+ } else
*dp++ = *cp;
}
*dp++ = '\0';
tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
} while
- ((cp = strtok((char *)0, ",")) != 0);
+ ((cp = strtok((char *) 0, ",")) != 0);
/*
* Note: ko=im and ko=ic both want to grab the `Insert'
@@ -799,15 +783,13 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* got mapped to kich1 and im to kIC to avoid a collision.
* If the description has im but not ic, hack kIC back to kich1.
*/
- if (foundim && WANTED(key_ic) && key_sic)
- {
+ if (foundim && WANTED(key_ic) && key_sic) {
key_ic = key_sic;
key_sic = ABSENT_STRING;
}
}
- if (!hard_copy)
- {
+ if (!hard_copy) {
if (WANTED(key_backspace))
key_backspace = _nc_save_str(C_BS);
if (WANTED(key_left))
@@ -829,90 +811,76 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
PRESENT(acs_ttee) ||
PRESENT(acs_hline) ||
PRESENT(acs_vline) ||
- PRESENT(acs_plus))
- {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
+ PRESENT(acs_plus)) {
+ char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
- if (acs_chars)
- {
- (void)strcpy(bp, acs_chars);
+ if (acs_chars) {
+ (void) strcpy(bp, acs_chars);
bp += strlen(bp);
}
- if (acs_ulcorner && acs_ulcorner[1] == '\0')
- {
+ if (acs_ulcorner && acs_ulcorner[1] == '\0') {
*bp++ = 'l';
*bp++ = *acs_ulcorner;
}
- if (acs_llcorner && acs_llcorner[1] == '\0')
- {
+ if (acs_llcorner && acs_llcorner[1] == '\0') {
*bp++ = 'm';
*bp++ = *acs_llcorner;
}
- if (acs_urcorner && acs_urcorner[1] == '\0')
- {
+ if (acs_urcorner && acs_urcorner[1] == '\0') {
*bp++ = 'k';
*bp++ = *acs_urcorner;
}
- if (acs_lrcorner && acs_lrcorner[1] == '\0')
- {
+ if (acs_lrcorner && acs_lrcorner[1] == '\0') {
*bp++ = 'j';
*bp++ = *acs_lrcorner;
}
- if (acs_ltee && acs_ltee[1] == '\0')
- {
+ if (acs_ltee && acs_ltee[1] == '\0') {
*bp++ = 't';
*bp++ = *acs_ltee;
}
- if (acs_rtee && acs_rtee[1] == '\0')
- {
+ if (acs_rtee && acs_rtee[1] == '\0') {
*bp++ = 'u';
*bp++ = *acs_rtee;
}
- if (acs_btee && acs_btee[1] == '\0')
- {
+ if (acs_btee && acs_btee[1] == '\0') {
*bp++ = 'v';
*bp++ = *acs_btee;
}
- if (acs_ttee && acs_ttee[1] == '\0')
- {
+ if (acs_ttee && acs_ttee[1] == '\0') {
*bp++ = 'w';
*bp++ = *acs_ttee;
}
- if (acs_hline && acs_hline[1] == '\0')
- {
+ if (acs_hline && acs_hline[1] == '\0') {
*bp++ = 'q';
*bp++ = *acs_hline;
}
- if (acs_vline && acs_vline[1] == '\0')
- {
+ if (acs_vline && acs_vline[1] == '\0') {
*bp++ = 'x';
*bp++ = *acs_vline;
}
- if (acs_plus)
- {
+ if (acs_plus) {
*bp++ = 'n';
strcpy(bp, acs_plus);
bp = buf2 + strlen(buf2);
}
- if (bp != buf2)
- {
+ if (bp != buf2) {
*bp++ = '\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)
- {
- acs_chars = _nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
+ } else if (acs_chars == 0
+ && enter_alt_charset_mode != 0
+ && exit_alt_charset_mode != 0) {
+ acs_chars =
+ _nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
}
}
static
-void postprocess_terminfo(TERMTYPE *tp)
+void
+postprocess_terminfo(TERMTYPE * tp)
{
/*
* TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
@@ -922,74 +890,60 @@ void postprocess_terminfo(TERMTYPE *tp)
/*
* Translate AIX forms characters.
*/
- if (PRESENT(box_chars_1))
- {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
+ if (PRESENT(box_chars_1)) {
+ char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
- if (acs_chars)
- {
- (void)strcpy(bp, acs_chars);
+ if (acs_chars) {
+ (void) strcpy(bp, acs_chars);
bp += strlen(bp);
}
- if (box_chars_1[0]) /* ACS_ULCORNER */
- {
+ if (box_chars_1[0]) { /* ACS_ULCORNER */
*bp++ = 'l';
*bp++ = box_chars_1[0];
}
- if (box_chars_1[1]) /* ACS_HLINE */
- {
+ if (box_chars_1[1]) { /* ACS_HLINE */
*bp++ = 'q';
*bp++ = box_chars_1[1];
}
- if (box_chars_1[2]) /* ACS_URCORNER */
- {
+ if (box_chars_1[2]) { /* ACS_URCORNER */
*bp++ = 'k';
*bp++ = box_chars_1[2];
}
- if (box_chars_1[3]) /* ACS_VLINE */
- {
+ if (box_chars_1[3]) { /* ACS_VLINE */
*bp++ = 'x';
*bp++ = box_chars_1[3];
}
- if (box_chars_1[4]) /* ACS_LRCORNER */
- {
+ if (box_chars_1[4]) { /* ACS_LRCORNER */
*bp++ = 'j';
*bp++ = box_chars_1[4];
}
- if (box_chars_1[5]) /* ACS_LLCORNER */
- {
+ if (box_chars_1[5]) { /* ACS_LLCORNER */
*bp++ = 'm';
*bp++ = box_chars_1[5];
}
- if (box_chars_1[6]) /* ACS_TTEE */
- {
+ if (box_chars_1[6]) { /* ACS_TTEE */
*bp++ = 'w';
*bp++ = box_chars_1[6];
}
- if (box_chars_1[7]) /* ACS_RTEE */
- {
+ if (box_chars_1[7]) { /* ACS_RTEE */
*bp++ = 'u';
*bp++ = box_chars_1[7];
}
- if (box_chars_1[8]) /* ACS_BTEE */
- {
+ if (box_chars_1[8]) { /* ACS_BTEE */
*bp++ = 'v';
*bp++ = box_chars_1[8];
}
- if (box_chars_1[9]) /* ACS_LTEE */
- {
+ if (box_chars_1[9]) { /* ACS_LTEE */
*bp++ = 't';
*bp++ = box_chars_1[9];
}
- if (box_chars_1[10]) /* ACS_PLUS */
- {
+ if (box_chars_1[10]) { /* ACS_PLUS */
*bp++ = 'n';
*bp++ = box_chars_1[10];
}
- if (bp != buf2)
- {
+ if (bp != buf2) {
*bp++ = '\0';
acs_chars = _nc_save_str(buf2);
_nc_warning("acsc string synthesized from AIX capabilities");
@@ -1010,7 +964,8 @@ void postprocess_terminfo(TERMTYPE *tp)
* sorted, but the nte_type fields are not necessarily grouped together.
*/
static
-struct name_table_entry const * lookup_fullname(const char *find)
+struct name_table_entry const *
+lookup_fullname(const char *find)
{
int state = -1;
@@ -1034,10 +989,10 @@ struct name_table_entry const * lookup_fullname(const char *find)
for (count = 0; names[count] != 0; count++) {
if (!strcmp(names[count], find)) {
- struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
- while (entry_ptr->nte_type != state
+ struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
+ while (entry_ptr->nte_type != state
|| entry_ptr->nte_index != count)
- entry_ptr++;
+ entry_ptr++;
return entry_ptr;
}
}
diff --git a/contrib/ncurses/ncurses/tinfo/read_entry.c b/contrib/ncurses/ncurses/tinfo/read_entry.c
index f60a4863bdf8..85dc3e0bf6e9 100644
--- a/contrib/ncurses/ncurses/tinfo/read_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/read_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* read_entry.c -- Routine for reading in a compiled terminfo file
*
@@ -40,23 +38,13 @@
#include <curses.priv.h>
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: read_entry.c,v 1.61 1999/07/24 20:07:20 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.67 2000/03/11 12:35:45 tom Exp $")
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-#if 0
-#define TRACE_IN(p) DEBUG(2, p)
-#else
-#define TRACE_IN(p) /*nothing*/
+#if !HAVE_TELL
+#define tell(fd) 0 /* lseek() is POSIX, but not tell() - odd... */
#endif
/*
@@ -82,7 +70,8 @@ static bool keep_tic_directory = FALSE;
* Record the "official" location of the terminfo directory, according to
* the place where we're writing to, or the normal default, if not.
*/
-const char *_nc_tic_dir(const char *path)
+const char *
+_nc_tic_dir(const char *path)
{
static const char *result = TERMINFO;
@@ -104,42 +93,44 @@ const char *_nc_tic_dir(const char *path)
* has chdir'd to it. If we let it be changed, then if $TERMINFO has a
* relative path, we'll lose track of the actual directory.
*/
-void _nc_keep_tic_dir(const char *path)
+void
+_nc_keep_tic_dir(const char *path)
{
_nc_tic_dir(path);
keep_tic_directory = TRUE;
}
-static void convert_shorts(char *buf, short *Numbers, int count)
+static void
+convert_shorts(char *buf, short *Numbers, int count)
{
int i;
- for (i = 0; i < count; i++)
- {
- if (IS_NEG1(buf + 2*i))
+ for (i = 0; i < count; i++) {
+ if (IS_NEG1(buf + 2 * i))
Numbers[i] = ABSENT_NUMERIC;
- else if (IS_NEG2(buf + 2*i))
+ else if (IS_NEG2(buf + 2 * i))
Numbers[i] = CANCELLED_NUMERIC;
else
- Numbers[i] = LOW_MSB(buf + 2*i);
- TRACE_IN(("get Numbers[%d]=%d", i, Numbers[i]));
+ Numbers[i] = LOW_MSB(buf + 2 * i);
+ TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i]));
}
}
-static void convert_strings(char *buf, char **Strings, int count, int size, char *table)
+static void
+convert_strings(char *buf, char **Strings, int count, int size, char *table)
{
int i;
char *p;
for (i = 0; i < count; i++) {
- if (IS_NEG1(buf + 2*i)) {
+ if (IS_NEG1(buf + 2 * i)) {
Strings[i] = ABSENT_STRING;
- } else if (IS_NEG2(buf + 2*i)) {
+ } else if (IS_NEG2(buf + 2 * i)) {
Strings[i] = CANCELLED_STRING;
- } else if (LOW_MSB(buf + 2*i) > size) {
+ } else if (LOW_MSB(buf + 2 * i) > size) {
Strings[i] = ABSENT_STRING;
} else {
- Strings[i] = (LOW_MSB(buf+2*i) + table);
- TRACE_IN(("Strings[%d] = %s", i, _nc_visbuf(Strings[i])));
+ Strings[i] = (LOW_MSB(buf + 2 * i) + table);
+ TR(TRACE_DATABASE, ("Strings[%d] = %s", i, _nc_visbuf(Strings[i])));
}
/* make sure all strings are NUL terminated */
@@ -159,53 +150,59 @@ static void convert_strings(char *buf, char **Strings, int count, int size, char
#define even_boundary(value) \
if ((value) % 2 != 0) read(fd, buf, 1)
-static int read_termtype(int fd, TERMTYPE *ptr)
+static int
+read_termtype(int fd, TERMTYPE * ptr)
/* return 1 if read, 0 if not found or garbled */
{
- int name_size, bool_count, num_count, str_count, str_size;
- int i;
- char buf[MAX_ENTRY_SIZE];
+ int name_size, bool_count, num_count, str_count, str_size;
+ int i;
+ char buf[MAX_ENTRY_SIZE];
+
+ TR(TRACE_DATABASE, ("READ termtype header @%d", tell(fd)));
- TRACE_IN(("READ termtype header @%d", tell(fd)));
+ memset(ptr, 0, sizeof(*ptr));
/* grab the header */
if (!read_shorts(fd, buf, 6)
- || LOW_MSB(buf) != MAGIC) {
- return(0);
+ || LOW_MSB(buf) != MAGIC) {
+ return (0);
}
_nc_free_termtype(ptr);
- name_size = LOW_MSB(buf + 2);
+ name_size = LOW_MSB(buf + 2);
bool_count = LOW_MSB(buf + 4);
- num_count = LOW_MSB(buf + 6);
- str_count = LOW_MSB(buf + 8);
- str_size = LOW_MSB(buf + 10);
-
- TRACE_IN(("header is %d/%d/%d/%d(%d)", name_size, bool_count, num_count, str_count, str_size));
- if (name_size < 0
- || bool_count < 0
- || num_count < 0
- || str_count < 0
- || str_size < 0) {
- return(0);
+ num_count = LOW_MSB(buf + 6);
+ str_count = LOW_MSB(buf + 8);
+ 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));
+ if (name_size < 0
+ || bool_count < 0
+ || num_count < 0
+ || str_count < 0
+ || str_size < 0) {
+ return (0);
}
if (str_size) {
/* try to allocate space for the string table */
- if (str_count*2 >= (int) sizeof(buf)
- || (ptr->str_table = typeMalloc(char, (unsigned)str_size)) == 0) {
- return(0);
+ if (str_count * 2 >= (int) sizeof(buf)
+ || (ptr->str_table = typeMalloc(char, (unsigned) str_size)) == 0) {
+ return (0);
}
} else {
str_count = 0;
}
/* grab the name (a null-terminate string) */
- read(fd, buf, min(MAX_NAME_SIZE, (unsigned)name_size));
+ read(fd, buf, min(MAX_NAME_SIZE, (unsigned) name_size));
buf[MAX_NAME_SIZE] = '\0';
ptr->term_names = typeCalloc(char, strlen(buf) + 1);
if (ptr->term_names == NULL) {
- return(0);
+ return (0);
}
(void) strcpy(ptr->term_names, buf);
if (name_size > MAX_NAME_SIZE)
@@ -213,8 +210,8 @@ static int read_termtype(int fd, TERMTYPE *ptr)
/* grab the booleans */
if ((ptr->Booleans = typeCalloc(char, max(BOOLCOUNT, bool_count))) == 0
- || read(fd, ptr->Booleans, (unsigned)bool_count) < bool_count) {
- return(0);
+ || read(fd, ptr->Booleans, (unsigned) bool_count) < bool_count) {
+ return (0);
}
/*
@@ -227,128 +224,142 @@ static int read_termtype(int fd, TERMTYPE *ptr)
/* grab the numbers */
if ((ptr->Numbers = typeCalloc(short, max(NUMCOUNT, num_count))) == 0
- || !read_shorts(fd, buf, num_count)) {
- return(0);
+ || !read_shorts(fd, buf, num_count)) {
+ return (0);
}
convert_shorts(buf, ptr->Numbers, num_count);
if ((ptr->Strings = typeCalloc(char *, max(STRCOUNT, str_count))) == 0)
- return(0);
+ return (0);
- if (str_count)
- {
+ if (str_count) {
/* grab the string offsets */
if (!read_shorts(fd, buf, str_count)) {
- return(0);
+ return (0);
}
/* finally, grab the string table itself */
- if (read(fd, ptr->str_table, (unsigned)str_size) != str_size)
- return(0);
+ if (read(fd, ptr->str_table, (unsigned) str_size) != str_size)
+ return (0);
convert_strings(buf, ptr->Strings, str_count, str_size, ptr->str_table);
}
-
#if NCURSES_XNAMES
ptr->num_Booleans = BOOLCOUNT;
- ptr->num_Numbers = NUMCOUNT;
- ptr->num_Strings = STRCOUNT;
+ ptr->num_Numbers = NUMCOUNT;
+ ptr->num_Strings = STRCOUNT;
/*
* Read extended entries, if any, after the normal end of terminfo data.
*/
even_boundary(str_size);
- TRACE_IN(("READ extended_header @%d", tell(fd)));
+ TR(TRACE_DATABASE, ("READ extended_header @%d", tell(fd)));
if (_nc_user_definable && read_shorts(fd, buf, 5)) {
int ext_bool_count = LOW_MSB(buf + 0);
- int ext_num_count = LOW_MSB(buf + 2);
- int ext_str_count = LOW_MSB(buf + 4);
- int ext_str_size = LOW_MSB(buf + 6);
- int ext_str_limit = LOW_MSB(buf + 8);
+ int ext_num_count = LOW_MSB(buf + 2);
+ int ext_str_count = LOW_MSB(buf + 4);
+ int ext_str_size = LOW_MSB(buf + 6);
+ int ext_str_limit = LOW_MSB(buf + 8);
int need = (ext_bool_count + ext_num_count + ext_str_count);
int base = 0;
if (need >= (int) sizeof(buf)
- || ext_str_size >= (int) sizeof(buf)
- || ext_str_limit >= (int) sizeof(buf)
- || ext_bool_count < 0
- || ext_num_count < 0
- || ext_str_count < 0
- || ext_str_size < 0
- || ext_str_limit < 0)
- return(0);
+ || ext_str_size >= (int) sizeof(buf)
+ || ext_str_limit >= (int) sizeof(buf)
+ || ext_bool_count < 0
+ || ext_num_count < 0
+ || ext_str_count < 0
+ || ext_str_size < 0
+ || ext_str_limit < 0)
+ return (0);
ptr->num_Booleans = BOOLCOUNT + ext_bool_count;
- ptr->num_Numbers = NUMCOUNT + ext_num_count;
- ptr->num_Strings = STRCOUNT + ext_str_count;
+ ptr->num_Numbers = NUMCOUNT + ext_num_count;
+ ptr->num_Strings = STRCOUNT + ext_str_count;
- ptr->Booleans = typeRealloc(char, ptr->num_Booleans,ptr->Booleans);
+ ptr->Booleans = typeRealloc(char, ptr->num_Booleans, ptr->Booleans);
ptr->Numbers = typeRealloc(short, ptr->num_Numbers, ptr->Numbers);
- ptr->Strings = typeRealloc(char*, ptr->num_Strings, ptr->Strings);
+ ptr->Strings = typeRealloc(char *, ptr->num_Strings, ptr->Strings);
- TRACE_IN(("extended header is %d/%d/%d(%d:%d)", ext_bool_count, ext_num_count, ext_str_count, ext_str_size, ext_str_limit));
+ 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));
- TRACE_IN(("READ %d extended-booleans @%d", ext_bool_count, tell(fd)));
+ TR(TRACE_DATABASE, ("READ %d extended-booleans @%d",
+ 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)
- return(0);
+ if (read(fd, ptr->Booleans + BOOLCOUNT, (unsigned)
+ ext_bool_count) != ext_bool_count)
+ return (0);
}
even_boundary(ext_bool_count);
- TRACE_IN(("READ %d extended-numbers @%d", ext_num_count, tell(fd)));
+ TR(TRACE_DATABASE, ("READ %d extended-numbers @%d",
+ ext_num_count, tell(fd)));
if ((ptr->ext_Numbers = ext_num_count) != 0) {
if (!read_shorts(fd, buf, ext_num_count))
- return(0);
- TRACE_IN(("Before converting extended-numbers"));
+ return (0);
+ TR(TRACE_DATABASE, ("Before converting extended-numbers"));
convert_shorts(buf, ptr->Numbers + NUMCOUNT, ext_num_count);
}
- TRACE_IN(("READ extended-offsets @%d", tell(fd)));
+ TR(TRACE_DATABASE, ("READ extended-offsets @%d", tell(fd)));
if ((ext_str_count || need)
- && !read_shorts(fd, buf, ext_str_count+need))
- return(0);
+ && !read_shorts(fd, buf, ext_str_count + need))
+ return (0);
+
+ TR(TRACE_DATABASE, ("READ %d bytes of extended-strings @%d",
+ ext_str_limit, tell(fd)));
- TRACE_IN(("READ %d bytes of extended-strings @%d", ext_str_limit, tell(fd)));
if (ext_str_limit) {
if ((ptr->ext_str_table = typeMalloc(char, ext_str_limit)) == 0)
- return(0);
+ return (0);
if (read(fd, ptr->ext_str_table, ext_str_limit) != ext_str_limit)
- return(0);
- TRACE_IN(("first extended-string is %s", _nc_visbuf(ptr->ext_str_table)));
+ return (0);
+ TR(TRACE_DATABASE, ("first extended-string is %s", _nc_visbuf(ptr->ext_str_table)));
}
if ((ptr->ext_Strings = ext_str_count) != 0) {
- TRACE_IN(("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);
- for (i = ext_str_count-1; i >= 0; i--) {
- TRACE_IN(("MOVE from [%d:%d] %s", 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);
- TRACE_IN(("... to [%d] %s", i+STRCOUNT, _nc_visbuf(ptr->Strings[i+STRCOUNT])));
+ TR(TRACE_DATABASE,
+ ("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);
+ 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])));
+ 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])));
}
}
if (need) {
if ((ptr->ext_Names = typeCalloc(char *, need)) == 0)
- return(0);
- TRACE_IN(("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);
+ return (0);
+ TR(TRACE_DATABASE,
+ ("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);
}
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));
- TRACE_IN(("extend: num_Booleans:%d", ptr->num_Booleans));
+ 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));
- TRACE_IN(("normal: num_Booleans:%d", ptr->num_Booleans));
+ bool_count, num_count, str_count));
+#if NCURSES_XNAMES
+ TR(TRACE_DATABASE, ("normal: num_Booleans:%d", ptr->num_Booleans));
+#endif
}
for (i = bool_count; i < BOOLCOUNT; i++)
@@ -358,18 +369,19 @@ static int read_termtype(int fd, TERMTYPE *ptr)
for (i = str_count; i < STRCOUNT; i++)
ptr->Strings[i] = ABSENT_STRING;
- return(1);
+ return (1);
}
-int _nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
+int
+_nc_read_file_entry(const char *const filename, TERMTYPE * ptr)
/* return 1 if read, 0 if not found or garbled */
{
int code, fd = -1;
if (_nc_access(filename, R_OK) < 0
- || (fd = open(filename, O_RDONLY|O_BINARY)) < 0) {
+ || (fd = open(filename, O_RDONLY | O_BINARY)) < 0) {
T(("cannot open terminfo %s (errno=%d)", filename, errno));
- return(0);
+ return (0);
}
T(("read terminfo %s", filename));
@@ -384,51 +396,54 @@ int _nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
* Build a terminfo pathname and try to read the data. Returns 1 on success,
* 0 on failure.
*/
-static int _nc_read_tic_entry(char *const filename,
- const char *const dir, const char *ttn, TERMTYPE *const tp)
+static int
+_nc_read_tic_entry(char *const filename,
+ 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)
- if (strlen(dir) > MAX_TPATH)
- return 0;
- (void) sprintf(filename, "%s/%s", dir, ttn);
- return _nc_read_file_entry(filename, tp);
+ if (strlen(dir) > MAX_TPATH)
+ return 0;
+ (void) sprintf(filename, "%s/%s", dir, ttn);
+ return _nc_read_file_entry(filename, tp);
}
/*
* Process the list of :-separated directories, looking for the terminal type.
* We don't use strtok because it does not show us empty tokens.
*/
-static int _nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const ttn, TERMTYPE *const tp)
+static int
+_nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const
+ ttn, TERMTYPE * const tp)
{
- char *list, *a;
- const char *b;
- int code = 0;
-
- /* we'll modify the argument, so we must copy */
- if ((b = a = list = strdup(dirs)) == NULL)
- return(0);
-
- for (;;) {
- int c = *a;
- if (c == 0 || c == ':') {
- *a = 0;
- if ((b + 1) >= a)
- b = TERMINFO;
- if (_nc_read_tic_entry(filename, b, ttn, tp) == 1) {
- code = 1;
- break;
- }
- b = a + 1;
- if (c == 0)
- break;
- }
- a++;
+ char *list, *a;
+ const char *b;
+ int code = 0;
+
+ /* we'll modify the argument, so we must copy */
+ if ((b = a = list = strdup(dirs)) == NULL)
+ return (0);
+
+ for (;;) {
+ int c = *a;
+ if (c == 0 || c == ':') {
+ *a = 0;
+ if ((b + 1) >= a)
+ b = TERMINFO;
+ if (_nc_read_tic_entry(filename, b, ttn, tp) == 1) {
+ code = 1;
+ break;
+ }
+ b = a + 1;
+ if (c == 0)
+ break;
}
+ a++;
+ }
- free(list);
- return(code);
+ free(list);
+ return (code);
}
/*
@@ -440,43 +455,43 @@ static int _nc_read_terminfo_dirs(const char *dirs, char *const filename, const
* overrun the file buffer.
*/
-int _nc_read_entry(const char *const tn, char *const filename, TERMTYPE *const tp)
+int
+_nc_read_entry(const char *const tn, char *const filename, TERMTYPE * const tp)
{
-char *envp;
-char ttn[MAX_ALIAS + 3];
-
- /* truncate the terminal name to prevent dangerous buffer airline */
- (void) sprintf(ttn, "%c/%.*s", *tn, MAX_ALIAS, tn);
-
- /* This is System V behavior, in conjunction with our requirements for
- * writing terminfo entries.
- */
- if (have_tic_directory
- && _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 ((envp = _nc_home_terminfo()) != 0) {
- if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
- return(1);
- }
+ char *envp;
+ char ttn[MAX_ALIAS + 3];
+
+ /* truncate the terminal name to prevent dangerous buffer airline */
+ (void) sprintf(ttn, "%c/%.*s", *tn, MAX_ALIAS, tn);
+
+ /* This is System V behavior, in conjunction with our requirements for
+ * writing terminfo entries.
+ */
+ if (have_tic_directory
+ && _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 ((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
- * interpreted as TERMINFO.
- */
+ /* Try the system directory. Note that the TERMINFO_DIRS value, if
+ * defined by the configure script, begins with a ":", which will be
+ * interpreted as TERMINFO.
+ */
#ifdef TERMINFO_DIRS
- return _nc_read_terminfo_dirs(TERMINFO_DIRS, filename, ttn, tp);
+ return _nc_read_terminfo_dirs(TERMINFO_DIRS, filename, ttn, tp);
#else
- return _nc_read_tic_entry(filename, TERMINFO, ttn, tp);
+ return _nc_read_tic_entry(filename, TERMINFO, ttn, tp);
#endif
}
-
diff --git a/contrib/ncurses/ncurses/tinfo/read_termcap.c b/contrib/ncurses/ncurses/tinfo/read_termcap.c
index d60a92d63f0a..26e72d403263 100644
--- a/contrib/ncurses/ncurses/tinfo/read_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/read_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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> *
****************************************************************************/
-
/*
* Termcap compatibility support
*
@@ -56,11 +55,7 @@
#include <tic.h>
#include <term_entry.h>
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-MODULE_ID("$Id: read_termcap.c,v 1.43 1999/04/10 20:52:52 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.47 2000/04/15 16:53:19 Todd.C.Miller Exp $")
#ifndef PURE_TERMINFO
@@ -86,7 +81,7 @@ MODULE_ID("$Id: read_termcap.c,v 1.43 1999/04/10 20:52:52 tom Exp $")
#define _nc_cgetset cgetset
#else
static int _nc_cgetmatch(char *, const char *);
-static int _nc_getent(char **, unsigned int *, 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 *);
/*-
@@ -130,16 +125,16 @@ static int _nc_nfcmp(const char *, char *);
#define BFRAG 1024
#define BSIZE 1024
#define ESC ('[' & 037) /* ASCII ESC */
-#define MAX_RECURSION 32 /* maximum getent recursion */
-#define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */
+#define MAX_RECURSION 32 /* maximum getent recursion */
+#define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */
#define RECOK (char)0
#define TCERR (char)1
#define SHADOW (char)2
-static size_t topreclen; /* toprec length */
-static char *toprec; /* Additional record specified by cgetset() */
-static int gottoprec; /* Flag indicating retrieval of toprecord */
+static size_t topreclen; /* toprec length */
+static char *toprec; /* Additional record specified by cgetset() */
+static int gottoprec; /* Flag indicating retrieval of toprecord */
/*
* Cgetset() allows the addition of a user specified buffer to be added to the
@@ -149,20 +144,20 @@ static int gottoprec; /* Flag indicating retrieval of toprecord */
static int
_nc_cgetset(const char *ent)
{
- if (ent == 0) {
- FreeIfNeeded(toprec);
- toprec = 0;
- topreclen = 0;
- return (0);
- }
- topreclen = strlen(ent);
- if ((toprec = typeMalloc(char, topreclen + 1)) == 0) {
- errno = ENOMEM;
- return (-1);
- }
- gottoprec = 0;
- (void)strcpy(toprec, ent);
+ if (ent == 0) {
+ FreeIfNeeded(toprec);
+ toprec = 0;
+ topreclen = 0;
return (0);
+ }
+ topreclen = strlen(ent);
+ if ((toprec = typeMalloc(char, topreclen + 1)) == 0) {
+ errno = ENOMEM;
+ return (-1);
+ }
+ gottoprec = 0;
+ (void) strcpy(toprec, ent);
+ return (0);
}
/*
@@ -180,43 +175,43 @@ _nc_cgetset(const char *ent)
static char *
_nc_cgetcap(char *buf, const char *cap, int type)
{
- register const char *cp;
- register char *bp;
+ register const char *cp;
+ register char *bp;
- bp = buf;
+ bp = buf;
+ for (;;) {
+ /*
+ * Skip past the current capability field - it's either the
+ * name field if this is the first time through the loop, or
+ * the remainder of a field whose name failed to match cap.
+ */
for (;;) {
- /*
- * Skip past the current capability field - it's either the
- * name field if this is the first time through the loop, or
- * the remainder of a field whose name failed to match cap.
- */
- for (;;) {
- if (*bp == '\0')
- return (0);
- else if (*bp++ == ':')
- break;
- }
+ if (*bp == '\0')
+ return (0);
+ else if (*bp++ == ':')
+ break;
+ }
- /*
- * Try to match (cap, type) in buf.
- */
- for (cp = cap; *cp == *bp && *bp != '\0'; cp++, bp++)
- continue;
- if (*cp != '\0')
- continue;
- if (*bp == '@')
- return (0);
- if (type == ':') {
- if (*bp != '\0' && *bp != ':')
- continue;
- return(bp);
- }
- if (*bp != type)
- continue;
- bp++;
- return (*bp == '@' ? 0 : bp);
+ /*
+ * Try to match (cap, type) in buf.
+ */
+ for (cp = cap; *cp == *bp && *bp != '\0'; cp++, bp++)
+ continue;
+ if (*cp != '\0')
+ continue;
+ if (*bp == '@')
+ return (0);
+ if (type == ':') {
+ if (*bp != '\0' && *bp != ':')
+ continue;
+ return (bp);
}
- /* NOTREACHED */
+ if (*bp != type)
+ continue;
+ bp++;
+ return (*bp == '@' ? 0 : bp);
+ }
+ /* NOTREACHED */
}
/*
@@ -236,9 +231,9 @@ _nc_cgetcap(char *buf, const char *cap, int type)
static int
_nc_cgetent(char **buf, int *oline, char **db_array, const char *name)
{
- unsigned int dummy;
+ unsigned dummy;
- return (_nc_getent(buf, &dummy, oline, 0, db_array, -1, name, 0, 0));
+ return (_nc_getent(buf, &dummy, oline, 0, db_array, -1, name, 0, 0));
}
/*
@@ -262,327 +257,327 @@ _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 int *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;
- char *record = 0;
- int tc_not_resolved;
- int current;
- int lineno;
-
- /*
- * Return with ``loop detected'' error if we've recurred more than
- * MAX_RECURSION times.
- */
- if (depth > MAX_RECURSION)
- return (TC_REF_LOOP);
+ register char *r_end, *rp;
+ int myfd = FALSE;
+ char *record = 0;
+ int tc_not_resolved;
+ int current;
+ int lineno;
+
+ /*
+ * Return with ``loop detected'' error if we've recurred more than
+ * MAX_RECURSION times.
+ */
+ if (depth > MAX_RECURSION)
+ return (TC_REF_LOOP);
+
+ /*
+ * Check if we have a top record from cgetset().
+ */
+ if (depth == 0 && toprec != 0 && _nc_cgetmatch(toprec, name) == 0) {
+ if ((record = DOALLOC(topreclen + BFRAG)) == 0) {
+ errno = ENOMEM;
+ return (TC_SYS_ERR);
+ }
+ (void) strcpy(record, toprec);
+ rp = record + topreclen + 1;
+ r_end = rp + BFRAG;
+ current = in_array;
+ } else {
+ int foundit;
/*
- * Check if we have a top record from cgetset().
+ * Allocate first chunk of memory.
*/
- if (depth == 0 && toprec != 0 && _nc_cgetmatch(toprec, name) == 0) {
- if ((record = DOALLOC(topreclen + BFRAG)) == 0) {
- errno = ENOMEM;
- return (TC_SYS_ERR);
- }
- (void)strcpy(record, toprec);
- rp = record + topreclen + 1;
- r_end = rp + BFRAG;
- current = in_array;
- } else {
- int foundit;
-
- /*
- * Allocate first chunk of memory.
- */
- if ((record = DOALLOC(BFRAG)) == 0) {
- errno = ENOMEM;
- return (TC_SYS_ERR);
- }
- rp = r_end = record + BFRAG;
- foundit = FALSE;
-
- /*
- * Loop through database array until finding the record.
- */
- for (current = in_array; db_array[current] != 0; current++) {
- int eof = FALSE;
-
- /*
- * Open database if not already open.
- */
- 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) {
- /* No error on unfound file. */
- if (errno == ENOENT)
- continue;
- free(record);
- return (TC_SYS_ERR);
- } else {
- myfd = TRUE;
- }
- lineno = 0;
-
- /*
- * Find the requested capability record ...
- */
- {
- char buf[2048];
- register char *b_end = buf;
- register char *bp = buf;
- register int c;
-
- /*
- * Loop invariants:
- * There is always room for one more character in record.
- * R_end always points just past end of record.
- * Rp always points just past last character in record.
- * B_end always points just past last character in buf.
- * Bp always points at next character in buf.
- */
-
- for (;;) {
- int first = lineno + 1;
-
- /*
- * Read in a line implementing (\, newline)
- * line continuation.
- */
- rp = record;
- for (;;) {
- if (bp >= b_end) {
- int n;
-
- n = read(fd, buf, sizeof(buf));
- if (n <= 0) {
- if (myfd)
- (void)close(fd);
- if (n < 0) {
- free(record);
- return (TC_SYS_ERR);
- }
- fd = -1;
- eof = TRUE;
- break;
- }
- b_end = buf+n;
- bp = buf;
- }
-
- c = *bp++;
- if (c == '\n') {
- lineno++;
- if (rp == record || *(rp-1) != '\\')
- break;
- }
- *rp++ = c;
-
- /*
- * Enforce loop invariant: if no room
- * left in record buffer, try to get
- * some more.
- */
- if (rp >= r_end) {
- unsigned int pos;
- size_t newsize;
-
- pos = rp - record;
- newsize = r_end - record + BFRAG;
- record = DOALLOC(newsize);
- if (record == 0) {
- if (myfd)
- (void)close(fd);
- errno = ENOMEM;
- return (TC_SYS_ERR);
- }
- r_end = record + newsize;
- rp = record + pos;
- }
- }
- /* loop invariant lets us do this */
- *rp++ = '\0';
-
- /*
- * If encountered eof check next file.
- */
- if (eof)
- break;
-
- /*
- * Toss blank lines and comments.
- */
- if (*record == '\0' || *record == '#')
- continue;
-
- /*
- * See if this is the record we want ...
- */
- if (_nc_cgetmatch(record, name) == 0
- && (nfield == 0
- || !_nc_nfcmp(nfield, record))) {
- foundit = TRUE;
- *beginning = first;
- break; /* found it! */
- }
- }
- }
- if (foundit)
- break;
- }
-
- if (!foundit)
- return (TC_NOT_FOUND);
+ if ((record = DOALLOC(BFRAG)) == 0) {
+ errno = ENOMEM;
+ return (TC_SYS_ERR);
}
+ rp = r_end = record + BFRAG;
+ foundit = FALSE;
/*
- * Got the capability record, but now we have to expand all tc=name
- * references in it ...
+ * Loop through database array until finding the record.
*/
- {
- register char *newicap, *s;
- register int newilen;
- unsigned int ilen;
- int diff, iret, tclen, oline;
- char *icap, *scan, *tc, *tcstart, *tcend;
+ for (current = in_array; db_array[current] != 0; current++) {
+ int eof = FALSE;
+
+ /*
+ * Open database if not already open.
+ */
+ 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) {
+ /* No error on unfound file. */
+ if (errno == ENOENT)
+ continue;
+ free(record);
+ return (TC_SYS_ERR);
+ } else {
+ myfd = TRUE;
+ }
+ lineno = 0;
+
+ /*
+ * Find the requested capability record ...
+ */
+ {
+ char buf[2048];
+ register char *b_end = buf;
+ register char *bp = buf;
+ register int c;
/*
* Loop invariants:
- * There is room for one more character in record.
- * R_end points just past end of record.
- * Rp points just past last character in record.
- * Scan points at remainder of record that needs to be
- * scanned for tc=name constructs.
+ * There is always room for one more character in record.
+ * R_end always points just past end of record.
+ * Rp always points just past last character in record.
+ * B_end always points just past last character in buf.
+ * Bp always points at next character in buf.
*/
- scan = record;
- tc_not_resolved = FALSE;
- for (;;) {
- if ((tc = _nc_cgetcap(scan, "tc", '=')) == 0)
- break;
- /*
- * Find end of tc=name and stomp on the trailing `:'
- * (if present) so we can use it to call ourselves.
- */
- s = tc;
- while (*s != '\0') {
- if (*s++ == ':') {
- *(s - 1) = '\0';
- break;
- }
- }
- tcstart = tc - 3;
- tclen = s - tcstart;
- tcend = s;
-
- iret = _nc_getent(&icap, &ilen, &oline, current, db_array, fd, tc, depth+1, 0);
- newicap = icap; /* Put into a register. */
- newilen = ilen;
- if (iret != TC_SUCCESS) {
- /* an error */
- if (iret < TC_NOT_FOUND) {
- if (myfd)
- (void)close(fd);
- free(record);
- return (iret);
- }
- if (iret == TC_UNRESOLVED)
- tc_not_resolved = TRUE;
- /* couldn't resolve tc */
- if (iret == TC_NOT_FOUND) {
- *(s - 1) = ':';
- scan = s - 1;
- tc_not_resolved = TRUE;
- continue;
+ for (;;) {
+ int first = lineno + 1;
+
+ /*
+ * Read in a line implementing (\, newline)
+ * line continuation.
+ */
+ rp = record;
+ for (;;) {
+ if (bp >= b_end) {
+ int n;
+
+ n = read(fd, buf, sizeof(buf));
+ if (n <= 0) {
+ if (myfd)
+ (void) close(fd);
+ if (n < 0) {
+ free(record);
+ return (TC_SYS_ERR);
}
+ fd = -1;
+ eof = TRUE;
+ break;
+ }
+ b_end = buf + n;
+ bp = buf;
}
- /* not interested in name field of tc'ed record */
- s = newicap;
- while (*s != '\0' && *s++ != ':')
- ;
- newilen -= s - newicap;
- newicap = s;
-
- /* make sure interpolated record is `:'-terminated */
- s += newilen;
- if (*(s-1) != ':') {
- *s = ':'; /* overwrite NUL with : */
- newilen++;
+ c = *bp++;
+ if (c == '\n') {
+ lineno++;
+ if (rp == record || *(rp - 1) != '\\')
+ break;
}
+ *rp++ = c;
/*
- * Make sure there's enough room to insert the
- * new record.
+ * Enforce loop invariant: if no room
+ * left in record buffer, try to get
+ * some more.
*/
- diff = newilen - tclen;
- if (diff >= r_end - rp) {
- unsigned int pos, tcpos, tcposend;
- size_t newsize;
-
- pos = rp - record;
- newsize = r_end - record + diff + BFRAG;
- tcpos = tcstart - record;
- tcposend = tcend - record;
- record = DOALLOC(newsize);
- if (record == 0) {
- if (myfd)
- (void)close(fd);
- free(icap);
- errno = ENOMEM;
- return (TC_SYS_ERR);
- }
- r_end = record + newsize;
- rp = record + pos;
- tcstart = record + tcpos;
- tcend = record + tcposend;
+ if (rp >= r_end) {
+ unsigned pos;
+ size_t newsize;
+
+ pos = rp - record;
+ newsize = r_end - record + BFRAG;
+ record = DOALLOC(newsize);
+ if (record == 0) {
+ if (myfd)
+ (void) close(fd);
+ errno = ENOMEM;
+ return (TC_SYS_ERR);
+ }
+ r_end = record + newsize;
+ rp = record + pos;
}
+ }
+ /* loop invariant lets us do this */
+ *rp++ = '\0';
+
+ /*
+ * If encountered eof check next file.
+ */
+ if (eof)
+ break;
- /*
- * Insert tc'ed record into our record.
- */
- s = tcstart + newilen;
- memmove(s, tcend, (size_t)(rp - tcend));
- memmove(tcstart, newicap, (size_t)newilen);
- rp += diff;
- free(icap);
+ /*
+ * Toss blank lines and comments.
+ */
+ if (*record == '\0' || *record == '#')
+ continue;
- /*
- * Start scan on `:' so next cgetcap works properly
- * (cgetcap always skips first field).
- */
- scan = s-1;
+ /*
+ * See if this is the record we want ...
+ */
+ if (_nc_cgetmatch(record, name) == 0
+ && (nfield == 0
+ || !_nc_nfcmp(nfield, record))) {
+ foundit = TRUE;
+ *beginning = first;
+ break; /* found it! */
+ }
}
+ }
+ if (foundit)
+ break;
}
+ if (!foundit)
+ return (TC_NOT_FOUND);
+ }
+
+ /*
+ * Got the capability record, but now we have to expand all tc=name
+ * references in it ...
+ */
+ {
+ register char *newicap, *s;
+ register int newilen;
+ unsigned ilen;
+ int diff, iret, tclen, oline;
+ char *icap, *scan, *tc, *tcstart, *tcend;
+
/*
- * Close file (if we opened it), give back any extra memory, and
- * return capability, length and success.
+ * Loop invariants:
+ * There is room for one more character in record.
+ * R_end points just past end of record.
+ * Rp points just past last character in record.
+ * Scan points at remainder of record that needs to be
+ * scanned for tc=name constructs.
*/
- if (myfd)
- (void)close(fd);
- *len = rp - record - 1; /* don't count NUL */
- if (r_end > rp) {
- if ((record = DOALLOC((size_t)(rp - record))) == 0) {
- errno = ENOMEM;
- return (TC_SYS_ERR);
+ scan = record;
+ tc_not_resolved = FALSE;
+ for (;;) {
+ if ((tc = _nc_cgetcap(scan, "tc", '=')) == 0)
+ break;
+
+ /*
+ * Find end of tc=name and stomp on the trailing `:'
+ * (if present) so we can use it to call ourselves.
+ */
+ s = tc;
+ while (*s != '\0') {
+ if (*s++ == ':') {
+ *(s - 1) = '\0';
+ break;
+ }
+ }
+ tcstart = tc - 3;
+ tclen = s - tcstart;
+ tcend = s;
+
+ iret = _nc_getent(&icap, &ilen, &oline, current, db_array, fd,
+ tc, depth + 1, 0);
+ newicap = icap; /* Put into a register. */
+ newilen = ilen;
+ if (iret != TC_SUCCESS) {
+ /* an error */
+ if (iret < TC_NOT_FOUND) {
+ if (myfd)
+ (void) close(fd);
+ free(record);
+ return (iret);
}
+ if (iret == TC_UNRESOLVED)
+ tc_not_resolved = TRUE;
+ /* couldn't resolve tc */
+ if (iret == TC_NOT_FOUND) {
+ *(s - 1) = ':';
+ scan = s - 1;
+ tc_not_resolved = TRUE;
+ continue;
+ }
+ }
+
+ /* not interested in name field of tc'ed record */
+ s = newicap;
+ while (*s != '\0' && *s++ != ':') ;
+ newilen -= s - newicap;
+ newicap = s;
+
+ /* make sure interpolated record is `:'-terminated */
+ s += newilen;
+ if (*(s - 1) != ':') {
+ *s = ':'; /* overwrite NUL with : */
+ newilen++;
+ }
+
+ /*
+ * Make sure there's enough room to insert the
+ * new record.
+ */
+ diff = newilen - tclen;
+ if (diff >= r_end - rp) {
+ unsigned pos, tcpos, tcposend;
+ size_t newsize;
+
+ pos = rp - record;
+ newsize = r_end - record + diff + BFRAG;
+ tcpos = tcstart - record;
+ tcposend = tcend - record;
+ record = DOALLOC(newsize);
+ if (record == 0) {
+ if (myfd)
+ (void) close(fd);
+ free(icap);
+ errno = ENOMEM;
+ return (TC_SYS_ERR);
+ }
+ r_end = record + newsize;
+ rp = record + pos;
+ tcstart = record + tcpos;
+ tcend = record + tcposend;
+ }
+
+ /*
+ * Insert tc'ed record into our record.
+ */
+ s = tcstart + newilen;
+ memmove(s, tcend, (size_t) (rp - tcend));
+ memmove(tcstart, newicap, (size_t) newilen);
+ rp += diff;
+ free(icap);
+
+ /*
+ * Start scan on `:' so next cgetcap works properly
+ * (cgetcap always skips first field).
+ */
+ scan = s - 1;
+ }
+ }
+
+ /*
+ * Close file (if we opened it), give back any extra memory, and
+ * return capability, length and success.
+ */
+ if (myfd)
+ (void) close(fd);
+ *len = rp - record - 1; /* don't count NUL */
+ if (r_end > rp) {
+ if ((record = DOALLOC((size_t) (rp - record))) == 0) {
+ errno = ENOMEM;
+ return (TC_SYS_ERR);
}
+ }
- *cap = record;
- if (tc_not_resolved)
- return (TC_UNRESOLVED);
- return (current);
+ *cap = record;
+ if (tc_not_resolved)
+ return (TC_UNRESOLVED);
+ return (current);
}
/*
@@ -592,40 +587,40 @@ _nc_getent(
static int
_nc_cgetmatch(char *buf, const char *name)
{
- register const char *np;
- register char *bp;
-
+ register const char *np;
+ register char *bp;
+
+ /*
+ * Start search at beginning of record.
+ */
+ bp = buf;
+ for (;;) {
/*
- * Start search at beginning of record.
+ * Try to match a record name.
*/
- bp = buf;
+ np = name;
for (;;) {
- /*
- * Try to match a record name.
- */
- np = name;
- for (;;) {
- if (*np == '\0') {
- if (*bp == '|' || *bp == ':' || *bp == '\0')
- return (0);
- else
- break;
- } else if (*bp++ != *np++) {
- break;
- }
- }
+ if (*np == '\0') {
+ if (*bp == '|' || *bp == ':' || *bp == '\0')
+ return (0);
+ else
+ break;
+ } else if (*bp++ != *np++) {
+ break;
+ }
+ }
- /*
- * Match failed, skip to next name in record.
- */
- bp--; /* a '|' or ':' may have stopped the match */
- for (;;) {
- if (*bp == '\0' || *bp == ':')
- return (-1); /* match failed totally */
- else if (*bp++ == '|')
- break; /* found next name */
- }
+ /*
+ * Match failed, skip to next name in record.
+ */
+ bp--; /* a '|' or ':' may have stopped the match */
+ for (;;) {
+ if (*bp == '\0' || *bp == ':')
+ return (-1); /* match failed totally */
+ else if (*bp++ == '|')
+ break; /* found next name */
}
+ }
}
/*
@@ -634,18 +629,17 @@ _nc_cgetmatch(char *buf, const char *name)
static int
_nc_nfcmp(const char *nf, char *rec)
{
- char *cp, tmp;
- int ret;
+ char *cp, tmp;
+ int ret;
- for (cp = rec; *cp != ':'; cp++)
- ;
+ for (cp = rec; *cp != ':'; cp++) ;
- tmp = *(cp + 1);
- *(cp + 1) = '\0';
- ret = strcmp(nf, rec);
- *(cp + 1) = tmp;
+ tmp = *(cp + 1);
+ *(cp + 1) = '\0';
+ ret = strcmp(nf, rec);
+ *(cp + 1) = tmp;
- return (ret);
+ return (ret);
}
#endif /* HAVE_BSD_CGETENT */
@@ -706,63 +700,63 @@ static char *tbuf;
static char *
get_tc_token(char **srcp, int *endp)
{
- int ch;
- bool found = FALSE;
- char *s, *base;
- char *tok = 0;
-
- *endp = TRUE;
- for (s = base = *srcp; *s != '\0'; ) {
- ch = *s++;
- if (ch == '\\') {
- if (*s == '\0') {
- break;
- } else if (*s++ == '\n') {
- while (isspace(*s))
- s++;
- } else {
- found = TRUE;
- }
- } else if (ch == ':') {
- if (found) {
- tok = base;
- s[-1] = '\0';
- *srcp = s;
- *endp = FALSE;
- break;
- }
- base = s;
- } else if (isgraph(ch)) {
- found = TRUE;
- }
- }
-
- /* malformed entry may end without a ':' */
- if (tok == 0 && found) {
+ int ch;
+ bool found = FALSE;
+ char *s, *base;
+ char *tok = 0;
+
+ *endp = TRUE;
+ for (s = base = *srcp; *s != '\0';) {
+ ch = *s++;
+ if (ch == '\\') {
+ if (*s == '\0') {
+ break;
+ } else if (*s++ == '\n') {
+ while (isspace(*s))
+ s++;
+ } else {
+ found = TRUE;
+ }
+ } else if (ch == ':') {
+ if (found) {
tok = base;
+ s[-1] = '\0';
+ *srcp = s;
+ *endp = FALSE;
+ break;
+ }
+ base = s;
+ } else if (isgraph(ch)) {
+ found = TRUE;
}
+ }
+
+ /* malformed entry may end without a ':' */
+ if (tok == 0 && found) {
+ tok = base;
+ }
- return tok;
+ return tok;
}
static char *
copy_tc_token(char *dst, const char *src, size_t len)
{
- int ch;
+ int ch;
- while ((ch = *src++) != '\0') {
- if (ch == '\\' && *src == '\n') {
- while (isspace(*src))
- src++;
- continue;
- }
- if (--len == 0) {
- dst = 0;
- break;
- }
- *dst++ = ch;
+ while ((ch = *src++) != '\0') {
+ if (ch == '\\' && *src == '\n') {
+ while (isspace(*src))
+ src++;
+ continue;
+ }
+ if (--len == 0) {
+ dst = 0;
+ break;
}
- return dst;
+ *dst++ = ch;
+ }
+ return dst;
}
/*
@@ -771,127 +765,126 @@ copy_tc_token(char *dst, const char *src, size_t len)
static int
_nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
{
- static char *the_source;
-
- register char *p;
- register char *cp;
- char *dummy;
- char **fname;
- char *home;
- int i;
- char pathbuf[PBUFSIZ]; /* holds raw path of filenames */
- char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
- char **pvec; /* holds usable tail of path vector */
- char *termpath;
-
- fname = pathvec;
- pvec = pathvec;
- tbuf = bp;
- p = pathbuf;
- cp = getenv("TERMCAP");
-
- /*
- * TERMCAP can have one of two things in it. It can be the name of a
- * file to use instead of /etc/termcap. In this case it better start
- * with a "/". Or it can be an entry to use so we don't have to read
- * the file. In this case it has to already have the newlines crunched
- * out. If TERMCAP does not hold a file name then a path of names is
- * searched 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 */
- if ((termpath = getenv("TERMPATH")) != 0) {
- strncpy(pathbuf, termpath, PBUFSIZ - 1);
- } 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 */
+ static char *the_source;
+
+ register char *p;
+ register char *cp;
+ char *dummy;
+ char **fname;
+ char *home;
+ int i;
+ char pathbuf[PBUFSIZ]; /* holds raw path of filenames */
+ char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
+ char **pvec; /* holds usable tail of path vector */
+ char *termpath;
+
+ fname = pathvec;
+ pvec = pathvec;
+ tbuf = bp;
+ p = pathbuf;
+ cp = getenv("TERMCAP");
+
+ /*
+ * TERMCAP can have one of two things in it. It can be the name of a file
+ * to use instead of /etc/termcap. In this case it better start with a
+ * "/". Or it can be an entry to use so we don't have to read the file.
+ * In this case it has to already have the newlines crunched out. If
+ * TERMCAP does not hold a file name then a path of names is searched
+ * 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 */
+ if ((termpath = getenv("TERMPATH")) != 0) {
+ strncpy(pathbuf, termpath, PBUFSIZ - 1);
+ } 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));
- }
+ strncpy(p, MY_PATH_DEF, (size_t) (PBUFSIZ - (p - pathbuf) - 1));
}
- else /* user-defined name in TERMCAP */
- strncpy(pathbuf, cp, PBUFSIZ - 1); /* still can be tokenized */
- pathbuf[PBUFSIZ - 1] = '\0';
-
- *fname++ = pathbuf; /* tokenize path into vector of names */
- while (*++p) {
- if (*p == ' ' || *p == ':') {
- *p = '\0';
- while (*++p)
- if (*p != ' ' && *p != ':')
- break;
- if (*p == '\0')
- break;
- *fname++ = p;
- if (fname >= pathvec + PVECSIZ) {
- fname--;
- break;
- }
- }
+ } else /* user-defined name in TERMCAP */
+ strncpy(pathbuf, cp, PBUFSIZ - 1); /* still can be tokenized */
+ pathbuf[PBUFSIZ - 1] = '\0';
+
+ *fname++ = pathbuf; /* tokenize path into vector of names */
+ while (*++p) {
+ if (*p == ' ' || *p == ':') {
+ *p = '\0';
+ while (*++p)
+ if (*p != ' ' && *p != ':')
+ break;
+ if (*p == '\0')
+ break;
+ *fname++ = p;
+ if (fname >= pathvec + PVECSIZ) {
+ fname--;
+ break;
+ }
}
- *fname = 0; /* mark end of vector */
- if (is_pathname(cp)) {
- if (_nc_cgetset(cp) < 0) {
- return(TC_SYS_ERR);
- }
+ }
+ *fname = 0; /* mark end of vector */
+ if (is_pathname(cp)) {
+ if (_nc_cgetset(cp) < 0) {
+ return (TC_SYS_ERR);
}
-
- i = _nc_cgetent(&dummy, lineno, pathvec, name);
-
- /* ncurses' termcap-parsing routines cannot handle multiple adjacent
- * empty fields, and mistakenly use the last valid cap entry instead of
- * the first (breaks tc= includes)
- */
- if (i >= 0) {
- char *pd, *ps, *tok;
- int endflag = FALSE;
- char *list[1023];
- size_t n, count = 0;
-
- pd = bp;
- ps = dummy;
- while (!endflag && (tok = get_tc_token(&ps, &endflag)) != 0) {
- bool ignore = FALSE;
-
- for (n = 1; n < count; n++) {
- char *s = list[n];
- if (s[0] == tok[0]
- && s[1] == tok[1]) {
- ignore = TRUE;
- break;
- }
- }
- if (ignore != TRUE) {
- list[count++] = tok;
- pd = copy_tc_token(pd, tok, TBUFSIZ - (2+pd-bp));
- if (pd == 0) {
- i = -1;
- break;
- }
- *pd++ = ':';
- *pd = '\0';
- }
+ }
+
+ i = _nc_cgetent(&dummy, lineno, pathvec, name);
+
+ /* ncurses' termcap-parsing routines cannot handle multiple adjacent
+ * empty fields, and mistakenly use the last valid cap entry instead of
+ * the first (breaks tc= includes)
+ */
+ if (i >= 0) {
+ char *pd, *ps, *tok;
+ int endflag = FALSE;
+ char *list[1023];
+ size_t n, count = 0;
+
+ pd = bp;
+ ps = dummy;
+ while (!endflag && (tok = get_tc_token(&ps, &endflag)) != 0) {
+ bool ignore = FALSE;
+
+ for (n = 1; n < count; n++) {
+ char *s = list[n];
+ if (s[0] == tok[0]
+ && s[1] == tok[1]) {
+ ignore = TRUE;
+ break;
}
+ }
+ if (ignore != TRUE) {
+ list[count++] = tok;
+ pd = copy_tc_token(pd, tok, TBUFSIZ - (2 + pd - bp));
+ if (pd == 0) {
+ i = -1;
+ break;
+ }
+ *pd++ = ':';
+ *pd = '\0';
+ }
}
-
- FreeIfNeeded(dummy);
- FreeIfNeeded(the_source);
- the_source = 0;
-
- /* This is not related to the BSD cgetent(), but to fake up a suitable
- * filename for ncurses' error reporting. (If we are not using BSD
- * cgetent, then it is the actual filename).
- */
- if (i >= 0) {
- if ((the_source = strdup(pathvec[i])) != 0)
- *sourcename = the_source;
- }
-
- return(i);
+ }
+
+ FreeIfNeeded(dummy);
+ FreeIfNeeded(the_source);
+ the_source = 0;
+
+ /* This is not related to the BSD cgetent(), but to fake up a suitable
+ * filename for ncurses' error reporting. (If we are not using BSD
+ * cgetent, then it is the actual filename).
+ */
+ if (i >= 0) {
+ if ((the_source = strdup(pathvec[i])) != 0)
+ *sourcename = the_source;
+ }
+
+ return (i);
}
#endif /* USE_BSD_TGETENT */
#endif /* USE_GETCAP */
@@ -903,214 +896,207 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
* a right to open the file.
*/
#if !USE_GETCAP
-static int add_tc(char *termpaths[], char *path, int count)
+static int
+add_tc(char *termpaths[], char *path, int count)
{
- if (count < MAXPATHS
- && _nc_access(path, R_OK) == 0)
- termpaths[count++] = path;
- termpaths[count] = 0;
- return count;
+ if (count < MAXPATHS
+ && _nc_access(path, R_OK) == 0)
+ termpaths[count++] = path;
+ termpaths[count] = 0;
+ return count;
}
#define ADD_TC(path, count) filecount = add_tc(termpaths, path, count)
#endif /* !USE_GETCAP */
-int _nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
+int
+_nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
{
- int found = FALSE;
- ENTRY *ep;
+ int found = FALSE;
+ ENTRY *ep;
#if USE_GETCAP_CACHE
- char cwd_buf[PATH_MAX];
+ char cwd_buf[PATH_MAX];
#endif
#if USE_GETCAP
- char tc[TBUFSIZ];
- static char *source;
- static int lineno;
-
+ char *p, tc[TBUFSIZ];
+ static char *source;
+ static int lineno;
+
+ if ((p = getenv("TERMCAP")) != 0
+ && !is_pathname(p) && _nc_name_match(p, tn, "|:")) {
+ /* TERMCAP holds a termcap entry */
+ strncpy(tc, p, sizeof(tc) - 1);
+ tc[sizeof(tc) - 1] = '\0';
+ _nc_set_source("TERMCAP");
+ } else {
/* we're using getcap(3) */
if (_nc_tgetent(tc, &source, &lineno, tn) < 0)
- return (ERR);
+ return (ERR);
_nc_curr_line = lineno;
_nc_set_source(source);
- _nc_read_entry_source((FILE *)0, tc, FALSE, FALSE, NULLHOOK);
+ }
+ _nc_read_entry_source((FILE *) 0, tc, FALSE, FALSE, NULLHOOK);
#else
- /*
- * Here is what the 4.4BSD termcap(3) page prescribes:
- *
- * It will look in the environment for a TERMCAP variable. If found,
- * and the value does not begin with a slash, and the terminal type
- * name is the same as the environment string TERM, the TERMCAP string
- * is used instead of reading a termcap file. If it does begin with a
- * slash, the string is used as a path name of the termcap file to
- * search. If TERMCAP does not begin with a slash and name is
- * different from TERM, tgetent() searches the files $HOME/.termcap and
- * /usr/share/misc/termcap, in that order, unless the environment
- * variable TERMPATH exists, in which case it specifies a list of file
- * pathnames (separated by spaces or colons) to be searched instead.
- *
- * It goes on to state:
- *
- * Whenever multiple files are searched and a tc field occurs in the
- * requested entry, the entry it names must be found in the same file
- * or one of the succeeding files.
- *
- * However, this restriction is relaxed in ncurses; tc references to
- * previous files are permitted.
- *
- * This routine returns 1 if an entry is found, 0 if not found, and -1
- * if the database is not accessible.
- */
- FILE *fp;
- char *tc, *termpaths[MAXPATHS];
- int filecount = 0;
- bool use_buffer = FALSE;
- char tc_buf[1024];
- char pathbuf[PATH_MAX];
-
- termpaths[filecount] = 0;
- if ((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 */
- {
- use_buffer = TRUE;
- (void) sprintf(tc_buf, "%.*s\n", (int)sizeof(tc_buf)-2, tc);
- }
- else if ((tc = getenv("TERMPATH")) != 0)
- {
- char *cp;
-
- for (cp = tc; *cp; cp++)
- {
- if (*cp == ':')
- *cp = '\0';
- else if (cp == tc || cp[-1] == '\0')
- {
- ADD_TC(cp, filecount);
- }
- }
+ /*
+ * Here is what the 4.4BSD termcap(3) page prescribes:
+ *
+ * It will look in the environment for a TERMCAP variable. If found, and
+ * the value does not begin with a slash, and the terminal type name is the
+ * same as the environment string TERM, the TERMCAP string is used instead
+ * of reading a termcap file. If it does begin with a slash, the string is
+ * used as a path name of the termcap file to search. If TERMCAP does not
+ * begin with a slash and name is different from TERM, tgetent() searches
+ * the files $HOME/.termcap and /usr/share/misc/termcap, in that order,
+ * unless the environment variable TERMPATH exists, in which case it
+ * specifies a list of file pathnames (separated by spaces or colons) to be
+ * searched instead.
+ *
+ * It goes on to state:
+ *
+ * Whenever multiple files are searched and a tc field occurs in the
+ * requested entry, the entry it names must be found in the same file or
+ * one of the succeeding files.
+ *
+ * However, this restriction is relaxed in ncurses; tc references to
+ * previous files are permitted.
+ *
+ * This routine returns 1 if an entry is found, 0 if not found, and -1 if
+ * the database is not accessible.
+ */
+ FILE *fp;
+ char *tc, *termpaths[MAXPATHS];
+ int filecount = 0;
+ bool use_buffer = FALSE;
+ char tc_buf[1024];
+ char pathbuf[PATH_MAX];
+
+ termpaths[filecount] = 0;
+ if ((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 */
+ use_buffer = TRUE;
+ (void) sprintf(tc_buf, "%.*s\n", (int) sizeof(tc_buf) - 2, tc);
+ } else if ((tc = getenv("TERMPATH")) != 0) {
+ char *cp;
+
+ for (cp = tc; *cp; cp++) {
+ if (*cp == ':')
+ *cp = '\0';
+ else if (cp == tc || cp[-1] == '\0') {
+ ADD_TC(cp, filecount);
}
+ }
}
- else /* normal case */
- {
- char envhome[PATH_MAX], *h;
+ } else { /* normal case */
+ char envhome[PATH_MAX], *h;
- filecount = 0;
+ filecount = 0;
- /*
- * Probably /etc/termcap is a symlink to /usr/share/misc/termcap.
- * Avoid reading the same file twice.
- */
- if (_nc_access("/etc/termcap", F_OK) == 0)
- ADD_TC("/etc/termcap", filecount);
- else
- ADD_TC("/usr/share/misc/termcap", filecount);
+ /*
+ * Probably /etc/termcap is a symlink to /usr/share/misc/termcap.
+ * Avoid reading the same file twice.
+ */
+ if (_nc_access("/etc/termcap", F_OK) == 0)
+ ADD_TC("/etc/termcap", filecount);
+ else
+ ADD_TC("/usr/share/misc/termcap", filecount);
#define PRIVATE_CAP "%s/.termcap"
- if ((h = getenv("HOME")) != NULL
- && (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX)
- {
- /* user's .termcap, if any, should override it */
- (void) strcpy(envhome, h);
- (void) sprintf(pathbuf, PRIVATE_CAP, envhome);
- ADD_TC(pathbuf, filecount);
- }
+ if ((h = getenv("HOME")) != NULL
+ && (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) {
+ /* user's .termcap, if any, should override it */
+ (void) strcpy(envhome, h);
+ (void) sprintf(pathbuf, PRIVATE_CAP, envhome);
+ ADD_TC(pathbuf, filecount);
}
+ }
- /* parse the sources */
- if (use_buffer)
- {
- _nc_set_source("TERMCAP");
+ /* parse the sources */
+ if (use_buffer) {
+ _nc_set_source("TERMCAP");
- /*
- * We don't suppress warning messages here. The presumption is
- * that since it's just a single entry, they won't be a pain.
- */
- _nc_read_entry_source((FILE *)0, tc_buf, FALSE, FALSE, NULLHOOK);
- } else {
- int i;
+ /*
+ * We don't suppress warning messages here. The presumption is
+ * that since it's just a single entry, they won't be a pain.
+ */
+ _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, FALSE, NULLHOOK);
+ } else {
+ int i;
- for (i = 0; i < filecount; i++) {
+ for (i = 0; i < filecount; i++) {
- T(("Looking for %s in %s", tn, termpaths[i]));
- if ((fp = fopen(termpaths[i], "r")) != (FILE *)0)
- {
- _nc_set_source(termpaths[i]);
+ T(("Looking for %s in %s", tn, termpaths[i]));
+ if ((fp = fopen(termpaths[i], "r")) != (FILE *) 0) {
+ _nc_set_source(termpaths[i]);
- /*
- * Suppress warning messages. Otherwise you
- * get 400 lines of crap from archaic termcap
- * files as ncurses complains about all the
- * obsolete capabilities.
- */
- _nc_read_entry_source(fp, (char*)0, FALSE, TRUE, NULLHOOK);
+ /*
+ * Suppress warning messages. Otherwise you get 400 lines of
+ * crap from archaic termcap files as ncurses complains about
+ * all the obsolete capabilities.
+ */
+ _nc_read_entry_source(fp, (char *) 0, FALSE, TRUE, NULLHOOK);
- (void) fclose(fp);
- }
- }
+ (void) fclose(fp);
+ }
}
+ }
#endif /* USE_GETCAP */
- if (_nc_head == 0)
- return(ERR);
+ if (_nc_head == 0)
+ return (ERR);
- /* resolve all use references */
- _nc_resolve_uses();
+ /* resolve all use references */
+ _nc_resolve_uses(TRUE);
- /* find a terminal matching tn, if we can */
+ /* find a terminal matching tn, if we can */
#if USE_GETCAP_CACHE
- if (getcwd(cwd_buf, sizeof(cwd_buf)) != 0)
- {
- _nc_set_writedir((char *)0); /* note: this does a chdir */
+ if (getcwd(cwd_buf, sizeof(cwd_buf)) != 0) {
+ _nc_set_writedir((char *) 0); /* note: this does a chdir */
#endif
- for_entry_list(ep) {
- if (_nc_name_match(ep->tterm.term_names, tn, "|:"))
- {
- /*
- * Make a local copy of the terminal
- * capabilities. Free all entry storage except
- * the string table for the loaded type (which
- * we disconnected from the list by NULLing out
- * ep->tterm.str_table above).
- */
- *tp = ep->tterm;
- ep->tterm.str_table = (char *)0;
-
- /*
- * OK, now try to write the type to user's
- * terminfo directory. Next time he loads
- * this, it will come through terminfo.
- *
- * Advantage: Second and subsequent fetches of
- * this entry will be very fast.
- *
- * Disadvantage: After the first time a
- * termcap type is loaded by its user, editing
- * it in the /etc/termcap file, or in TERMCAP,
- * or in a local ~/.termcap, will be
- * ineffective unless the terminfo entry is
- * explicitly removed.
- */
+ for_entry_list(ep) {
+ if (_nc_name_match(ep->tterm.term_names, tn, "|:")) {
+ /*
+ * Make a local copy of the terminal capabilities. Free all
+ * entry storage except the string table for the loaded type
+ * (which we disconnected from the list by NULLing out
+ * ep->tterm.str_table above).
+ */
+ *tp = ep->tterm;
+ ep->tterm.str_table = (char *) 0;
+
+ /*
+ * OK, now try to write the type to user's terminfo directory.
+ * Next time he loads this, it will come through terminfo.
+ *
+ * Advantage: Second and subsequent fetches of this entry will
+ * be very fast.
+ *
+ * Disadvantage: After the first time a termcap type is loaded
+ * by its user, editing it in the /etc/termcap file, or in
+ * TERMCAP, or in a local ~/.termcap, will be ineffective
+ * unless the terminfo entry is explicitly removed.
+ */
#if USE_GETCAP_CACHE
- (void) _nc_write_entry(tp);
+ (void) _nc_write_entry(tp);
#endif
- found = TRUE;
- break;
- }
- }
-#if USE_GETCAP_CACHE
- chdir(cwd_buf);
+ found = TRUE;
+ break;
+ }
}
+#if USE_GETCAP_CACHE
+ chdir(cwd_buf);
+ }
#endif
- _nc_free_entries(_nc_head);
- return(found);
+ _nc_free_entries(_nc_head);
+ return (found);
}
#else
-extern void _nc_read_termcap(void);
- void _nc_read_termcap(void) { }
-#endif /* PURE_TERMINFO */
+extern void _nc_read_termcap(void);
+void
+_nc_read_termcap(void)
+{
+}
+#endif /* PURE_TERMINFO */
diff --git a/contrib/ncurses/ncurses/tinfo/write_entry.c b/contrib/ncurses/ncurses/tinfo/write_entry.c
index 4829fa936d01..12aedd6e565c 100644
--- a/contrib/ncurses/ncurses/tinfo/write_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/write_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* write_entry.c -- write a terminfo structure onto the file system
*/
@@ -51,28 +49,29 @@
#if 0
#define TRACE_OUT(p) DEBUG(2, p)
#else
-#define TRACE_OUT(p) /*nothing*/
+#define TRACE_OUT(p) /*nothing */
#endif
-MODULE_ID("$Id: write_entry.c,v 1.47 1999/07/10 20:29:22 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.52 2000/03/11 12:23:42 tom Exp $")
static int total_written;
static int write_object(FILE *, TERMTYPE *);
-static void write_file(char *filename, TERMTYPE *tp)
+static void
+write_file(char *filename, TERMTYPE * tp)
{
- FILE *fp = (_nc_access(filename, W_OK) == 0) ? fopen(filename, "wb") : 0;
- if (fp == 0) {
- perror(filename);
- _nc_syserr_abort("can't open %s/%s", _nc_tic_dir(0), filename);
- }
- DEBUG(1, ("Created %s", filename));
+ FILE *fp = (_nc_access(filename, W_OK) == 0) ? fopen(filename, "wb") : 0;
+ if (fp == 0) {
+ perror(filename);
+ _nc_syserr_abort("can't open %s/%s", _nc_tic_dir(0), filename);
+ }
+ DEBUG(1, ("Created %s", filename));
- if (write_object(fp, tp) == ERR) {
- _nc_syserr_abort("error writing %s/%s", _nc_tic_dir(0), filename);
- }
- fclose(fp);
+ if (write_object(fp, tp) == ERR) {
+ _nc_syserr_abort("error writing %s/%s", _nc_tic_dir(0), filename);
+ }
+ fclose(fp);
}
/*
@@ -80,36 +79,38 @@ static void write_file(char *filename, TERMTYPE *tp)
*
* Make a directory if it doesn't exist.
*/
-static int make_directory(const char *path)
+static int
+make_directory(const char *path)
{
-int rc;
-struct stat statbuf;
-char fullpath[PATH_MAX];
-const char *destination = _nc_tic_dir(0);
-
- if (path == destination || *path == '/') {
- if (strlen(path) + 1 > sizeof(fullpath))
- return(-1);
- (void)strcpy(fullpath, path);
- } else {
- if (strlen(destination) + strlen(path) + 2 > sizeof(fullpath))
- return(-1);
- (void)sprintf(fullpath, "%s/%s", destination, path);
- }
+ int rc;
+ struct stat statbuf;
+ char fullpath[PATH_MAX];
+ const char *destination = _nc_tic_dir(0);
+
+ if (path == destination || *path == '/') {
+ if (strlen(path) + 1 > sizeof(fullpath))
+ return (-1);
+ (void) strcpy(fullpath, path);
+ } else {
+ if (strlen(destination) + strlen(path) + 2 > sizeof(fullpath))
+ return (-1);
+ (void) sprintf(fullpath, "%s/%s", destination, path);
+ }
- if ((rc = stat(path, &statbuf)) < 0) {
- rc = mkdir(path, 0777);
- } else {
- if (_nc_access(path, R_OK|W_OK|X_OK) < 0) {
- rc = -1; /* permission denied */
- } else if (!(S_ISDIR(statbuf.st_mode))) {
- rc = -1; /* not a directory */
- }
+ if ((rc = stat(path, &statbuf)) < 0) {
+ rc = mkdir(path, 0777);
+ } else {
+ if (_nc_access(path, R_OK | W_OK | X_OK) < 0) {
+ rc = -1; /* permission denied */
+ } else if (!(S_ISDIR(statbuf.st_mode))) {
+ rc = -1; /* not a directory */
}
- return rc;
+ }
+ return rc;
}
-void _nc_set_writedir(char *dir)
+void
+_nc_set_writedir(char *dir)
/* set the write directory for compiled entries */
{
const char *destination;
@@ -121,15 +122,14 @@ void _nc_set_writedir(char *dir)
(void) _nc_tic_dir(getenv("TERMINFO"));
destination = _nc_tic_dir(0);
- if (make_directory(destination) < 0)
- {
- char *home = _nc_home_terminfo();
+ if (make_directory(destination) < 0) {
+ char *home = _nc_home_terminfo();
if (home != 0) {
destination = home;
if (make_directory(destination) < 0)
_nc_err_abort("%s: permission denied (errno %d)",
- destination, errno);
+ destination, errno);
}
}
@@ -138,7 +138,7 @@ void _nc_set_writedir(char *dir)
* *once only* per run.
*/
if (chdir(_nc_tic_dir(destination)) < 0
- || getcwd(actual, sizeof(actual)) == 0)
+ || getcwd(actual, sizeof(actual)) == 0)
_nc_err_abort("%s: not a directory", destination);
_nc_keep_tic_dir(strdup(actual));
}
@@ -155,27 +155,28 @@ void _nc_set_writedir(char *dir)
*
*/
-static void check_writeable(int code)
+static void
+check_writeable(int code)
{
-static const char dirnames[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-static bool verified[sizeof(dirnames)];
+ static const char dirnames[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ static bool verified[sizeof(dirnames)];
-char dir[2];
-char *s;
+ char dir[2];
+ char *s;
- if (code == 0 || (s = strchr(dirnames, code)) == 0)
- _nc_err_abort("Illegal terminfo subdirectory \"%c\"", code);
+ if (code == 0 || (s = strchr(dirnames, code)) == 0)
+ _nc_err_abort("Illegal terminfo subdirectory \"%c\"", code);
- if (verified[s-dirnames])
- return;
+ if (verified[s - dirnames])
+ return;
- dir[0] = code;
- dir[1] = '\0';
- if (make_directory(dir) < 0) {
- _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir);
- }
+ dir[0] = code;
+ dir[1] = '\0';
+ if (make_directory(dir) < 0) {
+ _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir);
+ }
- verified[s-dirnames] = TRUE;
+ verified[s - dirnames] = TRUE;
}
/*
@@ -200,163 +201,159 @@ char *s;
* _nc_curr_line is properly set before the write_entry() call.
*/
-void _nc_write_entry(TERMTYPE *const tp)
+void
+_nc_write_entry(TERMTYPE * const tp)
{
-struct stat statbuf;
-char name_list[MAX_TERMINFO_LENGTH];
-char *first_name, *other_names;
-char *ptr;
-char filename[PATH_MAX];
-char linkname[PATH_MAX];
+ struct stat statbuf;
+ char name_list[MAX_TERMINFO_LENGTH];
+ char *first_name, *other_names;
+ char *ptr;
+ char filename[PATH_MAX];
+ char linkname[PATH_MAX];
#if USE_SYMLINKS
-char symlinkname[PATH_MAX];
+ char symlinkname[PATH_MAX];
#endif /* USE_SYMLINKS */
-static int call_count;
-static time_t start_time; /* time at start of writes */
+ static int call_count;
+ static time_t start_time; /* time at start of writes */
- if (call_count++ == 0) {
- start_time = 0;
- }
+ if (call_count++ == 0) {
+ start_time = 0;
+ }
- (void) strcpy(name_list, tp->term_names);
- DEBUG(7, ("Name list = '%s'", name_list));
+ (void) strcpy(name_list, tp->term_names);
+ DEBUG(7, ("Name list = '%s'", name_list));
- first_name = name_list;
+ first_name = name_list;
- ptr = &name_list[strlen(name_list) - 1];
- other_names = ptr + 1;
+ ptr = &name_list[strlen(name_list) - 1];
+ other_names = ptr + 1;
- while (ptr > name_list && *ptr != '|')
- ptr--;
+ while (ptr > name_list && *ptr != '|')
+ ptr--;
- if (ptr != name_list) {
- *ptr = '\0';
+ if (ptr != name_list) {
+ *ptr = '\0';
- for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++)
- continue;
+ for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++)
+ continue;
- if (*ptr == '\0')
- other_names = ptr;
- else {
- *ptr = '\0';
- other_names = ptr + 1;
- }
+ if (*ptr == '\0')
+ other_names = ptr;
+ else {
+ *ptr = '\0';
+ other_names = ptr + 1;
}
+ }
- DEBUG(7, ("First name = '%s'", first_name));
- DEBUG(7, ("Other names = '%s'", other_names));
+ DEBUG(7, ("First name = '%s'", first_name));
+ DEBUG(7, ("Other names = '%s'", other_names));
- _nc_set_type(first_name);
+ _nc_set_type(first_name);
- if (strlen(first_name) > sizeof(filename)-3)
- _nc_warning("terminal name too long.");
+ if (strlen(first_name) > sizeof(filename) - 3)
+ _nc_warning("terminal name too long.");
- sprintf(filename, "%c/%s", first_name[0], first_name);
+ sprintf(filename, "%c/%s", first_name[0], first_name);
- /*
- * Has this primary name been written since the first call to
- * write_entry()? If so, the newer write will step on the older,
- * so warn the user.
- */
- if (start_time > 0 &&
- stat(filename, &statbuf) >= 0
- && statbuf.st_mtime >= start_time)
- {
- _nc_warning("name multiply defined.");
+ /*
+ * Has this primary name been written since the first call to
+ * write_entry()? If so, the newer write will step on the older,
+ * so warn the user.
+ */
+ if (start_time > 0 &&
+ stat(filename, &statbuf) >= 0
+ && statbuf.st_mtime >= start_time) {
+ _nc_warning("name multiply defined.");
+ }
+
+ check_writeable(first_name[0]);
+ write_file(filename, tp);
+
+ if (start_time == 0) {
+ if (stat(filename, &statbuf) < 0
+ || (start_time = statbuf.st_mtime) == 0) {
+ _nc_syserr_abort("error obtaining time from %s/%s",
+ _nc_tic_dir(0), filename);
}
+ }
+ while (*other_names != '\0') {
+ ptr = other_names++;
+ while (*other_names != '|' && *other_names != '\0')
+ other_names++;
- check_writeable(first_name[0]);
- write_file(filename, tp);
+ if (*other_names != '\0')
+ *(other_names++) = '\0';
- if (start_time == 0) {
- if (stat(filename, &statbuf) < 0
- || (start_time = statbuf.st_mtime) == 0) {
- _nc_syserr_abort("error obtaining time from %s/%s",
- _nc_tic_dir(0), filename);
- }
+ if (strlen(ptr) > sizeof(linkname) - 3) {
+ _nc_warning("terminal alias %s too long.", ptr);
+ continue;
}
- while (*other_names != '\0') {
- ptr = other_names++;
- while (*other_names != '|' && *other_names != '\0')
- other_names++;
-
- if (*other_names != '\0')
- *(other_names++) = '\0';
-
- if (strlen(ptr) > sizeof(linkname)-3) {
- _nc_warning("terminal alias %s too long.", ptr);
- continue;
- }
- if (strchr(ptr, '/') != 0) {
- _nc_warning("cannot link alias %s.", ptr);
- continue;
- }
-
- check_writeable(ptr[0]);
- sprintf(linkname, "%c/%s", ptr[0], ptr);
-
- if (strcmp(filename, linkname) == 0) {
- _nc_warning("self-synonym ignored");
- }
- else if (stat(linkname, &statbuf) >= 0 &&
- statbuf.st_mtime < start_time)
- {
- _nc_warning("alias %s multiply defined.", ptr);
- }
- else if (_nc_access(linkname, W_OK) == 0)
+ if (strchr(ptr, '/') != 0) {
+ _nc_warning("cannot link alias %s.", ptr);
+ continue;
+ }
+
+ check_writeable(ptr[0]);
+ sprintf(linkname, "%c/%s", ptr[0], ptr);
+
+ if (strcmp(filename, linkname) == 0) {
+ _nc_warning("self-synonym ignored");
+ } else if (stat(linkname, &statbuf) >= 0 &&
+ statbuf.st_mtime < start_time) {
+ _nc_warning("alias %s multiply defined.", ptr);
+ } else if (_nc_access(linkname, W_OK) == 0)
#if HAVE_LINK
- {
- int code;
+ {
+ int code;
#if USE_SYMLINKS
- strcpy(symlinkname, "../");
- strncat(symlinkname, filename, sizeof(symlinkname) - 4);
- symlinkname[sizeof(symlinkname) - 1] = '\0';
+ strcpy(symlinkname, "../");
+ strncat(symlinkname, filename, sizeof(symlinkname) - 4);
+ symlinkname[sizeof(symlinkname) - 1] = '\0';
#endif /* USE_SYMLINKS */
#if HAVE_REMOVE
- code = remove(linkname);
+ code = remove(linkname);
#else
- code = unlink(linkname);
+ code = unlink(linkname);
#endif
- if (code != 0 && errno == ENOENT)
- code = 0;
+ if (code != 0 && errno == ENOENT)
+ code = 0;
#if USE_SYMLINKS
- if (symlink(symlinkname, linkname) < 0)
+ if (symlink(symlinkname, linkname) < 0)
#else
- if (link(filename, linkname) < 0)
+ if (link(filename, linkname) < 0)
#endif /* USE_SYMLINKS */
- {
- /*
- * If there wasn't anything there, and we cannot
- * link to the target because it is the same as the
- * target, then the source must be on a filesystem
- * that uses caseless filenames, such as Win32, etc.
- */
- if (code == 0 && errno == EEXIST)
- _nc_warning("can't link %s to %s", filename, linkname);
- else if (code == 0 && errno == EPERM)
- write_file(linkname, tp);
- else
- _nc_syserr_abort("can't link %s to %s", filename, linkname);
- }
- else
- {
- DEBUG(1, ("Linked %s", linkname));
- }
- }
+ {
+ /*
+ * If there wasn't anything there, and we cannot
+ * link to the target because it is the same as the
+ * target, then the source must be on a filesystem
+ * that uses caseless filenames, such as Win32, etc.
+ */
+ if (code == 0 && errno == EEXIST)
+ _nc_warning("can't link %s to %s", filename, linkname);
+ else if (code == 0 && errno == EPERM)
+ write_file(linkname, tp);
+ else
+ _nc_syserr_abort("can't link %s to %s", filename, linkname);
+ } else {
+ DEBUG(1, ("Linked %s", linkname));
+ }
+ }
#else /* just make copies */
- write_file(linkname, tp);
+ write_file(linkname, tp);
#endif /* HAVE_LINK */
- }
+ }
}
-#undef LITTLE_ENDIAN /* BSD/OS defines this as a feature macro */
+#undef LITTLE_ENDIAN /* BSD/OS defines this as a feature macro */
#define HI(x) ((x) / 256)
#define LO(x) ((x) % 256)
#define LITTLE_ENDIAN(p, x) (p)[0] = LO(x), (p)[1] = HI(x)
#define WRITE_STRING(str) (fwrite(str, sizeof(char), strlen(str) + 1, fp) == strlen(str) + 1)
-static int compute_offsets(char **Strings, int strmax, short *offsets)
+static int
+compute_offsets(char **Strings, int strmax, short *offsets)
{
size_t nextfree = 0;
int i;
@@ -375,17 +372,18 @@ static int compute_offsets(char **Strings, int strmax, short *offsets)
return nextfree;
}
-static void convert_shorts(unsigned char *buf, short *Numbers, int count)
+static void
+convert_shorts(unsigned char *buf, short *Numbers, int count)
{
int i;
for (i = 0; i < count; i++) {
- if (Numbers[i] == -1) { /* HI/LO won't work */
- buf[2*i] = buf[2*i + 1] = 0377;
- } else if (Numbers[i] == -2) { /* HI/LO won't work */
- buf[2*i] = 0376;
- buf[2*i + 1] = 0377;
+ if (Numbers[i] == ABSENT_NUMERIC) { /* HI/LO won't work */
+ buf[2 * i] = buf[2 * i + 1] = 0377;
+ } else if (Numbers[i] == CANCELLED_NUMERIC) { /* HI/LO won't work */
+ buf[2 * i] = 0376;
+ buf[2 * i + 1] = 0377;
} else {
- LITTLE_ENDIAN(buf + 2*i, Numbers[i]);
+ LITTLE_ENDIAN(buf + 2 * i, Numbers[i]);
TRACE_OUT(("put Numbers[%d]=%d", i, Numbers[i]));
}
}
@@ -394,164 +392,188 @@ static void convert_shorts(unsigned char *buf, short *Numbers, int count)
#define even_boundary(value) \
((value) % 2 != 0 && fwrite(&zero, sizeof(char), 1, fp) != 1)
-static int write_object(FILE *fp, TERMTYPE *tp)
+static int
+write_object(FILE * fp, TERMTYPE * tp)
{
-char *namelist;
-size_t namelen, boolmax, nummax, strmax;
-char zero = '\0';
-size_t i;
-short nextfree;
-short offsets[MAX_ENTRY_SIZE/2];
-unsigned char buf[MAX_ENTRY_SIZE];
+ char *namelist;
+ size_t namelen, boolmax, nummax, strmax;
+ char zero = '\0';
+ size_t i;
+ short nextfree;
+ short offsets[MAX_ENTRY_SIZE / 2];
+ unsigned char buf[MAX_ENTRY_SIZE];
+ unsigned last_bool = BOOLWRITE;
+ unsigned last_num = NUMWRITE;
+ unsigned last_str = STRWRITE;
- namelist = tp->term_names;
- namelen = strlen(namelist) + 1;
+#if NCURSES_XNAMES
+ /*
+ * Normally we limit the list of values to exclude the "obsolete"
+ * capabilities. However, if we are accepting extended names, add
+ * these as well, since they are used for supporting translation
+ * to/from termcap.
+ */
+ if (_nc_user_definable) {
+ last_bool = BOOLCOUNT;
+ last_num = NUMCOUNT;
+ last_str = STRCOUNT;
+ }
+#endif
- /*
- * BOOLWRITE, etc., are less than BOOLCOUNT because we store some
- * values internally.
- */
- boolmax = 0;
- for (i = 0; i < BOOLWRITE; i++) {
- if (tp->Booleans[i])
- boolmax = i+1;
- }
+ namelist = tp->term_names;
+ namelen = strlen(namelist) + 1;
- nummax = 0;
- for (i = 0; i < NUMWRITE; i++) {
- if (tp->Numbers[i] != ABSENT_NUMERIC)
- nummax = i+1;
- }
+ boolmax = 0;
+ for (i = 0; i < last_bool; i++) {
+ if (tp->Booleans[i] == TRUE)
+ boolmax = i + 1;
+ }
- strmax = 0;
- for (i = 0; i < STRWRITE; i++) {
- if (tp->Strings[i] != ABSENT_STRING)
- strmax = i+1;
- }
+ nummax = 0;
+ for (i = 0; i < last_num; i++) {
+ if (tp->Numbers[i] != ABSENT_NUMERIC)
+ nummax = i + 1;
+ }
- nextfree = compute_offsets(tp->Strings, strmax, offsets);
+ strmax = 0;
+ for (i = 0; i < last_str; i++) {
+ if (tp->Strings[i] != ABSENT_STRING)
+ strmax = i + 1;
+ }
- /* fill in the header */
- LITTLE_ENDIAN(buf, MAGIC);
- LITTLE_ENDIAN(buf+2, min(namelen, MAX_NAME_SIZE + 1));
- LITTLE_ENDIAN(buf+4, boolmax);
- LITTLE_ENDIAN(buf+6, nummax);
- LITTLE_ENDIAN(buf+8, strmax);
- LITTLE_ENDIAN(buf+10, nextfree);
+ nextfree = compute_offsets(tp->Strings, strmax, offsets);
- /* write out the header */
- TRACE_OUT(("Header of %s @%ld", namelist, ftell(fp)));
- if (fwrite(buf, 12, 1, fp) != 1
- || fwrite(namelist, sizeof(char), namelen, fp) != namelen
- || fwrite(tp->Booleans, sizeof(char), boolmax, fp) != boolmax)
- return(ERR);
+ /* fill in the header */
+ LITTLE_ENDIAN(buf, MAGIC);
+ LITTLE_ENDIAN(buf + 2, min(namelen, MAX_NAME_SIZE + 1));
+ LITTLE_ENDIAN(buf + 4, boolmax);
+ LITTLE_ENDIAN(buf + 6, nummax);
+ LITTLE_ENDIAN(buf + 8, strmax);
+ LITTLE_ENDIAN(buf + 10, nextfree);
- if (even_boundary(namelen+boolmax))
- return(ERR);
+ /* write out the header */
+ TRACE_OUT(("Header of %s @%ld", namelist, ftell(fp)));
+ if (fwrite(buf, 12, 1, fp) != 1
+ || fwrite(namelist, sizeof(char), namelen, fp) != namelen)
+ return (ERR);
- TRACE_OUT(("Numerics begin at %04lx", ftell(fp)));
+ for (i = 0; i < boolmax; i++)
+ if (tp->Booleans[i] == TRUE)
+ buf[i] = TRUE;
+ else
+ buf[i] = FALSE;
+ if (fwrite(buf, sizeof(char), boolmax, fp) != boolmax)
+ return (ERR);
- /* the numerics */
- convert_shorts(buf, tp->Numbers, nummax);
- if (fwrite(buf, 2, nummax, fp) != nummax)
- return(ERR);
+ if (even_boundary(namelen + boolmax))
+ return (ERR);
- TRACE_OUT(("String offsets begin at %04lx", ftell(fp)));
+ TRACE_OUT(("Numerics begin at %04lx", ftell(fp)));
- /* the string offsets */
- convert_shorts(buf, offsets, strmax);
- if (fwrite(buf, 2, strmax, fp) != strmax)
- return(ERR);
+ /* the numerics */
+ convert_shorts(buf, tp->Numbers, nummax);
+ if (fwrite(buf, 2, nummax, fp) != nummax)
+ return (ERR);
- TRACE_OUT(("String table begins at %04lx", ftell(fp)));
+ TRACE_OUT(("String offsets begin at %04lx", ftell(fp)));
- /* the strings */
- for (i = 0; i < strmax; i++)
- if (VALID_STRING(tp->Strings[i]))
- if (!WRITE_STRING(tp->Strings[i]))
- return(ERR);
+ /* the string offsets */
+ convert_shorts(buf, offsets, strmax);
+ if (fwrite(buf, 2, strmax, fp) != strmax)
+ return (ERR);
+
+ TRACE_OUT(("String table begins at %04lx", ftell(fp)));
+
+ /* the strings */
+ for (i = 0; i < strmax; i++)
+ if (VALID_STRING(tp->Strings[i]))
+ if (!WRITE_STRING(tp->Strings[i]))
+ return (ERR);
#if NCURSES_XNAMES
- if (NUM_EXT_NAMES(tp)) {
- unsigned extcnt = NUM_EXT_NAMES(tp);
-
- if (even_boundary(nextfree))
- return(ERR);
-
- nextfree = compute_offsets(tp->Strings + STRCOUNT, tp->ext_Strings, offsets);
- TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
- nextfree += compute_offsets(tp->ext_Names, extcnt, offsets + tp->ext_Strings);
- TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
- strmax = tp->ext_Strings + extcnt;
-
- /*
- * Write the extended header
- */
- LITTLE_ENDIAN(buf+0, tp->ext_Booleans);
- LITTLE_ENDIAN(buf+2, tp->ext_Numbers);
- LITTLE_ENDIAN(buf+4, tp->ext_Strings);
- LITTLE_ENDIAN(buf+6, strmax);
- LITTLE_ENDIAN(buf+8, nextfree);
- TRACE_OUT(("WRITE extended-header @%ld", ftell(fp)));
- if (fwrite(buf, 10, 1, fp) != 1)
- return(ERR);
-
- TRACE_OUT(("WRITE %d booleans @%ld", tp->ext_Booleans, ftell(fp)));
- if (tp->ext_Booleans
- && fwrite(tp->Booleans + BOOLCOUNT, sizeof(char), tp->ext_Booleans, fp) != tp->ext_Booleans)
- return(ERR);
-
- if (even_boundary(tp->ext_Booleans))
- return(ERR);
-
- TRACE_OUT(("WRITE %d numbers @%ld", tp->ext_Numbers, ftell(fp)));
- if (tp->ext_Numbers) {
- convert_shorts(buf, tp->Numbers + NUMCOUNT, tp->ext_Numbers);
- if (fwrite(buf, 2, tp->ext_Numbers, fp) != tp->ext_Numbers)
- return(ERR);
- }
+ if (NUM_EXT_NAMES(tp)) {
+ unsigned extcnt = NUM_EXT_NAMES(tp);
- /*
- * Convert the offsets for the ext_Strings and ext_Names tables,
- * in that order.
- */
- convert_shorts(buf, offsets, strmax);
- TRACE_OUT(("WRITE offsets @%ld", ftell(fp)));
- if (fwrite(buf, 2, strmax, fp) != strmax)
- return(ERR);
-
- /*
- * Write the string table after the offset tables so we do not
- * have to do anything about alignment.
- */
- for (i = 0; i < tp->ext_Strings; i++) {
- if (VALID_STRING(tp->Strings[i+STRCOUNT])) {
- TRACE_OUT(("WRITE ext_Strings[%d]=%s", i, _nc_visbuf(tp->Strings[i+STRCOUNT])));
- if (!WRITE_STRING(tp->Strings[i+STRCOUNT]))
- return(ERR);
- }
- }
+ if (even_boundary(nextfree))
+ return (ERR);
- /*
- * Write the extended names
- */
- for (i = 0; i < extcnt; i++) {
- TRACE_OUT(("WRITE ext_Names[%d]=%s", i, tp->ext_Names[i]));
- if (!WRITE_STRING(tp->ext_Names[i]))
- return(ERR);
+ nextfree = compute_offsets(tp->Strings + STRCOUNT, tp->ext_Strings, offsets);
+ TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
+ nextfree += compute_offsets(tp->ext_Names, extcnt, offsets + tp->ext_Strings);
+ TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
+ strmax = tp->ext_Strings + extcnt;
+
+ /*
+ * Write the extended header
+ */
+ LITTLE_ENDIAN(buf + 0, tp->ext_Booleans);
+ LITTLE_ENDIAN(buf + 2, tp->ext_Numbers);
+ LITTLE_ENDIAN(buf + 4, tp->ext_Strings);
+ LITTLE_ENDIAN(buf + 6, strmax);
+ LITTLE_ENDIAN(buf + 8, nextfree);
+ TRACE_OUT(("WRITE extended-header @%ld", ftell(fp)));
+ if (fwrite(buf, 10, 1, fp) != 1)
+ return (ERR);
+
+ TRACE_OUT(("WRITE %d booleans @%ld", tp->ext_Booleans, ftell(fp)));
+ if (tp->ext_Booleans
+ && fwrite(tp->Booleans + BOOLCOUNT, sizeof(char),
+ tp->ext_Booleans, fp) != tp->ext_Booleans)
+ return (ERR);
+
+ if (even_boundary(tp->ext_Booleans))
+ return (ERR);
+
+ TRACE_OUT(("WRITE %d numbers @%ld", tp->ext_Numbers, ftell(fp)));
+ if (tp->ext_Numbers) {
+ convert_shorts(buf, tp->Numbers + NUMCOUNT, tp->ext_Numbers);
+ if (fwrite(buf, 2, tp->ext_Numbers, fp) != tp->ext_Numbers)
+ return (ERR);
+ }
+
+ /*
+ * Convert the offsets for the ext_Strings and ext_Names tables,
+ * in that order.
+ */
+ convert_shorts(buf, offsets, strmax);
+ TRACE_OUT(("WRITE offsets @%ld", ftell(fp)));
+ if (fwrite(buf, 2, strmax, fp) != strmax)
+ return (ERR);
+
+ /*
+ * Write the string table after the offset tables so we do not
+ * have to do anything about alignment.
+ */
+ for (i = 0; i < tp->ext_Strings; i++) {
+ if (VALID_STRING(tp->Strings[i + STRCOUNT])) {
+ TRACE_OUT(("WRITE ext_Strings[%d]=%s", i,
+ _nc_visbuf(tp->Strings[i + STRCOUNT])));
+ if (!WRITE_STRING(tp->Strings[i + STRCOUNT]))
+ return (ERR);
}
+ }
+ /*
+ * Write the extended names
+ */
+ for (i = 0; i < extcnt; i++) {
+ TRACE_OUT(("WRITE ext_Names[%d]=%s", i, tp->ext_Names[i]));
+ if (!WRITE_STRING(tp->ext_Names[i]))
+ return (ERR);
}
+
+ }
#endif /* NCURSES_XNAMES */
- total_written++;
- return(OK);
+ total_written++;
+ return (OK);
}
/*
* Returns the total number of entries written by this process
*/
-int _nc_tic_written(void)
+int
+_nc_tic_written(void)
{
- return total_written;
+ return total_written;
}
diff --git a/contrib/ncurses/ncurses/trace/lib_trace.c b/contrib/ncurses/ncurses/trace/lib_trace.c
index 0f47e16e698f..51260aec6b17 100644
--- a/contrib/ncurses/ncurses/trace/lib_trace.c
+++ b/contrib/ncurses/ncurses/trace/lib_trace.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -38,163 +38,179 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: lib_trace.c,v 1.30 1998/10/03 23:41:42 tom Exp $")
-
#include <ctype.h>
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
+
+MODULE_ID("$Id: lib_trace.c,v 1.34 2000/04/01 20:25:47 tom Exp $")
unsigned _nc_tracing = 0; /* always define this */
#ifdef TRACE
const char *_nc_tputs_trace = "";
-long _nc_outchars;
+long _nc_outchars = 0;
-static FILE * tracefp; /* default to writing to stderr */
-#endif
+static FILE *tracefp; /* default to writing to stderr */
-void _nc_trace(const unsigned int tracelevel GCC_UNUSED)
+void
+trace(const unsigned int tracelevel GCC_UNUSED)
{
-#ifdef TRACE
-static bool been_here = FALSE;
-static char my_name[] = "trace";
-
- _nc_tracing = tracelevel;
- if (! been_here && tracelevel) {
- been_here = TRUE;
-
- if (_nc_access(my_name, W_OK) < 0
- || (tracefp = fopen(my_name, "w")) == 0) {
- perror("curses: Can't open 'trace' file: ");
- exit(EXIT_FAILURE);
- }
- /* Try to set line-buffered mode, or (failing that) unbuffered,
- * so that the trace-output gets flushed automatically at the
- * end of each line. This is useful in case the program dies.
- */
-#if HAVE_SETVBUF /* ANSI */
- (void) setvbuf(tracefp, (char *)0, _IOLBF, 0);
-#elif HAVE_SETBUF /* POSIX */
- (void) setbuffer(tracefp, (char *)0);
-#endif
- _tracef("TRACING NCURSES version %s (%d)",
- NCURSES_VERSION, NCURSES_VERSION_PATCH);
+ static bool been_here = FALSE;
+ static char my_name[] = "trace";
+
+ _nc_tracing = tracelevel;
+ if (!been_here && tracelevel) {
+ been_here = TRUE;
+
+ if (_nc_access(my_name, W_OK) < 0
+ || (tracefp = fopen(my_name, "w")) == 0) {
+ perror("curses: Can't open 'trace' file: ");
+ exit(EXIT_FAILURE);
}
+ /* Try to set line-buffered mode, or (failing that) unbuffered,
+ * so that the trace-output gets flushed automatically at the
+ * end of each line. This is useful in case the program dies.
+ */
+#if HAVE_SETVBUF /* ANSI */
+ (void) setvbuf(tracefp, (char *) 0, _IOLBF, 0);
+#elif HAVE_SETBUF /* POSIX */
+ (void) setbuffer(tracefp, (char *) 0);
#endif
+ _tracef("TRACING NCURSES version %s (%d)",
+ NCURSES_VERSION, NCURSES_VERSION_PATCH);
+ }
}
+#endif
-const char *_nc_visbuf2(int bufnum, const char *buf)
+const char *
+_nc_visbuf2(int bufnum, const char *buf)
/* visibilize a given string */
{
-char *vbuf;
-char *tp;
-int c;
-
- if (buf == 0)
- return("(null)");
- if (buf == CANCELLED_STRING)
- return("(cancelled)");
-
- tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
- *tp++ = '"';
- while ((c = *buf++) != '\0') {
- if (c == '"') {
- *tp++ = '\\'; *tp++ = '"';
- } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
- *tp++ = c;
- } else if (c == '\n') {
- *tp++ = '\\'; *tp++ = 'n';
- } else if (c == '\r') {
- *tp++ = '\\'; *tp++ = 'r';
- } else if (c == '\b') {
- *tp++ = '\\'; *tp++ = 'b';
- } else if (c == '\033') {
- *tp++ = '\\'; *tp++ = 'e';
- } else if (is7bits(c) && iscntrl(c)) {
- *tp++ = '\\'; *tp++ = '^'; *tp++ = '@' + c;
- } else {
- sprintf(tp, "\\%03o", c & 0xff);
- tp += strlen(tp);
- }
+ char *vbuf;
+ char *tp;
+ int c;
+
+ if (buf == 0)
+ return ("(null)");
+ if (buf == CANCELLED_STRING)
+ return ("(cancelled)");
+
+#ifdef TRACE
+ tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
+#else
+ {
+ static char *mybuf[2];
+ mybuf[bufnum] = _nc_doalloc(mybuf[bufnum], (strlen(buf) * 4) + 5);
+ tp = vbuf = mybuf[bufnum];
+ }
+#endif
+ *tp++ = '"';
+ while ((c = *buf++) != '\0') {
+ if (c == '"') {
+ *tp++ = '\\';
+ *tp++ = '"';
+ } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
+ *tp++ = c;
+ } else if (c == '\n') {
+ *tp++ = '\\';
+ *tp++ = 'n';
+ } else if (c == '\r') {
+ *tp++ = '\\';
+ *tp++ = 'r';
+ } else if (c == '\b') {
+ *tp++ = '\\';
+ *tp++ = 'b';
+ } else if (c == '\033') {
+ *tp++ = '\\';
+ *tp++ = 'e';
+ } else if (is7bits(c) && iscntrl(c)) {
+ *tp++ = '\\';
+ *tp++ = '^';
+ *tp++ = '@' + c;
+ } else {
+ sprintf(tp, "\\%03o", c & 0xff);
+ tp += strlen(tp);
}
- *tp++ = '"';
- *tp++ = '\0';
- return(vbuf);
+ }
+ *tp++ = '"';
+ *tp++ = '\0';
+ return (vbuf);
}
-const char *_nc_visbuf(const char *buf)
+const char *
+_nc_visbuf(const char *buf)
{
- return _nc_visbuf2(0, buf);
+ return _nc_visbuf2(0, buf);
}
#ifdef TRACE
void
-_tracef(const char *fmt, ...)
+_tracef(const char *fmt,...)
{
-static const char Called[] = T_CALLED("");
-static const char Return[] = T_RETURN("");
-static int level;
-va_list ap;
-bool before = FALSE;
-bool after = FALSE;
-int doit = _nc_tracing;
-int save_err = errno;
-
- if (strlen(fmt) >= sizeof(Called) - 1) {
- if (!strncmp(fmt, Called, sizeof(Called)-1)) {
- before = TRUE;
- level++;
- } else if (!strncmp(fmt, Return, sizeof(Return)-1)) {
- after = TRUE;
- }
- if (before || after) {
- if ((level <= 1)
- || (doit & TRACE_ICALLS) != 0)
- doit &= (TRACE_CALLS|TRACE_CCALLS);
- else
- doit = 0;
- }
+ static const char Called[] = T_CALLED("");
+ static const char Return[] = T_RETURN("");
+ static int level;
+ va_list ap;
+ bool before = FALSE;
+ bool after = FALSE;
+ int doit = _nc_tracing;
+ int save_err = errno;
+
+ if (strlen(fmt) >= sizeof(Called) - 1) {
+ if (!strncmp(fmt, Called, sizeof(Called) - 1)) {
+ before = TRUE;
+ level++;
+ } else if (!strncmp(fmt, Return, sizeof(Return) - 1)) {
+ after = TRUE;
}
-
- if (doit != 0) {
- if (tracefp == 0)
- tracefp = stderr;
- if (before || after) {
- int n;
- for (n = 1; n < level; n++)
- fputs("+ ", tracefp);
- }
- va_start(ap, fmt);
- vfprintf(tracefp, fmt, ap);
- fputc('\n', tracefp);
- va_end(ap);
- fflush(tracefp);
+ if (before || after) {
+ if ((level <= 1)
+ || (doit & TRACE_ICALLS) != 0)
+ doit &= (TRACE_CALLS | TRACE_CCALLS);
+ else
+ doit = 0;
}
-
- if (after && level)
- level--;
- errno = save_err;
+ }
+
+ if (doit != 0) {
+ if (tracefp == 0)
+ tracefp = stderr;
+ if (before || after) {
+ int n;
+ for (n = 1; n < level; n++)
+ fputs("+ ", tracefp);
+ }
+ va_start(ap, fmt);
+ vfprintf(tracefp, fmt, ap);
+ fputc('\n', tracefp);
+ va_end(ap);
+ fflush(tracefp);
+ }
+
+ if (after && level)
+ level--;
+ errno = save_err;
}
/* Trace 'int' return-values */
-int _nc_retrace_int(int code)
+int
+_nc_retrace_int(int code)
{
- T((T_RETURN("%d"), code));
- return code;
+ T((T_RETURN("%d"), code));
+ return code;
}
/* Trace 'char*' return-values */
-char * _nc_retrace_ptr(char * code)
+char *
+_nc_retrace_ptr(char *code)
{
- T((T_RETURN("%s"), _nc_visbuf(code)));
- return code;
+ T((T_RETURN("%s"), _nc_visbuf(code)));
+ return code;
}
/* Trace 'WINDOW *' return-values */
-WINDOW *_nc_retrace_win(WINDOW *code)
+WINDOW *
+_nc_retrace_win(WINDOW *code)
{
- T((T_RETURN("%p"), code));
- return code;
+ T((T_RETURN("%p"), code));
+ return code;
}
#endif /* TRACE */
diff --git a/contrib/ncurses/ncurses/trace/lib_tracebits.c b/contrib/ncurses/ncurses/trace/lib_tracebits.c
index a92e00a8624e..6dbb2f793ad0 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracebits.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracebits.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -32,21 +32,20 @@
****************************************************************************/
#include <curses.priv.h>
-#include <term.h> /* cur_term */
+#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_tracebits.c,v 1.3 1999/08/21 21:43:48 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.5 2000/02/13 01:01:55 tom Exp $")
#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#if HAVE_SYS_TERMIO_H
-#include <sys/termio.h> /* needed for ISC */
+#include <sys/termio.h> /* needed for ISC */
#endif
#ifdef __EMX__
#include <io.h>
-#include <fcntl.h>
#endif
/* may be undefined if we're using termio.h */
@@ -59,90 +58,89 @@ MODULE_ID("$Id: lib_tracebits.c,v 1.3 1999/08/21 21:43:48 tom Exp $")
#ifdef TRACE
-typedef struct {unsigned int val; const char *name;} BITNAMES;
+typedef struct {
+ unsigned int val;
+ const char *name;
+} BITNAMES;
-static void lookup_bits(char *buf, const BITNAMES *table, const char *label, unsigned int val)
+static void
+lookup_bits(char *buf, const BITNAMES * table, const char *label, unsigned int val)
{
- const BITNAMES *sp;
-
- (void) strcat(buf, label);
- (void) strcat(buf, ": {");
- for (sp = table; sp->name; sp++)
- if (sp->val != 0
- && (val & sp->val) == sp->val)
- {
- (void) strcat(buf, sp->name);
- (void) strcat(buf, ", ");
- }
- if (buf[strlen(buf) - 2] == ',')
- buf[strlen(buf) - 2] = '\0';
- (void) strcat(buf,"} ");
+ const BITNAMES *sp;
+
+ (void) strcat(buf, label);
+ (void) strcat(buf, ": {");
+ for (sp = table; sp->name; sp++)
+ if (sp->val != 0
+ && (val & sp->val) == sp->val) {
+ (void) strcat(buf, sp->name);
+ (void) strcat(buf, ", ");
+ }
+ if (buf[strlen(buf) - 2] == ',')
+ buf[strlen(buf) - 2] = '\0';
+ (void) strcat(buf, "} ");
}
-char *_nc_tracebits(void)
+char *
+_nc_tracebits(void)
/* describe the state of the terminal control bits exactly */
{
-char *buf;
-static const BITNAMES
+ char *buf;
#ifdef TERMIOS
-iflags[] =
+ static const BITNAMES iflags[] =
{
- {BRKINT, "BRKINT"},
- {IGNBRK, "IGNBRK"},
- {IGNPAR, "IGNPAR"},
- {PARMRK, "PARMRK"},
- {INPCK, "INPCK"},
- {ISTRIP, "ISTRIP"},
- {INLCR, "INLCR"},
- {IGNCR, "IGNC"},
- {ICRNL, "ICRNL"},
- {IXON, "IXON"},
- {IXOFF, "IXOFF"},
- {0, NULL}
+ {BRKINT, "BRKINT"},
+ {IGNBRK, "IGNBRK"},
+ {IGNPAR, "IGNPAR"},
+ {PARMRK, "PARMRK"},
+ {INPCK, "INPCK"},
+ {ISTRIP, "ISTRIP"},
+ {INLCR, "INLCR"},
+ {IGNCR, "IGNC"},
+ {ICRNL, "ICRNL"},
+ {IXON, "IXON"},
+ {IXOFF, "IXOFF"},
+ {0, NULL}
#define ALLIN (BRKINT|IGNBRK|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IXOFF)
- },
-oflags[] =
+ }, oflags[] =
{
- {OPOST, "OPOST"},
- {0, NULL}
+ {OPOST, "OPOST"},
+ {0, NULL}
#define ALLOUT (OPOST)
- },
-cflags[] =
+ }, cflags[] =
{
- {CLOCAL, "CLOCAL"},
- {CREAD, "CREAD"},
- {CSTOPB, "CSTOPB"},
+ {CLOCAL, "CLOCAL"},
+ {CREAD, "CREAD"},
+ {CSTOPB, "CSTOPB"},
#if !defined(CS5) || !defined(CS8)
- {CSIZE, "CSIZE"},
+ {CSIZE, "CSIZE"},
#endif
- {HUPCL, "HUPCL"},
- {PARENB, "PARENB"},
- {PARODD|PARENB, "PARODD"}, /* concession to readability */
- {0, NULL}
+ {HUPCL, "HUPCL"},
+ {PARENB, "PARENB"},
+ {PARODD | PARENB, "PARODD"}, /* concession to readability */
+ {0, NULL}
#define ALLCTRL (CLOCAL|CREAD|CSIZE|CSTOPB|HUPCL|PARENB|PARODD)
- },
-lflags[] =
+ }, lflags[] =
{
- {ECHO, "ECHO"},
- {ECHOE|ECHO, "ECHOE"}, /* concession to readability */
- {ECHOK|ECHO, "ECHOK"}, /* concession to readability */
- {ECHONL, "ECHONL"},
- {ICANON, "ICANON"},
- {ISIG, "ISIG"},
- {NOFLSH, "NOFLSH"},
- {TOSTOP, "TOSTOP"},
- {IEXTEN, "IEXTEN"},
- {0, NULL}
+ {ECHO, "ECHO"},
+ {ECHOE | ECHO, "ECHOE"}, /* concession to readability */
+ {ECHOK | ECHO, "ECHOK"}, /* concession to readability */
+ {ECHONL, "ECHONL"},
+ {ICANON, "ICANON"},
+ {ISIG, "ISIG"},
+ {NOFLSH, "NOFLSH"},
+ {TOSTOP, "TOSTOP"},
+ {IEXTEN, "IEXTEN"},
+ {0, NULL}
#define ALLLOCAL (ECHO|ECHONL|ICANON|ISIG|NOFLSH|TOSTOP|IEXTEN)
};
-
buf = _nc_trace_buf(0,
- 8 + sizeof(iflags) +
- 8 + sizeof(oflags) +
- 8 + sizeof(cflags) +
- 8 + sizeof(lflags) +
+ 8 + sizeof(iflags) +
+ 8 + sizeof(oflags) +
+ 8 + sizeof(cflags) +
+ 8 + sizeof(lflags) +
8);
if (cur_term->Nttyb.c_iflag & ALLIN)
@@ -157,18 +155,28 @@ lflags[] =
#if defined(CS5) && defined(CS8)
switch (cur_term->Nttyb.c_cflag & CSIZE) {
#if defined(CS5) && (CS5 != 0)
- case CS5: strcat(buf, "CS5 "); break;
+ case CS5:
+ strcat(buf, "CS5 ");
+ break;
#endif
#if defined(CS6) && (CS6 != 0)
- case CS6: strcat(buf, "CS6 "); break;
+ case CS6:
+ strcat(buf, "CS6 ");
+ break;
#endif
#if defined(CS7) && (CS7 != 0)
- case CS7: strcat(buf, "CS7 "); break;
+ case CS7:
+ strcat(buf, "CS7 ");
+ break;
#endif
#if defined(CS8) && (CS8 != 0)
- case CS8: strcat(buf, "CS8 "); break;
+ case CS8:
+ strcat(buf, "CS8 ");
+ break;
#endif
- default: strcat(buf, "CSIZE? "); break;
+ default:
+ strcat(buf, "CSIZE? ");
+ break;
}
#endif
@@ -193,33 +201,36 @@ lflags[] =
#define TANDEM 0
#endif
-cflags[] =
+ static const BITNAMES cflags[] =
{
- {CBREAK, "CBREAK"},
- {CRMOD, "CRMOD"},
- {ECHO, "ECHO"},
- {EVENP, "EVENP"},
- {LCASE, "LCASE"},
- {LLITOUT, "LLITOUT"},
- {ODDP, "ODDP"},
- {RAW, "RAW"},
- {TANDEM, "TANDEM"},
- {XTABS, "XTABS"},
- {0, NULL}
+ {CBREAK, "CBREAK"},
+ {CRMOD, "CRMOD"},
+ {ECHO, "ECHO"},
+ {EVENP, "EVENP"},
+ {LCASE, "LCASE"},
+ {LLITOUT, "LLITOUT"},
+ {ODDP, "ODDP"},
+ {RAW, "RAW"},
+ {TANDEM, "TANDEM"},
+ {XTABS, "XTABS"},
+ {0, NULL}
#define ALLCTRL (CBREAK|CRMOD|ECHO|EVENP|LCASE|LLITOUT|ODDP|RAW|TANDEM|XTABS)
};
buf = _nc_trace_buf(0,
- 8 + sizeof(cflags));
+ 8 + sizeof(cflags));
- if (cur_term->Nttyb.sg_flags & ALLCTRL)
- {
+ if (cur_term->Nttyb.sg_flags & ALLCTRL) {
lookup_bits(buf, cflags, "cflags", cur_term->Nttyb.sg_flags);
}
-
#endif
- return(buf);
+ return (buf);
}
#else
-char *_nc_tracebits(void) { static char tmp[] = ""; return tmp; }
+char *
+_nc_tracebits(void)
+{
+ static char tmp[] = "";
+ return tmp;
+}
#endif /* TRACE */
diff --git a/contrib/ncurses/ncurses/trace/lib_tracechr.c b/contrib/ncurses/ncurses/trace/lib_tracechr.c
index e97e67931464..bf004f35294e 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracechr.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracechr.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,36 +31,18 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* lib_tracechr.c - Tracing/Debugging routines
*/
-
-#ifndef TRACE
-#define TRACE /* turn on internal defs for this module */
-#endif
-
#include <curses.priv.h>
-#include <ctype.h>
+MODULE_ID("$Id: lib_tracechr.c,v 1.2 2000/04/01 20:17:26 tom Exp $")
#ifdef TRACE
char *_tracechar(const unsigned char ch)
{
static char crep[20];
- /*
- * We can show the actual character if it's either an ordinary printable
- * or one of the high-half characters.
- */
- if (isprint(ch) || (ch & 0x80))
- {
- crep[0] = '\'';
- crep[1] = ch; /* necessary; printf tries too hard on metachars */
- (void) sprintf(crep + 2, "' = 0x%02x", (unsigned)ch);
- }
- else
- (void) sprintf(crep, "0x%02x", (unsigned)ch);
+ (void) sprintf(crep, "'%s' = 0x%02x", unctrl(ch), (unsigned)ch);
return(crep);
}
#else
diff --git a/contrib/ncurses/ncurses/tty/hashmap.c b/contrib/ncurses/ncurses/tty/hashmap.c
index f6a58bc6e112..300ac9a3232a 100644
--- a/contrib/ncurses/ncurses/tty/hashmap.c
+++ b/contrib/ncurses/ncurses/tty/hashmap.c
@@ -70,7 +70,7 @@ AUTHOR
#include <curses.priv.h>
#include <term.h> /* for back_color_erase */
-MODULE_ID("$Id: hashmap.c,v 1.33 1999/03/18 02:09:45 Alexander.V.Lukyanov Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.34 1999/11/28 00:10:57 tom Exp $")
#ifdef HASHDEBUG
@@ -286,7 +286,9 @@ void _nc_hash_map(void)
if (!hashtab)
{
if (oldhash)
+ {
FreeAndNull(oldhash);
+ }
lines_alloc = 0;
return;
}
diff --git a/contrib/ncurses/ncurses/tty/lib_mvcur.c b/contrib/ncurses/ncurses/tty/lib_mvcur.c
index 955eb8c6cd84..190c59bd4a15 100644
--- a/contrib/ncurses/ncurses/tty/lib_mvcur.c
+++ b/contrib/ncurses/ncurses/tty/lib_mvcur.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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_mvcur.c
**
@@ -153,13 +152,13 @@
#include <term.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_mvcur.c,v 1.60 1999/10/03 01:08:27 Alexander.V.Lukyanov Exp $")
+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
+#define CURRENT_ROW SP->_cursrow /* phys cursor row */
+#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
#define CURRENT_ATTR SP->_current_attr /* current phys attribute */
-#define CURRENT_ROW SP->_cursrow /* phys cursor row */
-#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
#define REAL_ATTR SP->_current_attr /* phys current attribute */
#define WANT_CHAR(y, x) SP->_newscr->_line[y].text[x] /* desired state */
#define BAUDRATE cur_term->_baudrate /* bits per second */
@@ -176,20 +175,21 @@ 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)
+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++;
+ 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;
}
- return result;
+ haystack++;
+ }
+ return result;
}
#endif
@@ -203,18 +203,20 @@ char * _nc_strstr(const char *haystack, const char *needle)
static int
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", capname, result));
- return result;
+ int result = _nc_msec_cost(cap, affcnt);
+ TR(TRACE_CHARPUT | TRACE_MOVE,
+ ("CostOf %s %d %s", capname, result, _nc_visbuf(cap)));
+ return result;
}
#define CostOf(cap,affcnt) trace_cost_of(#cap,cap,affcnt);
static int
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", capname, result));
- return result;
+ int result = normalized_cost(cap, affcnt);
+ TR(TRACE_CHARPUT | TRACE_MOVE,
+ ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap)));
+ return result;
}
#define NormalizedCost(cap,affcnt) trace_normalized_cost(#cap,cap,affcnt);
@@ -225,25 +227,22 @@ trace_normalized_cost(const char *capname, const char *cap, int affcnt)
#endif
-int _nc_msec_cost(const char *const cap, int affcnt)
+int
+_nc_msec_cost(const char *const cap, int affcnt)
/* compute the cost of a given operation */
{
if (cap == 0)
- return(INFINITY);
- else
- {
- const char *cp;
- float cum_cost = 0;
+ return (INFINITY);
+ else {
+ const char *cp;
+ float cum_cost = 0;
- for (cp = cap; *cp; cp++)
- {
+ for (cp = cap; *cp; cp++) {
/* extract padding, either mandatory or required */
- if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>'))
- {
- float number = 0;
+ if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) {
+ float number = 0;
- for (cp += 2; *cp != '>'; cp++)
- {
+ for (cp += 2; *cp != '>'; cp++) {
if (isdigit(*cp))
number = number * 10 + (*cp - '0');
else if (*cp == '*')
@@ -252,41 +251,44 @@ int _nc_msec_cost(const char *const cap, int affcnt)
number += (*cp - '0') / 10.0;
}
- cum_cost += number * 10;
- }
- else
+#ifdef NCURSES_NO_PADDING
+ if (!(SP->_no_padding))
+#endif
+ cum_cost += number * 10;
+ } else
cum_cost += SP->_char_padding;
}
- return((int)cum_cost);
+ return ((int) cum_cost);
}
}
-static int normalized_cost(const char *const cap, int affcnt)
+static int
+normalized_cost(const char *const cap, int affcnt)
/* compute the effective character-count for an operation (round up) */
{
- int cost = _nc_msec_cost(cap, affcnt);
- if (cost != INFINITY)
- cost = (cost + SP->_char_padding - 1) / SP->_char_padding;
- return cost;
+ int cost = _nc_msec_cost(cap, affcnt);
+ if (cost != INFINITY)
+ cost = (cost + SP->_char_padding - 1) / SP->_char_padding;
+ return cost;
}
-static void reset_scroll_region(void)
+static void
+reset_scroll_region(void)
/* Set the scroll-region to a known state (the default) */
{
- if (change_scroll_region)
- {
+ if (change_scroll_region) {
TPUTS_TRACE("change_scroll_region");
putp(tparm(change_scroll_region, 0, screen_lines - 1));
}
}
-void _nc_mvcur_resume(void)
+void
+_nc_mvcur_resume(void)
/* what to do at initialization time and after each shellout */
{
/* initialize screen for cursor access */
- if (enter_ca_mode)
- {
+ if (enter_ca_mode) {
TPUTS_TRACE("enter_ca_mode");
putp(enter_ca_mode);
}
@@ -304,15 +306,15 @@ void _nc_mvcur_resume(void)
SP->_cursrow = SP->_curscol = -1;
/* restore cursor shape */
- if (SP->_cursor != -1)
- {
+ if (SP->_cursor != -1) {
int cursor = SP->_cursor;
SP->_cursor = -1;
- curs_set (cursor);
+ curs_set(cursor);
}
}
-void _nc_mvcur_init(void)
+void
+_nc_mvcur_init(void)
/* initialize the cost structure */
{
/*
@@ -321,15 +323,15 @@ void _nc_mvcur_init(void)
SP->_char_padding = (9 * 1000 * 10) / (BAUDRATE > 0 ? BAUDRATE : 9600);
if (SP->_char_padding <= 0)
SP->_char_padding = 1; /* must be nonzero */
- TR(TRACE_CHARPUT|TRACE_MOVE, ("char_padding %d msecs", SP->_char_padding));
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("char_padding %d msecs", SP->_char_padding));
/* non-parameterized local-motion strings */
- SP->_cr_cost = CostOf(carriage_return, 0);
+ SP->_cr_cost = CostOf(carriage_return, 0);
SP->_home_cost = CostOf(cursor_home, 0);
- SP->_ll_cost = CostOf(cursor_to_ll, 0);
+ SP->_ll_cost = CostOf(cursor_to_ll, 0);
#if USE_HARD_TABS
- SP->_ht_cost = CostOf(tab, 0);
- SP->_cbt_cost = CostOf(back_tab, 0);
+ SP->_ht_cost = CostOf(tab, 0);
+ SP->_cbt_cost = CostOf(back_tab, 0);
#endif /* USE_HARD_TABS */
SP->_cub1_cost = CostOf(cursor_left, 0);
SP->_cuf1_cost = CostOf(cursor_right, 0);
@@ -357,7 +359,7 @@ void _nc_mvcur_init(void)
*
* (1) They never have * padding. In the entire master terminfo database
* as of March 1995, only the obsolete Zenith Z-100 pc violates this.
- * (Proportional padding is found mainly in insert, delete and scroll
+ * (Proportional padding is found mainly in insert, delete and scroll
* capabilities).
*
* (2) The average case of cup has two two-digit parameters. Strictly,
@@ -375,34 +377,38 @@ void _nc_mvcur_init(void)
* All these averages depend on the assumption that all parameter values
* are equally probable.
*/
- SP->_cup_cost = CostOf(tparm(SP->_address_cursor, 23, 23), 1);
- SP->_cub_cost = CostOf(tparm(parm_left_cursor, 23), 1);
- SP->_cuf_cost = CostOf(tparm(parm_right_cursor, 23), 1);
- SP->_cud_cost = CostOf(tparm(parm_down_cursor, 23), 1);
- SP->_cuu_cost = CostOf(tparm(parm_up_cursor, 23), 1);
- SP->_hpa_cost = CostOf(tparm(column_address, 23), 1);
- SP->_vpa_cost = CostOf(tparm(row_address, 23), 1);
+ SP->_cup_cost = CostOf(tparm(SP->_address_cursor, 23, 23), 1);
+ SP->_cub_cost = CostOf(tparm(parm_left_cursor, 23), 1);
+ SP->_cuf_cost = CostOf(tparm(parm_right_cursor, 23), 1);
+ SP->_cud_cost = CostOf(tparm(parm_down_cursor, 23), 1);
+ SP->_cuu_cost = CostOf(tparm(parm_up_cursor, 23), 1);
+ SP->_hpa_cost = CostOf(tparm(column_address, 23), 1);
+ SP->_vpa_cost = CostOf(tparm(row_address, 23), 1);
/* non-parameterized screen-update strings */
- SP->_ed_cost = NormalizedCost(clr_eos, 1);
- SP->_el_cost = NormalizedCost(clr_eol, 1);
- SP->_el1_cost = NormalizedCost(clr_bol, 1);
+ SP->_ed_cost = NormalizedCost(clr_eos, 1);
+ SP->_el_cost = NormalizedCost(clr_eol, 1);
+ SP->_el1_cost = NormalizedCost(clr_bol, 1);
SP->_dch1_cost = NormalizedCost(delete_character, 1);
SP->_ich1_cost = NormalizedCost(insert_character, 1);
/* parameterized screen-update strings */
- SP->_dch_cost = NormalizedCost(tparm(parm_dch, 23), 1);
- SP->_ich_cost = NormalizedCost(tparm(parm_ich, 23), 1);
- SP->_ech_cost = NormalizedCost(tparm(erase_chars, 23), 1);
- SP->_rep_cost = NormalizedCost(tparm(repeat_char, ' ', 23), 1);
+ SP->_dch_cost = NormalizedCost(tparm(parm_dch, 23), 1);
+ SP->_ich_cost = NormalizedCost(tparm(parm_ich, 23), 1);
+ SP->_ech_cost = NormalizedCost(tparm(erase_chars, 23), 1);
+ SP->_rep_cost = NormalizedCost(tparm(repeat_char, ' ', 23), 1);
SP->_cup_ch_cost = NormalizedCost(tparm(SP->_address_cursor, 23, 23), 1);
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);
+ SP->_cursor_home_length = STRLEN(cursor_home);
+ SP->_cursor_to_ll_length = STRLEN(cursor_to_ll);
/*
* If save_cursor is used within enter_ca_mode, we should not use it for
@@ -411,8 +417,8 @@ void _nc_mvcur_init(void)
* feature.
*/
if (save_cursor != 0
- && enter_ca_mode != 0
- && strstr(enter_ca_mode, save_cursor) != 0) {
+ && enter_ca_mode != 0
+ && strstr(enter_ca_mode, save_cursor) != 0) {
T(("...suppressed sc/rc capability due to conflict with smcup/rmcup"));
save_cursor = 0;
restore_cursor = 0;
@@ -426,7 +432,8 @@ void _nc_mvcur_init(void)
_nc_mvcur_resume();
}
-void _nc_mvcur_wrap(void)
+void
+_nc_mvcur_wrap(void)
/* wrap up cursor-addressing mode */
{
/* leave cursor at screen bottom */
@@ -436,8 +443,7 @@ void _nc_mvcur_wrap(void)
if (SP->_cursor != -1)
curs_set(1);
- if (exit_ca_mode)
- {
+ if (exit_ca_mode) {
TPUTS_TRACE("exit_ca_mode");
putp(exit_ca_mode);
}
@@ -462,24 +468,24 @@ void _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(int total, int num, int repeat, char *dst, 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;
- }
- }
- } else {
- total = INFINITY;
+ 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;
+ }
}
- return total;
+ } else {
+ total = INFINITY;
+ }
+ return total;
}
#ifndef NO_OPTIMIZE
@@ -494,56 +500,47 @@ repeated_append (int total, int num, int repeat, char *dst, const char *src)
/* 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(char *result, 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) */
{
- int n, vcost = 0, hcost = 0;
+ int n, vcost = 0, hcost = 0;
if (result)
result[0] = '\0';
- if (to_y != from_y)
- {
+ if (to_y != from_y) {
vcost = INFINITY;
- if (row_address)
- {
+ if (row_address) {
if (result)
(void) strcpy(result, tparm(row_address, to_y));
vcost = SP->_vpa_cost;
}
- if (to_y > from_y)
- {
+ if (to_y > from_y) {
n = (to_y - from_y);
- if (parm_down_cursor && SP->_cud_cost < vcost)
- {
+ if (parm_down_cursor && SP->_cud_cost < vcost) {
if (result)
(void) strcpy(result, tparm(parm_down_cursor, n));
vcost = SP->_cud_cost;
}
- if (cursor_down && (n * SP->_cud1_cost < vcost))
- {
+ if (cursor_down && (n * SP->_cud1_cost < vcost)) {
if (result)
result[0] = '\0';
vcost = repeated_append(0, SP->_cud1_cost, n, result, cursor_down);
}
- }
- else /* (to_y < from_y) */
- {
+ } else { /* (to_y < from_y) */
n = (from_y - to_y);
- if (parm_up_cursor && SP->_cup_cost < vcost)
- {
+ if (parm_up_cursor && SP->_cup_cost < vcost) {
if (result)
(void) strcpy(result, tparm(parm_up_cursor, n));
vcost = SP->_cup_cost;
}
- if (cursor_up && (n * SP->_cuu1_cost < vcost))
- {
+ if (cursor_up && (n * SP->_cuu1_cost < vcost)) {
if (result)
result[0] = '\0';
vcost = repeated_append(0, SP->_cuu1_cost, n, result, cursor_up);
@@ -551,53 +548,47 @@ relative_move(char *result, int from_y,int from_x,int to_y,int to_x, bool ovw)
}
if (vcost == INFINITY)
- return(INFINITY);
+ return (INFINITY);
}
if (result)
result += strlen(result);
- if (to_x != from_x)
- {
- char str[OPT_SIZE];
+ if (to_x != from_x) {
+ char str[OPT_SIZE];
hcost = INFINITY;
- if (column_address)
- {
+ if (column_address) {
if (result)
(void) strcpy(result, tparm(column_address, to_x));
hcost = SP->_hpa_cost;
}
- if (to_x > from_x)
- {
+ if (to_x > from_x) {
n = to_x - from_x;
- if (parm_right_cursor && SP->_cuf_cost < hcost)
- {
+ if (parm_right_cursor && SP->_cuf_cost < hcost) {
if (result)
(void) strcpy(result, tparm(parm_right_cursor, n));
hcost = SP->_cuf_cost;
}
- if (cursor_right)
- {
- int lhcost = 0;
+ if (cursor_right) {
+ int lhcost = 0;
str[0] = '\0';
#if USE_HARD_TABS
/* use hard tabs, if we have them, to do as much as possible */
- if (init_tabs > 0 && tab)
- {
- int nxt, fr;
+ if (init_tabs > 0 && tab) {
+ int nxt, fr;
- for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt)
- {
- lhcost = repeated_append(lhcost, SP->_ht_cost, 1, str, tab);
+ for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt) {
+ lhcost = repeated_append(lhcost, SP->_ht_cost, 1,
+ str, tab);
if (lhcost == INFINITY)
- break;
+ break;
}
n = to_x - fr;
@@ -614,11 +605,11 @@ relative_move(char *result, int from_y,int from_x,int to_y,int to_x, bool ovw)
* screen.
*/
if (ovw
- && n > 0
- && vcost == 0
- && str[0] == '\0'
- && isdigit(TextOf(WANT_CHAR(to_y, from_x))))
- ovw = FALSE;
+ && n > 0
+ && vcost == 0
+ && str[0] == '\0'
+ && isdigit(TextOf(WANT_CHAR(to_y, from_x))))
+ ovw = FALSE;
#endif
/*
* If we have no attribute changes, overwrite is cheaper.
@@ -628,21 +619,18 @@ relative_move(char *result, int from_y,int from_x,int to_y,int to_x, bool ovw)
* and the time the structure WANT_CHAR would access has been
* updated.
*/
- if (ovw)
- {
- int i;
+ if (ovw) {
+ int i;
for (i = 0; i < n; i++)
- if ((WANT_CHAR(to_y, from_x + i) & A_ATTRIBUTES) != CURRENT_ATTR)
- {
+ if ((WANT_CHAR(to_y, from_x + i) & A_ATTRIBUTES) != CURRENT_ATTR) {
ovw = FALSE;
break;
}
}
- if (ovw)
- {
- char *sp;
- int i;
+ if (ovw) {
+ char *sp;
+ int i;
sp = str + strlen(str);
@@ -650,48 +638,41 @@ relative_move(char *result, int from_y,int from_x,int to_y,int to_x, bool ovw)
*sp++ = WANT_CHAR(to_y, from_x + i);
*sp = '\0';
lhcost += n * SP->_char_padding;
- }
- else
+ } else
#endif /* defined(REAL_ATTR) && defined(WANT_CHAR) */
{
lhcost = repeated_append(lhcost, SP->_cuf1_cost, n, str, cursor_right);
}
- if (lhcost < hcost)
- {
+ if (lhcost < hcost) {
if (result)
(void) strcpy(result, str);
hcost = lhcost;
}
}
- }
- else /* (to_x < from_x) */
- {
+ } else { /* (to_x < from_x) */
n = from_x - to_x;
- if (parm_left_cursor && SP->_cub_cost < hcost)
- {
+ if (parm_left_cursor && SP->_cub_cost < hcost) {
if (result)
(void) strcpy(result, tparm(parm_left_cursor, n));
hcost = SP->_cub_cost;
}
- if (cursor_left)
- {
- int lhcost = 0;
+ if (cursor_left) {
+ int lhcost = 0;
str[0] = '\0';
#if USE_HARD_TABS
- if (init_tabs > 0 && back_tab)
- {
- int nxt, fr;
+ 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);
+ for (fr = from_x; (nxt = LASTTAB(fr)) >= to_x; fr = nxt) {
+ lhcost = repeated_append(lhcost, SP->_cbt_cost, 1,
+ str, back_tab);
if (lhcost == INFINITY)
- break;
+ break;
}
n = fr - to_x;
@@ -700,8 +681,7 @@ relative_move(char *result, int from_y,int from_x,int to_y,int to_x, bool ovw)
lhcost = repeated_append(lhcost, SP->_cub1_cost, n, str, cursor_left);
- if (lhcost < hcost)
- {
+ if (lhcost < hcost) {
if (result)
(void) strcpy(result, str);
hcost = lhcost;
@@ -710,10 +690,10 @@ relative_move(char *result, int from_y,int from_x,int to_y,int to_x, bool ovw)
}
if (hcost == INFINITY)
- return(INFINITY);
+ return (INFINITY);
}
- return(vcost + hcost);
+ return (vcost + hcost);
}
#endif /* !NO_OPTIMIZE */
@@ -729,12 +709,12 @@ relative_move(char *result, int from_y,int from_x,int to_y,int to_x, bool ovw)
*/
static inline int
-onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
+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;
- int tactic = 0, newcost, usecost = INFINITY;
- int t5_cr_cost;
+ char use[OPT_SIZE], *sp;
+ int tactic = 0, newcost, usecost = INFINITY;
+ int t5_cr_cost;
#if defined(MAIN) || defined(NCURSES_TEST)
struct timeval before, after;
@@ -744,8 +724,7 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
/* tactic #0: use direct cursor addressing */
sp = tparm(SP->_address_cursor, ynew, xnew);
- if (sp)
- {
+ if (sp) {
tactic = 0;
(void) strcpy(use, sp);
usecost = SP->_cup_cost;
@@ -763,11 +742,9 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
* (like, say, local-movement \n getting mapped to some obscure
* character because A_ALTCHARSET is on).
*/
- if (yold == -1 || xold == -1 || NOT_LOCAL(yold, xold, ynew, xnew))
- {
+ if (yold == -1 || xold == -1 || NOT_LOCAL(yold, xold, ynew, xnew)) {
#if defined(MAIN) || defined(NCURSES_TEST)
- if (!profiling)
- {
+ if (!profiling) {
(void) fputs("nonlocal\n", stderr);
goto nonlocal; /* always run the optimizer if profiling */
}
@@ -776,40 +753,36 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
#endif /* MAIN */
}
}
-
#ifndef NO_OPTIMIZE
/* tactic #1: use local movement */
if (yold != -1 && xold != -1
- && ((newcost=relative_move(NULL, yold, xold, ynew, xnew, ovw))!=INFINITY)
- && newcost < usecost)
- {
+ && ((newcost = relative_move(NULL, yold, xold, ynew, xnew, ovw)) != INFINITY)
+ && newcost < usecost) {
tactic = 1;
usecost = newcost;
}
/* tactic #2: use carriage-return + local movement */
if (yold != -1 && carriage_return
- && ((newcost=relative_move(NULL, yold,0,ynew,xnew, ovw)) != INFINITY)
- && SP->_cr_cost + newcost < usecost)
- {
+ && ((newcost = relative_move(NULL, yold, 0, ynew, xnew, ovw)) != INFINITY)
+ && SP->_cr_cost + newcost < usecost) {
tactic = 2;
usecost = SP->_cr_cost + newcost;
}
/* tactic #3: use home-cursor + local movement */
if (cursor_home
- && ((newcost=relative_move(NULL, 0, 0, ynew, xnew, ovw)) != INFINITY)
- && SP->_home_cost + newcost < usecost)
- {
+ && ((newcost = relative_move(NULL, 0, 0, ynew, xnew, ovw)) != INFINITY)
+ && SP->_home_cost + newcost < usecost) {
tactic = 3;
usecost = SP->_home_cost + newcost;
}
/* tactic #4: use home-down + local movement */
if (cursor_to_ll
- && ((newcost=relative_move(NULL, screen_lines-1, 0, ynew, xnew, ovw)) != INFINITY)
- && SP->_ll_cost + newcost < usecost)
- {
+ && ((newcost = relative_move(NULL, screen_lines - 1, 0, ynew, xnew,
+ ovw)) != INFINITY)
+ && SP->_ll_cost + newcost < usecost) {
tactic = 4;
usecost = SP->_ll_cost + newcost;
}
@@ -818,12 +791,12 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
* tactic #5: use left margin for wrap to right-hand side,
* unless strange wrap behavior indicated by xenl might hose us.
*/
- t5_cr_cost = (xold>0 ? SP->_cr_cost : 0);
+ 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)
- && t5_cr_cost + SP->_cub1_cost + newcost < usecost)
- {
+ && ((newcost = relative_move(NULL, 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;
}
@@ -831,37 +804,33 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
/*
* These cases are ordered by estimated relative frequency.
*/
- if (tactic)
- {
- if (tactic == 1)
- (void) relative_move(use, yold, xold, ynew, xnew, ovw);
- else if (tactic == 2)
- {
- (void) strcpy(use, carriage_return);
- (void) relative_move(use + SP->_carriage_return_length,
- yold,0,ynew,xnew, ovw);
- }
- else if (tactic == 3)
- {
- (void) strcpy(use, cursor_home);
- (void) relative_move(use + SP->_cursor_home_length,
- 0, 0, ynew, xnew, ovw);
- }
- else if (tactic == 4)
- {
- (void) strcpy(use, cursor_to_ll);
- (void) relative_move(use + SP->_cursor_to_ll_length,
- screen_lines-1, 0, ynew, xnew, ovw);
- }
- else /* if (tactic == 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);
- }
+ switch (tactic) {
+ case 1:
+ (void) relative_move(use, 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);
+ break;
+ case 3:
+ (void) strcpy(use, cursor_home);
+ (void) relative_move(use + SP->_cursor_home_length,
+ 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);
+ 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);
+ break;
}
#endif /* !NO_OPTIMIZE */
@@ -870,28 +839,28 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
diff = after.tv_usec - before.tv_usec
+ (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);
+ (void) fprintf(stderr,
+ "onscreen: %d msec, %f 28.8Kbps char-equivalents\n",
+ (int) diff, diff / 288);
#endif /* MAIN */
- nonlocal:
- if (usecost != INFINITY)
- {
+ nonlocal:
+ if (usecost != INFINITY) {
TPUTS_TRACE("mvcur");
tputs(use, 1, _nc_outch);
- return(OK);
- }
- else
- return(ERR);
+ return (OK);
+ } else
+ return (ERR);
}
-int mvcur(int yold, int xold, int ynew, int xnew)
+int
+mvcur(int yold, int xold, int ynew, int xnew)
/* optimized cursor move from (yold, xold) to (ynew, xnew) */
{
TR(TRACE_MOVE, ("mvcur(%d,%d,%d,%d) called", yold, xold, ynew, xnew));
if (yold == ynew && xold == xnew)
- return(OK);
+ return (OK);
/*
* Most work here is rounding for terminal boundaries getting the
@@ -899,40 +868,33 @@ int mvcur(int yold, int xold, int ynew, int xnew)
* rolling up the screen to get ynew on the screen.
*/
- if (xnew >= screen_columns)
- {
+ if (xnew >= screen_columns) {
ynew += xnew / screen_columns;
xnew %= screen_columns;
}
- if (xold >= screen_columns)
- {
- int l;
+ if (xold >= screen_columns) {
+ int l;
l = (xold + 1) / screen_columns;
yold += l;
if (yold >= screen_lines)
- l -= (yold - screen_lines - 1);
+ l -= (yold - screen_lines - 1);
while (l > 0) {
- if (newline)
- {
- TPUTS_TRACE("newline");
- tputs(newline, 0, _nc_outch);
- }
- else
- putchar('\n');
- l--;
- if (xold > 0)
- {
- if (carriage_return)
- {
- TPUTS_TRACE("carriage_return");
- tputs(carriage_return, 0, _nc_outch);
- }
- else
- putchar('\r');
- xold = 0;
- }
+ if (newline) {
+ TPUTS_TRACE("newline");
+ tputs(newline, 0, _nc_outch);
+ } else
+ putchar('\n');
+ l--;
+ if (xold > 0) {
+ if (carriage_return) {
+ TPUTS_TRACE("carriage_return");
+ tputs(carriage_return, 0, _nc_outch);
+ } else
+ putchar('\r');
+ xold = 0;
+ }
}
}
@@ -942,7 +904,7 @@ int mvcur(int yold, int xold, int ynew, int xnew)
ynew = screen_lines - 1;
/* destination location is on screen now */
- return(onscreen_mvcur(yold, xold, ynew, xnew, TRUE));
+ return (onscreen_mvcur(yold, xold, ynew, xnew, TRUE));
}
#if defined(TRACE) || defined(NCURSES_TEST)
@@ -963,35 +925,51 @@ const char *_nc_progname = "mvcur";
static unsigned long xmits;
-int tputs(const char *string, int affcnt GCC_UNUSED, int (*outc)(int) GCC_UNUSED)
+/* these override lib_tputs.c */
+int
+tputs(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
/* stub tputs() that dumps sequences in a visible form */
{
if (profiling)
xmits += strlen(string);
else
(void) fputs(_nc_visbuf(string), stdout);
- return(OK);
+ return (OK);
}
-int putp(const char *string)
+int
+putp(const char *string)
{
- return(tputs(string, 1, _nc_outch));
+ return (tputs(string, 1, _nc_outch));
}
-int _nc_outch(int ch)
+int
+_nc_outch(int ch)
{
putc(ch, stdout);
return OK;
}
-static char tname[MAX_ALIAS];
+char PC = 0; /* used by termcap library */
+speed_t ospeed = 0; /* used by termcap library */
+int _nc_nulls_sent = 0; /* used by 'tack' program */
+
+int
+delay_output(int ms GCC_UNUSED)
+{
+ return OK;
+}
+
+static char tname[MAX_ALIAS];
-static void load_term(void)
+static void
+load_term(void)
{
(void) setupterm(tname, STDOUT_FILENO, NULL);
}
-static int roll(int n)
+static int
+roll(int n)
{
int i, j;
@@ -1001,7 +979,8 @@ static int roll(int n)
return (j % n);
}
-int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
(void) strcpy(tname, termname());
load_term();
@@ -1016,30 +995,32 @@ int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
fputs("smcup:", stdout);
putchar('\n');
- for (;;)
- {
- int fy, fx, ty, tx, n, i;
- char buf[BUFSIZ], capname[BUFSIZ];
+ for (;;) {
+ int fy, fx, ty, tx, n, i;
+ char buf[BUFSIZ], capname[BUFSIZ];
(void) fputs("> ", stdout);
(void) fgets(buf, sizeof(buf), stdin);
- if (buf[0] == '?')
- {
-(void) puts("? -- display this help message");
-(void) puts("fy fx ty tx -- (4 numbers) display (fy,fx)->(ty,tx) move");
-(void) puts("s[croll] n t b m -- display scrolling sequence");
-(void) printf("r[eload] -- reload terminal info for %s\n", termname());
-(void) puts("l[oad] <term> -- load terminal info for type <term>");
-(void) puts("d[elete] <cap> -- delete named capability");
-(void) puts("i[nspect] -- display terminal capabilities");
-(void) puts("c[ost] -- dump cursor-optimization cost table");
-(void) puts("o[optimize] -- toggle movement optimization");
-(void) puts("t[orture] <num> -- torture-test with <num> random moves");
-(void) puts("q[uit] -- quit the program");
- }
- else if (sscanf(buf, "%d %d %d %d", &fy, &fx, &ty, &tx) == 4)
- {
+ if (buf[0] == '?') {
+ (void) puts("? -- display this help message");
+ (void)
+ puts("fy fx ty tx -- (4 numbers) display (fy,fx)->(ty,tx) move");
+ (void) puts("s[croll] n t b m -- display scrolling sequence");
+ (void)
+ printf("r[eload] -- reload terminal info for %s\n",
+ termname());
+ (void)
+ puts("l[oad] <term> -- load terminal info for type <term>");
+ (void) puts("d[elete] <cap> -- delete named capability");
+ (void) puts("i[nspect] -- display terminal capabilities");
+ (void)
+ puts("c[ost] -- dump cursor-optimization cost table");
+ (void) puts("o[optimize] -- toggle movement optimization");
+ (void)
+ puts("t[orture] <num> -- torture-test with <num> random moves");
+ (void) puts("q[uit] -- quit the program");
+ } else if (sscanf(buf, "%d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
struct timeval before, after;
putchar('"');
@@ -1049,10 +1030,9 @@ int 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));
- }
- else if (sscanf(buf, "s %d %d %d %d", &fy, &fx, &ty, &tx) == 4)
- {
+ (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;
putchar('"');
@@ -1062,66 +1042,53 @@ int 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));
- }
- else if (buf[0] == 'r')
- {
+ (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();
- }
- else if (sscanf(buf, "l %s", tname) == 1)
- {
+ } else if (sscanf(buf, "l %s", tname) == 1) {
load_term();
- }
- else if (sscanf(buf, "d %s", capname) == 1)
- {
- struct name_table_entry const *np = _nc_find_entry(capname,
- _nc_info_hash_table);
+ } else if (sscanf(buf, "d %s", capname) == 1) {
+ struct name_table_entry const *np = _nc_find_entry(capname,
+ _nc_info_hash_table);
if (np == NULL)
(void) printf("No such capability as \"%s\"\n", capname);
- else
- {
- switch(np->nte_type)
- {
+ else {
+ switch (np->nte_type) {
case BOOLEAN:
cur_term->type.Booleans[np->nte_index] = FALSE;
- (void) printf("Boolean capability `%s' (%d) turned off.\n",
- np->nte_name, np->nte_index);
+ (void)
+ printf("Boolean capability `%s' (%d) turned off.\n",
+ np->nte_name, np->nte_index);
break;
case NUMBER:
- cur_term->type.Numbers[np->nte_index] = -1;
+ 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] = (char *)NULL;
+ 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;
}
}
- }
- else if (buf[0] == 'i')
- {
- dump_init((char *)NULL, F_TERMINFO, S_TERMINFO, 70, 0, FALSE);
- dump_entry(&cur_term->type, FALSE, TRUE, 0);
- putchar('\n');
- }
- else if (buf[0] == 'o')
- {
- if (_nc_optimize_enable & OPTIMIZE_MVCUR)
- {
- _nc_optimize_enable &=~ OPTIMIZE_MVCUR;
- (void) puts("Optimization is now off.");
- }
- else
- {
- _nc_optimize_enable |= OPTIMIZE_MVCUR;
- (void) puts("Optimization is now on.");
- }
+ } else if (buf[0] == 'i') {
+ dump_init((char *) NULL, F_TERMINFO, S_TERMINFO, 70, 0, FALSE);
+ dump_entry(&cur_term->type, FALSE, TRUE, 0);
+ putchar('\n');
+ } else if (buf[0] == 'o') {
+ if (_nc_optimize_enable & OPTIMIZE_MVCUR) {
+ _nc_optimize_enable &= ~OPTIMIZE_MVCUR;
+ (void) puts("Optimization is now off.");
+ } else {
+ _nc_optimize_enable |= OPTIMIZE_MVCUR;
+ (void) puts("Optimization is now on.");
+ }
}
/*
* You can use the `t' test to profile and tune the movement
@@ -1142,16 +1109,15 @@ int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
* modes. As long as the optimized times are less, the optimizer
* is winning.
*/
- else if (sscanf(buf, "t %d", &n) == 1)
- {
+ else if (sscanf(buf, "t %d", &n) == 1) {
float cumtime = 0, perchar;
- int speeds[] = {2400, 9600, 14400, 19200, 28800, 38400, 0};
+ int speeds[] =
+ {2400, 9600, 14400, 19200, 28800, 38400, 0};
- srand((unsigned)(getpid() + time((time_t *)0)));
+ srand((unsigned) (getpid() + time((time_t *) 0)));
profiling = TRUE;
xmits = 0;
- for (i = 0; i < n; i++)
- {
+ for (i = 0; i < n; i++) {
/*
* This does a move test between two random locations,
* Random moves probably short-change the optimizer,
@@ -1182,10 +1148,9 @@ int 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++)
- {
+ for (i = 0; speeds[i]; i++) {
/*
* Total estimated time for the moves, computation and
* transmission both. Transmission time is an estimate
@@ -1200,12 +1165,11 @@ int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
*/
float overhead = speeds[i] * perchar / 1e6;
- (void) printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n",
- speeds[i], overhead, totalest);
+ (void)
+ printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n",
+ speeds[i], overhead, totalest);
}
- }
- else if (buf[0] == 'c')
- {
+ } else if (buf[0] == 'c') {
(void) printf("char padding: %d\n", SP->_char_padding);
(void) printf("cr cost: %d\n", SP->_cr_cost);
(void) printf("cup cost: %d\n", SP->_cup_cost);
@@ -1225,8 +1189,7 @@ int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
(void) printf("cuu cost: %d\n", SP->_cuu_cost);
(void) printf("hpa cost: %d\n", SP->_hpa_cost);
(void) printf("vpa cost: %d\n", SP->_vpa_cost);
- }
- else if (buf[0] == 'x' || buf[0] == 'q')
+ } else if (buf[0] == 'x' || buf[0] == 'q')
break;
else
(void) puts("Invalid command.");
@@ -1236,7 +1199,7 @@ int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
_nc_mvcur_wrap();
putchar('\n');
- return(0);
+ return (0);
}
#endif /* MAIN */
diff --git a/contrib/ncurses/ncurses/tty/lib_tstp.c b/contrib/ncurses/ncurses/tty/lib_tstp.c
index 6fb912cf5096..d01a62f71487 100644
--- a/contrib/ncurses/ncurses/tty/lib_tstp.c
+++ b/contrib/ncurses/ncurses/tty/lib_tstp.c
@@ -48,7 +48,7 @@
#define _POSIX_SOURCE
#endif
-MODULE_ID("$Id: lib_tstp.c,v 1.20 1999/10/22 23:11:09 tom Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.21 2000/05/20 23:28:56 tom Exp $")
#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
#define USE_SIGTSTP 1
@@ -226,6 +226,7 @@ static void cleanup(int sig)
&& SP->_ofp != 0
&& isatty(fileno(SP->_ofp))) {
SP->_cleanup = TRUE;
+ SP->_outch = _nc_outch;
}
set_term(scan);
endwin();
diff --git a/contrib/ncurses/ncurses/tty/lib_twait.c b/contrib/ncurses/ncurses/tty/lib_twait.c
index f095c9b53c0c..a21e2a16db0f 100644
--- a/contrib/ncurses/ncurses/tty/lib_twait.c
+++ b/contrib/ncurses/ncurses/tty/lib_twait.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -47,8 +47,6 @@
#include <curses.priv.h>
#if USE_FUNC_POLL
-# include <stropts.h>
-# include <poll.h>
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# endif
@@ -61,7 +59,7 @@
# endif
#endif
-MODULE_ID("$Id: lib_twait.c,v 1.34 1999/10/16 21:25:10 tom Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.37 2000/06/29 23:03:09 tom Exp $")
static long _nc_gettime(bool first)
{
@@ -243,7 +241,6 @@ retry:
if ((mode & (1 << count))
&& (fds[count].revents & POLLIN)) {
result |= (1 << count);
- count++;
}
}
#elif defined(__BEOS__)
diff --git a/contrib/ncurses/ncurses/tty/lib_vidattr.c b/contrib/ncurses/ncurses/tty/lib_vidattr.c
index 20cc2b138011..7cff22ec4b43 100644
--- a/contrib/ncurses/ncurses/tty/lib_vidattr.c
+++ b/contrib/ncurses/ncurses/tty/lib_vidattr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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 *
@@ -64,7 +64,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_vidattr.c,v 1.23 1999/06/12 21:20:41 tom Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.27 2000/04/29 23:25:27 tom Exp $")
#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
@@ -76,203 +76,218 @@ MODULE_ID("$Id: lib_vidattr.c,v 1.23 1999/06/12 21:20:41 tom Exp $")
/* if there is no current screen, assume we *can* do color */
#define SetColorsIf(why,old_attr) \
- if ((!SP || SP->_coloron) && (why)) { \
+ if (can_color && (why)) { \
int old_pair = PAIR_NUMBER(old_attr); \
T(("old pair = %d -- new pair = %d", old_pair, pair)); \
if ((pair != old_pair) \
+ || (fix_pair0 && (pair == 0)) \
|| (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
- _nc_do_color(pair, reverse, outc); \
+ _nc_do_color(old_pair, pair, reverse, outc); \
} \
}
-int vidputs(attr_t newmode, int (*outc)(int))
+int
+vidputs(attr_t newmode, int (*outc) (int))
{
-static attr_t previous_attr = A_NORMAL;
-attr_t turn_on, turn_off;
-int pair;
-bool reverse = FALSE;
-bool used_ncv = FALSE;
+ static attr_t previous_attr = A_NORMAL;
+ attr_t turn_on, turn_off;
+ int pair;
+ bool reverse = FALSE;
+ bool used_ncv = FALSE;
+ bool can_color = (SP == 0 || SP->_coloron);
+#ifdef NCURSES_EXT_FUNCS
+ bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
+#else
+#define fix_pair0 FALSE
+#endif
- T((T_CALLED("vidputs(%s)"), _traceattr(newmode)));
+ T((T_CALLED("vidputs(%s)"), _traceattr(newmode)));
- /* this allows us to go on whether or not newterm() has been called */
- if (SP)
- previous_attr = SP->_current_attr;
+ /* this allows us to go on whether or not newterm() has been called */
+ if (SP)
+ previous_attr = SP->_current_attr;
- T(("previous attribute was %s", _traceattr(previous_attr)));
+ T(("previous attribute was %s", _traceattr(previous_attr)));
#if !USE_XMC_SUPPORT
- if ((SP != 0)
- && (magic_cookie_glitch > 0))
- newmode &= ~(SP->_xmc_suppress);
+ if ((SP != 0)
+ && (magic_cookie_glitch > 0))
+ newmode &= ~(SP->_xmc_suppress);
#endif
- /*
- * If we have a terminal that cannot combine color with video
- * attributes, use the colors in preference.
- */
- if ((newmode & A_COLOR)
- && (no_color_video > 0)) {
- 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 },
- };
- 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 have a terminal that cannot combine color with video
+ * attributes, use the colors in preference.
+ */
+ if (((newmode & A_COLOR) != 0
+ || 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 (newmode == previous_attr)
+ returnCode(OK);
+
+ pair = PAIR_NUMBER(newmode);
- if (newmode == previous_attr)
- returnCode(OK);
+ if (reverse) {
+ newmode &= ~A_REVERSE;
+ }
- pair = PAIR_NUMBER(newmode);
+ turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR;
+ turn_on = (newmode & ~previous_attr) & ALL_BUT_COLOR;
- if (reverse) {
- newmode &= ~A_REVERSE;
+ SetColorsIf(((pair == 0) && !fix_pair0), previous_attr);
+
+ if (newmode == A_NORMAL) {
+ if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
+ doPut(exit_alt_charset_mode);
+ previous_attr &= ~A_ALTCHARSET;
+ }
+ if (previous_attr) {
+ doPut(exit_attribute_mode);
+ previous_attr &= ~A_COLOR;
}
- turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR;
- turn_on = (newmode & ~previous_attr) & ALL_BUT_COLOR;
-
- SetColorsIf(pair == 0, previous_attr);
-
- if (newmode == A_NORMAL) {
- if((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
- doPut(exit_alt_charset_mode);
- previous_attr &= ~A_ALTCHARSET;
- }
- if (previous_attr) {
- doPut(exit_attribute_mode);
- previous_attr &= ~A_COLOR;
- }
-
- SetColorsIf(pair != 0, previous_attr);
- } else if (set_attributes && !used_ncv) {
- 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);
- previous_attr &= ~A_COLOR;
- }
- SetColorsIf(pair != 0, previous_attr);
- } else {
-
- T(("turning %s off", _traceattr(turn_off)));
-
- TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
-
- if (!SP || SP->_use_rmul) {
- TurnOff(A_UNDERLINE, exit_underline_mode);
- }
-
- if (!SP || SP->_use_rmso) {
- TurnOff(A_STANDOUT, exit_standout_mode);
- }
-
- if (turn_off && exit_attribute_mode) {
- doPut(exit_attribute_mode);
- turn_on |= (newmode & (chtype)(~A_COLOR));
- previous_attr &= ~A_COLOR;
- }
- SetColorsIf(pair != 0, previous_attr);
-
- T(("turning %s on", _traceattr(turn_on)));
-
- TurnOn (A_ALTCHARSET, enter_alt_charset_mode);
- TurnOn (A_BLINK, enter_blink_mode);
- TurnOn (A_BOLD, enter_bold_mode);
- TurnOn (A_DIM, enter_dim_mode);
- TurnOn (A_REVERSE, enter_reverse_mode);
- TurnOn (A_STANDOUT, enter_standout_mode);
- TurnOn (A_PROTECT, enter_protected_mode);
- TurnOn (A_INVIS, enter_secure_mode);
- TurnOn (A_UNDERLINE, enter_underline_mode);
- TurnOn (A_HORIZONTAL, enter_horizontal_hl_mode);
- TurnOn (A_LEFT, enter_left_hl_mode);
- TurnOn (A_LOW, enter_low_hl_mode);
- TurnOn (A_RIGHT, enter_right_hl_mode);
- TurnOn (A_TOP, enter_top_hl_mode);
- TurnOn (A_VERTICAL, enter_vertical_hl_mode);
+ SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+ } else if (set_attributes && !used_ncv) {
+ 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);
+ previous_attr &= ~A_COLOR;
}
+ SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+ } else {
- if (reverse)
- newmode |= A_REVERSE;
+ T(("turning %s off", _traceattr(turn_off)));
- if (SP)
- SP->_current_attr = newmode;
- else
- previous_attr = newmode;
+ TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
- returnCode(OK);
+ if (!SP || SP->_use_rmul) {
+ TurnOff(A_UNDERLINE, exit_underline_mode);
+ }
+
+ if (!SP || SP->_use_rmso) {
+ TurnOff(A_STANDOUT, exit_standout_mode);
+ }
+
+ if (turn_off && exit_attribute_mode) {
+ doPut(exit_attribute_mode);
+ turn_on |= (newmode & (chtype) (~A_COLOR));
+ previous_attr &= ~A_COLOR;
+ }
+ SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+
+ T(("turning %s on", _traceattr(turn_on)));
+ /* *INDENT-OFF* */
+ TurnOn(A_ALTCHARSET, enter_alt_charset_mode);
+ TurnOn(A_BLINK, enter_blink_mode);
+ TurnOn(A_BOLD, enter_bold_mode);
+ TurnOn(A_DIM, enter_dim_mode);
+ TurnOn(A_REVERSE, enter_reverse_mode);
+ TurnOn(A_STANDOUT, enter_standout_mode);
+ TurnOn(A_PROTECT, enter_protected_mode);
+ TurnOn(A_INVIS, enter_secure_mode);
+ TurnOn(A_UNDERLINE, enter_underline_mode);
+ TurnOn(A_HORIZONTAL, enter_horizontal_hl_mode);
+ TurnOn(A_LEFT, enter_left_hl_mode);
+ TurnOn(A_LOW, enter_low_hl_mode);
+ TurnOn(A_RIGHT, enter_right_hl_mode);
+ TurnOn(A_TOP, enter_top_hl_mode);
+ TurnOn(A_VERTICAL, enter_vertical_hl_mode);
+ /* *INDENT-ON* */
+
+ }
+
+ if (reverse)
+ newmode |= A_REVERSE;
+
+ if (SP)
+ SP->_current_attr = newmode;
+ else
+ previous_attr = newmode;
+
+ returnCode(OK);
}
-int vidattr(attr_t newmode)
+int
+vidattr(attr_t newmode)
{
- T((T_CALLED("vidattr(%s)"), _traceattr(newmode)));
+ T((T_CALLED("vidattr(%s)"), _traceattr(newmode)));
- returnCode(vidputs(newmode, _nc_outch));
+ returnCode(vidputs(newmode, _nc_outch));
}
-chtype termattrs(void)
+chtype
+termattrs(void)
{
- chtype attrs = A_NORMAL;
+ chtype attrs = A_NORMAL;
- if (enter_alt_charset_mode)
- attrs |= A_ALTCHARSET;
+ if (enter_alt_charset_mode)
+ attrs |= A_ALTCHARSET;
- if (enter_blink_mode)
- attrs |= A_BLINK;
+ if (enter_blink_mode)
+ attrs |= A_BLINK;
- if (enter_bold_mode)
- attrs |= A_BOLD;
+ if (enter_bold_mode)
+ attrs |= A_BOLD;
- if (enter_dim_mode)
- attrs |= A_DIM;
+ if (enter_dim_mode)
+ attrs |= A_DIM;
- if (enter_reverse_mode)
- attrs |= A_REVERSE;
+ if (enter_reverse_mode)
+ attrs |= A_REVERSE;
- if (enter_standout_mode)
- attrs |= A_STANDOUT;
+ if (enter_standout_mode)
+ attrs |= A_STANDOUT;
- if (enter_protected_mode)
- attrs |= A_PROTECT;
+ if (enter_protected_mode)
+ attrs |= A_PROTECT;
- if (enter_secure_mode)
- attrs |= A_INVIS;
+ if (enter_secure_mode)
+ attrs |= A_INVIS;
- if (enter_underline_mode)
- attrs |= A_UNDERLINE;
+ if (enter_underline_mode)
+ attrs |= A_UNDERLINE;
- if (SP->_coloron)
- attrs |= A_COLOR;
+ if (SP->_coloron)
+ attrs |= A_COLOR;
- return(attrs);
+ return (attrs);
}
-
diff --git a/contrib/ncurses/ncurses/tty/tty_display.h b/contrib/ncurses/ncurses/tty/tty_display.h
index 1bc0d2d9dc42..e7b447d8045d 100644
--- a/contrib/ncurses/ncurses/tty/tty_display.h
+++ b/contrib/ncurses/ncurses/tty/tty_display.h
@@ -132,15 +132,6 @@ struct tty_display_data {
vidattr(AttrOf(c));
#endif
-/*
- * Check whether the given character can be output by clearing commands. This
- * includes test for being a space and not including any 'bad' attributes, such
- * as A_REVERSE. All attribute flags which don't affect appearance of a space
- * or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
- */
-#define can_clear_with(ch) \
- ((ch & ~(NONBLANK_ATTR|(back_color_erase ? A_COLOR:0))) == BLANK)
-
#define XMC_CHANGES(c) ((c) & D->_xmc_suppress)
#endif /* TTY_DISPLAY_H */
diff --git a/contrib/ncurses/ncurses/tty/tty_update.c b/contrib/ncurses/ncurses/tty/tty_update.c
index a5a640f8663c..b8670cd15f1d 100644
--- a/contrib/ncurses/ncurses/tty/tty_update.c
+++ b/contrib/ncurses/ncurses/tty/tty_update.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 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_doupdate.c
@@ -63,8 +62,6 @@
#endif
#if USE_FUNC_POLL
-#include <stropts.h>
-#include <poll.h>
#elif HAVE_SELECT
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
@@ -73,7 +70,7 @@
#include <term.h>
-MODULE_ID("$Id: tty_update.c,v 1.117 1999/10/22 23:28:46 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.139 2000/06/24 23:45:17 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -86,6 +83,8 @@ MODULE_ID("$Id: tty_update.c,v 1.117 1999/10/22 23:28:46 tom Exp $")
*/
#define CHECK_INTERVAL 5
+#define FILL_BCE() (SP->_col