]> git.refcnt.org Git - colorize.git/commitdiff
Eliminate goto
authorSteven Schubiger <stsc@refcnt.org>
Fri, 27 Jan 2017 20:39:10 +0000 (21:39 +0100)
committerSteven Schubiger <stsc@refcnt.org>
Fri, 27 Jan 2017 20:39:10 +0000 (21:39 +0100)
colorize.c

index 70de8488614cd2c2cbb24a8b8740b5c245f2584c..06f448b15e8b7f20734c134d6e3ede2e077ff7cb 100644 (file)
@@ -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);