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 line; /**< current line of document */
|
||||||
uint column; /**< current column of document */
|
uint column; /**< current column of document */
|
||||||
|
|
||||||
|
int idx; /**< general purpose register */
|
||||||
|
|
||||||
Bool closed; /**< true if closed by explicit end tag */
|
Bool closed; /**< true if closed by explicit end tag */
|
||||||
Bool implicit; /**< true if inferred */
|
Bool implicit; /**< true if inferred */
|
||||||
Bool linebreak; /**< true if followed by a line break */
|
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* TY_(ParseScript)( TidyDocImpl* doc, Node *script, GetTokenMode ARG_UNUSED(mode) )
|
||||||
{
|
{
|
||||||
Node *node = NULL;
|
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;
|
doc->lexer->parent = script;
|
||||||
node = TY_(GetToken)(doc, CdataContent);
|
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>" */
|
/* handle e.g. a document like "<script>" */
|
||||||
TY_(Report)(doc, script, NULL, MISSING_ENDTAG_FOR);
|
TY_(Report)(doc, script, NULL, MISSING_ENDTAG_FOR);
|
||||||
|
DEBUG_LOG_EXIT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = TY_(GetToken)(doc, IgnoreWhitespace);
|
node = TY_(GetToken)(doc, IgnoreWhitespace);
|
||||||
|
DEBUG_LOG_GOT_TOKEN(node);
|
||||||
|
|
||||||
if (!(node && node->type == EndTag && node->tag &&
|
if (!(node && node->type == EndTag && node->tag &&
|
||||||
node->tag->id == script->tag->id))
|
node->tag->id == script->tag->id))
|
||||||
|
@ -5184,6 +5192,7 @@ Node* TY_(ParseScript)( TidyDocImpl* doc, Node *script, GetTokenMode ARG_UNUSED(
|
||||||
{
|
{
|
||||||
TY_(FreeNode)(doc, node);
|
TY_(FreeNode)(doc, node);
|
||||||
}
|
}
|
||||||
|
DEBUG_LOG_EXIT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2048,24 +2048,52 @@ void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent )
|
||||||
SPRTF("\n");
|
SPRTF("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tail recursion here with sensible compilers will re-use
|
/* Make this non-recursive, because we really do want to eliminate
|
||||||
the stack frame and avoid overflows during debugging.
|
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 )
|
void dbg_show_all_nodes( TidyDocImpl* doc, Node *node, int indent )
|
||||||
{
|
{
|
||||||
dbg_show_node( doc, node, 0, indent );
|
Stack *stack = TY_(newStack)(doc, 16);
|
||||||
dbg_show_all_nodes_loop( doc, node->content, indent + 1 );
|
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
|
#endif
|
||||||
|
|
||||||
int tidyDocCleanAndRepair( TidyDocImpl* doc )
|
int tidyDocCleanAndRepair( TidyDocImpl* doc )
|
||||||
|
|
Loading…
Reference in a new issue