diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-02-21 21:54:32 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-15 02:25:59 +0100 |
commit | 13391893fd91d9fd39dc393e2b90106236783ba7 (patch) | |
tree | 57af7948d4d1e9b8a9ff7e158172f70fd691833b | |
parent | ed7b9191f7a5850140604da890e61a4d6fc9fca6 (diff) | |
download | sparse-13391893fd91d9fd39dc393e2b90106236783ba7.tar.gz |
option: allow handle_switches() to set non-boolean values
The function handle_switches() was designated to set or clear
simple boolean flags but some options, internally, are
non-boolean.
So, extend the function so that it can be used to set non-boolean
values.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | lib.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -418,11 +418,13 @@ static const char *match_option(const char *arg, const char *prefix) } #define OPT_INVERSE 1 +#define OPT_VAL 2 struct flag { const char *name; int *flag; int (*fun)(const char *arg, const char *opt, const struct flag *, int options); unsigned long mask; + int val; }; static int handle_switches(const char *ori, const char *opt, const struct flag *flags) @@ -453,6 +455,8 @@ static int handle_switches(const char *ori, const char *opt, const struct flag * // boolean flag if (opt[0] == '\0' && flags->flag) { + if (flags->mask & OPT_VAL) + val = flags->val; if (flags->mask & OPT_INVERSE) val = !val; *flags->flag = val; |