aboutsummaryrefslogtreecommitdiff
path: root/src/libbio
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-06-16 15:32:56 +0000
committerrsc <devnull@localhost>2004-06-16 15:32:56 +0000
commit39ef727f465306bad804814e58ee0a94224c9fec (patch)
treec43c3f817714e8133902ea20b6d22ea701298e4d /src/libbio
parent75a69d3b20b73b4a66530043090198b8be1d7d0a (diff)
downloadplan9port-39ef727f465306bad804814e58ee0a94224c9fec.tar.gz
plan9port-39ef727f465306bad804814e58ee0a94224c9fec.tar.bz2
plan9port-39ef727f465306bad804814e58ee0a94224c9fec.zip
do a better job with 64-bit files
Diffstat (limited to 'src/libbio')
-rw-r--r--src/libbio/bseek.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/libbio/bseek.c b/src/libbio/bseek.c
index c9e4493e..4e79affd 100644
--- a/src/libbio/bseek.c
+++ b/src/libbio/bseek.c
@@ -5,6 +5,7 @@ off_t
Bseek(Biobuf *bp, off_t offset, int base)
{
vlong n, d;
+ int bufsz;
switch(bp->state) {
default:
@@ -28,13 +29,16 @@ Bseek(Biobuf *bp, off_t offset, int base)
*/
if(base == 0) {
d = n - Boffset(bp);
- bp->icount += d;
- if(d >= 0) {
- if(bp->icount <= 0)
- return n;
- } else {
- if(bp->ebuf - bp->gbuf >= -bp->icount)
- return n;
+ bufsz = bp->ebuf - bp->gbuf;
+ if(-bufsz <= d && d <= bufsz){
+ bp->icount += d;
+ if(d >= 0) {
+ if(bp->icount <= 0)
+ return n;
+ } else {
+ if(bp->ebuf - bp->gbuf >= -bp->icount)
+ return n;
+ }
}
}