handle 64-bit file sizes

This commit is contained in:
rsc 2004-06-13 20:08:00 +00:00
parent d9e16d252a
commit b707cb51ed
2 changed files with 9 additions and 9 deletions

View file

@ -162,8 +162,8 @@ main(int argc, char *argv[])
int int
locate(void) locate(void)
{ {
long top, bot, mid; vlong top, bot, mid;
long c; int c;
int n; int n;
bot = 0; bot = 0;

View file

@ -8,7 +8,7 @@
* the simple command tail -c, legal in v10, is illegal * the simple command tail -c, legal in v10, is illegal
*/ */
long count; vlong count;
int anycount; int anycount;
int follow; int follow;
int file = 0; int file = 0;
@ -41,7 +41,7 @@ extern void suffix(char*);
extern long tread(char*, long); extern long tread(char*, long);
#define trunc tailtrunc #define trunc tailtrunc
extern void trunc(Dir*, Dir**); extern void trunc(Dir*, Dir**);
extern long tseek(long, int); extern vlong tseek(vlong, int);
extern void twrite(char*, long); extern void twrite(char*, long);
extern void usage(void); extern void usage(void);
@ -85,7 +85,7 @@ main(int argc, char **argv)
if(dir==REV && (units==CHARS || follow || origin==BEG)) if(dir==REV && (units==CHARS || follow || origin==BEG))
fatal("incompatible options"); fatal("incompatible options");
if(!anycount) if(!anycount)
count = dir==REV? ~0UL>>1: 10; count = dir==REV? ~0ULL>>1: 10;
if(origin==BEG && units==LINES && count>0) if(origin==BEG && units==LINES && count>0)
count--; count--;
if(argc > 2) if(argc > 2)
@ -126,7 +126,7 @@ void
trunc(Dir *old, Dir **new) trunc(Dir *old, Dir **new)
{ {
Dir *d; Dir *d;
ulong olength; vlong olength;
d = dirfstat(file); d = dirfstat(file);
if(d == nil) if(d == nil)
@ -268,7 +268,7 @@ reverse(void)
long n = 0; long n = 0;
long bufsiz = 0; long bufsiz = 0;
char *buf = 0; char *buf = 0;
long pos = tseek(0L, 2); vlong pos = tseek(0L, 2);
for(first=1; pos>0 && count>0; first=0) { for(first=1; pos>0 && count>0; first=0) {
n = pos>Bsize? Bsize: (int)pos; n = pos>Bsize? Bsize: (int)pos;
@ -301,8 +301,8 @@ reverse(void)
twrite(buf, len); twrite(buf, len);
} }
long vlong
tseek(long o, int p) tseek(vlong o, int p)
{ {
o = seek(file, o, p); o = seek(file, o, p);
if(o == -1) if(o == -1)