mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 13:37:35 +02:00
Fixing (byte)vector-copy! for non-zero at.
This commit is contained in:
parent
72094b760b
commit
dd168e5506
1 changed files with 10 additions and 8 deletions
|
@ -152,10 +152,11 @@
|
||||||
(apply for-each proc (map vector->list (cons vec lov)))))
|
(apply for-each proc (map vector->list (cons vec lov)))))
|
||||||
|
|
||||||
(define (vector-copy! to at from . o)
|
(define (vector-copy! to at from . o)
|
||||||
(let ((start (if (pair? o) (car o) 0))
|
(let* ((start (if (pair? o) (car o) 0))
|
||||||
(end (if (and (pair? o) (pair? (cdr o))) (cadr o) (vector-length from))))
|
(end (if (and (pair? o) (pair? (cdr o))) (cadr o) (vector-length from)))
|
||||||
|
(limit (min end (+ start (- (vector-length to) at)))))
|
||||||
(do ((i at (+ i 1)) (j start (+ j 1)))
|
(do ((i at (+ i 1)) (j start (+ j 1)))
|
||||||
((>= j end))
|
((>= j limit))
|
||||||
(vector-set! to i (vector-ref from j)))))
|
(vector-set! to i (vector-ref from j)))))
|
||||||
|
|
||||||
(define (vector->string vec . o)
|
(define (vector->string vec . o)
|
||||||
|
@ -165,12 +166,13 @@
|
||||||
(list->vector (apply string->list vec o)))
|
(list->vector (apply string->list vec o)))
|
||||||
|
|
||||||
(define (bytevector-copy! to at from . o)
|
(define (bytevector-copy! to at from . o)
|
||||||
(let ((start (if (pair? o) (car o) 0))
|
(let* ((start (if (pair? o) (car o) 0))
|
||||||
(end (if (and (pair? o) (pair? (cdr o)))
|
(end (if (and (pair? o) (pair? (cdr o)))
|
||||||
(cadr o)
|
(cadr o)
|
||||||
(bytevector-length from))))
|
(bytevector-length from)))
|
||||||
|
(limit (min end (+ start (- (bytevector-length to) at)))))
|
||||||
(do ((i at (+ i 1)) (j start (+ j 1)))
|
(do ((i at (+ i 1)) (j start (+ j 1)))
|
||||||
((>= j end))
|
((>= j limit))
|
||||||
(bytevector-u8-set! to i (bytevector-u8-ref from j)))))
|
(bytevector-u8-set! to i (bytevector-u8-ref from j)))))
|
||||||
|
|
||||||
(define (bytevector-copy vec . o)
|
(define (bytevector-copy vec . o)
|
||||||
|
|
Loading…
Add table
Reference in a new issue