From 958325e25ab0a3bdda75919ee88522a0ffa4eebd Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 2 Jun 2018 12:42:55 +0100 Subject: [PATCH] add enum for 'set' commands The 'set' family of commands are mutually exclusive, so change the defines to an enumeration. --- init.c | 8 ++++---- init.h | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/init.c b/init.c index d07bf488c..d5431751f 100644 --- 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 15cec68ce..03a7def44 100644 --- a/init.h +++ b/init.h @@ -51,10 +51,13 @@ // 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 }, -- 2.40.0