CMUCL commit: RELEASE-20B-BRANCH src/code (fd-stream.lisp)
Raymond Toy
rtoy at common-lisp.net
Wed Sep 15 17:32:45 CEST 2010
Date: Wednesday, September 15, 2010 @ 11:32:45
Author: rtoy
Path: /project/cmucl/cvsroot/src/code
Tag: RELEASE-20B-BRANCH
Modified: fd-stream.lisp
Merge from trunk to 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.114.2.2 src/code/fd-stream.lisp:1.114.2.3
--- src/code/fd-stream.lisp:1.114.2.2 Wed Aug 18 13:31:51 2010
+++ src/code/fd-stream.lisp Wed Sep 15 11:32:45 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.114.2.2 2010-08-18 17:31:51 rtoy Exp $")
+ "$Header: /project/cmucl/cvsroot/src/code/fd-stream.lisp,v 1.114.2.3 2010-09-15 15:32:45 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -1695,14 +1695,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,
@@ -1721,8 +1722,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