From 6835ff8992a001602cd4c75b03363f0037b2ade9 Mon Sep 17 00:00:00 2001 From: emarsden <emarsden> Date: Mon, 10 May 2004 16:58:37 +0000 Subject: [PATCH] When compiling from a stream, the compiler can't use FILE-LENGTH on the string-input-stream. From Luke Gorrie. --- compiler/main.lisp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/main.lisp b/compiler/main.lisp index 61084ec84..e80d602f2 100644 --- a/compiler/main.lisp +++ b/compiler/main.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/main.lisp,v 1.140 2004/04/06 20:44:01 rtoy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/main.lisp,v 1.141 2004/05/10 16:58:37 emarsden Exp $") ;;; ;;; ********************************************************************** ;;; @@ -800,12 +800,13 @@ in the user USER-INFO slot of STREAM-SOURCE-LOCATIONs.") ;;; Unexpected-EOF-Error -- Internal ;;; ;;; Print an error message giving some context for an EOF error. We print -;;; the first line after Pos that contains #\" or #\(, or lacking that, the +;;; the first line after POS that contains #\" or #\(, or lacking that, the ;;; first non-empty line. ;;; (defun unexpected-eof-error (stream pos condition) (declare (type stream stream) (type unsigned-byte pos)) - (let ((res nil)) + (let ((eof-pos (file-position stream)) + (res nil)) (file-position stream pos) (loop (let ((line (read-line stream nil nil))) @@ -820,25 +821,24 @@ in the user USER-INFO slot of STREAM-SOURCE-LOCATIONs.") "Read error in form starting at ~D:~%~@[ \"~A\"~%~]~A" pos res condition)) - (file-position stream (file-length stream)) + (file-position stream eof-pos) (undefined-value)) ;;; Careful-Read -- Internal ;;; -;;; Read a form from Stream, returning EOF at EOF. If a read error happens, +;;; Read a form from STREAM, returning EOF at EOF. If a read error happens, ;;; then attempt to recover if possible, returing a proxy error form. ;;; (defun careful-read (stream eof pos) (handler-case (let ((*features* (backend-features *target-backend*))) (read stream nil eof)) (error (condition) - (let ((new-pos (file-position stream))) - (cond ((= new-pos (file-length stream)) - (unexpected-eof-error stream pos condition)) - (t - (normal-read-error stream pos condition) - (ignore-error-form stream pos)))) + (if (null (peek-char nil stream nil)) + (unexpected-eof-error stream pos condition) + (progn + (normal-read-error stream pos condition) + (ignore-error-form stream pos))) '(cerror "Skip this form." "Attempt to load a file having a compile-time read error.")))) -- GitLab