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

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


    Date: Friday, January 22, 2010 @ 08:28:26
  Author: rtoy
    Path: /project/cmucl/cvsroot/src/code

Modified: fd-stream.lisp

Oops.  The string buffer contains characters, so to get the correct
file position, we need to convert what's left in the buffer into
octets to figure out how many octets haven't been delivered yet.


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


Index: src/code/fd-stream.lisp
diff -u src/code/fd-stream.lisp:1.93 src/code/fd-stream.lisp:1.94
--- src/code/fd-stream.lisp:1.93	Fri Jan 22 01:14:19 2010
+++ src/code/fd-stream.lisp	Fri Jan 22 08:28:26 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.93 2010-01-22 06:14:19 rtoy Exp $")
+  "$Header: /project/cmucl/cvsroot/src/code/fd-stream.lisp,v 1.94 2010-01-22 13:28:26 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1667,10 +1667,18 @@
 			       (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)))
+		     ;; The string buffer contains Lisp characters,
+		     ;; not octets!  To figure out how many octets
+		     ;; have not been already supplied, we need to
+		     ;; convert them back to the encoded format and
+		     ;; count the number of octets.
+		     (decf posn (length
+				 (string-encode (subseq (fd-stream-string-buffer stream)
+							(fd-stream-string-index stream)
+							(fd-stream-string-buffer-len stream))
+						(fd-stream-external-format stream))))
 		     (decf posn (- (fd-stream-ibuf-tail stream)
-			       (fd-stream-ibuf-head stream))))
+				   (fd-stream-ibuf-head stream))))
 		 (when (fd-stream-unread stream) ;;@@
 		   (decf posn))
 		 ;; Divide bytes by element size.



More information about the cmucl-commit mailing list