bb9fd936f397 — Sean Farley 12 years ago
fast-status: make PRINT take variadic arguments
1 files changed, 10 insertions(+), 9 deletions(-)

M fast-hg-status.c
M fast-hg-status.c +10 -9
@@ 19,14 19,14 @@ 
 #include <limits.h>
 
 #ifndef DEBUG
-#define PRINT(arg)
+#define PRINT(format, ...) /* arg */
 #else
-#define PRINT(arg) (printf("DEBUG: "), printf arg)
+#define PRINT(format, ...) printf("DEBUG: "); printf(format, ##__VA_ARGS__)
 #endif
 
 void dirty(const char* reason) {
   /* we got here because the repo is modified in some way */
-  PRINT(( "dirty repo reason: %s\n", reason ));
+  PRINT("dirty repo reason: %s\n", reason);
   printf("*");
 }
 

          
@@ 91,16 91,17 @@ int parse_dirstate(const char* hg_path, 
     mtime  = htonl(mtime);
     length = htonl(length);
 
-    PRINT(("[%zu] status: %c\n", i, status));
-    PRINT(("[%zu] mode: %.3o\n", i, mode));
-    PRINT(("[%zu] size: %u\n", i, size));
-    PRINT(("[%zu] mtime: %lld\n", i, (long long)mtime));
-    PRINT(("[%zu] length: %u\n", i, length));
+
+    PRINT("[%zu] status: %c\n", i, status);
+    PRINT("[%zu] mode: %.3o\n", i, mode);
+    PRINT("[%zu] size: %u\n", i, size);
+    PRINT("[%zu] mtime: %lld\n", i, (long long)mtime);
+    PRINT("[%zu] length: %u\n", i, length);
 
     fread(filename, 1, length, f);
     filename[length] = 0;       /* let's go ahead and terminate the string */
 
-    PRINT(("[%zu] filename: %s\n\n", i, filename));
+    PRINT("[%zu] filename: %s\n\n", i, filename);
 
     sprintf(filepath, "%s/%s", hg_path, filename);