Removed dependency on NDEBUG, and introduced ENABLE_DEBUG_LOG in CMakeLists.txt.

By default Windows will continue to show SPRTF output, and other platforms will
require the -DENABLE_DEBUG_LOG to be set in default (debug) configurations.

Debug and Release builds on macOS, Windows 10, and Ubuntu 16.04 confirmed
working as most people expect.
This commit is contained in:
Jim Derry 2017-10-07 14:56:01 -04:00
parent f26b198213
commit 0977aa6077
11 changed files with 118 additions and 132 deletions

View File

@ -138,14 +138,7 @@ endif ()
#------------------------------------------------------------------------
# Diagnostics
# Enable building with logs, some memory diagnostics.
#
# - ensure that NDEBUG is applied by default, so that default builds
# don't spew debugging messages everywhere, except MSVC builds,
# where this is already expected behavior.
# - allow other diagnostic tools.
#------------------------------------------------------------------------
add_definitions( -DNDEBUG )
if (MSVC AND NOT CMAKE_BUILD_TYPE MATCHES Release)
option( ENABLE_DEBUG_LOG "Set ON to output debugging messages." ON )
else ()
@ -153,7 +146,7 @@ else ()
endif ()
if ( ENABLE_DEBUG_LOG )
remove_definitions ( -DNDEBUG )
add_definitions( -DENABLE_DEBUG_LOG )
message(STATUS "*** Debug Logging is enabled.")
else ()
message(STATUS "*** Debug Logging is NOT enabled.")
@ -167,10 +160,10 @@ if (ENABLE_ALLOC_DEBUG)
message(STATUS "*** Note, lexer.c node allocation diagnostics are ON")
endif ()
if (ENABLE_MEMORY_DEBUG)
add_definitions ( -DDEBUG_MEMORY ) # see alloc.c for details
message(STATUS "*** Note, alloc.c memory diagnostics are ON")
endif ()
if (ENABLE_MEMORY_DEBUG)
add_definitions ( -DDEBUG_MEMORY ) # see alloc.c for details
message(STATUS "*** Note, alloc.c memory diagnostics are ON")
endif ()
if (WIN32)
option( ENABLE_CRTDBG_MEMORY "Set ON to enable the Windows CRT debug library." OFF )

View File

@ -21,17 +21,21 @@
#include "tidy.h"
#include "tidybuffio.h"
#include "locale.h" /* for determing and setting locale */
#include "locale.h"
#if defined(_WIN32)
# include <windows.h> /* Force console to UTF8. */
#endif
#if !defined(NDEBUG) && defined(_MSC_VER) && defined(_CRTDBG_MAP_ALLOC)
#ifdef ENABLE_DEBUG_LOG
# include "sprtf.h"
#endif
#if defined(ENABLE_DEBUG_LOG) && defined(_MSC_VER) && defined(_CRTDBG_MAP_ALLOC)
# include <stdlib.h>
# include <crtdbg.h>
#endif
#include "sprtf.h"
/** Tidy will send errors to this file, which will be stderr later. */
static FILE* errout = NULL;
@ -2008,7 +2012,7 @@ int main( int argc, char** argv )
uint contentWarnings = 0;
uint accessWarnings = 0;
#if !defined(NDEBUG) && defined(_MSC_VER)
#if defined(ENABLE_DEBUG_LOG) && defined(_MSC_VER)
# if defined(_CRTDBG_MAP_ALLOC)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
# endif
@ -2426,9 +2430,7 @@ int main( int argc, char** argv )
if ( argc > 1 )
{
htmlfil = argv[1];
#if (!defined(NDEBUG))
SPRTF("Tidying '%s'\n", htmlfil);
#endif /* DEBUG outout */
DEBUG_LOG( SPRTF("Tidying '%s'\n", htmlfil) );
if ( tidyOptGetBool(tdoc, TidyEmacs) )
tidySetEmacsFile( tdoc, htmlfil );
status = tidyParseFile( tdoc, htmlfil );
@ -2458,7 +2460,7 @@ int main( int argc, char** argv )
if ( outfil ) {
status = tidySaveFile( tdoc, outfil );
} else {
#if !defined(NDEBUG)
#ifdef ENABLE_DEBUG_LOG
static char tmp_buf[264];
sprintf(tmp_buf,"%s.html",get_log_file());
status = tidySaveFile( tdoc, tmp_buf );

View File

@ -654,15 +654,18 @@ opaque_type( TidyIterator );
/*=============================================================================
* Debugging
* When building and not defining the NDEBUG macro, Tidy will output
* 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.
*===========================================================================*/
#if !defined(NDEBUG)
#ifdef ENABLE_DEBUG_LOG
# include "sprtf.h"
#endif
@ -670,6 +673,11 @@ opaque_type( TidyIterator );
# 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__ */

View File

@ -15,7 +15,7 @@ static TidyRealloc g_realloc = NULL;
static TidyFree g_free = NULL;
static TidyPanic g_panic = NULL;
#if !defined(NDEBUG) && defined(DEBUG_MEMORY)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_MEMORY)
static int alloccnt = 0;
static int realloccnt = 0;
static int freecnt = 0;
@ -63,7 +63,7 @@ static void* TIDY_CALL defaultAlloc( TidyAllocator* allocator, size_t size )
void *p = ( g_malloc ? g_malloc(size) : malloc(size) );
if ( !p )
defaultPanic( allocator,"Out of memory!");
#if !defined(NDEBUG) && defined(DEBUG_MEMORY)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_MEMORY)
alloccnt++;
SPRTF("%d: alloc MEM %p, size %d\n", alloccnt, p, (int)size );
if (size == 0) {
@ -82,7 +82,7 @@ static void* TIDY_CALL defaultRealloc( TidyAllocator* allocator, void* mem, size
p = ( g_realloc ? g_realloc(mem, newsize) : realloc(mem, newsize) );
if (!p)
defaultPanic( allocator, "Out of memory!");
#if !defined(NDEBUG) && defined(DEBUG_MEMORY)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_MEMORY)
realloccnt++;
SPRTF("%d: realloc MEM %p, size %d\n", realloccnt, p, (int)newsize );
#endif
@ -93,7 +93,7 @@ static void TIDY_CALL defaultFree( TidyAllocator* ARG_UNUSED(allocator), void* m
{
if ( mem )
{
#if !defined(NDEBUG) && defined(DEBUG_MEMORY)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_MEMORY)
freecnt++;
SPRTF("%d: free MEM %p\n", freecnt, mem );
#endif

View File

@ -82,7 +82,7 @@ void TIDY_CALL TY_(filesink_putByte)( void* sinkData, byte bv )
{
FILE* fout = (FILE*) sinkData;
fputc( bv, fout );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
if (fileno(fout) != 2)
{
if (bv != 0x0d)

View File

@ -269,7 +269,7 @@ Node *TY_(InsertedToken)( TidyDocImpl* doc )
istack = lexer->insert;
/* #if 0 && defined(_DEBUG) */
#if !defined(NDEBUG)
#if definedENABLE_DEBUG_LOG
if ( lexer->istacksize == 0 )
{
SPRTF( "WARNING: ZERO sized istack!\n" );

View File

@ -40,7 +40,7 @@
#include "utf8.h"
#include "streamio.h"
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
/* #define DEBUG_ALLOCATION special EXTRA allocation debug information - VERY NOISY */
static void check_me(char *name);
static Bool show_attrs = yes;
@ -173,9 +173,9 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node )
}
}
#define GTDBG(a,b,c) Show_Node(a,b,c)
#else /* NDEBUG is define */
#else /* ENABLE_DEBUG_LOG */
#define GTDBG(a,b,c)
#endif /* !defined(NDEBUG) */
#endif /* defined(ENABLE_DEBUG_LOG) */
/* Forward references
*/
@ -322,7 +322,7 @@ static uint GetVersFromFPI(ctmbstr fpi)
return 0;
}
#ifndef NDEBUG
#ifdef ENABLE_DEBUG_LOG
# ifndef EndBuf
# define EndBuf(a) ( a + strlen(a) )
# endif
@ -417,14 +417,14 @@ void TY_(ConstrainVersion)(TidyDocImpl* doc, uint vers)
SPRTF("After : %s\n", vcur);
}
}
#else /* !#if defined(_MSC_VER) */
#else /* !#if defined(ENABLE_DEBUG_LOG) */
/* everything is allowed in proprietary version of HTML */
/* this is handled here rather than in the tag/attr dicts */
void TY_(ConstrainVersion)(TidyDocImpl* doc, uint vers)
{
doc->lexer->versions &= (vers | VERS_PROPRIETARY);
}
#endif /* #if defined(_MSC_VER) y/n */
#endif /* #if defined(ENABLE_DEBUG_LOG) y/n */
Bool TY_(IsWhite)(uint c)
{
@ -1417,7 +1417,7 @@ Node *TY_(NewNode)(TidyAllocator* allocator, Lexer *lexer)
node->column = lexer->columns;
}
node->type = TextNode;
#if !defined(NDEBUG) && defined(DEBUG_ALLOCATION)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_ALLOCATION)
SPRTF("Allocated node %p\n", node );
#endif
return node;
@ -1511,7 +1511,7 @@ void TY_(RemoveAttribute)( TidyDocImpl* doc, Node *node, AttVal *attr )
*/
void TY_(FreeNode)( TidyDocImpl* doc, Node *node )
{
#if !defined(NDEBUG) && defined(DEBUG_ALLOCATION)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_ALLOCATION)
/* avoid showing free of root node! */
if (node) {
if (RootNode != node->type) {
@ -2397,7 +2397,7 @@ void TY_(UngetToken)( TidyDocImpl* doc )
doc->lexer->pushed = yes;
}
#if !defined(NDEBUG) && defined(_MSC_VER)
#if defined(ENABLE_DEBUG_LOG)
# define CondReturnTextNode(doc, skip) \
if (lexer->txtend > lexer->txtstart) { \
Node *_node = TY_(TextToken)(lexer); \
@ -2488,7 +2488,7 @@ Node* TY_(GetToken)( TidyDocImpl* doc, GetTokenMode mode )
return GetTokenFromStream( doc, mode );
}
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
static void check_me(char *name)
{
SPRTF("Have node %s\n", name);
@ -3422,9 +3422,7 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
return node; /* the COMMENT token */
}
#if !defined(NDEBUG)
SPRTF("Returning NULL...\n");
#endif
DEBUG_LOG(SPRTF("Returning NULL...\n"));
return NULL;
}

View File

@ -454,10 +454,8 @@ static void TrimInitialSpace( TidyDocImpl* doc, Node *element, Node *text )
node->end = element->start;
lexer->lexbuf[node->start] = ' ';
TY_(InsertNodeBeforeElement)(element ,node);
#if !defined(NDEBUG)
SPRTF("TrimInitialSpace: Created text node, inserted before <%s>\n",
(element->element ? element->element : "unknown"));
#endif
DEBUG_LOG(SPRTF("TrimInitialSpace: Created text node, inserted before <%s>\n",
(element->element ? element->element : "unknown")));
}
}
@ -794,7 +792,7 @@ static void AddClassNoIndent( TidyDocImpl* doc, Node *node )
*/
void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
static int in_parse_block = 0;
static int parse_block_cnt = 0;
#endif
@ -802,7 +800,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
Node *node;
Bool checkstack = yes;
uint istackbase = 0;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block++;
parse_block_cnt++;
SPRTF("Entering ParseBlock %d... %d %s\n",in_parse_block,parse_block_cnt,
@ -810,7 +808,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
#endif
if ( element->tag->model & CM_EMPTY ) {
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlockL 1 %d...\n",in_parse_block);
#endif
@ -875,7 +873,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
element->closed = yes;
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 2 %d...\n",in_parse_block);
#endif
@ -929,7 +927,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
{
TY_(UngetToken)( doc );
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 2 %d...\n",in_parse_block);
#endif
@ -1093,7 +1091,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
{
TY_(UngetToken)( doc );
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 3 %d...\n",in_parse_block);
#endif
@ -1113,7 +1111,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
lexer->istackbase = istackbase;
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 4 %d...\n",in_parse_block);
#endif
@ -1172,7 +1170,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
element->parent->tag->parser == TY_(ParseList) )
{
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 5 %d...\n",in_parse_block);
#endif
@ -1187,7 +1185,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
if ( nodeIsDL(element->parent) )
{
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 6 %d...\n",in_parse_block);
#endif
@ -1202,7 +1200,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
/* In exiled mode, return so table processing can
continue. */
if (lexer->exiled) {
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 7 %d...\n",in_parse_block);
#endif
@ -1217,7 +1215,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
TY_(PopInline)( doc, NULL );
lexer->istackbase = istackbase;
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 8 %d...\n",in_parse_block);
#endif
@ -1227,7 +1225,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
else
{
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 9 %d...\n",in_parse_block);
#endif
@ -1271,7 +1269,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
if (!(mode & Preformatted))
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 9b %d...\n",in_parse_block);
#endif
@ -1339,7 +1337,7 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
}
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_block--;
SPRTF("Exit ParseBlock 10 %d...\n",in_parse_block);
#endif
@ -1539,18 +1537,18 @@ void TY_(ParseNamespace)(TidyDocImpl* doc, Node *basenode, GetTokenMode mode)
void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
static int in_parse_inline = 0;
#endif
Lexer* lexer = doc->lexer;
Node *node, *parent;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline++;
SPRTF("Entering ParseInline %d...\n",in_parse_inline);
#endif
if (element->tag->model & CM_EMPTY) {
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 1 %d...\n",in_parse_inline);
#endif
@ -1632,7 +1630,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
element->closed = yes;
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 2 %d...\n",in_parse_inline);
#endif
@ -1723,7 +1721,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
if (!(mode & Preformatted))
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 3 %d...\n",in_parse_inline);
#endif
@ -1813,7 +1811,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
TY_(InlineDup1)( doc, NULL, element ); /* dupe the <i>, after </b> */
if (!(mode & Preformatted))
TrimSpaces( doc, element );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 4 %d...\n",in_parse_inline);
#endif
@ -1837,7 +1835,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
if (!(mode & Preformatted))
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 5 %d...\n",in_parse_inline);
#endif
@ -1854,7 +1852,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
{
TY_(UngetToken)( doc );
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 6 %d...\n",in_parse_inline);
#endif
@ -1880,7 +1878,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
if (!(mode & Preformatted))
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 7 %d...\n",in_parse_inline);
#endif
@ -1917,7 +1915,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
if (!(mode & Preformatted))
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 8 %d...\n",in_parse_inline);
#endif
@ -2043,7 +2041,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
if (!(mode & Preformatted))
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 9 %d...\n",in_parse_inline);
#endif
@ -2095,7 +2093,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
{
TY_(DiscardElement)( doc, element );
TY_(UngetToken)( doc );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 10 %d...\n",in_parse_inline);
#endif
@ -2108,7 +2106,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
if (!(mode & Preformatted))
TrimSpaces(doc, element);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 11 %d...\n",in_parse_inline);
#endif
@ -2139,7 +2137,7 @@ void TY_(ParseInline)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
if (!(element->tag->model & CM_OPT))
TY_(Report)(doc, element, node, MISSING_ENDTAG_FOR);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_inline--;
SPRTF("Exit ParseInline 12 %d...\n",in_parse_inline);
#endif
@ -2327,7 +2325,7 @@ static Bool FindLastLI( Node *list, Node **lastli )
void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
static int in_parse_list = 0;
#endif
Lexer* lexer = doc->lexer;
@ -2335,13 +2333,13 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
Bool wasblock;
Bool nodeisOL = nodeIsOL(list);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_list++;
SPRTF("Entering ParseList %d...\n",in_parse_list);
#endif
if (list->tag->model & CM_EMPTY)
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_list--;
SPRTF("Exit ParseList 1 %d... CM_EMPTY\n",in_parse_list);
#endif
@ -2356,7 +2354,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
{
TY_(FreeNode)( doc, node);
list->closed = yes;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_list--;
SPRTF("Exit ParseList 2 %d... Endtag\n",in_parse_list);
#endif
@ -2423,7 +2421,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
{
TY_(Report)(doc, list, node, MISSING_ENDTAG_BEFORE);
TY_(UngetToken)( doc );
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_list--;
SPRTF("Exit ParseList 3 %d... No End Tag\n",in_parse_list);
#endif
@ -2456,7 +2454,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
if (TY_(nodeHasCM)(node,CM_BLOCK) && lexer->excludeBlocks)
{
TY_(Report)(doc, list, node, MISSING_ENDTAG_BEFORE);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_list--;
SPRTF("Exit ParseList 4 %d... No End Tag\n",in_parse_list);
#endif
@ -2468,7 +2466,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
&& (TY_(nodeHasCM)(node, CM_TABLE|CM_ROWGRP|CM_ROW)
|| nodeIsTABLE(node)) )
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_list--;
SPRTF("Exit ParseList 5 %d... exiled\n",in_parse_list);
#endif
@ -2507,7 +2505,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
}
TY_(Report)(doc, list, node, MISSING_ENDTAG_FOR);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_list--;
SPRTF("Exit ParseList 6 %d... missing end tag\n",in_parse_list);
#endif
@ -2931,7 +2929,7 @@ void TY_(ParseColGroup)(TidyDocImpl* doc, Node *colgroup, GetTokenMode ARG_UNUSE
void TY_(ParseTableTag)(TidyDocImpl* doc, Node *table, GetTokenMode ARG_UNUSED(mode))
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
static int in_parse_table = 0;
#endif
Lexer* lexer = doc->lexer;
@ -2941,7 +2939,7 @@ void TY_(ParseTableTag)(TidyDocImpl* doc, Node *table, GetTokenMode ARG_UNUSED(m
TY_(DeferDup)( doc );
istackbase = lexer->istackbase;
lexer->istackbase = lexer->istacksize;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_table++;
SPRTF("Entering ParseTableTag %d...\n",in_parse_table);
#endif
@ -2966,7 +2964,7 @@ void TY_(ParseTableTag)(TidyDocImpl* doc, Node *table, GetTokenMode ARG_UNUSED(m
}
lexer->istackbase = istackbase;
table->closed = yes;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_table--;
SPRTF("Exit ParseTableTag 1 %d... EndTag\n",in_parse_table);
#endif
@ -3046,7 +3044,7 @@ void TY_(ParseTableTag)(TidyDocImpl* doc, Node *table, GetTokenMode ARG_UNUSED(m
TY_(Report)(doc, table, node, MISSING_ENDTAG_BEFORE );
TY_(UngetToken)( doc );
lexer->istackbase = istackbase;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_table--;
SPRTF("Exit ParseTableTag 2 %d... missing EndTag\n",in_parse_table);
#endif
@ -3060,7 +3058,7 @@ void TY_(ParseTableTag)(TidyDocImpl* doc, Node *table, GetTokenMode ARG_UNUSED(m
TY_(UngetToken)( doc );
TY_(Report)(doc, table, node, TAG_NOT_ALLOWED_IN);
lexer->istackbase = istackbase;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_table--;
SPRTF("Exit ParseTableTag 3 %d... CM_TABLE\n",in_parse_table);
#endif
@ -3081,7 +3079,7 @@ void TY_(ParseTableTag)(TidyDocImpl* doc, Node *table, GetTokenMode ARG_UNUSED(m
TY_(Report)(doc, table, node, MISSING_ENDTAG_FOR);
lexer->istackbase = istackbase;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_table--;
SPRTF("Exit ParseTableTag 4 %d... missing end\n",in_parse_table);
#endif
@ -3317,14 +3315,14 @@ void TY_(ParseOptGroup)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(m
void TY_(ParseSelect)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(mode))
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
static int in_parse_select = 0;
#endif
Lexer* lexer = doc->lexer;
Node *node;
lexer->insert = NULL; /* defer implicit inline start tags */
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_select++;
SPRTF("Entering ParseSelect %d...\n",in_parse_select);
#endif
@ -3336,7 +3334,7 @@ void TY_(ParseSelect)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(mod
TY_(FreeNode)( doc, node);
field->closed = yes;
TrimSpaces(doc, field);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_select--;
SPRTF("Exit ParseSelect 1 %d...\n",in_parse_select);
#endif
@ -3365,7 +3363,7 @@ void TY_(ParseSelect)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(mod
}
TY_(Report)(doc, field, node, MISSING_ENDTAG_FOR);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_select--;
SPRTF("Exit ParseSelect 2 %d...\n",in_parse_select);
#endif
@ -3374,14 +3372,14 @@ void TY_(ParseSelect)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(mod
/* HTML5 */
void TY_(ParseDatalist)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(mode))
{
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
static int in_parse_datalist = 0;
#endif
Lexer* lexer = doc->lexer;
Node *node;
lexer->insert = NULL; /* defer implicit inline start tags */
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_datalist++;
SPRTF("Entering ParseDatalist %d...\n",in_parse_datalist);
#endif
@ -3393,7 +3391,7 @@ void TY_(ParseDatalist)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(m
TY_(FreeNode)( doc, node);
field->closed = yes;
TrimSpaces(doc, field);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_datalist--;
SPRTF("Exit ParseDatalist 1 %d...\n",in_parse_datalist);
#endif
@ -3422,7 +3420,7 @@ void TY_(ParseDatalist)(TidyDocImpl* doc, Node *field, GetTokenMode ARG_UNUSED(m
}
TY_(Report)(doc, field, node, MISSING_ENDTAG_FOR);
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
in_parse_datalist--;
SPRTF("Exit ParseDatalist 2 %d...\n",in_parse_datalist);
#endif
@ -3628,9 +3626,7 @@ void TY_(ParseHead)(TidyDocImpl* doc, Node *head, GetTokenMode ARG_UNUSED(mode))
int HasTitle = 0;
int HasBase = 0;
#if !defined(NDEBUG)
SPRTF("Enter ParseHead...\n");
#endif
DEBUG_LOG(SPRTF("Enter ParseHead...\n"));
while ((node = TY_(GetToken)(doc, IgnoreWhitespace)) != NULL)
{
if (node->tag == head->tag && node->type == EndTag)
@ -3734,9 +3730,7 @@ void TY_(ParseHead)(TidyDocImpl* doc, Node *head, GetTokenMode ARG_UNUSED(mode))
TY_(Report)(doc, head, node, DISCARDING_UNEXPECTED);
TY_(FreeNode)( doc, node);
}
#if !defined(NDEBUG)
SPRTF("Exit ParseHead 1...\n");
#endif
DEBUG_LOG(SPRTF("Exit ParseHead 1...\n"));
}
/*\
@ -3790,10 +3784,8 @@ void TY_(ParseBody)(TidyDocImpl* doc, Node *body, GetTokenMode mode)
checkstack = yes;
TY_(BumpObject)( doc, body->parent );
#if !defined(NDEBUG)
SPRTF("Enter ParseBody...\n");
#endif
DEBUG_LOG(SPRTF("Enter ParseBody...\n"));
while ((node = TY_(GetToken)(doc, mode)) != NULL)
{
/* find and discard multiple <body> elements */
@ -4057,9 +4049,7 @@ void TY_(ParseBody)(TidyDocImpl* doc, Node *body, GetTokenMode mode)
TY_(Report)(doc, body, node, DISCARDING_UNEXPECTED);
TY_(FreeNode)( doc, node);
}
#if !defined(NDEBUG)
SPRTF("Exit ParseBody 1...\n");
#endif
DEBUG_LOG(SPRTF("Exit ParseBody 1...\n"));
}
void TY_(ParseNoFrames)(TidyDocImpl* doc, Node *noframes, GetTokenMode mode)
@ -4246,9 +4236,7 @@ void TY_(ParseHTML)(TidyDocImpl* doc, Node *html, GetTokenMode mode)
Node *frameset = NULL;
Node *noframes = NULL;
#if !defined(NDEBUG)
SPRTF("Entering ParseHTML...\n");
#endif
DEBUG_LOG(SPRTF("Entering ParseHTML...\n"));
TY_(SetOptionBool)( doc, TidyXmlTags, no );
for (;;)
@ -4304,9 +4292,8 @@ void TY_(ParseHTML)(TidyDocImpl* doc, Node *html, GetTokenMode mode)
TY_(InsertNodeAtEnd)(html, node);
TY_(ParseBody)(doc, node, mode);
}
#if !defined(NDEBUG)
SPRTF("Exit ParseHTML 1...\n");
#endif
DEBUG_LOG(SPRTF("Exit ParseHTML 1...\n"));
return;
}
@ -4475,9 +4462,7 @@ void TY_(ParseHTML)(TidyDocImpl* doc, Node *html, GetTokenMode mode)
TY_(InsertNodeAtEnd)(html, node);
ParseTag(doc, node, mode);
#if !defined(NDEBUG)
SPRTF("Exit ParseHTML 2...\n");
#endif
DEBUG_LOG(SPRTF("Exit ParseHTML 2...\n"));
}
static Bool nodeCMIsOnlyInline( Node* node )

View File

@ -20,7 +20,7 @@
/* *** FOR DEBUG ONLY *** */
/* #define DEBUG_PPRINT */
/* #define DEBUG_INDENT */
#if !defined(NDEBUG) && defined(DEBUG_PPRINT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_PPRINT)
extern void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent );
#endif
@ -614,7 +614,7 @@ static Bool CheckWrapIndent( TidyDocImpl* doc, uint indent )
WrapLine( doc );
if ( pprint->indent[ 0 ].spaces < 0 )
{
#if !defined(NDEBUG) && defined(DEBUG_INDENT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_INDENT)
SPRTF("%s Indent from %d to %d\n", __FUNCTION__, pprint->indent[ 0 ].spaces, indent );
#endif
pprint->indent[ 0 ].spaces = indent;
@ -678,7 +678,7 @@ void TY_(PFlushLine)( TidyDocImpl* doc, uint indent )
if (pprint->indent[ 0 ].spaces != (int)indent )
{
#if !defined(NDEBUG) && defined(DEBUG_INDENT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_INDENT)
SPRTF("%s Indent from %d to %d\n", __FUNCTION__, pprint->indent[ 0 ].spaces, indent );
#endif
pprint->indent[ 0 ].spaces = indent;
@ -700,7 +700,7 @@ static void PCondFlushLine( TidyDocImpl* doc, uint indent )
/* Issue #390 - Whether chars to flush or not, set new indent */
if ( pprint->indent[ 0 ].spaces != (int)indent )
{
#if !defined(NDEBUG) && defined(DEBUG_INDENT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_INDENT)
SPRTF("%s Indent from %d to %d\n", __FUNCTION__, pprint->indent[ 0 ].spaces, indent );
#endif
pprint->indent[ 0 ].spaces = indent;
@ -728,7 +728,7 @@ void TY_(PFlushLineSmart)( TidyDocImpl* doc, uint indent )
if ( pprint->indent[ 0 ].spaces != (int)indent )
{
#if !defined(NDEBUG) && defined(DEBUG_INDENT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_INDENT)
SPRTF("%s Indent from %d to %d\n", __FUNCTION__, pprint->indent[ 0 ].spaces, indent );
#endif
pprint->indent[ 0 ].spaces = indent;
@ -757,7 +757,7 @@ static void PCondFlushLineSmart( TidyDocImpl* doc, uint indent )
\*/
if (pprint->indent[ 0 ].spaces != (int)indent)
{
#if !defined(NDEBUG) && defined(DEBUG_INDENT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_INDENT)
SPRTF("%s Indent from %d to %d\n", __FUNCTION__, pprint->indent[ 0 ].spaces, indent );
#endif
pprint->indent[ 0 ].spaces = indent;
@ -1945,7 +1945,7 @@ void PPrintScriptStyle( TidyDocImpl* doc, uint mode, uint indent, Node *node )
if ( node->content && pprint->indent[ 0 ].spaces != (int)indent )
{
#if !defined(NDEBUG) && defined(DEBUG_INDENT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_INDENT)
SPRTF("%s Indent from %d to %d\n", __FUNCTION__, pprint->indent[ 0 ].spaces, indent );
#endif
pprint->indent[ 0 ].spaces = indent;
@ -2053,7 +2053,7 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
doc->progressCallback( tidyImplToDoc(doc), node->line, node->column, doc->pprint.line + 1 );
}
#if !defined(NDEBUG) && defined(DEBUG_PPRINT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_PPRINT)
dbg_show_node( doc, node, 4, GetSpaces( &doc->pprint ) );
#endif
@ -2313,7 +2313,7 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
TidyPrintImpl* pprint = &doc->pprint;
if (pprint->indent[ 0 ].spaces != (int)indent)
{
#if !defined(NDEBUG) && defined(DEBUG_INDENT)
#if defined(ENABLE_DEBUG_LOG) && defined(DEBUG_INDENT)
SPRTF("%s Indent from %d to %d\n", __FUNCTION__, pprint->indent[ 0 ].spaces, indent );
#endif
pprint->indent[ 0 ].spaces = indent;

View File

@ -473,7 +473,7 @@ static void declare( TidyDocImpl* doc, TidyTagImpl* tags,
}
}
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
void ListElementsPerVersion( uint vers, Bool has )
{
uint val, cnt, total, wrap = 10;
@ -519,7 +519,7 @@ void show_have_html5(void)
ListElementsPerVersion( VERS_HTML5, yes );
}
#endif /* !defined(NDEBUG) */
#endif /* defined(ENABLE_DEBUG_LOG) */
/* public interface for finding tag by name */
Bool TY_(FindTag)( TidyDocImpl* doc, Node *node )

View File

@ -1398,7 +1398,7 @@ void tidyDocReportDoctype( TidyDocImpl* doc )
/*****************************************************************************
* HTML5 STUFF
*****************************************************************************/
#if 0 && !defined(NDEBUG)
#if 0 && defined(ENABLE_DEBUG_LOG)
extern void show_not_html5(void);
/* -----------------------------
List tags that do not have version HTML5 (HT50|XH50)
@ -1773,7 +1773,7 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
}
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
/* *** FOR DEBUG ONLY *** */
const char *dbg_get_lexer_type( void *vp )
{
@ -1910,7 +1910,7 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc )
Bool mergeEmphasis = cfgBool( doc, TidyMergeEmphasis );
Node* node;
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
SPRTF("All nodes BEFORE clean and repair\n");
dbg_show_all_nodes( doc, &doc->root, 0 );
#endif
@ -2028,7 +2028,7 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc )
}
}
#if !defined(NDEBUG)
#if defined(ENABLE_DEBUG_LOG)
SPRTF("All nodes AFTER clean and repair\n");
dbg_show_all_nodes( doc, &doc->root, 0 );
#endif