changeset 525:59b8f15c5334

Add (compile-time enabled via TH_PRINTF_DEBUG define) global variable for controlling printf() function debug messages.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 27 Dec 2019 09:26:53 +0200
parents 19dc326dcdad
children 32245648f0f0
files tests.c th_string.c th_string.h
diffstat 3 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests.c	Fri Dec 27 09:16:21 2019 +0200
+++ b/tests.c	Fri Dec 27 09:26:53 2019 +0200
@@ -563,6 +563,9 @@
 
     tprint(1, "Enabled test types are 0x%04x.\n", optFlags);
 
+    // Setup printf debug value
+    th_printf_debug = th_verbosity >= 2;
+
     //
     // Test series for printf()
     //
--- a/th_string.c	Fri Dec 27 09:16:21 2019 +0200
+++ b/th_string.c	Fri Dec 27 09:26:53 2019 +0200
@@ -191,6 +191,8 @@
 
 
 #ifdef TH_PRINTF_DEBUG
+BOOL th_printf_debug = FALSE;
+
 static void pflag(char *buf, const char *str, const int sep, const int flags, const int flg)
 {
     strcat(buf, (flags & flg) ? str : "   ");
@@ -215,7 +217,7 @@
     return buf;
 }
 
-#define PP_PRINTF(...) fprintf(stdout, __VA_ARGS__)
+#define PP_PRINTF(...) do { if (th_printf_debug) fprintf(stdout, __VA_ARGS__); } while (0)
 #else
 #define PP_PRINTF(...) /* stub */
 #endif
--- a/th_string.h	Fri Dec 27 09:16:21 2019 +0200
+++ b/th_string.h	Fri Dec 27 09:26:53 2019 +0200
@@ -149,6 +149,11 @@
 #include "th_printf1.c"
 
 
+#ifdef TH_PRINTF_DEBUG
+extern BOOL th_printf_debug;
+#endif
+
+
 /* Parsing, matching
  */
 const char    *th_findnext(const char *, size_t *);