read-string: return EOF if nothing can be read

R7RS states that there's three possible scenarios for read-string:

- More characters can be read than asked for (return string)
- Less characters can be read than asked for (return string)
- No characters can be read (return EOF)

This commit ensures the last scenario works as intended.
This commit is contained in:
Vasilij Schneidermann 2017-09-07 17:07:05 +02:00
parent c4a569d2cd
commit d731f92e7d

View file

@ -645,6 +645,8 @@
(let ((port (if (null? opts)
(current-input-port)
(car opts))))
(if (eof-object? (peek-char port))
(eof-object)
(let loop ((acc '())
(i k)
(chr #f))
@ -659,7 +661,7 @@
(else
(loop (if chr (cons chr acc) acc)
(- i 1)
(read-char port)))))))
(read-char port))))))))
(define (flush-output-port . port)
(if (null? port)
(Cyc-flush-output-port (current-output-port))