]> git.refcnt.org Git - colorize.git/commitdiff
Reduce short options code
authorSteven Schubiger <stsc@refcnt.org>
Tue, 5 Mar 2013 13:22:47 +0000 (14:22 +0100)
committerSteven Schubiger <stsc@refcnt.org>
Tue, 5 Mar 2013 13:22:47 +0000 (14:22 +0100)
colorize.c

index b900a98cc4ecedf7c78efc1c71ebebef8ab50c89..c2d31de1c57ecb7c1a1de117cf4168520682ae07 100644 (file)
@@ -205,6 +205,11 @@ static void vfprintf_fail (const char *, ...);
 static void stack_var (void ***, unsigned int *, unsigned int, void *);
 static void release_var (void **, unsigned int, void **);
 
+#define SET_OPT_TYPE(type) \
+    opt_type = type;       \
+    opt = 0;               \
+    goto PARSE_OPT;        \
+
 extern char *optarg;
 extern int optind;
 
@@ -277,13 +282,9 @@ main (int argc, char **argv)
                 }
               break;
             case 'h':
-              opt_type = OPT_HELP;
-              opt = 0;
-              goto PARSE_OPT;
+              SET_OPT_TYPE (OPT_HELP);
             case 'v':
-              opt_type = OPT_VERSION;
-              opt = 0;
-              goto PARSE_OPT;
+              SET_OPT_TYPE (OPT_VERSION);
             case '?':
               print_help ();
               exit (EXIT_FAILURE);