]> git.refcnt.org Git - colorize.git/commitdiff
Define color separator once
authorSteven Schubiger <stsc@refcnt.org>
Tue, 19 Feb 2013 11:09:52 +0000 (12:09 +0100)
committerSteven Schubiger <stsc@refcnt.org>
Tue, 19 Feb 2013 11:09:52 +0000 (12:09 +0100)
colorize.c

index 027249448ac631cf914225f44ce34941a08d1c8e..ea9ca069b67c4017457f14f2edf9a2ad007b2a01 100644 (file)
@@ -88,6 +88,8 @@
  && (streq (color_names[color2]->name, "none")     \
   || streq (color_names[color2]->name, "default")) \
 
+#define COLOR_SEP_CHAR '/'
+
 #define VERSION "0.49"
 
 typedef unsigned short bool;
@@ -414,7 +416,7 @@ process_options (unsigned int arg_cnt, char **option_strings, bool *bold, const
                     break;
                   }
               }
-            if (matched && *color == '/' && *(color + 1))
+            if (matched && *color == COLOR_SEP_CHAR && *(color + 1))
               color++;
             else
               break;
@@ -431,13 +433,13 @@ process_options (unsigned int arg_cnt, char **option_strings, bool *bold, const
           }
       }
 
-    if ((p = strchr (color_string, '/')))
+    if ((p = strchr (color_string, COLOR_SEP_CHAR)))
       {
         if (p == color_string)
           vfprintf_fail (formats[FMT_GENERIC], "foreground color missing");
         else if (p == color_string + strlen (color_string) - 1)
           vfprintf_fail (formats[FMT_GENERIC], "background color missing");
-        else if (strchr (++p, '/'))
+        else if (strchr (++p, COLOR_SEP_CHAR))
           vfprintf_fail (formats[FMT_GENERIC], "one color pair allowed only");
       }
 
@@ -447,7 +449,7 @@ process_options (unsigned int arg_cnt, char **option_strings, bool *bold, const
     for (index = 0, color = str; *color; index++, color = p)
       {
         char *ch, *sep;
-        if ((sep = strchr (color, '/')))
+        if ((sep = strchr (color, COLOR_SEP_CHAR)))
           {
             *sep = '\0';
             p = sep + 1;