mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Correct read-bytevector logic for small reads
This commit is contained in:
parent
d0e6dc7556
commit
1b1e8b311b
1 changed files with 5 additions and 3 deletions
|
@ -135,9 +135,11 @@
|
||||||
(if (zero? n)
|
(if (zero? n)
|
||||||
#u8()
|
#u8()
|
||||||
(let ((in (if (pair? o) (car o) (current-input-port)))
|
(let ((in (if (pair? o) (car o) (current-input-port)))
|
||||||
(res (make-bytevector n)))
|
(vec (make-bytevector n))
|
||||||
(read-bytevector! res in)
|
(res (read-bytevector! vec in)))
|
||||||
res)))
|
(cond ((eof-object? res) res)
|
||||||
|
((< res n) (subbytes vec 0 i))
|
||||||
|
(else res)))))
|
||||||
|
|
||||||
(define (read-bytevector! vec . o)
|
(define (read-bytevector! vec . o)
|
||||||
(let* ((in (if (pair? o) (car o) (current-input-port)))
|
(let* ((in (if (pair? o) (car o) (current-input-port)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue