summaryrefslogtreecommitdiff
path: root/usr.bin/tset
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2013-09-18 16:21:31 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2013-09-18 16:21:31 +0000
commit83670772f22a4302e7e867459f89cc4ae2d937c9 (patch)
treefff7934928fc7582081d83d64d38423e8a359f41 /usr.bin/tset
parenta43eef20f32974bc853195fcaa46355e7784047e (diff)
Remove "tset -S" compatibility I added years ago. Most converted
terminfo entries for most terminals are too large to fit within the 1023 bytes allowed for termcap. We're better off without it. OK espie@ jmc@
Diffstat (limited to 'usr.bin/tset')
-rw-r--r--usr.bin/tset/Makefile4
-rw-r--r--usr.bin/tset/termcap.c211
-rw-r--r--usr.bin/tset/tset.1107
-rw-r--r--usr.bin/tset/tset.c61
4 files changed, 44 insertions, 339 deletions
diff --git a/usr.bin/tset/Makefile b/usr.bin/tset/Makefile
index 0b3a4ccc40a..aff17b10b19 100644
--- a/usr.bin/tset/Makefile
+++ b/usr.bin/tset/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.8 2009/05/06 19:12:45 millert Exp $
+# $OpenBSD: Makefile,v 1.9 2013/09/18 16:21:29 millert Exp $
PROG= tset
-SRCS= tset.c dump_entry.c termcap.c
+SRCS= tset.c dump_entry.c
DPADD= ${LIBCURSES}
LDADD= -lcurses
CURSES= ${.CURDIR}/../../lib/libcurses
diff --git a/usr.bin/tset/termcap.c b/usr.bin/tset/termcap.c
deleted file mode 100644
index 6ab914792a9..00000000000
--- a/usr.bin/tset/termcap.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* $OpenBSD: termcap.c,v 1.7 2009/10/27 23:59:46 deraadt Exp $ */
-/* $NetBSD: termcap.c,v 1.7 1995/06/05 19:45:52 pk Exp $ */
-
-/*
- * Copyright (c) 1980, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define PVECSIZ 32 /* max number of names in path */
-#define _PATH_DEF ".termcap /usr/share/misc/termcap"
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <err.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/*
- * Get an entry for terminal name in buffer bp from the termcap file.
- */
-int
-tcgetent(bp, name)
- char *bp;
- const char *name;
-{
- char *p;
- char *cp;
- char *dummy;
- char **fname;
- char *home;
- int i;
- char pathbuf[MAXPATHLEN]; /* holds raw path of filenames */
- char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
- char **pvec; /* holds usable tail of path vector */
- char *termpath;
-
- fname = pathvec;
- pvec = pathvec;
-
- if (!issetugid()) {
- cp = getenv("TERMCAP");
- /*
- * TERMCAP can have one of two things in it. It can be the name
- * of a file to use instead of /usr/share/misc/termcap. In this
- * case it better start with a "/". Or it can be an entry to
- * use so we don't have to read the file. In this case it
- * has to already have the newlines crunched out. If TERMCAP
- * does not hold a file name then a path of names is searched
- * instead. The path is found in the TERMPATH variable, or
- * becomes "$HOME/.termcap /usr/share/misc/termcap" if no
- * TERMPATH exists.
- */
- if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */
- if ((termpath = getenv("TERMPATH")) != NULL)
- strlcpy(pathbuf, termpath, sizeof(pathbuf));
- else {
- if ((home = getenv("HOME")) != NULL &&
- *home != '\0' &&
- strlen(home) + sizeof(_PATH_DEF) <
- sizeof(pathbuf)) {
- snprintf(pathbuf, sizeof pathbuf,
- "%s/%s", home, _PATH_DEF);
- } else {
- strlcpy(pathbuf, _PATH_DEF,
- sizeof(pathbuf));
- }
- }
- } else { /* user-defined path in TERMCAP */
- /* still can be tokenized */
- strlcpy(pathbuf, cp, sizeof(pathbuf));
- }
- *fname++ = pathbuf; /* tokenize path into vector of names */
- }
-
- /* split pathbuf into a vector of paths */
- p = pathbuf;
- while (*++p)
- if (*p == ' ' || *p == ':') {
- *p = '\0';
- while (*++p)
- if (*p != ' ' && *p != ':')
- break;
- if (*p == '\0')
- break;
- *fname++ = p;
- if (fname >= pathvec + PVECSIZ) {
- fname--;
- break;
- }
- }
- *fname = (char *) 0; /* mark end of vector */
- if (cp && *cp && *cp != '/')
- if (cgetset(cp) < 0)
- return (-2);
-
- dummy = NULL;
- i = cgetent(&dummy, pathvec, (char *)name);
-
- if (i == 0 && bp != NULL) {
- strlcpy(bp, dummy, 1024);
- if ((cp = strrchr(bp, ':')) != NULL)
- if (cp[1] != '\0')
- cp[1] = '\0';
- }
- else if (i == 0 && bp == NULL)
- bp = dummy;
- else if (dummy != NULL)
- free(dummy);
-
- /* no tc reference loop return code in libterm XXX */
- if (i == -3)
- return (-1);
- return (i + 1);
-}
-
-/*
- * Output termcap entry to stdout, quoting characters that would give the
- * shell problems and omitting empty fields.
- */
-void
-wrtermcap(bp)
- char *bp;
-{
- int ch;
- char *p;
- char *t, *sep;
-
- /* Find the end of the terminal names. */
- if ((t = strchr(bp, ':')) == NULL)
- err(1, "termcap names not colon terminated");
- *t++ = '\0';
-
- /* Output terminal names that don't have whitespace. */
- sep = "";
- while ((p = strsep(&bp, "|")) != NULL)
- if (*p != '\0' && strpbrk(p, " \t") == NULL) {
- (void)printf("%s%s", sep, p);
- sep = "|";
- }
- (void)putchar(':');
-
- /*
- * Output fields, transforming any dangerous characters. Skip
- * empty fields or fields containing only whitespace.
- */
- while ((p = strsep(&t, ":")) != NULL) {
- while (isspace(*p))
- ++p;
- if (*p == '\0')
- continue;
- while ((ch = *p++) != '\0')
- switch(ch) {
- case '\033':
- (void)printf("\\E");
- case ' ': /* No spaces. */
- (void)printf("\\040");
- break;
- case '!': /* No csh history chars. */
- (void)printf("\\041");
- break;
- case ',': /* No csh history chars. */
- (void)printf("\\054");
- break;
- case '"': /* No quotes. */
- (void)printf("\\042");
- break;
- case '\'': /* No quotes. */
- (void)printf("\\047");
- break;
- case '`': /* No quotes. */
- (void)printf("\\140");
- break;
- case '\\': /* Anything following is OK. */
- case '^':
- (void)putchar(ch);
- if ((ch = *p++) == '\0')
- break;
- /* FALLTHROUGH */
- default:
- (void)putchar(ch);
- }
- (void)putchar(':');
- }
-}
diff --git a/usr.bin/tset/tset.1 b/usr.bin/tset/tset.1
index 5a28f20288e..5cfdf4ed448 100644
--- a/usr.bin/tset/tset.1
+++ b/usr.bin/tset/tset.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tset.1,v 1.18 2011/12/28 22:27:18 schwarze Exp $
+.\" $OpenBSD: tset.1,v 1.19 2013/09/18 16:21:30 millert Exp $
.\"
.\" Copyright (c) 1985, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)tset.1 8.1 (Berkeley) 6/9/93
.\"
-.Dd $Mdocdate: December 28 2011 $
+.Dd $Mdocdate: September 18 2013 $
.Dt TSET 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Nd terminal initialization
.Sh SYNOPSIS
.Nm tset
-.Op Fl cIQqrSsVw
+.Op Fl cIQqrsVw
.Op Fl
.Op Fl e Ar ch
.Op Fl i Ar ch
@@ -45,7 +45,7 @@
.Op Fl m Ar mapping
.Op Ar terminal
.Nm reset
-.Op Fl cIQqrSsVw
+.Op Fl cIQqrsVw
.Op Fl
.Op Fl e Ar ch
.Op Fl i Ar ch
@@ -78,18 +78,20 @@ The default terminal type,
.Pp
If the terminal type was not specified on the command line, the
.Fl m
-option mappings are then applied (see below for more information).
+option mappings are then applied (see the
+.Sx TERMINAL TYPE MAPPING
+section below for more information).
Then, if the terminal type begins with a question mark
.Pq Ql \&? ,
the user is prompted for confirmation of the terminal type.
An empty response confirms the type, or another type can be entered to
specify a new type.
-Once the terminal type has been determined, the termcap entry for the terminal
+Once the terminal type has been determined, the terminfo entry for the terminal
is retrieved.
-If no termcap entry is found for the type, the user is prompted for another
+If no terminfo entry is found for the type, the user is prompted for another
terminal type.
.Pp
-Once the termcap entry is retrieved, the window size, backspace, interrupt,
+Once the terminfo entry is retrieved, the window size, backspace, interrupt,
and line kill characters (among many other things) are set and the terminal
and tab initialization strings are sent to the standard error output.
Finally, if the erase, interrupt and line kill characters have changed,
@@ -138,7 +140,9 @@ Set the line kill character to
.Ar ch .
.It Fl m Ar mapping
Specify a mapping from a port type to a terminal.
-See below for more information.
+See the
+.Sx TERMINAL TYPE MAPPING
+section below for more information.
.It Fl Q
Don't display any values for the erase, interrupt and line kill characters.
Normally
@@ -150,16 +154,13 @@ The terminal type is displayed to the standard output, and the terminal is
not initialized in any way.
.It Fl r
Print the terminal type to the standard error output.
-.It Fl S
-Print the terminal type and the termcap entry to the standard output.
-See the section below on setting the environment for details.
.It Fl s
-Print the sequence of shell commands to initialize the environment variables
+Print the sequence of shell commands to initialize the environment variable
.Ev TERM
-and
-.Ev TERMCAP
to the standard output.
-See the section below on setting the environment for details.
+See the
+.Sx SETTING THE ENVIRONMENT
+section below for details.
.It Fl V
Report the version of ncurses which was used in this program, and exit.
.It Fl w
@@ -185,21 +186,8 @@ or
It is often desirable to enter the terminal type and information about
the terminal's capabilities into the shell's environment.
This is done using the
-.Fl S
-and
.Fl s
-options.
-.Pp
-When the
-.Fl S
-option is specified, the terminal type and the termcap entry are written
-to the standard output, separated by a space and without a terminating
-newline.
-This can be assigned to an array by
-.Xr csh 1
-and
-.Xr ksh 1
-users and then used like any other shell array.
+option.
.Pp
When the
.Fl s
@@ -226,20 +214,6 @@ files will initialize the environment correctly:
.Bd -literal -offset indent
eval \`tset -s options ... \`
.Ed
-.Pp
-To demonstrate a simple use of the
-.Fl S
-option, the following lines in the
-.Pa .login
-file have an equivalent effect:
-.Bd -literal -offset indent
-set noglob
-set term=(`tset -S options ...`)
-setenv TERM $term[1]
-setenv TERMCAP "$term[2]"
-unset term
-unset noglob
-.Ed
.Sh TERMINAL TYPE MAPPING
When the terminal is not hardwired into the system (or the current system
information is incorrect), the terminal type derived from the
@@ -357,10 +331,10 @@ and
.Ev TERM
environment variables.
.Sh FILES
-.Bl -tag -width /usr/share/misc/termcap -compact
+.Bl -tag -width /usr/share/misc/terminfo.db -compact
.It Pa /etc/ttys
port name to terminal type mapping database
-.It Pa /usr/share/misc/termcap
+.It Pa /usr/share/misc/terminfo.db
terminal capability database
.El
.Sh SEE ALSO
@@ -368,7 +342,7 @@ terminal capability database
.Xr sh 1 ,
.Xr stty 1 ,
.Xr tty 4 ,
-.Xr termcap 5 ,
+.Xr terminfo 5 ,
.Xr ttys 5 ,
.Xr environ 7
.Sh STANDARDS
@@ -378,28 +352,25 @@ command now uses the
.Xr terminfo 5
database where previous versions used
.Xr termcap 5 .
-To make the
-.Fl s
-and
-.Fl S
-options still work,
-.Nm tset
-also reads in the terminal entry from
-.Xr termcap 5 .
-However, this info is used for setting
-.Ev TERMCAP
-only.
-If the terminal type appears in
-.Xr terminfo 5
-but not in
-.Xr termcap 5 ,
-the
-.Fl q
-option will not set
+.Pp
+Historic versions of the
+.Xr termcap 3
+library limited entries to 1023 bytes.
+Modern
+.Xr terminfo 3
+entries are often much larger, making it impossible to
+store the full entry in the
.Ev TERMCAP
-and the
-.Fl Q
-option will not work at all.
+environment variable.
+Because of this, the
+.Fl S
+option is no longer supported (it prints an error message to the standard
+error and exits) and the
+.Fl s
+option only sets
+.Ev TERM ,
+not
+.Ev TERMCAP .
.Pp
The
.Fl A ,
diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c
index 50a942874f6..8ccb6413da7 100644
--- a/usr.bin/tset/tset.c
+++ b/usr.bin/tset/tset.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tset.c,v 1.35 2010/01/12 23:22:14 nicm Exp $ */
+/* $OpenBSD: tset.c,v 1.36 2013/09/18 16:21:30 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
@@ -105,7 +105,7 @@ char *ttyname(int fd);
#include <dump_entry.h>
#include <transform.h>
-MODULE_ID("$Id: tset.c,v 1.35 2010/01/12 23:22:14 nicm Exp $")
+MODULE_ID("$Id: tset.c,v 1.36 2013/09/18 16:21:30 millert Exp $")
/*
* SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS,
@@ -1133,7 +1133,7 @@ usage(void)
," -w set window-size"
};
unsigned n;
- (void) fprintf(stderr, "Usage: %s [-cIQqrSsVw] [-] "
+ (void) fprintf(stderr, "Usage: %s [-cIQqrsVw] [-] "
"[-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n",
_nc_progname);
for (n = 0; n < sizeof(tbl) / sizeof(tbl[0]); ++n)
@@ -1157,11 +1157,6 @@ main(int argc, char **argv)
int ch, noinit, noset, quiet, Sflag, sflag, showterm;
const char *p;
const char *ttype;
-#ifdef __OpenBSD__
- char tcapbuf[1024], *t;
- int tcgetent(char *, const char *);
- void wrtermcap (char *);
-#endif /* __OpenBSD__ */
obsolete(argv);
noinit = noset = quiet = Sflag = sflag = showterm = 0;
@@ -1249,10 +1244,6 @@ main(int argc, char **argv)
}
ttype = get_termcap_entry(*argv);
-#ifdef __OpenBSD__
- if (tcgetent(tcapbuf, ttype) < 0)
- tcapbuf[0] = '\0';
-#endif /* __OpenBSD__ */
if (!noset) {
tcolumns = columns;
@@ -1307,54 +1298,9 @@ main(int argc, char **argv)
#endif
}
-#ifdef __OpenBSD__
- if (Sflag) {
- if (tcapbuf[0]) {
- (void) printf("%s ", ttype);
- wrtermcap(tcapbuf);
- } else
- err("No termcap entry for %s, only terminfo.", ttype);
- }
-#else
if (Sflag)
err("The -S option is not supported under terminfo.");
-#endif /* __OpenBSD__ */
-#ifdef __OpenBSD__
- if (sflag) {
- /*
- * Figure out what shell we're using. A hack, we look for an
- * environmental variable SHELL ending in "csh".
- */
- if ((p = getenv("SHELL")) != 0 && !strcmp(p + strlen(p) - 3, "csh")) {
- if (tcapbuf[0])
- p = "set noglob histchars="";\nsetenv TERM %s;\nsetenv TERMCAP ";
- else
- p = "set noglob histchars="";\nsetenv TERM %s;\n";
- t = "unset noglob histchars;\n";
- } else {
- if (tcapbuf) {
- p = "TERM=%s;\nTERMCAP=";
- t = "export TERMCAP TERM;\n";
- } else {
- if (tcapbuf) {
- p = "TERM=%s;\nTERMCAP=";
- t = "export TERMCAP TERM;\n";
- } else {
- p = "TERM=%s;\n";
- t = "export TERMCAP;\n";
- }
- }
- }
- (void) printf(p, ttype);
- if (tcapbuf[0]) {
- putchar('\'');
- wrtermcap(tcapbuf);
- fputs("';\n", stdout);
- }
- (void)fputs(t, stdout);
- }
-#else
if (sflag) {
int len;
char *var;
@@ -1371,7 +1317,6 @@ main(int argc, char **argv)
p = "TERM=%s;\n";
(void) printf(p, ttype);
}
-#endif /* __OpenBSD__ */
ExitProgram(EXIT_SUCCESS);
}