tdo a better job with 64-bit files - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 39ef727f465306bad804814e58ee0a94224c9fec
 (DIR) parent 75a69d3b20b73b4a66530043090198b8be1d7d0a
 (HTM) Author: rsc <devnull@localhost>
       Date:   Wed, 16 Jun 2004 15:32:56 +0000
       
       do a better job with 64-bit files
       
       Diffstat:
         M src/libbio/bseek.c                  |      18 +++++++++++-------
       
       1 file changed, 11 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/src/libbio/bseek.c b/src/libbio/bseek.c
       t@@ -5,6 +5,7 @@ off_t
        Bseek(Biobuf *bp, off_t offset, int base)
        {
                vlong n, d;
       +        int bufsz;
        
                switch(bp->state) {
                default:
       t@@ -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;
       +                                }
                                }
                        }