get-u8 and lookahead-u8 did not update the port position properly.

Fixed.
This commit is contained in:
Abdulaziz Ghuloum 2008-07-23 11:15:44 -07:00
parent 9f623124d5
commit 0305537374
3 changed files with 7 additions and 16 deletions

Binary file not shown.

View File

@ -1177,21 +1177,12 @@
(import UNSAFE) (import UNSAFE)
(define (get-u8-byte-mode p who start) (define (get-u8-byte-mode p who start)
(when ($port-closed? p) (die who "port is closed" p)) (when ($port-closed? p) (die who "port is closed" p))
(let* ([bv ($port-buffer p)] (let ([cnt (refill-bv-buffer p who)])
[n (bytevector-length bv)]) (cond
(let ([j (($port-read! p) bv 0 n)]) [(eqv? cnt 0) (eof-object)]
(unless (fixnum? j) [else
(die who "invalid return value from read! procedure" j)) ($set-port-index! p start)
(cond (bytevector-u8-ref ($port-buffer p) 0)])))
[(fx> j 0)
(unless (fx<= j n)
(die who "read! returned a value out of range" j))
($set-port-index! p start)
($set-port-size! p j)
(bytevector-u8-ref bv 0)]
[(fx= j 0) (eof-object)]
[else
(die who "read! returned a value out of range" j)]))))
(define (slow-get-u8 p who start) (define (slow-get-u8 p who start)
(assert-binary-input-port p who) (assert-binary-input-port p who)
($set-port-attrs! p fast-get-byte-tag) ($set-port-attrs! p fast-get-byte-tag)

View File

@ -1 +1 @@
1548 1549