diff --git a/pcl/simple-streams/impl.lisp b/pcl/simple-streams/impl.lisp index 5217c4f6435a746ecacc26b7b73b00e5917ccead..9a7a7e8eebe53e49bcd1fbfce2f85fc787f5a768 100644 --- a/pcl/simple-streams/impl.lisp +++ b/pcl/simple-streams/impl.lisp @@ -5,7 +5,7 @@ ;;; domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/simple-streams/impl.lisp,v 1.6 2004/07/11 03:49:33 rtoy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/simple-streams/impl.lisp,v 1.7 2004/12/06 17:07:05 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -624,13 +624,16 @@ (index (or start 0) (1+ index)) (end (or end (* (length vector) (vector-elt-width vector)))) (endian-swap (endian-swap-value vector endian-swap)) - (byte (funcall j-read-byte encap nil nil t) - (funcall j-read-byte encap nil nil nil))) - ((or (null byte) (>= index end)) index) - (setf (bref vector (logxor index endian-swap)) byte))))) + (flag t nil)) + ((>= index end) index) + (let ((byte (funcall j-read-byte encap nil nil flag))) + (unless byte (return index)) + (setf (bref vector (logxor index endian-swap)) byte)))))) + ((or lisp-stream fundamental-stream) (unless (typep vector '(or string (simple-array (signed-byte 8) (*)) (simple-array (unsigned-byte 8) (*)))) (error "Wrong vector type for read-vector on stream not of type simple-stream.")) (read-sequence vector stream :start (or start 0) :end end)))) + diff --git a/pcl/simple-streams/rt/simple-streams-test.lisp b/pcl/simple-streams/rt/simple-streams-test.lisp index 81430c1344799411a14277f6aa17799a3c01d512..a1d636e7a8ef868b6fede76e558b3b700aadceda 100644 --- a/pcl/simple-streams/rt/simple-streams-test.lisp +++ b/pcl/simple-streams/rt/simple-streams-test.lisp @@ -411,3 +411,20 @@ result) t) + +;;; From Lynn Quam, cmucl-imp, 2004-12-04: After doing a READ-VECTOR, +;;; FILE-POSITION returns the wrong value. + +(deftest file-position-6 + ;; Test the file-position is write. + (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))) + (buf2 (make-array 100 :element-type '(unsigned-byte 8))) + (n1 (stream:read-vector buf1 st1)) + (n2 (read-sequence buf2 st2))) + (list n1 (file-position st1) + n2 (file-position st2))))) + (100 100 100 100) + ) +