From 290443f86f6dc282f0355a9324474507f82a2226 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 31 Jul 2006 04:50:05 +0000 Subject: [PATCH 1/1] Update to reflect Unicode PR #29 (#348694, Nikolai Weibull) 2006-07-31 Behdad Esfahbod * glib/gunidecomp.c (_g_utf8_normalize_wc): Update to reflect Unicode PR #29 (#348694, Nikolai Weibull) * tests/unicode-normalize.c (encode), (test_form): Make output more useful, reporting the unexpected output of the test. --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-12 | 8 ++++++++ glib/gunidecomp.c | 2 +- tests/unicode-normalize.c | 28 ++++++++++++++++++++++++---- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index df9aaf2..e99a6a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-07-31 Behdad Esfahbod + + * glib/gunidecomp.c (_g_utf8_normalize_wc): Update to reflect Unicode + PR #29 (#348694, Nikolai Weibull) + + * tests/unicode-normalize.c (encode), (test_form): Make output more + useful, reporting the unexpected output of the test. + 2006-07-24 Tor Lillqvist * tests/slice-test.c: Use g_get_current_time() insted of diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index df9aaf2..e99a6a3 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +2006-07-31 Behdad Esfahbod + + * glib/gunidecomp.c (_g_utf8_normalize_wc): Update to reflect Unicode + PR #29 (#348694, Nikolai Weibull) + + * tests/unicode-normalize.c (encode), (test_form): Make output more + useful, reporting the unexpected output of the test. + 2006-07-24 Tor Lillqvist * tests/slice-test.c: Use g_get_current_time() insted of diff --git a/glib/gunidecomp.c b/glib/gunidecomp.c index fb3bf3d..21fd7c6 100644 --- a/glib/gunidecomp.c +++ b/glib/gunidecomp.c @@ -442,7 +442,7 @@ _g_utf8_normalize_wc (const gchar *str, int cc = COMBINING_CLASS (wc_buffer[i]); if (i > 0 && - (last_cc == 0 || last_cc != cc) && + (last_cc == 0 || last_cc < cc) && combine (wc_buffer[last_start], wc_buffer[i], &wc_buffer[last_start])) { diff --git a/tests/unicode-normalize.c b/tests/unicode-normalize.c index 9621bf4..9679e25 100644 --- a/tests/unicode-normalize.c +++ b/tests/unicode-normalize.c @@ -42,6 +42,22 @@ const char *names[4] = { "NFKC" }; +static char * +encode (const gchar *input) +{ + GString *result = g_string_new(NULL); + + const gchar *p = input; + while (*p) + { + gunichar c = g_utf8_get_char (p); + g_string_append_printf (result, "%04X ", c); + p = g_utf8_next_char(p); + } + + return g_string_free (result, FALSE); +} + static void test_form (int line, GNormalizeMode mode, @@ -62,9 +78,11 @@ test_form (int line, char *result = g_utf8_normalize (c[i], -1, mode); if (strcmp (result, c[expected]) != 0) { + char *result_raw = encode(result); fprintf (stderr, "\nFailure: %d/%d: %s\n", line, i + 1, raw[5]); - fprintf (stderr, " g_utf8_normalize (%s, %s) != %s\n", - raw[i], names[mode], raw[expected]); + fprintf (stderr, " g_utf8_normalize (%s, %s) != %s but %s\n", + raw[i], names[mode], raw[expected], result_raw); + g_free (result_raw); success = FALSE; } @@ -78,9 +96,11 @@ test_form (int line, char *result = g_utf8_normalize (c[i], -1, mode); if (strcmp (result, c[expected]) != 0) { + char *result_raw = encode(result); fprintf (stderr, "\nFailure: %d/%d: %s\n", line, i, raw[5]); - fprintf (stderr, " g_utf8_normalize (%s, %s) != %s\n", - raw[i], names[mode], raw[expected]); + fprintf (stderr, " g_utf8_normalize (%s, %s) != %s but %s\n", + raw[i], names[mode], raw[expected], result_raw); + g_free (result_raw); success = FALSE; } -- 2.7.4