From a9200066a941d66607609ba5499471b02b6b750d Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Sat, 22 Aug 2009 15:54:46 +0000 Subject: [PATCH] 1.0.30.48: utf-8 simple-array-nil correctness 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 | 13 ++++++++----- tests/octets.pure.lisp | 11 +++++++++-- version.lisp-expr | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/code/octets.lisp b/src/code/octets.lisp index 4f725a7..b860d0f 100644 --- a/src/code/octets.lisp +++ b/src/code/octets.lisp @@ -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)))))) ;;;; to-string conversions diff --git a/tests/octets.pure.lisp b/tests/octets.pure.lisp index 166d01b..c07b82b 100644 --- a/tests/octets.pure.lisp +++ b/tests/octets.pure.lisp @@ -220,6 +220,13 @@ ) -;; 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))) diff --git a/version.lisp-expr b/version.lisp-expr index 08ce1a5..e1d7ac4 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.30.47" +"1.0.30.48" -- 1.7.10.4