From: Nathan Froyd Date: Mon, 8 Feb 2010 17:42:25 +0000 (+0000) Subject: 1.0.35.8: Fix FILE-POSITION on simple-streams after READ-VECTOR X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=d9dc64d61bfaf26ccaad1f142ed6ecbdfb852504;p=sbcl.git 1.0.35.8: Fix FILE-POSITION on simple-streams after READ-VECTOR Patch ported from CMUCL; independent testcase that doesn't rely on Unixisms added instead of the one from CMUCL. --- diff --git a/NEWS b/NEWS index 827b37a..8de5755 100644 --- 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) diff --git a/contrib/sb-simple-streams/impl.lisp b/contrib/sb-simple-streams/impl.lisp index 014c852..07732f3 100644 --- a/contrib/sb-simple-streams/impl.lisp +++ b/contrib/sb-simple-streams/impl.lisp @@ -584,10 +584,12 @@ (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 index 0000000..40381e2 --- /dev/null +++ b/contrib/sb-simple-streams/lp491087.txt @@ -0,0 +1 @@ +0123 diff --git a/contrib/sb-simple-streams/simple-stream-tests.lisp b/contrib/sb-simple-streams/simple-stream-tests.lisp index 1a31992..2371fc8 100644 --- a/contrib/sb-simple-streams/simple-stream-tests.lisp +++ b/contrib/sb-simple-streams/simple-stream-tests.lisp @@ -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) diff --git a/version.lisp-expr b/version.lisp-expr index e07a2c0..06a2ec2 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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"