Fix logic for determining end-of-file in a buffered input port.
authorChris Hanson <org/chris-hanson/cph>
Mon, 15 Jun 1987 18:09:02 +0000 (18:09 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 15 Jun 1987 18:09:02 +0000 (18:09 +0000)
v7/src/runtime/input.scm

index 91994809edb37f28bc42fc8b39e8859132de19c1..f686da62df983b022a8e5bf1f2ffe25c01977c34 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/input.scm,v 13.43 1987/03/17 18:50:41 cph Exp $
+;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/input.scm,v 13.44 1987/06/15 18:09:02 cph Exp $
 ;;;
 ;;;    Copyright (c) 1987 Massachusetts Institute of Technology
 ;;;
   (set! end-index (file-fill-input-buffer file-channel buffer))
   (zero? end-index))
 
+(declare (integrate buffer-ready?))
+
+(define (buffer-ready?)
+  (and (not (zero? end-index))
+       (not (refill-buffer!))))
+
 (define (:char-ready? delay)
-  (not (zero? end-index)))
+  (or (< start-index end-index)
+      (buffer-ready?)))
 
 (define (:close)
   (set! end-index 0)
 (define (:peek-char)
   (if (< start-index end-index)
       (string-ref buffer start-index)
-      (and (not (zero? end-index))
-          (not (refill-buffer!))
+      (and (buffer-ready?)
           (string-ref buffer 0))))
 
 (define (:discard-char)
 (define (:read-char)
   (if (< start-index end-index)
       (string-ref buffer (set! start-index (1+ start-index)))
-      (and (not (zero? end-index))
-          (not (refill-buffer!))
+      (and (buffer-ready?)
           (begin (set! start-index 1)
                  (string-ref buffer 0)))))
 \f
                                           result head-length)
                    result)))))))
   (and (or (< start-index end-index)
-          (and (not (zero? end-index))
-               (not (refill-buffer!))))
+          (buffer-ready?))
        (loop)))
 
 (define (:discard-chars delimiters)
       (cond (index (set! start-index index))
            ((not (refill-buffer!)) (loop)))))
   (if (or (< start-index end-index)
-         (and (not (zero? end-index))
-              (not (refill-buffer!))))
+         (buffer-ready?))
       (loop)))
 \f
 (define (:rest->string)