[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sorting in glib2



On Wed, 2003-09-03 at 14:35, Marc Matteo wrote:
> 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...

Ok, I think this one is better...

strxfrm behaves differently on OpenBSD than on whatever system this
weirdness was though up (Linux I betcha).  Rather than messing with the
buffers just use strlen instead.  Apps should sort on the full string
now.

Marc
$OpenBSD$
--- glib/gunicollate.c.orig	2002-12-05 12:33:26.000000000 -0800
+++ glib/gunicollate.c	2003-09-03 16:11:35.000000000 -0700
@@ -224,6 +224,8 @@ g_utf8_collate_key (const gchar *str,
   if (g_get_charset (&charset))
     {
       xfrm_len = strxfrm (NULL, str_norm, 0);
+      if (xfrm_len == 0)
+        xfrm_len = strlen (str_norm);
       result = g_malloc (xfrm_len + 1);
       strxfrm (result, str_norm, xfrm_len + 1);
     }
@@ -234,6 +236,8 @@ g_utf8_collate_key (const gchar *str,
       if (str_locale)
 	{
 	  xfrm_len = strxfrm (NULL, str_locale, 0);
+	  if (xfrm_len == 0)
+	    xfrm_len = strlen (str_locale);
 	  result = g_malloc (xfrm_len + 2);
 	  result[0] = 'A';
 	  strxfrm (result + 1, str_locale, xfrm_len + 1);

Visit your host, monkey.org