Added read-line

This commit is contained in:
Justin Ethier 2015-07-30 22:55:46 -04:00
parent f5729c4526
commit f530eb1804
2 changed files with 10 additions and 2 deletions

View file

@ -1381,9 +1381,12 @@ object Cyc_io_read_line(object cont, object port) {
if (c == EOF && i == 0) { if (c == EOF && i == 0) {
return_funcall1(cont, Cyc_EOF); return_funcall1(cont, Cyc_EOF);
} else if (c == EOF || i == 1023 || c == '\n') { } else if (c == EOF || i == 1023 || c == '\n') {
buf[i] = '\0';
{
make_string(s, buf); make_string(s, buf);
return_funcall1(cont, &s); return_funcall1(cont, &s);
} }
}
buf[i++] = c; buf[i++] = c;
} }

View file

@ -78,6 +78,7 @@
newline newline
write-char write-char
flush-output-port flush-output-port
read-line
features features
) )
(begin (begin
@ -139,6 +140,10 @@
(if (null? lst) (if (null? lst)
end end
(func (car lst) (foldr func end (cdr lst))))) (func (car lst) (foldr func end (cdr lst)))))
(define (read-line . port)
(if (null? port)
(Cyc-read-line (current-output-port))
(Cyc-read-line (car port))))
(define (flush-output-port . port) (define (flush-output-port . port)
(if (null? port) (if (null? port)
(Cyc-flush-output-port (current-output-port)) (Cyc-flush-output-port (current-output-port))