aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/progs
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/progs')
-rw-r--r--contrib/ncurses/progs/Makefile.in103
-rw-r--r--contrib/ncurses/progs/dump_entry.c5
-rw-r--r--contrib/ncurses/progs/infocmp.c150
-rw-r--r--contrib/ncurses/progs/progs.priv.h8
-rw-r--r--contrib/ncurses/progs/tic.c280
-rw-r--r--contrib/ncurses/progs/toe.c12
-rw-r--r--contrib/ncurses/progs/tput.c165
-rw-r--r--contrib/ncurses/progs/tset.c100
8 files changed, 546 insertions, 277 deletions
diff --git a/contrib/ncurses/progs/Makefile.in b/contrib/ncurses/progs/Makefile.in
index f0ecd0bdf724..8898c149f36f 100644
--- a/contrib/ncurses/progs/Makefile.in
+++ b/contrib/ncurses/progs/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.40 2000/05/28 01:28:09 tom Exp $
+# $Id: Makefile.in,v 1.49 2000/09/30 23:08:58 tom Exp $
##############################################################################
# Copyright (c) 1998-2000 Free Software Foundation, Inc. #
# #
@@ -50,7 +50,7 @@ CF_MFLAGS = @cf_cv_makeflags@
x = @PROG_EXT@
MODEL = ../@DFT_OBJ_SUBDIR@
-INSTALL_PREFIX = @INSTALL_PREFIX@
+DESTDIR = @DESTDIR@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
@@ -59,10 +59,9 @@ libdir = @libdir@
includedir = @includedir@
datadir = @datadir@
-ticdir = $(datadir)/terminfo
-
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
+transform = @program_transform_name@
AWK = @AWK@
LN_S = @LN_S@
@@ -73,14 +72,14 @@ CFLAGS = @CFLAGS@
INCDIR = $(srcdir)/../include
CPPFLAGS = -I../progs -I$(srcdir) @CPPFLAGS@ \
- -DHAVE_CONFIG_H -DTERMINFO=\"$(ticdir)\"
+ -DHAVE_CONFIG_H
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
CFLAGS_NORMAL = $(CCFLAGS)
CFLAGS_DEBUG = $(CCFLAGS) @CC_G_OPT@ -DTRACE
CFLAGS_PROFILE = $(CCFLAGS) -pg
-CFLAGS_SHARED = $(CCFLAGS) # @CC_SHARED_OPTS@
+CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@
CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@)
@@ -101,7 +100,8 @@ LINT_OPTS = @LINT_OPTS@
LINT_LIBS = -lncurses @LIBS@
AUTO_SRC = \
- termsort.c
+ termsort.c \
+ transform.h
PROGS = tic$x toe$x infocmp$x clear$x tput$x tset$x
@@ -111,47 +111,66 @@ TESTPROGS = mvcur$x tctest$x hardscroll$x hashmap$x
DEPS_CURSES = ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
################################################################################
-all: $(AUTO_SRC) $(PROGS)
+all: $(AUTO_SRC) $(PROGS)
sources: $(AUTO_SRC)
-install: install.progs
-uninstall: uninstall.progs
+install: $(AUTO_SRC) install.progs
+uninstall: uninstall.progs
# this line simplifies the configure-script
libs \
install.libs \
uninstall.libs:
-install.progs: $(PROGS) $(INSTALL_PREFIX)$(bindir)
- $(INSTALL_PROGRAM) tic$x $(INSTALL_PREFIX)$(bindir)/tic$x
- $(INSTALL_PROGRAM) toe$x $(INSTALL_PREFIX)$(bindir)/toe$x
- $(INSTALL_PROGRAM) infocmp$x $(INSTALL_PREFIX)$(bindir)/infocmp$x
- $(INSTALL_PROGRAM) clear$x $(INSTALL_PREFIX)$(bindir)/clear$x
- $(INSTALL_PROGRAM) tput$x $(INSTALL_PREFIX)$(bindir)/tput$x
- $(INSTALL_PROGRAM) tset$x $(INSTALL_PREFIX)$(bindir)/tset$x
- @echo "linking captoinfo to tic"
- -@rm -f $(INSTALL_PREFIX)$(bindir)/captoinfo$x
- (cd $(INSTALL_PREFIX)$(bindir) && $(LN_S) tic$x captoinfo$x)
- @echo "linking infotocap to tic"
- -@rm -f $(INSTALL_PREFIX)$(bindir)/infotocap$x
- (cd $(INSTALL_PREFIX)$(bindir) && $(LN_S) tic$x infotocap$x)
- @echo "linking reset to tset"
- -@rm -f $(INSTALL_PREFIX)$(bindir)/reset$x
- (cd $(INSTALL_PREFIX)$(bindir) && $(LN_S) tset$x reset$x)
+TRANSFORM = sed 's/$x$$//'|sed '$(transform)'|sed 's/$$/$x/'
+
+actual_captoinfo = `echo captoinfo$x| $(TRANSFORM)`
+actual_clear = `echo clear$x| $(TRANSFORM)`
+actual_infocmp = `echo infocmp$x| $(TRANSFORM)`
+actual_infotocap = `echo infotocap$x| $(TRANSFORM)`
+actual_init = `echo init$x| $(TRANSFORM)`
+actual_reset = `echo reset$x| $(TRANSFORM)`
+actual_tic = `echo tic$x| $(TRANSFORM)`
+actual_toe = `echo toe$x| $(TRANSFORM)`
+actual_tput = `echo tput$x| $(TRANSFORM)`
+actual_tset = `echo tset$x| $(TRANSFORM)`
+
+transform.h :
+ echo "#define PROG_CAPTOINFO \"$(actual_captoinfo)\"" >$@
+ echo "#define PROG_INFOTOCAP \"$(actual_infotocap)\"" >>$@
+ echo "#define PROG_RESET \"$(actual_reset)\"" >>$@
+ echo "#define PROG_INIT \"$(actual_init)\"" >>$@
+
+install.progs: $(AUTO_SRC) $(PROGS) $(DESTDIR)$(bindir)
+ $(INSTALL_PROGRAM) tic$x $(DESTDIR)$(bindir)/$(actual_tic)
+ $(INSTALL_PROGRAM) toe$x $(DESTDIR)$(bindir)/$(actual_toe)
+ $(INSTALL_PROGRAM) infocmp$x $(DESTDIR)$(bindir)/$(actual_infocmp)
+ $(INSTALL_PROGRAM) clear$x $(DESTDIR)$(bindir)/$(actual_clear)
+ $(INSTALL_PROGRAM) tput$x $(DESTDIR)$(bindir)/$(actual_tput)
+ $(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:
- -@rm -f $(INSTALL_PREFIX)$(bindir)/tic$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/toe$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/infocmp$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/clear$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/tput$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/tset$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/captoinfo$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/infotocap$x
- -@rm -f $(INSTALL_PREFIX)$(bindir)/reset$x
-
-$(INSTALL_PREFIX)$(bindir) :
+ -@rm -f $(DESTDIR)$(bindir)/$(actual_tic)
+ -@rm -f $(DESTDIR)$(bindir)/$(actual_toe)
+ -@rm -f $(DESTDIR)$(bindir)/$(actual_infocmp)
+ -@rm -f $(DESTDIR)$(bindir)/$(actual_clear)
+ -@rm -f $(DESTDIR)$(bindir)/$(actual_tput)
+ -@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 $@
#
@@ -162,7 +181,7 @@ DEPS_TIC = \
$(MODEL)/tic.o \
$(MODEL)/dump_entry.o
-tic$x: $(DEPS_TIC) $(DEPS_CURSES)
+tic$x: $(DEPS_TIC) $(DEPS_CURSES) transform.h
@ECHO_LINK@ $(LINK) $(DEPS_TIC) $(LDFLAGS_DEFAULT) -o $@
DEPS_TOE = \
@@ -181,7 +200,7 @@ clear$x: $(DEPS_CLEAR) $(DEPS_CURSES)
DEPS_TPUT = \
$(MODEL)/tput.o
-tput$x: $(DEPS_TPUT) $(DEPS_CURSES)
+tput$x: $(DEPS_TPUT) $(DEPS_CURSES) transform.h
@ECHO_LINK@ $(LINK) $(DEPS_TPUT) $(LDFLAGS_DEFAULT) -o $@
DEPS_INFOCMP = \
@@ -195,7 +214,7 @@ DEPS_TSET = \
$(MODEL)/tset.o \
$(MODEL)/dump_entry.o
-tset$x: $(DEPS_TSET) $(DEPS_CURSES)
+tset$x: $(DEPS_TSET) $(DEPS_CURSES) transform.h
@ECHO_LINK@ $(LINK) $(DEPS_TSET) $(LDFLAGS_DEFAULT) -o $@
termsort.c: $(srcdir)/MKtermsort.sh
@@ -208,8 +227,8 @@ termsort.c: $(srcdir)/MKtermsort.sh
tags:
ctags *.[ch]
-TAGS:
- etags *.[ch]
+@MAKE_UPPER_TAGS@TAGS:
+@MAKE_UPPER_TAGS@ etags *.[ch]
mostlyclean ::
-rm -f core tags TAGS *~ *.ln *.atac trace
diff --git a/contrib/ncurses/progs/dump_entry.c b/contrib/ncurses/progs/dump_entry.c
index 3830742fcbd6..60c88d3f9cab 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.53 2000/04/15 21:23:30 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.54 2000/10/01 01:34:06 tom Exp $")
#define INDENT 8
#define DISCARD(string) string = ABSENT_STRING
@@ -641,8 +641,9 @@ fmt_entry(TERMTYPE * tterm,
sprintf(buffer, "%s@", name);
WRAP_CONCAT;
} else if (outform == F_TERMCAP || outform == F_TCONVERR) {
+ int params = (i < (int) SIZEOF(parametrized)) ? parametrized[i] : 0;
char *srccap = _nc_tic_expand(tterm->Strings[i], TRUE, numbers);
- char *cv = _nc_infotocap(name, srccap, parametrized[i]);
+ char *cv = _nc_infotocap(name, srccap, params);
if (cv == 0) {
if (outform == F_TCONVERR) {
diff --git a/contrib/ncurses/progs/infocmp.c b/contrib/ncurses/progs/infocmp.c
index add5efb9b4d0..bf7ff1c54b07 100644
--- a/contrib/ncurses/progs/infocmp.c
+++ b/contrib/ncurses/progs/infocmp.c
@@ -41,7 +41,7 @@
#include <term_entry.h>
#include <dump_entry.h>
-MODULE_ID("$Id: infocmp.c,v 1.54 2000/03/19 02:56:14 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.57 2000/10/01 01:26:25 tom Exp $")
#define L_CURL "{"
#define R_CURL "}"
@@ -73,7 +73,7 @@ static const char *tversion; /* terminfo version selected */
static int itrace; /* trace flag for debugging */
static int mwidth = 60;
static int numbers = 0; /* format "%'char'" to/from "%{number}" */
-static int outform = F_TERMINFO;/* output format */
+static int outform = F_TERMINFO; /* output format */
static int sortmode; /* sort_mode */
/* main comparison mode */
@@ -90,8 +90,8 @@ static bool ignorepads; /* ignore pad prefixes when diffing */
static void
ExitProgram(int code) GCC_NORETURN;
/* prototype is to get gcc to accept the noreturn attribute */
-static void
-ExitProgram(int code)
+ static void
+ ExitProgram(int code)
{
while (termcount-- > 0)
_nc_free_termtype(&entries[termcount].tterm);
@@ -350,10 +350,10 @@ compare_predicate(int type, int idx, const char *name)
case C_DIFFERENCE:
if (!(b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) && b1 != b2)
(void) printf("\t%s: %s%s%s.\n",
- name,
- dump_boolean(b1),
- bool_sep,
- dump_boolean(b2));
+ name,
+ dump_boolean(b1),
+ bool_sep,
+ dump_boolean(b2));
break;
case C_COMMON:
@@ -732,8 +732,8 @@ file_comparison(int argc, char *argv[])
/* maybe do use resolution */
if (!_nc_resolve_uses(!limited)) {
(void) fprintf(stderr,
- "There are unresolved use entries in %s:\n",
- argv[n]);
+ "There are unresolved use entries in %s:\n",
+ argv[n]);
for_entry_list(qp) {
if (qp->nuses) {
(void) fputs(qp->tterm.term_names, stderr);
@@ -773,30 +773,30 @@ file_comparison(int argc, char *argv[])
for (qp = heads[0]; qp; qp = qp->next) {
if (qp->ncrosslinks > 1) {
(void) fprintf(stderr,
- "%s in file 1 (%s) has %d matches in file 2 (%s):\n",
- _nc_first_name(qp->tterm.term_names),
- argv[0],
- qp->ncrosslinks,
- argv[1]);
+ "%s in file 1 (%s) has %d matches in file 2 (%s):\n",
+ _nc_first_name(qp->tterm.term_names),
+ argv[0],
+ qp->ncrosslinks,
+ argv[1]);
for (i = 0; i < qp->ncrosslinks; i++)
(void) fprintf(stderr,
- "\t%s\n",
- _nc_first_name((qp->crosslinks[i])->tterm.term_names));
+ "\t%s\n",
+ _nc_first_name((qp->crosslinks[i])->tterm.term_names));
}
}
for (rp = heads[1]; rp; rp = rp->next) {
if (rp->ncrosslinks > 1) {
(void) fprintf(stderr,
- "%s in file 2 (%s) has %d matches in file 1 (%s):\n",
- _nc_first_name(rp->tterm.term_names),
- argv[1],
- rp->ncrosslinks,
- argv[0]);
+ "%s in file 2 (%s) has %d matches in file 1 (%s):\n",
+ _nc_first_name(rp->tterm.term_names),
+ argv[1],
+ rp->ncrosslinks,
+ argv[0]);
for (i = 0; i < rp->ncrosslinks; i++)
(void) fprintf(stderr,
- "\t%s\n",
- _nc_first_name((rp->crosslinks[i])->tterm.term_names));
+ "\t%s\n",
+ _nc_first_name((rp->crosslinks[i])->tterm.term_names));
}
}
@@ -804,13 +804,13 @@ file_comparison(int argc, char *argv[])
for (qp = heads[0]; qp; qp = qp->next)
if (qp->ncrosslinks == 0)
(void) printf("\t%s\n",
- _nc_first_name(qp->tterm.term_names));
+ _nc_first_name(qp->tterm.term_names));
(void) printf("In file 2 (%s) only:\n", argv[1]);
for (rp = heads[1]; rp; rp = rp->next)
if (rp->ncrosslinks == 0)
(void) printf("\t%s\n",
- _nc_first_name(rp->tterm.term_names));
+ _nc_first_name(rp->tterm.term_names));
(void) printf("The following entries are equivalent:\n");
for (qp = heads[0]; qp; qp = qp->next) {
@@ -858,7 +858,7 @@ file_comparison(int argc, char *argv[])
case C_DIFFERENCE:
if (itrace)
(void) fprintf(stderr,
- "infocmp: dumping differences\n");
+ "infocmp: dumping differences\n");
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@@ -866,7 +866,7 @@ file_comparison(int argc, char *argv[])
case C_COMMON:
if (itrace)
(void) fprintf(stderr,
- "infocmp: dumping common capabilities\n");
+ "infocmp: dumping common capabilities\n");
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@@ -874,7 +874,7 @@ file_comparison(int argc, char *argv[])
case C_NAND:
if (itrace)
(void) fprintf(stderr,
- "infocmp: dumping differences\n");
+ "infocmp: dumping differences\n");
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@@ -924,7 +924,7 @@ usage(void)
," -w number (width)"
};
const size_t first = 3;
- const size_t last = sizeof(tbl) / sizeof(tbl[0]);
+ const size_t last = SIZEOF(tbl);
const size_t left = (last - first + 1) / 2 + first;
size_t n;
@@ -985,7 +985,7 @@ dump_initializers(TERMTYPE * term)
break;
}
(void) printf("\t/* %3d: %-8s */\t%s,\n",
- n, ExtBoolname(term, n, boolnames), str);
+ n, ExtBoolname(term, n, boolnames), str);
}
(void) printf("%s;\n", R_CURL);
@@ -1005,8 +1005,8 @@ dump_initializers(TERMTYPE * term)
str = buf;
break;
}
- (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtNumname(term, n,
- numnames), str);
+ (void) printf("\t/* %3d: %-8s */\t%s,\n", n,
+ ExtNumname(term, n, numnames), str);
}
(void) printf("%s;\n", R_CURL);
@@ -1027,8 +1027,8 @@ dump_initializers(TERMTYPE * term)
tp = buf;
*tp++ = '"';
for (sp = term->Strings[n];
- *sp != 0 && (tp - buf) < MAX_STRING - 6;
- sp++) {
+ *sp != 0 && (tp - buf) < MAX_STRING - 6;
+ sp++) {
if (isascii(*sp) && isprint(*sp) && *sp != '\\' && *sp != '"')
*tp++ = *sp;
else {
@@ -1046,11 +1046,11 @@ dump_initializers(TERMTYPE * term)
(void) printf("%s;\n", R_CURL);
(void) printf("static char * %s[] = %s\n",
- name_initializer("string_ext"), L_CURL);
+ name_initializer("string_ext"), L_CURL);
}
#endif
- (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtStrname(term, n,
- strnames), str);
+ (void) printf("\t/* %3d: %-8s */\t%s,\n", n,
+ ExtStrname(term, n, strnames), str);
}
(void) printf("%s;\n", R_CURL);
}
@@ -1071,26 +1071,39 @@ 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)
- ? name_initializer("string_ext")
- : "(char **)0");
+ (NUM_STRINGS(term) != STRCOUNT)
+ ? name_initializer("string_ext")
+ : "(char **)0");
(void) printf("\t\t%d,\t\t/* count total Booleans */\n", NUM_BOOLEANS(term));
(void) printf("\t\t%d,\t\t/* count total Numbers */\n", NUM_NUMBERS(term));
(void) printf("\t\t%d,\t\t/* count total Strings */\n", NUM_STRINGS(term));
(void) printf("\t\t%d,\t\t/* count extensions to Booleans */\n",
- NUM_BOOLEANS(term) - BOOLCOUNT);
+ NUM_BOOLEANS(term) - BOOLCOUNT);
(void) printf("\t\t%d,\t\t/* count extensions to Numbers */\n",
- NUM_NUMBERS(term) - NUMCOUNT);
+ NUM_NUMBERS(term) - NUMCOUNT);
(void) printf("\t\t%d,\t\t/* count extensions to Strings */\n",
- NUM_STRINGS(term) - STRCOUNT);
+ NUM_STRINGS(term) - STRCOUNT);
(void) printf("#endif /* NCURSES_XNAMES */\n");
#endif /* NCURSES_XNAMES */
(void) printf("\t%s\n", R_CURL);
}
+static int
+optarg_to_number(void)
+{
+ char *temp = 0;
+ long value = strtol(optarg, &temp, 0);
+
+ if (temp == 0 || temp == optarg || *temp != 0) {
+ fprintf(stderr, "Expected a number, not \"%s\"\n", optarg);
+ exit(EXIT_FAILURE);
+ }
+ return (int) value;
+}
+
/***************************************************************************
*
* Main sequence
@@ -1112,7 +1125,7 @@ main(int argc, char *argv[])
if ((terminal = getenv("TERM")) == 0) {
(void) fprintf(stderr,
- "infocmp: environment variable TERM not set\n");
+ "infocmp: environment variable TERM not set\n");
return EXIT_FAILURE;
}
@@ -1222,7 +1235,7 @@ main(int argc, char *argv[])
sortmode = S_TERMCAP;
else {
(void) fprintf(stderr,
- "infocmp: unknown sort mode\n");
+ "infocmp: unknown sort mode\n");
return EXIT_FAILURE;
}
break;
@@ -1232,17 +1245,16 @@ main(int argc, char *argv[])
break;
case 'v':
- itrace = atoi(optarg);
+ itrace = optarg_to_number();
set_trace_level(itrace);
break;
case 'V':
- (void) fputs(NCURSES_VERSION, stdout);
- putchar('\n');
+ puts(curses_version());
ExitProgram(EXIT_SUCCESS);
case 'w':
- mwidth = atoi(optarg);
+ mwidth = optarg_to_number();
break;
case 'A':
@@ -1289,7 +1301,7 @@ main(int argc, char *argv[])
for (; optind < argc; optind++) {
if (termcount >= MAXTERMS) {
(void) fprintf(stderr,
- "infocmp: too many terminal type arguments\n");
+ "infocmp: too many terminal type arguments\n");
return EXIT_FAILURE;
} else {
const char *directory = termcount ? restdir : firstdir;
@@ -1299,31 +1311,31 @@ main(int argc, char *argv[])
if (directory) {
(void) sprintf(tfile[termcount], "%s/%c/%s",
- directory,
- *argv[optind], argv[optind]);
+ directory,
+ *argv[optind], argv[optind]);
if (itrace)
(void) fprintf(stderr,
- "infocmp: reading entry %s from file %s\n",
- argv[optind], tfile[termcount]);
+ "infocmp: reading entry %s from file %s\n",
+ argv[optind], tfile[termcount]);
status = _nc_read_file_entry(tfile[termcount],
- &entries[termcount].tterm);
+ &entries[termcount].tterm);
} else {
if (itrace)
(void) fprintf(stderr,
- "infocmp: reading entry %s from system directories %s\n",
- argv[optind], tname[termcount]);
+ "infocmp: reading entry %s from system directories %s\n",
+ argv[optind], tname[termcount]);
status = _nc_read_entry(tname[termcount],
- tfile[termcount],
- &entries[termcount].tterm);
+ tfile[termcount],
+ &entries[termcount].tterm);
directory = TERMINFO; /* for error message */
}
if (status <= 0) {
(void) fprintf(stderr,
- "infocmp: couldn't open terminfo file %s.\n",
- tfile[termcount]);
+ "infocmp: couldn't open terminfo file %s.\n",
+ tfile[termcount]);
return EXIT_FAILURE;
}
repair_acsc(&entries[termcount].tterm);
@@ -1368,10 +1380,10 @@ main(int argc, char *argv[])
case C_DEFAULT:
if (itrace)
(void) fprintf(stderr,
- "infocmp: about to dump %s\n",
- tname[0]);
+ "infocmp: about to dump %s\n",
+ tname[0]);
(void) printf("#\tReconstructed via infocmp from file: %s\n",
- tfile[0]);
+ tfile[0]);
len = dump_entry(&entries[0].tterm, limited, numbers, NULL);
putchar('\n');
if (itrace)
@@ -1388,7 +1400,7 @@ main(int argc, char *argv[])
case C_COMMON:
if (itrace)
(void) fprintf(stderr,
- "infocmp: dumping common capabilities\n");
+ "infocmp: dumping common capabilities\n");
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@@ -1396,7 +1408,7 @@ main(int argc, char *argv[])
case C_NAND:
if (itrace)
(void) fprintf(stderr,
- "infocmp: dumping differences\n");
+ "infocmp: dumping differences\n");
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@@ -1407,7 +1419,7 @@ main(int argc, char *argv[])
len = dump_entry(&entries[0].tterm, limited, numbers, use_predicate);
for (i = 1; i < termcount; i++)
len += dump_uses(tname[i], !(outform == F_TERMCAP || outform
- == F_TCONVERR));
+ == F_TCONVERR));
putchar('\n');
if (itrace)
(void) fprintf(stderr, "infocmp: length %d\n", len);
@@ -1419,7 +1431,7 @@ main(int argc, char *argv[])
(void) fprintf(stderr, "Use `tic -[CI] <file>' for this.\n");
else if (argc - optind != 2)
(void) fprintf(stderr,
- "File comparison needs exactly two file arguments.\n");
+ "File comparison needs exactly two file arguments.\n");
else
file_comparison(argc - optind, argv + optind);
diff --git a/contrib/ncurses/progs/progs.priv.h b/contrib/ncurses/progs/progs.priv.h
index 2d22c9ad1a8a..d704c0989b33 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.22 2000/04/08 23:47:39 tom Exp $
+ * $Id: progs.priv.h,v 1.24 2000/10/01 01:33:34 tom Exp $
*
* progs.priv.h
*
@@ -39,7 +39,7 @@
#include <ncurses_cfg.h>
-#ifdef USE_RCS_IDS
+#if USE_RCS_IDS
#define MODULE_ID(id) static const char Ident[] = id;
#else
#define MODULE_ID(id) /*nothing*/
@@ -162,7 +162,7 @@ extern int optind;
/* We use isascii only to guard against use of 7-bit ctype tables in the
* isprint test in infocmp.
*/
-#ifndef HAVE_ISASCII
+#if !HAVE_ISASCII
# undef isascii
# if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
# define isascii(c) (((c) & 0xff) <= 127)
@@ -170,3 +170,5 @@ extern int optind;
# define isascii(c) 1 /* not really ascii anyway */
# endif
#endif
+
+#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
diff --git a/contrib/ncurses/progs/tic.c b/contrib/ncurses/progs/tic.c
index cc73a4db220c..9ab0f10776d0 100644
--- a/contrib/ncurses/progs/tic.c
+++ b/contrib/ncurses/progs/tic.c
@@ -38,11 +38,13 @@
*/
#include <progs.priv.h>
+#include <sys/stat.h>
#include <dump_entry.h>
#include <term_entry.h>
+#include <transform.h>
-MODULE_ID("$Id: tic.c,v 1.69 2000/04/08 23:53:49 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.82 2000/10/01 02:11:39 tom Exp $")
const char *_nc_progname = "tic";
@@ -54,7 +56,7 @@ static const char *to_remove;
static void (*save_check_termtype) (TERMTYPE *);
static void check_termtype(TERMTYPE * tt);
-static const char usage_string[] = "[-h] [-v[n]] [-e names] [-CILNRTcfrswx1] source-file\n";
+static const char usage_string[] = "[-V] [-v[n]] [-e names] [-CILNRTcfrswx1] source-file\n";
static void
cleanup(void)
@@ -91,6 +93,7 @@ usage(void)
" -N disable smart defaults for source translation",
" -R restrict translation to given terminfo/termcap version",
" -T remove size-restrictions on compiled description",
+ " -V print version",
#if NCURSES_XNAMES
" -a retain commented-out capabilities (sets -x also)",
#endif
@@ -114,7 +117,7 @@ usage(void)
size_t j;
fprintf(stderr, "Usage: %s %s\n", _nc_progname, usage_string);
- for (j = 0; j < sizeof(tbl) / sizeof(tbl[0]); j++) {
+ for (j = 0; j < SIZEOF(tbl); j++) {
fputs(tbl[j], stderr);
putc('\n', stderr);
}
@@ -148,7 +151,7 @@ write_it(ENTRY * ep)
if (ch == '\\') {
*d++ = *t++;
} else if ((ch == '%')
- && (*t == L_BRACE)) {
+ && (*t == L_BRACE)) {
char *v = 0;
long value = strtol(t + 1, &v, 0);
if (v != 0
@@ -179,7 +182,7 @@ static bool
immedhook(ENTRY * ep GCC_UNUSED)
/* write out entries with no use capabilities immediately to save storage */
{
-#ifndef HAVE_BIG_CORE
+#if !HAVE_BIG_CORE
/*
* This is strictly a core-economy kluge. The really clean way to handle
* compilation is to slurp the whole file into core and then do all the
@@ -301,6 +304,24 @@ stripped(char *src)
return 0;
}
+static FILE *
+open_input(const char *filename)
+{
+ FILE *fp = fopen(filename, "r");
+ struct stat sb;
+
+ if (fp == 0) {
+ fprintf(stderr, "%s: Can't open %s\n", _nc_progname, filename);
+ exit(EXIT_FAILURE);
+ }
+ if (fstat(fileno(fp), &sb) < 0
+ || (sb.st_mode & S_IFMT) != S_IFREG) {
+ fprintf(stderr, "%s: %s is not a file\n", _nc_progname, filename);
+ exit(EXIT_FAILURE);
+ }
+ return fp;
+}
+
/* Parse the "-e" option-value into a list of names */
static const char **
make_namelist(char *src)
@@ -314,9 +335,7 @@ make_namelist(char *src)
if (src == 0) {
/* EMPTY */ ;
} else if (strchr(src, '/') != 0) { /* a filename */
- FILE *fp = fopen(src, "r");
- if (fp == 0)
- failed(src);
+ FILE *fp = open_input(src);
for (pass = 1; pass <= 2; pass++) {
nn = 0;
@@ -425,16 +444,13 @@ main(int argc, char *argv[])
log_fp = stderr;
- if ((_nc_progname = strrchr(argv[0], '/')) == NULL)
- _nc_progname = argv[0];
- else
- _nc_progname++;
+ _nc_progname = _nc_basename(argv[0]);
- if ((infodump = (strcmp(_nc_progname, "captoinfo") == 0)) != FALSE) {
+ if ((infodump = (strcmp(_nc_progname, PROG_CAPTOINFO) == 0)) != FALSE) {
outform = F_TERMINFO;
sortmode = S_TERMINFO;
}
- if ((capdump = (strcmp(_nc_progname, "infotocap") == 0)) != FALSE) {
+ if ((capdump = (strcmp(_nc_progname, PROG_INFOTOCAP) == 0)) != FALSE) {
outform = F_TERMCAP;
sortmode = S_TERMCAP;
}
@@ -448,7 +464,7 @@ main(int argc, char *argv[])
* be optional.
*/
while ((this_opt = getopt(argc, argv,
- "0123456789CILNR:TVace:fGgo:rsvwx")) != EOF) {
+ "0123456789CILNR:TVace:fGgo:rsvwx")) != EOF) {
if (isdigit(this_opt)) {
switch (last_opt) {
case 'v':
@@ -491,7 +507,7 @@ main(int argc, char *argv[])
limited = FALSE;
break;
case 'V':
- puts(NCURSES_VERSION);
+ puts(curses_version());
return EXIT_SUCCESS;
case 'c':
check_only = TRUE;
@@ -544,7 +560,7 @@ main(int argc, char *argv[])
save_check_termtype = _nc_check_termtype;
_nc_check_termtype = check_termtype;
}
-#ifndef HAVE_BIG_CORE
+#if !HAVE_BIG_CORE
/*
* Aaargh! immedhook seriously hoses us!
*
@@ -557,7 +573,7 @@ main(int argc, char *argv[])
*/
if (namelst && (!infodump && !capdump)) {
(void) fprintf(stderr,
- "Sorry, -e can't be used without -I or -C\n");
+ "Sorry, -e can't be used without -I or -C\n");
cleanup();
return EXIT_FAILURE;
}
@@ -567,10 +583,10 @@ main(int argc, char *argv[])
source_file = argv[optind++];
if (optind < argc) {
fprintf(stderr,
- "%s: Too many file names. Usage:\n\t%s %s",
- _nc_progname,
- _nc_progname,
- usage_string);
+ "%s: Too many file names. Usage:\n\t%s %s",
+ _nc_progname,
+ _nc_progname,
+ usage_string);
return EXIT_FAILURE;
}
} else {
@@ -582,11 +598,13 @@ main(int argc, char *argv[])
if (access(termcap, F_OK) == 0) {
/* file exists */
source_file = termcap;
- } else if ((tmp_fp = open_tempfile(my_tmpname)) != 0) {
+ } else if ((tmp_fp = open_tempfile(strcpy(my_tmpname,
+ "/tmp/XXXXXX")))
+ != 0) {
source_file = my_tmpname;
fprintf(tmp_fp, "%s\n", termcap);
fclose(tmp_fp);
- tmp_fp = fopen(source_file, "r");
+ tmp_fp = open_input(source_file);
to_remove = source_file;
} else {
failed("tmpnam");
@@ -595,41 +613,38 @@ main(int argc, char *argv[])
} else {
/* tic */
fprintf(stderr,
- "%s: File name needed. Usage:\n\t%s %s",
- _nc_progname,
- _nc_progname,
- usage_string);
+ "%s: File name needed. Usage:\n\t%s %s",
+ _nc_progname,
+ _nc_progname,
+ usage_string);
cleanup();
return EXIT_FAILURE;
}
}
- if (tmp_fp == 0
- && (tmp_fp = fopen(source_file, "r")) == 0) {
- fprintf(stderr, "%s: Can't open %s\n", _nc_progname, source_file);
- return EXIT_FAILURE;
- }
+ if (tmp_fp == 0)
+ tmp_fp = open_input(source_file);
if (infodump)
dump_init(tversion,
- smart_defaults
- ? outform
- : F_LITERAL,
- sortmode, width, debug_level, formatted);
+ smart_defaults
+ ? outform
+ : F_LITERAL,
+ sortmode, width, debug_level, formatted);
else if (capdump)
dump_init(tversion,
- outform,
- sortmode, width, debug_level, FALSE);
+ outform,
+ sortmode, width, debug_level, FALSE);
/* parse entries out of the source file */
_nc_set_source(source_file);
-#ifndef HAVE_BIG_CORE
+#if !HAVE_BIG_CORE
if (!(check_only || infodump || capdump))
_nc_set_writedir(outdir);
#endif /* HAVE_BIG_CORE */
_nc_read_entry_source(tmp_fp, (char *) NULL,
- !smart_defaults, FALSE,
- (check_only || infodump || capdump) ? NULLHOOK : immedhook);
+ !smart_defaults, FALSE,
+ (check_only || infodump || capdump) ? NULLHOOK : immedhook);
/* do use resolution */
if (check_only || (!infodump && !capdump) || forceresolve) {
@@ -647,9 +662,9 @@ main(int argc, char *argv[])
if (len > (infodump ? MAX_TERMINFO_LENGTH : MAX_TERMCAP_LENGTH))
(void) fprintf(stderr,
- "warning: resolved %s entry is %d bytes long\n",
- _nc_first_name(qp->tterm.term_names),
- len);
+ "warning: resolved %s entry is %d bytes long\n",
+ _nc_first_name(qp->tterm.term_names),
+ len);
}
}
}
@@ -722,8 +737,8 @@ main(int argc, char *argv[])
int total = _nc_tic_written();
if (total != 0)
fprintf(log_fp, "%d entries written to %s\n",
- total,
- _nc_tic_dir((char *) 0));
+ total,
+ _nc_tic_dir((char *) 0));
else
fprintf(log_fp, "No entries written\n");
}
@@ -743,6 +758,145 @@ TERMINAL *cur_term; /* tweak to avoid linking lib_cur_term.c */
#define CUR tp->
/*
+ * Returns the expected number of parameters for the given capability.
+ */
+static int
+expected_params(char *name)
+{
+ /* *INDENT-OFF* */
+ static const struct {
+ const char *name;
+ int count;
+ } table[] = {
+ { "birep", 2 },
+ { "chr", 1 },
+ { "colornm", 1 },
+ { "cpi", 1 },
+ { "csr", 2 },
+ { "cub", 1 },
+ { "cud", 1 },
+ { "cuf", 1 },
+ { "cup", 2 },
+ { "cvr", 1 },
+ { "cuu", 1 },
+ { "cwin", 5 },
+ { "dch", 1 },
+ { "dclk", 2 },
+ { "dial", 1 },
+ { "dispc", 1 },
+ { "dl", 1 },
+ { "ech", 1 },
+ { "getm", 1 },
+ { "hpa", 1 },
+ { "ich", 1 },
+ { "il", 1 },
+ { "indn", 1 },
+ { "initc", 4 },
+ { "initp", 7 },
+ { "lpi", 1 },
+ { "mc5p", 1 },
+ { "mrcup", 2 },
+ { "mvpa", 1 },
+ { "pfkey", 2 },
+ { "pfloc", 2 },
+ { "pfx", 2 },
+ { "pfxl", 3 },
+ { "pln", 2 },
+ { "qdial", 1 },
+ { "rep", 2 },
+ { "rin", 1 },
+ { "sclk", 3 },
+ { "scp", 1 },
+ { "scs", 1 },
+ { "setab", 1 },
+ { "setaf", 1 },
+ { "setb", 1 },
+ { "setcolor", 1 },
+ { "setf", 1 },
+ { "sgr", 9 },
+ { "sgr1", 6 },
+ { "slength", 1 },
+ { "slines", 1 },
+ { "smgbp", 2 },
+ { "smglp", 2 },
+ { "smglr", 2 },
+ { "smgrp", 1 },
+ { "smgtb", 2 },
+ { "smgtp", 2 },
+ { "tsl", 1 },
+ { "u6", -1 },
+ { "vpa", 1 },
+ { "wind", 4 },
+ { "wingo", 1 },
+ };
+ /* *INDENT-ON* */
+
+ unsigned n;
+ int result = 0; /* function-keys, etc., use none */
+
+ for (n = 0; n < SIZEOF(table); n++) {
+ if (!strcmp(name, table[n].name)) {
+ result = table[n].count;
+ break;
+ }
+ }
+
+ return result;
+}
+
+/*
+ * Make a quick sanity check for the parameters which are used in the given
+ * strings. If there are no "%p" tokens, then there should be no other "%"
+ * markers.
+ */
+static void
+check_params(TERMTYPE * tp, char *name, char *value)
+{
+ int expected = expected_params(name);
+ int actual = 0;
+ int n;
+ bool params[10];
+ char *s = value;
+
+ for (n = 0; n < 10; n++)
+ params[n] = FALSE;
+
+ while (*s != 0) {
+ if (*s == '%') {
+ if (*++s == '\0') {
+ _nc_warning("expected character after %% in %s", name);
+ break;
+ } else if (*s == 'p') {
+ if (*++s == '\0' || !isdigit((int) *s)) {
+ _nc_warning("expected digit after %%p in %s", name);
+ return;
+ } else {
+ n = (*s - '0');
+ if (n > actual)
+ actual = n;
+ params[n] = TRUE;
+ }
+ }
+ }
+ s++;
+ }
+
+ if (params[0]) {
+ _nc_warning("%s refers to parameter 0 (%%p0), which is not allowed", name);
+ }
+ if (value == set_attributes || expected < 0) {
+ ;
+ } else if (expected != actual) {
+ _nc_warning("%s uses %d parameters, expected %d", name,
+ actual, expected);
+ for (n = 1; n < actual; n++) {
+ if (!params[n])
+ _nc_warning("%s omits parameter %d", name, n);
+ }
+ }
+}
+
+/*
* An sgr string may contain several settings other than the one we're
* interested in, essentially sgr0 + rmacs + whatever. As long as the
* "whatever" is contained in the sgr string, that is close enough for our
@@ -767,20 +921,20 @@ static void
check_sgr(TERMTYPE * tp, char *zero, int num, char *cap, const char *name)
{
char *test = tparm(set_attributes,
- num == 1,
- num == 2,
- num == 3,
- num == 4,
- num == 5,
- num == 6,
- num == 7,
- num == 8,
- num == 9);
+ num == 1,
+ num == 2,
+ num == 3,
+ num == 4,
+ num == 5,
+ num == 6,
+ num == 7,
+ num == 8,
+ num == 9);
if (test != 0) {
if (PRESENT(cap)) {
if (!similar_sgr(test, cap)) {
_nc_warning("%s differs from sgr(%d): %s", name, num,
- _nc_visbuf(test));
+ _nc_visbuf(test));
}
} else if (strcmp(test, zero)) {
_nc_warning("sgr(%d) present, but not %s", num, name);
@@ -827,12 +981,12 @@ check_termtype(TERMTYPE * tp)
conflict = TRUE;
}
fprintf(stderr, "... %s is the same as %s",
- keyname(_nc_tinfo_fkeys[j].code),
- keyname(_nc_tinfo_fkeys[k].code));
+ keyname(_nc_tinfo_fkeys[j].code),
+ keyname(_nc_tinfo_fkeys[k].code));
first = FALSE;
} else {
fprintf(stderr, ", %s",
- keyname(_nc_tinfo_fkeys[k].code));
+ keyname(_nc_tinfo_fkeys[k].code));
}
}
}
@@ -840,6 +994,12 @@ check_termtype(TERMTYPE * tp)
fprintf(stderr, "\n");
}
+ for (j = 0; j < NUM_STRINGS(tp); j++) {
+ char *a = tp->Strings[j];
+ if (VALID_STRING(a))
+ check_params(tp, ExtStrname(tp, j, strnames), a);
+ }
+
/*
* Quick check for color. We could also check if the ANSI versus
* non-ANSI strings are misused.
diff --git a/contrib/ncurses/progs/toe.c b/contrib/ncurses/progs/toe.c
index afdf379fb287..b7afb676b015 100644
--- a/contrib/ncurses/progs/toe.c
+++ b/contrib/ncurses/progs/toe.c
@@ -43,7 +43,7 @@
#include <dump_entry.h>
#include <term_entry.h>
-MODULE_ID("$Id: toe.c,v 1.22 2000/03/11 21:47:35 tom Exp $")
+MODULE_ID("$Id: toe.c,v 1.24 2000/09/09 19:52:35 tom Exp $")
#define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
@@ -87,10 +87,7 @@ main(int argc, char *argv[])
int i, c;
int code;
- if ((_nc_progname = strrchr(argv[0], '/')) == 0)
- _nc_progname = argv[0];
- else
- _nc_progname++;
+ _nc_progname = _nc_basename(argv[0]);
while ((c = getopt(argc, argv, "huv:UV")) != EOF)
switch (c) {
@@ -107,8 +104,7 @@ main(int argc, char *argv[])
invert_dependencies = TRUE;
break;
case 'V':
- (void) fputs(NCURSES_VERSION, stdout);
- putchar('\n');
+ puts(curses_version());
ExitProgram(EXIT_SUCCESS);
default:
(void) fprintf(stderr, "usage: toe [-huUV] [-v n] [file...]\n");
@@ -191,7 +187,7 @@ main(int argc, char *argv[])
if ((eargv[j] = get_directory(personal)) != 0)
j++;
}
- if ((eargv[j] = get_directory(TERMINFO)) != 0)
+ if ((eargv[j] = get_directory(strcpy(personal, TERMINFO))) != 0)
j++;
}
eargv[j] = 0;
diff --git a/contrib/ncurses/progs/tput.c b/contrib/ncurses/progs/tput.c
index 63c6d1a5be5b..a72a2e892fdf 100644
--- a/contrib/ncurses/progs/tput.c
+++ b/contrib/ncurses/progs/tput.c
@@ -39,17 +39,27 @@
*/
#include <progs.priv.h>
-#ifndef PURE_TERMINFO
+
+#if !PURE_TERMINFO
#include <termsort.c>
#endif
+#include <transform.h>
-MODULE_ID("$Id: tput.c,v 1.16 2000/03/19 01:08:08 tom Exp $")
+MODULE_ID("$Id: tput.c,v 1.24 2000/10/05 00:05:04 tom Exp $")
#define PUTS(s) fputs(s, stdout)
#define PUTCHAR(c) putchar(c)
#define FLUSH fflush(stdout)
+typedef enum {
+ Numbers = 0
+ ,Num_Str
+ ,Num_Str_Str
+} TParams;
+
static char *prg_name;
+static bool is_init = FALSE;
+static bool is_reset = FALSE;
static void
quit(int status, const char *fmt,...)
@@ -66,38 +76,77 @@ quit(int status, const char *fmt,...)
static void
usage(void)
{
- fprintf(stderr, "usage: %s [-S] [-T term] capname\n", prg_name);
+ fprintf(stderr, "usage: %s [-V] [-S] [-T term] capname\n", prg_name);
exit(EXIT_FAILURE);
}
+static void
+check_aliases(const char *name)
+{
+ is_init = (strcmp(name, PROG_INIT) == 0);
+ is_reset = (strcmp(name, PROG_RESET) == 0);
+}
+
+/*
+ * Lookup the type of call we should make to tparm(). This ignores the actual
+ * terminfo capability (bad, because it is not extensible), but makes this
+ * code portable to platforms where sizeof(int) != sizeof(char *).
+ *
+ * FIXME: If we want extensibility, analyze the capability string as we do
+ * in tparm() to decide how to parse the varargs list.
+ */
+static TParams
+tparm_type(char *name)
+{
+#define TD(code, longname, ti, tc) {code,longname},{code,ti},{code,tc}
+ TParams result = Numbers;
+ /* *INDENT-OFF* */
+ static const struct {
+ TParams code;
+ const char *name;
+ } table[] = {
+ TD(Num_Str, "pkey_key", "pfkey", "pk"),
+ TD(Num_Str, "pkey_local", "pfloc", "pl"),
+ TD(Num_Str, "pkey_xmit", "pfx", "px"),
+ TD(Num_Str, "plab_norm", "pln", "pn"),
+ TD(Num_Str_Str, "pkey_plab", "pfxl", "xl"),
+ };
+ /* *INDENT-ON* */
+
+ unsigned n;
+ for (n = 0; n < SIZEOF(table); n++) {
+ if (!strcmp(name, table[n].name)) {
+ result = table[n].code;
+ break;
+ }
+ }
+ return result;
+}
+
static int
tput(int argc, char *argv[])
{
NCURSES_CONST char *name;
char *s;
int i, j, c;
- int reset, status;
+ int status;
FILE *f;
- reset = 0;
- name = argv[0];
- if (strcmp(name, "reset") == 0) {
- reset = 1;
- }
- if (reset || strcmp(name, "init") == 0) {
+ check_aliases(name = argv[0]);
+ if (is_reset || is_init) {
if (init_prog != 0) {
system(init_prog);
}
FLUSH;
- if (reset && reset_1string != 0) {
+ if (is_reset && reset_1string != 0) {
PUTS(reset_1string);
} else if (init_1string != 0) {
PUTS(init_1string);
}
FLUSH;
- if (reset && reset_2string != 0) {
+ if (is_reset && reset_2string != 0) {
PUTS(reset_2string);
} else if (init_2string != 0) {
PUTS(init_2string);
@@ -107,12 +156,12 @@ tput(int argc, char *argv[])
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) {
+ && 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) {
+ && set_left_margin != 0
+ && set_right_margin != 0) {
PUTS(clear_margins);
if (carriage_return != 0) {
PUTS(carriage_return);
@@ -151,7 +200,7 @@ tput(int argc, char *argv[])
}
}
- if (reset && reset_file != 0) {
+ if (is_reset && reset_file != 0) {
f = fopen(reset_file, "r");
if (f == 0) {
quit(errno, "Can't open reset_file: '%s'", reset_file);
@@ -172,7 +221,7 @@ tput(int argc, char *argv[])
}
FLUSH;
- if (reset && reset_3string != 0) {
+ if (is_reset && reset_3string != 0) {
PUTS(reset_3string);
} else if (init_2string != 0) {
PUTS(init_2string);
@@ -185,7 +234,7 @@ tput(int argc, char *argv[])
PUTS(longname());
return 0;
}
-#ifndef PURE_TERMINFO
+#if !PURE_TERMINFO
{
const struct name_table_entry *np;
@@ -216,10 +265,11 @@ tput(int argc, char *argv[])
return (0);
} else if ((s = tigetstr(name)) == CANCELLED_STRING) {
quit(4, "%s: unknown terminfo capability '%s'", prg_name, name);
- } else if (s != 0) {
+ } else if (s != ABSENT_STRING) {
if (argc > 1) {
int k;
- char * params[10];
+ int numbers[10];
+ char *strings[10];
/* Nasty hack time. The tparm function needs to see numeric
* parameters as numbers, not as pointers to their string
@@ -227,20 +277,31 @@ tput(int argc, char *argv[])
*/
for (k = 1; k < argc; k++) {
- if (isdigit(argv[k][0])) {
- long val = atol(argv[k]);
- params[k] = (char *)val;
- } else {
- params[k] = argv[k];
- }
+ char *tmp = 0;
+ strings[k] = argv[k];
+ numbers[k] = strtol(argv[k], &tmp, 0);
+ if (tmp == 0 || *tmp != 0)
+ numbers[k] = 0;
+ }
+ for (k = argc; k <= 9; k++) {
+ numbers[k] = 0;
+ strings[k] = 0;
}
- for (k = argc; k <= 9; k++)
- params[k] = 0;
- s = tparm(s,
- params[1], params[2], params[3],
- params[4], params[5], params[6],
- params[7], params[8], params[9]);
+ switch (tparm_type(name)) {
+ case Num_Str:
+ s = tparm(s, numbers[1], strings[2]);
+ break;
+ case Num_Str_Str:
+ s = tparm(s, numbers[1], strings[2], strings[3]);
+ break;
+ default:
+ s = tparm(s,
+ numbers[1], numbers[2], numbers[3],
+ numbers[4], numbers[5], numbers[6],
+ numbers[7], numbers[8], numbers[9]);
+ break;
+ }
}
/* use putp() in order to perform padding */
@@ -253,38 +314,47 @@ tput(int argc, char *argv[])
int
main(int argc, char **argv)
{
- char *s, *term;
- int errret, cmdline = 1;
+ char *term;
+ int errret;
+ bool cmdline = TRUE;
int c;
char buf[BUFSIZ];
int errors = 0;
- prg_name = argv[0];
- s = strrchr(prg_name, '/');
- if (s != 0 && *++s != '\0')
- prg_name = s;
+ check_aliases(prg_name = _nc_basename(argv[0]));
term = getenv("TERM");
- while ((c = getopt(argc, argv, "ST:")) != EOF)
+ while ((c = getopt(argc, argv, "ST:V")) != EOF) {
switch (c) {
case 'S':
- cmdline = 0;
+ cmdline = FALSE;
break;
case 'T':
use_env(FALSE);
term = optarg;
break;
+ case 'V':
+ puts(curses_version());
+ return EXIT_SUCCESS;
default:
usage();
/* NOTREACHED */
}
- argc -= optind;
- argv += optind;
+ }
- if (cmdline && argc == 0) {
- usage();
- /* NOTREACHED */
+ /*
+ * Modify the argument list to omit the options we processed.
+ */
+ if (is_reset || is_init) {
+ if (optind-- < argc) {
+ argc -= optind;
+ argv += optind;
+ }
+ argv[0] = prg_name;
+ } else {
+ argc -= optind;
+ argv += optind;
}
if (term == 0 || *term == '\0')
@@ -293,8 +363,11 @@ main(int argc, char **argv)
if (setupterm(term, STDOUT_FILENO, &errret) != OK && errret <= 0)
quit(3, "unknown terminal \"%s\"", term);
- if (cmdline)
+ if (cmdline) {
+ if ((argc <= 0) && !is_reset && !is_init)
+ usage();
return tput(argc, argv);
+ }
while (fgets(buf, sizeof(buf), stdin) != 0) {
char *argvec[16]; /* command, 9 parms, null, & slop */
diff --git a/contrib/ncurses/progs/tset.c b/contrib/ncurses/progs/tset.c
index 392aac0ef551..d8dbda4974f5 100644
--- a/contrib/ncurses/progs/tset.c
+++ b/contrib/ncurses/progs/tset.c
@@ -101,8 +101,9 @@ char *ttyname(int fd);
#include <curses.h> /* for bool typedef */
#include <dump_entry.h>
+#include <transform.h>
-MODULE_ID("$Id: tset.c,v 0.41 2000/03/12 00:03:00 tom Exp $")
+MODULE_ID("$Id: tset.c,v 0.47 2000/10/08 01:01:08 tom Exp $")
extern char **environ;
@@ -113,9 +114,9 @@ const char *_nc_progname = "tset";
static TTY mode, oldmode;
+static bool isreset = FALSE; /* invoked as reset */
static int terasechar = -1; /* new erase character */
static int intrchar = -1; /* new interrupt character */
-static int isreset; /* invoked as reset */
static int tkillchar = -1; /* new kill character */
static int tlines, tcolumns; /* window size */
@@ -233,7 +234,7 @@ typedef struct map {
const char *porttype; /* Port type, or "" for any. */
const char *type; /* Terminal type to select. */
int conditional; /* Baud rate conditionals bitmask. */
- speed_t speed; /* Baud rate to compare against. */
+ int speed; /* Baud rate to compare against. */
} MAP;
static MAP *cur, *maplist;
@@ -260,10 +261,19 @@ static const SPEEDS speeds[] =
{"2400", B2400},
{"4800", B4800},
{"9600", B9600},
+ /* sgttyb may define up to this point */
+#ifdef B19200
{"19200", B19200},
+#endif
+#ifdef B38400
{"38400", B38400},
+#endif
+#ifdef B19200
{"19200", B19200},
+#endif
+#ifdef B38400
{"38400", B38400},
+#endif
#ifdef B19200
{"19200", B19200},
#else
@@ -505,10 +515,7 @@ get_termcap_entry(char *userarg)
goto map;
if ((ttypath = ttyname(STDERR_FILENO)) != 0) {
- if ((p = strrchr(ttypath, '/')) != 0)
- ++p;
- else
- p = ttypath;
+ p = _nc_basename(ttypath);
#if HAVE_GETTTYNAM
/*
* We have the 4.3BSD library call getttynam(3); that means
@@ -582,15 +589,15 @@ get_termcap_entry(char *userarg)
}
/* Find the terminfo entry. If it doesn't exist, ask the user. */
while ((rval = setupterm((NCURSES_CONST char *) ttype, STDOUT_FILENO,
- &errret)) != OK) {
+ &errret)) != OK) {
if (errret == 0) {
(void) fprintf(stderr, "tset: unknown terminal type %s\n",
- ttype);
+ ttype);
ttype = 0;
} else {
(void) fprintf(stderr,
- "tset: can't initialize terminal type %s (error %d)\n",
- ttype, errret);
+ "tset: can't initialize terminal type %s (error %d)\n",
+ ttype, errret);
ttype = 0;
}
ttype = askuser(ttype);
@@ -683,46 +690,46 @@ reset_mode(void)
mode.c_iflag &= ~(IGNBRK | PARMRK | INPCK | ISTRIP | INLCR | IGNCR
#ifdef IUCLC
- | IUCLC
+ | IUCLC
#endif
#ifdef IXANY
- | IXANY
+ | IXANY
#endif
- | IXOFF);
+ | IXOFF);
mode.c_iflag |= (BRKINT | IGNPAR | ICRNL | IXON
#ifdef IMAXBEL
- | IMAXBEL
+ | IMAXBEL
#endif
);
mode.c_oflag &= ~(0
#ifdef OLCUC
- | OLCUC
+ | OLCUC
#endif
#ifdef OCRNL
- | OCRNL
+ | OCRNL
#endif
#ifdef ONOCR
- | ONOCR
+ | ONOCR
#endif
#ifdef ONLRET
- | ONLRET
+ | ONLRET
#endif
#ifdef OFILL
- | OFILL
+ | OFILL
#endif
#ifdef OFDEL
- | OFDEL
+ | OFDEL
#endif
#ifdef NLDLY
- | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY
+ | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY
#endif
);
mode.c_oflag |= (OPOST
#ifdef ONLCR
- | ONLCR
+ | ONLCR
#endif
);
@@ -730,22 +737,22 @@ reset_mode(void)
mode.c_cflag |= (CS8 | CREAD);
mode.c_lflag &= ~(ECHONL | NOFLSH
#ifdef TOSTOP
- | TOSTOP
+ | TOSTOP
#endif
#ifdef ECHOPTR
- | ECHOPRT
+ | ECHOPRT
#endif
#ifdef XCASE
- | XCASE
+ | XCASE
#endif
);
mode.c_lflag |= (ISIG | ICANON | ECHO | ECHOE | ECHOK
#ifdef ECHOCTL
- | ECHOCTL
+ | ECHOCTL
#endif
#ifdef ECHOKE
- | ECHOKE
+ | ECHOKE
#endif
);
#endif
@@ -761,6 +768,7 @@ reset_mode(void)
* Returns a "good" value for the erase character. This is loosely based on
* the BSD4.4 logic.
*/
+#ifdef TERMIOS
static int
default_erase(void)
{
@@ -775,6 +783,7 @@ default_erase(void)
return result;
}
+#endif
/*
* Update the values of the erase, interrupt, and kill characters in 'mode'.
@@ -954,10 +963,10 @@ set_tabs()
/*
* Tell the user if a control key has been changed from the default value.
*/
+#ifdef TERMIOS
static void
report(const char *name, int which, unsigned def)
{
-#ifdef TERMIOS
unsigned older, newer;
char *p;
@@ -976,16 +985,16 @@ report(const char *name, int which, unsigned def)
if (newer == 0177)
(void) fprintf(stderr, "delete.\n");
else if ((p = key_backspace) != 0
- && newer == (unsigned char) p[0]
- && p[1] == '\0')
+ && newer == (unsigned char) p[0]
+ && p[1] == '\0')
(void) fprintf(stderr, "backspace.\n");
else if (newer < 040) {
newer ^= 0100;
(void) fprintf(stderr, "control-%c (^%c).\n", newer, newer);
} else
(void) fprintf(stderr, "%c.\n", newer);
-#endif
}
+#endif
/*
* Convert the obsolete argument forms into something that getopt can handle.
@@ -1025,7 +1034,7 @@ static void
usage(const char *pname)
{
(void) fprintf(stderr,
- "usage: %s [-IQrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n", pname);
+ "usage: %s [-IQVrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n", pname);
exit(EXIT_FAILURE);
}
@@ -1047,32 +1056,24 @@ main(int argc, char **argv)
const char *p;
const char *ttype;
-#ifdef TERMIOS
- if (tcgetattr(STDERR_FILENO, &mode) < 0)
+ if (GET_TTY(STDERR_FILENO, &mode) < 0)
failed("standard error");
-
oldmode = mode;
+#ifdef TERMIOS
ospeed = cfgetospeed(&mode);
#else
- if (gtty(STDERR_FILENO, &mode) < 0)
- failed("standard error");
-
- oldmode = mode;
ospeed = mode.sg_ospeed;
#endif
- if ((p = strrchr(*argv, '/')) != 0)
- ++p;
- else
- p = *argv;
- if (!CaselessCmp(p, "reset")) {
- isreset = 1;
+ p = _nc_basename(*argv);
+ if (!strcmp(p, PROG_RESET)) {
+ isreset = TRUE;
reset_mode();
}
obsolete(argv);
noinit = noset = quiet = Sflag = sflag = showterm = 0;
- while ((ch = getopt(argc, argv, "a:d:e:Ii:k:m:np:qQSrs")) != EOF) {
+ while ((ch = getopt(argc, argv, "a:d:e:Ii:k:m:np:qQSrsV")) != EOF) {
switch (ch) {
case 'q': /* display term only */
noset = 1;
@@ -1115,6 +1116,9 @@ main(int argc, char **argv)
case 's': /* output TERM set command */
sflag = 1;
break;
+ case 'V':
+ puts(curses_version());
+ return EXIT_SUCCESS;
case '?':
default:
usage(*argv);
@@ -1170,11 +1174,13 @@ main(int argc, char **argv)
* If erase, kill and interrupt characters could have been
* modified and not -Q, display the changes.
*/
+#ifdef TERMIOS
if (!quiet) {
report("Erase", VERASE, CERASE);
report("Kill", VKILL, CINTR);
report("Interrupt", VINTR, CKILL);
}
+#endif
}
if (Sflag)