]> git.refcnt.org Git - colorize.git/blobdiff - colorize.c
colorize 0.54
[colorize.git] / colorize.c
index 8eccfc91f1a0535bcb73f725b620fa4b03e2058e..26eaa2f5ee9092ac7d11862cf3e9b4ae741af604 100644 (file)
 
 #define streq(s1, s2) (strcmp (s1, s2) == 0)
 
-#if DEBUG
-# define xmalloc(size)        malloc_wrap_debug(size,        __FILE__, __LINE__)
-# define xcalloc(nmemb, size) calloc_wrap_debug(nmemb, size, __FILE__, __LINE__)
-# define xrealloc(ptr, size)  realloc_wrap_debug(ptr, size,  __FILE__, __LINE__)
-#else
+#if !DEBUG
 # define xmalloc(size)        malloc_wrap(size)
 # define xcalloc(nmemb, size) calloc_wrap(nmemb, size)
 # define xrealloc(ptr, size)  realloc_wrap(ptr, size)
+#else
+# define xmalloc(size)        malloc_wrap_debug(size,        __FILE__, __LINE__)
+# define xcalloc(nmemb, size) calloc_wrap_debug(nmemb, size, __FILE__, __LINE__)
+# define xrealloc(ptr, size)  realloc_wrap_debug(ptr, size,  __FILE__, __LINE__)
 #endif
 
 #define free_null(ptr) free_wrap((void **)&ptr)
     release_var (vars_list, stacked_vars, (void **)&ptr); \
 } while (false)
 
-#if DEBUG
-# define MEM_ALLOC_FAIL_DEBUG(file, line) do {                                              \
-    fprintf (stderr, "Memory allocation failure in source file %s, line %u\n", file, line); \
-    exit (2);                                                                               \
-} while (false)
-#else
+#if !DEBUG
 # define MEM_ALLOC_FAIL() do {                                         \
     fprintf (stderr, "%s: memory allocation failure\n", program_name); \
     exit (2);                                                          \
 } while (false)
+#else
+# define MEM_ALLOC_FAIL_DEBUG(file, line) do {                                              \
+    fprintf (stderr, "Memory allocation failure in source file %s, line %u\n", file, line); \
+    exit (2);                                                                               \
+} while (false)
 #endif
 
 #define ABORT_TRACE()                                                              \
 
 #define COLOR_SEP_CHAR '/'
 
-#define VERSION "0.53"
+#define VERSION "0.54"
 
 typedef enum { false, true } bool;
 
@@ -507,14 +507,15 @@ process_args (unsigned int arg_cnt, char **arg_strings, bool *bold, const struct
 
         if (have_file)
           {
+            const char *file_exists = color_string;
             if (file_string)
-              vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), color_string, "cannot be used as color string");
+              vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), file_exists, "cannot be used as color string");
             else
               {
                 if (VALID_FILE_TYPE (mode))
-                  vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), color_string, "must be preceeded by color string");
+                  vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), file_exists, "must be preceeded by color string");
                 else
-                  vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), color_string, "is not a valid file type");
+                  vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), file_exists, "is not a valid file type");
               }
           }
       }
@@ -625,7 +626,7 @@ process_file_arg (const char *file_string, const char **file, FILE **stream)
             FILE *s;
             const char *file = file_string;
             struct stat sb;
-            int errno, ret;
+            int ret;
 
             errno = 0;
             ret = lstat (file, &sb);