mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 14:49:18 +02:00
Fixing read-bytevector to use read-u8 instead of the hacked definition in terms of read-string.
This commit is contained in:
parent
60c96d76a4
commit
b5046925f7
1 changed files with 12 additions and 5 deletions
|
@ -43,11 +43,18 @@
|
|||
|
||||
(define (read-bytevector n . o)
|
||||
(if (zero? n)
|
||||
""
|
||||
(let ((res (read-string n (if (pair? o) (car o) (current-input-port)))))
|
||||
(if (eof-object? res)
|
||||
#u8()
|
||||
(let ((in (if (pair? o) (car o) (current-input-port)))
|
||||
(res (make-bytevector n)))
|
||||
(let lp ((i 0))
|
||||
(if (>= i n)
|
||||
res
|
||||
(string->utf8 res)))))
|
||||
(let ((x (read-u8 in)))
|
||||
(cond ((eof-object? x)
|
||||
(if (zero? i) x (subbytes res 0 i)))
|
||||
(else
|
||||
(bytevector-u8-set! res i x)
|
||||
(lp (+ i 1))))))))))
|
||||
|
||||
(define (read-bytevector! vec start end . o)
|
||||
(if (>= start end)
|
||||
|
|
Loading…
Add table
Reference in a new issue