]> git.refcnt.org Git - colorize.git/blobdiff - colorize.c
Assert after find_color_entry() returns
[colorize.git] / colorize.c
index e242c3f89a0df70b976f972e86115890f477cfdb..ff346b0c25e35bacd3707f1d8b784b57e004d0fb 100644 (file)
 # define COLOR_SEP_CHAR '/'
 #endif
 
-#define DEBUG_FILE "debug.txt"
+#if DEBUG
+# define DEBUG_FILE "debug.txt"
+#endif
 
-#define MAX_ATTRIBUTE_CHARS (5 * 2)
+#define MAX_ATTRIBUTE_CHARS (6 * 2)
 
 #define VERSION "0.62"
 
@@ -164,7 +166,7 @@ struct bytes_size {
     char unit;
 };
 
-enum fmts {
+enum {
     FMT_GENERIC,
     FMT_STRING,
     FMT_QUOTE,
@@ -188,7 +190,7 @@ static const char *formats[] = {
 enum { GENERIC, FOREGROUND = 0, BACKGROUND };
 
 static const struct {
-    struct color const *entries;
+    const struct color *entries;
     unsigned int count;
     const char *desc;
 } tables[] = {
@@ -474,6 +476,7 @@ process_opt_attr (const char *p)
                 strncpy (attr_invalid, s, p - s);
                 attr_invalid[p - s] = '\0';
                 vfprintf_fail ("--attr switch attribute '%s' is not valid", attr_invalid);
+                RELEASE_VAR (attr_invalid); /* never reached */
               }
           }
         if (*p)
@@ -701,6 +704,7 @@ process_args (unsigned int arg_cnt, char **arg_strings, char *attr, const struct
         color_name.name = color_name.orig = "default";
 
         find_color_entry (&color_name, FOREGROUND, colors);
+        assert (colors[FOREGROUND]->code != NULL);
       }
 
     process_file_arg (file_string, file, stream);