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 | |
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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | libsylph/libsylph-0.def | 1 | ||||
-rw-r--r-- | libsylph/utils.c | 37 | ||||
-rw-r--r-- | libsylph/utils.h | 2 | ||||
-rw-r--r-- | src/compose.c | 8 |
5 files changed, 50 insertions, 4 deletions
@@ -1,5 +1,11 @@ 2009-12-16 + * libsylph/utils.[ch]: strcasestr_with_skip_quote(): added. + * src/compose.c: compose_reply_set_entry(): ignore case when checking + mailing list post. + +2009-12-16 + * renamed folder-group.png to group.png. * removed unused icons. 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); diff --git a/src/compose.c b/src/compose.c index 09a3f9b6..5b15e289 100644 --- a/src/compose.c +++ b/src/compose.c @@ -1723,11 +1723,11 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo, if (to_ml && compose->ml_post) { /* don't reply to list for confirmation request etc. */ if ((!msginfo->to || - !strstr_with_skip_quote(msginfo->to, - compose->ml_post)) && + !strcasestr_with_skip_quote(msginfo->to, + compose->ml_post)) && (!compose->cc || - !strstr_with_skip_quote(compose->cc, - compose->ml_post))) + !strcasestr_with_skip_quote(compose->cc, + compose->ml_post))) to_ml = FALSE; } if (to_ml && compose->ml_post) { |