]> granicus.if.org Git - neomutt/commitdiff
add: PatternExecFlags for mutt_pattern_exec()
authorRichard Russon <rich@flatcap.org>
Wed, 10 Apr 2019 18:06:40 +0000 (19:06 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 14 Apr 2019 15:44:26 +0000 (16:44 +0100)
The flags were an enum, which wasn't really suitable.

pattern.c
pattern.h

index b31a7d818f8dce5dc43ac56a5e38da69d23d281f..0bacf9b3964236fd89f5e6e77ce8eb03d75e3a12 100644 (file)
--- 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;
index e3c8f530827ff24315eb79cbe663c9eb24f24c74..b326cd6ec6b733f4c8a798229c83ce7a773ff58b 100644 (file)
--- 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);