diff options
author | Christopher Li <sparse@chrisli.org> | 2014-06-29 00:38:08 -0700 |
---|---|---|
committer | Christopher Li <sparse@chrisli.org> | 2014-06-29 08:59:17 -0700 |
commit | 1db35d0a95caee0f0c57e5dc227822381579620d (patch) | |
tree | 906dbdab4f5b300d85bdffbd86da239ef62e3521 | |
parent | d917662d54ba68d0c3b03e994cb1fa66d7b19c30 (diff) | |
download | sparse-1db35d0a95caee0f0c57e5dc227822381579620d.tar.gz |
Minor clean up for option handling
Remove the loop for short option.
Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r-- | lib.c | 44 |
1 files changed, 24 insertions, 20 deletions
@@ -661,6 +661,14 @@ static char **handle_nostdinc(char *arg, char **next) return next; } +static char **handle_switch_n(char *arg, char **next) +{ + if (!strcmp (arg, "nostdinc")) + return handle_nostdinc(arg, next); + + return next; +} + static char **handle_base_dir(char *arg, char **next) { gcc_base_dir = *++next; @@ -669,6 +677,15 @@ static char **handle_base_dir(char *arg, char **next) return next; } +static char **handle_switch_g(char *arg, char **next) +{ + if (!strcmp (arg, "gcc-base-dir")) + return handle_base_dir(arg, next); + + return next; +} + + static char **handle_version(char *arg, char **next) { printf("%s\n", SPARSE_VERSION); @@ -714,46 +731,33 @@ static char **handle_long_options(char *arg, char **next) s++; } return next; - } static char **handle_switch(char *arg, char **next) { - static struct switches cmd[] = { - { "nostdinc", handle_nostdinc }, - { "gcc-base-dir", handle_base_dir}, - { NULL, NULL } - }; - struct switches *s; - switch (*arg) { + case 'a': return handle_switch_a(arg, next); case 'D': return handle_switch_D(arg, next); case 'E': return handle_switch_E(arg, next); + case 'f': return handle_switch_f(arg, next); + case 'g': return handle_switch_g(arg, next); + case 'G': return handle_switch_G(arg, next); case 'I': return handle_switch_I(arg, next); case 'i': return handle_switch_i(arg, next); case 'M': return handle_switch_M(arg, next); case 'm': return handle_switch_m(arg, next); + case 'n': return handle_switch_n(arg, next); case 'o': return handle_switch_o(arg, next); + case 'O': return handle_switch_O(arg, next); + case 's': return handle_switch_s(arg, next); case 'U': return handle_switch_U(arg, next); case 'v': return handle_switch_v(arg, next); case 'W': return handle_switch_W(arg, next); - case 'O': return handle_switch_O(arg, next); - case 'f': return handle_switch_f(arg, next); - case 'G': return handle_switch_G(arg, next); - case 'a': return handle_switch_a(arg, next); - case 's': return handle_switch_s(arg, next); case '-': return handle_long_options(arg + 1, next); default: break; } - s = cmd; - while (s->name) { - if (!strcmp(s->name, arg)) - return s->fn(arg, next); - s++; - } - /* * Ignore unknown command line options: * they're probably gcc switches |