1.0.30.48: utf-8 simple-array-nil correctness
authorChristophe Rhodes <csr21@cantab.net>
Sat, 22 Aug 2009 15:54:46 +0000 (15:54 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Sat, 22 Aug 2009 15:54:46 +0000 (15:54 +0000)
If an empty range of a simple-array-nil is requested for conversion, we
should return an empty octet sequence, not blow up.

src/code/octets.lisp
tests/octets.pure.lisp
version.lisp-expr

index 4f725a7..b860d0f 100644 (file)
@@ -423,13 +423,16 @@ one-past-the-end"
                        finally (return array)))))))
       #!+sb-unicode
       ((simple-array base-char (*))
-       ;; On unicode builds BASE-STRINGs are limited to ASCII range, so we can take
-       ;; a fast path -- and get benefit of the element type information. On non-unicode
-       ;; build BASE-CHAR == CHARACTER.
+       ;; On unicode builds BASE-STRINGs are limited to ASCII range,
+       ;; so we can take a fast path -- and get benefit of the element
+       ;; type information. On non-unicode build BASE-CHAR ==
+       ;; CHARACTER.
        (ascii-bash))
       ((simple-array nil (*))
-       ;; Just get the error...
-       (aref string sstart)))))
+       (if (= send sstart)
+           (make-array 0 :element-type '(unsigned-byte 8))
+           ;; Just get the error...
+           (aref string sstart))))))
 \f
 ;;;; to-string conversions
 
index 166d01b..c07b82b 100644 (file)
 
 )
 
-;; regression test: STRING->UTF8 didn't properly handle a non-zero
-;; START argument.
+;;; regression test: STRING->UTF8 didn't properly handle a non-zero
+;;; START argument.
 (assert (equalp #(50) (string-to-octets "42" :start 1 :external-format :utf-8)))
+
+;;; STRING->UTF8 should cope with NIL strings if a null range is required
+(assert (equalp #() (string-to-octets "" :external-format :utf-8)))
+(assert (equalp #() (string-to-octets (make-array 0 :element-type nil)
+                                      :external-format :utf-8)))
+(assert (equalp #() (string-to-octets (make-array 5 :element-type nil)
+                                      :start 3 :end 3 :external-format :utf-8)))
index 08ce1a5..e1d7ac4 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.30.47"
+"1.0.30.48"