mes: read-string: Take optional port argument.
* src/posix.c (read_string): Take optional port argument. * mes/module/mes/guile.mes (read-string): Remove.
This commit is contained in:
parent
d6660a5d83
commit
0e1d98963c
|
@ -31,16 +31,6 @@
|
|||
(mes-use-module (srfi srfi-16))
|
||||
(mes-use-module (mes display))
|
||||
|
||||
(if #t ;;(not (defined? 'read-string))
|
||||
(define (read-string)
|
||||
(define (read-string c)
|
||||
(if (eq? c #\*eof*) '()
|
||||
(cons c (read-string (read-char)))))
|
||||
(let ((string (list->string (read-string (read-char)))))
|
||||
(if (and=> (getenv "MES_DEBUG") (compose (lambda (o) (> o 3)) string->number))
|
||||
(core:display-error (string-append "drained: `" string "'\n")))
|
||||
string)))
|
||||
|
||||
(define (drain-input port) (read-string))
|
||||
|
||||
(define (make-string n . fill)
|
||||
|
|
|
@ -112,8 +112,11 @@ write_char (SCM i) ///((arity . n))
|
|||
}
|
||||
|
||||
SCM
|
||||
read_string ()
|
||||
read_string (SCM port) ///((arity . n))
|
||||
{
|
||||
int fd = g_stdin;
|
||||
if (TYPE (port) == TPAIR && TYPE (car (port)) == TNUMBER)
|
||||
g_stdin = VALUE (CAR (port));
|
||||
SCM lst = cell_nil;
|
||||
SCM c = read_char ();
|
||||
while (VALUE (c) != -1)
|
||||
|
@ -121,6 +124,7 @@ read_string ()
|
|||
lst = append2 (lst, cons (c, cell_nil));
|
||||
c = read_char ();
|
||||
}
|
||||
g_stdin = fd;
|
||||
return MAKE_STRING (lst);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue