From dcb7c7ddf5dc2c7e32720ed91c6d7bbed7f7455a Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sun, 27 Feb 2011 23:26:08 +0100 Subject: [PATCH] flush all input on a read error * module/system/repl/repl.scm (flush-all-input): New helper. (prompting-meta-read): Flush all input on a read error, as we could be within some expression or a string or something. --- module/system/repl/repl.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/module/system/repl/repl.scm b/module/system/repl/repl.scm index 6eb29be91..0d7aca762 100644 --- a/module/system/repl/repl.scm +++ b/module/system/repl/repl.scm @@ -54,6 +54,13 @@ meta-command-token) (else (read port env)))))))) +(define (flush-all-input) + (if (and (char-ready?) + (not (eof-object? (peek-char)))) + (begin + (read-char) + (flush-all-input)))) + ;; repl-reader is a function defined in boot-9.scm, and is replaced by ;; something else if readline has been activated. much of this hoopla is ;; to be able to re-use the existing readline machinery. @@ -72,6 +79,7 @@ (else (format (current-output-port) "While reading expression:\n") (print-exception (current-output-port) #f key args) + (flush-all-input) *unspecified*)))))