From 6f85c98d127ac9c97ed3b20b56af740d51e5adca Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sat, 26 Nov 2011 17:01:20 +0900 Subject: [PATCH] bytevector io fixes --- lib/scheme/extras.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/scheme/extras.scm b/lib/scheme/extras.scm index 78406941..d3786aa8 100644 --- a/lib/scheme/extras.scm +++ b/lib/scheme/extras.scm @@ -35,14 +35,14 @@ (if (zero? n) "" (let ((res (read-string n (if (pair? o) (car o) (current-input-port))))) - (if (equal? res "") - (read-char (open-input-string res)) + (if (eof-object? res) + res (string->utf8 res))))) (define (read-bytevector! vec start end . o) (if (>= start end) 0 - (let* ((res (read-bytevector! + (let* ((res (read-bytevector (- end start) (if (pair? o) (car o) (current-input-port)))) (len (bytevector-length res))) @@ -55,7 +55,7 @@ (bytevector-u8-set! vec (+ i start) (bytevector-u8-ref res i)))))))) (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) (apply write-bytevector (bytevector-copy-partial vec start end) o))