summaryrefslogtreecommitdiffstats
path: root/contrib/ncurses/progs
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
committerpeter <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
commit9a7523d4b2c09cefef7372e8a011b8d54fb07e5e (patch)
treebd986d58f5a6e348466b5362637ba93e6cd5bf8c /contrib/ncurses/progs
parent635048e64c28721e175b82444857d679f6740aa2 (diff)
downloadFreeBSD-src-9a7523d4b2c09cefef7372e8a011b8d54fb07e5e.zip
FreeBSD-src-9a7523d4b2c09cefef7372e8a011b8d54fb07e5e.tar.gz
Import ncurses-5.2-20020518 onto the vendor branch.
Obtained from: ftp://dickey.his.com/ncurses/
Diffstat (limited to 'contrib/ncurses/progs')
-rwxr-xr-xcontrib/ncurses/progs/MKtermsort.sh21
-rw-r--r--contrib/ncurses/progs/Makefile.in41
-rw-r--r--contrib/ncurses/progs/dump_entry.c4
-rw-r--r--contrib/ncurses/progs/infocmp.c116
-rw-r--r--contrib/ncurses/progs/progs.priv.h6
-rw-r--r--contrib/ncurses/progs/tic.c8
-rw-r--r--contrib/ncurses/progs/toe.c52
-rw-r--r--contrib/ncurses/progs/tput.c36
-rw-r--r--contrib/ncurses/progs/tset.c77
9 files changed, 222 insertions, 139 deletions
diff --git a/contrib/ncurses/progs/MKtermsort.sh b/contrib/ncurses/progs/MKtermsort.sh
index 5486fd7..c3495c4 100755
--- a/contrib/ncurses/progs/MKtermsort.sh
+++ b/contrib/ncurses/progs/MKtermsort.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: MKtermsort.sh,v 1.6 2000/01/25 11:35:36 tom Exp $
+# $Id: MKtermsort.sh,v 1.7 2001/05/26 23:37:57 tom Exp $
#
# MKtermsort.sh -- generate indirection vectors for the various sort methods
#
@@ -15,6 +15,11 @@ export LC_ALL
AWK=${1-awk}
DATA=${2-../include/Caps}
+data=data$$
+trap 'rm -f $data' 1 2 5 15
+sed -e 's/[ ]\+/ /g' < $DATA >$data
+DATA=$data
+
echo "/*";
echo " * termsort.c --- sort order arrays for use by infocmp.";
echo " *";
@@ -104,24 +109,26 @@ echo "";
echo "static const bool bool_from_termcap[] = {";
$AWK <$DATA '
-$3 == "bool" && substr($5, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
-$3 == "bool" && substr($5, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
+$3 == "bool" && substr($7, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
+$3 == "bool" && substr($7, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
'
echo "};";
echo "";
echo "static const bool num_from_termcap[] = {";
$AWK <$DATA '
-$3 == "num" && substr($5, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
-$3 == "num" && substr($5, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
+$3 == "num" && substr($7, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
+$3 == "num" && substr($7, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
'
echo "};";
echo "";
echo "static const bool str_from_termcap[] = {";
$AWK <$DATA '
-$3 == "str" && substr($5, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
-$3 == "str" && substr($5, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
+$3 == "str" && substr($7, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
+$3 == "str" && substr($7, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
'
echo "};";
echo "";
+
+rm -f $data
diff --git a/contrib/ncurses/progs/Makefile.in b/contrib/ncurses/progs/Makefile.in
index f0d772a..43b85c4 100644
--- a/contrib/ncurses/progs/Makefile.in
+++ b/contrib/ncurses/progs/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.52 2001/03/24 19:53:31 tom Exp $
+# $Id: Makefile.in,v 1.56 2001/12/08 18:48:01 tom Exp $
##############################################################################
# Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. #
# #
@@ -107,7 +107,10 @@ AUTO_SRC = \
termsort.c \
transform.h
-PROGS = tic$x toe$x infocmp$x clear$x tput$x tset$x
+# tic and toe rely on direct access to the terminfo database
+GET_PROGS = infocmp$x clear$x tput$x tset$x
+PUT_PROGS = @MAKE_TERMINFO@ tic$x toe$x
+PROGS = $(PUT_PROGS) $(GET_PROGS)
TESTPROGS = mvcur$x tctest$x hardscroll$x hashmap$x
@@ -147,35 +150,35 @@ transform.h :
echo "#define PROG_INIT \"$(actual_init)\"" >>$@
install.progs: $(AUTO_SRC) $(PROGS) $(DESTDIR)$(bindir)
- $(LIBTOOL) $(INSTALL_PROGRAM) tic$x $(DESTDIR)$(bindir)/$(actual_tic)
- $(LIBTOOL) $(INSTALL_PROGRAM) toe$x $(DESTDIR)$(bindir)/$(actual_toe)
+@MAKE_TERMINFO@ $(LIBTOOL) $(INSTALL_PROGRAM) tic$x $(DESTDIR)$(bindir)/$(actual_tic)
+@MAKE_TERMINFO@ $(LIBTOOL) $(INSTALL_PROGRAM) toe$x $(DESTDIR)$(bindir)/$(actual_toe)
+@MAKE_TERMINFO@ @echo "linking $(actual_infotocap) to $(actual_tic)"
+@MAKE_TERMINFO@ -@rm -f $(DESTDIR)$(bindir)/$(actual_infotocap)
+@MAKE_TERMINFO@ (cd $(DESTDIR)$(bindir) && $(LN_S) $(actual_tic) $(actual_infotocap))
+@MAKE_TERMINFO@ @echo "linking $(actual_captoinfo) to $(actual_tic)"
+@MAKE_TERMINFO@ -@rm -f $(DESTDIR)$(bindir)/$(actual_captoinfo)
+@MAKE_TERMINFO@ (cd $(DESTDIR)$(bindir) && $(LN_S) $(actual_tic) $(actual_captoinfo))
$(LIBTOOL) $(INSTALL_PROGRAM) infocmp$x $(DESTDIR)$(bindir)/$(actual_infocmp)
$(LIBTOOL) $(INSTALL_PROGRAM) clear$x $(DESTDIR)$(bindir)/$(actual_clear)
$(LIBTOOL) $(INSTALL_PROGRAM) tput$x $(DESTDIR)$(bindir)/$(actual_tput)
$(LIBTOOL) $(INSTALL_PROGRAM) tset$x $(DESTDIR)$(bindir)/$(actual_tset)
- @echo "linking $(actual_captoinfo) to $(actual_tic)"
- -@rm -f $(DESTDIR)$(bindir)/$(actual_captoinfo)
- (cd $(DESTDIR)$(bindir) && $(LN_S) $(actual_tic) $(actual_captoinfo))
- @echo "linking $(actual_infotocap) to $(actual_tic)"
- -@rm -f $(DESTDIR)$(bindir)/$(actual_infotocap)
- (cd $(DESTDIR)$(bindir) && $(LN_S) $(actual_tic) $(actual_infotocap))
@echo "linking $(actual_reset) to $(actual_tset)"
-@rm -f $(DESTDIR)$(bindir)/$(actual_reset)
(cd $(DESTDIR)$(bindir) && $(LN_S) $(actual_tset) $(actual_reset))
uninstall.progs:
- -@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_tic)
- -@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_toe)
+@MAKE_TERMINFO@ -@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_tic)
+@MAKE_TERMINFO@ -@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_toe)
+@MAKE_TERMINFO@ -@rm -f $(DESTDIR)$(bindir)/$(actual_captoinfo)
+@MAKE_TERMINFO@ -@rm -f $(DESTDIR)$(bindir)/$(actual_infotocap)
-@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_infocmp)
-@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_clear)
-@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_tput)
-@$(LIBTOOL) rm -f $(DESTDIR)$(bindir)/$(actual_tset)
- -@rm -f $(DESTDIR)$(bindir)/$(actual_captoinfo)
- -@rm -f $(DESTDIR)$(bindir)/$(actual_infotocap)
-@rm -f $(DESTDIR)$(bindir)/$(actual_reset)
$(DESTDIR)$(bindir) :
- $(srcdir)/../mkinstalldirs $@
+ sh $(srcdir)/../mkinstalldirs $@
#
# Utilities normally built by make all start here
@@ -222,7 +225,7 @@ tset$x: $(DEPS_TSET) $(DEPS_CURSES) transform.h
@ECHO_LINK@ $(LINK) $(DEPS_TSET) $(LDFLAGS_DEFAULT) -o $@
termsort.c: $(srcdir)/MKtermsort.sh
- sh -c "$(srcdir)/MKtermsort.sh $(AWK) $(srcdir)/../include/Caps" >$@
+ sh -c "$(srcdir)/MKtermsort.sh $(AWK) $(srcdir)/../include/@TERMINFO_CAPS@" >$@
#
# Utility productions start here
@@ -235,7 +238,7 @@ tags:
@MAKE_UPPER_TAGS@ etags *.[ch]
mostlyclean ::
- -rm -f core tags TAGS *~ *.i *.ln *.atac trace
+ -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
-rm -f $(TESTPROGS)
clean :: mostlyclean
@@ -257,10 +260,10 @@ $(DEPS_CURSES) :
cd ../ncurses; $(MAKE) $(CF_MFLAGS)
lint:
+@MAKE_TERMINFO@ $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tic.c $(srcdir)/dump_entry.c $(LINT_LIBS)
+@MAKE_TERMINFO@ $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/toe.c $(srcdir)/dump_entry.c $(LINT_LIBS)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/clear.c $(LINT_LIBS)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/infocmp.c $(srcdir)/dump_entry.c $(LINT_LIBS)
- $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tic.c $(srcdir)/dump_entry.c $(LINT_LIBS)
- $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/toe.c $(srcdir)/dump_entry.c $(LINT_LIBS)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tput.c $(LINT_LIBS)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tset.c $(srcdir)/dump_entry.c $(LINT_LIBS)
diff --git a/contrib/ncurses/progs/dump_entry.c b/contrib/ncurses/progs/dump_entry.c
index 4320c09..5245a47 100644
--- a/contrib/ncurses/progs/dump_entry.c
+++ b/contrib/ncurses/progs/dump_entry.c
@@ -38,7 +38,7 @@
#include "termsort.c" /* this C file is generated */
#include <parametrized.h> /* so is this */
-MODULE_ID("$Id: dump_entry.c,v 1.55 2001/03/10 19:45:51 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.56 2001/08/12 00:21:22 tom Exp $")
#define INDENT 8
#define DISCARD(string) string = ABSENT_STRING
@@ -56,7 +56,6 @@ static int sortmode; /* sort mode to use */
static int width = 60; /* max line width for listings */
static int column; /* current column, limited by 'width' */
static int oldcol; /* last value of column before wrap */
-static int tracelevel; /* level of debug output */
static bool pretty; /* true if we format if-then-else strings */
static DYNBUF outbuf;
@@ -172,7 +171,6 @@ dump_init(const char *version, int mode, int sort, int twidth, int traceval,
{
width = twidth;
pretty = formatted;
- tracelevel = traceval;
/* versions */
if (version == 0)
diff --git a/contrib/ncurses/progs/infocmp.c b/contrib/ncurses/progs/infocmp.c
index 5d1a111..69f00ae 100644
--- a/contrib/ncurses/progs/infocmp.c
+++ b/contrib/ncurses/progs/infocmp.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,7 +41,7 @@
#include <term_entry.h>
#include <dump_entry.h>
-MODULE_ID("$Id: infocmp.c,v 1.60 2001/02/24 22:03:12 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.63 2001/09/22 19:57:40 tom Exp $")
#define L_CURL "{"
#define R_CURL "}"
@@ -937,30 +937,75 @@ usage(void)
}
static char *
-name_initializer(const char *type)
+any_initializer(const char *fmt, const char *type)
{
static char *initializer;
char *s;
if (initializer == 0)
- initializer = (char *) malloc(strlen(entries->tterm.term_names) + 20);
+ initializer = (char *) malloc(strlen(entries->tterm.term_names) +
+ strlen(type) + strlen(fmt));
- (void) sprintf(initializer, "%s_data_%s", type, entries->tterm.term_names);
+ (void) strcpy(initializer, entries->tterm.term_names);
for (s = initializer; *s != 0 && *s != '|'; s++) {
- if (!isalnum(CharOf(*s)))
+ if (!isalnum(UChar(*s)))
*s = '_';
}
*s = 0;
+ (void) sprintf(s, fmt, type);
return initializer;
}
+static char *
+name_initializer(const char *type)
+{
+ return any_initializer("_%s_data", type);
+}
+
+static char *
+string_variable(const char *type)
+{
+ return any_initializer("_s_%s", type);
+}
+
/* dump C initializers for the terminal type */
static void
dump_initializers(TERMTYPE * term)
{
int n;
- const char *str = 0;
int size;
+ const char *str = 0;
+
+ printf("\nstatic char %s[] = \"%s\";\n\n",
+ name_initializer("alias"), entries->tterm.term_names);
+
+ for_each_string(n, term) {
+ char buf[MAX_STRING], *sp, *tp;
+
+ if (VALID_STRING(term->Strings[n])) {
+ tp = buf;
+ *tp++ = '"';
+ for (sp = term->Strings[n];
+ *sp != 0 && (tp - buf) < MAX_STRING - 6;
+ sp++) {
+ if (isascii(UChar(*sp))
+ && isprint(UChar(*sp))
+ && *sp != '\\'
+ && *sp != '"')
+ *tp++ = *sp;
+ else {
+ (void) sprintf(tp, "\\%03o", UChar(*sp));
+ tp += 4;
+ }
+ }
+ *tp++ = '"';
+ *tp = '\0';
+ size += (strlen(term->Strings[n]) + 1);
+ (void) printf("static char %-20s[] = %s;\n",
+ string_variable(ExtStrname(term, n, strnames)), buf);
+ }
+ }
+ printf("\n");
(void) printf("static char %s[] = %s\n", name_initializer("bool"), L_CURL);
@@ -1015,52 +1060,47 @@ dump_initializers(TERMTYPE * term)
(void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL);
for_each_string(n, term) {
- char buf[MAX_STRING], *sp, *tp;
if (term->Strings[n] == ABSENT_STRING)
str = "ABSENT_STRING";
else if (term->Strings[n] == CANCELLED_STRING)
str = "CANCELLED_STRING";
else {
- tp = buf;
- *tp++ = '"';
- for (sp = term->Strings[n];
- *sp != 0 && (tp - buf) < MAX_STRING - 6;
- sp++) {
- if (isascii(CharOf(*sp))
- && isprint(CharOf(*sp))
- && *sp != '\\'
- && *sp != '"')
- *tp++ = *sp;
- else {
- (void) sprintf(tp, "\\%03o", CharOf(*sp));
- tp += 4;
- }
- }
- *tp++ = '"';
- *tp = '\0';
- size += (strlen(term->Strings[n]) + 1);
- str = buf;
+ str = string_variable(ExtStrname(term, n, strnames));
}
-#if NCURSES_XNAMES
- if (n == STRCOUNT) {
- (void) printf("%s;\n", R_CURL);
-
- (void) printf("static char * %s[] = %s\n",
- name_initializer("string_ext"), L_CURL);
- }
-#endif
(void) printf("\t/* %3d: %-8s */\t%s,\n", n,
ExtStrname(term, n, strnames), str);
}
(void) printf("%s;\n", R_CURL);
+
+#if NCURSES_XNAMES
+ if ((NUM_BOOLEANS(term) != BOOLCOUNT)
+ || (NUM_NUMBERS(term) != NUMCOUNT)
+ || (NUM_STRINGS(term) != STRCOUNT)) {
+ (void) printf("static char * %s[] = %s\n",
+ name_initializer("string_ext"), L_CURL);
+ for (n = BOOLCOUNT; n < NUM_BOOLEANS(term); ++n) {
+ (void) printf("\t/* %3d: bool */\t\"%s\",\n",
+ n, ExtBoolname(term, n, boolnames));
+ }
+ for (n = NUMCOUNT; n < NUM_NUMBERS(term); ++n) {
+ (void) printf("\t/* %3d: num */\t\"%s\",\n",
+ n, ExtNumname(term, n, numnames));
+ }
+ for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) {
+ (void) printf("\t/* %3d: str */\t\"%s\",\n",
+ n, ExtStrname(term, n, strnames));
+ }
+ (void) printf("%s;\n", R_CURL);
+ }
+#endif
}
/* dump C initializers for the terminal type */
static void
dump_termtype(TERMTYPE * term)
{
- (void) printf("\t%s\n\t\t\"%s\",\n", L_CURL, term->term_names);
+ (void) printf("\t%s\n\t\t%s,\n", L_CURL, name_initializer("alias"));
(void) printf("\t\t(char *)0,\t/* pointer to string table */\n");
(void) printf("\t\t%s,\n", name_initializer("bool"));
@@ -1072,7 +1112,9 @@ dump_termtype(TERMTYPE * term)
(void) printf("#if NCURSES_XNAMES\n");
(void) printf("\t\t(char *)0,\t/* pointer to extended string table */\n");
(void) printf("\t\t%s,\t/* ...corresponding names */\n",
- (NUM_STRINGS(term) != STRCOUNT)
+ ((NUM_BOOLEANS(term) != BOOLCOUNT)
+ || (NUM_NUMBERS(term) != NUMCOUNT)
+ || (NUM_STRINGS(term) != STRCOUNT))
? name_initializer("string_ext")
: "(char **)0");
diff --git a/contrib/ncurses/progs/progs.priv.h b/contrib/ncurses/progs/progs.priv.h
index 1826275..9d13b3c 100644
--- a/contrib/ncurses/progs/progs.priv.h
+++ b/contrib/ncurses/progs/progs.priv.h
@@ -30,7 +30,7 @@
* Author: Thomas E. Dickey <dickey@clark.net> 1997,1998 *
****************************************************************************/
/*
- * $Id: progs.priv.h,v 1.26 2000/11/05 00:22:05 tom Exp $
+ * $Id: progs.priv.h,v 1.27 2001/06/18 18:43:52 tom Exp $
*
* progs.priv.h
*
@@ -165,12 +165,12 @@ extern int optind;
#if !HAVE_ISASCII
# undef isascii
# if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
-# define isascii(c) (CharOf(c) <= 127)
+# define isascii(c) (UChar(c) <= 127)
# else
# define isascii(c) 1 /* not really ascii anyway */
# endif
#endif
-#define CharOf(c) ((unsigned char)(c))
+#define UChar(c) ((unsigned char)(c))
#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
diff --git a/contrib/ncurses/progs/tic.c b/contrib/ncurses/progs/tic.c
index c74afc3..28292e6 100644
--- a/contrib/ncurses/progs/tic.c
+++ b/contrib/ncurses/progs/tic.c
@@ -44,7 +44,7 @@
#include <term_entry.h>
#include <transform.h>
-MODULE_ID("$Id: tic.c,v 1.90 2001/04/15 00:21:31 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.92 2001/06/18 18:44:01 tom Exp $")
const char *_nc_progname = "tic";
@@ -293,12 +293,12 @@ put_translate(int c)
static char *
stripped(char *src)
{
- while (isspace(CharOf(*src)))
+ while (isspace(UChar(*src)))
src++;
if (*src != '\0') {
char *dst = strcpy(malloc(strlen(src) + 1), src);
size_t len = strlen(dst);
- while (--len != 0 && isspace(CharOf(dst[len])))
+ while (--len != 0 && isspace(UChar(dst[len])))
dst[len] = '\0';
return dst;
}
@@ -445,7 +445,7 @@ main(int argc, char *argv[])
log_fp = stderr;
- _nc_progname = _nc_basename(argv[0]);
+ _nc_progname = _nc_rootname(argv[0]);
if ((infodump = (strcmp(_nc_progname, PROG_CAPTOINFO) == 0)) != FALSE) {
outform = F_TERMINFO;
diff --git a/contrib/ncurses/progs/toe.c b/contrib/ncurses/progs/toe.c
index b7afb67..7a75785 100644
--- a/contrib/ncurses/progs/toe.c
+++ b/contrib/ncurses/progs/toe.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 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,14 +43,14 @@
#include <dump_entry.h>
#include <term_entry.h>
-MODULE_ID("$Id: toe.c,v 1.24 2000/09/09 19:52:35 tom Exp $")
+MODULE_ID("$Id: toe.c,v 1.26 2001/06/16 11:00:41 tom Exp $")
#define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
const char *_nc_progname;
static int typelist(int eargc, char *eargv[], bool,
- void (*)(const char *, TERMTYPE *));
+ void (*)(const char *, TERMTYPE *));
static void deschook(const char *, TERMTYPE *);
#if NO_LEAKS
@@ -65,13 +65,27 @@ ExitProgram(int code) GCC_NORETURN;
}
#endif
+static bool
+is_a_file(char *path)
+{
+ struct stat sb;
+ return (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFREG);
+}
+
+static bool
+is_a_directory(char *path)
+{
+ struct stat sb;
+ return (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFDIR);
+}
+
static char *
get_directory(char *path)
{
if (path != 0) {
- struct stat sb;
- if (stat(path, &sb) != 0
- || (sb.st_mode & S_IFMT) != S_IFDIR
+ if (!is_a_directory(path)
|| access(path, R_OK | X_OK) != 0)
path = 0;
}
@@ -87,7 +101,7 @@ main(int argc, char *argv[])
int i, c;
int code;
- _nc_progname = _nc_basename(argv[0]);
+ _nc_progname = _nc_rootname(argv[0]);
while ((c = getopt(argc, argv, "huv:UV")) != EOF)
switch (c) {
@@ -153,12 +167,12 @@ main(int argc, char *argv[])
for (i = 0; i < rp->nuses; i++)
if (_nc_name_match(qp->tterm.term_names,
- rp->uses[i].name, "|")) {
+ rp->uses[i].name, "|")) {
if (matchcount++ == 0)
(void) printf("%s:",
- _nc_first_name(qp->tterm.term_names));
+ _nc_first_name(qp->tterm.term_names));
(void) printf(" %s",
- _nc_first_name(rp->tterm.term_names));
+ _nc_first_name(rp->tterm.term_names));
}
}
if (matchcount)
@@ -214,8 +228,8 @@ deschook(const char *cn, TERMTYPE * tp)
static int
typelist(int eargc, char *eargv[],
- bool verbosity,
- void (*hook) (const char *, TERMTYPE * tp))
+ bool verbosity,
+ void (*hook) (const char *, TERMTYPE * tp))
/* apply a function to each entry in given terminfo directories */
{
int i;
@@ -227,8 +241,8 @@ typelist(int eargc, char *eargv[],
if ((termdir = opendir(eargv[i])) == 0) {
(void) fflush(stdout);
(void) fprintf(stderr,
- "%s: can't open terminfo directory %s\n",
- _nc_progname, eargv[i]);
+ "%s: can't open terminfo directory %s\n",
+ _nc_progname, eargv[i]);
return (EXIT_FAILURE);
} else if (verbosity)
(void) printf("#\n#%s:\n#\n", eargv[i]);
@@ -245,7 +259,9 @@ typelist(int eargc, char *eargv[],
continue;
(void) sprintf(buf, "%s/%s/", eargv[i], name_1);
- chdir(buf);
+ if (chdir(buf) != 0)
+ continue;
+
entrydir = opendir(".");
while ((entry = readdir(entrydir)) != 0) {
char name_2[PATH_MAX];
@@ -255,15 +271,15 @@ typelist(int eargc, char *eargv[],
len = NAMLEN(entry);
strncpy(name_2, entry->d_name, len)[len] = '\0';
- if (isDotname(name_2))
+ if (isDotname(name_2) || !is_a_file(name_2))
continue;
status = _nc_read_file_entry(name_2, &lterm);
if (status <= 0) {
(void) fflush(stdout);
(void) fprintf(stderr,
- "toe: couldn't open terminfo file %s.\n",
- name_2);
+ "toe: couldn't open terminfo file %s.\n",
+ name_2);
return (EXIT_FAILURE);
}
diff --git a/contrib/ncurses/progs/tput.c b/contrib/ncurses/progs/tput.c
index 7aab909..3b65d15 100644
--- a/contrib/ncurses/progs/tput.c
+++ b/contrib/ncurses/progs/tput.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 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 *
@@ -45,7 +45,7 @@
#endif
#include <transform.h>
-MODULE_ID("$Id: tput.c,v 1.26 2001/03/24 21:59:48 tom Exp $")
+MODULE_ID("$Id: tput.c,v 1.30 2001/07/22 00:16:33 tom Exp $")
#define PUTS(s) fputs(s, stdout)
#define PUTCHAR(c) putchar(c)
@@ -132,7 +132,9 @@ tput(int argc, char *argv[])
int status;
FILE *f;
- check_aliases(name = argv[0]);
+ if ((name = argv[0]) == 0)
+ name = "";
+ check_aliases(name);
if (is_reset || is_init) {
if (init_prog != 0) {
system(init_prog);
@@ -153,15 +155,21 @@ tput(int argc, char *argv[])
}
FLUSH;
+#ifdef set_lr_margin
if (set_lr_margin != 0) {
PUTS(tparm(set_lr_margin, 0, columns - 1));
- } else if (set_left_margin_parm != 0
- && set_right_margin_parm != 0) {
+ } else
+#endif
+#ifdef set_left_margin_parm
+ if (set_left_margin_parm != 0
+ && set_right_margin_parm != 0) {
PUTS(tparm(set_left_margin_parm, 0));
PUTS(tparm(set_right_margin_parm, columns - 1));
- } else if (clear_margins != 0
- && set_left_margin != 0
- && set_right_margin != 0) {
+ } else
+#endif
+ if (clear_margins != 0
+ && set_left_margin != 0
+ && set_right_margin != 0) {
PUTS(clear_margins);
if (carriage_return != 0) {
PUTS(carriage_return);
@@ -321,7 +329,7 @@ main(int argc, char **argv)
char buf[BUFSIZ];
int errors = 0;
- check_aliases(prg_name = _nc_basename(argv[0]));
+ check_aliases(prg_name = _nc_rootname(argv[0]));
term = getenv("TERM");
@@ -376,14 +384,18 @@ main(int argc, char **argv)
/* crack the argument list into a dope vector */
for (cp = buf; *cp; cp++) {
- if (isspace(CharOf(*cp)))
+ if (isspace(UChar(*cp))) {
*cp = '\0';
- else if (cp == buf || cp[-1] == 0)
+ } else if (cp == buf || cp[-1] == 0) {
argvec[argnum++] = cp;
+ if (argnum >= (int) SIZEOF(argvec) - 1)
+ break;
+ }
}
argvec[argnum] = 0;
- if (tput(argnum, argvec) != 0)
+ if (argnum != 0
+ && tput(argnum, argvec) != 0)
errors++;
}
diff --git a/contrib/ncurses/progs/tset.c b/contrib/ncurses/progs/tset.c
index f6e02db..0276c4b 100644
--- a/contrib/ncurses/progs/tset.c
+++ b/contrib/ncurses/progs/tset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 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 *
@@ -95,15 +95,15 @@ char *ttyname(int fd);
#if NEED_PTEM_H
/* they neglected to define struct winsize in termios.h -- it's only
in termio.h */
-#include <sys/stream.h>
-#include <sys/ptem.h>
+#include <sys/stream.h>
+#include <sys/ptem.h>
#endif
#include <curses.h> /* for bool typedef */
#include <dump_entry.h>
#include <transform.h>
-MODULE_ID("$Id: tset.c,v 0.49 2001/02/24 23:29:33 tom Exp $")
+MODULE_ID("$Id: tset.c,v 0.52 2001/09/29 21:13:56 tom Exp $")
extern char **environ;
@@ -112,15 +112,16 @@ extern char **environ;
const char *_nc_progname = "tset";
-static TTY mode, oldmode;
+static TTY mode, oldmode, original;
+static bool can_restore = FALSE;
static bool isreset = FALSE; /* invoked as reset */
static int terasechar = -1; /* new erase character */
static int intrchar = -1; /* new interrupt character */
static int tkillchar = -1; /* new kill character */
static int tlines, tcolumns; /* window size */
-#define LOWERCASE(c) ((isalpha(CharOf(c)) && isupper(CharOf(c))) ? tolower(CharOf(c)) : (c))
+#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
static int
CaselessCmp(const char *a, const char *b)
@@ -135,6 +136,17 @@ CaselessCmp(const char *a, const char *b)
}
static void
+exit_error(void)
+{
+ if (can_restore)
+ SET_TTY(STDERR_FILENO, &original);
+ (void) fprintf(stderr, "\n");
+ fflush(stderr);
+ exit(EXIT_FAILURE);
+ /* NOTREACHED */
+}
+
+static void
err(const char *fmt,...)
{
va_list ap;
@@ -142,8 +154,7 @@ err(const char *fmt,...)
(void) fprintf(stderr, "tset: ");
(void) vfprintf(stderr, fmt, ap);
va_end(ap);
- (void) fprintf(stderr, "\n");
- exit(EXIT_FAILURE);
+ exit_error();
/* NOTREACHED */
}
@@ -152,25 +163,24 @@ failed(const char *msg)
{
char temp[BUFSIZ];
perror(strncat(strcpy(temp, "tset: "), msg, sizeof(temp) - 10));
- exit(EXIT_FAILURE);
+ exit_error();
/* NOTREACHED */
}
static void
cat(char *file)
{
- register int fd, nr;
+ FILE *fp;
+ size_t nr;
char buf[BUFSIZ];
- if ((fd = open(file, O_RDONLY, 0)) < 0)
+ if ((fp = fopen(file, "r")) == 0)
failed(file);
- while ((nr = read(fd, buf, sizeof(buf))) > 0)
- if (write(STDERR_FILENO, buf, (size_t) nr) == -1)
- failed("write to stderr");
- if (nr != 0)
- failed(file);
- (void) close(fd);
+ while ((nr = fread(buf, sizeof(char), sizeof(buf), fp)) != 0)
+ if (fwrite(buf, sizeof(char), nr, stderr) != nr)
+ failed("write to stderr");
+ fclose(fp);
}
static int
@@ -189,7 +199,8 @@ askuser(const char *dflt)
/* We can get recalled; if so, don't continue uselessly. */
if (feof(stdin) || ferror(stdin)) {
(void) fprintf(stderr, "\n");
- exit(EXIT_FAILURE);
+ exit_error();
+ /* NOTREACHED */
}
for (;;) {
if (dflt)
@@ -200,8 +211,8 @@ askuser(const char *dflt)
if (fgets(answer, sizeof(answer), stdin) == 0) {
if (dflt == 0) {
- (void) fprintf(stderr, "\n");
- exit(EXIT_FAILURE);
+ exit_error();
+ /* NOTREACHED */
}
return (dflt);
}
@@ -534,7 +545,7 @@ get_termcap_entry(char *userarg)
while (fgets(buffer, sizeof(buffer) - 1, fp) != 0) {
for (s = buffer, t = d = 0; *s; s++) {
- if (isspace(CharOf(*s)))
+ if (isspace(UChar(*s)))
*s = '\0';
else if (t == 0)
t = s;
@@ -757,11 +768,7 @@ reset_mode(void)
);
#endif
-#ifdef TERMIOS
- tcsetattr(STDERR_FILENO, TCSADRAIN, &mode);
-#else
- stty(STDERR_FILENO, &mode);
-#endif
+ SET_TTY(STDERR_FILENO, &mode);
}
/*
@@ -891,7 +898,7 @@ set_init(void)
#ifdef TAB3
if (oldmode.c_oflag & (TAB3 | ONLCR | OCRNL | ONLRET)) {
oldmode.c_oflag &= (TAB3 | ONLCR | OCRNL | ONLRET);
- tcsetattr(STDERR_FILENO, TCSADRAIN, &oldmode);
+ SET_TTY(STDERR_FILENO, &oldmode);
}
#endif
settle = set_tabs();
@@ -1034,8 +1041,9 @@ static void
usage(const char *pname)
{
(void) fprintf(stderr,
- "usage: %s [-IQVrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n", pname);
- exit(EXIT_FAILURE);
+ "usage: %s [-IQVrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]", pname);
+ exit_error();
+ /* NOTREACHED */
}
static char
@@ -1058,14 +1066,15 @@ main(int argc, char **argv)
if (GET_TTY(STDERR_FILENO, &mode) < 0)
failed("standard error");
- oldmode = mode;
+ can_restore = TRUE;
+ original = oldmode = mode;
#ifdef TERMIOS
ospeed = cfgetospeed(&mode);
#else
ospeed = mode.sg_ospeed;
#endif
- p = _nc_basename(*argv);
+ p = _nc_rootname(*argv);
if (!strcmp(p, PROG_RESET)) {
isreset = TRUE;
reset_mode();
@@ -1154,11 +1163,7 @@ main(int argc, char **argv)
/* Set the modes if they've changed. */
if (memcmp(&mode, &oldmode, sizeof(mode))) {
-#ifdef TERMIOS
- tcsetattr(STDERR_FILENO, TCSADRAIN, &mode);
-#else
- stty(STDERR_FILENO, &mode);
-#endif
+ SET_TTY(STDERR_FILENO, &mode);
}
}
OpenPOWER on IntegriCloud