Bugfix - Allow read-bytevector to return EOF

This commit is contained in:
Justin Ethier 2020-03-05 23:00:20 -05:00
parent 12489dcea5
commit 9a464e002e

View file

@ -709,11 +709,6 @@
(if (null? port) (if (null? port)
(Cyc-display str (current-output-port)) (Cyc-display str (current-output-port))
(Cyc-display str (car port)))) (Cyc-display str (car port))))
(define (read-bytevector k . _port)
(let ((port (if (null? _port)
(current-input-port)
(car _port))))
'test))
(define (read-bytevector k . _port) (define (read-bytevector k . _port)
(letrec ((port (if (null? port) (letrec ((port (if (null? port)
(current-input-port) (current-input-port)
@ -723,7 +718,9 @@
(let ((b (read-u8 port))) (let ((b (read-u8 port)))
(cond (cond
((eof-object? b) ((eof-object? b)
(bytevector-copy bv 0 n)) (if (zero? n)
b ;; EOF
(bytevector-copy bv 0 n)))
((< n k) ((< n k)
(bytevector-u8-set! bv n b) (bytevector-u8-set! bv n b)
(loop (+ n 1))) (loop (+ n 1)))