diff --git a/mes/module/mes/guile.mes b/mes/module/mes/guile.mes index 65169415..ab1e2455 100644 --- a/mes/module/mes/guile.mes +++ b/mes/module/mes/guile.mes @@ -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) diff --git a/src/posix.c b/src/posix.c index acd77e48..eba767a4 100644 --- a/src/posix.c +++ b/src/posix.c @@ -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); }