aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Steven Schubiger <stsc@refcnt.org> 2014-01-28 11:28:20 +0100
committerGravatar Steven Schubiger <stsc@refcnt.org> 2014-01-28 11:28:20 +0100
commit35856678cb240a60f0b4dd547165504a5186fa5e (patch)
tree74746cd430f1c740fdd2a49710fef18654f89f22
parent0029079c8eb98e122286fb05f8fb798476a1b7a8 (diff)
downloadcolorize-35856678cb240a60f0b4dd547165504a5186fa5e.tar.gz
colorize-35856678cb240a60f0b4dd547165504a5186fa5e.tar.bz2
Quote color string in error messages
-rw-r--r--colorize.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/colorize.c b/colorize.c
index 6c998ab..2f0e8a5 100644
--- a/colorize.c
+++ b/colorize.c
@@ -142,6 +142,7 @@ static const struct color bg_colors[] = {
enum fmts {
FMT_GENERIC,
+ FMT_STRING,
FMT_QUOTE,
FMT_COLOR,
FMT_RANDOM,
@@ -151,6 +152,7 @@ enum fmts {
};
static const char *formats[] = {
"%s", /* generic */
+ "%s '%s'", /* string */
"%s `%s' %s", /* quote */
"%s color '%s' %s", /* color */
"%s color '%s' %s '%s'", /* random */
@@ -514,11 +516,11 @@ process_args (unsigned int arg_cnt, char **arg_strings, bool *bold, const struct
if ((p = strchr (color_string, COLOR_SEP_CHAR)))
{
if (p == color_string)
- vfprintf_fail (formats[FMT_GENERIC], "foreground color missing");
+ vfprintf_fail (formats[FMT_STRING], "foreground color missing in string", color_string);
else if (p == color_string + strlen (color_string) - 1)
- vfprintf_fail (formats[FMT_GENERIC], "background color missing");
+ vfprintf_fail (formats[FMT_STRING], "background color missing in string", color_string);
else if (strchr (++p, COLOR_SEP_CHAR))
- vfprintf_fail (formats[FMT_GENERIC], "one color pair allowed only");
+ vfprintf_fail (formats[FMT_STRING], "one color pair allowed only for string", color_string);
}
str = xstrdup (color_string);