diff --git a/pcl/simple-streams/file.lisp b/pcl/simple-streams/file.lisp index 1786be4fd96dd49b4015e3cb730d3d8f09f95b4c..6c3cdbe6c89dd6040a5d938204075288b8d46449 100644 --- a/pcl/simple-streams/file.lisp +++ b/pcl/simple-streams/file.lisp @@ -5,7 +5,7 @@ ;;; domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/simple-streams/file.lisp,v 1.4 2003/06/26 13:27:42 toy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/simple-streams/file.lisp,v 1.5 2006/12/21 17:53:28 rtoy Rel $") ;;; ;;; ********************************************************************** ;;; @@ -193,7 +193,7 @@ (error "Unable to map file.")) (setf (sm buffer stream) buffer (sm buffpos stream) 0 - (sm buffer-ptr stream) size + (sm buffer-ptr stream) 0 (sm buf-len stream) size) (when (any-stream-instance-flags stream :output) (setf (sm control-out stream) *std-control-out-table*)) diff --git a/pcl/simple-streams/rt/simple-streams-test.lisp b/pcl/simple-streams/rt/simple-streams-test.lisp index a1d636e7a8ef868b6fede76e558b3b700aadceda..6684d718187e810a35a89cb7870ec367c9148165 100644 --- a/pcl/simple-streams/rt/simple-streams-test.lisp +++ b/pcl/simple-streams/rt/simple-streams-test.lisp @@ -416,7 +416,7 @@ ;;; FILE-POSITION returns the wrong value. (deftest file-position-6 - ;; Test the file-position is write. + ;; Test the file-position is right. (with-open-file (st1 "/etc/passwd" :class 'stream:file-simple-stream) (with-open-file (st2 "/etc/passwd" :element-type '(unsigned-byte 8)) (let* ((buf1 (make-array 100 :element-type '(unsigned-byte 8))) @@ -428,3 +428,19 @@ (100 100 100 100) ) +;;; From Madhu, cmucl-imp, 2006-12-16 +(deftest file-position-7 + (with-open-file (st1 "/etc/passwd" :mapped t :class 'stream:file-simple-stream) + (let* ((posn1 (file-position st1)) + (line1 (read-line st1)) + (posn2 (file-position st1))) + (list posn1 (= posn2 (1+ (length line1)))))) + (0 t)) + +(deftest file-position-8 + (with-open-file (st1 "/etc/passwd" :mapped t :class 'stream:file-simple-stream) + (let* ((posn1 (file-position st1)) + (c1 (read-char st1)) + (posn2 (file-position st1))) + (list posn1 posn2))) + (0 1)) diff --git a/pcl/simple-streams/strategy.lisp b/pcl/simple-streams/strategy.lisp index 82844e9acb391400c6cb652db4c658099028fea1..8e0e2327c1e944d662e472dab8c406cbf19d0283 100644 --- a/pcl/simple-streams/strategy.lisp +++ b/pcl/simple-streams/strategy.lisp @@ -5,7 +5,7 @@ ;;; domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/simple-streams/strategy.lisp,v 1.9 2004/07/11 04:34:16 rtoy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/simple-streams/strategy.lisp,v 1.10 2006/12/21 17:53:28 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -210,7 +210,7 @@ (ef (sm external-format stream)) (state (sm oc-state stream))) (flet ((input () - (when (>= buffpos (sm buffer-ptr stream)) + (when (>= buffpos (sm buf-len stream)) (return-from read-char (lisp::eof-or-lose stream eof-error-p eof-value))) (incf (sm last-char-read-size stream)) @@ -319,7 +319,7 @@ ;; if stream is single-channel and mode == 3, flush buffer (if dirty) (do ((buffer (sm buffer stream)) (buffpos (sm buffpos stream)) - (buffer-ptr (sm buffer-ptr stream)) + (buf-len (sm buf-len stream)) (lcrs 0) (ctrl (sm control-in stream)) (ef (sm external-format stream)) @@ -331,9 +331,9 @@ (sm last-char-read-size stream) lcrs (sm oc-state stream) state) (values count nil)) - (declare (type lisp::index buffpos buffer-ptr posn count)) + (declare (type lisp::index buffpos buf-len posn count)) (flet ((input () - (when (>= buffpos buffer-ptr) + (when (>= buffpos buf-len) (return (values count :eof))) (prog1 (bref buffer buffpos) (incf buffpos)