]> granicus.if.org Git - neomutt/commitdiff
add enum for 'set' commands
authorRichard Russon <rich@flatcap.org>
Sat, 2 Jun 2018 11:42:55 +0000 (12:42 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 6 Jun 2018 14:29:21 +0000 (15:29 +0100)
The 'set' family of commands are mutually exclusive, so change the
defines to an enumeration.

init.c
init.h

diff --git a/init.c b/init.c
index d07bf488c3af854a289c431f39957b7dfa517074..d5431751f43df23dd87d4a2c4693cbe77aa8da4b 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1976,9 +1976,9 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
   while (MoreArgs(s))
   {
     int query = 0;
-    int unset = data & MUTT_SET_UNSET;
-    int inv = data & MUTT_SET_INV;
-    int reset = data & MUTT_SET_RESET;
+    int unset = (data == MUTT_SET_UNSET);
+    int inv = (data == MUTT_SET_INV);
+    int reset = (data == MUTT_SET_RESET);
     int idx = -1;
     const char *p = NULL;
     const char *myvar = NULL;
@@ -2565,7 +2565,7 @@ static int parse_setenv(struct Buffer *buf, struct Buffer *s,
   char **envp = mutt_envlist_getlist();
 
   bool query = false;
-  bool unset = data & MUTT_SET_UNSET;
+  bool unset = (data == MUTT_SET_UNSET);
 
   if (!MoreArgs(s))
   {
diff --git a/init.h b/init.h
index 15cec68ce9cca783ab10fb8982161143307627e7..03a7def44d1bc80e545093524624a600b66b90cc 100644 (file)
--- a/init.h
+++ b/init.h
 
 // clang-format off
 #ifndef _MAKEDOC
-/* flags to parse_set() */
-#define MUTT_SET_INV   (1 << 0) /**< default is to invert all vars */
-#define MUTT_SET_UNSET (1 << 1) /**< default is to unset all vars */
-#define MUTT_SET_RESET (1 << 2) /**< default is to reset all vars to default */
+enum MuttSetCommand
+{
+  MUTT_SET_SET,   /**< default is to set all vars */
+  MUTT_SET_INV,   /**< default is to invert all vars */
+  MUTT_SET_UNSET, /**< default is to unset all vars */
+  MUTT_SET_RESET, /**< default is to reset all vars to default */
+};
 
 /* forced redraw/resort types + other flags */
 #define R_NONE        0
@@ -4641,8 +4644,8 @@ const struct Command Commands[] = {
   { "score",               mutt_parse_score,       0 },
   { "send-hook",           mutt_parse_hook,        MUTT_SENDHOOK },
   { "send2-hook",          mutt_parse_hook,        MUTT_SEND2HOOK },
-  { "set",                 parse_set,              0 },
-  { "setenv",              parse_setenv,           0 },
+  { "set",                 parse_set,              MUTT_SET_SET },
+  { "setenv",              parse_setenv,           MUTT_SET_SET },
   { "shutdown-hook",       mutt_parse_hook,        MUTT_SHUTDOWNHOOK | MUTT_GLOBALHOOK },
 #ifdef USE_SIDEBAR
   { "sidebar_whitelist",   parse_path_list,        UL &SidebarWhitelist },