Improve MSVC DEBUG output.
Previous only output the first 8 characters, followed by an elipse if more than 8. Now return first up to 19 chars. If nore than 19, return first 8, followed by an elipse, followed by the last 8 characters. This is in the get_text_string service, which is only used if MSVC and not NDEBUG.
This commit is contained in:
parent
c66bb848f2
commit
a4f425546f
65
src/lexer.c
65
src/lexer.c
|
@ -52,7 +52,7 @@
|
||||||
static void check_me(char *name);
|
static void check_me(char *name);
|
||||||
static Bool show_attrs = yes;
|
static Bool show_attrs = yes;
|
||||||
#define MX_TXT 8
|
#define MX_TXT 8
|
||||||
static char buffer[MX_TXT+8]; /* NOTE extra for '...'\0 tail */
|
static char buffer[(MX_TXT*4)+8]; /* NOTE extra for '...'\0 tail */
|
||||||
static tmbstr get_text_string(Lexer* lexer, Node *node)
|
static tmbstr get_text_string(Lexer* lexer, Node *node)
|
||||||
{
|
{
|
||||||
uint len = node->end - node->start;
|
uint len = node->end - node->start;
|
||||||
|
@ -61,14 +61,15 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
Bool insp = no;
|
Bool insp = no;
|
||||||
buffer[0] = (char)0;
|
if (len <= ((MX_TXT * 2) + 3)) {
|
||||||
while (cp < end ) {
|
buffer[0] = 0;
|
||||||
|
while (cp < end) {
|
||||||
c = *cp;
|
c = *cp;
|
||||||
|
cp++;
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
buffer[i++] = '\\';
|
buffer[i++] = '\\';
|
||||||
buffer[i++] = 'n';
|
buffer[i++] = 'n';
|
||||||
insp = yes;
|
} else if ( c == ' ' ) {
|
||||||
} else if (c == ' ') {
|
|
||||||
if (!insp)
|
if (!insp)
|
||||||
buffer[i++] = c;
|
buffer[i++] = c;
|
||||||
insp = yes;
|
insp = yes;
|
||||||
|
@ -76,16 +77,58 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
|
||||||
buffer[i++] = c;
|
buffer[i++] = c;
|
||||||
insp = no;
|
insp = no;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
char *end1 = cp + MX_TXT;
|
||||||
|
char *bgn = cp + (len - MX_TXT);
|
||||||
|
buffer[0] = 0;
|
||||||
|
if (bgn < end1)
|
||||||
|
bgn = end1;
|
||||||
|
while (cp < end1) {
|
||||||
|
c = *cp;
|
||||||
cp++;
|
cp++;
|
||||||
|
if (c == '\n') {
|
||||||
|
buffer[i++] = '\\';
|
||||||
|
buffer[i++] = 'n';
|
||||||
|
} else if ( c == ' ' ) {
|
||||||
|
if (!insp)
|
||||||
|
buffer[i++] = c;
|
||||||
|
insp = yes;
|
||||||
|
} else {
|
||||||
|
buffer[i++] = c;
|
||||||
|
insp = no;
|
||||||
|
}
|
||||||
if (i >= MX_TXT)
|
if (i >= MX_TXT)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < len) {
|
c = '.';
|
||||||
buffer[i++] = '.';
|
if ((i < len)&&(cp < bgn)) {
|
||||||
if (i < len) {
|
buffer[i++] = c;
|
||||||
buffer[i++] = '.';
|
cp++;
|
||||||
if (i < len) {
|
if ((i < len)&&(cp < bgn)) {
|
||||||
buffer[i++] = '.';
|
buffer[i++] = c;
|
||||||
|
cp++;
|
||||||
|
if ((i < len)&&(cp < bgn)) {
|
||||||
|
buffer[i++] = c;
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cp = bgn;
|
||||||
|
insp = no;
|
||||||
|
while (cp < end) {
|
||||||
|
c = *cp;
|
||||||
|
cp++;
|
||||||
|
if (c == '\n') {
|
||||||
|
buffer[i++] = '\\';
|
||||||
|
buffer[i++] = 'n';
|
||||||
|
} else if ( c == ' ' ) {
|
||||||
|
if (!insp)
|
||||||
|
buffer[i++] = c;
|
||||||
|
insp = yes;
|
||||||
|
} else {
|
||||||
|
buffer[i++] = c;
|
||||||
|
insp = no;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue