CMUCL commit: src/code (fd-stream.lisp)

Raymond Toy rtoy at common-lisp.net
Fri Jan 22 07:14:20 CET 2010


    Date: Friday, January 22, 2010 @ 01:14:20
  Author: rtoy
    Path: /project/cmucl/cvsroot/src/code

Modified: fd-stream.lisp

Fix FILE-POSITION for fd-streams with a string buffer.  It was
inadvertently broken when the fast external format work was done.  The
position did not take into account the number of octets that had been
read in but not yet processed.


----------------+
 fd-stream.lisp |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)


Index: src/code/fd-stream.lisp
diff -u src/code/fd-stream.lisp:1.92 src/code/fd-stream.lisp:1.93
--- src/code/fd-stream.lisp:1.92	Sun Oct 18 10:21:24 2009
+++ src/code/fd-stream.lisp	Fri Jan 22 01:14:19 2010
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /project/cmucl/cvsroot/src/code/fd-stream.lisp,v 1.92 2009-10-18 14:21:24 rtoy Exp $")
+  "$Header: /project/cmucl/cvsroot/src/code/fd-stream.lisp,v 1.93 2010-01-22 06:14:19 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1662,8 +1662,15 @@
 		 ;; the user of the stream, the *real* file position will
 		 ;; smaller than reported, because we want to look like the
 		 ;; unread stuff is still available.
+		 #-unicode
 		 (decf posn (- (fd-stream-ibuf-tail stream)
 			       (fd-stream-ibuf-head stream)))
+		 #+unicode
+		 (if (fd-stream-string-buffer stream)
+		     (decf posn (- (fd-stream-string-buffer-len stream)
+				   (fd-stream-string-index stream)))
+		     (decf posn (- (fd-stream-ibuf-tail stream)
+			       (fd-stream-ibuf-head stream))))
 		 (when (fd-stream-unread stream) ;;@@
 		   (decf posn))
 		 ;; Divide bytes by element size.
@@ -1688,7 +1695,11 @@
 	;; Clear out any pending input to force the next read to go to the
 	;; disk.
 	(setf (fd-stream-unread stream) nil) ;;@@
-	#+unicode (setf (fd-stream-last-char-read-size stream) 0)
+	#+unicode
+	(progn
+	  (setf (fd-stream-last-char-read-size stream) 0)
+	  (setf (fd-stream-string-index stream)
+		(fd-stream-string-buffer-len stream)))
 	(setf (fd-stream-ibuf-head stream) 0)
 	(setf (fd-stream-ibuf-tail stream) 0)
 	;; Trash cached value for listen, so that we check next time.



More information about the cmucl-commit mailing list