summaryrefslogtreecommitdiffstats
path: root/usr.bin/tail
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-08-25 21:12:01 +0000
committerpeter <peter@FreeBSD.org>1996-08-25 21:12:01 +0000
commita5eafc88c57bd29b20f08b371c61fcf2b5df93a6 (patch)
treec9475df4865da030976237416491e0d5ad8f720f /usr.bin/tail
parent86926bee8cab2cfd47a24f582269eef739f4a2ff (diff)
downloadFreeBSD-src-a5eafc88c57bd29b20f08b371c61fcf2b5df93a6.zip
FreeBSD-src-a5eafc88c57bd29b20f08b371c61fcf2b5df93a6.tar.gz
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.
Diffstat (limited to 'usr.bin/tail')
-rw-r--r--usr.bin/tail/extern.h1
-rw-r--r--usr.bin/tail/misc.c35
-rw-r--r--usr.bin/tail/read.c8
-rw-r--r--usr.bin/tail/reverse.c9
-rw-r--r--usr.bin/tail/tail.c8
5 files changed, 15 insertions, 46 deletions
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 <stdarg.h>
-#else
-#include <varargs.h>
-#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);
OpenPOWER on IntegriCloud