Add debug display of text modes.

Note this ONLY effects a MSVC Debug build!
This commit is contained in:
Geoff McLane 2015-06-04 12:57:49 +02:00
parent 0c96ed8af4
commit a278b04a19

View file

@ -1572,6 +1572,7 @@ const char *dbg_get_element_name( void *vp )
void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent ) void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent )
{ {
AttVal* av; AttVal* av;
Lexer* lexer = doc->lexer;
ctmbstr call = ""; ctmbstr call = "";
ctmbstr name = dbg_get_element_name(node); ctmbstr name = dbg_get_element_name(node);
ctmbstr type = dbg_get_lexer_type(node); ctmbstr type = dbg_get_lexer_type(node);
@ -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 ); SPRTF("%s %s %s %s", type, name, impl, call );
else else
SPRTF("%s %s %s", name, impl, call ); 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) { for (av = node->attributes; av; av = av->next) {
name = av->attribute; name = av->attribute;
if (name) { if (name) {
@ -1597,6 +1621,7 @@ void dbg_show_node( TidyDocImpl* doc, Node *node, int caller, int indent )
} }
} }
} }
SPRTF("\n"); SPRTF("\n");
} }