diff options
author | charnier <charnier@FreeBSD.org> | 1997-06-30 06:48:46 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-06-30 06:48:46 +0000 |
commit | 136480890da36aea64796e7d6ba40d1d694eaaed (patch) | |
tree | 2e10583a8c593a630d7a41b95c8f733409a9eb39 /usr.bin/cut | |
parent | c33fef67f8f1278a9e79f603058af5ea44800b4f (diff) | |
download | FreeBSD-src-136480890da36aea64796e7d6ba40d1d694eaaed.zip FreeBSD-src-136480890da36aea64796e7d6ba40d1d694eaaed.tar.gz |
Use err(3) instead of local redefinition. Change argument name in man
page to sync with usage string.
Diffstat (limited to 'usr.bin/cut')
-rw-r--r-- | usr.bin/cut/cut.1 | 6 | ||||
-rw-r--r-- | usr.bin/cut/cut.c | 50 |
2 files changed, 14 insertions, 42 deletions
diff --git a/usr.bin/cut/cut.1 b/usr.bin/cut/cut.1 index 97c5645..3ba43ed 100644 --- a/usr.bin/cut/cut.1 +++ b/usr.bin/cut/cut.1 @@ -46,7 +46,7 @@ .Ar .Nm cut .Fl f Ar list -.Op Fl d Ar string +.Op Fl d Ar delim .Op Fl s .Ar .Sh DESCRIPTION @@ -85,9 +85,9 @@ The options are as follows: The .Ar list specifies character positions. -.It Fl d Ar string +.It Fl d Ar delim Use the first character of -.Ar string +.Ar delim as the field delimiter character instead of the tab character. .It Fl f Ar list The diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c index 8d58b8f..cc57685 100644 --- a/usr.bin/cut/cut.c +++ b/usr.bin/cut/cut.c @@ -45,6 +45,7 @@ static char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95"; #endif /* not lint */ #include <ctype.h> +#include <err.h> #include <errno.h> #include <limits.h> #include <stdio.h> @@ -59,10 +60,9 @@ int fflag; int sflag; void c_cut __P((FILE *, char *)); -void err __P((const char *, ...)); void f_cut __P((FILE *, char *)); void get_list __P((char *)); -void usage __P((void)); +static void usage __P((void)); int main(argc, argv) @@ -110,7 +110,7 @@ main(argc, argv) if (*argv) for (; *argv; ++argv) { if (!(fp = fopen(*argv, "r"))) - err("%s: %s\n", *argv, strerror(errno)); + err(1, "%s", *argv); fcn(fp, *argv); (void)fclose(fp); } @@ -160,11 +160,11 @@ get_list(list) } } if (*p) - err("[-cf] list: illegal list value\n"); + errx(1, "[-cf] list: illegal list value"); if (!stop || !start) - err("[-cf] list: values may not include zero\n"); + errx(1, "[-cf] list: values may not include zero"); if (stop > _POSIX2_LINE_MAX) - err("[-cf] list: %d too large (max %d)\n", + errx(1, "[-cf] list: %d too large (max %d)", stop, _POSIX2_LINE_MAX); if (maxval < stop) maxval = stop; @@ -223,7 +223,7 @@ f_cut(fp, fname) output = 0; for (isdelim = 0, p = lbuf;; ++p) { if (!(ch = *p)) - err("%s: line too long.\n", fname); + errx(1, "%s: line too long", fname); /* this should work if newline is delimiter */ if (ch == sep) isdelim = 1; @@ -260,39 +260,11 @@ f_cut(fp, fname) } } -void +static void usage() { - (void)fprintf(stderr, -"usage:\tcut -c list [file1 ...]\n\tcut -f list [-s] [-d delim] [file ...]\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, "cut: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); + (void)fprintf(stderr, "%s\n%s\n", + "usage: cut -c list [file1 ...]", + " cut -f list [-s] [-d delim] [file ...]"); exit(1); - /* NOTREACHED */ } |