From 5e764dcac939cf6e3386234304bfa1bac862f8cf Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Wed, 12 Jul 2000 22:59:25 +0000 Subject: From addressbook/ChangeLog: 2000-07-12 Christopher James Lahey * backend/pas/pas-backend-file.c: Do case insensitive compares. * addressbook/gui/component/addressbook.c: Make quick search search both name and company name. From camel/ChangeLog: 2000-07-12 Christopher James Lahey * camel-folder-search.c, providers/imap/camel-imap-store.c: Changed from strstrcase to e_strstrcase. * string-utils.c, string-utils.h: Removed strstrcase (in favor of e_strstrcase in e-util/e-util.c.) From e-util/ChangeLog: 2000-07-12 Christopher James Lahey * e-util.c, e-util.h: Added e_strstrcase function. svn path=/trunk/; revision=4127 --- e-util/ChangeLog | 4 ++++ e-util/e-util.c | 24 ++++++++++++++++++++++++ e-util/e-util.c-8611 | 24 ++++++++++++++++++++++++ e-util/e-util.h | 3 +++ e-util/e-util.h-29002 | 3 +++ 5 files changed, 58 insertions(+) (limited to 'e-util') diff --git a/e-util/ChangeLog b/e-util/ChangeLog index ba3b0abb95..bf68a708c3 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,7 @@ +2000-07-12 Christopher James Lahey + + * e-util.c, e-util.h: Added e_strstrcase function. + 2000-07-11 Christopher James Lahey * e-canvas-vbox.c: Removed some debugging printfs. diff --git a/e-util/e-util.c b/e-util/e-util.c index 3dea9282c3..c8c60fe1b3 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -305,3 +305,27 @@ e_strsplit (const gchar *string, return str_array; } + +gchar * +e_strstrcase (const gchar *haystack, const gchar *needle) +{ + /* find the needle in the haystack neglecting case */ + gchar *ptr; + guint len; + + g_return_val_if_fail (haystack != NULL, NULL); + g_return_val_if_fail (needle != NULL, NULL); + + len = strlen(needle); + if (len > strlen(haystack)) + return NULL; + + if (len == 0) + return haystack; + + for (ptr = (char *)haystack; *(ptr + len - 1) != '\0'; ptr++) + if (!g_strncasecmp(ptr, needle, len)) + return ptr; + + return NULL; +} diff --git a/e-util/e-util.c-8611 b/e-util/e-util.c-8611 index 3dea9282c3..c8c60fe1b3 100644 --- a/e-util/e-util.c-8611 +++ b/e-util/e-util.c-8611 @@ -305,3 +305,27 @@ e_strsplit (const gchar *string, return str_array; } + +gchar * +e_strstrcase (const gchar *haystack, const gchar *needle) +{ + /* find the needle in the haystack neglecting case */ + gchar *ptr; + guint len; + + g_return_val_if_fail (haystack != NULL, NULL); + g_return_val_if_fail (needle != NULL, NULL); + + len = strlen(needle); + if (len > strlen(haystack)) + return NULL; + + if (len == 0) + return haystack; + + for (ptr = (char *)haystack; *(ptr + len - 1) != '\0'; ptr++) + if (!g_strncasecmp(ptr, needle, len)) + return ptr; + + return NULL; +} diff --git a/e-util/e-util.h b/e-util/e-util.h index ab5325806b..25fd839e19 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -46,6 +46,9 @@ gchar **e_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens); +gchar *e_strstrcase (const gchar *haystack, + const gchar *needle); + void e_marshal_INT__INT_INT_POINTER (GtkObject * object, GtkSignalFunc func, gpointer func_data, GtkArg * args); diff --git a/e-util/e-util.h-29002 b/e-util/e-util.h-29002 index ab5325806b..25fd839e19 100644 --- a/e-util/e-util.h-29002 +++ b/e-util/e-util.h-29002 @@ -46,6 +46,9 @@ gchar **e_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens); +gchar *e_strstrcase (const gchar *haystack, + const gchar *needle); + void e_marshal_INT__INT_INT_POINTER (GtkObject * object, GtkSignalFunc func, gpointer func_data, GtkArg * args); -- cgit