diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-07-25 22:13:26 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-07-25 22:13:26 +0000 |
commit | 7b73c922fbbe8a90f902743c24d2cc06ae3dc74d (patch) | |
tree | 505ea16daf41ea5aab29987c6847dfec5a366dc3 | |
parent | e96f055d1d0fcef46dcf86f16e226a0eb6c93968 (diff) |
user err(3)
-rw-r--r-- | usr.bin/tset/extern.h | 3 | ||||
-rw-r--r-- | usr.bin/tset/map.c | 9 | ||||
-rw-r--r-- | usr.bin/tset/misc.c | 40 | ||||
-rw-r--r-- | usr.bin/tset/term.c | 14 | ||||
-rw-r--r-- | usr.bin/tset/tset.c | 9 |
5 files changed, 23 insertions, 52 deletions
diff --git a/usr.bin/tset/extern.h b/usr.bin/tset/extern.h index d7517411753..d3509a11465 100644 --- a/usr.bin/tset/extern.h +++ b/usr.bin/tset/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.2 1996/06/26 05:41:54 deraadt Exp $ */ +/* $OpenBSD: extern.h,v 1.3 1997/07/25 22:13:23 mickey Exp $ */ /* $NetBSD: extern.h,v 1.3 1994/12/07 05:08:06 jtc Exp $ */ /*- @@ -52,7 +52,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 *)); void outc __P((int)); diff --git a/usr.bin/tset/map.c b/usr.bin/tset/map.c index bbe63ddd2c0..9e7c6b3d1f4 100644 --- a/usr.bin/tset/map.c +++ b/usr.bin/tset/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.3 1997/01/17 07:13:43 millert Exp $ */ +/* $OpenBSD: map.c,v 1.4 1997/07/25 22:13:23 mickey Exp $ */ /* $NetBSD: map.c,v 1.4 1994/12/07 05:08:07 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/9/93"; #endif -static char rcsid[] = "$OpenBSD: map.c,v 1.3 1997/01/17 07:13:43 millert Exp $"; +static char rcsid[] = "$OpenBSD: map.c,v 1.4 1997/07/25 22:13:23 mickey Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -46,6 +46,7 @@ static char rcsid[] = "$OpenBSD: map.c,v 1.3 1997/01/17 07:13:43 millert Exp $"; #include <errno.h> #include <stdlib.h> #include <string.h> +#include <err.h> #include "extern.h" int baudrate __P((char *)); @@ -83,7 +84,7 @@ add_mapping(port, arg) copy = strdup(arg); mapp = malloc((u_int)sizeof(MAP)); if (copy == NULL || mapp == NULL) - err("%s", strerror(errno)); + err(1, "malloc"); mapp->next = NULL; if (maplist == NULL) cur = maplist = mapp; @@ -159,7 +160,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; } diff --git a/usr.bin/tset/misc.c b/usr.bin/tset/misc.c index 6f1790a6256..64c936531c1 100644 --- a/usr.bin/tset/misc.c +++ b/usr.bin/tset/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.3 1997/07/25 21:05:45 mickey Exp $ */ +/* $OpenBSD: misc.c,v 1.4 1997/07/25 22:13:24 mickey Exp $ */ /* $NetBSD: misc.c,v 1.3 1994/12/07 05:08:09 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/9/93"; #endif -static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1997/07/25 21:05:45 mickey Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.4 1997/07/25 22:13:24 mickey Exp $"; #endif /* not lint */ #include <fcntl.h> @@ -47,6 +47,7 @@ static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1997/07/25 21:05:45 mickey Exp $"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <err.h> #include "extern.h" void @@ -57,13 +58,13 @@ cat(file) char buf[1024]; if ((fd = open(file, O_RDONLY, 0)) < 0) - err("%s: %s", file, strerror(errno)); + err(1, 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, file); (void)close(fd); } @@ -73,32 +74,3 @@ outc(c) { (void)putc(c, stderr); } - -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -void -#ifdef __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#ifdef __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/term.c b/usr.bin/tset/term.c index e1c0f0bf2da..c824a66c371 100644 --- a/usr.bin/tset/term.c +++ b/usr.bin/tset/term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: term.c,v 1.3 1997/01/17 07:13:44 millert Exp $ */ +/* $OpenBSD: term.c,v 1.4 1997/07/25 22:13:24 mickey Exp $ */ /* $NetBSD: term.c,v 1.6 1994/12/07 05:08:12 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.1 (Berkeley) 6/9/93"; #endif -static char rcsid[] = "$OpenBSD: term.c,v 1.3 1997/01/17 07:13:44 millert Exp $"; +static char rcsid[] = "$OpenBSD: term.c,v 1.4 1997/07/25 22:13:24 mickey Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -48,6 +48,7 @@ static char rcsid[] = "$OpenBSD: term.c,v 1.3 1997/01/17 07:13:44 millert Exp $" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <err.h> #include "extern.h" char tbuf[1024]; /* Termcap entry. */ @@ -113,12 +114,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)); + warnx("termcap: %s", strerror(errno ? errno : ENOENT)); *tcapbufp = tbuf; return (ttype); } @@ -132,10 +132,8 @@ askuser(dflt) char *p; /* We can get recalled; if so, don't continue uselessly. */ - if (feof(stdin) || ferror(stdin)) { - (void)fprintf(stderr, "\n"); + if (feof(stdin) || ferror(stdin)) exit(1); - } for (;;) { if (dflt) (void)fprintf(stderr, "Terminal type? [%s] ", dflt); diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c index 5e51908b1a9..9a236b83b22 100644 --- a/usr.bin/tset/tset.c +++ b/usr.bin/tset/tset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tset.c,v 1.3 1997/01/15 23:43:25 millert Exp $ */ +/* $OpenBSD: tset.c,v 1.4 1997/07/25 22:13:25 mickey Exp $ */ /* $NetBSD: tset.c,v 1.4 1994/12/07 05:08:15 jtc Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)tset.c 8.1 (Berkeley) 6/9/93"; #endif -static char rcsid[] = "$OpenBSD: tset.c,v 1.3 1997/01/15 23:43:25 millert Exp $"; +static char rcsid[] = "$OpenBSD: tset.c,v 1.4 1997/07/25 22:13:25 mickey Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -56,6 +56,7 @@ static char rcsid[] = "$OpenBSD: tset.c,v 1.3 1997/01/15 23:43:25 millert Exp $" #include <stdio.h> #include <ctype.h> #include <string.h> +#include <err.h> #include "extern.h" void obsolete __P((char *[])); @@ -82,7 +83,7 @@ main(argc, argv) char savech, *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); @@ -194,7 +195,7 @@ main(argc, argv) savech = *p; *p = '\0'; if ((ttype = strdup(t)) == NULL) - err("%s", strerror(errno)); + err(1, "strdup"); *p = savech; } } |