summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-10-08 22:47:13 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-10-08 22:47:13 +0000
commit457e19a5caf834be99ae13c3efc359a02a42fb20 (patch)
tree244a1ee1210da4e47f53ccd339625b8a9f03b00e /lib
parenta6de1b801fa82570ef7457ae6e5188ebc7f5d93e (diff)
update to ncurses-5.1-20001007
Diffstat (limited to 'lib')
-rw-r--r--lib/libcurses++/cursesw.cc4
-rw-r--r--lib/libcurses++/internal.h6
-rw-r--r--lib/libcurses/Caps28
-rw-r--r--lib/libcurses/Makefile8
-rw-r--r--lib/libcurses/base/MKlib_gen.sh11
-rw-r--r--lib/libcurses/base/lib_addstr.c6
-rw-r--r--lib/libcurses/base/lib_color.c14
-rw-r--r--lib/libcurses/base/lib_colorset.c28
-rw-r--r--lib/libcurses/base/lib_getch.c20
-rw-r--r--lib/libcurses/base/lib_mouse.c8
-rw-r--r--lib/libcurses/base/lib_newterm.c8
-rw-r--r--lib/libcurses/base/lib_restart.c67
-rw-r--r--lib/libcurses/base/lib_set_term.c40
-rw-r--r--lib/libcurses/base/lib_winch.c21
-rw-r--r--lib/libcurses/curses.3tbl9
-rw-r--r--lib/libcurses/curses.h13
-rw-r--r--lib/libcurses/curses.priv.h79
-rw-r--r--lib/libcurses/ncurses_cfg.h26
-rw-r--r--lib/libcurses/ncurses_def.h480
-rw-r--r--lib/libcurses/term.5tbl4
-rw-r--r--lib/libcurses/term.76
-rw-r--r--lib/libcurses/termcap.h7
-rw-r--r--lib/libcurses/terminfo.5tbl4
-rw-r--r--lib/libcurses/tic.h7
-rw-r--r--lib/libcurses/tinfo/access.c77
-rw-r--r--lib/libcurses/tinfo/alloc_ttype.c88
-rw-r--r--lib/libcurses/tinfo/comp_parse.c39
-rw-r--r--lib/libcurses/tinfo/comp_scan.c59
-rw-r--r--lib/libcurses/tinfo/home_terminfo.c31
-rw-r--r--lib/libcurses/tinfo/lib_baudrate.c166
-rw-r--r--lib/libcurses/tinfo/lib_options.c6
-rw-r--r--lib/libcurses/tinfo/lib_raw.c6
-rw-r--r--lib/libcurses/tinfo/lib_setup.c8
-rw-r--r--lib/libcurses/tinfo/lib_termcap.c20
-rw-r--r--lib/libcurses/tinfo/lib_tgoto.c199
-rw-r--r--lib/libcurses/tinfo/lib_tparm.c952
-rw-r--r--lib/libcurses/tinfo/lib_tputs.c24
-rw-r--r--lib/libcurses/tinfo/parse_entry.c301
-rw-r--r--lib/libcurses/tinfo/read_bsd_terminfo.c8
-rw-r--r--lib/libcurses/tinfo/read_entry.c31
-rw-r--r--lib/libcurses/tinfo/read_termcap.c54
-rw-r--r--lib/libcurses/tinfo/strings.c141
-rw-r--r--lib/libcurses/tinfo/write_entry.c10
-rw-r--r--lib/libcurses/trace/lib_traceatr.c240
-rw-r--r--lib/libcurses/trace/lib_tracebits.c6
-rw-r--r--lib/libcurses/tty/MKexpanded.sh12
-rw-r--r--lib/libcurses/tty/lib_mvcur.c253
-rw-r--r--lib/libcurses/tty/lib_tstp.c344
-rw-r--r--lib/libcurses/tty/lib_twait.c286
-rw-r--r--lib/libcurses/tty/lib_vidattr.c95
-rw-r--r--lib/libcurses/tty/tty_update.c177
-rw-r--r--lib/libform/form_fieldtype.34
-rw-r--r--lib/libform/fty_enum.c76
-rw-r--r--lib/libmenu/mf_common.h6
-rw-r--r--lib/libpanel/panel.34
-rw-r--r--lib/libpanel/panel.priv.h35
56 files changed, 2897 insertions, 1765 deletions
diff --git a/lib/libcurses++/cursesw.cc b/lib/libcurses++/cursesw.cc
index 49662eaaf97..baa7a373045 100644
--- a/lib/libcurses++/cursesw.cc
+++ b/lib/libcurses++/cursesw.cc
@@ -25,7 +25,7 @@
#include "cursesw.h"
#include "internal.h"
-MODULE_ID("$From: cursesw.cc,v 1.16 1999/11/13 23:42:17 tom Exp $")
+MODULE_ID("$From: cursesw.cc,v 1.17 2000/09/02 18:55:31 tom Exp $")
#define COLORS_NEED_INITIALIZATION -1
#define COLORS_NOT_INITIALIZED 0
@@ -424,7 +424,7 @@ NCursesWindow::setcolor(short pair)
return OK;
}
-#ifdef HAVE_HAS_KEY
+#if HAVE_HAS_KEY
extern "C" int _nc_has_mouse(void);
bool NCursesWindow::has_mouse() const {
diff --git a/lib/libcurses++/internal.h b/lib/libcurses++/internal.h
index d2f29c426a9..daa8bc8d44b 100644
--- a/lib/libcurses++/internal.h
+++ b/lib/libcurses++/internal.h
@@ -1,6 +1,6 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
- * 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,12 +31,12 @@
* Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1997 *
****************************************************************************/
-// $From: internal.h,v 1.5 1999/05/16 17:29:25 juergen Exp $
+// $From: internal.h,v 1.6 2000/09/02 18:22:23 tom Exp $
#ifndef _CPLUS_INTERNAL_H
#define _CPLUS_INTERNAL_H 1
-#ifdef USE_RCS_IDS
+#if USE_RCS_IDS
#define MODULE_ID(id) static const char Ident[] = id;
#else
#define MODULE_ID(id) /*nothing*/
diff --git a/lib/libcurses/Caps b/lib/libcurses/Caps
index ada2914fc7e..94c16b996bc 100644
--- a/lib/libcurses/Caps
+++ b/lib/libcurses/Caps
@@ -29,8 +29,8 @@
# Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995
# and: Eric S. Raymond <esr@snark.thyrsus.com>
#
-# $OpenBSD: Caps,v 1.3 1999/11/28 17:53:40 millert Exp $
-# $From: Caps,v 1.25 1999/11/27 20:13:55 tom Exp $
+# $OpenBSD: Caps,v 1.4 2000/10/08 22:46:53 millert Exp $
+# $From: Caps,v 1.28 2000/10/01 02:07:36 tom Exp $
#
# This is the master termcap/terminfo capability table.
#
@@ -335,7 +335,7 @@ cursor_down cud1 str do YBCGE down one line
cursor_home home str ho YBCGE home cursor (if no cup)
cursor_invisible civis str vi YB-G- make cursor invisible
cursor_left cub1 str le YBCGE move left one space
-cursor_mem_address mrcup str CM YB-G- memory relative cursor addressing
+cursor_mem_address mrcup str CM YB-G- memory relative cursor addressing, move to row #1 columns #2
cursor_normal cnorm str ve YBCGE make cursor appear normal (undo civis/cvvis)
cursor_right cuf1 str nd YBCGE non-destructive space (move right one space)
cursor_to_ll ll str ll YBCGE last line, first column (if no cup)
@@ -455,7 +455,7 @@ set_attributes sgr str sa YB-G- define video attributes #1-#9 (PG9)
set_tab hts str st YB-G- set a tab in every row, current columns
set_window wind str wi -B-GE current window is lines #1-#2 cols #3-#4
tab ht str ta YBCGE tab to next 8-space hardware tab stop
-to_status_line tsl str ts YB-G- move to status line
+to_status_line tsl str ts YB-G- move to status line, column #1
underline_char uc str uc YBCG- underline char and move past it
up_half_line hu str hu YB-G- half a line up
init_prog iprog str iP -B--- path name of program for initialization
@@ -634,10 +634,10 @@ set_background setb str Sb ----- Set background color #1
#
# SVr4 added these capabilities to support printers
#
-change_char_pitch cpi str ZA ----- Change number of characters per inch
-change_line_pitch lpi str ZB ----- Change number of lines per inch
-change_res_horz chr str ZC ----- Change horizontal resolution
-change_res_vert cvr str ZD ----- Change vertical resolution
+change_char_pitch cpi str ZA ----- Change number of characters per inch to #1
+change_line_pitch lpi str ZB ----- Change number of lines per inch to #1
+change_res_horz chr str ZC ----- Change horizontal resolution to #1
+change_res_vert cvr str ZD ----- Change vertical resolution to #1
define_char defc str ZE ----- Define a character
enter_doublewide_mode swidm str ZF ----- Enter double-wide mode
enter_draft_quality sdrfq str ZG ----- Enter draft-quality mode
@@ -662,14 +662,14 @@ micro_column_address mhpa str ZY ----- Like column_address in micro mode
micro_down mcud1 str ZZ ----- Like cursor_down in micro mode
micro_left mcub1 str Za ----- Like cursor_left in micro mode
micro_right mcuf1 str Zb ----- Like cursor_right in micro mode
-micro_row_address mvpa str Zc ----- Like row_address in micro mode
+micro_row_address mvpa str Zc ----- Like row_address #1 in micro mode
micro_up mcuu1 str Zd ----- Like cursor_up in micro mode
order_of_pins porder str Ze ----- Match software bits to print-head pins
parm_down_micro mcud str Zf ----- Like parm_down_cursor in micro mode
parm_left_micro mcub str Zg ----- Like parm_left_cursor in micro mode
parm_right_micro mcuf str Zh ----- Like parm_right_cursor in micro mode
parm_up_micro mcuu str Zi ----- Like parm_up_cursor in micro mode
-select_char_set scs str Zj ----- Select character set
+select_char_set scs str Zj ----- Select character set, #1
set_bottom_margin smgb str Zk ----- Set bottom margin at current line
set_bottom_margin_parm smgbp str Zl ----- Set bottom margin at line #1 or #2 lines from bottom
set_left_margin_parm smglp str Zm ----- Set left (right) margin at column #1 (#2)
@@ -702,9 +702,9 @@ char_set_names csnm str Zy ----- List of character set names
key_mouse kmous str Km ----- Mouse event has occurred
mouse_info minfo str Mi ----- Mouse status information
req_mouse_pos reqmp str RQ ----- Request mouse position
-get_mouse getm str Gm ----- Curses should get button events
-set_a_foreground setaf str AF ----- Set foreground color using ANSI escape
-set_a_background setab str AB ----- Set background color using ANSI escape
+get_mouse getm str Gm ----- Curses should get button events, parameter #1 not documented.
+set_a_foreground setaf str AF ----- Set foreground color to #1, using ANSI escape
+set_a_background setab str AB ----- Set background color to #1, using ANSI escape
pkey_plab pfxl str xl ----- Program function key #1 to type string #2 and show string #3
device_type devt str dv ----- Indicate language/codeset support
code_set_init csin str ci ----- Init sequence for multiple codesets
@@ -725,7 +725,7 @@ set_page_length slines str YZ ----- Set page length to #1 lines
#
# SVr4 added these capabilities for direct PC-clone support
#
-display_pc_char dispc str S1 ----- Display PC character
+display_pc_char dispc str S1 ----- Display PC character #1
enter_pc_charset_mode smpch str S2 ----- Enter PC character display mode
exit_pc_charset_mode rmpch str S3 ----- Exit PC character display mode
enter_scancode_mode smsc str S4 ----- Enter PC scancode mode
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile
index 0cd9a9051ce..736ffb1c945 100644
--- a/lib/libcurses/Makefile
+++ b/lib/libcurses/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.46 2000/07/24 04:06:09 millert Exp $
+# $OpenBSD: Makefile,v 1.47 2000/10/08 22:46:54 millert Exp $
# Uncomment this to enable tracing in libcurses
#CURSESTRACE=-DTRACE
@@ -40,10 +40,10 @@ SRCS+= access.c add_tries.c alloc_entry.c alloc_ttype.c captoinfo.c \
doalloc.c free_ttype.c getenv_num.c home_terminfo.c init_keytry.c \
lib_acs.c lib_baudrate.c lib_cur_term.c lib_data.c lib_has_cap.c \
lib_kernel.c lib_longname.c lib_napms.c lib_options.c lib_print.c \
- lib_raw.c lib_setup.c lib_termcap.c lib_termname.c lib_ti.c \
- lib_tparm.c lib_tputs.c lib_ttyflags.c name_match.c \
+ lib_raw.c lib_setup.c lib_termcap.c lib_termname.c lib_tgoto.c \
+ lib_ti.c lib_tparm.c lib_tputs.c lib_ttyflags.c name_match.c \
parse_entry.c read_bsd_terminfo.c read_entry.c read_termcap.c \
- setbuf.c write_entry.c
+ setbuf.c strings.c write_entry.c
# trace
SRCS+= lib_trace.c lib_traceatr.c lib_tracebits.c lib_tracechr.c \
lib_tracedmp.c lib_tracemse.c trace_buf.c trace_tries.c trace_xnames.c
diff --git a/lib/libcurses/base/MKlib_gen.sh b/lib/libcurses/base/MKlib_gen.sh
index 283a614c72d..2efe9091a08 100644
--- a/lib/libcurses/base/MKlib_gen.sh
+++ b/lib/libcurses/base/MKlib_gen.sh
@@ -2,8 +2,8 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# $OpenBSD: MKlib_gen.sh,v 1.1 1999/01/18 19:09:32 millert Exp $
-# ($From: MKlib_gen.sh,v 1.11 1998/01/17 14:16:52 Juan.Jose.Garcia.Ripoll Exp $)
+# $OpenBSD: MKlib_gen.sh,v 1.2 2000/10/08 22:46:58 millert Exp $
+# ($From: MKlib_gen.sh,v 1.12 2000/07/29 16:30:11 tom Exp $)
#
# The XSI Curses standard requires all curses entry points to exist as
# functions, even though many definitions would normally be shadowed
@@ -114,6 +114,11 @@ BEGIN {
print "\n"
skip=1;
+ if ( $1 == "chtype" ) {
+ returnType = "Char";
+ } else {
+ returnType = "Code";
+ }
print "M_" $2
print $0;
print "{";
@@ -201,7 +206,7 @@ BEGIN {
if (match($0, "^void"))
call = ""
else if (dotrace)
- call = "returnCode( ";
+ call = sprintf("return%s( ", returnType);
else
call = "%%return ";
diff --git a/lib/libcurses/base/lib_addstr.c b/lib/libcurses/base/lib_addstr.c
index 32d5fbb116f..99d76a18aa8 100644
--- a/lib/libcurses/base/lib_addstr.c
+++ b/lib/libcurses/base/lib_addstr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_addstr.c,v 1.2 2000/06/19 03:53:38 millert Exp $ */
+/* $OpenBSD: lib_addstr.c,v 1.3 2000/10/08 22:46:58 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_addstr.c,v 1.17 2000/04/29 21:15:55 tom Exp $")
+MODULE_ID("$From: lib_addstr.c,v 1.18 2000/07/29 16:42:41 tom Exp $")
int
waddnstr(WINDOW *win, const char *const astr, int n)
@@ -53,7 +53,7 @@ waddnstr(WINDOW *win, const char *const astr, int n)
T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));
if (win && (str != 0)) {
- T(("... current %s", _traceattr(win->_attrs)));
+ TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs)));
TR(TRACE_VIRTPUT, ("str is not null"));
code = OK;
if (n < 0)
diff --git a/lib/libcurses/base/lib_color.c b/lib/libcurses/base/lib_color.c
index a1a195453c4..952698083d0 100644
--- a/lib/libcurses/base/lib_color.c
+++ b/lib/libcurses/base/lib_color.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_color.c,v 1.8 2000/06/19 03:53:40 millert Exp $ */
+/* $OpenBSD: lib_color.c,v 1.9 2000/10/08 22:46:58 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -43,7 +43,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$From: lib_color.c,v 1.51 2000/05/20 20:09:22 tom Exp $")
+MODULE_ID("$From: lib_color.c,v 1.53 2000/09/02 18:02:15 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
@@ -87,7 +87,7 @@ static const color_t hls_palette[] =
};
/* *INDENT-ON* */
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
/*
* These are called from _nc_do_color(), which in turn is called from
* vidattr - so we have to assume that SP may be null.
@@ -267,7 +267,7 @@ init_pair(short pair, short f, short b)
if ((pair < 0) || (pair >= COLOR_PAIRS))
returnCode(ERR);
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (SP->_default_color) {
if (f < 0)
f = C_MASK;
@@ -440,7 +440,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
pair_content(old_pair, &old_fg, &old_bg);
if ((fg == C_MASK && old_fg != C_MASK)
|| (bg == C_MASK && old_bg != C_MASK)) {
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
/*
* A minor optimization - but extension. If "AX" is specified in
* the terminal description, treat it as screen's indicator of ECMA
@@ -460,7 +460,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
return;
}
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (fg == C_MASK)
fg = default_fg();
if (bg == C_MASK)
@@ -473,7 +473,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
bg = xx;
}
- T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+ TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
if (fg != C_MASK) {
set_foreground_color(fg, outc);
diff --git a/lib/libcurses/base/lib_colorset.c b/lib/libcurses/base/lib_colorset.c
index e3070f4ce30..0c03674baab 100644
--- a/lib/libcurses/base/lib_colorset.c
+++ b/lib/libcurses/base/lib_colorset.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_colorset.c,v 1.2 1999/05/17 03:03:58 millert Exp $ */
+/* $OpenBSD: lib_colorset.c,v 1.3 2000/10/08 22:46:58 millert Exp $ */
/****************************************************************************
- * 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 *
@@ -42,17 +42,19 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_colorset.c,v 1.5 1999/05/16 17:13:43 juergen Exp $")
+MODULE_ID("$From: lib_colorset.c,v 1.6 2000/07/29 16:37:19 tom Exp $")
-int wcolor_set(WINDOW *win, short color_pair_number, void *opts)
+int
+wcolor_set(WINDOW *win, short color_pair_number, void *opts)
{
- T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
- if (win && !opts && (color_pair_number >= 0) && (color_pair_number < COLOR_PAIRS)) {
- T(("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
- toggle_attr_on(win->_attrs,COLOR_PAIR(color_pair_number));
- returnCode(OK);
- } else
- returnCode(ERR);
+ T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
+ if (win
+ && !opts
+ && (color_pair_number >= 0)
+ && (color_pair_number < COLOR_PAIRS)) {
+ TR(TRACE_ATTRS, ("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
+ toggle_attr_on(win->_attrs, COLOR_PAIR(color_pair_number));
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
-
-
diff --git a/lib/libcurses/base/lib_getch.c b/lib/libcurses/base/lib_getch.c
index 4d45740a62a..0b37e2190c6 100644
--- a/lib/libcurses/base/lib_getch.c
+++ b/lib/libcurses/base/lib_getch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_getch.c,v 1.6 2000/07/10 03:06:13 millert Exp $ */
+/* $OpenBSD: lib_getch.c,v 1.7 2000/10/08 22:46:58 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_getch.c,v 1.48 2000/07/08 11:21:51 tom Exp $")
+MODULE_ID("$From: lib_getch.c,v 1.49 2000/07/29 15:45:24 tom Exp $")
#include <fifo_defs.h>
@@ -91,7 +91,7 @@ static inline int
fifo_peek(void)
{
int ch = SP->_fifo[peek];
- T(("peeking at %d", peek));
+ TR(TRACE_IEVENT, ("peeking at %d", peek));
p_inc();
return ch;
@@ -102,7 +102,7 @@ fifo_pull(void)
{
int ch;
ch = SP->_fifo[head];
- T(("pulling %d from %d", ch, head));
+ TR(TRACE_IEVENT, ("pulling %d from %d", ch, head));
if (peek == head) {
h_inc();
@@ -164,17 +164,17 @@ fifo_push(void)
#endif
if ((n == -1) || (n == 0)) {
- T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
+ TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
ch = ERR;
}
- T(("read %d characters", n));
+ TR(TRACE_IEVENT, ("read %d characters", n));
SP->_fifo[tail] = ch;
SP->_fifohold = 0;
if (head == -1)
head = peek = tail;
t_inc();
- T(("pushed %#x at %d", ch, tail));
+ TR(TRACE_IEVENT, ("pushed %#x at %d", ch, tail));
#ifdef TRACE
if (_nc_tracing & TRACE_IEVENT)
_nc_fifo_dump();
@@ -225,7 +225,7 @@ wgetch(WINDOW *win)
if (head == -1 && !SP->_raw && !SP->_cbreak) {
char buf[MAXCOLUMNS], *sp;
- T(("filling queue in cooked mode"));
+ TR(TRACE_IEVENT, ("filling queue in cooked mode"));
wgetnstr(win, buf, MAXCOLUMNS);
@@ -243,13 +243,13 @@ wgetch(WINDOW *win)
if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
int delay;
- T(("timed delay in wgetch()"));
+ TR(TRACE_IEVENT, ("timed delay in wgetch()"));
if (SP->_cbreak > 1)
delay = (SP->_cbreak - 1) * 100;
else
delay = win->_delay;
- T(("delay is %d milliseconds", delay));
+ TR(TRACE_IEVENT, ("delay is %d milliseconds", delay));
if (head == -1) /* fifo is empty */
if (!_nc_timed_wait(3, delay, (int *) 0))
diff --git a/lib/libcurses/base/lib_mouse.c b/lib/libcurses/base/lib_mouse.c
index cd8e602ce3b..e915f4bf6b7 100644
--- a/lib/libcurses/base/lib_mouse.c
+++ b/lib/libcurses/base/lib_mouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_mouse.c,v 1.10 2000/07/10 03:06:14 millert Exp $ */
+/* $OpenBSD: lib_mouse.c,v 1.11 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -86,7 +86,7 @@
#endif
#endif
-MODULE_ID("$From: lib_mouse.c,v 1.52 2000/06/29 23:02:26 tom Exp $")
+MODULE_ID("$From: lib_mouse.c,v 1.54 2000/10/03 08:26:34 tom Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
@@ -156,7 +156,7 @@ write_event(int down, int button, int x, int y)
char buf[6];
unsigned long ignore;
- strcpy(buf, key_mouse);
+ strncpy(buf, key_mouse, 3); /* should be "\033[M" */
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
@@ -516,7 +516,7 @@ mouse_activate(bool on)
switch (mousetype) {
case M_XTERM:
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
keyok(KEY_MOUSE, on);
#endif
TPUTS_TRACE("xterm mouse initialization");
diff --git a/lib/libcurses/base/lib_newterm.c b/lib/libcurses/base/lib_newterm.c
index 6e01e19a271..2dbe3e87230 100644
--- a/lib/libcurses/base/lib_newterm.c
+++ b/lib/libcurses/base/lib_newterm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_newterm.c,v 1.10 2000/07/24 04:06:10 millert Exp $ */
+/* $OpenBSD: lib_newterm.c,v 1.11 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -42,14 +42,14 @@
#include <curses.priv.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_newterm.c,v 1.47 2000/07/22 22:33:34 Bruno.Haible Exp $")
+MODULE_ID("$From: lib_newterm.c,v 1.48 2000/09/02 18:11:42 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -193,7 +193,7 @@ newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
SP->_use_rmso = SGR0_TEST(exit_standout_mode);
SP->_use_rmul = SGR0_TEST(exit_underline_mode);
-#ifdef USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT
/*
* XFree86 xterm can be configured to support UTF-8 based on environment
* variable settings.
diff --git a/lib/libcurses/base/lib_restart.c b/lib/libcurses/base/lib_restart.c
index 8f2ae3f91fc..c77edbeb067 100644
--- a/lib/libcurses/base/lib_restart.c
+++ b/lib/libcurses/base/lib_restart.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_restart.c,v 1.2 1999/08/15 11:40:55 millert Exp $ */
+/* $OpenBSD: lib_restart.c,v 1.3 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
- * 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 *
@@ -43,50 +43,51 @@
#include <curses.priv.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
-#include <term.h> /* lines, columns, cur_term */
+#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$From: lib_restart.c,v 1.2 1999/07/24 20:10:04 tom Exp $")
+MODULE_ID("$From: lib_restart.c,v 1.3 2000/09/02 18:09:44 tom Exp $")
-int restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
+int
+restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
{
-int saveecho = SP->_echo;
-int savecbreak = SP->_cbreak;
-int saveraw = SP->_raw;
-int savenl = SP->_nl;
+ int saveecho = SP->_echo;
+ int savecbreak = SP->_cbreak;
+ int saveraw = SP->_raw;
+ int savenl = SP->_nl;
- T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
+ T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
- setupterm(termp, filenum, errret);
+ setupterm(termp, filenum, errret);
- if (saveecho)
- echo();
- else
- noecho();
+ if (saveecho)
+ echo();
+ else
+ noecho();
- if (savecbreak) {
- cbreak();
- noraw();
- } else if (saveraw) {
- nocbreak();
- raw();
- } else {
- nocbreak();
- noraw();
- }
- if (savenl)
- nl();
- else
- nonl();
+ if (savecbreak) {
+ cbreak();
+ noraw();
+ } else if (saveraw) {
+ nocbreak();
+ raw();
+ } else {
+ nocbreak();
+ noraw();
+ }
+ if (savenl)
+ nl();
+ else
+ nonl();
- reset_prog_mode();
+ reset_prog_mode();
#if USE_SIZECHANGE
- _nc_update_screensize();
+ _nc_update_screensize();
#endif
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c
index 438d8fade6d..6952649ddfe 100644
--- a/lib/libcurses/base/lib_set_term.c
+++ b/lib/libcurses/base/lib_set_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_set_term.c,v 1.10 2000/07/10 03:06:15 millert Exp $ */
+/* $OpenBSD: lib_set_term.c,v 1.11 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -45,7 +45,7 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_set_term.c,v 1.55 2000/07/02 00:22:18 tom Exp $")
+MODULE_ID("$From: lib_set_term.c,v 1.58 2000/10/04 22:05:48 tom Exp $")
SCREEN *
set_term(SCREEN * screenp)
@@ -173,7 +173,7 @@ no_mouse_wrap(SCREEN * sp GCC_UNUSED)
{
}
-#if defined(NCURSES_EXT_FUNCS) && defined(USE_COLORFGBG)
+#if NCURSES_EXT_FUNCS && USE_COLORFGBG
static char *
extract_fgbg(char *src, int *result)
{
@@ -222,17 +222,45 @@ _nc_setupscreen(short slines, short const scolumns, FILE * output)
SP->_endwin = TRUE;
SP->_ofp = output;
SP->_cursor = -1; /* cannot know real cursor shape */
-#ifdef NCURSES_NO_PADDING
+
+#if NCURSES_NO_PADDING
SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
SP->_no_padding ? " not" : ""));
#endif
-#ifdef NCURSES_EXT_FUNCS
+
+#if NCURSES_EXT_FUNCS
SP->_default_color = FALSE;
SP->_has_sgr_39_49 = FALSE;
+
+ /*
+ * Set our assumption of the terminal's default foreground and background
+ * colors. The curs_color man-page states that we can assume that the
+ * background is black. The origin of this assumption appears to be
+ * terminals that displayed colored text, but no colored backgrounds, e.g.,
+ * the first colored terminals around 1980. More recent ones with better
+ * technology can display not only colored backgrounds, but all
+ * combinations. So a terminal might be something other than "white" on
+ * black (green/black looks monochrome too), but black on white or even
+ * on ivory.
+ *
+ * White-on-black is the simplest thing to use for monochrome. Almost
+ * all applications that use color paint both text and background, so
+ * the distinction is moot. But a few do not - which is why we leave this
+ * configurable (a better solution is to use assume_default_colors() for
+ * the rare applications that do require that sort of appearance, since
+ * is appears that more users expect to be able to make a white-on-black
+ * or black-on-white display under control of the application than not).
+ */
+#ifdef USE_ASSUMED_COLOR
SP->_default_fg = COLOR_WHITE;
SP->_default_bg = COLOR_BLACK;
-#ifdef USE_COLORFGBG
+#else
+ SP->_default_fg = C_MASK;
+ SP->_default_bg = C_MASK;
+#endif
+
+#if USE_COLORFGBG
/*
* If rxvt's $COLORFGBG variable is set, use it to specify the assumed
* default colors. Note that rxvt (mis)uses bold colors, equating a bold
diff --git a/lib/libcurses/base/lib_winch.c b/lib/libcurses/base/lib_winch.c
index 8148b890a06..1c468be590b 100644
--- a/lib/libcurses/base/lib_winch.c
+++ b/lib/libcurses/base/lib_winch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_winch.c,v 1.1 1999/01/18 19:10:06 millert Exp $ */
+/* $OpenBSD: lib_winch.c,v 1.2 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,14 +41,15 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_winch.c,v 1.1 1998/11/14 22:06:09 tom Exp $")
+MODULE_ID("$From: lib_winch.c,v 1.2 2000/07/29 16:41:44 tom Exp $")
-chtype winch(WINDOW *win)
+chtype
+winch(WINDOW *win)
{
- T((T_CALLED("winch(%p)"), win));
- if (win != 0) {
- returnCode(win->_line[win->_cury].text[win->_curx]);
- } else {
- returnCode(0);
- }
+ T((T_CALLED("winch(%p)"), win));
+ if (win != 0) {
+ returnChar(win->_line[win->_cury].text[win->_curx]);
+ } else {
+ returnChar(0);
+ }
}
diff --git a/lib/libcurses/curses.3tbl b/lib/libcurses/curses.3tbl
index f906acf45f8..01fb9ed4c35 100644
--- a/lib/libcurses/curses.3tbl
+++ b/lib/libcurses/curses.3tbl
@@ -1,5 +1,5 @@
'\" t
-.\" $OpenBSD: curses.3tbl,v 1.15 2000/07/24 04:06:09 millert Exp $
+.\" $OpenBSD: curses.3tbl,v 1.16 2000/10/08 22:46:54 millert Exp $
.\"
.\"***************************************************************************
.\" Copyright (c) 1998,1999 Free Software Foundation, Inc. *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: ncurses.3x,v 1.41 2000/07/15 22:04:13 tom Exp $
+.\" $From: ncurses.3x,v 1.44 2000/10/08 01:39:26 tom Exp $
.TH ncurses 3 ""
.ds n 5
.ds d /usr/share/terminfo
@@ -695,6 +695,11 @@ the TERMPATH symbol.
This is a list of filenames separated by colons (i.e., ":").
If the TERMPATH symbol is not set, \fBcurses\fR looks in the files
/etc/termcap, /usr/share/termcap and $HOME/.termcap, in that order.
+.PP
+The library may be configured to disregard the following variables when the
+current user is the superuser (root), or if the application uses setuid or
+setgid permissions:
+$TERMCAP, $TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME.
.SH FILES
.TP 5
/usr/share/tabset
diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h
index 3fc791092ac..0080d97cf88 100644
--- a/lib/libcurses/curses.h
+++ b/lib/libcurses/curses.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: curses.h,v 1.53 2000/07/24 04:06:09 millert Exp $ */
+/* $OpenBSD: curses.h,v 1.54 2000/10/08 22:46:54 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -33,7 +33,7 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-/* $From: curses.h.in,v 1.93 2000/07/08 11:07:26 tom Exp $ */
+/* $From: curses.h.in,v 1.96 2000/09/16 16:11:01 tom Exp $ */
#ifndef __NCURSES_H
#define __NCURSES_H
@@ -50,7 +50,7 @@
/* These are defined only in curses.h, and are used for conditional compiles */
#define NCURSES_VERSION_MAJOR 5
#define NCURSES_VERSION_MINOR 1
-#define NCURSES_VERSION_PATCH 20000722
+#define NCURSES_VERSION_PATCH 20001004
/* This is defined in more than one ncurses header, for identification */
#undef NCURSES_VERSION
@@ -65,7 +65,7 @@
#endif
#undef NCURSES_CONST
-#define NCURSES_CONST
+#define NCURSES_CONST /*nothing*/
#undef NCURSES_COLOR_T
#define NCURSES_COLOR_T short
@@ -359,13 +359,13 @@ extern int wresize (WINDOW *, int, int);
* We cannot define these in ncurses_cfg.h, since they require parameters to be
* passed (that's non-portable).
*/
-#if GCC_PRINTF
+#ifdef GCC_PRINTF
#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
#else
#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
#endif
-#if GCC_SCANF
+#ifdef GCC_SCANF
#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
#else
#define GCC_SCANFLIKE(fmt,var) /*nothing*/
@@ -1345,6 +1345,7 @@ extern void trace(const unsigned int);
#define TRACE_ICALLS 0x0200 /* trace internal/nested calls */
#define TRACE_CCALLS 0x0400 /* trace per-character calls */
#define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */
+#define TRACE_ATTRS 0x1000 /* trace attribute updates */
#define TRACE_MAXIMUM 0xffff /* maximum trace level */
#if defined(TRACE) || defined(NCURSES_TEST)
diff --git a/lib/libcurses/curses.priv.h b/lib/libcurses/curses.priv.h
index a3ca08cb086..3327b4d97cd 100644
--- a/lib/libcurses/curses.priv.h
+++ b/lib/libcurses/curses.priv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: curses.priv.h,v 1.28 2000/07/10 03:06:10 millert Exp $ */
+/* $OpenBSD: curses.priv.h,v 1.29 2000/10/08 22:46:55 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -35,7 +35,7 @@
/*
- * $From: curses.priv.h,v 1.162 2000/06/24 21:06:10 tom Exp $
+ * $From: curses.priv.h,v 1.168 2000/10/08 01:24:59 tom Exp $
*
* curses.priv.h
*
@@ -101,7 +101,7 @@ extern int errno;
/* Some systems have a broken 'select()', but workable 'poll()'. Use that */
#if HAVE_WORKING_POLL
#define USE_FUNC_POLL 1
-#ifdef HAVE_POLL_H
+#if HAVE_POLL_H
#include <poll.h>
#else
#include <sys/poll.h>
@@ -136,7 +136,7 @@ extern int errno;
* If we don't have signals to support it, don't add a sigwinch handler.
* In any case, resizing is an extended feature. Use it if we've got it.
*/
-#ifndef NCURSES_EXT_FUNCS
+#if !NCURSES_EXT_FUNCS
#undef HAVE_SIZECHANGE
#endif
@@ -147,6 +147,17 @@ extern int errno;
#endif
/*
+ * If desired, one can configure this, disabling environment variables that
+ * point to custom terminfo/termcap locations.
+ */
+#ifdef USE_ROOT_ENVIRON
+#define use_terminfo_vars() 1
+#else
+#define use_terminfo_vars() _nc_env_access()
+extern int _nc_env_access(void);
+#endif
+
+/*
* Not all platforms have memmove; some have an equivalent bcopy. (Some may
* have neither).
*/
@@ -290,7 +301,7 @@ struct screen {
SLK *_slk; /* ptr to soft key struct / NULL */
int slk_format; /* selected format for this screen */
/* cursor movement costs; units are 10ths of milliseconds */
-#ifdef NCURSES_NO_PADDING
+#if NCURSES_NO_PADDING
int _no_padding; /* flag to set if padding disabled */
#endif
int _char_padding; /* cost of character put */
@@ -331,9 +342,7 @@ struct screen {
int _ip_cost; /* cost of (insert_padding) */
/* used in lib_mvcur.c */
char * _address_cursor;
- int _carriage_return_length;
- int _cursor_home_length;
- int _cursor_to_ll_length;
+ /* used in tty_update.c */
int _scrolling; /* 1 if terminal's smart enough to */
/* used in lib_color.c */
@@ -341,7 +350,7 @@ struct screen {
int _color_count; /* count of colors in palette */
unsigned short *_color_pairs; /* screen's color pair list */
int _pair_count; /* count of color pairs */
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
bool _default_color; /* use default colors */
bool _has_sgr_39_49; /* has ECMA default color support */
int _default_fg; /* assumed default foreground */
@@ -409,7 +418,7 @@ struct screen {
extern SCREEN *_nc_screen_chain;
-#ifdef NCURSES_NOMACROS
+#if NCURSES_NOMACROS
#include <nomacros.h>
#endif
@@ -532,12 +541,14 @@ typedef struct {
#define TPUTS_TRACE(s) _nc_tputs_trace = s;
#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
#define returnAttr(code) TRACE_RETURN(code,attr_t)
+#define returnChar(code) TRACE_RETURN(code,chtype)
#define returnCode(code) TRACE_RETURN(code,int)
#define returnPtr(code) TRACE_RETURN(code,ptr)
#define returnVoid T((T_RETURN(""))); return
#define returnWin(code) TRACE_RETURN(code,win)
extern WINDOW * _nc_retrace_win(WINDOW *);
extern attr_t _nc_retrace_attr_t(attr_t);
+extern attr_t _nc_retrace_chtype(chtype);
extern char *_nc_retrace_ptr(char *);
extern const char *_nc_tputs_trace;
extern int _nc_retrace_int(int);
@@ -548,6 +559,7 @@ extern void _nc_fifo_dump(void);
#define TR(n, a)
#define TPUTS_TRACE(s)
#define returnAttr(code) return code
+#define returnChar(code) return code
#define returnCode(code) return code
#define returnPtr(code) return code
#define returnVoid return
@@ -570,7 +582,7 @@ extern const char *_nc_visbuf2(int, const char *);
(S) = ((S) & ALL_BUT_COLOR) | (at);\
else\
(S) |= (at);\
- T(("new attribute is %s", _traceattr((S))));}
+ TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define toggle_attr_off(S,at) {\
@@ -585,7 +597,7 @@ extern const char *_nc_visbuf2(int, const char *);
else /* leave color alone */\
(S) &= ~(at);\
}\
- T(("new attribute is %s", _traceattr((S))));}
+ TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define DelCharCost(count) \
((parm_dch != 0) \
@@ -609,7 +621,8 @@ extern const char *_nc_visbuf2(int, const char *);
vidattr(AttrOf(c)); \
if (magic_cookie_glitch > 0 \
&& XMC_CHANGES((chg ^ SP->_current_attr))) { \
- T(("%s @%d before glitch %d,%d", \
+ TR(TRACE_ATTRS, \
+ ("%s @%d before glitch %d,%d", \
__FILE__, __LINE__, \
SP->_cursrow, \
SP->_curscol)); \
@@ -621,7 +634,7 @@ extern const char *_nc_visbuf2(int, const char *);
vidattr(AttrOf(c))
#endif
-#if defined(NCURSES_EXPANDED) && defined(NCURSES_EXT_FUNCS)
+#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
#undef toggle_attr_on
#define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
@@ -680,14 +693,40 @@ extern void _nc_screen_init(void);
extern void _nc_screen_resume(void);
extern void _nc_screen_wrap(void);
+/* lib_mouse.c */
+extern int _nc_has_mouse(void);
+
+/* lib_mvcur.c */
+#define INFINITY 1000000 /* cost: too high to use */
+
+typedef struct {
+ char *s_head;
+ char *s_tail;
+ size_t s_size;
+} string_desc;
+
+/* strings.c */
+extern string_desc *_nc_str_init(string_desc * dst, char *src, size_t len);
+extern string_desc *_nc_str_null(string_desc * dst, size_t len);
+extern string_desc *_nc_str_copy(string_desc * dst, string_desc * src);
+extern bool _nc_safe_strcat(string_desc * dst, const char *src);
+extern bool _nc_safe_strcpy(string_desc * dst, const char *src);
+
+extern void _nc_mvcur_init(void);
+extern void _nc_mvcur_resume(void);
+extern void _nc_mvcur_wrap(void);
+
+extern int _nc_scrolln(int, int, int, int);
+
+extern void _nc_screen_init(void);
+extern void _nc_screen_resume(void);
+extern void _nc_screen_wrap(void);
+
#if !HAVE_STRSTR
#define strstr _nc_strstr
extern char *_nc_strstr(const char *, const char *);
#endif
-/* lib_mouse.c */
-extern int _nc_has_mouse(void);
-
/* safe_sprintf.c */
extern char * _nc_printf_string(const char *fmt, va_list ap);
@@ -733,7 +772,7 @@ extern void _nc_trace_tries(struct tries *tree);
extern void _nc_update_screensize(void);
#endif
-#ifdef USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT
extern int _nc_utf8_outch(int);
#endif
@@ -752,10 +791,6 @@ extern int *_nc_oldnums;
* On systems with a broken linker, define 'SP' as a function to force the
* linker to pull in the data-only module with 'SP'.
*/
-#ifndef BROKEN_LINKER
-#define BROKEN_LINKER 0
-#endif
-
#if BROKEN_LINKER
#define SP _nc_screen()
extern SCREEN *_nc_screen(void);
diff --git a/lib/libcurses/ncurses_cfg.h b/lib/libcurses/ncurses_cfg.h
index 9bb5eecfcd6..4895cb22993 100644
--- a/lib/libcurses/ncurses_cfg.h
+++ b/lib/libcurses/ncurses_cfg.h
@@ -1,5 +1,3 @@
-/* $OpenBSD: ncurses_cfg.h,v 1.19 2000/06/19 03:53:36 millert Exp $ */
-
/* include/ncurses_cfg.h. Generated automatically by configure. */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -33,13 +31,17 @@
* Author: Thomas E. Dickey <dickey@clark.net> 1997 *
****************************************************************************/
/*
- * $From: ncurses_cfg.hin,v 1.2 1998/02/11 12:13:46 tom Exp $
+ * $From: ncurses_cfg.hin,v 1.3 2000/09/02 17:13:32 tom Exp $
*
* This is a template-file used to generate the "ncurses_cfg.h" file.
*
- * Rather than list every definition, the configuration script substitutes
- * the definitions that it finds using 'sed'. You need a patch (971222)
- * to autoconf 2.12 to do this.
+ * Rather than list every definition, the configuration script substitutes the
+ * definitions that it finds using 'sed'. You need a patch (original date
+ * 971222) to autoconf 2.12 or 2.13 to do this.
+ *
+ * See:
+ * http://dickey.his.com/autoconf/
+ * ftp://dickey.his.com/autoconf/
*/
#ifndef NC_CONFIG_H
#define NC_CONFIG_H
@@ -55,15 +57,19 @@
#define GCC_UNUSED __attribute__((unused))
#define HAVE_BIG_CORE 1
#define HAVE_BSD_CGETENT 1
+#define HAVE_CURSES_VERSION 1
#define HAVE_DIRENT_H 1
#define HAVE_ERRNO 1
#define HAVE_FCNTL_H 1
#define HAVE_FORM_H 1
#define HAVE_GETCWD 1
+#define HAVE_GETEGID 1
+#define HAVE_GETEUID 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_GETTTYNAM 1
#define HAVE_HAS_KEY 1
#define HAVE_ISASCII 1
+#define HAVE_ISSETUGID 1
/* #define HAVE_LIBFORM 1 */
/* #define HAVE_LIBMENU 1 */
/* #define HAVE_LIBPANEL 1 */
@@ -112,20 +118,24 @@
#define HAVE_VSSCANF 1
#define HAVE_WORKING_POLL 1
#define HAVE_WRESIZE 1
+#define MIXEDCASE_FILENAMES 1
#define NCURSES_EXT_FUNCS 1
#define NCURSES_NO_PADDING 1
#define NDEBUG 1
-/* #define PURE_TERMINFO 1 */
#define RETSIGTYPE void
#define STDC_HEADERS 1
-#define SYSTEM_NAME "openbsd2.7"
+#define SYSTEM_NAME "openbsd2.8"
+#define TERMINFO "/usr/share/terminfo"
#define TERMINFO_DIRS "/usr/share/terminfo"
#define TYPEOF_CHTYPE long
+#define USE_ASSUMED_COLOR 1
#define USE_DATABASE 1
#define USE_GETCAP 1
#define USE_HASHMAP 1
/* #define USE_SIGWINCH 1 */
+#include <ncurses_def.h>
+
/* The C compiler may not treat these properly but C++ has to */
#ifdef __cplusplus
#undef const
diff --git a/lib/libcurses/ncurses_def.h b/lib/libcurses/ncurses_def.h
new file mode 100644
index 00000000000..0be36557211
--- /dev/null
+++ b/lib/libcurses/ncurses_def.h
@@ -0,0 +1,480 @@
+/*
+ * This file is generated by ./MKncurses_def.sh
+ */
+
+#ifndef NC_DEFINE_H
+#define NC_DEFINE_H 1
+
+#ifndef BROKEN_LINKER
+#define BROKEN_LINKER 0
+#endif
+
+#ifndef BSD_TPUTS
+#define BSD_TPUTS 0
+#endif
+
+#ifndef CC_HAS_INLINE_FUNCS
+#define CC_HAS_INLINE_FUNCS 0
+#endif
+
+#ifndef CC_HAS_PROTOS
+#define CC_HAS_PROTOS 0
+#endif
+
+#ifndef CPP_HAS_PARAM_INIT
+#define CPP_HAS_PARAM_INIT 0
+#endif
+
+#ifndef DECL_ERRNO
+#define DECL_ERRNO 0
+#endif
+
+#ifndef ETIP_NEEDS_MATH_H
+#define ETIP_NEEDS_MATH_H 0
+#endif
+
+#ifndef GCC_NORETURN
+#define GCC_NORETURN /* nothing */
+#endif
+
+#ifndef GCC_UNUSED
+#define GCC_UNUSED /* nothing */
+#endif
+
+#ifndef HAVE_BIG_CORE
+#define HAVE_BIG_CORE 0
+#endif
+
+#ifndef HAVE_BSD_CGETENT
+#define HAVE_BSD_CGETENT 0
+#endif
+
+#ifndef HAVE_BUILTIN_H
+#define HAVE_BUILTIN_H 0
+#endif
+
+#ifndef HAVE_DIRENT_H
+#define HAVE_DIRENT_H 0
+#endif
+
+#ifndef HAVE_ERRNO
+#define HAVE_ERRNO 0
+#endif
+
+#ifndef HAVE_FCNTL_H
+#define HAVE_FCNTL_H 0
+#endif
+
+#ifndef HAVE_FORM_H
+#define HAVE_FORM_H 0
+#endif
+
+#ifndef HAVE_GETCWD
+#define HAVE_GETCWD 0
+#endif
+
+#ifndef HAVE_GETEGID
+#define HAVE_GETEGID 0
+#endif
+
+#ifndef HAVE_GETEUID
+#define HAVE_GETEUID 0
+#endif
+
+#ifndef HAVE_GETOPT_H
+#define HAVE_GETOPT_H 0
+#endif
+
+#ifndef HAVE_GETTIMEOFDAY
+#define HAVE_GETTIMEOFDAY 0
+#endif
+
+#ifndef HAVE_GETTTYNAM
+#define HAVE_GETTTYNAM 0
+#endif
+
+#ifndef HAVE_GPP_BUILTIN_H
+#define HAVE_GPP_BUILTIN_H 0
+#endif
+
+#ifndef HAVE_GXX_BUILTIN_H
+#define HAVE_GXX_BUILTIN_H 0
+#endif
+
+#ifndef HAVE_HAS_KEY
+#define HAVE_HAS_KEY 0
+#endif
+
+#ifndef HAVE_ISASCII
+#define HAVE_ISASCII 0
+#endif
+
+#ifndef HAVE_ISSETUGID
+#define HAVE_ISSETUGID 0
+#endif
+
+#ifndef HAVE_LIBDBMALLOC
+#define HAVE_LIBDBMALLOC 0
+#endif
+
+#ifndef HAVE_LIBDMALLOC
+#define HAVE_LIBDMALLOC 0
+#endif
+
+#ifndef HAVE_LIBFORM
+#define HAVE_LIBFORM 0
+#endif
+
+#ifndef HAVE_LIBGPM
+#define HAVE_LIBGPM 0
+#endif
+
+#ifndef HAVE_LIBMENU
+#define HAVE_LIBMENU 0
+#endif
+
+#ifndef HAVE_LIBPANEL
+#define HAVE_LIBPANEL 0
+#endif
+
+#ifndef HAVE_LIMITS_H
+#define HAVE_LIMITS_H 0
+#endif
+
+#ifndef HAVE_LINK
+#define HAVE_LINK 0
+#endif
+
+#ifndef HAVE_LOCALE_H
+#define HAVE_LOCALE_H 0
+#endif
+
+#ifndef HAVE_LONG_FILE_NAMES
+#define HAVE_LONG_FILE_NAMES 0
+#endif
+
+#ifndef HAVE_MEMCCPY
+#define HAVE_MEMCCPY 0
+#endif
+
+#ifndef HAVE_MENU_H
+#define HAVE_MENU_H 0
+#endif
+
+#ifndef HAVE_MKSTEMP
+#define HAVE_MKSTEMP 0
+#endif
+
+#ifndef HAVE_NANOSLEEP
+#define HAVE_NANOSLEEP 0
+#endif
+
+#ifndef HAVE_NC_ALLOC_H
+#define HAVE_NC_ALLOC_H 0
+#endif
+
+#ifndef HAVE_PANEL_H
+#define HAVE_PANEL_H 0
+#endif
+
+#ifndef HAVE_POLL
+#define HAVE_POLL 0
+#endif
+
+#ifndef HAVE_POLL_H
+#define HAVE_POLL_H 0
+#endif
+
+#ifndef HAVE_REGEXPR_H_FUNCS
+#define HAVE_REGEXPR_H_FUNCS 0
+#endif
+
+#ifndef HAVE_REGEXP_H_FUNCS
+#define HAVE_REGEXP_H_FUNCS 0
+#endif
+
+#ifndef HAVE_REGEX_H_FUNCS
+#define HAVE_REGEX_H_FUNCS 0
+#endif
+
+#ifndef HAVE_REMOVE
+#define HAVE_REMOVE 0
+#endif
+
+#ifndef HAVE_RESIZETERM
+#define HAVE_RESIZETERM 0
+#endif
+
+#ifndef HAVE_SELECT
+#define HAVE_SELECT 0
+#endif
+
+#ifndef HAVE_SETBUF
+#define HAVE_SETBUF 0
+#endif
+
+#ifndef HAVE_SETBUFFER
+#define HAVE_SETBUFFER 0
+#endif
+
+#ifndef HAVE_SETVBUF
+#define HAVE_SETVBUF 0
+#endif
+
+#ifndef HAVE_SIGACTION
+#define HAVE_SIGACTION 0
+#endif
+
+#ifndef HAVE_SIGVEC
+#define HAVE_SIGVEC 0
+#endif
+
+#ifndef HAVE_SIZECHANGE
+#define HAVE_SIZECHANGE 0
+#endif
+
+#ifndef HAVE_STRDUP
+#define HAVE_STRDUP 0
+#endif
+
+#ifndef HAVE_STRSTR
+#define HAVE_STRSTR 0
+#endif
+
+#ifndef HAVE_SYMLINK
+#define HAVE_SYMLINK 0
+#endif
+
+#ifndef HAVE_SYS_BSDTYPES_H
+#define HAVE_SYS_BSDTYPES_H 0
+#endif
+
+#ifndef HAVE_SYS_IOCTL_H
+#define HAVE_SYS_IOCTL_H 0
+#endif
+
+#ifndef HAVE_SYS_PARAM_H
+#define HAVE_SYS_PARAM_H 0
+#endif
+
+#ifndef HAVE_SYS_POLL_H
+#define HAVE_SYS_POLL_H 0
+#endif
+
+#ifndef HAVE_SYS_SELECT_H
+#define HAVE_SYS_SELECT_H 0
+#endif
+
+#ifndef HAVE_SYS_TERMIO_H
+#define HAVE_SYS_TERMIO_H 0
+#endif
+
+#ifndef HAVE_SYS_TIMES_H
+#define HAVE_SYS_TIMES_H 0
+#endif
+
+#ifndef HAVE_SYS_TIME_H
+#define HAVE_SYS_TIME_H 0
+#endif
+
+#ifndef HAVE_SYS_TIME_SELECT
+#define HAVE_SYS_TIME_SELECT 0
+#endif
+
+#ifndef HAVE_TCGETATTR
+#define HAVE_TCGETATTR 0
+#endif
+
+#ifndef HAVE_TCGETPGRP
+#define HAVE_TCGETPGRP 0
+#endif
+
+#ifndef HAVE_TELL
+#define HAVE_TELL 0
+#endif
+
+#ifndef HAVE_TERMIOS_H
+#define HAVE_TERMIOS_H 0
+#endif
+
+#ifndef HAVE_TERMIO_H
+#define HAVE_TERMIO_H 0
+#endif
+
+#ifndef HAVE_TIMES
+#define HAVE_TIMES 0
+#endif
+
+#ifndef HAVE_TTYENT_H
+#define HAVE_TTYENT_H 0
+#endif
+
+#ifndef HAVE_TYPEINFO
+#define HAVE_TYPEINFO 0
+#endif
+
+#ifndef HAVE_TYPE_SIGACTION
+#define HAVE_TYPE_SIGACTION 0
+#endif
+
+#ifndef HAVE_UNISTD_H
+#define HAVE_UNISTD_H 0
+#endif
+
+#ifndef HAVE_UNLINK
+#define HAVE_UNLINK 0
+#endif
+
+#ifndef HAVE_USE_DEFAULT_COLORS
+#define HAVE_USE_DEFAULT_COLORS 0
+#endif
+
+#ifndef HAVE_VFSCANF
+#define HAVE_VFSCANF 0
+#endif
+
+#ifndef HAVE_VSNPRINTF
+#define HAVE_VSNPRINTF 0
+#endif
+
+#ifndef HAVE_VSSCANF
+#define HAVE_VSSCANF 0
+#endif
+
+#ifndef HAVE_WORKING_POLL
+#define HAVE_WORKING_POLL 0
+#endif
+
+#ifndef HAVE_WRESIZE
+#define HAVE_WRESIZE 0
+#endif
+
+#ifndef MIXEDCASE_FILENAMES
+#define MIXEDCASE_FILENAMES 0
+#endif
+
+#ifndef NCURSES_EXPANDED
+#define NCURSES_EXPANDED 0
+#endif
+
+#ifndef NCURSES_EXT_FUNCS
+#define NCURSES_EXT_FUNCS 0
+#endif
+
+#ifndef NCURSES_NOMACROS
+#define NCURSES_NOMACROS 0
+#endif
+
+#ifndef NCURSES_NO_PADDING
+#define NCURSES_NO_PADDING 0
+#endif
+
+#ifndef NDEBUG
+#define NDEBUG 0
+#endif
+
+#ifndef NEED_PTEM_H
+#define NEED_PTEM_H 0
+#endif
+
+#ifndef NO_LEAKS
+#define NO_LEAKS 0
+#endif
+
+#ifndef PURE_TERMINFO
+#define PURE_TERMINFO 0
+#endif
+
+#ifndef RETSIGTYPE
+#define RETSIGTYPE 0
+#endif
+
+#ifndef STDC_HEADERS
+#define STDC_HEADERS 0
+#endif
+
+#ifndef SVR4_ACTION
+#define SVR4_ACTION 0
+#endif
+
+#ifndef SVR4_TERMIO
+#define SVR4_TERMIO 0
+#endif
+
+#ifndef SYSTEM_NAME
+#define SYSTEM_NAME "unknown"
+#endif
+
+#ifndef TERMINFO
+#define TERMINFO "none"
+#endif
+
+#ifndef TYPEOF_CHTYPE
+#define TYPEOF_CHTYPE 0
+#endif
+
+#ifndef USE_COLORFGBG
+#define USE_COLORFGBG 0
+#endif
+
+#ifndef USE_DATABASE
+#define USE_DATABASE 0
+#endif
+
+#ifndef USE_GETCAP
+#define USE_GETCAP 0
+#endif
+
+#ifndef USE_GETCAP_CACHE
+#define USE_GETCAP_CACHE 0
+#endif
+
+#ifndef USE_HARD_TABS
+#define USE_HARD_TABS 0
+#endif
+
+#ifndef USE_HASHMAP
+#define USE_HASHMAP 0
+#endif
+
+#ifndef USE_LINKS
+#define USE_LINKS 0
+#endif
+
+#ifndef USE_MY_MEMMOVE
+#define USE_MY_MEMMOVE 0
+#endif
+
+#ifndef USE_OK_BCOPY
+#define USE_OK_BCOPY 0
+#endif
+
+#ifndef USE_RCS_IDS
+#define USE_RCS_IDS 0
+#endif
+
+#ifndef USE_SAFE_SPRINTF
+#define USE_SAFE_SPRINTF 0
+#endif
+
+#ifndef USE_SCROLL_HINTS
+#define USE_SCROLL_HINTS 0
+#endif
+
+#ifndef USE_SIGWINCH
+#define USE_SIGWINCH 0
+#endif
+
+#ifndef USE_SYMLINKS
+#define USE_SYMLINKS 0
+#endif
+
+#ifndef USE_WIDEC_SUPPORT
+#define USE_WIDEC_SUPPORT 0
+#endif
+
+#ifndef USE_XMC_SUPPORT
+#define USE_XMC_SUPPORT 0
+#endif
+
+#endif /* NC_DEFINE_H */
diff --git a/lib/libcurses/term.5tbl b/lib/libcurses/term.5tbl
index 647d7f17698..5cb1df43e29 100644
--- a/lib/libcurses/term.5tbl
+++ b/lib/libcurses/term.5tbl
@@ -26,8 +26,8 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: term.5,v 1.9 1998/03/11 21:12:53 juergen Exp $
-.\" $OpenBSD: term.5tbl,v 1.1 1999/01/18 19:09:15 millert Exp $
+.\" $From: term.5,v 1.10 2000/08/13 01:56:45 tom Exp $
+.\" $OpenBSD: term.5tbl,v 1.2 2000/10/08 22:46:55 millert Exp $
.TH TERM 5
.ds n 5
.ds d /usr/share/terminfo
diff --git a/lib/libcurses/term.7 b/lib/libcurses/term.7
index 749fd72173d..b5f2bd50bce 100644
--- a/lib/libcurses/term.7
+++ b/lib/libcurses/term.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: term.7,v 1.3 2000/04/17 02:32:46 aaron Exp $
+.\" $OpenBSD: term.7,v 1.4 2000/10/08 22:46:55 millert Exp $
.\"
.\"***************************************************************************
.\" Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -28,8 +28,8 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: term.7,v 1.11 1999/01/24 02:35:14 Todd.Miller Exp $
-.\" $OpenBSD: term.7,v 1.3 2000/04/17 02:32:46 aaron Exp $
+.\" $From: term.7,v 1.12 2000/08/13 01:56:42 tom Exp $
+.\" $OpenBSD: term.7,v 1.4 2000/10/08 22:46:55 millert Exp $
.TH TERM 7
.ds n 5
.ds d /usr/share/terminfo
diff --git a/lib/libcurses/termcap.h b/lib/libcurses/termcap.h
index bc6b3b9e9b6..5109159cb97 100644
--- a/lib/libcurses/termcap.h
+++ b/lib/libcurses/termcap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: termcap.h,v 1.5 2000/07/10 03:06:11 millert Exp $ */
+/* $OpenBSD: termcap.h,v 1.6 2000/10/08 22:46:56 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -33,7 +33,7 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-/* $From: termcap.h.in,v 1.10 1999/01/09 22:38:04 Uchiyama.Yasushi Exp $ */
+/* $From: termcap.h.in,v 1.12 2000/10/08 01:06:37 tom Exp $ */
#ifndef _NCU_TERMCAP_H
#define _NCU_TERMCAP_H 1
@@ -47,7 +47,6 @@ extern "C"
#endif /* __cplusplus */
#include <sys/types.h>
-#include <termios.h>
#undef NCURSES_CONST
#define NCURSES_CONST
@@ -55,7 +54,7 @@ extern "C"
extern char PC;
extern char *UP;
extern char *BC;
-extern speed_t ospeed;
+extern short ospeed;
#if !defined(_NCU_TERM_H)
extern char *tgetstr(NCURSES_CONST char *, char **);
diff --git a/lib/libcurses/terminfo.5tbl b/lib/libcurses/terminfo.5tbl
index 0358d907938..5eedf5564c5 100644
--- a/lib/libcurses/terminfo.5tbl
+++ b/lib/libcurses/terminfo.5tbl
@@ -32,8 +32,8 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: terminfo.head,v 1.8 1998/03/11 21:12:53 juergen Exp $
-.\" $OpenBSD: terminfo.5tbl,v 1.9 2000/08/03 17:11:48 naddy Exp $
+.\" $From: terminfo.head,v 1.9 2000/08/13 01:56:40 tom Exp $
+.\" $OpenBSD: terminfo.5tbl,v 1.10 2000/10/08 22:46:56 millert Exp $
.TH TERMINFO 5 "" "" "File Formats"
.ds n 5
.ds d /usr/share/terminfo
diff --git a/lib/libcurses/tic.h b/lib/libcurses/tic.h
index 27ca09bfce4..d36fcbf584b 100644
--- a/lib/libcurses/tic.h
+++ b/lib/libcurses/tic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tic.h,v 1.9 2000/03/26 16:45:03 millert Exp $ */
+/* $OpenBSD: tic.h,v 1.10 2000/10/08 22:46:56 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998-2000 Free Software Foundation, Inc. *
@@ -34,9 +34,9 @@
****************************************************************************/
/*
+ * $From: tic.h,v 1.35 2000/09/09 19:47:16 tom Exp $
* tic.h - Global variables and structures for the terminfo
* compiler.
- *
*/
#ifndef __TIC_H
@@ -239,6 +239,9 @@ extern const struct name_table_entry * const *_nc_get_hash_table(bool);
#define TERMINFO "/usr/share/terminfo"
#endif
+/* access.c */
+extern char *_nc_basename(char *);
+
/* comp_hash.c: name lookup */
struct name_table_entry const *_nc_find_entry(const char *,
const struct name_table_entry *const *);
diff --git a/lib/libcurses/tinfo/access.c b/lib/libcurses/tinfo/access.c
index 20ae2ed4773..5c0e4c64920 100644
--- a/lib/libcurses/tinfo/access.c
+++ b/lib/libcurses/tinfo/access.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -27,29 +27,68 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 *
****************************************************************************/
-
#include <curses.priv.h>
+#include <tic.h>
-MODULE_ID("$From: access.c,v 1.1 1998/07/25 20:17:09 tom Exp $")
+MODULE_ID("$From: access.c,v 1.4 2000/10/08 01:25:06 tom Exp $")
-int _nc_access(const char *path, int mode)
+char *
+_nc_basename(char *path)
{
- if (access(path, mode) < 0) {
- if ((mode & W_OK) != 0
- && errno == ENOENT) {
- char head[PATH_MAX];
- char *leaf = strrchr(strcpy(head, path), '/');
- if (leaf == 0)
- leaf = head;
- *leaf = '\0';
- if (head == leaf)
- (void)strcpy(head, ".");
- return access(head, R_OK|W_OK|X_OK);
- }
- return -1;
+ char *result = strrchr(path, '/');
+#ifdef __EMX__
+ if (result == 0)
+ result = strrchr(path, '\\');
+#endif
+ if (result == 0)
+ result = path;
+ else
+ result++;
+ return result;
+}
+
+int
+_nc_access(const char *path, int mode)
+{
+ if (access(path, mode) < 0) {
+ if ((mode & W_OK) != 0
+ && errno == ENOENT
+ && strlen(path) < PATH_MAX) {
+ char head[PATH_MAX];
+ char *leaf = _nc_basename(strcpy(head, path));
+
+ if (leaf == 0)
+ leaf = head;
+ *leaf = '\0';
+ if (head == leaf)
+ (void) strcpy(head, ".");
+
+ return access(head, R_OK | W_OK | X_OK);
}
- return 0;
+ return -1;
+ }
+ return 0;
+}
+
+#ifndef USE_ROOT_ENVIRON
+/*
+ * Returns true if we allow application to use environment variables that are
+ * used for searching lists of directories, etc.
+ */
+int
+_nc_env_access(void)
+{
+#if HAVE_ISSETUGID
+ if (issetugid())
+ return FALSE;
+#elif HAVE_GETEUID && HAVE_GETEGID
+ if (getuid() != geteuid()
+ || getgid() != getegid())
+ return FALSE;
+#endif
+ return getuid() != 0; /* ...finally, disallow root */
}
+#endif
diff --git a/lib/libcurses/tinfo/alloc_ttype.c b/lib/libcurses/tinfo/alloc_ttype.c
index c2ec35fc070..c03a3a5919c 100644
--- a/lib/libcurses/tinfo/alloc_ttype.c
+++ b/lib/libcurses/tinfo/alloc_ttype.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alloc_ttype.c,v 1.3 2000/03/26 16:45:03 millert Exp $ */
+/* $OpenBSD: alloc_ttype.c,v 1.4 2000/10/08 22:47:00 millert Exp $ */
/****************************************************************************
* Copyright (c) 1999,2000 Free Software Foundation, Inc. *
@@ -45,7 +45,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: alloc_ttype.c,v 1.8 2000/03/25 17:03:11 tom Exp $")
+MODULE_ID("$From: alloc_ttype.c,v 1.10 2000/08/12 21:56:24 tom Exp $")
#if NCURSES_XNAMES
/*
@@ -56,7 +56,7 @@ static int
merge_names(char **dst, char **a, int na, char **b, int nb)
{
int n = 0;
- while (na && nb) {
+ while (na > 0 && nb > 0) {
int cmp = strcmp(*a, *b);
if (cmp < 0) {
dst[n++] = *a++;
@@ -95,7 +95,7 @@ find_name(char **table, int length, char *name)
static void
realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
- ext_Numbers, int ext_Strings)
+ ext_Numbers, int ext_Strings)
{
int n, m, base;
int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
@@ -104,8 +104,8 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
to->num_Booleans += (ext_Booleans - to->ext_Booleans);
to->Booleans = typeRealloc(char, to->num_Booleans, to->Booleans);
for (n = to->ext_Booleans - 1,
- m = ext_Booleans - 1,
- base = to->num_Booleans - (m + 1); m >= 0; m--) {
+ m = ext_Booleans - 1,
+ base = to->num_Booleans - (m + 1); m >= 0; m--) {
if (find_name(to->ext_Names, limit, ext_Names[m])) {
to->Booleans[base + m] = to->Booleans[base + n--];
} else {
@@ -118,8 +118,8 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
to->num_Numbers += (ext_Numbers - to->ext_Numbers);
to->Numbers = typeRealloc(short, to->num_Numbers, to->Numbers);
for (n = to->ext_Numbers - 1,
- m = ext_Numbers - 1,
- base = to->num_Numbers - (m + 1); m >= 0; m--) {
+ m = ext_Numbers - 1,
+ base = to->num_Numbers - (m + 1); m >= 0; m--) {
if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans])) {
to->Numbers[base + m] = to->Numbers[base + n--];
} else {
@@ -132,8 +132,8 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
to->num_Strings += (ext_Strings - to->ext_Strings);
to->Strings = typeRealloc(char *, to->num_Strings, to->Strings);
for (n = to->ext_Strings - 1,
- m = ext_Strings - 1,
- base = to->num_Strings - (m + 1); m >= 0; m--) {
+ m = ext_Strings - 1,
+ base = to->num_Strings - (m + 1); m >= 0; m--) {
if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans + ext_Numbers])) {
to->Strings[base + m] = to->Strings[base + n--];
} else {
@@ -237,7 +237,7 @@ _nc_ext_data_index(TERMTYPE * tp, int n, int token_type)
* Adjust tables to remove (not free) an extended name and its corresponding
* data.
*/
-static void
+static bool
_nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
{
int j;
@@ -272,7 +272,9 @@ _nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
tp->num_Strings -= 1;
break;
}
+ return TRUE;
}
+ return FALSE;
}
/*
@@ -347,14 +349,22 @@ adjust_cancels(TERMTYPE * to, TERMTYPE * from)
if (to->Strings[j + j_str] == CANCELLED_STRING) {
if ((k = _nc_find_ext_name(from, to->ext_Names[j], BOOLEAN)) >= 0) {
- _nc_del_ext_name(to, name, STRING);
- k = _nc_ins_ext_name(to, name, BOOLEAN);
- to->Booleans[k] = FALSE;
+ if (_nc_del_ext_name(to, name, STRING)
+ || _nc_del_ext_name(to, name, NUMBER)) {
+ k = _nc_ins_ext_name(to, name, BOOLEAN);
+ to->Booleans[k] = FALSE;
+ } else {
+ j++;
+ }
} else if ((k = _nc_find_ext_name(from, to->ext_Names[j],
- NUMBER)) >= 0) {
- _nc_del_ext_name(to, name, STRING);
- k = _nc_ins_ext_name(to, name, NUMBER);
- to->Numbers[k] = CANCELLED_NUMERIC;
+ NUMBER)) >= 0) {
+ if (_nc_del_ext_name(to, name, STRING)
+ || _nc_del_ext_name(to, name, BOOLEAN)) {
+ k = _nc_ins_ext_name(to, name, NUMBER);
+ to->Numbers[k] = CANCELLED_NUMERIC;
+ } else {
+ j++;
+ }
}
} else {
j++;
@@ -373,7 +383,7 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
int ext_Booleans, ext_Numbers, ext_Strings;
DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names,
- nb, from->term_names));
+ nb, from->term_names));
if (na != 0 || nb != 0) {
if ((na == nb) /* check if the arrays are equivalent */
@@ -404,26 +414,26 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
adjust_cancels(from, to);
ext_Booleans = merge_names(ext_Names,
- to->ext_Names,
- to->ext_Booleans,
- from->ext_Names,
- from->ext_Booleans);
+ to->ext_Names,
+ to->ext_Booleans,
+ from->ext_Names,
+ from->ext_Booleans);
ext_Numbers = merge_names(ext_Names + ext_Booleans,
- to->ext_Names
- + to->ext_Booleans,
- to->ext_Numbers,
- from->ext_Names
- + from->ext_Booleans,
- from->ext_Numbers);
+ to->ext_Names
+ + to->ext_Booleans,
+ to->ext_Numbers,
+ from->ext_Names
+ + from->ext_Booleans,
+ from->ext_Numbers);
ext_Strings = merge_names(ext_Names + ext_Numbers + ext_Booleans,
- to->ext_Names
- + to->ext_Booleans
- + to->ext_Numbers,
- to->ext_Strings,
- from->ext_Names
- + from->ext_Booleans
- + from->ext_Numbers,
- from->ext_Strings);
+ to->ext_Names
+ + to->ext_Booleans
+ + to->ext_Numbers,
+ to->ext_Strings,
+ from->ext_Names
+ + from->ext_Booleans
+ + from->ext_Numbers,
+ from->ext_Strings);
/*
* Now we must reallocate the Booleans, etc., to allow the data to be
* overlaid.
@@ -433,7 +443,7 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
FreeIfNeeded(to->ext_Names);
to->ext_Names = ext_Names;
DEBUG(2, ("realigned %d extended names for '%s' (to)",
- NUM_EXT_NAMES(to), to->term_names));
+ NUM_EXT_NAMES(to), to->term_names));
}
if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) {
nb = (ext_Booleans + ext_Numbers + ext_Strings);
@@ -441,7 +451,7 @@ _nc_align_termtype(TERMTYPE * to, TERMTYPE * from)
from->ext_Names = typeRealloc(char *, nb, from->ext_Names);
memcpy(from->ext_Names, ext_Names, sizeof(char *) * nb);
DEBUG(2, ("realigned %d extended names for '%s' (from)",
- NUM_EXT_NAMES(from), from->term_names));
+ NUM_EXT_NAMES(from), from->term_names));
}
}
}
diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c
index 731d0b5724d..d9d1f2eb151 100644
--- a/lib/libcurses/tinfo/comp_parse.c
+++ b/lib/libcurses/tinfo/comp_parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: comp_parse.c,v 1.7 2000/06/19 03:53:48 millert Exp $ */
+/* $OpenBSD: comp_parse.c,v 1.8 2000/10/08 22:47:00 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -54,7 +54,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: comp_parse.c,v 1.40 2000/04/15 16:57:08 tom Exp $")
+MODULE_ID("$From: comp_parse.c,v 1.41 2000/10/03 09:53:49 tom Exp $")
static void sanity_check(TERMTYPE *);
void (*_nc_check_termtype) (TERMTYPE *) = sanity_check;
@@ -124,29 +124,30 @@ _nc_free_entries(ENTRY * headp)
}
}
+static char *
+force_bar(char *dst, char *src, size_t siz)
+{
+ if (strchr(src, '|') == 0) {
+ size_t len;
+
+ len = strlcpy(dst, src, siz);
+ if (len >= siz - 2)
+ len = siz - 2;;
+ (void) strcpy(dst + len, "|");
+ src = dst;
+ }
+ return src;
+}
+
bool
_nc_entry_match(char *n1, char *n2)
/* do any of the aliases in a pair of terminal names match? */
{
char *pstart, *qstart, *pend, *qend;
- char nc1[MAX_NAME_SIZE + 1], nc2[MAX_NAME_SIZE + 1];
- size_t n;
-
- if (strchr(n1, '|') == NULL) {
- if ((n = strlcpy(nc1, n1, sizeof(nc1))) > sizeof(nc1) - 2)
- n = sizeof(nc1) - 2;
- nc1[n++] = '|';
- nc1[n] = '\0';
- n1 = nc1;
- }
+ char nc1[MAX_NAME_SIZE + 2], nc2[MAX_NAME_SIZE + 2];
- if (strchr(n2, '|') == NULL) {
- if ((n = strlcpy(nc2, n2, sizeof(nc2))) > sizeof(nc2) - 2)
- n = sizeof(nc2) - 2;
- nc2[n++] = '|';
- nc2[n] = '\0';
- n2 = nc2;
- }
+ n1 = force_bar(nc1, n1, sizeof(nc1));
+ n2 = force_bar(nc2, n2, sizeof(nc2));
for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1)
for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1)
diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c
index 765174d8f12..2ada427fc8c 100644
--- a/lib/libcurses/tinfo/comp_scan.c
+++ b/lib/libcurses/tinfo/comp_scan.c
@@ -50,7 +50,7 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$From: comp_scan.c,v 1.45 2000/07/08 00:43:55 tom Exp $")
+MODULE_ID("$From: comp_scan.c,v 1.47 2000/09/24 01:15:17 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -80,8 +80,8 @@ static char separator; /* capability separator */
static int pushtype; /* type of pushback token */
static char pushname[MAX_NAME_SIZE + 1];
-#ifdef NCURSES_EXT_FUNCS
-bool _nc_disable_period = FALSE; /* used by tic -a option */
+#if NCURSES_EXT_FUNCS
+bool _nc_disable_period = FALSE; /* used by tic -a option */
#endif
static int last_char(void);
@@ -153,7 +153,7 @@ _nc_get_token(void)
_nc_set_type(pushname);
DEBUG(3, ("pushed-back token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
+ _nc_curr_token.tk_name, pushtype));
pushtype = NO_PUSHBACK;
pushname[0] = '\0';
@@ -180,10 +180,10 @@ _nc_get_token(void)
ch = next_char();
if (ch == '.'
-#ifdef NCURSES_EXT_FUNCS
- && !_nc_disable_period
+#if NCURSES_EXT_FUNCS
+ && !_nc_disable_period
#endif
- ) {
+ ) {
dot_flag = TRUE;
DEBUG(8, ("dot-flag set"));
@@ -198,12 +198,12 @@ _nc_get_token(void)
/* have to make some punctuation chars legal for terminfo */
if (!isalnum(ch)
-#ifdef NCURSES_EXT_FUNCS
- && !(ch == '.' && _nc_disable_period)
+#if NCURSES_EXT_FUNCS
+ && !(ch == '.' && _nc_disable_period)
#endif
- && !strchr(terminfo_punct, (char) ch)) {
+ && !strchr(terminfo_punct, (char) ch)) {
_nc_warning("Illegal character (expected alphanumeric or %s) - %s",
- terminfo_punct, unctrl(ch));
+ terminfo_punct, unctrl(ch));
_nc_panic_mode(separator);
goto start_token;
}
@@ -338,7 +338,7 @@ _nc_get_token(void)
case '@':
if ((ch = next_char()) != separator)
_nc_warning("Missing separator after `%s', have %s",
- buffer, unctrl(ch));
+ buffer, unctrl(ch));
_nc_curr_token.tk_name = buffer;
type = CANCEL;
break;
@@ -391,30 +391,30 @@ _nc_get_token(void)
switch (type) {
case BOOLEAN:
_tracef("Token: Boolean; name='%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
break;
case NUMBER:
_tracef("Token: Number; name='%s', value=%d",
- _nc_curr_token.tk_name,
- _nc_curr_token.tk_valnumber);
+ _nc_curr_token.tk_name,
+ _nc_curr_token.tk_valnumber);
break;
case STRING:
_tracef("Token: String; name='%s', value=%s",
- _nc_curr_token.tk_name,
- _nc_visbuf(_nc_curr_token.tk_valstring));
+ _nc_curr_token.tk_name,
+ _nc_visbuf(_nc_curr_token.tk_valstring));
break;
case CANCEL:
_tracef("Token: Cancel; name='%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
break;
case NAMES:
_tracef("Token: Names; value='%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
break;
case EOF:
@@ -571,7 +571,7 @@ _nc_trans_string(char *ptr, char *last)
default:
_nc_warning("Illegal character %s in \\ sequence",
- unctrl(ch));
+ unctrl(ch));
*(ptr++) = (char) ch;
} /* endswitch (ch) */
} /* endelse (ch < '0' || ch > '7') */
@@ -621,7 +621,7 @@ _nc_push_token(int tokclass)
_nc_get_type(pushname);
DEBUG(3, ("pushing token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
+ _nc_curr_token.tk_name, pushtype));
}
/*
@@ -736,7 +736,7 @@ next_char(void)
} while
(bufstart != NULL && line[0] == '#');
- if (bufstart == NULL)
+ if (bufstart == NULL || *bufstart == 0)
return (EOF);
while (iswhite(*bufptr))
@@ -749,10 +749,19 @@ next_char(void)
if ((len = strlen(bufptr)) > 1) {
if (bufptr[len - 1] == '\n'
&& bufptr[len - 2] == '\r') {
- bufptr[len - 2] = '\n';
- bufptr[len - 1] = '\0';
+ len--;
+ bufptr[len - 1] = '\n';
+ bufptr[len] = '\0';
}
}
+
+ /*
+ * If we don't have a trailing newline, it's because the line is simply
+ * too long. Give up. (FIXME: We could instead reallocate the line
+ * buffer and allow arbitrary-length lines).
+ */
+ if (len == 0 || (bufptr[len - 1] != '\n'))
+ return (EOF);
}
first_column = (bufptr == bufstart);
@@ -782,7 +791,7 @@ end_of_stream(void)
/* are we at end of input? */
{
return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
- ? TRUE : FALSE);
+ ? TRUE : FALSE);
}
/* comp_scan.c ends here */
diff --git a/lib/libcurses/tinfo/home_terminfo.c b/lib/libcurses/tinfo/home_terminfo.c
index 9ed5c5f0e32..f225d33654b 100644
--- a/lib/libcurses/tinfo/home_terminfo.c
+++ b/lib/libcurses/tinfo/home_terminfo.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: home_terminfo.c,v 1.4 2000/10/02 17:33:47 millert Exp $ */
+/* $OpenBSD: home_terminfo.c,v 1.5 2000/10/08 22:47:01 millert Exp $ */
/****************************************************************************
- * 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 *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 *
****************************************************************************/
/*
@@ -39,7 +39,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$From: home_terminfo.c,v 1.2 1999/02/27 19:58:46 tom Exp $")
+MODULE_ID("$From: home_terminfo.c,v 1.3 2000/10/04 02:31:53 tom Exp $");
#define my_length (strlen(home) + sizeof(PRIVATE_INFO))
@@ -48,17 +48,20 @@ MODULE_ID("$From: home_terminfo.c,v 1.2 1999/02/27 19:58:46 tom Exp $")
char *
_nc_home_terminfo(void)
{
- char *home;
- static char *temp = 0;
+ char *home;
+ static char *temp = 0;
- if (temp == 0 && !issetugid()) {
- if ((home = getenv("HOME")) != 0 && *home != '\0'
- && my_length <= PATH_MAX) {
- temp = typeMalloc(char, my_length);
- if (temp == 0)
- _nc_err_abort("Out of memory");
- (void) sprintf(temp, PRIVATE_INFO, home);
- }
+ if (use_terminfo_vars()) {
+ if (temp == 0) {
+ if ((home = getenv("HOME")) != 0
+ && my_length <= PATH_MAX) {
+ temp = typeMalloc(char, my_length);
+ if (temp == 0)
+ _nc_err_abort("Out of memory");
+ (void) sprintf(temp, PRIVATE_INFO, home);
+ }
}
return temp;
+ }
+ return 0;
}
diff --git a/lib/libcurses/tinfo/lib_baudrate.c b/lib/libcurses/tinfo/lib_baudrate.c
index d0c946d20fa..31a78c107f6 100644
--- a/lib/libcurses/tinfo/lib_baudrate.c
+++ b/lib/libcurses/tinfo/lib_baudrate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_baudrate.c,v 1.2 1999/01/31 20:17:10 millert Exp $ */
+/* $OpenBSD: lib_baudrate.c,v 1.3 2000/10/08 22:47:01 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -33,17 +33,16 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* lib_baudrate.c
*
*/
#include <curses.priv.h>
-#include <term.h> /* cur_term, pad_char */
-#include <termcap.h> /* ospeed */
+#include <term.h> /* cur_term, pad_char */
+#include <termcap.h> /* ospeed */
-MODULE_ID("$From: lib_baudrate.c,v 1.15 1999/01/31 03:05:25 tom Exp $")
+MODULE_ID("$From: lib_baudrate.c,v 1.17 2000/10/08 00:59:08 tom Exp $")
/*
* int
@@ -54,117 +53,118 @@ MODULE_ID("$From: lib_baudrate.c,v 1.15 1999/01/31 03:05:25 tom Exp $")
*/
struct speed {
- speed_t s;
- int sp;
+ int s; /* value for 'ospeed' is an index */
+ int sp; /* the actual speed */
};
-static struct speed const speeds[] = {
- {B0, 0},
- {B50, 50},
- {B75, 75},
- {B110, 110},
- {B134, 134},
- {B150, 150},
- {B200, 200},
- {B300, 300},
- {B600, 600},
- {B1200, 1200},
- {B1800, 1800},
- {B2400, 2400},
- {B4800, 4800},
- {B9600, 9600},
+static struct speed const speeds[] =
+{
+ {B0, 0},
+ {B50, 50},
+ {B75, 75},
+ {B110, 110},
+ {B134, 134},
+ {B150, 150},
+ {B200, 200},
+ {B300, 300},
+ {B600, 600},
+ {B1200, 1200},
+ {B1800, 1800},
+ {B2400, 2400},
+ {B4800, 4800},
+ {B9600, 9600},
#ifdef B19200
- {B19200, 19200},
+ {B19200, 19200},
#else
#ifdef EXTA
- {EXTA, 19200},
+ {EXTA, 19200},
#endif
#endif
#ifdef B38400
- {B38400, 38400},
+ {B38400, 38400},
#else
#ifdef EXTB
- {EXTB, 38400},
+ {EXTB, 38400},
#endif
#endif
#ifdef B57600
- {B57600, 57600},
+ {B57600, 57600},
#endif
#ifdef B115200
- {B115200, 115200},
+ {B115200, 115200},
#endif
#ifdef B230400
- {B230400, 230400},
+ {B230400, 230400},
#endif
#ifdef B460800
- {B460800, 460800},
+ {B460800, 460800},
#endif
};
-int _nc_baudrate(int OSpeed)
+int
+_nc_baudrate(int OSpeed)
{
- static int last_OSpeed;
- static int last_baudrate;
-
- int result;
- unsigned i;
-
- if (OSpeed == last_OSpeed) {
- result = last_baudrate;
- } else {
- result = ERR;
- if (OSpeed >= 0) {
- for (i = 0; i < SIZEOF(speeds); i++) {
- if (speeds[i].s == (speed_t)OSpeed) {
- result = speeds[i].sp;
- break;
- }
- }
+ static int last_OSpeed;
+ static int last_baudrate;
+
+ int result;
+ unsigned i;
+
+ if (OSpeed == last_OSpeed) {
+ result = last_baudrate;
+ } else {
+ result = ERR;
+ if (OSpeed >= 0) {
+ for (i = 0; i < SIZEOF(speeds); i++) {
+ if (speeds[i].s == OSpeed) {
+ result = speeds[i].sp;
+ break;
}
- last_baudrate = result;
+ }
}
- return (result);
+ last_baudrate = result;
+ }
+ return (result);
}
-
-int _nc_ospeed(int BaudRate)
+int
+_nc_ospeed(int BaudRate)
{
- speed_t result = 1;
- unsigned i;
-
- if (BaudRate >= 0) {
- for (i = 0; i < SIZEOF(speeds); i++) {
- if (speeds[i].sp == BaudRate) {
- result = speeds[i].s;
- break;
- }
- }
+ int result = 1;
+ unsigned i;
+
+ if (BaudRate >= 0) {
+ for (i = 0; i < SIZEOF(speeds); i++) {
+ if (speeds[i].sp == BaudRate) {
+ result = speeds[i].s;
+ break;
+ }
}
- return (result);
+ }
+ return (result);
}
int
baudrate(void)
{
-int result;
+ int result;
- T((T_CALLED("baudrate()")));
+ T((T_CALLED("baudrate()")));
- /*
- * In debugging, allow the environment symbol to override when we're
- * redirecting to a file, so we can construct repeatable test-cases
- * that take into account costs that depend on baudrate.
- */
+ /*
+ * In debugging, allow the environment symbol to override when we're
+ * redirecting to a file, so we can construct repeatable test-cases
+ * that take into account costs that depend on baudrate.
+ */
#ifdef TRACE
- if (SP && !isatty(fileno(SP->_ofp))
- && getenv("BAUDRATE") != 0) {
- int ret;
- if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
- ret = 9600;
- ospeed = _nc_ospeed(ret);
- returnCode(ret);
- }
- else
+ if (SP && !isatty(fileno(SP->_ofp))
+ && getenv("BAUDRATE") != 0) {
+ int ret;
+ if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
+ ret = 9600;
+ ospeed = _nc_ospeed(ret);
+ returnCode(ret);
+ } else
#endif
#ifdef TERMIOS
@@ -172,9 +172,9 @@ int result;
#else
ospeed = cur_term->Nttyb.sg_ospeed;
#endif
- result = _nc_baudrate(ospeed);
- if (cur_term != 0)
- cur_term->_baudrate = result;
+ result = _nc_baudrate(ospeed);
+ if (cur_term != 0)
+ cur_term->_baudrate = result;
- returnCode(result);
+ returnCode(result);
}
diff --git a/lib/libcurses/tinfo/lib_options.c b/lib/libcurses/tinfo/lib_options.c
index 7a16334c5a2..ad42bf8b41f 100644
--- a/lib/libcurses/tinfo/lib_options.c
+++ b/lib/libcurses/tinfo/lib_options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_options.c,v 1.7 2000/03/13 23:53:40 millert Exp $ */
+/* $OpenBSD: lib_options.c,v 1.8 2000/10/08 22:47:01 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -44,7 +44,7 @@
#include <term.h>
-MODULE_ID("$From: lib_options.c,v 1.39 2000/03/12 00:19:11 tom Exp $")
+MODULE_ID("$From: lib_options.c,v 1.40 2000/09/02 18:02:05 tom Exp $")
int
idlok(WINDOW *win, bool flag)
@@ -208,7 +208,7 @@ typeahead(int fd)
**
*/
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
static int
has_key_internal(int keycode, struct tries *tp)
{
diff --git a/lib/libcurses/tinfo/lib_raw.c b/lib/libcurses/tinfo/lib_raw.c
index 9af0548698d..be87b5a3049 100644
--- a/lib/libcurses/tinfo/lib_raw.c
+++ b/lib/libcurses/tinfo/lib_raw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_raw.c,v 1.5 2000/03/10 01:35:04 millert Exp $ */
+/* $OpenBSD: lib_raw.c,v 1.6 2000/10/08 22:47:01 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -50,9 +50,9 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$From: lib_raw.c,v 1.7 2000/02/13 01:01:26 tom Exp $")
+MODULE_ID("$From: lib_raw.c,v 1.8 2000/09/02 18:08:48 tom Exp $")
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
diff --git a/lib/libcurses/tinfo/lib_setup.c b/lib/libcurses/tinfo/lib_setup.c
index 75758539989..77003ad61ab 100644
--- a/lib/libcurses/tinfo/lib_setup.c
+++ b/lib/libcurses/tinfo/lib_setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_setup.c,v 1.9 2000/03/10 01:35:04 millert Exp $ */
+/* $OpenBSD: lib_setup.c,v 1.10 2000/10/08 22:47:01 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -44,13 +44,13 @@
#include <tic.h> /* for MAX_NAME_SIZE */
#include <term_entry.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$From: lib_setup.c,v 1.59 2000/02/13 01:01:26 tom Exp $")
+MODULE_ID("$From: lib_setup.c,v 1.60 2000/09/02 18:13:12 tom Exp $")
/****************************************************************************
*
@@ -247,7 +247,7 @@ grab_entry(const char *const tn, TERMTYPE * const tp)
if ((status = _nc_read_entry(tn, filename, tp)) != 1) {
-#ifndef PURE_TERMINFO
+#if !PURE_TERMINFO
/*
* Try falling back on the termcap file.
* Note: allowing this call links the entire terminfo/termcap
diff --git a/lib/libcurses/tinfo/lib_termcap.c b/lib/libcurses/tinfo/lib_termcap.c
index 2f41572d913..3c3e11afc6b 100644
--- a/lib/libcurses/tinfo/lib_termcap.c
+++ b/lib/libcurses/tinfo/lib_termcap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_termcap.c,v 1.6 2000/03/10 01:35:04 millert Exp $ */
+/* $OpenBSD: lib_termcap.c,v 1.7 2000/10/08 22:47:02 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -41,7 +41,7 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$From: lib_termcap.c,v 1.36 2000/02/13 01:01:26 tom Exp $")
+MODULE_ID("$From: lib_termcap.c,v 1.37 2000/09/16 20:30:16 tom Exp $")
/*
some of the code in here was contributed by:
@@ -192,19 +192,3 @@ tgetstr(NCURSES_CONST char *id, char **area)
}
returnPtr(NULL);
}
-
-/*
- * char *
- * tgoto(string, x, y)
- *
- * Retained solely for upward compatibility. Note the intentional
- * reversing of the last two arguments.
- *
- */
-
-char *
-tgoto(const char *string, int x, int y)
-{
- T((T_CALLED("tgoto(%s,%d,%d)"), string, x, y));
- returnPtr(tparm((NCURSES_CONST char *) string, y, x));
-}
diff --git a/lib/libcurses/tinfo/lib_tgoto.c b/lib/libcurses/tinfo/lib_tgoto.c
new file mode 100644
index 00000000000..b305935cdee
--- /dev/null
+++ b/lib/libcurses/tinfo/lib_tgoto.c
@@ -0,0 +1,199 @@
+/* $OpenBSD: lib_tgoto.c,v 1.1 2000/10/08 22:47:02 millert Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+#include <termcap.h>
+
+MODULE_ID("$From: lib_tgoto.c,v 1.2 2000/09/24 00:19:14 tom Exp $")
+
+#if !PURE_TERMINFO
+static bool
+is_termcap(const char *string)
+{
+ bool result = TRUE;
+
+ while ((*string != '\0') && result) {
+ if (*string == '%') {
+ switch (*++string) {
+ case 'p':
+ result = FALSE;
+ break;
+ case '\0':
+ string--;
+ break;
+ }
+ } else if (string[0] == '$' && string[1] == '<') {
+ result = FALSE;
+ }
+ string++;
+ }
+ return result;
+}
+
+static char *
+tgoto_internal(const char *string, int x, int y)
+{
+ static char *result;
+ static size_t length;
+
+ int swap_arg;
+ int param[3];
+ size_t used = 0;
+ size_t need = 10;
+ int *value = param;
+ bool need_BC = FALSE;
+
+ if (BC)
+ need += strlen(BC);
+
+ param[0] = y;
+ param[1] = x;
+ param[2] = 0;
+
+ while (*string != 0) {
+ if ((used + need) > length) {
+ length += (used + need);
+ if ((result = _nc_doalloc(result, length)) == 0) {
+ length = 0;
+ break;
+ }
+ }
+ if (*string == '%') {
+ char *fmt = 0;
+
+ switch (*++string) {
+ case '\0':
+ string--;
+ break;
+ case 'd':
+ fmt = "%d";
+ break;
+ case '2':
+ fmt = "%02d";
+ *value %= 100;
+ break;
+ case '3':
+ fmt = "%03d";
+ *value %= 1000;
+ break;
+ case '+':
+ *value += (*++string & 0xff);
+ /* FALLTHRU */
+ case '.':
+ /*
+ * Guard against tputs() seeing a truncated string. The
+ * termcap documentation refers to a similar fixup for \n
+ * and \r, but I don't see that it could work -TD
+ */
+ if (*value == 0) {
+ if (BC != 0) {
+ *value += 1;
+ need_BC = TRUE;
+ } else {
+ *value = 0200; /* tputs will treat this as \0 */
+ }
+ }
+ result[used++] = *value++;
+ break;
+ case '%':
+ result[used++] = *string;
+ break;
+ case 'r':
+ swap_arg = param[0];
+ param[0] = param[1];
+ param[1] = swap_arg;
+ break;
+ case 'i':
+ param[0] += 1;
+ param[1] += 1;
+ break;
+ case '>':
+ if (*value > string[1])
+ *value += string[2];
+ string += 2;
+ break;
+ case 'n': /* Datamedia 2500 */
+ param[0] ^= 0140;
+ param[1] ^= 0140;
+ break;
+ case 'B': /* BCD */
+ *value = 16 * (*value / 10) + (*value % 10);
+ break;
+ case 'D': /* Reverse coding (Delta Data) */
+ *value -= 2 * (*value / 16);
+ break;
+ }
+ if (fmt != 0) {
+ sprintf(result + used, fmt, *value++);
+ used += strlen(result + used);
+ fmt = 0;
+ }
+ if (value - param > 2) {
+ value = param + 2;
+ *value = 0;
+ }
+ } else {
+ result[used++] = *string;
+ }
+ string++;
+ }
+ if (need_BC) {
+ strcpy(result + used, BC);
+ used += strlen(BC);
+ }
+ result[used] = '\0';
+ return result;
+}
+#endif
+
+/*
+ * Retained solely for upward compatibility. Note the intentional reversing of
+ * the last two arguments when invoking tparm().
+ */
+char *
+tgoto(const char *string, int x, int y)
+{
+ char *result;
+
+ T((T_CALLED("tgoto(%s, %d, %d)"), _nc_visbuf(string), x, y));
+#if !PURE_TERMINFO
+ if (is_termcap(string))
+ result = tgoto_internal(string, x, y);
+ else
+#endif
+ result = tparm((NCURSES_CONST char *) string, y, x);
+ returnPtr(result);
+}
diff --git a/lib/libcurses/tinfo/lib_tparm.c b/lib/libcurses/tinfo/lib_tparm.c
index fa546352160..a548dcb35de 100644
--- a/lib/libcurses/tinfo/lib_tparm.c
+++ b/lib/libcurses/tinfo/lib_tparm.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tparm.c,v 1.4 1999/06/06 15:55:18 millert Exp $ */
+/* $OpenBSD: lib_tparm.c,v 1.5 2000/10/08 22:47:02 millert Exp $ */
/****************************************************************************
- * 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 *
@@ -33,7 +33,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* tparm.c
*
@@ -45,7 +44,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$From: lib_tparm.c,v 1.39 1999/06/06 00:04:55 tom Exp $")
+MODULE_ID("$From: lib_tparm.c,v 1.47 2000/10/04 00:57:13 tom Exp $")
/*
* char *
@@ -76,6 +75,8 @@ MODULE_ID("$From: lib_tparm.c,v 1.39 1999/06/06 00:04:55 tom Exp $")
* %s print pop() like %s in printf()
* %[[:]flags][width[.precision]][doxXs]
* as in printf, flags are [-+#] and space
+ * The ':' is used to avoid making %+ or %-
+ * patterns (see below).
*
* %p[1-9] push ith parm
* %P[a-z] set dynamic variable [a-z] to pop()
@@ -107,481 +108,636 @@ MODULE_ID("$From: lib_tparm.c,v 1.39 1999/06/06 00:04:55 tom Exp $")
#define STACKSIZE 20
-typedef union {
- unsigned int num;
- char *str;
+typedef struct {
+ union {
+ unsigned int num;
+ char *str;
+ } data;
+ bool num_type;
} stack_frame;
-static stack_frame stack[STACKSIZE];
-static int stack_ptr;
+static stack_frame stack[STACKSIZE];
+static int stack_ptr;
+
#ifdef TRACE
static const char *tname;
#endif /* TRACE */
-static char *out_buff;
+static char *out_buff;
static size_t out_size;
static size_t out_used;
#if NO_LEAKS
-void _nc_free_tparm(void)
+void
+_nc_free_tparm(void)
{
- if (out_buff != 0) {
- FreeAndNull(out_buff);
- out_size = 0;
- out_used = 0;
- }
+ if (out_buff != 0) {
+ FreeAndNull(out_buff);
+ out_size = 0;
+ out_used = 0;
+ }
}
#endif
-static void really_get_space(size_t need)
+static void
+really_get_space(size_t need)
{
- out_size = need * 2;
- out_buff = typeRealloc(char, out_size, out_buff);
- if (out_buff == 0)
- _nc_err_abort("Out of memory");
+ out_size = need * 2;
+ out_buff = typeRealloc(char, out_size, out_buff);
+ if (out_buff == 0)
+ _nc_err_abort("Out of memory");
}
-static inline void get_space(size_t need)
+static inline void
+get_space(size_t need)
{
- need += out_used;
- if (need > out_size)
- really_get_space(need);
+ need += out_used;
+ if (need > out_size)
+ really_get_space(need);
}
-static inline void save_text(const char *fmt, char *s, int len)
+static inline void
+save_text(const char *fmt, const char *s, int len)
{
- size_t s_len = strlen(s);
- if (len > (int)s_len)
- s_len = len;
+ size_t s_len = strlen(s);
+ if (len > (int) s_len)
+ s_len = len;
- get_space(s_len + 1);
+ get_space(s_len + 1);
- (void)sprintf(out_buff+out_used, fmt, s);
- out_used += strlen(out_buff+out_used);
+ (void) sprintf(out_buff + out_used, fmt, s);
+ out_used += strlen(out_buff + out_used);
}
-static inline void save_number(const char *fmt, int number, int len)
+static inline void
+save_number(const char *fmt, int number, int len)
{
- if (len < 30)
- len = 30; /* actually log10(MAX_INT)+1 */
+ if (len < 30)
+ len = 30; /* actually log10(MAX_INT)+1 */
- get_space(len + 1);
+ get_space(len + 1);
- (void)sprintf(out_buff+out_used, fmt, number);
- out_used += strlen(out_buff+out_used);
+ (void) sprintf(out_buff + out_used, fmt, number);
+ out_used += strlen(out_buff + out_used);
}
-static inline void save_char(int c)
+static inline void
+save_char(int c)
{
- if (c == 0)
- c = 0200;
- get_space(1);
- out_buff[out_used++] = c;
+ if (c == 0)
+ c = 0200;
+ get_space(1);
+ out_buff[out_used++] = c;
}
-static inline void npush(int x)
+static inline void
+npush(int x)
{
- if (stack_ptr < STACKSIZE) {
- stack[stack_ptr].num = x;
- stack_ptr++;
- }
+ if (stack_ptr < STACKSIZE) {
+ stack[stack_ptr].num_type = TRUE;
+ stack[stack_ptr].data.num = x;
+ stack_ptr++;
+ }
}
-static inline int npop(void)
+static inline int
+npop(void)
{
- return (stack_ptr > 0 ? stack[--stack_ptr].num : 0);
+ int result = 0;
+ if (stack_ptr > 0) {
+ stack_ptr--;
+ if (stack[stack_ptr].num_type)
+ result = stack[stack_ptr].data.num;
+ }
+ return result;
}
-static inline char *spop(void)
+static inline void
+spush(char *x)
{
- static char dummy[] = ""; /* avoid const-cast */
- return (stack_ptr > 0 ? stack[--stack_ptr].str : dummy);
+ if (stack_ptr < STACKSIZE) {
+ stack[stack_ptr].num_type = FALSE;
+ stack[stack_ptr].data.str = x;
+ stack_ptr++;
+ }
}
-static inline const char *parse_format(const char *s, char *format, int *len)
+static inline char *
+spop(void)
{
- bool done = FALSE;
- bool allowminus = FALSE;
- bool dot = FALSE;
- int prec = 0;
- int width = 0;
+ static char dummy[] = ""; /* avoid const-cast */
+ char *result = dummy;
+ if (stack_ptr > 0) {
+ stack_ptr--;
+ if (!stack[stack_ptr].num_type && stack[stack_ptr].data.str != 0)
+ result = stack[stack_ptr].data.str;
+ }
+ return result;
+}
- *len = 0;
- *format++ = '%';
- while (*s != '\0' && !done) {
- switch (*s) {
- case 'c': /* FALLTHRU */
- case 'd': /* FALLTHRU */
- case 'o': /* FALLTHRU */
- case 'x': /* FALLTHRU */
- case 'X': /* FALLTHRU */
- case 's':
- *format++ = *s;
- done = TRUE;
- break;
- case '.':
- *format++ = *s++;
- dot = TRUE;
- break;
- case '#':
- *format++ = *s++;
- break;
- case ' ':
- *format++ = *s++;
- break;
- case ':':
- s++;
- allowminus = TRUE;
- break;
- case '-':
- if (allowminus) {
- *format++ = *s++;
- } else {
- done = TRUE;
- }
- break;
- default:
- if (isdigit(*s)) {
- if (dot)
- prec = (prec * 10) + (*s - '0');
- else
- width = (width * 10) + (*s - '0');
- *format++ = *s++;
- } else {
- done = TRUE;
- }
- }
+static inline const char *
+parse_format(const char *s, char *format, int *len)
+{
+ bool done = FALSE;
+ bool allowminus = FALSE;
+ bool dot = FALSE;
+ bool err = FALSE;
+ char *fmt = format;
+ int prec = 0;
+ int width = 0;
+ int value = 0;
+
+ *len = 0;
+ *format++ = '%';
+ while (*s != '\0' && !done) {
+ switch (*s) {
+ case 'c': /* FALLTHRU */
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 's':
+ *format++ = *s;
+ done = TRUE;
+ break;
+ case '.':
+ *format++ = *s++;
+ if (dot) {
+ err = TRUE;
+ } else {
+ dot = TRUE;
+ prec = value;
+ }
+ value = 0;
+ break;
+ case '#':
+ *format++ = *s++;
+ break;
+ case ' ':
+ *format++ = *s++;
+ break;
+ case ':':
+ s++;
+ allowminus = TRUE;
+ break;
+ case '-':
+ if (allowminus) {
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
+ break;
+ default:
+ if (isdigit(*s)) {
+ value = (value * 10) + (*s - '0');
+ if (value > 10000)
+ err = TRUE;
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
}
- *format = '\0';
- /* return maximum string length in print */
- *len = (prec > width) ? prec : width;
- return s;
+ }
+
+ /*
+ * If we found an error, ignore (and remove) the flags.
+ */
+ if (err) {
+ prec = width = value = 0;
+ format = fmt;
+ *format++ = '%';
+ *format++ = *s;
+ }
+
+ if (dot)
+ width = value;
+ else
+ prec = value;
+
+ *format = '\0';
+ /* return maximum string length in print */
+ *len = (prec > width) ? prec : width;
+ return s;
}
#define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
-static inline char *tparam_internal(const char *string, va_list ap)
+static inline char *
+tparam_internal(const char *string, va_list ap)
{
#define NUM_VARS 26
-int param[9];
-int popcount;
-int number;
-int len;
-int level;
-int x, y;
-int i;
-register const char *cp;
-static size_t len_fmt;
-static char *format;
-static int dynamic_var[NUM_VARS];
-static int static_vars[NUM_VARS];
-
- out_used = 0;
- if (string == NULL)
- return NULL;
-
- /*
- * Find the highest parameter-number referred to in the format string.
- * Use this value to limit the number of arguments copied from the
- * variable-length argument list.
- */
- for (cp = string, popcount = number = 0; *cp != '\0'; cp++) {
- if (cp[0] == '%' && cp[1] != '\0') {
- switch (cp[1]) {
- case '%':
- cp++;
- break;
- case 'i':
- if (popcount < 2)
- popcount = 2;
- break;
- case 'p':
- cp++;
- if (cp[1] >= '1' && cp[1] <= '9') {
- int c = cp[1] - '0';
- if (c > popcount)
- popcount = c;
- }
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'd': case 'c': case 's':
- ++number;
- break;
- }
+ char *p_is_s[9];
+ int param[9];
+ int lastpop;
+ int popcount;
+ int number;
+ int len;
+ int level;
+ int x, y;
+ int i;
+ size_t len2;
+ register const char *cp;
+ static size_t len_fmt;
+ static char dummy[] = "";
+ static char *format;
+ static int dynamic_var[NUM_VARS];
+ static int static_vars[NUM_VARS];
+
+ out_used = 0;
+ if (string == NULL)
+ return NULL;
+
+ if ((len2 = strlen(string)) > len_fmt) {
+ len_fmt = len2 + len_fmt + 2;
+ if ((format = typeRealloc(char, len_fmt, format)) == 0)
+ return 0;
+ }
+
+ /*
+ * Find the highest parameter-number referred to in the format string.
+ * Use this value to limit the number of arguments copied from the
+ * variable-length argument list.
+ */
+
+ number = 0;
+ lastpop = -1;
+ popcount = 0;
+ memset(p_is_s, 0, sizeof(p_is_s));
+
+ /*
+ * Analyze the string to see how many parameters we need from the varargs
+ * list, and what their types are. We will only accept string parameters
+ * if they appear as a %l or %s format following an explicit parameter
+ * reference (e.g., %p2%s). All other parameters are numbers.
+ *
+ * 'number' counts coarsely the number of pop's we see in the string, and
+ * 'popcount' shows the highest parameter number in the string. We would
+ * like to simply use the latter count, but if we are reading termcap
+ * strings, there may be cases that we cannot see the explicit parameter
+ * numbers.
+ */
+ for (cp = string; (cp - string) < (int) len2;) {
+ if (*cp == '%') {
+ cp++;
+ cp = parse_format(cp, format, &len);
+ switch (*cp) {
+ default:
+ break;
+
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 'c': /* FALLTHRU */
+ number++;
+ lastpop = -1;
+ break;
+
+ case 'l':
+ case 's':
+ if (lastpop > 0)
+ p_is_s[lastpop - 1] = dummy;
+ ++number;
+ break;
+
+ case 'p':
+ cp++;
+ i = (*cp - '0');
+ if (i >= 0 && i <= 9) {
+ lastpop = i;
+ if (lastpop > popcount)
+ popcount = lastpop;
}
+ break;
+
+ case 'P':
+ case 'g':
+ cp++;
+ break;
+
+ case S_QUOTE:
+ cp += 2;
+ lastpop = -1;
+ break;
+
+ case L_BRACE:
+ cp++;
+ while (*cp >= '0' && *cp <= '9') {
+ cp++;
+ }
+ break;
+
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case 'm':
+ case 'A':
+ case 'O':
+ case '&':
+ case '|':
+ case '^':
+ case '=':
+ case '<':
+ case '>':
+ case '!':
+ case '~':
+ lastpop = -1;
+ number += 2;
+ break;
+
+ case 'i':
+ lastpop = -1;
+ if (popcount < 2)
+ popcount = 2;
+ break;
+ }
}
- if ((size_t)(cp - string) > len_fmt) {
- len_fmt = (cp - string) + len_fmt + 2;
- if ((format = typeRealloc(char, len_fmt, format)) == 0)
- return 0;
- }
-
- if (number > 9) number = 9;
- for (i = 0; i < max(popcount, number); i++) {
- /*
- * FIXME: potential loss here if sizeof(int) != sizeof(char *).
- * A few caps (such as plab_norm) have string-valued parms.
- */
- param[i] = va_arg(ap, int);
- }
+ if (*cp != '\0')
+ cp++;
+ }
+ if (number > 9)
+ number = 9;
+ for (i = 0; i < max(popcount, number); i++) {
/*
- * This is a termcap compatibility hack. If there are no explicit pop
- * operations in the string, load the stack in such a way that
- * successive pops will grab successive parameters. That will make
- * the expansion of (for example) \E[%d;%dH work correctly in termcap
- * style, which means tparam() will expand termcap strings OK.
+ * A few caps (such as plab_norm) have string-valued parms.
+ * We'll have to assume that the caller knows the difference, since
+ * a char* and an int may not be the same size on the stack.
*/
- stack_ptr = 0;
- if (popcount == 0) {
- popcount = number;
- for (i = number - 1; i >= 0; i--)
- npush(param[i]);
+ if (p_is_s[i] != 0) {
+ p_is_s[i] = va_arg(ap, char *);
+ } else {
+ param[i] = va_arg(ap, int);
}
-
+ }
+
+ /*
+ * This is a termcap compatibility hack. If there are no explicit pop
+ * operations in the string, load the stack in such a way that
+ * successive pops will grab successive parameters. That will make
+ * the expansion of (for example) \E[%d;%dH work correctly in termcap
+ * style, which means tparam() will expand termcap strings OK.
+ */
+ stack_ptr = 0;
+ if (popcount == 0) {
+ popcount = number;
+ for (i = number - 1; i >= 0; i--)
+ npush(param[i]);
+ }
#ifdef TRACE
- if (_nc_tracing & TRACE_CALLS) {
- for (i = 0; i < popcount; i++)
- save_number(", %d", param[i], 0);
- _tracef(T_CALLED("%s(%s%s)"), tname, _nc_visbuf(string), out_buff);
- out_used = 0;
+ if (_nc_tracing & TRACE_CALLS) {
+ for (i = 0; i < popcount; i++) {
+ if (p_is_s[i] != 0)
+ save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
+ else
+ save_number(", %d", param[i], 0);
}
+ _tracef(T_CALLED("%s(%s%s)"), tname, _nc_visbuf(string), out_buff);
+ out_used = 0;
+ }
#endif /* TRACE */
- while (*string) {
- if (*string != '%') {
- save_char(*string);
- } else {
- string++;
- string = parse_format(string, format, &len);
- switch (*string) {
- default:
- break;
- case '%':
- save_char('%');
- break;
-
- case 'd': /* FALLTHRU */
- case 'o': /* FALLTHRU */
- case 'x': /* FALLTHRU */
- case 'X': /* FALLTHRU */
- case 'c':
- save_number(format, npop(), len);
- break;
-
- case 'l':
- save_number("%d", strlen(spop()), 0);
- break;
-
- case 's':
- save_text(format, spop(), len);
- break;
-
- case 'p':
- string++;
- if (*string >= '1' && *string <= '9')
- npush(param[*string - '1']);
- break;
-
- case 'P':
- string++;
- if (isUPPER(*string)) {
- i = (*string - 'A');
- static_vars[i] = npop();
- } else if (isLOWER(*string)) {
- i = (*string - 'a');
- dynamic_var[i] = npop();
- }
- break;
-
- case 'g':
- string++;
- if (isUPPER(*string)) {
- i = (*string - 'A');
- npush(static_vars[i]);
- } else if (isLOWER(*string)) {
- i = (*string - 'a');
- npush(dynamic_var[i]);
- }
- break;
-
- case S_QUOTE:
- string++;
- npush(*string);
- string++;
- break;
-
- case L_BRACE:
- number = 0;
- string++;
- while (*string >= '0' && *string <= '9') {
- number = number * 10 + *string - '0';
- string++;
- }
- npush(number);
- break;
-
- case '+':
- npush(npop() + npop());
- break;
-
- case '-':
- y = npop();
- x = npop();
- npush(x - y);
- break;
-
- case '*':
- npush(npop() * npop());
- break;
-
- case '/':
- y = npop();
- x = npop();
- npush(y ? (x / y) : 0);
- break;
-
- case 'm':
- y = npop();
- x = npop();
- npush(y ? (x % y) : 0);
- break;
-
- case 'A':
- npush(npop() && npop());
- break;
-
- case 'O':
- npush(npop() || npop());
- break;
-
- case '&':
- npush(npop() & npop());
- break;
-
- case '|':
- npush(npop() | npop());
- break;
-
- case '^':
- npush(npop() ^ npop());
- break;
-
- case '=':
- y = npop();
- x = npop();
- npush(x == y);
- break;
-
- case '<':
- y = npop();
- x = npop();
- npush(x < y);
- break;
+ while (*string) {
+ if (*string != '%') {
+ save_char(*string);
+ } else {
+ string++;
+ string = parse_format(string, format, &len);
+ switch (*string) {
+ default:
+ break;
+ case '%':
+ save_char('%');
+ break;
+
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 'c': /* FALLTHRU */
+ save_number(format, npop(), len);
+ break;
+
+ case 'l':
+ save_number("%d", strlen(spop()), 0);
+ break;
+
+ case 's':
+ save_text(format, spop(), len);
+ break;
+
+ case 'p':
+ string++;
+ i = (*string - '1');
+ if (i >= 0 && i < 9) {
+ if (p_is_s[i])
+ spush(p_is_s[i]);
+ else
+ npush(param[i]);
+ }
+ break;
- case '>':
- y = npop();
- x = npop();
- npush(x > y);
- break;
+ case 'P':
+ string++;
+ if (isUPPER(*string)) {
+ i = (*string - 'A');
+ static_vars[i] = npop();
+ } else if (isLOWER(*string)) {
+ i = (*string - 'a');
+ dynamic_var[i] = npop();
+ }
+ break;
- case '!':
- npush(! npop());
- break;
+ case 'g':
+ string++;
+ if (isUPPER(*string)) {
+ i = (*string - 'A');
+ npush(static_vars[i]);
+ } else if (isLOWER(*string)) {
+ i = (*string - 'a');
+ npush(dynamic_var[i]);
+ }
+ break;
- case '~':
- npush(~ npop());
- break;
+ case S_QUOTE:
+ string++;
+ npush(*string);
+ string++;
+ break;
- case 'i':
- param[0]++;
- param[1]++;
+ case L_BRACE:
+ number = 0;
+ string++;
+ while (*string >= '0' && *string <= '9') {
+ number = number * 10 + *string - '0';
+ string++;
+ }
+ npush(number);
+ break;
+
+ case '+':
+ npush(npop() + npop());
+ break;
+
+ case '-':
+ y = npop();
+ x = npop();
+ npush(x - y);
+ break;
+
+ case '*':
+ npush(npop() * npop());
+ break;
+
+ case '/':
+ y = npop();
+ x = npop();
+ npush(y ? (x / y) : 0);
+ break;
+
+ case 'm':
+ y = npop();
+ x = npop();
+ npush(y ? (x % y) : 0);
+ break;
+
+ case 'A':
+ npush(npop() && npop());
+ break;
+
+ case 'O':
+ npush(npop() || npop());
+ break;
+
+ case '&':
+ npush(npop() & npop());
+ break;
+
+ case '|':
+ npush(npop() | npop());
+ break;
+
+ case '^':
+ npush(npop() ^ npop());
+ break;
+
+ case '=':
+ y = npop();
+ x = npop();
+ npush(x == y);
+ break;
+
+ case '<':
+ y = npop();
+ x = npop();
+ npush(x < y);
+ break;
+
+ case '>':
+ y = npop();
+ x = npop();
+ npush(x > y);
+ break;
+
+ case '!':
+ npush(!npop());
+ break;
+
+ case '~':
+ npush(~npop());
+ break;
+
+ case 'i':
+ if (p_is_s[0] == 0)
+ param[0]++;
+ if (p_is_s[1] == 0)
+ param[1]++;
+ break;
+
+ case '?':
+ break;
+
+ case 't':
+ x = npop();
+ if (!x) {
+ /* scan forward for %e or %; at level zero */
+ string++;
+ level = 0;
+ while (*string) {
+ if (*string == '%') {
+ string++;
+ if (*string == '?')
+ level++;
+ else if (*string == ';') {
+ if (level > 0)
+ level--;
+ else
+ break;
+ } else if (*string == 'e' && level == 0)
break;
+ }
- case '?':
- break;
+ if (*string)
+ string++;
+ }
+ }
+ break;
- case 't':
- x = npop();
- if (!x) {
- /* scan forward for %e or %; at level zero */
- string++;
- level = 0;
- while (*string) {
- if (*string == '%') {
- string++;
- if (*string == '?')
- level++;
- else if (*string == ';') {
- if (level > 0)
- level--;
- else
- break;
- }
- else if (*string == 'e' && level == 0)
- break;
- }
-
- if (*string)
- string++;
- }
- }
+ case 'e':
+ /* scan forward for a %; at level zero */
+ string++;
+ level = 0;
+ while (*string) {
+ if (*string == '%') {
+ string++;
+ if (*string == '?')
+ level++;
+ else if (*string == ';') {
+ if (level > 0)
+ level--;
+ else
break;
+ }
+ }
- case 'e':
- /* scan forward for a %; at level zero */
- string++;
- level = 0;
- while (*string) {
- if (*string == '%') {
- string++;
- if (*string == '?')
- level++;
- else if (*string == ';') {
- if (level > 0)
- level--;
- else
- break;
- }
- }
-
- if (*string)
- string++;
- }
- break;
+ if (*string)
+ string++;
+ }
+ break;
- case ';':
- break;
+ case ';':
+ break;
- } /* endswitch (*string) */
- } /* endelse (*string == '%') */
+ } /* endswitch (*string) */
+ } /* endelse (*string == '%') */
- if (*string == '\0')
- break;
+ if (*string == '\0')
+ break;
- string++;
- } /* endwhile (*string) */
+ string++;
+ } /* endwhile (*string) */
- if (out_buff == 0 && (out_buff = typeCalloc(char,1)) == NULL)
- return(NULL);
- out_buff[out_used] = '\0';
+ if (out_buff == 0 && (out_buff = typeCalloc(char, 1)) == NULL)
+ return (NULL);
+ out_buff[out_used] = '\0';
- T((T_RETURN("%s"), _nc_visbuf(out_buff)));
- return(out_buff);
+ T((T_RETURN("%s"), _nc_visbuf(out_buff)));
+ return (out_buff);
}
-char *tparm(NCURSES_CONST char *string, ...)
+char *
+tparm(NCURSES_CONST char *string,...)
{
-va_list ap;
-char *result;
+ va_list ap;
+ char *result;
- va_start(ap, string);
+ va_start(ap, string);
#ifdef TRACE
- tname = "tparm";
+ tname = "tparm";
#endif /* TRACE */
- result = tparam_internal(string, ap);
- va_end(ap);
- return result;
+ result = tparam_internal(string, ap);
+ va_end(ap);
+ return result;
}
diff --git a/lib/libcurses/tinfo/lib_tputs.c b/lib/libcurses/tinfo/lib_tputs.c
index 11b13bac863..6084d441902 100644
--- a/lib/libcurses/tinfo/lib_tputs.c
+++ b/lib/libcurses/tinfo/lib_tputs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_tputs.c,v 1.7 2000/07/24 04:06:10 millert Exp $ */
+/* $OpenBSD: lib_tputs.c,v 1.8 2000/10/08 22:47:02 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -47,10 +47,10 @@
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$From: lib_tputs.c,v 1.48 2000/07/22 22:33:23 Bruno.Haible Exp $")
+MODULE_ID("$From: lib_tputs.c,v 1.51 2000/10/08 00:22:24 tom Exp $")
char PC = 0; /* used by termcap library */
-speed_t ospeed = 0; /* used by termcap library */
+short ospeed = 0; /* used by termcap library */
int _nc_nulls_sent = 0; /* used by 'tack' program */
@@ -104,7 +104,7 @@ _nc_outch(int ch)
return OK;
}
-#ifdef USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT
/*
* Reference: The Unicode Standard 2.0
*
@@ -143,20 +143,26 @@ _nc_utf8_outch(int ch)
case 6:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 5:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 4:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 3:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 2:
*--ptr = (ch | otherMark) & byteMask;
ch >>= 6;
+ /* FALLTHRU */
case 1:
*--ptr = (ch | firstMark[count]);
+ break;
}
while (count--)
_nc_outch(*ptr++);
@@ -176,7 +182,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
bool always_delay;
bool normal_delay;
int number;
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
int trailpad;
#endif /* BSD_TPUTS */
@@ -190,7 +196,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
(void) sprintf(addrbuf, "%p", outc);
if (_nc_tputs_trace) {
_tracef("tputs(%s = %s, %d, %s) called", _nc_tputs_trace,
- _nc_visbuf(string), affcnt, addrbuf);
+ _nc_visbuf(string), affcnt, addrbuf);
} else {
_tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf);
}
@@ -209,13 +215,13 @@ tputs(const char *string, int affcnt, int (*outc) (int))
normal_delay =
!xon_xoff
&& padding_baud_rate
-#ifdef NCURSES_NO_PADDING
+#if NCURSES_NO_PADDING
&& (SP == 0 || !(SP->_no_padding))
#endif
&& (_nc_baudrate(ospeed) >= padding_baud_rate);
}
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
/*
* This ugly kluge deals with the fact that some ancient BSD programs
* (like nethack) actually do the likes of tputs("50") to get delays.
@@ -306,7 +312,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
string++;
}
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
/*
* Emit any BSD-style prefix padding that we've accumulated now.
*/
diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c
index 9ee99320357..3a88ec027e2 100644
--- a/lib/libcurses/tinfo/parse_entry.c
+++ b/lib/libcurses/tinfo/parse_entry.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse_entry.c,v 1.7 2000/06/19 03:53:51 millert Exp $ */
+/* $OpenBSD: parse_entry.c,v 1.8 2000/10/08 22:47:02 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -49,7 +49,7 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$From: parse_entry.c,v 1.44 2000/04/30 00:17:42 tom Exp $")
+MODULE_ID("$From: parse_entry.c,v 1.48 2000/10/03 09:38:48 tom Exp $")
#ifdef LINT
static short const parametrized[] =
@@ -202,7 +202,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
{
int token_type;
struct name_table_entry const *entry_ptr;
- char *ptr, namecpy[MAX_NAME_SIZE + 1];
+ char *ptr, *base;
token_type = _nc_get_token();
@@ -237,21 +237,22 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
_nc_set_type(_nc_first_name(entryp->tterm.term_names));
/* check for overly-long names and aliases */
- (void) strlcpy(namecpy, entryp->tterm.term_names, sizeof(namecpy));
- if ((ptr = strrchr(namecpy, '|')) != (char *) 0)
- *ptr = '\0';
- ptr = strtok(namecpy, "|");
- if (strlen(ptr) > MAX_ALIAS)
- _nc_warning("primary name may be too long");
- while ((ptr = strtok((char *) 0, "|")) != (char *) 0)
- if (strlen(ptr) > MAX_ALIAS)
- _nc_warning("alias `%s' may be too long", ptr);
+ for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != 0;
+ base = ptr + 1) {
+ if (ptr - base > MAX_ALIAS) {
+ _nc_warning("%s `%.*s' may be too long",
+ (base == entryp->tterm.term_names)
+ ? "primary name"
+ : "alias",
+ ptr - base, base);
+ }
+ }
entryp->nuses = 0;
for (token_type = _nc_get_token();
- token_type != EOF && token_type != NAMES;
- token_type = _nc_get_token()) {
+ token_type != EOF && token_type != NAMES;
+ token_type = _nc_get_token()) {
if (strcmp(_nc_curr_token.tk_name, "use") == 0
|| strcmp(_nc_curr_token.tk_name, "tc") == 0) {
entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
@@ -260,7 +261,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
} else {
/* normal token lookup */
entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
- _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
+ _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
/*
* Our kluge to handle aliasing. The reason it's done
@@ -278,14 +279,14 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s termcap extension) ignored",
- ap->from, ap->source);
+ ap->from, ap->source);
goto nexttok;
}
entry_ptr = _nc_find_entry(ap->to, _nc_cap_hash_table);
if (entry_ptr && !silent)
_nc_warning("%s (%s termcap extension) aliased to %s",
- ap->from, ap->source, ap->to);
+ ap->from, ap->source, ap->to);
break;
}
} else { /* if (_nc_syntax == SYN_TERMINFO) */
@@ -293,14 +294,14 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s terminfo extension) ignored",
- ap->from, ap->source);
+ ap->from, ap->source);
goto nexttok;
}
entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
if (entry_ptr && !silent)
_nc_warning("%s (%s terminfo extension) aliased to %s",
- ap->from, ap->source, ap->to);
+ ap->from, ap->source, ap->to);
break;
}
@@ -317,7 +318,8 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (entry_ptr == NOTFOUND
&& _nc_user_definable
&& (entry_ptr = _nc_extend_names(entryp,
- _nc_curr_token.tk_name, token_type)) != 0) {
+ _nc_curr_token.tk_name,
+ token_type)) != 0) {
if (_nc_tracing >= DEBUG_LEVEL(1))
_nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
}
@@ -327,7 +329,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (entry_ptr == NOTFOUND) {
if (!silent)
_nc_warning("unknown capability '%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
continue;
}
@@ -346,12 +348,14 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
/* tell max_attributes from arrow_key_map */
if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name))
entry_ptr = _nc_find_type_entry("ma", NUMBER,
- _nc_get_table(_nc_syntax != 0));
+ _nc_get_table(_nc_syntax
+ != 0));
/* map terminfo's string MT to MT */
else if (token_type == STRING && !strcmp("MT", _nc_curr_token.tk_name))
entry_ptr = _nc_find_type_entry("MT", STRING,
- _nc_get_table(_nc_syntax != 0));
+ _nc_get_table(_nc_syntax
+ != 0));
/* treat strings without following "=" as empty strings */
else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING)
@@ -375,7 +379,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
break;
}
_nc_warning("wrong type used for %s capability '%s'",
- type_name, _nc_curr_token.tk_name);
+ type_name, _nc_curr_token.tk_name);
}
continue;
}
@@ -412,8 +416,8 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
ptr = _nc_curr_token.tk_valstring;
if (_nc_syntax == SYN_TERMCAP)
ptr = _nc_captoinfo(_nc_curr_token.tk_name,
- ptr,
- parametrized[entry_ptr->nte_index]);
+ ptr,
+ parametrized[entry_ptr->nte_index]);
entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr);
break;
@@ -480,14 +484,14 @@ _nc_capcmp(const char *s, const char *t)
if (s[0] == '$' && s[1] == '<') {
for (s += 2;; s++)
if (!(isdigit(*s) || *s == '.' || *s == '*' || *s == '/' ||
- *s == '>'))
+ *s == '>'))
break;
}
if (t[0] == '$' && t[1] == '<') {
for (t += 2;; t++)
if (!(isdigit(*t) || *t == '.' || *t == '*' || *t == '/' ||
- *t == '>'))
+ *t == '>'))
break;
}
@@ -504,6 +508,26 @@ _nc_capcmp(const char *s, const char *t)
}
}
+static void
+append_acs0(string_desc *dst, int code, int src)
+{
+ if (src != 0) {
+ char temp[3];
+ temp[0] = code;
+ temp[1] = src;
+ temp[2] = 0;
+ _nc_safe_strcat(dst, temp);
+ }
+}
+
+static void
+append_acs(string_desc *dst, int code, char *src)
+{
+ if (src != 0 && strlen(src) == 1) {
+ append_acs0(dst, code, *src);
+ }
+}
+
/*
* The ko capability, if present, consists of a comma-separated capability
* list. For each capability, we may assume there is a keycap that sends the
@@ -564,11 +588,11 @@ static const char C_HT[] = "\t";
#undef CUR
#define CUR tp->
-static
-void
+static void
postprocess_termcap(TERMTYPE * tp, bool has_base)
{
char buf[MAX_LINE * 2 + 2];
+ string_desc result;
/*
* TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS
@@ -633,13 +657,15 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
} else
newline = _nc_save_str(C_LF);
} else if (PRESENT(carriage_return) && PRESENT(scroll_forward)) {
- strlcpy(buf, carriage_return, MAX_LINE + 1);
- strlcat(buf, scroll_forward, MAX_LINE + 1);
- newline = _nc_save_str(buf);
+ _nc_str_init(&result, buf, sizeof(buf));
+ if (_nc_safe_strcat(&result, carriage_return)
+ && _nc_safe_strcat(&result, scroll_forward))
+ newline = _nc_save_str(buf);
} else if (PRESENT(carriage_return) && PRESENT(cursor_down)) {
- strlcpy(buf, carriage_return, MAX_LINE + 1);
- strlcat(buf, cursor_down, MAX_LINE + 1);
- newline = _nc_save_str(buf);
+ _nc_str_init(&result, buf, sizeof(buf));
+ if (_nc_safe_strcat(&result, carriage_return)
+ && _nc_safe_strcat(&result, cursor_down))
+ newline = _nc_save_str(buf);
}
}
}
@@ -692,7 +718,7 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
else {
if (tab && _nc_capcmp(tab, C_HT))
_nc_warning("hardware tabs with a non-^I tab string %s",
- _nc_visbuf(tab));
+ _nc_visbuf(tab));
else {
if (WANTED(tab))
tab = _nc_save_str(C_HT);
@@ -705,7 +731,8 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
* isn't from mytinfo...
*/
if (PRESENT(other_non_function_keys)) {
- char *dp, *cp = strtok(other_non_function_keys, ",");
+ char *base = other_non_function_keys;
+ char *bp, *cp, *dp;
struct name_table_entry const *from_ptr;
struct name_table_entry const *to_ptr;
assoc const *ap;
@@ -714,15 +741,21 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
/* we're going to use this for a special case later */
dp = strchr(other_non_function_keys, 'i');
- foundim = dp && dp[1] == 'm';
+ foundim = (dp != 0) && (dp[1] == 'm');
/* look at each comma-separated capability in the ko string... */
- do {
+ for (base = other_non_function_keys;
+ (cp = strchr(base, ',')) != 0;
+ base = cp + 1) {
+ size_t len = cp - base;
+
for (ap = ko_xlate; ap->from; ap++)
- if (strcmp(ap->from, cp) == 0)
+ if (len == strlen(ap->from)
+ && strncmp(ap->from, base, len) == 0)
break;
if (!ap->to) {
- _nc_warning("unknown capability `%s' in ko string", cp);
+ _nc_warning("unknown capability `%.*s' in ko string",
+ (int) len, base);
continue;
} else if (ap->to == CANCELLED_STRING) /* ignore it */
continue;
@@ -745,11 +778,11 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
* string; that's just an inefficiency.
*/
if (strcmp(
- tp->Strings[from_ptr->nte_index],
- tp->Strings[to_ptr->nte_index]) != 0)
+ tp->Strings[from_ptr->nte_index],
+ tp->Strings[to_ptr->nte_index]) != 0)
_nc_warning("%s (%s) already has an explicit value %s, ignoring ko",
- ap->to, ap->from,
- _nc_visbuf(tp->Strings[to_ptr->nte_index]));
+ ap->to, ap->from,
+ _nc_visbuf(tp->Strings[to_ptr->nte_index]));
continue;
}
@@ -757,22 +790,18 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
* The magic moment -- copy the mapped key string over,
* stripping out padding.
*/
- dp = buf2;
- for (cp = tp->Strings[from_ptr->nte_index]; *cp; cp++) {
- if (cp[0] == '$' && cp[1] == '<') {
- while (*cp && *cp != '>')
- if (!*cp)
- break;
- else
- ++cp;
+ for (dp = buf2, bp = tp->Strings[from_ptr->nte_index]; *bp; bp++) {
+ if (bp[0] == '$' && bp[1] == '<') {
+ while (*bp && *bp != '>') {
+ ++bp;
+ }
} else
- *dp++ = *cp;
+ *dp++ = *bp;
}
*dp++ = '\0';
tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
- } while
- ((cp = strtok((char *) 0, ",")) != 0);
+ }
/*
* Note: ko=im and ko=ic both want to grab the `Insert'
@@ -809,74 +838,36 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
PRESENT(acs_hline) ||
PRESENT(acs_vline) ||
PRESENT(acs_plus)) {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
-
- if (acs_chars) {
- (void) strcpy(bp, acs_chars);
- bp += strlen(bp);
- }
-
- if (acs_ulcorner && acs_ulcorner[1] == '\0') {
- *bp++ = 'l';
- *bp++ = *acs_ulcorner;
- }
- if (acs_llcorner && acs_llcorner[1] == '\0') {
- *bp++ = 'm';
- *bp++ = *acs_llcorner;
- }
- if (acs_urcorner && acs_urcorner[1] == '\0') {
- *bp++ = 'k';
- *bp++ = *acs_urcorner;
- }
- if (acs_lrcorner && acs_lrcorner[1] == '\0') {
- *bp++ = 'j';
- *bp++ = *acs_lrcorner;
- }
- if (acs_ltee && acs_ltee[1] == '\0') {
- *bp++ = 't';
- *bp++ = *acs_ltee;
- }
- if (acs_rtee && acs_rtee[1] == '\0') {
- *bp++ = 'u';
- *bp++ = *acs_rtee;
- }
- if (acs_btee && acs_btee[1] == '\0') {
- *bp++ = 'v';
- *bp++ = *acs_btee;
- }
- if (acs_ttee && acs_ttee[1] == '\0') {
- *bp++ = 'w';
- *bp++ = *acs_ttee;
- }
- if (acs_hline && acs_hline[1] == '\0') {
- *bp++ = 'q';
- *bp++ = *acs_hline;
- }
- if (acs_vline && acs_vline[1] == '\0') {
- *bp++ = 'x';
- *bp++ = *acs_vline;
- }
- if (acs_plus) {
- *bp++ = 'n';
- strcpy(bp, acs_plus);
- bp = buf2 + strlen(buf2);
- }
-
- if (bp != buf2) {
- *bp++ = '\0';
+ char buf2[MAX_TERMCAP_LENGTH];
+
+ _nc_str_init(&result, buf2, sizeof(buf2));
+ _nc_safe_strcat(&result, acs_chars);
+
+ append_acs (&result, 'j', acs_lrcorner);
+ append_acs (&result, 'k', acs_urcorner);
+ append_acs (&result, 'l', acs_ulcorner);
+ append_acs (&result, 'm', acs_llcorner);
+ append_acs (&result, 'n', acs_plus);
+ append_acs (&result, 'q', acs_hline);
+ append_acs (&result, 't', acs_ltee);
+ append_acs (&result, 'u', acs_rtee);
+ append_acs (&result, 'v', acs_btee);
+ append_acs (&result, 'w', acs_ttee);
+ append_acs (&result, 'x', acs_vline);
+
+ if (buf2[0]) {
acs_chars = _nc_save_str(buf2);
_nc_warning("acsc string synthesized from XENIX capabilities");
}
} else if (acs_chars == 0
- && enter_alt_charset_mode != 0
- && exit_alt_charset_mode != 0) {
+ && enter_alt_charset_mode != 0
+ && exit_alt_charset_mode != 0) {
acs_chars =
_nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
}
}
-static
-void
+static void
postprocess_terminfo(TERMTYPE * tp)
{
/*
@@ -888,60 +879,25 @@ postprocess_terminfo(TERMTYPE * tp)
* Translate AIX forms characters.
*/
if (PRESENT(box_chars_1)) {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
-
- if (acs_chars) {
- (void) strcpy(bp, acs_chars);
- bp += strlen(bp);
- }
-
- if (box_chars_1[0]) { /* ACS_ULCORNER */
- *bp++ = 'l';
- *bp++ = box_chars_1[0];
- }
- if (box_chars_1[1]) { /* ACS_HLINE */
- *bp++ = 'q';
- *bp++ = box_chars_1[1];
- }
- if (box_chars_1[2]) { /* ACS_URCORNER */
- *bp++ = 'k';
- *bp++ = box_chars_1[2];
- }
- if (box_chars_1[3]) { /* ACS_VLINE */
- *bp++ = 'x';
- *bp++ = box_chars_1[3];
- }
- if (box_chars_1[4]) { /* ACS_LRCORNER */
- *bp++ = 'j';
- *bp++ = box_chars_1[4];
- }
- if (box_chars_1[5]) { /* ACS_LLCORNER */
- *bp++ = 'm';
- *bp++ = box_chars_1[5];
- }
- if (box_chars_1[6]) { /* ACS_TTEE */
- *bp++ = 'w';
- *bp++ = box_chars_1[6];
- }
- if (box_chars_1[7]) { /* ACS_RTEE */
- *bp++ = 'u';
- *bp++ = box_chars_1[7];
- }
- if (box_chars_1[8]) { /* ACS_BTEE */
- *bp++ = 'v';
- *bp++ = box_chars_1[8];
- }
- if (box_chars_1[9]) { /* ACS_LTEE */
- *bp++ = 't';
- *bp++ = box_chars_1[9];
- }
- if (box_chars_1[10]) { /* ACS_PLUS */
- *bp++ = 'n';
- *bp++ = box_chars_1[10];
- }
-
- if (bp != buf2) {
- *bp++ = '\0';
+ char buf2[MAX_TERMCAP_LENGTH];
+ string_desc result;
+
+ _nc_str_init(&result, buf2, sizeof(buf2));
+ _nc_safe_strcat(&result, acs_chars);
+
+ append_acs0 (&result, 'l', box_chars_1[0]); /* ACS_ULCORNER */
+ append_acs0 (&result, 'q', box_chars_1[1]); /* ACS_HLINE */
+ append_acs0 (&result, 'k', box_chars_1[2]); /* ACS_URCORNER */
+ append_acs0 (&result, 'x', box_chars_1[3]); /* ACS_VLINE */
+ append_acs0 (&result, 'j', box_chars_1[4]); /* ACS_LRCORNER */
+ append_acs0 (&result, 'm', box_chars_1[5]); /* ACS_LLCORNER */
+ append_acs0 (&result, 'w', box_chars_1[6]); /* ACS_TTEE */
+ append_acs0 (&result, 'u', box_chars_1[7]); /* ACS_RTEE */
+ append_acs0 (&result, 'v', box_chars_1[8]); /* ACS_BTEE */
+ append_acs0 (&result, 't', box_chars_1[9]); /* ACS_LTEE */
+ append_acs0 (&result, 'n', box_chars_1[10]); /* ACS_PLUS */
+
+ if (buf2[0]) {
acs_chars = _nc_save_str(buf2);
_nc_warning("acsc string synthesized from AIX capabilities");
box_chars_1 = ABSENT_STRING;
@@ -960,8 +916,7 @@ postprocess_terminfo(TERMTYPE * tp)
* up in _nc_info_table, which is organized so that the nte_index fields are
* sorted, but the nte_type fields are not necessarily grouped together.
*/
-static
-struct name_table_entry const *
+static struct name_table_entry const *
lookup_fullname(const char *find)
{
int state = -1;
@@ -988,7 +943,7 @@ lookup_fullname(const char *find)
if (!strcmp(names[count], find)) {
struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
while (entry_ptr->nte_type != state
- || entry_ptr->nte_index != count)
+ || entry_ptr->nte_index != count)
entry_ptr++;
return entry_ptr;
}
diff --git a/lib/libcurses/tinfo/read_bsd_terminfo.c b/lib/libcurses/tinfo/read_bsd_terminfo.c
index 45d308e7b10..7ff1b6e243f 100644
--- a/lib/libcurses/tinfo/read_bsd_terminfo.c
+++ b/lib/libcurses/tinfo/read_bsd_terminfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read_bsd_terminfo.c,v 1.8 2000/08/02 04:10:47 millert Exp $ */
+/* $OpenBSD: read_bsd_terminfo.c,v 1.9 2000/10/08 22:47:02 millert Exp $ */
/*
* Copyright (c) 1998, 1999, 2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -28,7 +28,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: read_bsd_terminfo.c,v 1.8 2000/08/02 04:10:47 millert Exp $";
+static char rcsid[] = "$OpenBSD: read_bsd_terminfo.c,v 1.9 2000/10/08 22:47:02 millert Exp $";
#endif
#include <curses.priv.h>
@@ -60,14 +60,14 @@ _nc_read_bsd_terminfo_entry(tn, filename, tp)
fname = pathvec;
/* $TERMINFO may hold a path to a terminfo file */
- if (!issetugid() && (p = getenv("TERMINFO")) != NULL) {
+ if (use_terminfo_vars() && (p = getenv("TERMINFO")) != NULL) {
len = strlcpy(envterm, p, sizeof(envterm));
if (len < sizeof(envterm))
*fname++ = envterm;
}
/* Also check $HOME/.terminfo if it exists */
- if (!issetugid() && (p = getenv("HOME")) != NULL && *p != '\0') {
+ if (use_terminfo_vars() && (p = getenv("HOME")) != NULL && *p != '\0') {
len = snprintf(hometerm, sizeof(hometerm), "%s/.terminfo", p);
if (len < sizeof(hometerm))
*fname++ = hometerm;
diff --git a/lib/libcurses/tinfo/read_entry.c b/lib/libcurses/tinfo/read_entry.c
index f4d07feaf50..f662136e9a1 100644
--- a/lib/libcurses/tinfo/read_entry.c
+++ b/lib/libcurses/tinfo/read_entry.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read_entry.c,v 1.9 2000/03/13 23:53:40 millert Exp $ */
+/* $OpenBSD: read_entry.c,v 1.10 2000/10/08 22:47:03 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -43,7 +43,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: read_entry.c,v 1.67 2000/03/11 12:35:45 tom Exp $")
+MODULE_ID("$From: read_entry.c,v 1.68 2000/10/04 02:32:04 tom Exp $")
#if !HAVE_TELL
#define tell(fd) 0 /* lseek() is POSIX, but not tell() - odd... */
@@ -81,9 +81,9 @@ _nc_tic_dir(const char *path)
if (path != 0) {
result = path;
have_tic_directory = TRUE;
- } else if (!have_tic_directory) {
+ } else if (!have_tic_directory && use_terminfo_vars()) {
char *envp;
- if (!issetugid() && (envp = getenv("TERMINFO")) != 0)
+ if ((envp = getenv("TERMINFO")) != 0)
return _nc_tic_dir(envp);
}
}
@@ -484,19 +484,22 @@ _nc_read_entry(const char *const tn, char *const filename, TERMTYPE * const tp)
&& _nc_read_tic_entry(filename, _nc_tic_dir(0), ttn, tp) == 1)
return 1;
- if (!issetugid() && (envp = getenv("TERMINFO")) != 0
- && _nc_read_tic_entry(filename, _nc_tic_dir(envp), ttn, tp) == 1)
- return 1;
+ if (use_terminfo_vars()) {
+ if ((envp = getenv("TERMINFO")) != 0
+ && _nc_read_tic_entry(filename, _nc_tic_dir(envp), ttn, tp) == 1)
+ return 1;
- if ((envp = _nc_home_terminfo()) != 0) {
- if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
- return (1);
+ /* this is an ncurses extension */
+ if ((envp = _nc_home_terminfo()) != 0) {
+ if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
+ return (1);
+ }
}
- }
- /* this is an ncurses extension */
- if (!issetugid() && (envp = getenv("TERMINFO_DIRS")) != 0)
- return _nc_read_terminfo_dirs(envp, filename, ttn, tp);
+ /* this is an ncurses extension */
+ if ((envp = getenv("TERMINFO_DIRS")) != 0)
+ return _nc_read_terminfo_dirs(envp, filename, ttn, tp);
+ }
/* Try the system directory. Note that the TERMINFO_DIRS value, if
* defined by the configure script, begins with a ":", which will be
diff --git a/lib/libcurses/tinfo/read_termcap.c b/lib/libcurses/tinfo/read_termcap.c
index be34f0defd5..d1ff65a1354 100644
--- a/lib/libcurses/tinfo/read_termcap.c
+++ b/lib/libcurses/tinfo/read_termcap.c
@@ -1,5 +1,3 @@
-/* $OpenBSD: read_termcap.c,v 1.11 2000/10/02 22:31:10 millert Exp $ */
-
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
* *
@@ -57,9 +55,9 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: read_termcap.c,v 1.47 2000/04/15 16:53:19 Todd.C.Miller Exp $")
+MODULE_ID("$From: read_termcap.c,v 1.49 2000/10/05 00:37:19 tom Exp $")
-#ifndef PURE_TERMINFO
+#if !PURE_TERMINFO
#ifdef __EMX__
#define is_pathname(s) ((((s) != 0) && ((s)[0] == '/')) \
@@ -779,12 +777,13 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
char **pvec; /* holds usable tail of path vector */
char *termpath;
+ string_desc desc;
fname = pathvec;
pvec = pathvec;
tbuf = bp;
p = pathbuf;
- cp = issetugid() ? NULL : getenv("TERMCAP");
+ cp = use_terminfo_vars() ? getenv("TERMCAP") : NULL;
/*
* TERMCAP can have one of two things in it. It can be the name of a file
@@ -795,25 +794,28 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
* instead. The path is found in the TERMPATH variable, or becomes
* "$HOME/.termcap /etc/termcap" if no TERMPATH exists.
*/
-#define MY_PATH_DEF "/etc/termcap /usr/share/misc/termcap"
- if (issetugid())
- strlcpy(pathbuf, MY_PATH_DEF, PBUFSIZ);
- else {
- if (!is_pathname(cp)) { /* no TERMCAP or it holds an entry */
- if ((termpath = getenv("TERMPATH")) != 0) {
- strlcpy(pathbuf, termpath, PBUFSIZ);
- } else {
- if ((home = getenv("HOME")) != 0 && *home != '\0' &&
- strlen(home) < PBUFSIZ) { /* setup path */
- p += strlen(home); /* path, looking in */
- strcpy(pathbuf, home); /* $HOME first */
- *p++ = '/';
- } /* if no $HOME look in cwd */
- strlcpy(p, ".termcap " MY_PATH_DEF,
- (size_t) (PBUFSIZ - (p - pathbuf)));
+ _nc_str_init(&desc, pathbuf, sizeof(pathbuf));
+ if (cp == NULL) {
+ _nc_safe_strcpy(&desc, "/usr/share/misc/termcap /etc/termcap");
+ } else if (!is_pathname(cp)) { /* TERMCAP holds an entry */
+ if ((termpath = getenv("TERMPATH")) != 0) {
+ _nc_safe_strcat(&desc, termpath);
+ } else {
+ char temp[PBUFSIZ];
+ size_t len;
+ temp[0] = 0;
+ if ((home = getenv("HOME")) != 0 && *home != '\0'
+ && strchr(home, ' ') == 0) { /* setup path */
+ len = snprintf(temp, sizeof(temp), "%s/.termcap", home);
+ if (len < sizeof(temp)) {
+ _nc_safe_strcat(&desc, temp);
+ }
}
- } else /* user-defined name in TERMCAP */
- strlcpy(pathbuf, cp, PBUFSIZ); /* still can be tokenized */
+ _nc_safe_strcat(&desc, " /usr/share/misc/termcap");
+ _nc_safe_strcat(&desc, " /etc/termcap");
+ }
+ } else { /* user-defined name in TERMCAP */
+ _nc_safe_strcat(&desc, cp); /* still can be tokenized */
}
*fname++ = pathbuf; /* tokenize path into vector of names */
@@ -927,7 +929,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
static char *source;
static int lineno;
- if (!issetugid() && (p = getenv("TERMCAP")) != 0
+ if (use_terminfo_vars() && (p = getenv("TERMCAP")) != 0
&& !is_pathname(p) && _nc_name_match(p, tn, "|:")) {
/* TERMCAP holds a termcap entry */
strlcpy(tc, p, sizeof(tc));
@@ -976,7 +978,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
char pathbuf[PATH_MAX];
termpaths[filecount] = 0;
- if (!issetugid() && (tc = getenv("TERMCAP"))) {
+ if (use_terminfo_vars() && (tc = getenv("TERMCAP")) != 0) {
if (is_pathname(tc)) { /* interpret as a filename */
ADD_TC(tc, 0);
} else if (_nc_name_match(tc, tn, "|:")) { /* treat as a capability file */
@@ -1009,7 +1011,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
#define PRIVATE_CAP "%s/.termcap"
- if (!issetugid() && (h = getenv("HOME")) != NULL && *home != '\0'
+ if (use_terminfo_vars() && (h = getenv("HOME")) != NULL && *h != '\0'
&& (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) {
/* user's .termcap, if any, should override it */
(void) strcpy(envhome, h);
diff --git a/lib/libcurses/tinfo/strings.c b/lib/libcurses/tinfo/strings.c
new file mode 100644
index 00000000000..28b55f0b9dc
--- /dev/null
+++ b/lib/libcurses/tinfo/strings.c
@@ -0,0 +1,141 @@
+/* $OpenBSD: strings.c,v 1.1 2000/10/08 22:47:03 millert Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+/*
+** lib_mvcur.c
+**/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id")
+
+/****************************************************************************
+ * Useful string functions (especially for mvcur)
+ ****************************************************************************/
+
+#if !HAVE_STRSTR
+char *
+_nc_strstr(const char *haystack, const char *needle)
+{
+ size_t len1 = strlen(haystack);
+ size_t len2 = strlen(needle);
+ char *result = 0;
+
+ while ((len1 != 0) && (len1-- >= len2)) {
+ if (!strncmp(haystack, needle, len2)) {
+ result = haystack;
+ break;
+ }
+ haystack++;
+ }
+ return result;
+}
+#endif
+
+/*
+ * Initialize the descriptor so we can append to it.
+ */
+string_desc *
+_nc_str_init(string_desc * dst, char *src, size_t len)
+{
+ if (dst != 0) {
+ dst->s_head = src;
+ dst->s_tail = src;
+ dst->s_size = len - 1;
+ if (src != 0)
+ *src = 0;
+ }
+ return dst;
+}
+
+/*
+ * Initialize the descriptor for only tracking the amount of memory used.
+ */
+string_desc *
+_nc_str_null(string_desc * dst, size_t len)
+{
+ return _nc_str_init(dst, 0, len);
+}
+
+/*
+ * Copy a descriptor
+ */
+string_desc *
+_nc_str_copy(string_desc * dst, string_desc * src)
+{
+ *dst = *src;
+ return dst;
+}
+
+/*
+ * Replaces strcat into a fixed buffer, returning false on failure.
+ */
+bool
+_nc_safe_strcat(string_desc * dst, const char *src)
+{
+ if (src != 0) {
+ size_t len = strlen(src);
+
+ if (len < dst->s_size) {
+ if (dst->s_tail != 0) {
+ strcpy(dst->s_tail, src);
+ dst->s_tail += len;
+ }
+ dst->s_size -= len;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/*
+ * Replaces strcpy into a fixed buffer, returning false on failure.
+ */
+bool
+_nc_safe_strcpy(string_desc * dst, const char *src)
+{
+ if (src != 0) {
+ size_t len = strlen(src);
+
+ if (len < dst->s_size) {
+ if (dst->s_head != 0) {
+ strcpy(dst->s_head, src);
+ dst->s_tail = dst->s_head + len;
+ }
+ dst->s_size -= len;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
diff --git a/lib/libcurses/tinfo/write_entry.c b/lib/libcurses/tinfo/write_entry.c
index fb9599ddb43..b282d069c81 100644
--- a/lib/libcurses/tinfo/write_entry.c
+++ b/lib/libcurses/tinfo/write_entry.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: write_entry.c,v 1.8 2000/03/13 23:53:40 millert Exp $ */
+/* $OpenBSD: write_entry.c,v 1.9 2000/10/08 22:47:03 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -54,7 +54,7 @@
#define TRACE_OUT(p) /*nothing */
#endif
-MODULE_ID("$From: write_entry.c,v 1.52 2000/03/11 12:23:42 tom Exp $")
+MODULE_ID("$From: write_entry.c,v 1.53 2000/10/04 02:32:14 tom Exp $")
static int total_written;
@@ -118,10 +118,12 @@ _nc_set_writedir(char *dir)
const char *destination;
char actual[PATH_MAX];
+ if (dir == 0
+ && use_terminfo_vars())
+ dir = getenv("TERMINFO");
+
if (dir != 0)
(void) _nc_tic_dir(dir);
- else if (getenv("TERMINFO") != NULL)
- (void) _nc_tic_dir(getenv("TERMINFO"));
destination = _nc_tic_dir(0);
if (make_directory(destination) < 0) {
diff --git a/lib/libcurses/trace/lib_traceatr.c b/lib/libcurses/trace/lib_traceatr.c
index 58c86c8081a..30b601275d0 100644
--- a/lib/libcurses/trace/lib_traceatr.c
+++ b/lib/libcurses/trace/lib_traceatr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_traceatr.c,v 1.1 1999/01/18 19:10:23 millert Exp $ */
+/* $OpenBSD: lib_traceatr.c,v 1.2 2000/10/08 22:47:03 millert Exp $ */
/****************************************************************************
- * 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 *
@@ -33,27 +33,29 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* lib_traceatr.c - Tracing/Debugging routines (attributes)
*/
#include <curses.priv.h>
-#include <term.h> /* acs_chars */
+#include <term.h> /* acs_chars */
-MODULE_ID("$From: lib_traceatr.c,v 1.28 1998/03/21 18:39:36 tom Exp $")
+MODULE_ID("$From: lib_traceatr.c,v 1.30 2000/07/29 18:06:09 tom Exp $")
#define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
#ifdef TRACE
-char *_traceattr2(int bufnum, attr_t newmode)
+char *
+_traceattr2(int bufnum, attr_t newmode)
{
-char *buf = _nc_trace_buf(bufnum, BUFSIZ);
-char *tmp = buf;
-static const struct {unsigned int val; const char *name;}
-names[] =
+ char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+ char *tmp = buf;
+ static const struct {
+ unsigned int val;
+ const char *name;
+ } names[] =
{
+ /* *INDENT-OFF* */
{ A_STANDOUT, "A_STANDOUT" },
{ A_UNDERLINE, "A_UNDERLINE" },
{ A_REVERSE, "A_REVERSE" },
@@ -66,9 +68,12 @@ names[] =
{ A_CHARTEXT, "A_CHARTEXT" },
{ A_NORMAL, "A_NORMAL" },
{ A_COLOR, "A_COLOR" },
+ /* *INDENT-ON* */
+
},
-colors[] =
+ colors[] =
{
+ /* *INDENT-OFF* */
{ COLOR_BLACK, "COLOR_BLACK" },
{ COLOR_RED, "COLOR_RED" },
{ COLOR_GREEN, "COLOR_GREEN" },
@@ -77,122 +82,125 @@ colors[] =
{ COLOR_MAGENTA, "COLOR_MAGENTA" },
{ COLOR_CYAN, "COLOR_CYAN" },
{ COLOR_WHITE, "COLOR_WHITE" },
+ /* *INDENT-ON* */
+
};
-size_t n;
-unsigned save_nc_tracing = _nc_tracing;
- _nc_tracing = 0;
-
- strcpy(tmp++, "{");
-
- for (n = 0; n < SIZEOF(names); n++) {
- if ((newmode & names[n].val) != 0) {
- if (buf[1] != '\0')
- strcat(tmp, "|");
- strcat(tmp, names[n].name);
- tmp += strlen(tmp);
-
- if (names[n].val == A_COLOR)
- {
- short pairnum = PAIR_NUMBER(newmode);
- short fg, bg;
-
- if (pair_content(pairnum, &fg, &bg) == OK)
- (void) sprintf(tmp,
- "{%d = {%s, %s}}",
- pairnum,
- COLOR_OF(fg),
- COLOR_OF(bg)
- );
- else
- (void) sprintf(tmp, "{%d}", pairnum);
- }
- }
- }
- if (AttrOf(newmode) == A_NORMAL) {
- if (buf[1] != '\0')
- strcat(tmp, "|");
- strcat(tmp, "A_NORMAL");
+ size_t n;
+ unsigned save_nc_tracing = _nc_tracing;
+ _nc_tracing = 0;
+
+ strcpy(tmp++, "{");
+
+ for (n = 0; n < SIZEOF(names); n++) {
+ if ((newmode & names[n].val) != 0) {
+ if (buf[1] != '\0')
+ strcat(tmp, "|");
+ strcat(tmp, names[n].name);
+ tmp += strlen(tmp);
+
+ if (names[n].val == A_COLOR) {
+ short pairnum = PAIR_NUMBER(newmode);
+ short fg, bg;
+
+ if (pair_content(pairnum, &fg, &bg) == OK)
+ (void) sprintf(tmp,
+ "{%d = {%s, %s}}",
+ pairnum,
+ COLOR_OF(fg),
+ COLOR_OF(bg)
+ );
+ else
+ (void) sprintf(tmp, "{%d}", pairnum);
+ }
}
+ }
+ if (AttrOf(newmode) == A_NORMAL) {
+ if (buf[1] != '\0')
+ strcat(tmp, "|");
+ strcat(tmp, "A_NORMAL");
+ }
- _nc_tracing = save_nc_tracing;
- return (strcat(buf,"}"));
+ _nc_tracing = save_nc_tracing;
+ return (strcat(buf, "}"));
}
-char *_traceattr(attr_t newmode)
+char *
+_traceattr(attr_t newmode)
{
- return _traceattr2(0, newmode);
+ return _traceattr2(0, newmode);
}
/* Trace 'int' return-values */
-attr_t _nc_retrace_attr_t(attr_t code)
+attr_t
+_nc_retrace_attr_t(attr_t code)
{
- T((T_RETURN("%s"), _traceattr(code)));
- return code;
+ T((T_RETURN("%s"), _traceattr(code)));
+ return code;
}
-char *_tracechtype2(int bufnum, chtype ch)
+char *
+_tracechtype2(int bufnum, chtype ch)
{
-char *buf = _nc_trace_buf(bufnum, BUFSIZ);
-char *found = 0;
+ char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+ char *found = 0;
strcpy(buf, "{");
- if (ch & A_ALTCHARSET)
- {
- char *cp;
- static const struct {unsigned int val; const char *name;}
- names[] =
+ if (ch & A_ALTCHARSET) {
+ char *cp;
+ static const struct {
+ unsigned int val;
+ const char *name;
+ } names[] =
{
- {'l', "ACS_ULCORNER"}, /* upper left corner */
- {'m', "ACS_LLCORNER"}, /* lower left corner */
- {'k', "ACS_URCORNER"}, /* upper right corner */
- {'j', "ACS_LRCORNER"}, /* lower right corner */
- {'t', "ACS_LTEE"}, /* tee pointing right */
- {'u', "ACS_RTEE"}, /* tee pointing left */
- {'v', "ACS_BTEE"}, /* tee pointing up */
- {'w', "ACS_TTEE"}, /* tee pointing down */
- {'q', "ACS_HLINE"}, /* horizontal line */
- {'x', "ACS_VLINE"}, /* vertical line */
- {'n', "ACS_PLUS"}, /* large plus or crossover */
- {'o', "ACS_S1"}, /* scan line 1 */
- {'s', "ACS_S9"}, /* scan line 9 */
- {'`', "ACS_DIAMOND"}, /* diamond */
- {'a', "ACS_CKBOARD"}, /* checker board (stipple) */
- {'f', "ACS_DEGREE"}, /* degree symbol */
- {'g', "ACS_PLMINUS"}, /* plus/minus */
- {'~', "ACS_BULLET"}, /* bullet */
- {',', "ACS_LARROW"}, /* arrow pointing left */
- {'+', "ACS_RARROW"}, /* arrow pointing right */
- {'.', "ACS_DARROW"}, /* arrow pointing down */
- {'-', "ACS_UARROW"}, /* arrow pointing up */
- {'h', "ACS_BOARD"}, /* board of squares */
- {'i', "ACS_LANTERN"}, /* lantern symbol */
- {'0', "ACS_BLOCK"}, /* solid square block */
- {'p', "ACS_S3"}, /* scan line 3 */
- {'r', "ACS_S7"}, /* scan line 7 */
- {'y', "ACS_LEQUAL"}, /* less/equal */
- {'z', "ACS_GEQUAL"}, /* greater/equal */
- {'{', "ACS_PI"}, /* Pi */
- {'|', "ACS_NEQUAL"}, /* not equal */
- {'}', "ACS_STERLING"}, /* UK pound sign */
- {'\0',(char *)0}
+ /* *INDENT-OFF* */
+ { 'l', "ACS_ULCORNER" }, /* upper left corner */
+ { 'm', "ACS_LLCORNER" }, /* lower left corner */
+ { 'k', "ACS_URCORNER" }, /* upper right corner */
+ { 'j', "ACS_LRCORNER" }, /* lower right corner */
+ { 't', "ACS_LTEE" }, /* tee pointing right */
+ { 'u', "ACS_RTEE" }, /* tee pointing left */
+ { 'v', "ACS_BTEE" }, /* tee pointing up */
+ { 'w', "ACS_TTEE" }, /* tee pointing down */
+ { 'q', "ACS_HLINE" }, /* horizontal line */
+ { 'x', "ACS_VLINE" }, /* vertical line */
+ { 'n', "ACS_PLUS" }, /* large plus or crossover */
+ { 'o', "ACS_S1" }, /* scan line 1 */
+ { 's', "ACS_S9" }, /* scan line 9 */
+ { '`', "ACS_DIAMOND" }, /* diamond */
+ { 'a', "ACS_CKBOARD" }, /* checker board (stipple) */
+ { 'f', "ACS_DEGREE" }, /* degree symbol */
+ { 'g', "ACS_PLMINUS" }, /* plus/minus */
+ { '~', "ACS_BULLET" }, /* bullet */
+ { ',', "ACS_LARROW" }, /* arrow pointing left */
+ { '+', "ACS_RARROW" }, /* arrow pointing right */
+ { '.', "ACS_DARROW" }, /* arrow pointing down */
+ { '-', "ACS_UARROW" }, /* arrow pointing up */
+ { 'h', "ACS_BOARD" }, /* board of squares */
+ { 'i', "ACS_LANTERN" }, /* lantern symbol */
+ { '0', "ACS_BLOCK" }, /* solid square block */
+ { 'p', "ACS_S3" }, /* scan line 3 */
+ { 'r', "ACS_S7" }, /* scan line 7 */
+ { 'y', "ACS_LEQUAL" }, /* less/equal */
+ { 'z', "ACS_GEQUAL" }, /* greater/equal */
+ { '{', "ACS_PI" }, /* Pi */
+ { '|', "ACS_NEQUAL" }, /* not equal */
+ { '}', "ACS_STERLING" }, /* UK pound sign */
+ { '\0', (char *) 0 }
+ /* *INDENT-OFF* */
},
- *sp;
+ *sp;
- for (cp = acs_chars; cp[0] && cp[1]; cp += 2)
- {
- if (TextOf(cp[1]) == TextOf(ch))
- {
+ for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
+ if (TextOf(cp[1]) == TextOf(ch)) {
found = cp;
/* don't exit from loop - there may be redefinitions */
}
}
- if (found != 0)
- {
+ if (found != 0) {
ch = TextOf(*found);
for (sp = names; sp->val; sp++)
- if (sp->val == ch)
- {
+ if (sp->val == ch) {
(void) strcat(buf, sp->name);
ch &= ~A_ALTCHARSET;
break;
@@ -204,17 +212,31 @@ char *found = 0;
(void) strcat(buf, _tracechar(TextOf(ch)));
if (AttrOf(ch) != A_NORMAL)
- (void) sprintf(buf + strlen(buf), " | %s", _traceattr2(bufnum+20,AttrOf(ch)));
+ (void) sprintf(buf + strlen(buf), " | %s",
+ _traceattr2(bufnum + 20, AttrOf(ch)));
strcat(buf, "}");
- return(buf);
+ return (buf);
}
-char *_tracechtype(chtype ch)
+char *
+_tracechtype(chtype ch)
{
- return _tracechtype2(0, ch);
+ return _tracechtype2(0, ch);
}
+
+/* Trace 'chtype' return-values */
+attr_t
+_nc_retrace_chtype(attr_t code)
+{
+ T((T_RETURN("%s"), _tracechtype(code)));
+ return code;
+}
+
#else
-extern void _nc_lib_traceatr(void);
- void _nc_lib_traceatr(void) { }
+extern void _nc_lib_traceatr(void);
+void
+_nc_lib_traceatr(void)
+{
+}
#endif /* TRACE */
diff --git a/lib/libcurses/trace/lib_tracebits.c b/lib/libcurses/trace/lib_tracebits.c
index 2460c4d8b95..494998dd73d 100644
--- a/lib/libcurses/trace/lib_tracebits.c
+++ b/lib/libcurses/trace/lib_tracebits.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_tracebits.c,v 1.6 2000/07/24 04:06:11 millert Exp $ */
+/* $OpenBSD: lib_tracebits.c,v 1.7 2000/10/08 22:47:04 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -36,9 +36,9 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$From: lib_tracebits.c,v 1.6 2000/07/23 00:22:32 tom Exp $")
+MODULE_ID("$From: lib_tracebits.c,v 1.7 2000/09/02 18:08:37 tom Exp $")
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
diff --git a/lib/libcurses/tty/MKexpanded.sh b/lib/libcurses/tty/MKexpanded.sh
index 11e9fc16878..2c4ef80d427 100644
--- a/lib/libcurses/tty/MKexpanded.sh
+++ b/lib/libcurses/tty/MKexpanded.sh
@@ -1,6 +1,6 @@
#! /bin/sh
##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc. #
+# Copyright (c) 1998,2000 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -29,8 +29,8 @@
#
# Author: Thomas E. Dickey <dickey@clark.net> 1997
#
-# $OpenBSD: MKexpanded.sh,v 1.1 1999/01/18 19:10:25 millert Exp $
-# $From: MKexpanded.sh,v 1.7 1998/11/11 20:15:39 Alexander.V.Lukyanov Exp $
+# $OpenBSD: MKexpanded.sh,v 1.2 2000/10/08 22:47:04 millert Exp $
+# $From: MKexpanded.sh,v 1.9 2000/09/02 22:55:21 tom Exp $
#
# Script to generate 'expanded.c', a dummy source that contains functions
# corresponding to complex macros used in this library. By making functions,
@@ -55,7 +55,7 @@ cat <<EOF
/* generated by MKexpanded.sh */
#include <curses.priv.h>
#include <term.h>
-#ifdef NCURSES_EXPANDED
+#if NCURSES_EXPANDED
EOF
cat >$TMP <<EOF
@@ -77,10 +77,6 @@ void _nc_toggle_attr_off(attr_t *S, attr_t at)
{
toggle_attr_off(*S,at);
}
-int _nc_can_clear_with(chtype ch)
-{
- return can_clear_with(ch);
-}
int _nc_DelCharCost(int count)
{
return DelCharCost(count);
diff --git a/lib/libcurses/tty/lib_mvcur.c b/lib/libcurses/tty/lib_mvcur.c
index 7672c928963..0c72f2b5c96 100644
--- a/lib/libcurses/tty/lib_mvcur.c
+++ b/lib/libcurses/tty/lib_mvcur.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_mvcur.c,v 1.8 2000/07/10 03:06:16 millert Exp $ */
+/* $OpenBSD: lib_mvcur.c,v 1.9 2000/10/08 22:47:04 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -154,9 +154,7 @@
#include <term.h>
#include <ctype.h>
-MODULE_ID("$From: lib_mvcur.c,v 1.67 2000/06/24 21:13:51 tom Exp $")
-
-#define STRLEN(s) (s != 0) ? strlen(s) : 0
+MODULE_ID("$From: lib_mvcur.c,v 1.72 2000/10/08 00:58:25 tom Exp $")
#define CURRENT_ROW SP->_cursrow /* phys cursor row */
#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
@@ -176,25 +174,6 @@ static float diff;
static int normalized_cost(const char *const cap, int affcnt);
-#if !HAVE_STRSTR
-char *
-_nc_strstr(const char *haystack, const char *needle)
-{
- size_t len1 = strlen(haystack);
- size_t len2 = strlen(needle);
- char *result = 0;
-
- while ((len1 != 0) && (len1-- >= len2)) {
- if (!strncmp(haystack, needle, len2)) {
- result = haystack;
- break;
- }
- haystack++;
- }
- return result;
-}
-#endif
-
/****************************************************************************
*
* Initialization/wrapup (including cost pre-computation)
@@ -207,7 +186,7 @@ trace_cost_of(const char *capname, const char *cap, int affcnt)
{
int result = _nc_msec_cost(cap, affcnt);
TR(TRACE_CHARPUT | TRACE_MOVE,
- ("CostOf %s %d %s", capname, result, _nc_visbuf(cap)));
+ ("CostOf %s %d %s", capname, result, _nc_visbuf(cap)));
return result;
}
#define CostOf(cap,affcnt) trace_cost_of(#cap,cap,affcnt);
@@ -217,7 +196,7 @@ trace_normalized_cost(const char *capname, const char *cap, int affcnt)
{
int result = normalized_cost(cap, affcnt);
TR(TRACE_CHARPUT | TRACE_MOVE,
- ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap)));
+ ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap)));
return result;
}
#define NormalizedCost(cap,affcnt) trace_normalized_cost(#cap,cap,affcnt);
@@ -237,12 +216,12 @@ _nc_msec_cost(const char *const cap, int affcnt)
return (INFINITY);
else {
const char *cp;
- float cum_cost = 0;
+ float cum_cost = 0.0;
for (cp = cap; *cp; cp++) {
/* extract padding, either mandatory or required */
if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) {
- float number = 0;
+ float number = 0.0;
for (cp += 2; *cp != '>'; cp++) {
if (isdigit(*cp))
@@ -253,7 +232,7 @@ _nc_msec_cost(const char *const cap, int affcnt)
number += (*cp - '0') / 10.0;
}
-#ifdef NCURSES_NO_PADDING
+#if NCURSES_NO_PADDING
if (!(SP->_no_padding))
#endif
cum_cost += number * 10;
@@ -404,13 +383,8 @@ _nc_mvcur_init(void)
SP->_hpa_ch_cost = NormalizedCost(tparm(column_address, 23), 1);
SP->_cuf_ch_cost = NormalizedCost(tparm(parm_right_cursor, 23), 1);
SP->_inline_cost = min(SP->_cup_ch_cost,
- min(SP->_hpa_ch_cost,
- SP->_cuf_ch_cost));
-
- /* pre-compute some capability lengths */
- SP->_carriage_return_length = STRLEN(carriage_return);
- SP->_cursor_home_length = STRLEN(cursor_home);
- SP->_cursor_to_ll_length = STRLEN(cursor_to_ll);
+ min(SP->_hpa_ch_cost,
+ SP->_cuf_ch_cost));
/*
* If save_cursor is used within enter_ca_mode, we should not use it for
@@ -470,18 +444,17 @@ _nc_mvcur_wrap(void)
* Perform repeated-append, returning cost
*/
static inline int
-repeated_append(int total, int num, int repeat, char *dst, const char *src)
+repeated_append(string_desc * target, int total, int num, int repeat, const char *src)
{
- register size_t src_len = strlen(src);
- register size_t dst_len = STRLEN(dst);
-
- if ((dst_len + repeat * src_len) < OPT_SIZE - 1) {
- total += (num * repeat);
- if (dst) {
- dst += dst_len;
- while (repeat-- > 0) {
- (void) strcpy(dst, src);
- dst += src_len;
+ size_t need = repeat * strlen(src);
+
+ if (need < target->s_size) {
+ while (repeat-- > 0) {
+ if (_nc_safe_strcat(target, src)) {
+ total += num;
+ } else {
+ total = INFINITY;
+ break;
}
}
} else {
@@ -499,53 +472,51 @@ repeated_append(int total, int num, int repeat, char *dst, const char *src)
*/
#define LASTTAB(fr) ((fr > 0) ? ((fr - 1) / init_tabs) * init_tabs : -1)
-/* Note: we'd like to inline this for speed, but GNU C barfs on the attempt. */
-
static int
-relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw)
+relative_move(string_desc * target, int from_y, int from_x, int to_y, int
+ to_x, bool ovw)
/* move via local motions (cuu/cuu1/cud/cud1/cub1/cub/cuf1/cuf/vpa/hpa) */
{
+ string_desc save;
int n, vcost = 0, hcost = 0;
- if (result)
- result[0] = '\0';
+ (void) _nc_str_copy(&save, target);
if (to_y != from_y) {
vcost = INFINITY;
- if (row_address) {
- if (result)
- (void) strcpy(result, tparm(row_address, to_y));
+ if (row_address != 0
+ && _nc_safe_strcat(target, tparm(row_address, to_y))) {
vcost = SP->_vpa_cost;
}
if (to_y > from_y) {
n = (to_y - from_y);
- if (parm_down_cursor && SP->_cud_cost < vcost) {
- if (result)
- (void) strcpy(result, tparm(parm_down_cursor, n));
+ if (parm_down_cursor
+ && SP->_cud_cost < vcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_down_cursor, n))) {
vcost = SP->_cud_cost;
}
if (cursor_down && (n * SP->_cud1_cost < vcost)) {
- if (result)
- result[0] = '\0';
- vcost = repeated_append(0, SP->_cud1_cost, n, result, cursor_down);
+ vcost = repeated_append(_nc_str_copy(target, &save), 0,
+ SP->_cud1_cost, n, cursor_down);
}
} else { /* (to_y < from_y) */
n = (from_y - to_y);
- if (parm_up_cursor && SP->_cup_cost < vcost) {
- if (result)
- (void) strcpy(result, tparm(parm_up_cursor, n));
+ if (parm_up_cursor
+ && SP->_cup_cost < vcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_up_cursor, n))) {
vcost = SP->_cup_cost;
}
if (cursor_up && (n * SP->_cuu1_cost < vcost)) {
- if (result)
- result[0] = '\0';
- vcost = repeated_append(0, SP->_cuu1_cost, n, result, cursor_up);
+ vcost = repeated_append(_nc_str_copy(target, &save), 0,
+ SP->_cuu1_cost, n, cursor_up);
}
}
@@ -553,33 +524,34 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
return (INFINITY);
}
- if (result)
- result += strlen(result);
+ save = *target;
if (to_x != from_x) {
char str[OPT_SIZE];
+ string_desc check;
hcost = INFINITY;
- if (column_address) {
- if (result)
- (void) strcpy(result, tparm(column_address, to_x));
+ if (column_address
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(column_address, to_x))) {
hcost = SP->_hpa_cost;
}
if (to_x > from_x) {
n = to_x - from_x;
- if (parm_right_cursor && SP->_cuf_cost < hcost) {
- if (result)
- (void) strcpy(result, tparm(parm_right_cursor, n));
+ if (parm_right_cursor
+ && SP->_cuf_cost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_right_cursor, n))) {
hcost = SP->_cuf_cost;
}
if (cursor_right) {
int lhcost = 0;
- str[0] = '\0';
+ (void) _nc_str_init(&check, str, sizeof(str));
#if USE_HARD_TABS
/* use hard tabs, if we have them, to do as much as possible */
@@ -587,8 +559,8 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
int nxt, fr;
for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt) {
- lhcost = repeated_append(lhcost, SP->_ht_cost, 1,
- str, tab);
+ lhcost = repeated_append(&check, lhcost,
+ SP->_ht_cost, 1, tab);
if (lhcost == INFINITY)
break;
}
@@ -599,7 +571,7 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
#endif /* USE_HARD_TABS */
#if defined(REAL_ATTR) && defined(WANT_CHAR)
-#ifdef BSD_TPUTS
+#if BSD_TPUTS
/*
* If we're allowing BSD-style padding in tputs, don't generate
* a string with a leading digit. Otherwise, that will be
@@ -608,6 +580,7 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
*/
if (ovw
&& n > 0
+ && n < (int) check.s_size
&& vcost == 0
&& str[0] == '\0'
&& isdigit(TextOf(WANT_CHAR(to_y, from_x))))
@@ -631,48 +604,47 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
}
}
if (ovw) {
- char *sp;
int i;
- sp = str + strlen(str);
-
for (i = 0; i < n; i++)
- *sp++ = WANT_CHAR(to_y, from_x + i);
- *sp = '\0';
+ *check.s_tail++ = WANT_CHAR(to_y, from_x + i);
+ *check.s_tail = '\0';
+ check.s_size -= n;
lhcost += n * SP->_char_padding;
} else
#endif /* defined(REAL_ATTR) && defined(WANT_CHAR) */
{
- lhcost = repeated_append(lhcost, SP->_cuf1_cost, n, str, cursor_right);
+ lhcost = repeated_append(&check, lhcost, SP->_cuf1_cost,
+ n, cursor_right);
}
- if (lhcost < hcost) {
- if (result)
- (void) strcpy(result, str);
+ if (lhcost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save), str)) {
hcost = lhcost;
}
}
} else { /* (to_x < from_x) */
n = from_x - to_x;
- if (parm_left_cursor && SP->_cub_cost < hcost) {
- if (result)
- (void) strcpy(result, tparm(parm_left_cursor, n));
+ if (parm_left_cursor
+ && SP->_cub_cost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save),
+ tparm(parm_left_cursor, n))) {
hcost = SP->_cub_cost;
}
if (cursor_left) {
int lhcost = 0;
- str[0] = '\0';
+ (void) _nc_str_init(&check, str, sizeof(str));
#if USE_HARD_TABS
if (init_tabs > 0 && back_tab) {
int nxt, fr;
for (fr = from_x; (nxt = LASTTAB(fr)) >= to_x; fr = nxt) {
- lhcost = repeated_append(lhcost, SP->_cbt_cost, 1,
- str, back_tab);
+ lhcost = repeated_append(&check, lhcost,
+ SP->_cbt_cost, 1, back_tab);
if (lhcost == INFINITY)
break;
}
@@ -681,11 +653,10 @@ relative_move(char *result, int from_y, int from_x, int to_y, int to_x, bool ovw
}
#endif /* USE_HARD_TABS */
- lhcost = repeated_append(lhcost, SP->_cub1_cost, n, str, cursor_left);
+ lhcost = repeated_append(&check, lhcost, SP->_cub1_cost, n, cursor_left);
- if (lhcost < hcost) {
- if (result)
- (void) strcpy(result, str);
+ if (lhcost < hcost
+ && _nc_safe_strcat(_nc_str_copy(target, &save), str)) {
hcost = lhcost;
}
}
@@ -714,7 +685,8 @@ static inline int
onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* onscreen move from (yold, xold) to (ynew, xnew) */
{
- char use[OPT_SIZE], *sp;
+ string_desc result;
+ char buffer[OPT_SIZE];
int tactic = 0, newcost, usecost = INFINITY;
int t5_cr_cost;
@@ -724,11 +696,12 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
gettimeofday(&before, NULL);
#endif /* MAIN */
+#define NullResult _nc_str_null(&result, sizeof(buffer))
+#define InitResult _nc_str_init(&result, buffer, sizeof(buffer))
+
/* tactic #0: use direct cursor addressing */
- sp = tparm(SP->_address_cursor, ynew, xnew);
- if (sp) {
+ if (_nc_safe_strcpy(InitResult, tparm(SP->_address_cursor, ynew, xnew))) {
tactic = 0;
- (void) strcpy(use, sp);
usecost = SP->_cup_cost;
#if defined(TRACE) || defined(NCURSES_TEST)
@@ -758,7 +731,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
#ifndef NO_OPTIMIZE
/* tactic #1: use local movement */
if (yold != -1 && xold != -1
- && ((newcost = relative_move(NULL, yold, xold, ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, yold, xold, ynew, xnew,
+ ovw)) != INFINITY)
&& newcost < usecost) {
tactic = 1;
usecost = newcost;
@@ -766,7 +740,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* tactic #2: use carriage-return + local movement */
if (yold != -1 && carriage_return
- && ((newcost = relative_move(NULL, yold, 0, ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, yold, 0, ynew, xnew, ovw))
+ != INFINITY)
&& SP->_cr_cost + newcost < usecost) {
tactic = 2;
usecost = SP->_cr_cost + newcost;
@@ -774,7 +749,7 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* tactic #3: use home-cursor + local movement */
if (cursor_home
- && ((newcost = relative_move(NULL, 0, 0, ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, 0, 0, ynew, xnew, ovw)) != INFINITY)
&& SP->_home_cost + newcost < usecost) {
tactic = 3;
usecost = SP->_home_cost + newcost;
@@ -782,8 +757,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* tactic #4: use home-down + local movement */
if (cursor_to_ll
- && ((newcost = relative_move(NULL, screen_lines - 1, 0, ynew, xnew,
- ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, screen_lines - 1, 0, ynew,
+ xnew, ovw)) != INFINITY)
&& SP->_ll_cost + newcost < usecost) {
tactic = 4;
usecost = SP->_ll_cost + newcost;
@@ -796,8 +771,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
t5_cr_cost = (xold > 0 ? SP->_cr_cost : 0);
if (auto_left_margin && !eat_newline_glitch
&& yold > 0 && cursor_left
- && ((newcost = relative_move(NULL, yold - 1, screen_columns - 1,
- ynew, xnew, ovw)) != INFINITY)
+ && ((newcost = relative_move(NullResult, yold - 1, screen_columns -
+ 1, ynew, xnew, ovw)) != INFINITY)
&& t5_cr_cost + SP->_cub1_cost + newcost < usecost) {
tactic = 5;
usecost = t5_cr_cost + SP->_cub1_cost + newcost;
@@ -806,32 +781,30 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/*
* These cases are ordered by estimated relative frequency.
*/
+ if (tactic)
+ InitResult;
switch (tactic) {
case 1:
- (void) relative_move(use, yold, xold, ynew, xnew, ovw);
+ (void) relative_move(&result, yold, xold, ynew, xnew, ovw);
break;
case 2:
- (void) strcpy(use, carriage_return);
- (void) relative_move(use + SP->_carriage_return_length,
- yold, 0, ynew, xnew, ovw);
+ (void) _nc_safe_strcpy(&result, carriage_return);
+ (void) relative_move(&result, yold, 0, ynew, xnew, ovw);
break;
case 3:
- (void) strcpy(use, cursor_home);
- (void) relative_move(use + SP->_cursor_home_length,
- 0, 0, ynew, xnew, ovw);
+ (void) _nc_safe_strcpy(&result, cursor_home);
+ (void) relative_move(&result, 0, 0, ynew, xnew, ovw);
break;
case 4:
- (void) strcpy(use, cursor_to_ll);
- (void) relative_move(use + SP->_cursor_to_ll_length,
- screen_lines - 1, 0, ynew, xnew, ovw);
+ (void) _nc_safe_strcpy(&result, cursor_to_ll);
+ (void) relative_move(&result, screen_lines - 1, 0, ynew, xnew, ovw);
break;
case 5:
- use[0] = '\0';
if (xold > 0)
- (void) strcat(use, carriage_return);
- (void) strcat(use, cursor_left);
- (void) relative_move(use + strlen(use),
- yold - 1, screen_columns - 1, ynew, xnew, ovw);
+ (void) _nc_safe_strcat(&result, carriage_return);
+ (void) _nc_safe_strcat(&result, cursor_left);
+ (void) relative_move(&result, yold - 1, screen_columns - 1, ynew,
+ xnew, ovw);
break;
}
#endif /* !NO_OPTIMIZE */
@@ -842,14 +815,14 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
+ (after.tv_sec - before.tv_sec) * 1000000;
if (!profiling)
(void) fprintf(stderr,
- "onscreen: %d msec, %f 28.8Kbps char-equivalents\n",
- (int) diff, diff / 288);
+ "onscreen: %d msec, %f 28.8Kbps char-equivalents\n",
+ (int) diff, diff / 288);
#endif /* MAIN */
nonlocal:
if (usecost != INFINITY) {
TPUTS_TRACE("mvcur");
- tputs(use, 1, _nc_outch);
+ tputs(buffer, 1, _nc_outch);
return (OK);
} else
return (ERR);
@@ -953,7 +926,7 @@ _nc_outch(int ch)
}
char PC = 0; /* used by termcap library */
-speed_t ospeed = 0; /* used by termcap library */
+short ospeed = 0; /* used by termcap library */
int _nc_nulls_sent = 0; /* used by 'tack' program */
int
@@ -1011,7 +984,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
(void) puts("s[croll] n t b m -- display scrolling sequence");
(void)
printf("r[eload] -- reload terminal info for %s\n",
- termname());
+ termname());
(void)
puts("l[oad] <term> -- load terminal info for type <term>");
(void) puts("d[elete] <cap> -- delete named capability");
@@ -1032,8 +1005,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
gettimeofday(&after, NULL);
printf("\" (%ld msec)\n",
- (long) (after.tv_usec - before.tv_usec + (after.tv_sec -
- before.tv_sec) * 1000000));
+ (long) (after.tv_usec - before.tv_usec
+ + (after.tv_sec - before.tv_sec)
+ * 1000000));
} else if (sscanf(buf, "s %d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
struct timeval before, after;
@@ -1044,8 +1018,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
gettimeofday(&after, NULL);
printf("\" (%ld msec)\n",
- (long) (after.tv_usec - before.tv_usec + (after.tv_sec -
- before.tv_sec) * 1000000));
+ (long) (after.tv_usec - before.tv_usec + (after.tv_sec -
+ before.tv_sec)
+ * 1000000));
} else if (buf[0] == 'r') {
(void) strcpy(tname, termname());
load_term();
@@ -1053,7 +1028,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
load_term();
} else if (sscanf(buf, "d %s", capname) == 1) {
struct name_table_entry const *np = _nc_find_entry(capname,
- _nc_info_hash_table);
+ _nc_info_hash_table);
if (np == NULL)
(void) printf("No such capability as \"%s\"\n", capname);
@@ -1063,19 +1038,19 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
cur_term->type.Booleans[np->nte_index] = FALSE;
(void)
printf("Boolean capability `%s' (%d) turned off.\n",
- np->nte_name, np->nte_index);
+ np->nte_name, np->nte_index);
break;
case NUMBER:
cur_term->type.Numbers[np->nte_index] = ABSENT_NUMERIC;
(void) printf("Number capability `%s' (%d) set to -1.\n",
- np->nte_name, np->nte_index);
+ np->nte_name, np->nte_index);
break;
case STRING:
cur_term->type.Strings[np->nte_index] = ABSENT_STRING;
(void) printf("String capability `%s' (%d) deleted.\n",
- np->nte_name, np->nte_index);
+ np->nte_name, np->nte_index);
break;
}
}
@@ -1112,7 +1087,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
* is winning.
*/
else if (sscanf(buf, "t %d", &n) == 1) {
- float cumtime = 0, perchar;
+ float cumtime = 0.0, perchar;
int speeds[] =
{2400, 9600, 14400, 19200, 28800, 38400, 0};
@@ -1150,7 +1125,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
perchar = cumtime / n;
(void) printf("%d moves (%ld chars) in %d msec, %f msec each:\n",
- n, xmits, (int) cumtime, perchar);
+ n, xmits, (int) cumtime, perchar);
for (i = 0; speeds[i]; i++) {
/*
@@ -1169,7 +1144,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
(void)
printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n",
- speeds[i], overhead, totalest);
+ speeds[i], overhead, totalest);
}
} else if (buf[0] == 'c') {
(void) printf("char padding: %d\n", SP->_char_padding);
diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c
index 08c6fec917a..e3f0e36e372 100644
--- a/lib/libcurses/tty/lib_tstp.c
+++ b/lib/libcurses/tty/lib_tstp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tstp.c,v 1.6 2000/06/19 03:53:54 millert Exp $ */
+/* $OpenBSD: lib_tstp.c,v 1.7 2000/10/08 22:47:05 millert 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 *
@@ -33,7 +33,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
** lib_tstp.c
**
@@ -46,11 +45,11 @@
#include <signal.h>
#include <SigAction.h>
-#if defined(SVR4_ACTION) && !defined(_POSIX_SOURCE)
+#if SVR4_ACTION && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
-MODULE_ID("$From: lib_tstp.c,v 1.21 2000/05/20 23:28:56 tom Exp $")
+MODULE_ID("$From: lib_tstp.c,v 1.22 2000/09/02 18:33:17 tom Exp $")
#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
#define USE_SIGTSTP 1
@@ -102,151 +101,152 @@ MODULE_ID("$From: lib_tstp.c,v 1.21 2000/05/20 23:28:56 tom Exp $")
*/
#if USE_SIGTSTP
-static void tstp(int dummy GCC_UNUSED)
+static void
+tstp(int dummy GCC_UNUSED)
{
- sigset_t mask, omask;
- sigaction_t act, oact;
+ sigset_t mask, omask;
+ sigaction_t act, oact;
#ifdef SIGTTOU
- int sigttou_blocked;
+ int sigttou_blocked;
#endif
- T(("tstp() called"));
-
- /*
- * The user may have changed the prog_mode tty bits, so save them.
- *
- * But first try to detect whether we still are in the foreground
- * process group - if not, an interactive shell may already have
- * taken ownership of the tty and modified the settings when our
- * parent was stopped before us, and we would likely pick up the
- * settings already modified by the shell.
- */
- if (SP != 0 && !SP->_endwin) /* don't do this if we're not in curses */
+ T(("tstp() called"));
+
+ /*
+ * The user may have changed the prog_mode tty bits, so save them.
+ *
+ * But first try to detect whether we still are in the foreground
+ * process group - if not, an interactive shell may already have
+ * taken ownership of the tty and modified the settings when our
+ * parent was stopped before us, and we would likely pick up the
+ * settings already modified by the shell.
+ */
+ if (SP != 0 && !SP->_endwin) /* don't do this if we're not in curses */
#if HAVE_TCGETPGRP
if (tcgetpgrp(STDIN_FILENO) == getpgrp())
#endif
def_prog_mode();
- /*
- * Block window change and timer signals. The latter
- * is because applications use timers to decide when
- * to repaint the screen.
- */
- (void)sigemptyset(&mask);
- (void)sigaddset(&mask, SIGALRM);
+ /*
+ * Block window change and timer signals. The latter
+ * is because applications use timers to decide when
+ * to repaint the screen.
+ */
+ (void) sigemptyset(&mask);
+ (void) sigaddset(&mask, SIGALRM);
#if USE_SIGWINCH
- (void)sigaddset(&mask, SIGWINCH);
+ (void) sigaddset(&mask, SIGWINCH);
#endif
- (void)sigprocmask(SIG_BLOCK, &mask, &omask);
+ (void) sigprocmask(SIG_BLOCK, &mask, &omask);
#ifdef SIGTTOU
- sigttou_blocked = sigismember(&omask, SIGTTOU);
- if (!sigttou_blocked) {
- (void)sigemptyset(&mask);
- (void)sigaddset(&mask, SIGTTOU);
- (void)sigprocmask(SIG_BLOCK, &mask, NULL);
- }
+ sigttou_blocked = sigismember(&omask, SIGTTOU);
+ if (!sigttou_blocked) {
+ (void) sigemptyset(&mask);
+ (void) sigaddset(&mask, SIGTTOU);
+ (void) sigprocmask(SIG_BLOCK, &mask, NULL);
+ }
#endif
- /*
- * End window mode, which also resets the terminal state to the
- * original (pre-curses) modes.
- */
- endwin();
+ /*
+ * End window mode, which also resets the terminal state to the
+ * original (pre-curses) modes.
+ */
+ endwin();
- /* Unblock SIGTSTP. */
- (void)sigemptyset(&mask);
- (void)sigaddset(&mask, SIGTSTP);
+ /* Unblock SIGTSTP. */
+ (void) sigemptyset(&mask);
+ (void) sigaddset(&mask, SIGTSTP);
#ifdef SIGTTOU
- if (!sigttou_blocked) {
- /* Unblock this too if it wasn't blocked on entry */
- (void)sigaddset(&mask, SIGTTOU);
- }
+ if (!sigttou_blocked) {
+ /* Unblock this too if it wasn't blocked on entry */
+ (void) sigaddset(&mask, SIGTTOU);
+ }
#endif
- (void)sigprocmask(SIG_UNBLOCK, &mask, NULL);
+ (void) sigprocmask(SIG_UNBLOCK, &mask, NULL);
- /* Now we want to resend SIGSTP to this process and suspend it */
- act.sa_handler = SIG_DFL;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
+ /* Now we want to resend SIGSTP to this process and suspend it */
+ act.sa_handler = SIG_DFL;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
+ act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
- sigaction(SIGTSTP, &act, &oact);
- kill(getpid(), SIGTSTP);
+ sigaction(SIGTSTP, &act, &oact);
+ kill(getpid(), SIGTSTP);
- /* Process gets suspended...time passes...process resumes */
+ /* Process gets suspended...time passes...process resumes */
- T(("SIGCONT received"));
- sigaction(SIGTSTP, &oact, NULL);
- flushinp();
+ T(("SIGCONT received"));
+ sigaction(SIGTSTP, &oact, NULL);
+ flushinp();
- /*
- * If the user modified the tty state while suspended, he wants
- * those changes to stick. So save the new "default" terminal state.
- */
- def_shell_mode();
+ /*
+ * If the user modified the tty state while suspended, he wants
+ * those changes to stick. So save the new "default" terminal state.
+ */
+ def_shell_mode();
- /*
- * This relies on the fact that doupdate() will restore the
- * program-mode tty state, and issue enter_ca_mode if need be.
- */
- doupdate();
+ /*
+ * This relies on the fact that doupdate() will restore the
+ * program-mode tty state, and issue enter_ca_mode if need be.
+ */
+ doupdate();
- /* Reset the signals. */
- (void)sigprocmask(SIG_SETMASK, &omask, NULL);
+ /* Reset the signals. */
+ (void) sigprocmask(SIG_SETMASK, &omask, NULL);
}
-#endif /* USE_SIGTSTP */
+#endif /* USE_SIGTSTP */
-static void cleanup(int sig)
+static void
+cleanup(int sig)
{
- static int nested;
-
- /*
- * Actually, doing any sort of I/O from within an signal handler is
- * "unsafe". But we'll _try_ to clean up the screen and terminal
- * settings on the way out.
- */
- if (!nested++
- && (sig == SIGINT
- || sig == SIGQUIT)) {
+ static int nested;
+
+ /*
+ * Actually, doing any sort of I/O from within an signal handler is
+ * "unsafe". But we'll _try_ to clean up the screen and terminal
+ * settings on the way out.
+ */
+ if (!nested++
+ && (sig == SIGINT
+ || sig == SIGQUIT)) {
#if HAVE_SIGACTION || HAVE_SIGVEC
- sigaction_t act;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- act.sa_handler = SIG_IGN;
- if (sigaction(sig, &act, (sigaction_t *)0) == 0)
+ sigaction_t act;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = SIG_IGN;
+ if (sigaction(sig, &act, (sigaction_t *) 0) == 0)
#else
- if (signal(sig, SIG_IGN) != SIG_ERR)
+ if (signal(sig, SIG_IGN) != SIG_ERR)
#endif
- {
- SCREEN *scan = _nc_screen_chain;
- while(scan)
- {
- if (SP != 0
- && SP->_ofp != 0
- && isatty(fileno(SP->_ofp))) {
- SP->_cleanup = TRUE;
- SP->_outch = _nc_outch;
- }
- set_term(scan);
- endwin();
- if (SP)
- SP->_endwin = FALSE; /* in case we have an atexit! */
- scan = scan->_next_screen;
- }
+ {
+ SCREEN *scan = _nc_screen_chain;
+ while (scan) {
+ if (SP != 0
+ && SP->_ofp != 0
+ && isatty(fileno(SP->_ofp))) {
+ SP->_cleanup = TRUE;
+ SP->_outch = _nc_outch;
}
+ set_term(scan);
+ endwin();
+ if (SP)
+ SP->_endwin = FALSE; /* in case we have an atexit! */
+ scan = scan->_next_screen;
+ }
}
- exit(EXIT_FAILURE);
+ }
+ exit(EXIT_FAILURE);
}
#if USE_SIGWINCH
-static void sigwinch(int sig GCC_UNUSED)
+static void
+sigwinch(int sig GCC_UNUSED)
{
SCREEN *scan = _nc_screen_chain;
- while(scan)
- {
+ while (scan) {
scan->_sig_winch = TRUE;
scan = scan->_next_screen;
}
@@ -258,38 +258,40 @@ static void sigwinch(int sig GCC_UNUSED)
* handler.
*/
#if HAVE_SIGACTION || HAVE_SIGVEC
-static int CatchIfDefault(int sig, sigaction_t *act)
+static int
+CatchIfDefault(int sig, sigaction_t * act)
{
- sigaction_t old_act;
+ sigaction_t old_act;
- if (sigaction(sig, (sigaction_t *)0, &old_act) == 0
- && (old_act.sa_handler == SIG_DFL
+ if (sigaction(sig, (sigaction_t *) 0, &old_act) == 0
+ && (old_act.sa_handler == SIG_DFL
#if USE_SIGWINCH
|| (sig == SIGWINCH && old_act.sa_handler == SIG_IGN)
#endif
- )) {
- (void)sigaction(sig, act, (sigaction_t *)0);
- return TRUE;
- }
- return FALSE;
+ )) {
+ (void) sigaction(sig, act, (sigaction_t *) 0);
+ return TRUE;
+ }
+ return FALSE;
}
#else
-static int CatchIfDefault(int sig, RETSIGTYPE (*handler)(int))
+static int
+CatchIfDefault(int sig, RETSIGTYPE(*handler) (int))
{
- void (*ohandler)(int);
+ void (*ohandler) (int);
- ohandler = signal(sig, SIG_IGN);
- if (ohandler == SIG_DFL
+ ohandler = signal(sig, SIG_IGN);
+ if (ohandler == SIG_DFL
#if USE_SIGWINCH
- || (sig == SIGWINCH && ohandler == SIG_IGN)
+ || (sig == SIGWINCH && ohandler == SIG_IGN)
#endif
) {
- signal(sig, handler);
- return TRUE;
- } else {
- signal(sig, ohandler);
- return FALSE;
- }
+ signal(sig, handler);
+ return TRUE;
+ } else {
+ signal(sig, ohandler);
+ return FALSE;
+ }
}
#endif
@@ -304,69 +306,63 @@ static int CatchIfDefault(int sig, RETSIGTYPE (*handler)(int))
* The XSI document implies that we shouldn't keep the SIGTSTP handler if
* the caller later changes its mind, but that doesn't seem correct.
*/
-void _nc_signal_handler(bool enable)
+void
+_nc_signal_handler(bool enable)
{
-#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */
-static sigaction_t act, oact;
-static int ignore;
-
- if (!ignore)
- {
- if (!enable)
- {
- act.sa_handler = SIG_IGN;
- sigaction(SIGTSTP, &act, &oact);
- }
- else if (act.sa_handler)
- {
- sigaction(SIGTSTP, &oact, NULL);
- }
- else /*initialize */
- {
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
+#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */
+ static sigaction_t act, oact;
+ static int ignore;
+
+ if (!ignore) {
+ if (!enable) {
+ act.sa_handler = SIG_IGN;
+ sigaction(SIGTSTP, &act, &oact);
+ } else if (act.sa_handler) {
+ sigaction(SIGTSTP, &oact, NULL);
+ } else { /*initialize */
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
#if USE_SIGWINCH
- act.sa_handler = sigwinch;
- CatchIfDefault(SIGWINCH, &act);
+ act.sa_handler = sigwinch;
+ CatchIfDefault(SIGWINCH, &act);
#endif
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
+ act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
- act.sa_handler = cleanup;
- CatchIfDefault(SIGINT, &act);
- CatchIfDefault(SIGTERM, &act);
+ act.sa_handler = cleanup;
+ CatchIfDefault(SIGINT, &act);
+ CatchIfDefault(SIGTERM, &act);
- act.sa_handler = tstp;
- if (!CatchIfDefault(SIGTSTP, &act))
- ignore = TRUE;
- }
+ act.sa_handler = tstp;
+ if (!CatchIfDefault(SIGTSTP, &act))
+ ignore = TRUE;
}
+ }
#else /* !USE_SIGTSTP */
- if (enable)
- {
+ if (enable) {
#if HAVE_SIGACTION || HAVE_SIGVEC
- static sigaction_t act;
- sigemptyset(&act.sa_mask);
+ static sigaction_t act;
+ sigemptyset(&act.sa_mask);
#if USE_SIGWINCH
- act.sa_handler = sigwinch;
- CatchIfDefault(SIGWINCH, &act);
+ act.sa_handler = sigwinch;
+ CatchIfDefault(SIGWINCH, &act);
#endif
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
+ act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
- act.sa_handler = cleanup;
- CatchIfDefault(SIGINT, &act);
- CatchIfDefault(SIGTERM, &act);
+ act.sa_handler = cleanup;
+ CatchIfDefault(SIGINT, &act);
+ CatchIfDefault(SIGTERM, &act);
#else /* !(HAVE_SIGACTION || HAVE_SIGVEC) */
- CatchIfDefault(SIGINT, cleanup);
- CatchIfDefault(SIGTERM, cleanup);
+ CatchIfDefault(SIGINT, cleanup);
+ CatchIfDefault(SIGTERM, cleanup);
#if USE_SIGWINCH
- CatchIfDefault(SIGWINCH, sigwinch);
+ CatchIfDefault(SIGWINCH, sigwinch);
#endif
#endif /* !(HAVE_SIGACTION || HAVE_SIGVEC) */
- }
+ }
#endif /* !USE_SIGTSTP */
}
diff --git a/lib/libcurses/tty/lib_twait.c b/lib/libcurses/tty/lib_twait.c
index 93aff6a4edf..5c038bd91df 100644
--- a/lib/libcurses/tty/lib_twait.c
+++ b/lib/libcurses/tty/lib_twait.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_twait.c,v 1.5 2000/07/10 03:06:16 millert Exp $ */
+/* $OpenBSD: lib_twait.c,v 1.6 2000/10/08 22:47:05 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -61,33 +61,34 @@
# endif
#endif
-MODULE_ID("$From: lib_twait.c,v 1.37 2000/06/29 23:03:09 tom Exp $")
+MODULE_ID("$From: lib_twait.c,v 1.39 2000/08/26 19:34:15 tom Exp $")
-static long _nc_gettime(bool first)
+static long
+_nc_gettime(bool first)
{
- long res;
+ long res;
#if HAVE_GETTIMEOFDAY
# define PRECISE_GETTIME 1
- static struct timeval t0;
- struct timeval t1;
- gettimeofday(&t1, (struct timezone *)0);
- if (first) {
- t0 = t1;
- }
- res = (t1.tv_sec - t0.tv_sec) * 1000
- + (t1.tv_usec - t0.tv_usec) / 1000;
+ static struct timeval t0;
+ struct timeval t1;
+ gettimeofday(&t1, (struct timezone *) 0);
+ if (first) {
+ t0 = t1;
+ }
+ res = (t1.tv_sec - t0.tv_sec) * 1000
+ + (t1.tv_usec - t0.tv_usec) / 1000;
#else
# define PRECISE_GETTIME 0
- static time_t t0;
- time_t t1 = time((time_t*)0);
- if (first) {
- t0 = t1;
- }
- res = (t1 - t0) * 1000;
+ static time_t t0;
+ time_t t1 = time((time_t *) 0);
+ if (first) {
+ t0 = t1;
+ }
+ res = (t1 - t0) * 1000;
#endif
- T(("%s time: %ld msec", first ? "get" : "elapsed", res));
- return res;
+ T(("%s time: %ld msec", first ? "get" : "elapsed", res));
+ return res;
}
/*
@@ -103,163 +104,164 @@ static long _nc_gettime(bool first)
* If the milliseconds given are -1, the wait blocks until activity on the
* descriptors.
*/
-int _nc_timed_wait(int mode, int milliseconds, int *timeleft)
+int
+_nc_timed_wait(int mode, int milliseconds, int *timeleft)
{
-int fd;
-int count;
+ int fd;
+ int count;
-int result;
+ int result;
#if USE_FUNC_POLL
-struct pollfd fds[2];
+ struct pollfd fds[2];
#elif defined(__BEOS__)
#elif HAVE_SELECT
-static fd_set set;
+ static fd_set set;
#endif
-long starttime, returntime;
+ long starttime, returntime;
- T(("start twait: %d milliseconds, mode: %d", milliseconds, mode));
+ T(("start twait: %d milliseconds, mode: %d", milliseconds, mode));
#if PRECISE_GETTIME
-retry:
+ retry:
#endif
- starttime = _nc_gettime(TRUE);
+ starttime = _nc_gettime(TRUE);
- count = 0;
+ count = 0;
#if USE_FUNC_POLL
- if (mode & 1) {
- fds[count].fd = SP->_ifd;
- fds[count].events = POLLIN;
- count++;
- }
- if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0) {
- fds[count].fd = fd;
- fds[count].events = POLLIN;
- count++;
- }
- result = poll(fds, count, milliseconds);
+ memset(fds, 0, sizeof(fds));
+ if (mode & 1) {
+ fds[count].fd = SP->_ifd;
+ fds[count].events = POLLIN;
+ count++;
+ }
+ if ((mode & 2)
+ && (fd = SP->_mouse_fd) >= 0) {
+ fds[count].fd = fd;
+ fds[count].events = POLLIN;
+ count++;
+ }
+ result = poll(fds, count, milliseconds);
#elif defined(__BEOS__)
- /*
- * BeOS's select() is declared in socket.h, so the configure script does
- * not see it. That's just as well, since that function works only for
- * sockets. This (using snooze and ioctl) was distilled from Be's patch
- * for ncurses which uses a separate thread to simulate select().
- *
- * FIXME: the return values from the ioctl aren't very clear if we get
- * interrupted.
- */
- result = 0;
- if (mode & 1) {
- bigtime_t d;
- bigtime_t useconds = milliseconds * 1000;
- int n, howmany;
+ /*
+ * BeOS's select() is declared in socket.h, so the configure script does
+ * not see it. That's just as well, since that function works only for
+ * sockets. This (using snooze and ioctl) was distilled from Be's patch
+ * for ncurses which uses a separate thread to simulate select().
+ *
+ * FIXME: the return values from the ioctl aren't very clear if we get
+ * interrupted.
+ */
+ result = 0;
+ if (mode & 1) {
+ bigtime_t d;
+ bigtime_t useconds = milliseconds * 1000;
+ int n, howmany;
- if (useconds == 0) /* we're here to go _through_ the loop */
- useconds = 1;
+ if (useconds == 0) /* we're here to go _through_ the loop */
+ useconds = 1;
- for (d = 0; d < useconds; d += 5000) {
- n = 0;
- howmany = ioctl(0, 'ichr', &n);
- if (howmany >= 0 && n > 0) {
- result = 1;
- break;
- }
- if (useconds > 1)
- snooze(5000);
- milliseconds -= 5;
- }
- } else if (milliseconds > 0) {
- snooze(milliseconds * 1000);
- milliseconds = 0;
+ for (d = 0; d < useconds; d += 5000) {
+ n = 0;
+ howmany = ioctl(0, 'ichr', &n);
+ if (howmany >= 0 && n > 0) {
+ result = 1;
+ break;
+ }
+ if (useconds > 1)
+ snooze(5000);
+ milliseconds -= 5;
}
+ } else if (milliseconds > 0) {
+ snooze(milliseconds * 1000);
+ milliseconds = 0;
+ }
#elif HAVE_SELECT
- /*
- * select() modifies the fd_set arguments; do this in the
- * loop.
- */
- FD_ZERO(&set);
+ /*
+ * select() modifies the fd_set arguments; do this in the
+ * loop.
+ */
+ FD_ZERO(&set);
- if (mode & 1) {
- FD_SET(SP->_ifd, &set);
- count = SP->_ifd + 1;
- }
- if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0) {
- FD_SET(fd, &set);
- count = max(fd, count) + 1;
- }
+ if (mode & 1) {
+ FD_SET(SP->_ifd, &set);
+ count = SP->_ifd + 1;
+ }
+ if ((mode & 2)
+ && (fd = SP->_mouse_fd) >= 0) {
+ FD_SET(fd, &set);
+ count = max(fd, count) + 1;
+ }
- if (milliseconds >= 0) {
- struct timeval ntimeout;
- ntimeout.tv_sec = milliseconds / 1000;
- ntimeout.tv_usec = (milliseconds % 1000) * 1000;
- result = select(count, &set, NULL, NULL, &ntimeout);
- } else {
- result = select(count, &set, NULL, NULL, NULL);
- }
+ if (milliseconds >= 0) {
+ struct timeval ntimeout;
+ ntimeout.tv_sec = milliseconds / 1000;
+ ntimeout.tv_usec = (milliseconds % 1000) * 1000;
+ result = select(count, &set, NULL, NULL, &ntimeout);
+ } else {
+ result = select(count, &set, NULL, NULL, NULL);
+ }
#endif
- returntime = _nc_gettime(FALSE);
+ returntime = _nc_gettime(FALSE);
- if (milliseconds >= 0)
- milliseconds -= (returntime - starttime);
+ if (milliseconds >= 0)
+ milliseconds -= (returntime - starttime);
#if PRECISE_GETTIME
- /*
- * If the timeout hasn't expired, and we've gotten no data,
- * this is probably a system where 'select()' needs to be left
- * alone so that it can complete. Make this process sleep,
- * then come back for more.
- */
- if (result == 0 && milliseconds > 100) {
- napms(100);
- milliseconds -= 100;
- goto retry;
- }
+ /*
+ * If the timeout hasn't expired, and we've gotten no data,
+ * this is probably a system where 'select()' needs to be left
+ * alone so that it can complete. Make this process sleep,
+ * then come back for more.
+ */
+ if (result == 0 && milliseconds > 100) {
+ napms(100);
+ milliseconds -= 100;
+ goto retry;
+ }
#endif
- /* return approximate time left in milliseconds */
- if (timeleft)
- *timeleft = milliseconds;
+ /* return approximate time left in milliseconds */
+ if (timeleft)
+ *timeleft = milliseconds;
- T(("end twait: returned %d (%d), remaining time %d msec",
- result, errno, milliseconds));
+ T(("end twait: returned %d (%d), remaining time %d msec",
+ result, errno, milliseconds));
- /*
- * Both 'poll()' and 'select()' return the number of file descriptors
- * that are active. Translate this back to the mask that denotes which
- * file-descriptors, so that we don't need all of this system-specific
- * code everywhere.
- */
- if (result != 0) {
- if (result > 0) {
- result = 0;
+ /*
+ * Both 'poll()' and 'select()' return the number of file descriptors
+ * that are active. Translate this back to the mask that denotes which
+ * file-descriptors, so that we don't need all of this system-specific
+ * code everywhere.
+ */
+ if (result != 0) {
+ if (result > 0) {
+ result = 0;
#if USE_FUNC_POLL
- for (count = 0; count < 2; count++) {
- if ((mode & (1 << count))
- && (fds[count].revents & POLLIN)) {
- result |= (1 << count);
- }
- }
+ for (count = 0; count < 2; count++) {
+ if ((mode & (1 << count))
+ && (fds[count].revents & POLLIN)) {
+ result |= (1 << count);
+ }
+ }
#elif defined(__BEOS__)
- result = 1; /* redundant, but simple */
+ result = 1; /* redundant, but simple */
#elif HAVE_SELECT
- if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0
- && FD_ISSET(fd, &set))
- result |= 2;
- if ((mode & 1)
- && FD_ISSET(SP->_ifd, &set))
- result |= 1;
+ if ((mode & 2)
+ && (fd = SP->_mouse_fd) >= 0
+ && FD_ISSET(fd, &set))
+ result |= 2;
+ if ((mode & 1)
+ && FD_ISSET(SP->_ifd, &set))
+ result |= 1;
#endif
- }
- else
- result = 0;
- }
+ } else
+ result = 0;
+ }
- return (result);
+ return (result);
}
diff --git a/lib/libcurses/tty/lib_vidattr.c b/lib/libcurses/tty/lib_vidattr.c
index 9584b26b108..9f8476c760c 100644
--- a/lib/libcurses/tty/lib_vidattr.c
+++ b/lib/libcurses/tty/lib_vidattr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_vidattr.c,v 1.5 2000/06/19 03:53:54 millert Exp $ */
+/* $OpenBSD: lib_vidattr.c,v 1.6 2000/10/08 22:47:05 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -66,7 +66,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_vidattr.c,v 1.27 2000/04/29 23:25:27 tom Exp $")
+MODULE_ID("$From: lib_vidattr.c,v 1.32 2000/09/17 00:15:23 tom Exp $")
#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
@@ -80,7 +80,7 @@ MODULE_ID("$From: lib_vidattr.c,v 1.27 2000/04/29 23:25:27 tom Exp $")
#define SetColorsIf(why,old_attr) \
if (can_color && (why)) { \
int old_pair = PAIR_NUMBER(old_attr); \
- T(("old pair = %d -- new pair = %d", old_pair, pair)); \
+ TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \
if ((pair != old_pair) \
|| (fix_pair0 && (pair == 0)) \
|| (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
@@ -97,7 +97,7 @@ vidputs(attr_t newmode, int (*outc) (int))
bool reverse = FALSE;
bool used_ncv = FALSE;
bool can_color = (SP == 0 || SP->_coloron);
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
#else
#define fix_pair0 FALSE
@@ -109,7 +109,7 @@ vidputs(attr_t newmode, int (*outc) (int))
if (SP)
previous_attr = SP->_current_attr;
- T(("previous attribute was %s", _traceattr(previous_attr)));
+ TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(previous_attr)));
#if !USE_XMC_SUPPORT
if ((SP != 0)
@@ -122,36 +122,29 @@ vidputs(attr_t newmode, int (*outc) (int))
* attributes, use the colors in preference.
*/
if (((newmode & A_COLOR) != 0
- || fix_pair0)
+ || fix_pair0)
&& (no_color_video > 0)) {
- /* *INDENT-OFF* */
- static const struct {
- attr_t video;
- unsigned bit;
- } table[] = {
- { A_STANDOUT, 1 },
- { A_UNDERLINE, 2 },
- { A_REVERSE, 4 },
- { A_BLINK, 8 },
- { A_DIM, 16 },
- { A_BOLD, 32 },
- { A_INVIS, 64 },
- { A_PROTECT, 128 },
- { A_ALTCHARSET, 256 },
- };
- /* *INDENT-ON* */
-
- size_t n;
- for (n = 0; n < SIZEOF(table); n++) {
- if ((table[n].bit & no_color_video)
- && (table[n].video & newmode)) {
- used_ncv = TRUE;
- if (table[n].video == A_REVERSE)
- reverse = TRUE;
- else
- newmode &= ~table[n].video;
- }
+ /*
+ * If we had chosen the A_xxx definitions to correspond to the
+ * no_color_video mask, we could simply shift it up and mask off the
+ * attributes. But we did not (actually copied Solaris' definitions).
+ * However, this is still simpler/faster than a lookup table.
+ *
+ * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK,
+ * A_DIM, A_BOLD which are 1:1 with no_color_video. The bits that
+ * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and
+ * A_ALTCHARSET (256) down 2 to line up. We use the NCURSES_BITS
+ * macro so this will work properly for the wide-character layout.
+ */
+ attr_t mask = NCURSES_BITS((no_color_video & 63)
+ | ((no_color_video & 192) << 1)
+ | ((no_color_video & 256) >> 2), 8);
+
+ if (mask & A_REVERSE) {
+ reverse = TRUE;
+ mask &= ~A_REVERSE;
}
+ newmode &= ~mask;
}
if (newmode == previous_attr)
@@ -174,7 +167,16 @@ vidputs(attr_t newmode, int (*outc) (int))
previous_attr &= ~A_ALTCHARSET;
}
if (previous_attr) {
- doPut(exit_attribute_mode);
+ if (exit_attribute_mode) {
+ doPut(exit_attribute_mode);
+ } else {
+ if (!SP || SP->_use_rmul) {
+ TurnOff(A_UNDERLINE, exit_underline_mode);
+ }
+ if (!SP || SP->_use_rmso) {
+ TurnOff(A_STANDOUT, exit_standout_mode);
+ }
+ }
previous_attr &= ~A_COLOR;
}
@@ -183,21 +185,21 @@ vidputs(attr_t newmode, int (*outc) (int))
if (turn_on || turn_off) {
TPUTS_TRACE("set_attributes");
tputs(tparm(set_attributes,
- (newmode & A_STANDOUT) != 0,
- (newmode & A_UNDERLINE) != 0,
- (newmode & A_REVERSE) != 0,
- (newmode & A_BLINK) != 0,
- (newmode & A_DIM) != 0,
- (newmode & A_BOLD) != 0,
- (newmode & A_INVIS) != 0,
- (newmode & A_PROTECT) != 0,
- (newmode & A_ALTCHARSET) != 0), 1, outc);
+ (newmode & A_STANDOUT) != 0,
+ (newmode & A_UNDERLINE) != 0,
+ (newmode & A_REVERSE) != 0,
+ (newmode & A_BLINK) != 0,
+ (newmode & A_DIM) != 0,
+ (newmode & A_BOLD) != 0,
+ (newmode & A_INVIS) != 0,
+ (newmode & A_PROTECT) != 0,
+ (newmode & A_ALTCHARSET) != 0), 1, outc);
previous_attr &= ~A_COLOR;
}
SetColorsIf((pair != 0) || fix_pair0, previous_attr);
} else {
- T(("turning %s off", _traceattr(turn_off)));
+ TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
@@ -216,7 +218,7 @@ vidputs(attr_t newmode, int (*outc) (int))
}
SetColorsIf((pair != 0) || fix_pair0, previous_attr);
- T(("turning %s on", _traceattr(turn_on)));
+ TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
/* *INDENT-OFF* */
TurnOn(A_ALTCHARSET, enter_alt_charset_mode);
TurnOn(A_BLINK, enter_blink_mode);
@@ -261,6 +263,7 @@ termattrs(void)
{
chtype attrs = A_NORMAL;
+ T((T_CALLED("termattrs()")));
if (enter_alt_charset_mode)
attrs |= A_ALTCHARSET;
@@ -291,5 +294,5 @@ termattrs(void)
if (SP->_coloron)
attrs |= A_COLOR;
- return (attrs);
+ returnChar(attrs);
}
diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c
index dfb983a61cc..ef52d7f7a11 100644
--- a/lib/libcurses/tty/tty_update.c
+++ b/lib/libcurses/tty/tty_update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_update.c,v 1.11 2000/07/24 04:06:11 millert Exp $ */
+/* $OpenBSD: tty_update.c,v 1.12 2000/10/08 22:47:05 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -72,7 +72,7 @@
#include <term.h>
-MODULE_ID("$From: tty_update.c,v 1.142 2000/07/23 01:41:17 tom Exp $")
+MODULE_ID("$From: tty_update.c,v 1.146 2000/10/07 01:11:44 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -114,15 +114,24 @@ position_check(int expected_y, int expected_x, char *legend)
/* check to see if the real cursor position matches the virtual */
{
char buf[20];
+ char *s;
int y, x;
if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
return;
+ _nc_flush();
memset(buf, '\0', sizeof(buf));
putp("\033[6n"); /* only works on ANSI-compatibles */
_nc_flush();
- (void) read(0, buf, sizeof(buf) - 1);
+ *(s = buf) = 0;
+ do {
+ int ask = sizeof(buf) - 1 - (s - buf);
+ int got = read(0, s, ask);
+ if (got == 0)
+ break;
+ s += got;
+ } while (strchr(buf, 'R') == 0);
_tracef("probe returned %s", _nc_visbuf(buf));
/* try to interpret as a position report */
@@ -135,8 +144,9 @@ position_check(int expected_y, int expected_x, char *legend)
expected_y = y - 1;
if (y - 1 != expected_y || x - 1 != expected_x) {
beep();
+ tputs(tparm("\033[%d;%dH", expected_y + 1, expected_x + 1), 1, _nc_outch);
_tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
- y - 1, x - 1, expected_y, expected_x, legend);
+ y - 1, x - 1, expected_y, expected_x, legend);
} else {
_tracef("position matches OK in %s", legend);
}
@@ -158,7 +168,7 @@ GoTo(int const row, int const col)
chtype oldattr = SP->_current_attr;
TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
- row, col, SP->_cursrow, SP->_curscol));
+ row, col, SP->_cursrow, SP->_curscol));
position_check(SP->_cursrow, SP->_curscol, "GoTo");
@@ -170,7 +180,7 @@ GoTo(int const row, int const col)
if ((oldattr & A_ALTCHARSET)
|| (oldattr && !move_standout_mode)) {
TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
- oldattr, _traceattr(oldattr)));
+ oldattr, _traceattr(oldattr)));
vidattr(A_NORMAL);
}
@@ -189,8 +199,8 @@ PutAttrChar(chtype ch)
ch = ('`' | AttrOf(ch));
TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
- _tracechtype(ch),
- SP->_cursrow, SP->_curscol));
+ _tracechtype(ch),
+ SP->_cursrow, SP->_curscol));
UpdateAttrs(ch);
data = TextOf(ch);
if (SP->_outch != 0) {
@@ -297,7 +307,7 @@ PutCharLR(chtype const ch)
TPUTS_TRACE("enter_am_mode");
putp(enter_am_mode);
} else if ((enter_insert_mode && exit_insert_mode)
- || insert_character || parm_ich) {
+ || insert_character || parm_ich) {
GoTo(screen_lines - 1, screen_columns - 2);
callPutChar(ch);
GoTo(screen_lines - 1, screen_columns - 2);
@@ -363,7 +373,7 @@ can_clear_with(chtype ch)
if (!back_color_erase && SP->_coloron) {
if (ch & A_COLOR)
return FALSE;
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (!SP->_default_color)
return FALSE;
if (SP->_default_fg != C_MASK || SP->_default_bg != C_MASK)
@@ -429,10 +439,11 @@ EmitRange(const chtype * ntext, int num)
* don't bother moving cursor, since it can be the
* last update on the line.
*/
- if (runcount < num)
+ if (runcount < num) {
GoTo(SP->_cursrow, SP->_curscol + runcount);
- else
+ } else {
return 1; /* cursor stays in the middle */
+ }
} else if (repeat_char && runcount > SP->_rep_cost) {
bool wrap_possible = (SP->_curscol + runcount >= screen_columns);
int rep_count = runcount;
@@ -471,15 +482,15 @@ EmitRange(const chtype * ntext, int num)
*/
static int
PutRange(
- const chtype * otext,
- const chtype * ntext,
- int row,
- int first, int last)
+ const chtype * otext,
+ const chtype * ntext,
+ int row,
+ int first, int last)
{
int j, run;
TR(TRACE_CHARPUT, ("PutRange(%p, %p, %d, %d, %d)",
- otext, ntext, row, first, last));
+ otext, ntext, row, first, last));
if (otext != ntext
&& (last - first + 1) > SP->_inline_cost) {
@@ -599,8 +610,8 @@ doupdate(void)
continue;
}
- T(("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
- T(("...to %s", _traceattr(turnon)));
+ TR(TRACE_ATTRS, ("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
+ TR(TRACE_ATTRS, ("...to %s", _traceattr(turnon)));
/*
* If the attribute change location is a blank with a
@@ -630,15 +641,17 @@ doupdate(void)
for (; n < screen_columns; n++) {
if (AttrOf(newscr->_line[m].text[n]) == rattr) {
end_onscreen = TRUE;
- T(("Range attributed with %s ends at (%d, %d)",
- _traceattr(turnon), m, n));
+ TR(TRACE_ATTRS,
+ ("Range attributed with %s ends at (%d, %d)",
+ _traceattr(turnon), m, n));
goto foundit;
}
}
n = 0;
}
- T(("Range attributed with %s ends offscreen",
- _traceattr(turnon)));
+ TR(TRACE_ATTRS,
+ ("Range attributed with %s ends offscreen",
+ _traceattr(turnon)));
foundit:;
if (end_onscreen) {
@@ -651,8 +664,8 @@ doupdate(void)
* of span.
*/
while (n >= 0
- && TextOf(lastline[n]) == ' '
- && SAFE(AttrOf(lastline[n])))
+ && TextOf(lastline[n]) == ' '
+ && SAFE(AttrOf(lastline[n])))
lastline[n--] &= ~turnon;
/* check that there's enough room at end of span */
@@ -667,8 +680,9 @@ doupdate(void)
if (failed) {
int p, q = j;
- T(("Clearing %s beginning at (%d, %d)",
- _traceattr(turnon), i, j));
+ TR(TRACE_ATTRS,
+ ("Clearing %s beginning at (%d, %d)",
+ _traceattr(turnon), i, j));
/* turn off new attributes over span */
for (p = i; p < screen_lines; p++) {
@@ -681,8 +695,9 @@ doupdate(void)
}
foundend:;
} else {
- T(("Cookie space for %s found before (%d, %d)",
- _traceattr(turnon), i, j));
+ TR(TRACE_ATTRS,
+ ("Cookie space for %s found before (%d, %d)",
+ _traceattr(turnon), i, j));
/*
* back up the start of range so there's room
@@ -708,7 +723,7 @@ doupdate(void)
nonempty = 0;
if (curscr->_clear || newscr->_clear) { /* force refresh ? */
- T(("clearing and updating from scratch"));
+ TR(TRACE_UPDATE, ("clearing and updating from scratch"));
ClrUpdate();
curscr->_clear = FALSE; /* reset flag */
newscr->_clear = FALSE; /* reset flag */
@@ -726,7 +741,7 @@ doupdate(void)
nonempty = ClrBottom(nonempty);
- T(("Transforming lines, nonempty %d", nonempty));
+ TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
for (i = 0; i < nonempty; i++) {
/*
* Here is our line-breakout optimization.
@@ -787,10 +802,10 @@ doupdate(void)
#if USE_TRACE_TIMES
(void) times(&after);
TR(TRACE_TIMES,
- ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
- _nc_outchars,
- after.tms_stime - before.tms_stime,
- after.tms_utime - before.tms_utime));
+ ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
+ _nc_outchars,
+ after.tms_stime - before.tms_stime,
+ after.tms_utime - before.tms_utime));
#endif /* USE_TRACE_TIMES */
_nc_signal_handler(TRUE);
@@ -834,11 +849,11 @@ ClrUpdate(void)
chtype blank = ClrBlank(stdscr);
int nonempty = min(screen_lines, newscr->_maxy + 1);
- T(("ClrUpdate() called"));
+ TR(TRACE_UPDATE, ("ClrUpdate() called"));
ClearScreen(blank);
- T(("updating screen from scratch"));
+ TR(TRACE_UPDATE, ("updating screen from scratch"));
nonempty = ClrBottom(nonempty);
@@ -936,12 +951,14 @@ ClrBottom(int total)
for (col = 0, ok = TRUE; ok && col < last; col++) {
ok = (newscr->_line[row].text[col] == blank);
}
- if (!ok) break;
+ if (!ok)
+ break;
for (col = 0; ok && col < last; col++) {
ok = (curscr->_line[row].text[col] == blank);
}
- if (!ok) top = row;
+ if (!ok)
+ top = row;
}
/* don't use clr_eos for just one line if clr_eol available */
@@ -985,7 +1002,7 @@ TransformLine(int const lineno)
int n;
bool attrchanged = FALSE;
- T(("TransformLine(%d) called", lineno));
+ TR(TRACE_UPDATE, ("TransformLine(%d) called", lineno));
/* copy new hash value to old one */
if (SP->oldhash && SP->newhash)
@@ -1067,11 +1084,11 @@ TransformLine(int const lineno)
*/
if (TextOf(newLine[n]) == ' '
&& ((n > 0
- && xmc_turn_on(newLine[n - 1], newLine[n]))
+ && xmc_turn_on(newLine[n - 1], newLine[n]))
|| (n == 0
&& lineno > 0
&& xmc_turn_on(NEW(lineno - 1, screen_columns - 1),
- newLine[n])))) {
+ newLine[n])))) {
n = m;
}
@@ -1083,7 +1100,7 @@ TransformLine(int const lineno)
*/
if (TextOf(newLine[n]) != ' '
&& ((n + 1 < screen_columns
- && xmc_turn_off(newLine[n], newLine[n + 1]))
+ && xmc_turn_off(newLine[n], newLine[n + 1]))
|| (n + 1 >= screen_columns
&& lineno + 1 < screen_lines
&& xmc_turn_off(newLine[n], NEW(lineno + 1, 0))))) {
@@ -1098,7 +1115,7 @@ TransformLine(int const lineno)
/* find the first differing character */
while (firstChar < screen_columns &&
- newLine[firstChar] == oldLine[firstChar])
+ newLine[firstChar] == oldLine[firstChar])
firstChar++;
/* if there wasn't one, we're done */
@@ -1144,15 +1161,15 @@ TransformLine(int const lineno)
nLastChar = screen_columns - 1;
while (nLastChar > firstChar
- && newLine[nLastChar] == oldLine[nLastChar])
+ && newLine[nLastChar] == oldLine[nLastChar])
nLastChar--;
if (nLastChar >= firstChar) {
GoTo(lineno, firstChar);
PutRange(oldLine, newLine, lineno, firstChar, nLastChar);
memcpy(oldLine + firstChar,
- newLine + firstChar,
- (nLastChar - firstChar + 1) * sizeof(chtype));
+ newLine + firstChar,
+ (nLastChar - firstChar + 1) * sizeof(chtype));
}
return;
}
@@ -1174,8 +1191,8 @@ TransformLine(int const lineno)
PutChar(newLine[firstChar]);
ClrToEOL(blank, FALSE);
} else if ((nLastChar != oLastChar)
- && (newLine[nLastChar] != oldLine[oLastChar]
- || !(_nc_idcok && has_ic()))) {
+ && (newLine[nLastChar] != oldLine[oLastChar]
+ || !(_nc_idcok && has_ic()))) {
GoTo(lineno, firstChar);
if ((oLastChar - nLastChar) > SP->_el_cost) {
if (PutRange(oldLine, newLine, lineno, firstChar, nLastChar))
@@ -1220,7 +1237,7 @@ TransformLine(int const lineno)
if (DelCharCost(oLastChar - nLastChar)
> SP->_el_cost + nLastNonblank - (n + 1)) {
if (PutRange(oldLine, newLine, lineno,
- n + 1, nLastNonblank))
+ n + 1, nLastNonblank))
GoTo(lineno, nLastNonblank + 1);
ClrToEOL(blank, FALSE);
} else {
@@ -1242,8 +1259,8 @@ TransformLine(int const lineno)
/* update the code's internal representation */
if (screen_columns > firstChar)
memcpy(oldLine + firstChar,
- newLine + firstChar,
- (screen_columns - firstChar) * sizeof(chtype));
+ newLine + firstChar,
+ (screen_columns - firstChar) * sizeof(chtype));
}
/*
@@ -1259,9 +1276,9 @@ ClearScreen(chtype blank)
int i, j;
bool fast_clear = (clear_screen || clr_eos || clr_eol);
- T(("ClearScreen() called"));
+ TR(TRACE_UPDATE, ("ClearScreen() called"));
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (SP->_coloron
&& !SP->_default_color) {
_nc_do_color(COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
@@ -1311,7 +1328,7 @@ ClearScreen(chtype blank)
curscr->_line[i].text[j] = blank;
}
- T(("screen cleared"));
+ TR(TRACE_UPDATE, ("screen cleared"));
}
/*
@@ -1324,7 +1341,7 @@ ClearScreen(chtype blank)
static void
InsStr(chtype * line, int count)
{
- T(("InsStr(%p,%d) called", line, count));
+ TR(TRACE_UPDATE, ("InsStr(%p,%d) called", line, count));
/* Prefer parm_ich as it has the smallest cost - no need to shift
* the whole line on each character. */
@@ -1379,7 +1396,8 @@ DelChar(int count)
{
int n;
- T(("DelChar(%d) called, position = (%d,%d)", count, newscr->_cury, newscr->_curx));
+ TR(TRACE_UPDATE, ("DelChar(%d) called, position = (%d,%d)", count,
+ newscr->_cury, newscr->_curx));
if (parm_dch) {
TPUTS_TRACE("parm_dch");
@@ -1480,7 +1498,7 @@ scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtype blank)
} else
return ERR;
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (FILL_BCE()) {
for (i = 0; i < n; i++) {
GoTo(bot - i, 0);
@@ -1536,7 +1554,7 @@ scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chtype blank)
} else
return ERR;
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (FILL_BCE()) {
for (i = 0; i < n; i++) {
GoTo(top + i, 0);
@@ -1616,18 +1634,11 @@ _nc_scrolln(int n, int top, int bot, int maxy)
* Explicitly clear if stuff pushed off top of region might
* be saved by the terminal.
*/
- if (non_dest_scroll_region || (memory_above && top == 0)) {
- for (i = 0; i < n; i++) {
- GoTo(i, 0);
- ClrToEOL(BLANK, FALSE);
- }
- }
-
res = scroll_csr_forward(n, top, bot, 0, maxy, blank);
if (res == ERR && change_scroll_region) {
if ((((n == 1 && scroll_forward) || parm_index)
- && (SP->_cursrow == bot || SP->_cursrow == bot - 1))
+ && (SP->_cursrow == bot || SP->_cursrow == bot - 1))
&& save_cursor && restore_cursor) {
cursor_saved = TRUE;
TPUTS_TRACE("save_cursor");
@@ -1651,23 +1662,24 @@ _nc_scrolln(int n, int top, int bot, int maxy)
if (res == ERR && _nc_idlok)
res = scroll_idl(n, top, bot - n + 1, blank);
- } else { /* (n < 0) - scroll down (backward) */
+
/*
- * Do explicit clear to end of region if it's possible that the
- * terminal might hold on to stuff we push off the end.
+ * Clear the newly shifted-in text.
*/
- if (non_dest_scroll_region || (memory_below && bot == maxy)) {
+ if (res != ERR
+ && (non_dest_scroll_region || (memory_below && bot == maxy))) {
if (bot == maxy && clr_eos) {
- GoTo(maxy + n, 0);
+ GoTo(bot - n, 0);
ClrToEOS(BLANK);
- } else if (clr_eol) {
- for (i = 0; i < -n; i++) {
- GoTo(maxy + n + i, 0);
+ } else {
+ for (i = 0; i < n; i++) {
+ GoTo(bot - i, 0);
ClrToEOL(BLANK, FALSE);
}
}
}
+ } else { /* (n < 0) - scroll down (backward) */
res = scroll_csr_backward(-n, top, bot, 0, maxy, blank);
if (res == ERR && change_scroll_region) {
@@ -1695,6 +1707,17 @@ _nc_scrolln(int n, int top, int bot, int maxy)
if (res == ERR && _nc_idlok)
res = scroll_idl(-n, bot + n + 1, top, blank);
+
+ /*
+ * Clear the newly shifted-in text.
+ */
+ if (res != ERR
+ && (non_dest_scroll_region || (memory_above && top == 0))) {
+ for (i = 0; i < -n; i++) {
+ GoTo(i + top, 0);
+ ClrToEOL(BLANK, FALSE);
+ }
+ }
}
if (res == ERR)
@@ -1745,7 +1768,7 @@ void
_nc_screen_wrap(void)
{
UpdateAttrs(A_NORMAL);
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (SP->_coloron
&& !SP->_default_color) {
SP->_default_color = TRUE;
@@ -1772,7 +1795,7 @@ _nc_do_xmc_glitch(attr_t previous)
SP->_curscol += magic_cookie_glitch;
if (SP->_curscol >= SP->_columns)
wrap_cursor();
- T(("bumped to %d,%d after cookie", SP->_cursrow, SP->_curscol));
+ TR(TRACE_UPDATE, ("bumped to %d,%d after cookie", SP->_cursrow, SP->_curscol));
}
chg >>= 1;
}
diff --git a/lib/libform/form_fieldtype.3 b/lib/libform/form_fieldtype.3
index 72ff4b665a9..1c83fda3330 100644
--- a/lib/libform/form_fieldtype.3
+++ b/lib/libform/form_fieldtype.3
@@ -1,5 +1,5 @@
'\" t
-.\" $OpenBSD: form_fieldtype.3,v 1.8 2000/07/24 04:06:11 millert Exp $
+.\" $OpenBSD: form_fieldtype.3,v 1.9 2000/10/08 22:47:08 millert Exp $
.\"
.\"***************************************************************************
.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: From: form_fieldtype.3x,v 1.8 2000/07/15 22:02:03 tom Exp $
+.\" $From: form_fieldtype.3x,v 1.8 2000/07/15 22:02:03 tom Exp $
.TH form_fieldtype 3 ""
.SH NAME
\fBform_fieldtype\fR - define validation-field types
diff --git a/lib/libform/fty_enum.c b/lib/libform/fty_enum.c
index 3139cdfd040..a27a9ca8751 100644
--- a/lib/libform/fty_enum.c
+++ b/lib/libform/fty_enum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fty_enum.c,v 1.6 2000/04/25 16:39:05 millert Exp $ */
+/* $OpenBSD: fty_enum.c,v 1.7 2000/10/08 22:47:09 millert Exp $ */
/*
@@ -15,7 +15,7 @@
#include "form.priv.h"
-MODULE_ID("$From: fty_enum.c,v 1.11 2000/03/19 01:09:56 Bruno.Haible Exp $")
+MODULE_ID("$From: fty_enum.c,v 1.13 2000/09/10 00:55:26 juergen Exp $")
typedef struct {
char **kwds;
@@ -35,20 +35,21 @@ typedef struct {
static void *Make_Enum_Type(va_list * ap)
{
enumARG *argp = (enumARG *)malloc(sizeof(enumARG));
- char **kp;
- int cnt=0;
if (argp)
{
+ int cnt = 0;
+ char **kp = (char **)0;
int ccase, cunique;
+
argp->kwds = va_arg(*ap,char **);
ccase = va_arg(*ap,int);
cunique = va_arg(*ap,int);
argp->checkcase = ccase ? TRUE : FALSE;
argp->checkunique = cunique ? TRUE : FALSE;
-
+
kp = argp->kwds;
- while( (*kp++) ) cnt++;
+ while( (kp && *kp++) ) cnt++;
argp->count = cnt;
}
return (void *)argp;
@@ -64,11 +65,12 @@ static void *Make_Enum_Type(va_list * ap)
+--------------------------------------------------------------------------*/
static void *Copy_Enum_Type(const void * argp)
{
- const enumARG *ap = (const enumARG *)argp;
enumARG *result = (enumARG *)0;
if (argp)
{
+ const enumARG *ap = (const enumARG *)argp;
+
result = (enumARG *)malloc(sizeof(enumARG));
if (result)
*result = *ap;
@@ -167,14 +169,14 @@ static bool Check_Enum_Field(FIELD * field, const void * argp)
char *s, *t, *p;
int res;
- while( (s=(*kwds++)) )
+ while( kwds && (s=(*kwds++)) )
{
if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH)
{
p=t=s; /* t is at least a partial match */
if ((unique && res!=EXACT))
{
- while( (p = *kwds++) )
+ while( kwds && (p = *kwds++) )
{
if ((res=Compare((unsigned char *)p,bp,ccase))!=NOMATCH)
{
@@ -220,18 +222,20 @@ static bool Next_Enum(FIELD * field, const void * argp)
int cnt = args->count;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
- while(cnt--)
- {
- if (Compare((unsigned char *)(*kwds++),bp,ccase)==EXACT)
- break;
- }
- if (cnt<=0)
- kwds = args->kwds;
- if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
- {
- set_field_buffer(field,0,*kwds);
- return TRUE;
- }
+ if (kwds) {
+ while(cnt--)
+ {
+ if (Compare((unsigned char *)(*kwds++),bp,ccase)==EXACT)
+ break;
+ }
+ if (cnt<=0)
+ kwds = args->kwds;
+ if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
+ {
+ set_field_buffer(field,0,*kwds);
+ return TRUE;
+ }
+ }
return FALSE;
}
@@ -254,20 +258,22 @@ static bool Previous_Enum(FIELD * field, const void * argp)
bool ccase = args->checkcase;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
- while(cnt--)
- {
- if (Compare((unsigned char *)(*kwds--),bp,ccase)==EXACT)
- break;
- }
-
- if (cnt<=0)
- kwds = &args->kwds[args->count-1];
-
- if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
- {
- set_field_buffer(field,0,*kwds);
- return TRUE;
- }
+ if (kwds) {
+ while(cnt--)
+ {
+ if (Compare((unsigned char *)(*kwds--),bp,ccase)==EXACT)
+ break;
+ }
+
+ if (cnt<=0)
+ kwds = &args->kwds[args->count-1];
+
+ if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
+ {
+ set_field_buffer(field,0,*kwds);
+ return TRUE;
+ }
+ }
return FALSE;
}
diff --git a/lib/libmenu/mf_common.h b/lib/libmenu/mf_common.h
index 77dc33749e6..b88aa91ac5b 100644
--- a/lib/libmenu/mf_common.h
+++ b/lib/libmenu/mf_common.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: mf_common.h,v 1.5 1999/05/17 03:04:26 millert Exp $ */
+/* $OpenBSD: mf_common.h,v 1.6 2000/10/08 22:47:07 millert Exp $ */
/****************************************************************************
- * 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 *
@@ -58,7 +58,7 @@ extern int errno;
#include <nc_alloc.h>
-#ifdef USE_RCS_IDS
+#if USE_RCS_IDS
#define MODULE_ID(id) static const char Ident[] = id;
#else
#define MODULE_ID(id) /*nothing*/
diff --git a/lib/libpanel/panel.3 b/lib/libpanel/panel.3
index 1d4021c4c0b..e9c40ef19c3 100644
--- a/lib/libpanel/panel.3
+++ b/lib/libpanel/panel.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: panel.3,v 1.6 1998/07/24 17:08:21 millert Exp $
+.\" $OpenBSD: panel.3,v 1.7 2000/10/08 22:47:06 millert Exp $
.\"
.\"***************************************************************************
.\" Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: panel.3x,v 1.9 1998/03/11 21:12:53 juergen Exp $
+.\" $From: panel.3x,v 1.10 2000/08/13 01:56:47 tom Exp $
.TH panel 3 ""
.ds n 5
.ds d /usr/share/terminfo
diff --git a/lib/libpanel/panel.priv.h b/lib/libpanel/panel.priv.h
index e6d2a7878b9..1b497896e43 100644
--- a/lib/libpanel/panel.priv.h
+++ b/lib/libpanel/panel.priv.h
@@ -1,5 +1,34 @@
-/* $OpenBSD: panel.priv.h,v 1.5 2000/01/16 01:35:18 millert Exp $ */
-/* $From: panel.priv.h,v 1.13 2000/01/15 20:39:53 juergen Exp $ */
+/* $OpenBSD: panel.priv.h,v 1.6 2000/10/08 22:47:07 millert Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/* $From: panel.priv.h,v 1.14 2000/09/02 18:22:23 tom Exp $ */
#ifndef _PANEL_PRIV_H
#define _PANEL_PRIV_H
@@ -29,7 +58,7 @@
# define INLINE
#endif
-#ifdef USE_RCS_IDS
+#if USE_RCS_IDS
# define MODULE_ID(id) static const char Ident[] = id;
#else
# define MODULE_ID(id) /*nothing*/