1.0.1.11:
authorJuho Snellman <jsnell@iki.fi>
Mon, 8 Jan 2007 02:36:23 +0000 (02:36 +0000)
committerJuho Snellman <jsnell@iki.fi>
Mon, 8 Jan 2007 02:36:23 +0000 (02:36 +0000)
        1.0.1.6 caused an error to be signaled for READ/WRITE-SEQUENCE
        on unsigned-byte vectors and bivalent streams, which broke
        ASDF-INSTALL. (Reported by Josip Gracin)

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

index db0b3e7..609df65 100644 (file)
                    (+ start bytes-read)
                    end))
              (let ((read-function
-                    (if (subtypep (stream-element-type stream) 'character)
+                    (if (subtypep (array-element-type data) 'character)
                         #'ansi-stream-read-char
                         #'ansi-stream-read-byte)))
                (do ((i offset-start (1+ i)))
          (labels
              ((output-seq-in-loop ()
                 (let ((write-function
-                       (if (subtypep (stream-element-type stream) 'character)
+                       (if (subtypep (array-element-type data) 'character)
                            (ansi-stream-out stream)
                            (ansi-stream-bout stream))))
                   (do ((i offset-start (1+ i)))
index 78e331b..e7036b2 100644 (file)
     (read-sequence sequence stream)
     (assert (equalp sequence #(-1)))))
 
+  ;; A bivalent stream can be read to a unsigned-byte vector or a
+  ;; string
+
+  (let ((sequence (make-array 1 :element-type '(unsigned-byte 8))))
+    (with-open-file (stream pathname
+                            :direction :input
+                            :element-type :default)
+      (read-sequence sequence stream)
+      (assert (equalp sequence #(255)))))
+
+  (let ((sequence (make-array 1 :element-type 'character)))
+    (with-open-file (stream pathname
+                            :direction :input
+                            :external-format :latin-1
+                            :element-type :default)
+      (read-sequence sequence stream)
+      (assert (equalp sequence #(#.(code-char 255))))))
+
   ;; Check that a TYPE-ERROR is signalled for incompatible (sequence,
   ;; stream) pairs.
 
         (type-error (condition)
           (assert (= (type-error-datum condition) -1))
           (assert (subtypep (type-error-expected-type condition)
-                            '(unsigned-byte 8))))))))
+                            '(unsigned-byte 8)))))))
+
+  ;; Can't read a signed-byte from a bivalent stream
+
+  (let ((sequence (make-array 1 :element-type '(signed-byte 8))))
+    (with-open-file (stream pathname
+                            :direction :input
+                            :element-type :default)
+      (handler-case (progn
+                      (read-sequence sequence stream)
+                      (error "READ-SEQUENCE didn't signal an error"))
+        (type-error (condition)
+          (assert (= (type-error-datum condition) 255))
+          (assert (subtypep (type-error-expected-type condition)
+                            '(signed-byte 8))))))))
+
 \f
 ;;; Check WRITE-SEQUENCE signals a TYPE-ERROR when the stream can't
 ;;; write a sequence element.
 
 (let ((pathname "write-sequence.data")
       (generic-sequence (make-array 1 :initial-contents '(255)))
+      (string (make-array 1 :element-type 'character
+                          :initial-element (code-char 255)))
       (unsigned-sequence (make-array 1
                                      :element-type '(unsigned-byte 8)
                                      :initial-contents '(255)))
                           :element-type '(signed-byte 8))
     (write-sequence signed-sequence stream))
 
+  ;; Bivalent streams on unsigned-byte and strings
+
+  (with-open-file (stream pathname
+                          :direction :output
+                          :if-exists :supersede
+                          :element-type :default)
+    (write-sequence unsigned-sequence stream))
+
+  (with-open-file (stream pathname
+                          :direction :output
+                          :external-format :latin-1
+                          :if-exists :supersede
+                          :element-type :default)
+    (write-sequence string stream))
+
   ;; Check a TYPE-ERROR is signalled for unsigned and signed vectors
   ;; which are incompatible with the stream element type.
   (with-open-file (stream pathname
       (type-error (condition)
         (assert (= (type-error-datum condition) -1))
         (assert (subtypep (type-error-expected-type condition)
+                          '(unsigned-byte 8))))))
+
+  (with-open-file (stream pathname
+                          :direction :output
+                          :if-exists :supersede
+                          :element-type :default)
+    (handler-case (progn
+                    (write-sequence signed-sequence stream)
+                    (error "WRITE-SEQUENCE didn't signal an error"))
+      (type-error (condition)
+        (assert (= (type-error-datum condition) -1))
+        (assert (subtypep (type-error-expected-type condition)
                           '(unsigned-byte 8)))))))
 
 ;;; success
index b1b8a0b..19f21c9 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.1.10"
+"1.0.1.11"