]> git.refcnt.org Git - colorize.git/blobdiff - colorize.c
Emit more concise error message when config file does not exist
[colorize.git] / colorize.c
index 147f13e2cbbaa550867da764026ab7a81e653d42..d527e5eff4f2f79f0b85b2bb259b69f4518779cd 100644 (file)
@@ -192,18 +192,20 @@ enum {
     FMT_ERROR,
     FMT_FILE,
     FMT_TYPE,
-    FMT_CONF
+    FMT_CONF,
+    FMT_CONF_FILE
 };
 static const char *formats[] = {
-    "%s",                     /* generic */
-    "%s '%s'",                /* string  */
-    "%s `%s' %s",             /* quote   */
-    "%s color '%s' %s",       /* color   */
-    "%s color '%s' %s '%s'",  /* random  */
-    "less than %lu bytes %s", /* error   */
-    "%s: %s",                 /* file    */
-    "%s: %s: %s",             /* type    */
-    "%s: option '%s' %s"      /* conf    */
+    "%s",                     /* generic   */
+    "%s '%s'",                /* string    */
+    "%s `%s' %s",             /* quote     */
+    "%s color '%s' %s",       /* color     */
+    "%s color '%s' %s '%s'",  /* random    */
+    "less than %lu bytes %s", /* error     */
+    "%s: %s",                 /* file      */
+    "%s: %s: %s",             /* type      */
+    "%s: option '%s' %s",     /* conf      */
+    "config file %s: %s"      /* conf file */
 };
 
 enum { GENERIC, FOREGROUND = 0, BACKGROUND };
@@ -391,7 +393,7 @@ main (int argc, char **argv)
           }
         errno = 0;
         if (access (conf_file, F_OK) == -1)
-          vfprintf_fail (formats[FMT_FILE], conf_file, strerror (errno));
+          vfprintf_fail (formats[FMT_CONF_FILE], conf_file, strerror (errno));
       }
 #endif
 #if defined(CONF_FILE_TEST) || !defined(TEST)
@@ -412,14 +414,7 @@ main (int argc, char **argv)
         if (clean && clean_all)
           vfprintf_fail (formats[FMT_GENERIC], "--clean and --clean-all switch are mutually exclusive");
         if (arg_cnt > 1)
-          {
-            const char *const format = "%s %s";
-            const char *const message = "switch cannot be used with more than one file";
-            if (clean)
-              vfprintf_fail (format, "--clean", message);
-            else if (clean_all)
-              vfprintf_fail (format, "--clean-all", message);
-          }
+          vfprintf_fail ("--clean%s switch cannot be used with more than one file", clean_all ? "-all" : "");
         {
           unsigned int i;
           const struct option_set {