--- evolution-2.30.2/widgets/table/e-table-extras.c.orig 2010-09-13 10:32:58.597227009 +0800
+++ evolution-2.30.2/widgets/table/e-table-extras.c 2010-09-13 10:33:05.421403470 +0800
@@ -156,6 +156,129 @@
return FALSE;
}
+
+/**
+ * g_utf8_collate_key_1:
+ * @str: a UTF-8 encoded string.
+ * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
+ *
+ * Converts a string into a collation key that can be compared
+ * with other collation keys produced by the same function using
+ * strcmp().
+ *
+ * The results of comparing the collation keys of two strings
+ * with strcmp() will always be the same as comparing the two
+ * original keys with g_utf8_collate().
+ *
+ * Note that this function depends on the
+ * <link linkend="setlocale">current locale</link>.
+ *
+ * Return value: a newly allocated string. This string should
+ * be freed with g_free() when you are done with it.
+ **/
+gchar *
+g_utf8_collate_key_1 (const gchar *str,
+ gssize len)
+{
+ gchar *result;
+
+#ifdef HAVE_CARBON
+
+ g_return_val_if_fail (str != NULL, NULL);
+ result = carbon_collate_key (str, len);
+
+#elif defined(__STDC_ISO_10646__)
+
+ gsize xfrm_len;
+ gunichar *str_norm;
+ wchar_t *result_wc;
+ gsize i;
+ gsize result_len = 0;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ str_norm = _g_utf8_normalize_wc (str, len, G_NORMALIZE_ALL_COMPOSE);
+
+ xfrm_len = wcsxfrm (NULL, (wchar_t *)str_norm, 0);
+ result_wc = g_new (wchar_t, xfrm_len + 1);
+ wcsxfrm (result_wc, (wchar_t *)str_norm, xfrm_len + 1);
+
+ for (i=0; i < xfrm_len; i++)
+ result_len += utf8_encode (NULL, result_wc[i]);
+
+ result = g_malloc (result_len + 1);
+ result_len = 0;
+ for (i=0; i < xfrm_len; i++)
+ result_len += utf8_encode (result + result_len, result_wc[i]);
+
+ result[result_len] = '\0';
+
+ g_free (result_wc);
+ g_free (str_norm);
+
+ return result;
+#else /* !__STDC_ISO_10646__ */
+
+ gsize xfrm_len;
+ const gchar *charset;
+ gchar *str_norm;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ str_norm = g_utf8_normalize (str, len, G_NORMALIZE_ALL_COMPOSE);
+
+ result = NULL;
+
+ if (g_get_charset (&charset))
+ {
+ if (str_norm)
+ xfrm_len = strxfrm (NULL, str_norm, 0);
+ else xfrm_len = 0;
+ if (xfrm_len >= 0 && xfrm_len < G_MAXINT - 2)
+ {
+ result = g_malloc (xfrm_len + 1);
+ if (str_norm)
+ strxfrm (result, str_norm, xfrm_len + 1);
+ }
+ }
+ else
+ {
+ gchar *str_locale = g_convert (str_norm, -1, charset, "UTF-8", NULL, NULL, NULL);
+
+ if (str_locale)
+ {
+ xfrm_len = strxfrm (NULL, str_locale, 0);
+ if (xfrm_len < 0 || xfrm_len >= G_MAXINT - 2)
+ {
+ g_free (str_locale);
+ str_locale = NULL;
+ }
+ }
+ if (str_locale)
+ {
+ result = g_malloc (xfrm_len + 2);
+ result[0] = 'A';
+ strxfrm (result + 1, str_locale, xfrm_len + 1);
+
+ g_free (str_locale);
+ }
+ }
+
+ if (!result)
+ {
+ xfrm_len = strlen (str_norm);
+ result = g_malloc (xfrm_len + 2);
+ result[0] = 'B';
+ memcpy (result + 1, str_norm, xfrm_len);
+ result[xfrm_len+1] = '\0';
+ }
+
+ g_free (str_norm);
+#endif /* __STDC_ISO_10646__ */
+
+ return result;
+}
+
static gint
e_table_str_case_compare (gconstpointer x, gconstpointer y, gpointer cmp_cache)
{
@@ -175,7 +298,7 @@
_cz = e_table_sorting_utils_lookup_cmp_cache (cmp_cache, _z); \
if (!_cz) { \
gchar *tmp = g_utf8_casefold (_z, -1); \
- _cz = g_utf8_collate_key (tmp, -1); \
+ _cz = g_utf8_collate_key_1 (tmp, -1); \
g_free (tmp); \
\
e_table_sorting_utils_add_to_cmp_cache ( \