do a better job with 64-bit files

This commit is contained in:
rsc 2004-06-16 15:32:56 +00:00
parent 75a69d3b20
commit 39ef727f46

View file

@ -5,6 +5,7 @@ off_t
Bseek(Biobuf *bp, off_t offset, int base) Bseek(Biobuf *bp, off_t offset, int base)
{ {
vlong n, d; vlong n, d;
int bufsz;
switch(bp->state) { switch(bp->state) {
default: default:
@ -28,13 +29,16 @@ Bseek(Biobuf *bp, off_t offset, int base)
*/ */
if(base == 0) { if(base == 0) {
d = n - Boffset(bp); d = n - Boffset(bp);
bp->icount += d; bufsz = bp->ebuf - bp->gbuf;
if(d >= 0) { if(-bufsz <= d && d <= bufsz){
if(bp->icount <= 0) bp->icount += d;
return n; if(d >= 0) {
} else { if(bp->icount <= 0)
if(bp->ebuf - bp->gbuf >= -bp->icount) return n;
return n; } else {
if(bp->ebuf - bp->gbuf >= -bp->icount)
return n;
}
} }
} }