diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-12-16 08:44:25 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-12-16 08:44:25 +0000 |
commit | 4e782a618a619d1daab03a61b0e093edacbf92fa (patch) | |
tree | 48304b344c913d9828053839759cde43f7be1d1e /libsylph | |
parent | d6667d16aa4f8b1ebe22226e4c981edfa75b62dd (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')
-rw-r--r-- | libsylph/libsylph-0.def | 1 | ||||
-rw-r--r-- | libsylph/utils.c | 37 | ||||
-rw-r--r-- | libsylph/utils.h | 2 |
3 files changed, 40 insertions, 0 deletions
diff --git a/libsylph/libsylph-0.def b/libsylph/libsylph-0.def index c57d4f9e..ad74b796 100644 --- a/libsylph/libsylph-0.def +++ b/libsylph/libsylph-0.def @@ -669,3 +669,4 @@ EXPORTS xml_tag_new @ 667
xml_truncate_buf @ 668
xml_unescape_str @ 669
+ strcasestr_with_skip_quote @ 670
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; diff --git a/libsylph/utils.h b/libsylph/utils.h index 616a87e0..d062041a 100644 --- a/libsylph/utils.h +++ b/libsylph/utils.h @@ -342,6 +342,8 @@ gint check_line_length (const gchar *str, gchar *strstr_with_skip_quote (const gchar *haystack, const gchar *needle); +gchar *strcasestr_with_skip_quote (const gchar *haystack, + const gchar *needle); gchar *strchr_parenthesis_close (const gchar *str, gchar op, gchar cl); |