summaryrefslogtreecommitdiffstats
path: root/usr.bin/tail
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-09-01 22:22:45 +0000
committerache <ache@FreeBSD.org>2001-09-01 22:22:45 +0000
commit46ab006323dc2c9a57c5b7399582ccbdb38ec5fa (patch)
tree76b6a36fea6e5f73587204b78bcc976c69d43fc9 /usr.bin/tail
parentfe9bd7a606374fc6ee1ad21490835b815db1e078 (diff)
downloadFreeBSD-src-46ab006323dc2c9a57c5b7399582ccbdb38ec5fa.zip
FreeBSD-src-46ab006323dc2c9a57c5b7399582ccbdb38ec5fa.tar.gz
File positions are off_t nowdays, not long, so:
long -> off_t strtol -> strtoll fseek -> fseeko NOTE: that fseek not works for >long offsets files per POSIX: [EOVERFLOW] For fseek( ), the resulting file offset would be a value which cannot be represented correctly in an object of type long.
Diffstat (limited to 'usr.bin/tail')
-rw-r--r--usr.bin/tail/extern.h4
-rw-r--r--usr.bin/tail/forward.c14
-rw-r--r--usr.bin/tail/reverse.c6
-rw-r--r--usr.bin/tail/tail.c4
4 files changed, 14 insertions, 14 deletions
diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h
index cdf6929..8c549a9 100644
--- a/usr.bin/tail/extern.h
+++ b/usr.bin/tail/extern.h
@@ -52,8 +52,8 @@ struct mapinfo {
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 forward __P((FILE *, enum STYLE, off_t, struct stat *));
+void reverse __P((FILE *, enum STYLE, off_t, struct stat *));
int bytes __P((FILE *, off_t));
int lines __P((FILE *, off_t));
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c
index cd1980f..ceacc04 100644
--- a/usr.bin/tail/forward.c
+++ b/usr.bin/tail/forward.c
@@ -58,7 +58,7 @@ static const char rcsid[] =
#include <err.h>
#include "extern.h"
-static void rlines __P((FILE *, long, struct stat *));
+static void rlines __P((FILE *, off_t, struct stat *));
/* defines for inner loop actions */
#define USE_SLEEP 0
@@ -91,7 +91,7 @@ void
forward(fp, style, off, sbp)
FILE *fp;
enum STYLE style;
- long off;
+ off_t off;
struct stat *sbp;
{
int ch, kq = -1;
@@ -106,7 +106,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;
}
@@ -137,7 +137,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;
}
@@ -154,7 +154,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;
}
@@ -226,7 +226,7 @@ forward(fp, style, off, sbp)
action = USE_SLEEP;
} else if (ev->data < 0) {
/* file shrank, reposition to end */
- if (fseek(fp, 0L, SEEK_END) == -1) {
+ if (fseeko(fp, (off_t)0, SEEK_END) == -1) {
ierr();
return;
}
@@ -266,7 +266,7 @@ forward(fp, style, off, sbp)
static void
rlines(fp, off, sbp)
FILE *fp;
- long off;
+ off_t off;
struct stat *sbp;
{
struct mapinfo map;
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 24468dd..83d21d9 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -56,7 +56,7 @@ static const char rcsid[] =
#include "extern.h"
static void r_buf __P((FILE *));
-static void r_reg __P((FILE *, enum STYLE, long, struct stat *));
+static void r_reg __P((FILE *, enum STYLE, off_t, struct stat *));
/*
* reverse -- display input in reverse order by line.
@@ -80,7 +80,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)
@@ -111,7 +111,7 @@ static void
r_reg(fp, style, off, sbp)
FILE *fp;
enum STYLE style;
- long off;
+ off_t off;
struct stat *sbp;
{
struct mapinfo map;
diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c
index 911dcda..9b7d9a2 100644
--- a/usr.bin/tail/tail.c
+++ b/usr.bin/tail/tail.c
@@ -71,7 +71,7 @@ main(argc, argv)
{
struct stat sb;
FILE *fp;
- long off;
+ off_t off;
enum STYLE style;
int ch, first;
char *p;
@@ -91,7 +91,7 @@ main(argc, 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]) { \
OpenPOWER on IntegriCloud