From 15368dec8372d8f1779e9101e7dc6bf7d357ae1e Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Tue, 20 Dec 2016 16:01:45 +0300 Subject: [PATCH] Fix with-array-data usage in sb-unicode:normalize-string. Check the fill pointer and use the actual start, not 0. --- src/code/target-unicode.lisp | 6 +++--- tests/unicode-misc.pure.lisp | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/code/target-unicode.lisp b/src/code/target-unicode.lisp index 9614c1cc1..ab812d984 100644 --- a/src/code/target-unicode.lisp +++ b/src/code/target-unicode.lisp @@ -596,15 +596,15 @@ disappears when accents are placed on top of it. and NIL otherwise" (t (push char chars) (setf previous-combining-class combining-class)))))) - (sb!kernel:with-array-data ((string string) (start) (end)) - (declare (ignore start)) + (sb!kernel:with-array-data ((string string) (start) (end) + :check-fill-pointer t) (let ((calback (if filter (let ((filter (sb!kernel:%coerce-callable-to-fun filter))) (lambda (char) (when (funcall filter char) (callback char)))) #'callback))) - (loop for i below end + (loop for i from start below end for char = (schar string i) do (decompose-char char compatibility calback)))) diff --git a/tests/unicode-misc.pure.lisp b/tests/unicode-misc.pure.lisp index 80f8abdc0..c272bea31 100644 --- a/tests/unicode-misc.pure.lisp +++ b/tests/unicode-misc.pure.lisp @@ -62,3 +62,11 @@ (assert (sb-unicode:confusable-p (coerce '(#\a #\COMBINING_RING_ABOVE) 'string) (string #\LATIN_SMALL_LETTER_A_WITH_RING_ABOVE)))) + +(with-test (:name :normalize-dispalced) + (assert (equal (sb-unicode:normalize-string + (make-array 3 :element-type 'character + :displaced-to "abcd" + :displaced-index-offset 1 + :fill-pointer 2) :nfc) + "bc"))) -- 2.11.4.GIT