# HG changeset patch # User Matti Hamalainen # Date 1577431613 -7200 # Node ID 59b8f15c53341f228087b943c6768aa5381d9ed6 # Parent 19dc326dcdad0320efd5352d9f210de8d0f522e4 Add (compile-time enabled via TH_PRINTF_DEBUG define) global variable for controlling printf() function debug messages. diff -r 19dc326dcdad -r 59b8f15c5334 tests.c --- 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() // diff -r 19dc326dcdad -r 59b8f15c5334 th_string.c --- 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 diff -r 19dc326dcdad -r 59b8f15c5334 th_string.h --- 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 *);