From 1ddf14c9f6674c0a96c0da1b6df452736672828d Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 6 Oct 2004 13:48:51 +0000 Subject: [PATCH] Fix think-o in READ-FINISH that caused infinite loop when reading an atom. --- v7/src/runtime/ttyio.scm | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/v7/src/runtime/ttyio.scm b/v7/src/runtime/ttyio.scm index 2946c9a92..c05886301 100644 --- a/v7/src/runtime/ttyio.scm +++ b/v7/src/runtime/ttyio.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: ttyio.scm,v 1.18 2004/09/10 18:01:36 cph Exp $ +$Id: ttyio.scm,v 1.19 2004/10/06 13:48:51 cph Exp $ Copyright 1991,1993,1996,1999,2003,2004 Massachusetts Institute of Technology @@ -96,28 +96,32 @@ USA. (define console-input-port) (define console-output-port) +(define *exit-on-eof?* #t) + (define (operation/read-char port) (let ((char (generic-io/read-char port))) (if (eof-object? char) - (begin - (if (not (nearest-cmdl/batch-mode?)) - (begin - (fresh-line port) - (write-string "End of input stream reached" port))) - (%exit))) - (maybe-echo-input port char) + (if *exit-on-eof?* + (begin + (if (not (nearest-cmdl/batch-mode?)) + (begin + (fresh-line port) + (write-string "End of input stream reached." port))) + (%exit))) + (maybe-echo-input port char)) char)) (define (operation/read-finish port) - (let loop () - (if (input-port/char-ready? port) - (let ((char (generic-io/read-char port))) - (if (not (eof-object? char)) - (if (char-whitespace? char) - (begin - (maybe-echo-input port char) - (loop)) - (input-port/unread-char port char)))))) + (fluid-let ((*exit-on-eof?* #f)) + (let loop () + (if (input-port/char-ready? port) + (let ((char (input-port/read-char port))) + (if (not (eof-object? char)) + (if (char-whitespace? char) + (begin + (maybe-echo-input port char) + (loop)) + (input-port/unread-char port char))))))) (output-port/discretionary-flush port)) (define (maybe-echo-input port char) -- 2.25.1