aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Steven Schubiger <stsc@refcnt.org> 2013-02-19 12:09:52 +0100
committerGravatar Steven Schubiger <stsc@refcnt.org> 2013-02-19 12:09:52 +0100
commit0ed67547ee6210b387dc5743d73a4936c873f526 (patch)
tree3553399ec4caf4d06e16322bff25b031cf84a232
parentefd7a83e87d347f11bfe54e890e62794c97d8865 (diff)
downloadcolorize-0ed67547ee6210b387dc5743d73a4936c873f526.tar.gz
colorize-0ed67547ee6210b387dc5743d73a4936c873f526.tar.bz2
Define color separator once
-rw-r--r--colorize.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/colorize.c b/colorize.c
index 0272494..ea9ca06 100644
--- a/colorize.c
+++ b/colorize.c
@@ -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;