- ;; the resyncing case correctly we need to call the
- ;; single-character reading function and check whether an
- ;; EOF was really reached. If not, we can just fill the
- ;; buffer by one character, and hope that the next refill
- ;; will not need to resync.
- (let* ((value (funcall (ansi-stream-in stream) stream nil :eof))
- (index (1- +ansi-stream-in-buffer-length+)))
- (case value
- ((:eof)
- ;; Mark buffer as empty.
+ ;; the resyncing case correctly we need to call the reading
+ ;; function and check whether an EOF was really reached. If
+ ;; not, we can just fill the buffer by one character, and
+ ;; hope that the next refill will not need to resync.
+ ;;
+ ;; KLUDGE: we can't use FD-STREAM functions (which are the
+ ;; only ones which will give us decoding errors) here,
+ ;; because this code is generic. We can't call the N-BIN
+ ;; function, because near the end of a real file that can
+ ;; legitimately bounce us to the IN function. So we have
+ ;; to call ANSI-STREAM-IN.
+ (let* ((index (1- +ansi-stream-in-buffer-length+))
+ (value (funcall (ansi-stream-in stream) stream nil :eof)))
+ (cond
+ ((eql value :eof)
+ ;; definitely EOF now