mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
applied fix for bug #476840.
2007-09-14 15:07:28 Tim Janik <timj@gtk.org> * glib/gutf8.c (g_utf8_strreverse): applied fix for bug #476840. * tests/utf8-pointer.c (test_misc): added test for g_utf8_strreverse(). svn path=/trunk/; revision=5757
This commit is contained in:
parent
f2ee7ca6e8
commit
63828ea746
@ -1,3 +1,9 @@
|
||||
2007-09-14 15:07:28 Tim Janik <timj@gtk.org>
|
||||
|
||||
* glib/gutf8.c (g_utf8_strreverse): applied fix for bug #476840.
|
||||
|
||||
* tests/utf8-pointer.c (test_misc): added test for g_utf8_strreverse().
|
||||
|
||||
2007-09-11 Marco Barisione <marco@barisione.org>
|
||||
|
||||
* glib/Makefile.am:
|
||||
|
@ -1785,9 +1785,8 @@ gchar *
|
||||
g_utf8_strreverse (const gchar *str,
|
||||
gssize len)
|
||||
{
|
||||
gchar *result;
|
||||
gchar *r, *result;
|
||||
const gchar *p;
|
||||
gchar *m, *r, skip;
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (str);
|
||||
@ -1795,9 +1794,9 @@ g_utf8_strreverse (const gchar *str,
|
||||
result = g_new (gchar, len + 1);
|
||||
r = result + len;
|
||||
p = str;
|
||||
while (*p)
|
||||
while (r > result)
|
||||
{
|
||||
skip = g_utf8_skip[*(guchar*)p];
|
||||
gchar *m, skip = g_utf8_skip[*(guchar*) p];
|
||||
r -= skip;
|
||||
for (m = r; skip; skip--)
|
||||
*m++ = *p++;
|
||||
|
@ -90,10 +90,23 @@ test_length (void)
|
||||
g_assert (g_utf8_strlen ("a\340\250\201c", 5) == 3);
|
||||
}
|
||||
|
||||
static void
|
||||
test_misc (void)
|
||||
{
|
||||
char *s;
|
||||
s = g_utf8_strreverse ("1234", -1);
|
||||
g_assert (strcmp (s, "4321") == 0);
|
||||
g_free (s);
|
||||
s = g_utf8_strreverse ("1234", 3);
|
||||
g_assert (strcmp (s, "321") == 0);
|
||||
g_free (s);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
test_utf8 (longline);
|
||||
test_length ();
|
||||
test_misc ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user