diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-07-25 21:14:05 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-07-25 21:14:05 +0000 |
commit | c9b10147fab970e61792d79502cd626bc097af01 (patch) | |
tree | 7e11c62c5fefd3bfe583c5fc8424e2469458ffa5 | |
parent | dac2e5bb3990fd05a5027fc01a8f9c0b59895523 (diff) |
use err(3)
-rw-r--r-- | usr.bin/tr/extern.h | 3 | ||||
-rw-r--r-- | usr.bin/tr/str.c | 21 | ||||
-rw-r--r-- | usr.bin/tr/tr.c | 36 |
3 files changed, 17 insertions, 43 deletions
diff --git a/usr.bin/tr/extern.h b/usr.bin/tr/extern.h index a4768226b53..fe97a8db28a 100644 --- a/usr.bin/tr/extern.h +++ b/usr.bin/tr/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.3 1996/06/26 05:41:49 deraadt Exp $ */ +/* $OpenBSD: extern.h,v 1.4 1997/07/25 21:14:03 mickey Exp $ */ /* $NetBSD: extern.h,v 1.4 1995/11/01 00:45:22 pk Exp $ */ /*- @@ -50,5 +50,4 @@ typedef struct { #define NCHARS (UCHAR_MAX + 1) /* Number of possible characters. */ #define OOBCH (UCHAR_MAX + 1) /* Out of band character value. */ -void err __P((const char *fmt, ...)); int next __P((STR *)); diff --git a/usr.bin/tr/str.c b/usr.bin/tr/str.c index a4121f0ad3a..f7aa9462880 100644 --- a/usr.bin/tr/str.c +++ b/usr.bin/tr/str.c @@ -1,4 +1,4 @@ -/* $OpenBSD: str.c,v 1.3 1997/01/17 07:13:40 millert Exp $ */ +/* $OpenBSD: str.c,v 1.4 1997/07/25 21:14:04 mickey Exp $ */ /* $NetBSD: str.c,v 1.7 1995/08/31 22:13:47 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)str.c 8.2 (Berkeley) 4/28/95"; #endif -static char rcsid[] = "$OpenBSD: str.c,v 1.3 1997/01/17 07:13:40 millert Exp $"; +static char rcsid[] = "$OpenBSD: str.c,v 1.4 1997/07/25 21:14:04 mickey Exp $"; #endif /* not lint */ #include <sys/cdefs.h> @@ -50,6 +50,7 @@ static char rcsid[] = "$OpenBSD: str.c,v 1.3 1997/01/17 07:13:40 millert Exp $"; #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <err.h> #include "extern.h" @@ -113,6 +114,8 @@ next(s) return (next(s)); } return (1); + default: + return 0; } /* NOTREACHED */ } @@ -182,10 +185,10 @@ genclass(s) tmp.name = s->str; if ((cp = (CLASS *)bsearch(&tmp, classes, sizeof(classes) / sizeof(CLASS), sizeof(CLASS), c_class)) == NULL) - err("unknown class %s", s->str); + errx(1, "unknown class %s", s->str); if ((cp->set = p = malloc((NCHARS + 1) * sizeof(int))) == NULL) - err("%s", strerror(errno)); + errx(1, "no memory for a class"); bzero(p, (NCHARS + 1) * sizeof(int)); for (cnt = 0, func = cp->func; cnt < NCHARS; ++cnt) if ((func)(cnt)) @@ -215,11 +218,11 @@ genequiv(s) if (*s->str == '\\') { s->equiv[0] = backslash(s); if (*s->str != '=') - err("misplaced equivalence equals sign"); + errx(1, "misplaced equivalence equals sign"); } else { s->equiv[0] = s->str[0]; if (s->str[1] != '=') - err("misplaced equivalence equals sign"); + errx(1, "misplaced equivalence equals sign"); } s->str += 2; s->cnt = 0; @@ -253,14 +256,14 @@ genseq(s) char *ep; if (s->which == STRING1) - err("sequences only valid in string2"); + errx(1, "sequences only valid in string2"); if (*s->str == '\\') s->lastch = backslash(s); else s->lastch = *s->str++; if (*s->str != '*') - err("misplaced sequence asterisk"); + errx(1, "misplaced sequence asterisk"); switch (*++s->str) { case '\\': @@ -278,7 +281,7 @@ genseq(s) break; } } - err("illegal sequence count"); + errx(1, "illegal sequence count"); /* NOTREACHED */ } diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c index 12e5cca1426..bfa7d1e1a79 100644 --- a/usr.bin/tr/tr.c +++ b/usr.bin/tr/tr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tr.c,v 1.4 1997/07/25 21:05:45 mickey Exp $ */ +/* $OpenBSD: tr.c,v 1.5 1997/07/25 21:14:04 mickey Exp $ */ /* $NetBSD: tr.c,v 1.5 1995/08/31 22:13:48 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95"; #endif -static char rcsid[] = "$OpenBSD: tr.c,v 1.4 1997/07/25 21:05:45 mickey Exp $"; +static char rcsid[] = "$OpenBSD: tr.c,v 1.5 1997/07/25 21:14:04 mickey Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -53,6 +53,7 @@ static char rcsid[] = "$OpenBSD: tr.c,v 1.4 1997/07/25 21:05:45 mickey Exp $"; #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <err.h> #include "extern.h" @@ -205,7 +206,7 @@ main(argc, argv) *p++ = OOBCH; if (!next(&s2)) - err("empty string2"); + errx(1, "empty string2"); /* If string2 runs out of characters, use the last one specified. */ if (sflag) @@ -265,32 +266,3 @@ usage() (void)fprintf(stderr, " tr [-c] -ds string1 string2\n"); exit(1); } - -#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, "tr: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} |