From b10e98ffbf7341bb0236c18f0f04a1cfda05cfb4 Mon Sep 17 00:00:00 2001
From: gerd <gerd>
Date: Mon, 3 Nov 2003 16:50:28 +0000
Subject: [PATCH] 	(with-open-file (stream "test.123" :direction :output 
                         :if-exists :supersede) 	  (format stream "~S
 ~S ~S~%" 'these 'are 'symbols))

	(with-open-file (stream "test.123" :direction :io
	                        :if-exists :overwrite)
	  (read stream) (prin1 'insert stream))

	(with-open-file (stream "test.123")
	  (loop for line = (read-line stream nil)
	        until (null line) do (write-line line)))

	Output should be "these insertmbols"
	Output is "these are symbols\ninsert"

	* src/code/fd-stream.lisp (def-output-routines): If there is any
	input read from UNIX but not supplied to the user of the stream,
	reposition to the real file position as seen from Lisp.
	Reported by Adam Warner.
---
 code/fd-stream.lisp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/code/fd-stream.lisp b/code/fd-stream.lisp
index 9a0515bd9..0a6bbc2f1 100644
--- a/code/fd-stream.lisp
+++ b/code/fd-stream.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/fd-stream.lisp,v 1.72 2003/08/19 09:26:57 gerd Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fd-stream.lisp,v 1.73 2003/11/03 16:50:28 gerd Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -254,6 +254,14 @@
 				    (+ (fd-stream-obuf-tail stream)
 				       ,size))
 			     (flush-output-buffer stream)))
+		       ;;
+		       ;; If there is any input read from UNIX but not
+		       ;; supplied to the user of the stream, reposition
+		       ;; to the real file position as seen from Lisp.
+		       ,(unless (eq (car buffering) :none)
+			  `(when (> (fd-stream-ibuf-tail stream)
+				    (fd-stream-ibuf-head stream))
+			     (file-position stream (file-position stream))))
 		       ,@body
 		       (incf (fd-stream-obuf-tail stream) ,size)
 		       ,(ecase (car buffering)
-- 
GitLab