1.0.12.31: fix READ-SEQUENCE regression from 1.0.12.22
authorNikodemus Siivola <nikodemus@random-state.net>
Thu, 13 Dec 2007 20:15:32 +0000 (20:15 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Thu, 13 Dec 2007 20:15:32 +0000 (20:15 +0000)
  * Keep track of FRC buffer index properly.

  * Test-case.

src/code/stream.lisp
tests/stream.impure.lisp
version.lisp-expr

index 223a9a1..c3825ac 100644 (file)
@@ -2108,6 +2108,7 @@ benefit of the function GET-OUTPUT-STREAM-STRING.")
                               :start2 %frc-index%
                               :end2 (+ %frc-index% len)))
                    (incf read len)
+                   (incf %frc-index% len)
                    (when (or (eql needed read)
                              (refill-buffer))
                      (done-with-fast-read-char)
index 2db6606..64d589c 100644 (file)
       (when (probe-file test)
         (delete-file test)))))
 
+;;; read-sequence misreported the amount read and lost position
+(let ((string (make-array (* 3 sb-impl::+ansi-stream-in-buffer-length+)
+                          :element-type 'character)))
+  (dotimes (i (length string))
+    (setf (char string i) (code-char (mod i char-code-limit))))
+  (with-open-file (f "read-sequence-character-test-data.tmp"
+                     :if-exists :supersede
+                     :direction :output
+                     :external-format :utf-8)
+    (write-sequence string f))
+  (let ((copy
+         (with-open-file (f "read-sequence-character-test-data.tmp"
+                            :if-does-not-exist :error
+                            :direction :input
+                            :external-format :utf-8)
+           (let ((buffer (make-array 128 :element-type 'character))
+                 (total 0))
+             (with-output-to-string (datum)
+               (loop for n-read = (read-sequence buffer f)
+                     do (write-sequence buffer datum :start 0 :end n-read)
+                        (assert (<= (incf total n-read) (length string)))
+                     while (and (= n-read 128))))))))
+    (assert (equal copy string)))
+  (delete-file "read-sequence-character-test-data.tmp"))
+
 ;;; success
index a4267be..184cce5 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.12.30"
+"1.0.12.31"