[cmucl-commit] CMUCL commit: src/code (stream.lisp)

Raymond Toy rtoy at common-lisp.net
Thu Mar 3 17:43:29 CET 2011


    Date: Thursday, March 3, 2011 @ 11:43:29
  Author: rtoy
    Path: /project/cmucl/cvsroot/src/code

Modified: stream.lisp

Fix Trac #43:  unread-char doesn't change file-position

The issue is caused by FAST-READ-CHAR-STRING-REFILL.  In some
situations the number of octets converted is not exactly the same as
the length of the buffer because the last octets in the buffer don't
hold a complete encoded character.  This is ok, but we didn't update
the ibuf-head pointer to indicate that some octets haven't actually
been converted.  This confuses FILE-POSITION.


-------------+
 stream.lisp |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)


Index: src/code/stream.lisp
diff -u src/code/stream.lisp:1.99 src/code/stream.lisp:1.100
--- src/code/stream.lisp:1.99	Tue Sep  7 23:04:54 2010
+++ src/code/stream.lisp	Thu Mar  3 11:43:28 2011
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /project/cmucl/cvsroot/src/code/stream.lisp,v 1.99 2010-09-08 03:04:54 rtoy Rel $")
+  "$Header: /project/cmucl/cvsroot/src/code/stream.lisp,v 1.100 2011-03-03 16:43:28 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -723,6 +723,13 @@
 	   (setf (lisp-stream-in-index stream) (1+ start))
 	   (code-char (aref ibuf start))))))
 
+;;; FAST-READ-CHAR-STRING-REFILL  --  Interface
+;;;
+;;;    This function is called by the fast-read-char expansion to refill the
+;;; string-buffer for text streams.  There is definitely a
+;;; string-buffer and an in-buffer, which implies there must be an
+;;; n-bin method.
+;;;
 #+unicode
 (defun fast-read-char-string-refill (stream eof-errorp eof-value)
   ;; Like fast-read-char-refill, but we don't need or want the
@@ -844,6 +851,11 @@
 			    (setf (lisp-stream-string-buffer-len stream) (1+ char-count))
 			    (setf (lisp-stream-string-index stream) 2)
 			    (setf (lisp-stream-in-index stream) octet-count)
+			    ;; If we didn't convert all the octets,
+			    ;; adjust the head pointer to indicate
+			    ;; that we have unread octets left.
+			    (decf (lisp::fd-stream-ibuf-head stream)
+				  (- (fd-stream-in-length stream) octet-count))
 			    #+(or debug-frc-sr)
 			    (progn
 			      (format t "new in-index = ~A~%" (lisp-stream-in-index stream))


More information about the cmucl-commit mailing list