summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-02-16 19:48:22 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-02-16 19:48:22 +0000
commit5c0721459e11dce47bbb72f53b93b1dd182c025f (patch)
treef382051d0f85f080496808614f9fb79bccb58236
parent3f2dad64aa7b17535fbbe86ef6791e09b1c3ce35 (diff)
make -b and -c work with large offsets; tweak from millert@
ok henning@ itojun@ millert@
-rw-r--r--usr.bin/tail/extern.h6
-rw-r--r--usr.bin/tail/forward.c16
-rw-r--r--usr.bin/tail/reverse.c10
-rw-r--r--usr.bin/tail/tail.c8
4 files changed, 20 insertions, 20 deletions
diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h
index 5397118d37d..5ab91243f51 100644
--- a/usr.bin/tail/extern.h
+++ b/usr.bin/tail/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.8 2003/06/03 02:56:17 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.9 2004/02/16 19:48:21 otto Exp $ */
/* $NetBSD: extern.h,v 1.3 1994/11/23 07:42:00 jtc Exp $ */
/*-
@@ -38,8 +38,8 @@
enum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE };
-void forward(FILE *, enum STYLE, long, struct stat *);
-void reverse(FILE *, enum STYLE, long, struct stat *);
+void forward(FILE *, enum STYLE, off_t, struct stat *);
+void reverse(FILE *, enum STYLE, off_t, struct stat *);
int bytes(FILE *, off_t);
int lines(FILE *, off_t);
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c
index 1a1f332476e..164f68efa98 100644
--- a/usr.bin/tail/forward.c
+++ b/usr.bin/tail/forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: forward.c,v 1.17 2003/07/14 08:06:06 otto Exp $ */
+/* $OpenBSD: forward.c,v 1.18 2004/02/16 19:48:21 otto Exp $ */
/* $NetBSD: forward.c,v 1.7 1996/02/13 16:49:10 ghudson Exp $ */
/*-
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: forward.c,v 1.17 2003/07/14 08:06:06 otto Exp $";
+static char rcsid[] = "$OpenBSD: forward.c,v 1.18 2004/02/16 19:48:21 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -56,7 +56,7 @@ static char rcsid[] = "$OpenBSD: forward.c,v 1.17 2003/07/14 08:06:06 otto Exp $
#include "extern.h"
-static int rlines(FILE *, long, struct stat *);
+static int rlines(FILE *, off_t, struct stat *);
/*
* forward -- display the file, from an offset, forward.
@@ -84,7 +84,7 @@ void
forward(fp, style, off, sbp)
FILE *fp;
enum STYLE style;
- long off;
+ off_t off;
struct stat *sbp;
{
int ch;
@@ -99,7 +99,7 @@ forward(fp, style, off, sbp)
if (S_ISREG(sbp->st_mode)) {
if (sbp->st_size < off)
off = sbp->st_size;
- if (fseek(fp, off, SEEK_SET) == -1) {
+ if (fseeko(fp, off, SEEK_SET) == -1) {
ierr();
return;
}
@@ -130,7 +130,7 @@ forward(fp, style, off, sbp)
case RBYTES:
if (S_ISREG(sbp->st_mode)) {
if (sbp->st_size >= off &&
- fseek(fp, -off, SEEK_END) == -1) {
+ fseeko(fp, -off, SEEK_END) == -1) {
ierr();
return;
}
@@ -149,7 +149,7 @@ forward(fp, style, off, sbp)
case RLINES:
if (S_ISREG(sbp->st_mode)) {
if (!off) {
- if (fseek(fp, 0L, SEEK_END) == -1) {
+ if (fseeko(fp, (off_t)0, SEEK_END) == -1) {
ierr();
return;
}
@@ -249,7 +249,7 @@ kq_retry:
* rlines -- display the last offset lines of the file.
*/
static int
-rlines(FILE *fp, long off, struct stat *sbp)
+rlines(FILE *fp, off_t off, struct stat *sbp)
{
off_t pos;
int ch;
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 3bf04c6cc3d..011126a0d18 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: reverse.c,v 1.14 2003/07/01 11:12:59 henning Exp $ */
+/* $OpenBSD: reverse.c,v 1.15 2004/02/16 19:48:21 otto Exp $ */
/* $NetBSD: reverse.c,v 1.6 1994/11/23 07:42:10 jtc Exp $ */
/*-
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)reverse.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: reverse.c,v 1.14 2003/07/01 11:12:59 henning Exp $";
+static char rcsid[] = "$OpenBSD: reverse.c,v 1.15 2004/02/16 19:48:21 otto Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -55,7 +55,7 @@ static char rcsid[] = "$OpenBSD: reverse.c,v 1.14 2003/07/01 11:12:59 henning Ex
#include "extern.h"
static void r_buf(FILE *);
-static int r_reg(FILE *, enum STYLE, long, struct stat *);
+static int r_reg(FILE *, enum STYLE, off_t, struct stat *);
#define COPYCHAR(fp, ch) \
do { \
@@ -91,7 +91,7 @@ void
reverse(fp, style, off, sbp)
FILE *fp;
enum STYLE style;
- long off;
+ off_t off;
struct stat *sbp;
{
if (style != REVERSE && off == 0)
@@ -117,7 +117,7 @@ reverse(fp, style, off, sbp)
* r_reg -- display a regular file in reverse order by line.
*/
static int
-r_reg(FILE *fp, enum STYLE style, long off, struct stat *sbp)
+r_reg(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
{
off_t start, pos, end;
int ch;
diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c
index 333eddcf7a2..dd4fef2cdde 100644
--- a/usr.bin/tail/tail.c
+++ b/usr.bin/tail/tail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tail.c,v 1.11 2003/06/10 22:20:52 deraadt Exp $ */
+/* $OpenBSD: tail.c,v 1.12 2004/02/16 19:48:21 otto Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: tail.c,v 1.11 2003/06/10 22:20:52 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: tail.c,v 1.12 2004/02/16 19:48:21 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -69,7 +69,7 @@ main(int argc, char *argv[])
{
struct stat sb;
FILE *fp;
- long off = 0;
+ off_t off = 0;
enum STYLE style;
int ch, first;
char *p;
@@ -89,7 +89,7 @@ main(int argc, char *argv[])
#define ARG(units, forward, backward) { \
if (style) \
usage(); \
- off = strtol(optarg, &p, 10) * (units); \
+ off = strtoll(optarg, &p, 10) * (units); \
if (*p) \
errx(1, "illegal offset -- %s", optarg); \
switch(optarg[0]) { \