* src/posix.c (read_string): Take optional port argument.
* mes/module/mes/guile.mes (read-string): Remove.
(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)
}
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)
lst = append2 (lst, cons (c, cell_nil));
c = read_char ();
}
+ g_stdin = fd;
return MAKE_STRING (lst);
}