From fc50916589a300e49183b5ee598e64ca28d0bd9a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 9 Oct 2018 00:39:42 -0400 Subject: [PATCH] Remove deprecated decompose_compatibility stuff --- src/hb-glib.cc | 31 +----------------------------- src/hb-icu.cc | 33 +------------------------------- src/hb-ucdn.cc | 8 +------- test/api/test-unicode.c | 51 ------------------------------------------------- 4 files changed, 3 insertions(+), 120 deletions(-) diff --git a/src/hb-glib.cc b/src/hb-glib.cc index 152601f..fab3cdd 100644 --- a/src/hb-glib.cc +++ b/src/hb-glib.cc @@ -328,36 +328,7 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, return ret; } -static unsigned int -hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t u, - hb_codepoint_t *decomposed, - void *user_data HB_UNUSED) -{ -#if GLIB_CHECK_VERSION(2,29,12) - return g_unichar_fully_decompose (u, true, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN); -#endif - - /* If the user doesn't have GLib >= 2.29.12 we have to perform - * a round trip to UTF-8 and the associated memory management dance. */ - gchar utf8[6]; - gchar *utf8_decomposed, *c; - gsize utf8_len, utf8_decomposed_len, i; - - /* Convert @u to UTF-8 and normalise it in NFKD mode. This performs the compatibility decomposition. */ - utf8_len = g_unichar_to_utf8 (u, utf8); - utf8_decomposed = g_utf8_normalize (utf8, utf8_len, G_NORMALIZE_NFKD); - utf8_decomposed_len = g_utf8_strlen (utf8_decomposed, -1); - - assert (utf8_decomposed_len <= HB_UNICODE_MAX_DECOMPOSITION_LEN); - - for (i = 0, c = utf8_decomposed; i < utf8_decomposed_len; i++, c = g_utf8_next_char (c)) - *decomposed++ = g_utf8_get_char (c); - - g_free (utf8_decomposed); - - return utf8_decomposed_len; -} +#define hb_glib_unicode_decompose_compatibility nullptr #ifdef HB_USE_ATEXIT diff --git a/src/hb-icu.cc b/src/hb-icu.cc index 784a25f..8dbeadd 100644 --- a/src/hb-icu.cc +++ b/src/hb-icu.cc @@ -292,39 +292,8 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, return ret; } -static unsigned int -hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t u, - hb_codepoint_t *decomposed, - void *user_data HB_UNUSED) -{ - UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1]; - unsigned int len; - int32_t utf32_len; - hb_bool_t err; - UErrorCode icu_err; - - /* Copy @u into a UTF-16 array to be passed to ICU. */ - len = 0; - err = false; - U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), u, err); - if (err) - return 0; +#define hb_icu_unicode_decompose_compatibility nullptr - /* Normalise the codepoint using NFKD mode. */ - icu_err = U_ZERO_ERROR; - len = unorm2_normalize (unorm2_getNFKDInstance (&icu_err), utf16, len, normalized, ARRAY_LENGTH (normalized), &icu_err); - if (U_FAILURE (icu_err)) - return 0; - - /* Convert the decomposed form from UTF-16 to UTF-32. */ - icu_err = U_ZERO_ERROR; - u_strToUTF32 ((UChar32*) decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN, &utf32_len, normalized, len, &icu_err); - if (U_FAILURE (icu_err)) - return 0; - - return utf32_len; -} #ifdef HB_USE_ATEXIT static void free_static_icu_funcs (void); diff --git a/src/hb-ucdn.cc b/src/hb-ucdn.cc index 2f06a98..3edd17e 100644 --- a/src/hb-ucdn.cc +++ b/src/hb-ucdn.cc @@ -224,13 +224,7 @@ hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs HB_UNUSED, return ucdn_decompose(ab, a, b); } -static unsigned int -hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t u, hb_codepoint_t *decomposed, - void *user_data HB_UNUSED) -{ - return ucdn_compat_decompose(u, decomposed); -} +#define hb_ucdn_decompose_compatibility nullptr #ifdef HB_USE_ATEXIT diff --git a/test/api/test-unicode.c b/test/api/test-unicode.c index 85546bc..6195bb2 100644 --- a/test/api/test-unicode.c +++ b/test/api/test-unicode.c @@ -722,7 +722,6 @@ test_unicode_normalization (gconstpointer user_data) { hb_unicode_funcs_t *uf = (hb_unicode_funcs_t *) user_data; gunichar a, b, ab; - hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN]; /* Test compose() */ @@ -785,56 +784,6 @@ test_unicode_normalization (gconstpointer user_data) g_assert (hb_unicode_decompose (uf, 0xD4CC, &a, &b) && a == 0x1111 && b == 0x1171); g_assert (hb_unicode_decompose (uf, 0xCE31, &a, &b) && a == 0xCE20 && b == 0x11B8); g_assert (hb_unicode_decompose (uf, 0xCE20, &a, &b) && a == 0x110E && b == 0x1173); - - - /* Test decompose_compatibility() */ - - /* Not decomposable */ - g_assert (hb_unicode_decompose_compatibility (uf, 0x0041, decomposed) == 0); - g_assert (hb_unicode_decompose_compatibility (uf, 0x1F632, decomposed) == 0); - - /* Singletons */ - g_assert (hb_unicode_decompose_compatibility (uf, 0x00B5, decomposed) == 1 && decomposed[0] == 0x03BC); - g_assert (hb_unicode_decompose_compatibility (uf, 0x03D6, decomposed) == 1 && decomposed[0] == 0x03C0); - - /* Arabic compatibility */ - g_assert (hb_unicode_decompose_compatibility (uf, 0xFB54, decomposed) == 1 && decomposed[0] == 0x067B); - - /* Longest decomposition ever */ - g_assert (18 <= HB_UNICODE_MAX_DECOMPOSITION_LEN); - g_assert (hb_unicode_decompose_compatibility (uf, 0xFDFA, decomposed) == 18 && decomposed[17] == 0x0645); - - /* Note: we deliberately don't test characters that have canonical decompositions but no - * compatibility decomposition against the decompose_compatibility() function as that we - * leave up to implementations (for now). */ - - /* Spaces */ - g_assert (hb_unicode_decompose_compatibility (uf, 0x2002, decomposed) == 1 && decomposed[0] == 0x0020); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2003, decomposed) == 1 && decomposed[0] == 0x0020); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2004, decomposed) == 1 && decomposed[0] == 0x0020); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2005, decomposed) == 1 && decomposed[0] == 0x0020); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2006, decomposed) == 1 && decomposed[0] == 0x0020); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2008, decomposed) == 1 && decomposed[0] == 0x0020); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2009, decomposed) == 1 && decomposed[0] == 0x0020); - g_assert (hb_unicode_decompose_compatibility (uf, 0x200A, decomposed) == 1 && decomposed[0] == 0x0020); - - /* Pairs */ - g_assert (hb_unicode_decompose_compatibility (uf, 0x0587, decomposed) == 2 && - decomposed[0] == 0x0565 && decomposed[1] == 0x0582); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2017, decomposed) == 2 && - decomposed[0] == 0x0020 && decomposed[1] == 0x0333); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2025, decomposed) == 2 && - decomposed[0] == 0x002E && decomposed[1] == 0x002E); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2033, decomposed) == 2 && - decomposed[0] == 0x2032 && decomposed[1] == 0x2032); - - /* Triples */ - g_assert (hb_unicode_decompose_compatibility (uf, 0x2026, decomposed) == 3 && - decomposed[0] == 0x002E && decomposed[1] == 0x002E && decomposed[2] == 0x002E); - g_assert (hb_unicode_decompose_compatibility (uf, 0x2034, decomposed) == 3 && - decomposed[0] == 0x2032 && decomposed[1] == 0x2032 && decomposed[2] == 0x2032); - g_assert (hb_unicode_decompose_compatibility (uf, 0x213B, decomposed) == 3 && - decomposed[0] == 0x0046 && decomposed[1] == 0x0041 && decomposed[2] == 0x0058); } -- 2.7.4