summaryrefslogtreecommitdiff
path: root/usr.bin/tset
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-08-18 07:27:59 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-08-18 07:27:59 +0000
commit71346dd10453d60620ef32942ee14c84ffcc1e03 (patch)
tree5a802cdf6a0e7fa756c969f1f9294a4be734f050 /usr.bin/tset
parent14aebc178de8a3b59e37b6cc02010be9cacd3dbf (diff)
downloadsrc-test2-71346dd10453d60620ef32942ee14c84ffcc1e03.tar.gz
src-test2-71346dd10453d60620ef32942ee14c84ffcc1e03.zip
Use err(3) insteadof local redefinition. Sync usage string with man page.
Notes
Notes: svn path=/head/; revision=28370
Diffstat (limited to 'usr.bin/tset')
-rw-r--r--usr.bin/tset/extern.h1
-rw-r--r--usr.bin/tset/map.c14
-rw-r--r--usr.bin/tset/misc.c41
-rw-r--r--usr.bin/tset/set.c4
-rw-r--r--usr.bin/tset/term.c22
-rw-r--r--usr.bin/tset/tset.124
-rw-r--r--usr.bin/tset/tset.c34
-rw-r--r--usr.bin/tset/wrterm.c9
8 files changed, 73 insertions, 76 deletions
diff --git a/usr.bin/tset/extern.h b/usr.bin/tset/extern.h
index 29acface3c37..6d1be245e343 100644
--- a/usr.bin/tset/extern.h
+++ b/usr.bin/tset/extern.h
@@ -41,7 +41,6 @@ extern int erasechar, intrchar, killchar;
void add_mapping __P((char *, char *));
void cat __P((char *));
-void err __P((const char *, ...));
char *get_termcap_entry __P((char *, char **));
char *mapped __P((char *));
int outc __P((int));
diff --git a/usr.bin/tset/map.c b/usr.bin/tset/map.c
index 2e71d2c502b4..cee4b669ed55 100644
--- a/usr.bin/tset/map.c
+++ b/usr.bin/tset/map.c
@@ -32,14 +32,18 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/9/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
-#include <termios.h>
-#include <errno.h>
+#include <err.h>
#include <stdlib.h>
#include <string.h>
+#include <termios.h>
#include "extern.h"
extern speed_t Ospeed;
@@ -78,7 +82,7 @@ add_mapping(port, arg)
copy = strdup(arg);
mapp = malloc((u_int)sizeof(MAP));
if (copy == NULL || mapp == NULL)
- err("%s", strerror(errno));
+ errx(1, "malloc");
mapp->next = NULL;
if (maplist == NULL)
cur = maplist = mapp;
@@ -154,7 +158,7 @@ next: if (*arg == ':') {
/* If user specified a port with an option flag, set it. */
done: if (port) {
if (mapp->porttype)
-badmopt: err("illegal -m option format: %s", copy);
+badmopt: errx(1, "illegal -m option format: %s", copy);
mapp->porttype = port;
}
@@ -247,6 +251,6 @@ baudrate(rate)
return (sp->speed);
speed = atol(rate);
if (speed == 0)
- err("unknown baud rate %s", rate);
+ errx(1, "unknown baud rate %s", rate);
return speed;
}
diff --git a/usr.bin/tset/misc.c b/usr.bin/tset/misc.c
index 27a2bf6fea51..1e94df18c83a 100644
--- a/usr.bin/tset/misc.c
+++ b/usr.bin/tset/misc.c
@@ -32,11 +32,15 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/9/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <fcntl.h>
-#include <errno.h>
+#include <err.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -51,13 +55,13 @@ cat(file)
char buf[1024];
if ((fd = open(file, O_RDONLY, 0)) < 0)
- err("%s: %s", file, strerror(errno));
+ err(1, "%s", file);
while ((nr = read(fd, buf, sizeof(buf))) > 0)
if ((nw = write(STDERR_FILENO, buf, nr)) == -1)
- err("write to stderr: %s", strerror(errno));
+ err(1, "write to stderr");
if (nr != 0)
- err("%s: %s", file, strerror(errno));
+ err(1, "%s", file);
(void)close(fd);
}
@@ -67,32 +71,3 @@ outc(c)
{
return putc(c, stderr);
}
-
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-void
-#if __STDC__
-err(const char *fmt, ...)
-#else
-err(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- (void)fprintf(stderr, "tset: ");
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- (void)fprintf(stderr, "\n");
- exit(1);
- /* NOTREACHED */
-}
diff --git a/usr.bin/tset/set.c b/usr.bin/tset/set.c
index e55ebbd126cf..68fa7a2259c0 100644
--- a/usr.bin/tset/set.c
+++ b/usr.bin/tset/set.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)set.c 8.2 (Berkeley) 2/28/94";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <termios.h>
diff --git a/usr.bin/tset/term.c b/usr.bin/tset/term.c
index dc652e3ec18b..714ef6515541 100644
--- a/usr.bin/tset/term.c
+++ b/usr.bin/tset/term.c
@@ -32,16 +32,21 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)term.c 8.1 (Berkeley) 6/9/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
+#include <err.h>
#include <errno.h>
-#include <ttyent.h>
-#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <ttyent.h>
#include "extern.h"
char tbuf[1024]; /* Termcap entry. */
@@ -67,12 +72,12 @@ get_termcap_entry(userarg, tcapbufp)
}
/* Try the environment. */
- if (ttype = getenv("TERM"))
+ if ((ttype = getenv("TERM")))
goto map;
/* Try ttyname(3); check for dialup or other mapping. */
- if (ttypath = ttyname(STDERR_FILENO)) {
- if (p = rindex(ttypath, '/'))
+ if ((ttypath = ttyname(STDERR_FILENO))) {
+ if ((p = rindex(ttypath, '/')))
++p;
else
p = ttypath;
@@ -107,12 +112,11 @@ found: if ((p = getenv("TERMCAP")) != NULL && *p != '/')
/* Find the termcap entry. If it doesn't exist, ask the user. */
while ((rval = tgetent(tbuf, ttype)) == 0) {
- (void)fprintf(stderr,
- "tset: terminal type %s is unknown\n", ttype);
+ warnx("terminal type %s is unknown", ttype);
ttype = askuser(NULL);
}
if (rval == -1)
- err("termcap: %s", strerror(errno ? errno : ENOENT));
+ errx(1, "termcap: %s", strerror(errno ? errno : ENOENT));
*tcapbufp = tbuf;
return (ttype);
}
@@ -145,7 +149,7 @@ askuser(dflt)
return (dflt);
}
- if (p = index(answer, '\n'))
+ if ((p = index(answer, '\n')))
*p = '\0';
if (answer[0])
return (answer);
diff --git a/usr.bin/tset/tset.1 b/usr.bin/tset/tset.1
index 16b73446211f..8c99cabf8924 100644
--- a/usr.bin/tset/tset.1
+++ b/usr.bin/tset/tset.1
@@ -70,7 +70,7 @@ argument specified on the command line.
.It
The value of the
.Ev TERM
-environmental variable.
+environment variable.
.It
The terminal type associated with the standard error output device in the
.Pa /etc/ttys
@@ -100,7 +100,7 @@ standard error output.
.Pp
When invoked as
.Nm reset ,
-.Nm tset
+.Nm
sets cooked and echo modes, turns off cbreak and raw modes, turns on
newline translation and resets any unset special characters to their
default values before doing the terminal initialization described above.
@@ -183,7 +183,7 @@ option is specified, the commands to enter the information into the
shell's environment are written to the standard output.
If the
.Ev SHELL
-environmental variable ends in ``csh'', the commands are for the
+environment variable ends in ``csh'', the commands are for the
.Nm csh ,
otherwise, they are for
.Xr sh .
@@ -220,13 +220,13 @@ information is incorrect) the terminal type derived from the
.Pa /etc/ttys
file or the
.Ev TERM
-environmental variable is often something generic like
+environment variable is often something generic like
.Dq network ,
.Dq dialup ,
or
.Dq unknown .
When
-.Nm tset
+.Nm
is used in a startup script
.Pf ( Pa .profile
for
@@ -243,7 +243,7 @@ option is to
.Dq map
from some set of conditions to a terminal type, that is, to
tell
-.Nm tset
+.Nm
``If I'm on this port at a particular speed, guess that I'm on that
kind of terminal''.
.Pp
@@ -320,7 +320,7 @@ users insert a backslash character (``\e'') before any exclamation
marks (``!'').
.Sh ENVIRONMENT
The
-.Nm tset
+.Nm
command utilizes the
.Ev SHELL
and
@@ -343,7 +343,7 @@ terminal capability database
.Xr environ 7
.Sh HISTORY
The
-.Nm tset
+.Nm
command appeared in
.Bx 3.0 .
.Sh COMPATIBILITY
@@ -355,7 +355,7 @@ The
and
.Fl v
options have been deleted from the
-.Nm tset
+.Nm
utility.
None of them were documented in 4.3BSD and all are of limited utility at
best.
@@ -382,7 +382,7 @@ options without arguments, although it is strongly recommended that such
usage be fixed to explicitly specify the character.
.Pp
Executing
-.Nm tset
+.Nm
as
.Nm reset
no longer implies the
@@ -393,11 +393,11 @@ Also, the interaction between the
option and the
.Ar terminal
argument in some historic implementations of
-.Nm tset
+.Nm
has been removed.
.Pp
Finally, the
-.Nm tset
+.Nm
implementation has been completely redone (as part of the addition to the
system of a
.St -p1003.1-88
diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c
index b25398b2dd6b..a097dcac8eef 100644
--- a/usr.bin/tset/tset.c
+++ b/usr.bin/tset/tset.c
@@ -32,24 +32,28 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1980, 1991, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)tset.c 8.1 (Berkeley) 6/9/93";
+#endif
+static const char rcdif[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
#include <sys/ioctl.h>
-#include <termios.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <ctype.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <termios.h>
#include "extern.h"
void obsolete __P((char *[]));
@@ -74,15 +78,15 @@ main(argc, argv)
struct winsize win;
#endif
int ch, noinit, noset, quiet, Sflag, sflag, showterm, usingupper;
- char savech, *p, *t, *tcapbuf, *ttype;
+ char *p, *t, *tcapbuf, *ttype;
if (tcgetattr(STDERR_FILENO, &mode) < 0)
- err("standard error: %s", strerror(errno));
+ err(1, "standard error");
oldmode = mode;
Ospeed = cfgetospeed(&mode);
- if (p = strrchr(*argv, '/'))
+ if ((p = strrchr(*argv, '/')))
++p;
else
p = *argv;
@@ -262,9 +266,9 @@ obsolete(argv)
char *argv[];
{
for (; *argv; ++argv) {
- if (argv[0][0] != '-' || argv[1] && argv[1][0] != '-' ||
- argv[0][1] != 'e' && argv[0][1] != 'i' &&
- argv[0][1] != 'k' || argv[0][2] != '\0')
+ if (argv[0][0] != '-' || (argv[1] && argv[1][0] != '-') ||
+ (argv[0][1] != 'e' && argv[0][1] != 'i' && argv[0][1] != 'k') ||
+ argv[0][2] != '\0')
continue;
switch(argv[0][1]) {
case 'e':
@@ -283,7 +287,9 @@ obsolete(argv)
void
usage()
{
- (void)fprintf(stderr,
-"usage: tset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n");
+ (void)fprintf(stderr, "%s\n%s\n",
+"usage: tset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]",
+" reset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]");
exit(1);
}
+
diff --git a/usr.bin/tset/wrterm.c b/usr.bin/tset/wrterm.c
index 5c33b49979ec..d6274cfd1e04 100644
--- a/usr.bin/tset/wrterm.c
+++ b/usr.bin/tset/wrterm.c
@@ -32,12 +32,17 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)wrterm.c 8.1 (Berkeley) 6/9/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
-#include <stdio.h>
#include <ctype.h>
+#include <err.h>
+#include <stdio.h>
#include <string.h>
#include "extern.h"
@@ -55,7 +60,7 @@ wrtermcap(bp)
/* Find the end of the terminal names. */
if ((t = index(bp, ':')) == NULL)
- err("termcap names not colon terminated");
+ errx(1, "termcap names not colon terminated");
*t++ = '\0';
/* Output terminal names that don't have whitespace. */