Fix think-o in READ-FINISH that caused infinite loop when reading an
authorChris Hanson <org/chris-hanson/cph>
Wed, 6 Oct 2004 13:48:51 +0000 (13:48 +0000)
committerChris Hanson <org/chris-hanson/cph>
Wed, 6 Oct 2004 13:48:51 +0000 (13:48 +0000)
atom.

v7/src/runtime/ttyio.scm

index 2946c9a925f4b9b0c42583e263c3dbe089c62b8c..c058863015d7768d713db20b3f44d9450df08e32 100644 (file)
@@ -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)
 \f
+(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)