mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Merge pull request #222 from wasamasa/read-string-eof-behavior
read-string: return EOF if nothing can be read
This commit is contained in:
commit
8fe853dfac
1 changed files with 17 additions and 15 deletions
|
@ -645,21 +645,23 @@
|
|||
(let ((port (if (null? opts)
|
||||
(current-input-port)
|
||||
(car opts))))
|
||||
(let loop ((acc '())
|
||||
(i k)
|
||||
(chr #f))
|
||||
(cond
|
||||
((eof-object? chr)
|
||||
(list->string
|
||||
(reverse acc)))
|
||||
((zero? i)
|
||||
(list->string
|
||||
(reverse
|
||||
(if chr (cons chr acc) acc))))
|
||||
(else
|
||||
(loop (if chr (cons chr acc) acc)
|
||||
(- i 1)
|
||||
(read-char port)))))))
|
||||
(if (eof-object? (peek-char port))
|
||||
(eof-object)
|
||||
(let loop ((acc '())
|
||||
(i k)
|
||||
(chr #f))
|
||||
(cond
|
||||
((eof-object? chr)
|
||||
(list->string
|
||||
(reverse acc)))
|
||||
((zero? i)
|
||||
(list->string
|
||||
(reverse
|
||||
(if chr (cons chr acc) acc))))
|
||||
(else
|
||||
(loop (if chr (cons chr acc) acc)
|
||||
(- i 1)
|
||||
(read-char port))))))))
|
||||
(define (flush-output-port . port)
|
||||
(if (null? port)
|
||||
(Cyc-flush-output-port (current-output-port))
|
||||
|
|
Loading…
Add table
Reference in a new issue