diff options
author | Steven Schubiger <stsc@refcnt.org> | 2017-01-27 21:39:10 +0100 |
---|---|---|
committer | Steven Schubiger <stsc@refcnt.org> | 2017-01-27 21:39:10 +0100 |
commit | e2557f57e0b36c61f81f12fa3e5eb42b07de91ac (patch) | |
tree | dfca2cd6823c3cd0184e0f3d7b7dfe14bd93e7b2 | |
parent | 0ac4c8c8ec3f28fa2ebfbbe9257f0832154afba9 (diff) | |
download | colorize-e2557f57e0b36c61f81f12fa3e5eb42b07de91ac.tar.gz colorize-e2557f57e0b36c61f81f12fa3e5eb42b07de91ac.tar.bz2 |
Eliminate goto
-rw-r--r-- | colorize.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -339,10 +339,13 @@ main (int argc, char **argv) exit (EXIT_SUCCESS); } -#define SET_OPT_TYPE(type) \ - opt_type = type; \ - opt = 0; \ - goto PARSE_OPT; \ +#define PRINT_HELP_EXIT() \ + print_help (); \ + exit (EXIT_SUCCESS); \ + +#define PRINT_VERSION_EXIT() \ + print_version (); \ + exit (EXIT_SUCCESS); \ extern char *optarg; @@ -352,7 +355,6 @@ process_opts (int argc, char **argv) int opt; while ((opt = getopt_long (argc, argv, "hV", long_opts, NULL)) != -1) { - PARSE_OPT: switch (opt) { case 0: /* long opts */ @@ -383,19 +385,17 @@ process_opts (int argc, char **argv) break; } case OPT_HELP: - print_help (); - exit (EXIT_SUCCESS); + PRINT_HELP_EXIT (); case OPT_VERSION: - print_version (); - exit (EXIT_SUCCESS); + PRINT_VERSION_EXIT (); default: /* never reached */ ABORT_TRACE (); } break; case 'h': - SET_OPT_TYPE (OPT_HELP); + PRINT_HELP_EXIT (); case 'V': - SET_OPT_TYPE (OPT_VERSION); + PRINT_VERSION_EXIT (); case '?': print_hint (); exit (EXIT_FAILURE); |