summaryrefslogtreecommitdiff
path: root/usr.bin/tail
diff options
context:
space:
mode:
authorEric Jackson <ericj@cvs.openbsd.org>2000-06-23 17:04:47 +0000
committerEric Jackson <ericj@cvs.openbsd.org>2000-06-23 17:04:47 +0000
commit605da317f368bae6e6c80b626f0a28cdfeadd624 (patch)
treeb8e0c578a60ea591c5c7dbc27159ddee7f918959 /usr.bin/tail
parenta37dbcd2ced8b343e4563bd46353a3c4b4e548db (diff)
Get rid of repeating error messages; From netbsd millert@ ok
Diffstat (limited to 'usr.bin/tail')
-rw-r--r--usr.bin/tail/extern.h6
-rw-r--r--usr.bin/tail/forward.c16
-rw-r--r--usr.bin/tail/read.c20
-rw-r--r--usr.bin/tail/reverse.c8
4 files changed, 31 insertions, 19 deletions
diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h
index a87460ac699..983ca7f3deb 100644
--- a/usr.bin/tail/extern.h
+++ b/usr.bin/tail/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.4 1999/02/03 02:09:30 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.5 2000/06/23 17:04:46 ericj Exp $ */
/* $NetBSD: extern.h,v 1.3 1994/11/23 07:42:00 jtc Exp $ */
/*-
@@ -45,8 +45,8 @@ enum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE };
void forward __P((FILE *, enum STYLE, long, struct stat *));
void reverse __P((FILE *, enum STYLE, long, struct stat *));
-void bytes __P((FILE *, off_t));
-void lines __P((FILE *, off_t));
+int bytes __P((FILE *, off_t));
+int lines __P((FILE *, off_t));
void ierr __P((void));
void oerr __P((void));
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c
index d23f6dfe4d0..df24b4d9363 100644
--- a/usr.bin/tail/forward.c
+++ b/usr.bin/tail/forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: forward.c,v 1.8 1999/08/04 18:24:10 mickey Exp $ */
+/* $OpenBSD: forward.c,v 1.9 2000/06/23 17:04:46 ericj Exp $ */
/* $NetBSD: forward.c,v 1.7 1996/02/13 16:49:10 ghudson Exp $ */
/*-
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: forward.c,v 1.8 1999/08/04 18:24:10 mickey Exp $";
+static char rcsid[] = "$OpenBSD: forward.c,v 1.9 2000/06/23 17:04:46 ericj Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -142,8 +142,10 @@ forward(fp, style, off, sbp)
ierr();
return;
}
- } else
- bytes(fp, off);
+ } else {
+ if (bytes(fp, off))
+ return;
+ }
break;
case RLINES:
if (S_ISREG(sbp->st_mode)) {
@@ -161,8 +163,10 @@ forward(fp, style, off, sbp)
ierr();
return;
}
- } else
- lines(fp, off);
+ } else {
+ if (lines(fp, off))
+ return;
+ }
break;
}
diff --git a/usr.bin/tail/read.c b/usr.bin/tail/read.c
index f84bd9d24f9..728d9bd498d 100644
--- a/usr.bin/tail/read.c
+++ b/usr.bin/tail/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.3 1997/01/12 23:43:06 millert Exp $ */
+/* $OpenBSD: read.c,v 1.4 2000/06/23 17:04:46 ericj Exp $ */
/* $NetBSD: read.c,v 1.4 1994/11/23 07:42:07 jtc Exp $ */
/*-
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: read.c,v 1.3 1997/01/12 23:43:06 millert Exp $";
+static char rcsid[] = "$OpenBSD: read.c,v 1.4 2000/06/23 17:04:46 ericj Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -66,8 +66,11 @@ static char rcsid[] = "$OpenBSD: read.c,v 1.3 1997/01/12 23:43:06 millert Exp $"
* routine has the usual nastiness of trying to find the newlines. Otherwise,
* it is displayed from the character closest to the beginning of the input to
* the end.
+ *
+ * A non-zero return means an (non-fatal) error occured.
+ *
*/
-void
+int
bytes(fp, off)
register FILE *fp;
off_t off;
@@ -89,7 +92,7 @@ bytes(fp, off)
}
if (ferror(fp)) {
ierr();
- return;
+ return(1);
}
if (rflag) {
@@ -122,6 +125,7 @@ bytes(fp, off)
if ((len = p - sp))
WR(sp, len);
}
+ return(0);
}
/*
@@ -133,8 +137,11 @@ bytes(fp, off)
* routine has the usual nastiness of trying to find the newlines. Otherwise,
* it is displayed from the line closest to the beginning of the input to
* the end.
+ *
+ * A non-zero return means an (non-fatal) error occured.
+ *
*/
-void
+int
lines(fp, off)
register FILE *fp;
off_t off;
@@ -179,7 +186,7 @@ lines(fp, off)
}
if (ferror(fp)) {
ierr();
- return;
+ return(1);
}
if (cnt) {
lines[recno].l = sp;
@@ -203,4 +210,5 @@ lines(fp, off)
for (cnt = 0; cnt < recno; ++cnt)
WR(lines[cnt].l, lines[cnt].len);
}
+ return(0);
}
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 927dfb1db95..d21527986e3 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: reverse.c,v 1.6 1999/08/04 18:24:10 mickey Exp $ */
+/* $OpenBSD: reverse.c,v 1.7 2000/06/23 17:04:46 ericj Exp $ */
/* $NetBSD: reverse.c,v 1.6 1994/11/23 07:42:10 jtc Exp $ */
/*-
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)reverse.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: reverse.c,v 1.6 1999/08/04 18:24:10 mickey Exp $";
+static char rcsid[] = "$OpenBSD: reverse.c,v 1.7 2000/06/23 17:04:46 ericj Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -93,11 +93,11 @@ reverse(fp, style, off, sbp)
switch(style) {
case FBYTES:
case RBYTES:
- bytes(fp, off);
+ (void)bytes(fp, off);
break;
case FLINES:
case RLINES:
- lines(fp, off);
+ (void)lines(fp, off);
break;
case REVERSE:
r_buf(fp);