]> git.refcnt.org Git - colorize.git/commitdiff
Quote color string in error messages
authorSteven Schubiger <stsc@refcnt.org>
Tue, 28 Jan 2014 10:28:20 +0000 (11:28 +0100)
committerSteven Schubiger <stsc@refcnt.org>
Tue, 28 Jan 2014 10:28:20 +0000 (11:28 +0100)
colorize.c

index 6c998ab6c5778a3a10eba3d74ddd3a2799fa40c8..2f0e8a58a4c1c8190ef02006319c930c7d90e6d7 100644 (file)
@@ -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);