diff --git a/console/tidy.c b/console/tidy.c index 91ba055..563cb0a 100644 --- a/console/tidy.c +++ b/console/tidy.c @@ -22,15 +22,12 @@ #include "tidy.h" #include "tidybuffio.h" #include "locale.h" +#include "sprtf.h" #if defined(_WIN32) # include /* Force console to UTF8. */ #endif -#ifdef ENABLE_DEBUG_LOG -# include "sprtf.h" -#endif - #if defined(ENABLE_DEBUG_LOG) && defined(_MSC_VER) && defined(_CRTDBG_MAP_ALLOC) # include # include @@ -2016,7 +2013,6 @@ int main( int argc, char** argv ) # if defined(_CRTDBG_MAP_ALLOC) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); # endif - set_log_file((char *)"temptidy.txt", 0); #endif tdoc = tidyCreate(); diff --git a/include/tidyplatform.h b/include/tidyplatform.h index 3aa9b57..32c3c05 100644 --- a/include/tidyplatform.h +++ b/include/tidyplatform.h @@ -483,6 +483,9 @@ extern "C" { # if defined(_MSC_VER) # define fileno _fileno +#if !defined(NDEBUG) && !defined(ENABLE_DEBUG_LOG) && !defined(DISABLE_DEBUG_LOG) +#define ENABLE_DEBUG_LOG +#endif #endif # define access _access @@ -651,38 +654,8 @@ opaque_type( TidyIterator ); } /* extern "C" */ #endif - -/*============================================================================= - * Debugging - * When building and defining the ENABLE_DEBUG_LOG macro, Tidy will output - * extensive debug information. In addition to this macro, you can supply - * build flags for additional diagnostic information: - * - _CRTDBG_MAP_ALLOC (_MSC_VER only) - * - DEBUG_ALLOCATION - * - DEBUG_MEMORY - * - * You can use DEBUG_LOG( SPRTF() ) to avoid #ifdef ENABLE_DEBUG_LOG for - * one-liners. - *===========================================================================*/ - -#ifdef ENABLE_DEBUG_LOG -# include "sprtf.h" -#endif - -#ifndef SPRTF -# define SPRTF printf -#endif - -#ifdef ENABLE_DEBUG_LOG -# define DEBUG_LOG(ARG) do { ARG; } while(0) -#else -# define DEBUG_LOG(ARG) -#endif - - #endif /* __TIDY_PLATFORM_H__ */ - /* * local variables: * mode: c diff --git a/src/alloc.c b/src/alloc.c index 1666e40..7235a3c 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -9,6 +9,7 @@ #include "tidy.h" #include "forward.h" +#include "sprtf.h" static TidyMalloc g_malloc = NULL; static TidyRealloc g_realloc = NULL; diff --git a/src/fileio.c b/src/fileio.c index 8a5297f..61048c0 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -13,6 +13,7 @@ #include "forward.h" #include "fileio.h" #include "tidy.h" +#include "sprtf.h" typedef struct _fp_input_source { diff --git a/src/lexer.c b/src/lexer.c index 21728e0..05fc509 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -39,6 +39,7 @@ #include "clean.h" #include "utf8.h" #include "streamio.h" +#include "sprtf.h" #if defined(ENABLE_DEBUG_LOG) /* #define DEBUG_ALLOCATION special EXTRA allocation debug information - VERY NOISY */ diff --git a/src/parser.c b/src/parser.c index 333996c..8569ed5 100644 --- a/src/parser.c +++ b/src/parser.c @@ -12,6 +12,7 @@ #include "clean.h" #include "tags.h" #include "tmbstr.h" +#include "sprtf.h" /* Issue #72 - Need to know to avoid error-reporting - no warning only if --show-body-only yes diff --git a/src/sprtf.c b/src/sprtf.c index cd6dd8d..d3b936c 100644 --- a/src/sprtf.c +++ b/src/sprtf.c @@ -56,11 +56,8 @@ char *GetNxtBuf() } #define MXIO 512 -#ifdef _MSC_VER /* use local log */ -static char def_log[] = "tempex.txt"; -#else -static char def_log[] = "ex.log"; -#endif + +static char def_log[] = "temptidy.txt"; /* use local log */ static char logfile[264] = "\0"; static FILE * outfile = NULL; static int addsystime = 0; diff --git a/src/sprtf.h b/src/sprtf.h index 322009c..4cfb6bf 100644 --- a/src/sprtf.h +++ b/src/sprtf.h @@ -25,6 +25,36 @@ #ifdef __cplusplus extern "C" { +#endif + /*============================================================================= + * EXTRA Debugging, and information aid. + * + * When building and defining the ENABLE_DEBUG_LOG macro, Tidy will output + * extensive debug information. In addition to this macro, you can supply + * cmake build flags for additional diagnostic information: + * - -DENABLE_ALLOC_DEBUG:BOOL=ON - DEBUG_ALLOCATION + * - -DENABLE_MEMORY_DEBUG:BOOL=ON - DEBUG_MEMORY + * - -DENABLE_CRTDBG_MEMORY:BOOL=ON - _CRTDBG_MAP_ALLOC (WIN32 only) + * + * _MSC_VER Only - ENABLE_DEBUG_LOG is automatically enabled in the Debug + * build, unless DISABLE_DEBUG_LOG is defined. See 'tidyplatform.h' + * + * You can use DEBUG_LOG( SPRTF() ) to avoid #ifdef ENABLE_DEBUG_LOG for + * one-liners. + * + * This EXTRA Debug information is also written to a 'temptidy.txt' log + * file, for review, and analysis. + * + *===========================================================================*/ + +#ifndef SPRTF +# define SPRTF sprtf +#endif + +#ifdef ENABLE_DEBUG_LOG +# define DEBUG_LOG(ARG) do { ARG; } while(0) +#else +# define DEBUG_LOG(ARG) #endif #ifdef _MSC_VER diff --git a/src/tags.c b/src/tags.c index 67eeaa0..fbcf547 100644 --- a/src/tags.c +++ b/src/tags.c @@ -10,6 +10,8 @@ #include "tidy-int.h" #include "message.h" #include "tmbstr.h" +#include "sprtf.h" + /* Attribute checking methods */ static CheckAttribs CheckIMG; static CheckAttribs CheckLINK; diff --git a/src/tidylib.c b/src/tidylib.c index dae71c8..62bb7d9 100644 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -33,7 +33,7 @@ #include "utf8.h" #include "mappedio.h" #include "language.h" - +#include "sprtf.h" /* Create/Destroy a Tidy "document" object */ static TidyDocImpl* tidyDocCreate( TidyAllocator *allocator );