Logging for ParseScript().
Improved debug output.
This commit is contained in:
parent
a604621fef
commit
a873a190e1
|
@ -323,6 +323,8 @@ struct _Node
|
|||
uint line; /**< current line of document */
|
||||
uint column; /**< current column of document */
|
||||
|
||||
int idx; /**< general purpose register */
|
||||
|
||||
Bool closed; /**< true if closed by explicit end tag */
|
||||
Bool implicit; /**< true if inferred */
|
||||
Bool linebreak; /**< true if followed by a line break */
|
||||
|
|
|
@ -5154,6 +5154,12 @@ Node* TY_(ParseRowGroup)( TidyDocImpl* doc, Node *rowgroup, GetTokenMode ARG_UNU
|
|||
Node* TY_(ParseScript)( TidyDocImpl* doc, Node *script, GetTokenMode ARG_UNUSED(mode) )
|
||||
{
|
||||
Node *node = NULL;
|
||||
#if defined(ENABLE_DEBUG_LOG)
|
||||
static int depth_parser = 0;
|
||||
static int count_parser = 0;
|
||||
#endif
|
||||
|
||||
DEBUG_LOG_ENTER_WITH_NODE(script);
|
||||
|
||||
doc->lexer->parent = script;
|
||||
node = TY_(GetToken)(doc, CdataContent);
|
||||
|
@ -5167,10 +5173,12 @@ Node* TY_(ParseScript)( TidyDocImpl* doc, Node *script, GetTokenMode ARG_UNUSED(
|
|||
{
|
||||
/* handle e.g. a document like "<script>" */
|
||||
TY_(Report)(doc, script, NULL, MISSING_ENDTAG_FOR);
|
||||
DEBUG_LOG_EXIT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node = TY_(GetToken)(doc, IgnoreWhitespace);
|
||||
DEBUG_LOG_GOT_TOKEN(node);
|
||||
|
||||
if (!(node && node->type == EndTag && node->tag &&
|
||||
node->tag->id == script->tag->id))
|
||||
|
@ -5184,6 +5192,7 @@ Node* TY_(ParseScript)( TidyDocImpl* doc, Node *script, GetTokenMode ARG_UNUSED(
|
|||
{
|
||||
TY_(FreeNode)(doc, node);
|
||||
}
|
||||
DEBUG_LOG_EXIT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -2048,24 +2048,52 @@ void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent )
|
|||
SPRTF("\n");
|
||||
}
|
||||
|
||||
/* Tail recursion here with sensible compilers will re-use
|
||||
the stack frame and avoid overflows during debugging.
|
||||
/* Make this non-recursive, because we really do want to eliminate
|
||||
recursion that makes us crash, even when debugging.
|
||||
*/
|
||||
void dbg_show_all_nodes_loop( TidyDocImpl* doc, Node *node, int indent )
|
||||
{
|
||||
while ( node && (node = node->next) )
|
||||
{
|
||||
dbg_show_node( doc, node, 0, indent );
|
||||
dbg_show_all_nodes_loop( doc, node->content, indent + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void dbg_show_all_nodes( TidyDocImpl* doc, Node *node, int indent )
|
||||
{
|
||||
dbg_show_node( doc, node, 0, indent );
|
||||
dbg_show_all_nodes_loop( doc, node->content, indent + 1 );
|
||||
Stack *stack = TY_(newStack)(doc, 16);
|
||||
Node *child = NULL;
|
||||
Node *next = NULL;
|
||||
|
||||
dbg_show_node( doc, node, 0, indent++ );
|
||||
|
||||
if ( (child = node->content) )
|
||||
{
|
||||
while ( child )
|
||||
{
|
||||
if ( (next = child->next) )
|
||||
{
|
||||
next->idx = indent;
|
||||
}
|
||||
|
||||
dbg_show_node( doc, child, 0, indent );
|
||||
|
||||
if (child->content)
|
||||
{
|
||||
TY_(push)(stack, next);
|
||||
indent++;
|
||||
child = child->content;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next)
|
||||
{
|
||||
child = next;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (child = TY_(pop)(stack)) )
|
||||
{
|
||||
indent = child->idx;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
TY_(freeStack)(stack);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int tidyDocCleanAndRepair( TidyDocImpl* doc )
|
||||
|
|
Loading…
Reference in a new issue