chiark / gitweb /
Patch from James H: make the Windows debugging output conditional on
authorSimon Tatham <anakin@pobox.com>
Tue, 12 Jan 2010 23:32:22 +0000 (23:32 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 12 Jan 2010 23:32:22 +0000 (23:32 +0000)
an enabling environment variable.

[originally from svn r8834]

windows.c

index d2044ccff5444e127db1c2cd0f6698e1abb9a914..7bdb5e2bdcef279fbaf2b190402ab28506172434 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -154,11 +154,17 @@ void debug_printf(char *fmt, ...)
 {
     char buf[4096];
     va_list ap;
+    static int debugging = -1;
 
-    va_start(ap, fmt);
-    _vsnprintf(buf, 4095, fmt, ap);
-    dputs(buf);
-    va_end(ap);
+    if (debugging == -1)
+        debugging = getenv("DEBUG_PUZZLES") ? 1 : 0;
+
+    if (debugging) {
+        va_start(ap, fmt);
+        _vsnprintf(buf, 4095, fmt, ap);
+       dputs(buf);
+        va_end(ap);
+    }
 }
 #endif