[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sorting in glib2
The attached patch file should fix sorting in glib2 apps that use
g_utf8_collate_key() to sort lists. It fixes a glib bug on systems
without full locale support (like OpenBSD).
It's not a diff against the port this time, it's a patch file to be
placed into glib2/patches :).
Please test and let me know what you think...
Marc
$OpenBSD$
--- glib/gunicollate.c.orig 2003-09-03 13:07:42.000000000 -0700
+++ glib/gunicollate.c 2003-09-03 13:08:53.000000000 -0700
@@ -224,8 +224,8 @@ g_utf8_collate_key (const gchar *str,
if (g_get_charset (&charset))
{
xfrm_len = strxfrm (NULL, str_norm, 0);
- result = g_malloc (xfrm_len + 1);
- strxfrm (result, str_norm, xfrm_len + 1);
+ result = g_malloc (xfrm_len + 2);
+ strxfrm (result, str_norm, xfrm_len + 2);
}
else
{
@@ -234,9 +234,9 @@ g_utf8_collate_key (const gchar *str,
if (str_locale)
{
xfrm_len = strxfrm (NULL, str_locale, 0);
- result = g_malloc (xfrm_len + 2);
+ result = g_malloc (xfrm_len + 3);
result[0] = 'A';
- strxfrm (result + 1, str_locale, xfrm_len + 1);
+ strxfrm (result + 1, str_locale, xfrm_len + 2);
g_free (str_locale);
}