Skip to content
Snippets Groups Projects
Commit 504069ea authored by rtoy's avatar rtoy
Browse files

After doing a READ-VECTOR, FILE-POSITION was returning the wrong value

for simple-streams.  Add a test for this too.

Bug report and fix from Lynn Quam, cmucl-imp, 2004-12-04.
parent c2bd29ee
No related branches found
No related tags found
No related merge requests found
......@@ -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))))
......@@ -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)
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment