diff options
author | Sivaiah Nallagatla <snallagatla@novell.com> | 2005-01-27 19:30:20 +0800 |
---|---|---|
committer | Sivaiah Nallagatla <siva@src.gnome.org> | 2005-01-27 19:30:20 +0800 |
commit | b9bc87999f59c9628706ae460c5c1bd5068cebc1 (patch) | |
tree | f9056982d8ba002d215afc2dab20d52d096fd595 | |
parent | dc0c9aef2765fdcf882c5f156e013f679bf265f4 (diff) | |
download | gsoc2013-evolution-b9bc87999f59c9628706ae460c5c1bd5068cebc1.tar.gz gsoc2013-evolution-b9bc87999f59c9628706ae460c5c1bd5068cebc1.tar.zst gsoc2013-evolution-b9bc87999f59c9628706ae460c5c1bd5068cebc1.zip |
case insesitive version of strstr. Used from camel
2005-01-26 Sivaiah Nallagatla <snallagatla@novell.com>
* util/eab-book-util.c (strstrcase) :
case insesitive version of strstr. Used
from camel
(eab_contact_list_from_string) : do case in sensitive
search for "BEGIN:VCARD" and "END:VCARD" to
take care of broken vcards
Fixes #70339
svn path=/trunk/; revision=28578
-rw-r--r-- | addressbook/ChangeLog | 13 | ||||
-rw-r--r-- | addressbook/util/eab-book-util.c | 34 |
2 files changed, 43 insertions, 4 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 1f7d7d0a95..7f2fc21abc 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,16 @@ +2005-01-26 Sivaiah Nallagatla <snallagatla@novell.com> + + * util/eab-book-util.c (strstrcase) : + case insesitive version of strstr. Used + from camel + + (eab_contact_list_from_string) : do case in sensitive + search for "BEGIN:VCARD" and "END:VCARD" to + take care of broken vcards + + Fixes #70339 + + 2005-01-26 Hao Sheng <hao.sheng@sun.com> * gui/contact-list-editor/e-contact-list-editor.c: diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c index a1ff103eeb..473d386f54 100644 --- a/addressbook/util/eab-book-util.c +++ b/addressbook/util/eab-book-util.c @@ -178,6 +178,32 @@ eab_nickname_query (EBook *book, return retval; } +/* Copied from camel_strstrcase */ +static char * +eab_strstrcase (const char *haystack, const char *needle) +{ + /* find the needle in the haystack neglecting case */ + const char *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 (char *) haystack; + + for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++) + if (!g_ascii_strncasecmp (ptr, needle, len)) + return (char *) ptr; + + return NULL; +} + + GList* eab_contact_list_from_string (const char *str) { @@ -217,21 +243,21 @@ eab_contact_list_from_string (const char *str) * would be to have a vcard parsing function that returned the end of the vcard * parsed. Arguably, contact list parsing should all be in libebook's e-vcard.c, * where we can do proper parsing and validation without code duplication. */ - - for (p = strstr (p, "BEGIN:VCARD"); p; p = strstr (q, "\nBEGIN:VCARD")) { + + for (p = eab_strstrcase (p, "BEGIN:VCARD"); p; p = eab_strstrcase (q, "\nBEGIN:VCARD")) { gchar *card_str; if (*p == '\n') p++; - for (q = strstr (p, "END:VCARD"); q; q = strstr (q, "END:VCARD")) { + for (q = eab_strstrcase (p, "END:VCARD"); q; q = eab_strstrcase (q, "END:VCARD")) { gchar *temp; q += 9; temp = q; temp += strspn (temp, "\r\n\t "); - if (*temp == '\0' || !strncmp (temp, "BEGIN:VCARD", 11)) + if (*temp == '\0' || !g_ascii_strncasecmp (temp, "BEGIN:VCARD", 11)) break; /* Found the outer END:VCARD */ } |