mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-20 00:47:52 +02:00
If a character can't be converted, don't replace it with a NUL byte, but
2006-08-05 Matthias Clasen <mclasen@redhat.com> * glib/guniprop.c (g_unichar_toupper, g_unichar_tolower) (real_toupper, real_tolower): If a character can't be converted, don't replace it with a NUL byte, but leave it unchanged. (#348491, Nikolai Weibull) * tests/unicode-caseconv.c: Adapt to this change. * tests/unicode-caseconv.c (main): Add a comment to point out a quirk in the test data that we are working around here.
This commit is contained in:
committed by
Matthias Clasen
parent
ce2d5c4b0c
commit
994d642cde
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2006-08-05 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/guniprop.c (g_unichar_toupper, g_unichar_tolower)
|
||||||
|
(real_toupper, real_tolower): If a character can't be converted,
|
||||||
|
don't replace it with a NUL byte, but leave it unchanged.
|
||||||
|
(#348491, Nikolai Weibull)
|
||||||
|
|
||||||
|
* tests/unicode-caseconv.c: Adapt to this change.
|
||||||
|
|
||||||
|
* tests/unicode-caseconv.c (main): Add a comment to point out
|
||||||
|
a quirk in the test data that we are working around here.
|
||||||
|
|
||||||
2006-07-31 Behdad Esfahbod <behdad@gnome.org>
|
2006-07-31 Behdad Esfahbod <behdad@gnome.org>
|
||||||
|
|
||||||
* glib/guniprop.c (g_unichar_isxdigit): Make it only accept those
|
* glib/guniprop.c (g_unichar_isxdigit): Make it only accept those
|
||||||
|
@@ -1,3 +1,15 @@
|
|||||||
|
2006-08-05 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/guniprop.c (g_unichar_toupper, g_unichar_tolower)
|
||||||
|
(real_toupper, real_tolower): If a character can't be converted,
|
||||||
|
don't replace it with a NUL byte, but leave it unchanged.
|
||||||
|
(#348491, Nikolai Weibull)
|
||||||
|
|
||||||
|
* tests/unicode-caseconv.c: Adapt to this change.
|
||||||
|
|
||||||
|
* tests/unicode-caseconv.c (main): Add a comment to point out
|
||||||
|
a quirk in the test data that we are working around here.
|
||||||
|
|
||||||
2006-07-31 Behdad Esfahbod <behdad@gnome.org>
|
2006-07-31 Behdad Esfahbod <behdad@gnome.org>
|
||||||
|
|
||||||
* glib/guniprop.c (g_unichar_isxdigit): Make it only accept those
|
* glib/guniprop.c (g_unichar_isxdigit): Make it only accept those
|
||||||
|
@@ -509,7 +509,12 @@ g_unichar_toupper (gunichar c)
|
|||||||
return g_utf8_get_char (p);
|
return g_utf8_get_char (p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return val ? val : c;
|
{
|
||||||
|
/* Some lowercase letters, e.g., U+000AA, FEMININE ORDINAL INDICATOR,
|
||||||
|
* do not have an uppercase equivalent, in which case val will be
|
||||||
|
* zero. */
|
||||||
|
return val ? val : c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (t == G_UNICODE_TITLECASE_LETTER)
|
else if (t == G_UNICODE_TITLECASE_LETTER)
|
||||||
{
|
{
|
||||||
@@ -546,7 +551,11 @@ g_unichar_tolower (gunichar c)
|
|||||||
return g_utf8_get_char (p);
|
return g_utf8_get_char (p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return val ? val : c;
|
{
|
||||||
|
/* Not all uppercase letters are guaranteed to have a lowercase
|
||||||
|
* equivalent. If this is the case, val will be zero. */
|
||||||
|
return val ? val : c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (t == G_UNICODE_TITLECASE_LETTER)
|
else if (t == G_UNICODE_TITLECASE_LETTER)
|
||||||
{
|
{
|
||||||
@@ -825,7 +834,10 @@ real_toupper (const gchar *str,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len += g_unichar_to_utf8 (val, out_buffer ? out_buffer + len : NULL);
|
/* Some lowercase letters, e.g., U+000AA, FEMININE ORDINAL INDICATOR,
|
||||||
|
* do not have an uppercase equivalent, in which case val will be
|
||||||
|
* zero. */
|
||||||
|
len += g_unichar_to_utf8 (val ? val : c, out_buffer ? out_buffer + len : NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1012,7 +1024,9 @@ real_tolower (const gchar *str,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len += g_unichar_to_utf8 (val, out_buffer ? out_buffer + len : NULL);
|
/* Not all uppercase letters are guaranteed to have a lowercase
|
||||||
|
* equivalent. If this is the case, val will be zero. */
|
||||||
|
len += g_unichar_to_utf8 (val ? val : c, out_buffer ? out_buffer + len : NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -16,6 +16,7 @@ int main (int argc, char **argv)
|
|||||||
char *filename;
|
char *filename;
|
||||||
const char *locale;
|
const char *locale;
|
||||||
const char *test;
|
const char *test;
|
||||||
|
const char *expected;
|
||||||
char *convert;
|
char *convert;
|
||||||
char *current_locale = setlocale (LC_CTYPE, NULL);
|
char *current_locale = setlocale (LC_CTYPE, NULL);
|
||||||
gint result = 0;
|
gint result = 0;
|
||||||
@@ -57,20 +58,30 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
test = strings[1];
|
test = strings[1];
|
||||||
|
|
||||||
|
/* gen-casemap-txt.pl uses an empty string when a single character
|
||||||
|
* doesn't have an equivalent in a particular case; since that behavior
|
||||||
|
* is nonsense for multicharacter strings, it would make more sense
|
||||||
|
* to put the expected result .. the original character unchanged. But
|
||||||
|
* for now, we just work around it here and take the empty string to mean
|
||||||
|
* "same as original"
|
||||||
|
*/
|
||||||
|
|
||||||
convert = g_utf8_strup (test, -1);
|
convert = g_utf8_strup (test, -1);
|
||||||
if (strcmp (convert, strings[4]) != 0)
|
expected = strings[4][0] ? strings[4] : test;
|
||||||
|
if (strcmp (convert, expected) != 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Failure: toupper(%s) == %s, should have been %s\n",
|
fprintf (stderr, "Failure: toupper(%s) == %s, should have been %s\n",
|
||||||
test, convert, strings[4]);
|
test, convert, expected);
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
g_free (convert);
|
g_free (convert);
|
||||||
|
|
||||||
convert = g_utf8_strdown (test, -1);
|
convert = g_utf8_strdown (test, -1);
|
||||||
if (strcmp (convert, strings[2]) != 0)
|
expected = strings[2][0] ? strings[2] : test;
|
||||||
|
if (strcmp (convert, expected) != 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Failure: tolower(%s) == %s, should have been %s\n",
|
fprintf (stderr, "Failure: tolower(%s) == %s, should have been %s\n",
|
||||||
test, convert, strings[2]);
|
test, convert, expected);
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
g_free (convert);
|
g_free (convert);
|
||||||
|
Reference in New Issue
Block a user