mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 14:49:18 +02:00
bytevector io fixes
This commit is contained in:
parent
c3fea1f765
commit
6f85c98d12
1 changed files with 4 additions and 4 deletions
|
@ -35,14 +35,14 @@
|
||||||
(if (zero? n)
|
(if (zero? n)
|
||||||
""
|
""
|
||||||
(let ((res (read-string n (if (pair? o) (car o) (current-input-port)))))
|
(let ((res (read-string n (if (pair? o) (car o) (current-input-port)))))
|
||||||
(if (equal? res "")
|
(if (eof-object? res)
|
||||||
(read-char (open-input-string res))
|
res
|
||||||
(string->utf8 res)))))
|
(string->utf8 res)))))
|
||||||
|
|
||||||
(define (read-bytevector! vec start end . o)
|
(define (read-bytevector! vec start end . o)
|
||||||
(if (>= start end)
|
(if (>= start end)
|
||||||
0
|
0
|
||||||
(let* ((res (read-bytevector!
|
(let* ((res (read-bytevector
|
||||||
(- end start)
|
(- end start)
|
||||||
(if (pair? o) (car o) (current-input-port))))
|
(if (pair? o) (car o) (current-input-port))))
|
||||||
(len (bytevector-length res)))
|
(len (bytevector-length res)))
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
(bytevector-u8-set! vec (+ i start) (bytevector-u8-ref res i))))))))
|
(bytevector-u8-set! vec (+ i start) (bytevector-u8-ref res i))))))))
|
||||||
|
|
||||||
(define (write-bytevector vec . o)
|
(define (write-bytevector vec . o)
|
||||||
(apply write-string (utf8->string vec) (bytevector-length vec) o))
|
(write-string (utf8->string vec) (bytevector-length vec) (if (pair? o) (car o) (current-output-port))))
|
||||||
|
|
||||||
(define (write-partial-bytevector vec start end . o)
|
(define (write-partial-bytevector vec start end . o)
|
||||||
(apply write-bytevector (bytevector-copy-partial vec start end) o))
|
(apply write-bytevector (bytevector-copy-partial vec start end) o))
|
||||||
|
|
Loading…
Add table
Reference in a new issue