From 35856678cb240a60f0b4dd547165504a5186fa5e Mon Sep 17 00:00:00 2001 From: Steven Schubiger Date: Tue, 28 Jan 2014 11:28:20 +0100 Subject: Quote color string in error messages --- colorize.c | 8 +++++--- 1 file 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); -- cgit v1.2.3