From 613453b1095e325149b8d37e5731d415e1d5f9bd Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Thu, 31 Oct 2002 21:30:57 +0000 Subject: merging the gal-2 branch back to the trunk. merging the gal-2 branch back to the trunk. svn path=/trunk/; revision=18471 --- widgets/table/e-table-extras.c | 62 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 9 deletions(-) (limited to 'widgets/table/e-table-extras.c') diff --git a/widgets/table/e-table-extras.c b/widgets/table/e-table-extras.c index 9c5b5fb935..b3c0efa27c 100644 --- a/widgets/table/e-table-extras.c +++ b/widgets/table/e-table-extras.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* +/* * e-table-extras.c - Set of hash table sort of thingies. * Copyright 2000, 2001, Ximian, Inc. * @@ -64,15 +64,25 @@ ete_destroy (GtkObject *object) { ETableExtras *ete = E_TABLE_EXTRAS (object); - g_hash_table_foreach (ete->cells, (GHFunc) cell_hash_free, NULL); - g_hash_table_foreach (ete->compares, (GHFunc) g_free, NULL); - g_hash_table_foreach (ete->searches, (GHFunc) g_free, NULL); - g_hash_table_foreach (ete->pixbufs, (GHFunc) pixbuf_hash_free, NULL); + if (ete->cells) { + g_hash_table_foreach (ete->cells, (GHFunc) cell_hash_free, NULL); + g_hash_table_destroy (ete->cells); + } + + if (ete->compares) { + g_hash_table_foreach (ete->compares, (GHFunc) g_free, NULL); + g_hash_table_destroy (ete->compares); + } + + if (ete->searches) { + g_hash_table_foreach (ete->searches, (GHFunc) g_free, NULL); + g_hash_table_destroy (ete->searches); + } - g_hash_table_destroy (ete->cells); - g_hash_table_destroy (ete->compares); - g_hash_table_destroy (ete->searches); - g_hash_table_destroy (ete->pixbufs); + if (ete->pixbufs) { + g_hash_table_foreach (ete->pixbufs, (GHFunc) pixbuf_hash_free, NULL); + g_hash_table_destroy (ete->pixbufs); + } ete->cells = NULL; ete->compares = NULL; @@ -99,6 +109,40 @@ e_strint_compare(gconstpointer data1, gconstpointer data2) return g_int_compare(GINT_TO_POINTER(int1), GINT_TO_POINTER(int2)); } +/* UTF-8 strncasecmp - not optimized */ + +static gint +g_utf8_strncasecmp (const gchar *s1, + const gchar *s2, + guint n) +{ + gunichar c1, c2; + + g_return_val_if_fail (s1 != NULL && g_utf8_validate (s1, -1, NULL), 0); + g_return_val_if_fail (s2 != NULL && g_utf8_validate (s2, -1, NULL), 0); + + while (n && *s1 && *s2) + { + + n -= 1; + + c1 = g_unichar_tolower (g_utf8_get_char (s1)); + c2 = g_unichar_tolower (g_utf8_get_char (s2)); + + /* Collation is locale-dependent, so this totally fails to do the right thing. */ + if (c1 != c2) + return c1 < c2 ? -1 : 1; + + s1 = g_utf8_next_char (s1); + s2 = g_utf8_next_char (s2); + } + + if (n == 0 || (*s1 == '\0' && *s2 == '\0')) + return 0; + + return *s1 ? 1 : -1; +} + static gboolean e_string_search(gconstpointer haystack, const char *needle) { -- cgit v1.2.3