fix `string-normalize-nf[k]c' when composed is much smaller then decomposed

For composed normalization, space is initially allocated based on the
decomposed length. The clean up step to avoid wasted space was wrong.
This commit is contained in:
Matthew Flatt 2013-01-23 10:41:48 -05:00
parent 14c970b490
commit 00362a273f
2 changed files with 8 additions and 2 deletions

View File

@ -80,4 +80,10 @@
(test c5 string-normalize-nfkd c5)))
test-strings)
;; Some tests where the composed form is much smaller than decomposed:
(let ()
(define s (list->string (for/list ([i 64]) #\é)))
(test s string-normalize-nfc s)
(test s string-normalize-nfc (string-normalize-nfd s)))
(report-errs)

View File

@ -3891,8 +3891,8 @@ static Scheme_Object *normalize_c(Scheme_Object *o)
s2[j] = 0;
if (len - j > 16) {
s2 = (mzchar *)scheme_malloc_atomic((j + 1) * sizeof(mzchar));
memcpy(s2, s, (j + 1) * sizeof(mzchar));
s = (mzchar *)scheme_malloc_atomic((j + 1) * sizeof(mzchar));
memcpy(s, s2, (j + 1) * sizeof(mzchar));
s2 = s;
}