From e3219c8425e9417ee888dd2aa8b5c826da62edc1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 17 Aug 2011 12:13:17 +0200 Subject: [PATCH] Fixup max decomposition len guarantee Unicode Technical Committee agreed to limit decomposition length to 18 in both cases. Reflect that. --- glib/gunidecomp.c | 9 ++++++--- glib/guniprop.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/glib/gunidecomp.c b/glib/gunidecomp.c index df5a627..fe76ec3 100644 --- a/glib/gunidecomp.c +++ b/glib/gunidecomp.c @@ -696,9 +696,12 @@ g_unichar_compose (gunichar a, * The decomposed sequence is placed in @result. Only up to * @result_len characters are written into @result. The length * of the full decomposition (irrespective of @result_len) is - * returned by the function. For canonical decomposition, a - * result buffer of length 4 is always enough, whereas for - * compatibility decomposition, a buffer of 18 is enough. + * returned by the function. For canonical decomposition, + * currently all decompositions are of length at most 4, but + * this may change in the future (very unlikely though). + * At any rate, Unicode does guarantee that a buffer of length + * 18 is always enough for both compatibility and canonical + * decompositions. * * See UAX#15 * for details. diff --git a/glib/guniprop.c b/glib/guniprop.c index c22035c..55170d4 100644 --- a/glib/guniprop.c +++ b/glib/guniprop.c @@ -855,7 +855,7 @@ real_toupper (const gchar *str, * which could simplify this considerably. */ gsize decomp_len, i; - gunichar decomp[4]; + gunichar decomp[18]; decomp_len = g_unichar_fully_decompose (c, FALSE, decomp, 4); for (i=0; i < decomp_len; i++) -- 2.7.4