1.0.35.8: Fix FILE-POSITION on simple-streams after READ-VECTOR
authorNathan Froyd <froydnj@cs.rice.edu>
Mon, 8 Feb 2010 17:42:25 +0000 (17:42 +0000)
committerNathan Froyd <froydnj@cs.rice.edu>
Mon, 8 Feb 2010 17:42:25 +0000 (17:42 +0000)
Patch ported from CMUCL; independent testcase that doesn't rely on Unixisms
added instead of the one from CMUCL.

NEWS
contrib/sb-simple-streams/impl.lisp
contrib/sb-simple-streams/lp491087.txt [new file with mode: 0644]
contrib/sb-simple-streams/simple-stream-tests.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 827b37a..8de5755 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 ;;;; -*- coding: utf-8; fill-column: 78 -*-
 changes relative to sbcl-1.0.35:
+  * bug fix: Fix SB-SIMPLE-STREAMS:READ-VECTOR to correctly set the
+    FILE-POSITION of the stream being read from.  (launchpad bug lp#491087)
   * bug fix: Fix grammer and style issues for the docstrings of
     printer-related variables and functions.  (Thanks to mon_key; launchpad
     bug lp#518696)
index 014c852..07732f3 100644 (file)
                     (index (or start 0) (1+ index))
                     (end (or end (* (length vector) (vector-elt-width vector))))
                     (endian-swap (endian-swap-value vector endian-swap))
-                    (byte (read-byte-internal encap nil nil t)
-                          (read-byte-internal 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 (read-byte-internal encap nil nil flag)))
+                  (unless byte
+                    (return index))
+                  (setf (bref vector (logxor index endian-swap)) byte)))))))
     ((or ansi-stream fundamental-stream)
      (unless (typep vector '(or string
                              (simple-array (signed-byte 8) (*))
diff --git a/contrib/sb-simple-streams/lp491087.txt b/contrib/sb-simple-streams/lp491087.txt
new file mode 100644 (file)
index 0000000..40381e2
--- /dev/null
@@ -0,0 +1 @@
+0123
index 1a31992..2371fc8 100644 (file)
@@ -930,3 +930,22 @@ Nothing to see here, move along.")
                        :external-format :utf-8)
         (char-code (read-char s))))
   196)
+
+;; launchpad bug #491087
+
+(deftest lp491087
+    (labels ((read-big-int (stream)
+               (let ((b (make-array 1 :element-type '(signed-byte 32)
+                                    :initial-element 0)))
+                 (declare (dynamic-extent b))
+                 (sb-simple-streams::read-vector b stream
+                                                 :endian-swap :network-order)
+                 (aref b 0))))
+      (with-open-file (stream "lp491087.txt" :class 'file-simple-stream)
+        (let* ((start (file-position stream))
+               (integer (read-big-int stream))
+               (end (file-position stream)))
+          (and (= start 0)
+               (= integer #x30313233)
+               (= end 4)))))
+  T)
index e07a2c0..06a2ec2 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.35.7"
+"1.0.35.8"