diff --git a/code/macros.lisp b/code/macros.lisp index a5f58110d052bdc0f985a7eed70c8128be1dbcea..08d31d46ec7990876461e874f60189021a09cf64 100644 --- a/code/macros.lisp +++ b/code/macros.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/code/macros.lisp,v 1.51 1997/09/03 20:27:08 dtc Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/macros.lisp,v 1.52 1997/09/13 20:28:10 pw Exp $") ;;; ;;; ********************************************************************** ;;; @@ -1391,20 +1391,22 @@ (defmacro with-input-from-string ((var string &key index start end) &body (forms decls)) "Binds the Var to an input stream that returns characters from String and executes the body. See manual for details." - `(let ((,var - ,(cond ((null end) - `(make-string-input-stream ,string ,(or start 0))) - ((symbolp end) - `(if ,end - (make-string-input-stream ,string ,(or start 0) ,end) - (make-string-input-stream ,string ,(or start 0)))) - (t - `(make-string-input-stream ,string ,(or start 0) ,end))))) - ,@decls - (unwind-protect - (progn ,@forms) - (close ,var) - ,@(if index `((setf ,index (string-input-stream-current ,var))))))) + ;; The once-only inhibits compiler note for unreachable code when 'end' is true. + (once-only ((string string)) + `(let ((,var + ,(cond ((null end) + `(make-string-input-stream ,string ,(or start 0))) + ((symbolp end) + `(if ,end + (make-string-input-stream ,string ,(or start 0) ,end) + (make-string-input-stream ,string ,(or start 0)))) + (t + `(make-string-input-stream ,string ,(or start 0) ,end))))) + ,@decls + (unwind-protect + (progn ,@forms) + (close ,var) + ,@(if index `((setf ,index (string-input-stream-current ,var)))))))) (defmacro with-output-to-string ((var &optional string) &body (forms decls))