From: Riad S. Wahby Date: Tue, 3 Jan 2017 03:42:35 +0000 (-0800) Subject: refactor mutt_matches_ignore X-Git-Tag: neomutt-20170113~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=77b4bf395e275da9d07faba1101f2611701fb7de;p=neomutt refactor mutt_matches_ignore Previous function called mutt_matches_ignore is now mutt_matches_list. mutt_matches_ignore now calls mutt_matches_list on Ignored and UnIgnored. Naming is now consistent with functionality; simplified mutt_matches_ignore() call makes writing correct conditionals easier. Fixed invocations in parse.c, copy.c, and url.c --- diff --git a/copy.c b/copy.c index 63475b13b..f4c1945d3 100644 --- a/copy.c +++ b/copy.c @@ -200,9 +200,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags, /* note: CH_FROM takes precedence over header weeding. */ if (!((flags & CH_FROM) && (flags & CH_FORCE_FROM) && this_is_from) && - (flags & CH_WEED) && - mutt_matches_ignore (buf, Ignore) && - !mutt_matches_ignore (buf, UnIgnore)) + (flags & CH_WEED) && mutt_matches_ignore (buf)) continue; if ((flags & CH_WEED_DELIVERED) && ascii_strncasecmp ("Delivered-To:", buf, 13) == 0) diff --git a/mutt.h b/mutt.h index 6e44a4cf3..f00b217be 100644 --- a/mutt.h +++ b/mutt.h @@ -657,7 +657,8 @@ void mutt_free_list (LIST **); void mutt_free_rx_list (RX_LIST **); void mutt_free_spam_list (SPAM_LIST **); LIST *mutt_copy_list (LIST *); -int mutt_matches_ignore (const char *, LIST *); +int mutt_matches_ignore (const char *); +int mutt_matches_list (const char *, LIST *); /* add an element to a list */ LIST *mutt_add_list (LIST *, const char *); diff --git a/muttlib.c b/muttlib.c index 6ef660a4f..d124324ef 100644 --- a/muttlib.c +++ b/muttlib.c @@ -382,7 +382,7 @@ void mutt_free_header (HEADER **h) } /* returns true if the header contained in "s" is in list "t" */ -int mutt_matches_ignore (const char *s, LIST *t) +int mutt_matches_list (const char *s, LIST *t) { for (; t; t = t->next) { @@ -392,6 +392,12 @@ int mutt_matches_ignore (const char *s, LIST *t) return 0; } +/* checks Ignore and UnIgnore using mutt_matches_list */ +int mutt_matches_ignore (const char *s) +{ + return mutt_matches_list (s, Ignore) && !mutt_matches_list (s, UnIgnore); +} + /* prepend the path part of *path to *link */ void mutt_expand_link (char *newpath, const char *path, const char *link) { diff --git a/parse.c b/parse.c index c75a8b1a6..2947c9a34 100644 --- a/parse.c +++ b/parse.c @@ -1347,8 +1347,7 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short /* restore the original line */ line[strlen (line)] = ':'; - if (weed && option (OPTWEED) && mutt_matches_ignore (line, Ignore) - && !mutt_matches_ignore (line, UnIgnore)) + if (weed && option (OPTWEED) && mutt_matches_ignore (line)) goto done; if (last) diff --git a/url.c b/url.c index d0ab57e62..eff1b1e67 100644 --- a/url.c +++ b/url.c @@ -316,7 +316,7 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char *src) * choose to create a message with only a subset of the headers given in * the URL. */ - if (mutt_matches_ignore(tag, MailtoAllow)) + if (mutt_matches_list (tag, MailtoAllow)) { if (!ascii_strcasecmp (tag, "body")) {