From a5eafc88c57bd29b20f08b371c61fcf2b5df93a6 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 25 Aug 1996 21:12:01 +0000 Subject: Argh! caught! *blush*.. This program was supplying it's own 'err' routine which was slightly different to the libc one. To save any more cunfusion, use the libc one. --- usr.bin/tail/extern.h | 1 - usr.bin/tail/misc.c | 35 ++--------------------------------- usr.bin/tail/read.c | 8 ++++---- usr.bin/tail/reverse.c | 9 +++++---- usr.bin/tail/tail.c | 8 ++++---- 5 files changed, 15 insertions(+), 46 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h index f1daa9b..f9a8bdf 100644 --- a/usr.bin/tail/extern.h +++ b/usr.bin/tail/extern.h @@ -45,7 +45,6 @@ void reverse __P((FILE *, enum STYLE, long, struct stat *)); int bytes __P((FILE *, off_t)); int lines __P((FILE *, off_t)); -void err __P((int fatal, const char *fmt, ...)); void ierr __P((void)); void oerr __P((void)); diff --git a/usr.bin/tail/misc.c b/usr.bin/tail/misc.c index 18fd63d..fb38d76 100644 --- a/usr.bin/tail/misc.c +++ b/usr.bin/tail/misc.c @@ -50,42 +50,11 @@ static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93"; void ierr() { - err(0, "%s: %s", fname, strerror(errno)); + err(0, "%s", fname); } void oerr() { - err(1, "stdout: %s", strerror(errno)); -} - -#if __STDC__ -#include -#else -#include -#endif - -void -#if __STDC__ -err(int fatal, const char *fmt, ...) -#else -err(fatal, fmt, va_alist) - int fatal; - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "tail: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - if (fatal) - exit(1); - rval = 1; + err(1, "stdout"); } diff --git a/usr.bin/tail/read.c b/usr.bin/tail/read.c index 2b60918..1871c51 100644 --- a/usr.bin/tail/read.c +++ b/usr.bin/tail/read.c @@ -69,7 +69,7 @@ bytes(fp, off) char *sp; if ((sp = p = malloc(off)) == NULL) - err(1, "%s", strerror(errno)); + err(1, "malloc"); for (wrap = 0, ep = p + off; (ch = getc(fp)) != EOF;) { *p = ch; @@ -142,7 +142,7 @@ lines(fp, off) char *sp; if ((lines = malloc(off * sizeof(*lines))) == NULL) - err(1, "%s", strerror(errno)); + err(1, "malloc"); bzero(lines, off * sizeof(*lines)); sp = NULL; blen = cnt = recno = wrap = 0; @@ -150,7 +150,7 @@ lines(fp, off) while ((ch = getc(fp)) != EOF) { if (++cnt > blen) { if ((sp = realloc(sp, blen += 1024)) == NULL) - err(1, "%s", strerror(errno)); + err(1, "realloc"); p = sp + cnt - 1; } *p++ = ch; @@ -159,7 +159,7 @@ lines(fp, off) lines[recno].blen = cnt + 256; if ((lines[recno].l = realloc(lines[recno].l, lines[recno].blen)) == NULL) - err(1, "%s", strerror(errno)); + err(1, "realloc"); } bcopy(sp, lines[recno].l, lines[recno].len = cnt); cnt = 0; diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c index 4557064..248cb69 100644 --- a/usr.bin/tail/reverse.c +++ b/usr.bin/tail/reverse.c @@ -118,13 +118,14 @@ r_reg(fp, style, off, sbp) return; if (size > SIZE_T_MAX) { - err(0, "%s: %s", fname, strerror(EFBIG)); + errno = EFBIG; + err(0, "%s", fname); return; } if ((start = mmap(NULL, (size_t)size, PROT_READ, 0, fileno(fp), (off_t)0)) == (caddr_t)-1) { - err(0, "%s: %s", fname, strerror(EFBIG)); + err(0, "%s", fname); return; } p = start + size - 1; @@ -145,7 +146,7 @@ r_reg(fp, style, off, sbp) if (llen) WR(p, llen); if (munmap(start, (size_t)sbp->st_size)) - err(0, "%s: %s", fname, strerror(errno)); + err(0, "%s", fname); } typedef struct bf { @@ -184,7 +185,7 @@ r_buf(fp) if (enomem || (tl = malloc(sizeof(BF))) == NULL || (tl->l = malloc(BSZ)) == NULL) { if (!mark) - err(1, "%s", strerror(errno)); + err(1, "malloc"); tl = enomem ? tl->next : mark; enomem += tl->len; } else if (mark) { diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c index cc8ea14..e800590 100644 --- a/usr.bin/tail/tail.c +++ b/usr.bin/tail/tail.c @@ -88,7 +88,7 @@ main(argc, argv) usage(); \ off = strtol(optarg, &p, 10) * (units); \ if (*p) \ - err(1, "illegal offset -- %s", optarg); \ + errx(1, "illegal offset -- %s", optarg); \ switch(optarg[0]) { \ case '+': \ if (off) \ @@ -131,7 +131,7 @@ main(argc, argv) argv += optind; if (fflag && argc > 1) - err(1, "-f option only appropriate for a single file"); + errx(1, "-f option only appropriate for a single file"); /* * If displaying in reverse, don't permit follow option, and convert @@ -234,7 +234,7 @@ obsolete(argv) /* Malloc space for dash, new option and argument. */ len = strlen(*argv); if ((start = p = malloc(len + 3)) == NULL) - err(1, "%s", strerror(errno)); + err(1, "malloc"); *p++ = '-'; /* @@ -264,7 +264,7 @@ obsolete(argv) *p++ = 'n'; break; default: - err(1, "illegal option -- %s", *argv); + errx(1, "illegal option -- %s", *argv); } *p++ = *argv[0]; (void)strcpy(p, ap); -- cgit v1.1