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.
This commit is contained in:
parent
7dda791089
commit
ac5512704d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17825
@ -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));
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user