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)))))) res))))))
(define (read-string n . o) (define (read-string n . o)
(let ((in (if (pair? o) (car o) (current-input-port)))) (if (zero? n)
(let ((res (%read-string n in))) ""
(cond (let ((in (if (pair? o) (car o) (current-input-port))))
((if (pair? res) (= 0 (car res)) #t) (let ((res (%read-string n in)))
eof) (cond
(else ((if (pair? res) (= 0 (car res)) #t)
(port-line-set! in (+ (string-count #\newline (cadr res)) eof)
(port-line in))) (else
(cadr res)))))) (port-line-set! in (+ (string-count #\newline (cadr res))
(port-line in)))
(cadr res)))))))
(define (read-string! str n . o) (define (read-string! str n . o)
(let* ((in (if (pair? o) (car o) (current-input-port))) (let* ((in (if (pair? o) (car o) (current-input-port)))