mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-22 07:09:18 +02:00
Updated order of read-bytevector! arguments.
This commit is contained in:
parent
f63d55aadb
commit
0c7a01d13a
2 changed files with 22 additions and 17 deletions
|
@ -102,20 +102,25 @@
|
|||
(bytevector-u8-set! res i x)
|
||||
(lp (+ i 1))))))))))
|
||||
|
||||
(define (read-bytevector! vec start end . o)
|
||||
(if (>= start end)
|
||||
0
|
||||
(let* ((res (read-bytevector
|
||||
(- end start)
|
||||
(if (pair? o) (car o) (current-input-port))))
|
||||
(len (bytevector-length res)))
|
||||
(cond
|
||||
((zero? len)
|
||||
(read-char (open-input-string "")))
|
||||
(else
|
||||
(do ((i 0 (+ i 1)))
|
||||
((>= i len) len)
|
||||
(bytevector-u8-set! vec (+ i start) (bytevector-u8-ref res i))))))))
|
||||
(define (read-bytevector! vec . o)
|
||||
(let* ((in (if (pair? o) (car o) (current-input-port)))
|
||||
(o (if (pair? o) (cdr o) o))
|
||||
(start (if (pair? o) (car o) 0))
|
||||
(end (if (and (pair? o) (pair? (cdr o)))
|
||||
(cadr o)
|
||||
(bytevector-length vec))))
|
||||
(if (>= start end)
|
||||
0
|
||||
(let* ((res (read-bytevector (- end start) in))
|
||||
(len (bytevector-length res)))
|
||||
(cond
|
||||
((zero? len)
|
||||
(read-char (open-input-string "")))
|
||||
(else
|
||||
(do ((i 0 (+ i 1)))
|
||||
((>= i len) len)
|
||||
(bytevector-u8-set! vec (+ i start) (bytevector-u8-ref res i))
|
||||
)))))))
|
||||
|
||||
(define (write-bytevector vec . o)
|
||||
(let* ((out (if (pair? o) (car o) (current-output-port)))
|
||||
|
|
|
@ -1526,17 +1526,17 @@
|
|||
|
||||
(test #u8(6 7 8 9 10)
|
||||
(let ((bv (bytevector 1 2 3 4 5)))
|
||||
(read-bytevector! bv 0 5 (open-input-bytevector #u8(6 7 8 9 10)))
|
||||
(read-bytevector! bv (open-input-bytevector #u8(6 7 8 9 10)) 0 5)
|
||||
bv))
|
||||
|
||||
(test #u8(6 7 8 4 5)
|
||||
(let ((bv (bytevector 1 2 3 4 5)))
|
||||
(read-bytevector! bv 0 3 (open-input-bytevector #u8(6 7 8 9 10)))
|
||||
(read-bytevector! bv (open-input-bytevector #u8(6 7 8 9 10)) 0 3)
|
||||
bv))
|
||||
|
||||
(test #u8(1 2 3 6 5)
|
||||
(let ((bv (bytevector 1 2 3 4 5)))
|
||||
(read-bytevector! bv 3 4 (open-input-bytevector #u8(6 7 8 9 10)))
|
||||
(read-bytevector! bv (open-input-bytevector #u8(6 7 8 9 10)) 3 4)
|
||||
bv))
|
||||
|
||||
(test #u8(1 2 3)
|
||||
|
|
Loading…
Add table
Reference in a new issue