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

Raymond Toy rtoy at common-lisp.net
Wed Sep 15 13:32:50 CEST 2010


    Date: Wednesday, September 15, 2010 @ 07:32:50
  Author: rtoy
    Path: /project/cmucl/cvsroot/src/code

Modified: fd-stream.lisp

Fix FD-STREAM-FILE-POSITION, which was returning the wrong thing for
streams with a string-buffer (all external formats except ISO-8859-1)
and for streams without a string-buffer but with an in-buffer
(ISO-8859-1).  This caused source location information to be totally
wrong.


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


Index: src/code/fd-stream.lisp
diff -u src/code/fd-stream.lisp:1.119 src/code/fd-stream.lisp:1.120
--- src/code/fd-stream.lisp:1.119	Tue Sep  7 23:04:54 2010
+++ src/code/fd-stream.lisp	Wed Sep 15 07:32:49 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.119 2010-09-08 03:04:54 rtoy Exp $")
+  "$Header: /project/cmucl/cvsroot/src/code/fd-stream.lisp,v 1.120 2010-09-15 11:32:49 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1691,14 +1691,15 @@
 		   (incf posn (- (the index (caddr later))
 				 (the index (cadr later)))))
 		 (incf posn (fd-stream-obuf-tail stream))
+
 		 ;; Adjust for unread input:
 		 ;;  If there is any input read from UNIX but not supplied to
 		 ;; 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)
 		     ;; The string buffer contains Lisp characters,
@@ -1717,8 +1718,18 @@
 			 (loop for k of-type fixnum from (1- (fd-stream-string-index stream))
 			    below (1- (fd-stream-string-buffer-len stream))
 			    do (decf posn (aref ocount k)))))
-		     (decf posn (- (fd-stream-ibuf-tail stream)
-				   (fd-stream-ibuf-head stream))))
+		     (when (fd-stream-in-buffer stream)
+		       ;; When we have an in-buffer (but no
+		       ;; string-buffer!), we need to adjust for the
+		       ;; octets that have not yet been supplied.
+		       ;; This situation (should!) only happens for an
+		       ;; external-format of ISO-8859-1.  If there's
+		       ;; no string-buffer and no in-buffer, then the
+		       ;; ibuf tail and head pointers contain all the
+		       ;; information needed.
+		       (decf posn (- in-buffer-length
+				     (fd-stream-in-index stream)))))
+		 
 		 (when (fd-stream-unread stream) ;;@@
 		   (decf posn))
 		 ;; Divide bytes by element size.



More information about the cmucl-commit mailing list