diff options
author | charnier <charnier@FreeBSD.org> | 1997-08-18 07:24:58 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-08-18 07:24:58 +0000 |
commit | 6473d1562f92e0491dd572238d97e2811c586902 (patch) | |
tree | d1aa4fdc529f3bf10dffd9f5ce13a5fa4e98bcd7 /usr.bin/tr | |
parent | 5e2454839f69da6c26bdd8d1e8d3dd721ffedb0d (diff) | |
download | FreeBSD-src-6473d1562f92e0491dd572238d97e2811c586902.zip FreeBSD-src-6473d1562f92e0491dd572238d97e2811c586902.tar.gz |
Use err(3) instead of local redefinition. Cosmetic in usage().
Diffstat (limited to 'usr.bin/tr')
-rw-r--r-- | usr.bin/tr/extern.h | 1 | ||||
-rw-r--r-- | usr.bin/tr/str.c | 22 | ||||
-rw-r--r-- | usr.bin/tr/tr.1 | 10 | ||||
-rw-r--r-- | usr.bin/tr/tr.c | 47 |
4 files changed, 30 insertions, 50 deletions
diff --git a/usr.bin/tr/extern.h b/usr.bin/tr/extern.h index 9e82d06..fbd71fa 100644 --- a/usr.bin/tr/extern.h +++ b/usr.bin/tr/extern.h @@ -47,5 +47,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 7c0fd7c..55ad1bd 100644 --- a/usr.bin/tr/str.c +++ b/usr.bin/tr/str.c @@ -32,18 +32,22 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)str.c 8.2 (Berkeley) 4/28/95"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/cdefs.h> #include <sys/types.h> -#include <errno.h> +#include <ctype.h> +#include <err.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> #include "extern.h" @@ -188,10 +192,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, "malloc"); bzero(p, (NCHARS + 1) * sizeof(int)); for (cnt = 0, func = cp->func; cnt < NCHARS; ++cnt) if ((func)(cnt)) @@ -221,11 +225,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; @@ -259,14 +263,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 '\\': @@ -284,7 +288,7 @@ genseq(s) break; } } - err("illegal sequence count"); + errx(1, "illegal sequence count"); /* NOTREACHED */ } diff --git a/usr.bin/tr/tr.1 b/usr.bin/tr/tr.1 index 5170463..7779073 100644 --- a/usr.bin/tr/tr.1 +++ b/usr.bin/tr/tr.1 @@ -58,7 +58,7 @@ .Ar string1 string2 .Sh DESCRIPTION The -.Nm tr +.Nm utility copies the standard input to the standard output with substitution or deletion of selected characters. .Pp @@ -225,7 +225,7 @@ it's interpreted as a decimal value. .El .Pp The -.Nm tr +.Nm utility exits 0 on success, and >0 if an error occurs. .Sh EXAMPLES The following examples are shown as given to the shell: @@ -261,13 +261,13 @@ represent the three characters ``a'', ``-'' and ``z'' will have to be rewritten as ``a\e-z''. .Pp The -.Nm tr +.Nm utility has historically not permitted the manipulation of NUL bytes in its input and, additionally, stripped NUL's from its input stream. This implementation has removed this behavior as a bug. .Pp The -.Nm tr +.Nm utility has historically been extremely forgiving of syntax errors, for example, the .Fl c @@ -277,7 +277,7 @@ options were ignored unless two strings were specified. This implementation will not permit illegal syntax. .Sh STANDARDS The -.Nm tr +.Nm utility is expected to be .St -p1003.2 compatible. diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c index 50b9d7c..fd17637 100644 --- a/usr.bin/tr/tr.c +++ b/usr.bin/tr/tr.c @@ -32,18 +32,23 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1988, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <locale.h> #include <sys/types.h> +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -202,7 +207,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) @@ -256,38 +261,10 @@ setup(string, arg, str, cflag) static void usage() { - (void)fprintf(stderr, "usage: tr [-cs] string1 string2\n"); - (void)fprintf(stderr, " tr [-c] -d string1\n"); - (void)fprintf(stderr, " tr [-c] -s string1\n"); - (void)fprintf(stderr, " tr [-c] -ds string1 string2\n"); - exit(1); -} - -#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, "tr: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); + (void)fprintf(stderr, "%s\n%s\n%s\n%s\n", + "usage: tr [-cs] string1 string2", + " tr [-c] -d string1", + " tr [-c] -s string1", + " tr [-c] -ds string1 string2"); exit(1); - /* NOTREACHED */ } |