aboutsummaryrefslogtreecommitdiff
path: root/libsylph/utils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-12-16 08:44:25 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-12-16 08:44:25 +0000
commit4e782a618a619d1daab03a61b0e093edacbf92fa (patch)
tree48304b344c913d9828053839759cde43f7be1d1e /libsylph/utils.c
parentd6667d16aa4f8b1ebe22226e4c981edfa75b62dd (diff)
ignore case when checking mailing list post.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2396 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r--libsylph/utils.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 62ab6aec..88b2fafb 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -1396,6 +1396,43 @@ gchar *strstr_with_skip_quote(const gchar *haystack, const gchar *needle)
return NULL;
}
+gchar *strcasestr_with_skip_quote(const gchar *haystack, const gchar *needle)
+{
+ register guint haystack_len, needle_len;
+ gboolean in_squote = FALSE, in_dquote = FALSE;
+
+ haystack_len = strlen(haystack);
+ needle_len = strlen(needle);
+
+ if (haystack_len < needle_len || needle_len == 0)
+ return NULL;
+
+ while (haystack_len >= needle_len) {
+ if (!in_squote && !in_dquote &&
+ !g_ascii_strncasecmp(haystack, needle, needle_len))
+ return (gchar *)haystack;
+
+ /* 'foo"bar"' -> foo"bar"
+ "foo'bar'" -> foo'bar' */
+ if (*haystack == '\'') {
+ if (in_squote)
+ in_squote = FALSE;
+ else if (!in_dquote)
+ in_squote = TRUE;
+ } else if (*haystack == '\"') {
+ if (in_dquote)
+ in_dquote = FALSE;
+ else if (!in_squote)
+ in_dquote = TRUE;
+ }
+
+ haystack++;
+ haystack_len--;
+ }
+
+ return NULL;
+}
+
gchar *strchr_parenthesis_close(const gchar *str, gchar op, gchar cl)
{
const gchar *p;