]> git.refcnt.org Git - colorize.git/blobdiff - colorize.c
Merge duplicated version printing code
[colorize.git] / colorize.c
index 54f6889fe3c308a74550bc38b335b3d0853a408a..7704c3b8f94af8e2befcdd95f03310d0dc9d5151 100644 (file)
@@ -403,6 +403,12 @@ print_help (void)
 static void
 print_version (void)
 {
+#ifdef HAVE_VERSION
+# include "version.h"
+#else
+    const char *version = NULL;
+#endif
+    const char *version_prefix, *version_string;
     const char *c_flags;
     struct bytes_size bytes_size;
     bool debug;
@@ -416,7 +422,10 @@ print_version (void)
 #else
     debug = false;
 #endif
-    printf ("%s v%s (compiled at %s, %s)\n", "colorize", VERSION, __DATE__, __TIME__);
+    version_prefix = version ? "" : "v";
+    version_string = version ? version : VERSION;
+    printf ("colorize %s%s (compiled at %s, %s)\n", version_prefix, version_string, __DATE__, __TIME__);
+
     printf ("Compiler flags: %s\n", c_flags);
     if (get_bytes_size (BUF_SIZE, &bytes_size))
       {
@@ -1018,7 +1027,7 @@ realloc_wrap_debug (void *ptr, size_t size, const char *file, unsigned int line)
       MEM_ALLOC_FAIL_DEBUG (file, line);
     return p;
 }
-#endif
+#endif /* !DEBUG */
 
 static void
 free_wrap (void **ptr)