]> git.refcnt.org Git - colorize.git/blobdiff - colorize.c
Declare check target as phony
[colorize.git] / colorize.c
index 36d7a0a228baa62400697051b7cd044a9ad98144..d174a11caa2709eaf694d245d99bb8cdc4e15ba8 100644 (file)
@@ -2,7 +2,7 @@
  * colorize - Read text from standard input stream or file and print
  *            it colorized through use of ANSI escape sequences
  *
- * Copyright (c) 2011-2013 Steven Schubiger
+ * Copyright (c) 2011-2014 Steven Schubiger
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 #define COLOR_SEP_CHAR '/'
 
-#define VERSION "0.52"
+#define VERSION "0.53"
 
-typedef unsigned short bool;
-
-enum { false, true };
+typedef enum { false, true } bool;
 
 struct color_name {
     char *name;
@@ -121,8 +119,8 @@ static const struct color fg_colors[] = {
     { "green",   "32m" },
     { "yellow",  "33m" },
     { "blue",    "34m" },
-    { "cyan",    "35m" },
-    { "magenta", "36m" },
+    { "magenta", "35m" },
+    { "cyan",    "36m" },
     { "white",   "37m" },
     { "default", "39m" },
 };
@@ -133,8 +131,8 @@ static const struct color bg_colors[] = {
     { "green",   "42m" },
     { "yellow",  "43m" },
     { "blue",    "44m" },
-    { "cyan",    "45m" },
-    { "magenta", "46m" },
+    { "magenta", "45m" },
+    { "cyan",    "46m" },
     { "white",   "47m" },
     { "default", "49m" },
 };
@@ -177,6 +175,7 @@ static char *exclude = NULL;
 
 static const char *program_name;
 
+static void print_hint (void);
 static void print_help (void);
 static void print_version (void);
 static void cleanup (void);
@@ -212,6 +211,8 @@ static void release_var (void **, unsigned int, void **);
 extern char *optarg;
 extern int optind;
 
+static int opt_type = 0;
+
 int
 main (int argc, char **argv)
 {
@@ -225,7 +226,7 @@ main (int argc, char **argv)
         OPT_VERSION
     };
 
-    int opt, opt_type = 0;
+    int opt;
     struct option long_opts[] = {
         { "clean",          no_argument,       &opt_type, OPT_CLEAN          },
         { "clean-all",      no_argument,       &opt_type, OPT_CLEAN_ALL      },
@@ -296,7 +297,7 @@ main (int argc, char **argv)
             case 'v':
               SET_OPT_TYPE (OPT_VERSION);
             case '?':
-              print_help ();
+              print_hint ();
               exit (EXIT_FAILURE);
             default: /* never reached */
               ABORT_TRACE ();
@@ -323,8 +324,8 @@ main (int argc, char **argv)
       {
         if (arg_cnt == 0 || arg_cnt > 2)
           {
-            vfprintf_diag ("%u arguments provided, expected 1-2 arguments or option", arg_cnt);
-            print_help ();
+            vfprintf_diag ("%u arguments provided, expected 1-2 arguments or clean option", arg_cnt);
+            print_hint ();
             exit (EXIT_FAILURE);
           }
       }
@@ -340,6 +341,12 @@ main (int argc, char **argv)
     exit (EXIT_SUCCESS);
 }
 
+static void
+print_hint (void)
+{
+    fprintf (stderr, "Type `%s --help' for help screen.\n", program_name);
+}
+
 static void
 print_help (void)
 {