Skip to content

Commit

Permalink
Add debug display of text modes.
Browse files Browse the repository at this point in the history
Note this ONLY effects a MSVC Debug build!
  • Loading branch information
geoffmcl committed Jun 4, 2015
1 parent 0c96ed8 commit a278b04
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/tidylib.c
Expand Up @@ -1572,6 +1572,7 @@ const char *dbg_get_element_name( void *vp )
void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent )
{
AttVal* av;
Lexer* lexer = doc->lexer;
ctmbstr call = "";
ctmbstr name = dbg_get_element_name(node);
ctmbstr type = dbg_get_lexer_type(node);
Expand All @@ -1588,6 +1589,29 @@ void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent )
SPRTF("%s %s %s %s", type, name, impl, call );
else
SPRTF("%s %s %s", name, impl, call );
if (lexer && (strcmp("Text",name) == 0)) {
uint len = node->end - node->start;
uint i;
SPRTF(" (%d) '", len);
if (len < 40) {
/* show it all */
for (i = node->start; i < node->end; i++) {
SPRTF("%c", lexer->lexbuf[i]);
}
} else {
/* partial display */
uint max = 19;
for (i = node->start; i < max; i++) {
SPRTF("%c", lexer->lexbuf[i]);
}
SPRTF("...");
i = node->end - 19;
for (; i < node->end; i++) {
SPRTF("%c", lexer->lexbuf[i]);
}
}
SPRTF("'");
}
for (av = node->attributes; av; av = av->next) {
name = av->attribute;
if (name) {
Expand All @@ -1597,6 +1621,7 @@ void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent )
}
}
}

SPRTF("\n");
}

Expand Down

0 comments on commit a278b04

Please sign in to comment.