From 6673622beaad991588e8534556e4946d48944fe4 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Wed, 10 Apr 2019 19:06:40 +0100 Subject: [PATCH] add: PatternExecFlags for mutt_pattern_exec() The flags were an enum, which wasn't really suitable. --- pattern.c | 12 ++++++------ pattern.h | 12 ++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pattern.c b/pattern.c index b31a7d818..0bacf9b39 100644 --- a/pattern.c +++ b/pattern.c @@ -1635,7 +1635,7 @@ cleanup: * @param cache Cached Patterns * @retval true If ALL of the Patterns evaluates to true */ -static bool perform_and(struct PatternHead *pat, enum PatternExecFlag flags, +static bool perform_and(struct PatternHead *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache) { struct Pattern *p = NULL; @@ -1657,7 +1657,7 @@ static bool perform_and(struct PatternHead *pat, enum PatternExecFlag flags, * @param cache Cached Patterns * @retval true If ONE (or more) of the Patterns evaluates to true */ -static int perform_or(struct PatternHead *pat, enum PatternExecFlag flags, +static int perform_or(struct PatternHead *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache) { struct Pattern *p = NULL; @@ -1791,7 +1791,7 @@ static int match_user(int alladdr, struct Address *a1, struct Address *a2) * @retval 1 Success, match found * @retval 0 No match */ -static int match_threadcomplete(struct PatternHead *pat, enum PatternExecFlag flags, +static int match_threadcomplete(struct PatternHead *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t, int left, int up, int right, int down) { @@ -1830,7 +1830,7 @@ static int match_threadcomplete(struct PatternHead *pat, enum PatternExecFlag fl * @retval 0 Pattern did not match * @retval -1 Error */ -static int match_threadparent(struct PatternHead *pat, enum PatternExecFlag flags, +static int match_threadparent(struct PatternHead *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t) { if (!t || !t->parent || !t->parent->message) @@ -1849,7 +1849,7 @@ static int match_threadparent(struct PatternHead *pat, enum PatternExecFlag flag * @retval 0 Pattern did not match * @retval -1 Error */ -static int match_threadchildren(struct PatternHead *pat, enum PatternExecFlag flags, +static int match_threadchildren(struct PatternHead *pat, PatternExecFlags flags, struct Mailbox *m, struct MuttThread *t) { if (!t || !t->child) @@ -1949,7 +1949,7 @@ static int is_pattern_cache_set(int cache_entry) * cache: For repeated matches against the same Header, passing in non-NULL will * store some of the cacheable pattern matches in this structure. */ -int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, +int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache) { int result; diff --git a/pattern.h b/pattern.h index e3c8f5308..b326cd6ec 100644 --- a/pattern.h +++ b/pattern.h @@ -65,13 +65,9 @@ struct Pattern }; SLIST_HEAD(PatternHead, Pattern); -/** - * enum PatternExecFlag - Flags for mutt_pattern_exec() - */ -enum PatternExecFlag -{ - MUTT_MATCH_FULL_ADDRESS = 1, ///< Match the full address -}; +typedef uint8_t PatternExecFlags; ///< Flags for mutt_pattern_exec(), e.g. #MUTT_MATCH_FULL_ADDRESS +#define MUTT_PAT_EXEC_NO_FLAGS 0 ///< No flags are set +#define MUTT_MATCH_FULL_ADDRESS (1 << 0) ///< Match the full address /** * struct PatternCache - Cache commonly-used patterns @@ -149,7 +145,7 @@ enum PatternType MUTT_PAT_MAX, }; -int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, +int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache); struct PatternHead *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer *err); void mutt_check_simple(char *s, size_t len, const char *simple); -- 2.49.0