return null string on (read-string 0)

This commit is contained in:
Alex Shinn 2011-04-17 23:45:21 +09:00
parent 08554fd29c
commit de539a472e

View file

@ -44,15 +44,17 @@
res))))))
(define (read-string n . o)
(let ((in (if (pair? o) (car o) (current-input-port))))
(let ((res (%read-string n in)))
(cond
((if (pair? res) (= 0 (car res)) #t)
eof)
(else
(port-line-set! in (+ (string-count #\newline (cadr res))
(port-line in)))
(cadr res))))))
(if (zero? n)
""
(let ((in (if (pair? o) (car o) (current-input-port))))
(let ((res (%read-string n in)))
(cond
((if (pair? res) (= 0 (car res)) #t)
eof)
(else
(port-line-set! in (+ (string-count #\newline (cadr res))
(port-line in)))
(cadr res)))))))
(define (read-string! str n . o)
(let* ((in (if (pair? o) (car o) (current-input-port)))