diff options
author | Steven Schubiger <stsc@refcnt.org> | 2014-01-28 11:28:20 +0100 |
---|---|---|
committer | Steven Schubiger <stsc@refcnt.org> | 2014-01-28 11:28:20 +0100 |
commit | 35856678cb240a60f0b4dd547165504a5186fa5e (patch) | |
tree | 74746cd430f1c740fdd2a49710fef18654f89f22 | |
parent | 0029079c8eb98e122286fb05f8fb798476a1b7a8 (diff) | |
download | colorize-35856678cb240a60f0b4dd547165504a5186fa5e.tar.gz colorize-35856678cb240a60f0b4dd547165504a5186fa5e.tar.bz2 |
Quote color string in error messages
-rw-r--r-- | colorize.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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); |