diff --git a/collects/mzlib/inflate.ss b/collects/mzlib/inflate.ss index 2b835b4159..e25157400e 100644 --- a/collects/mzlib/inflate.ss +++ b/collects/mzlib/inflate.ss @@ -271,19 +271,16 @@ (READBITS n))) (define (READBITS n) (if (= buf-pos buf-max) - (if (and (buf-max . < . BUFFER-SIZE) - (positive? buf-max)) - (error 'inflate "unexpected end of file") - (begin - (when (positive? buf-max) - (read-bytes! buffer input-port 0 (- buf-max MAX-LOOKAHEAD)) - ; (bytes-copy! buffer 0 buffer (- buf-max MAX-LOOKAHEAD) buf-max) - (set! buf-pos MAX-LOOKAHEAD)) - (let ([got (peek-bytes! buffer buf-pos input-port buf-pos BUFFER-SIZE)]) - (if (eof-object? got) - (error 'inflate "unexpected end of file") - (set! buf-max (+ buf-pos got)))) - (READBITS n))) + (begin + (when (positive? buf-max) + (read-bytes! buffer input-port 0 (- buf-max MAX-LOOKAHEAD)) + ; (bytes-copy! buffer 0 buffer (- buf-max MAX-LOOKAHEAD) buf-max) + (set! buf-pos MAX-LOOKAHEAD)) + (let ([got (peek-bytes-avail! buffer buf-pos #f input-port buf-pos BUFFER-SIZE)]) + (if (eof-object? got) + (error 'inflate "unexpected end of file") + (set! buf-max (+ buf-pos got)))) + (READBITS n)) (let ([v (bytes-ref buffer buf-pos)]) (set! buf-pos (add1 buf-pos)) (set! bb (+ bb (arithmetic-shift v bk)))