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:
Geoff McLane 2016-02-14 18:11:57 +01:00
parent c66bb848f2
commit a4f425546f

View file

@ -52,7 +52,7 @@
static void check_me(char *name);
static Bool show_attrs = yes;
#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)
{
uint len = node->end - node->start;
@ -61,14 +61,15 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
unsigned char c;
uint i = 0;
Bool insp = no;
buffer[0] = (char)0;
while (cp < end ) {
if (len <= ((MX_TXT * 2) + 3)) {
buffer[0] = 0;
while (cp < end) {
c = *cp;
cp++;
if (c == '\n') {
buffer[i++] = '\\';
buffer[i++] = 'n';
insp = yes;
} else if (c == ' ') {
} else if ( c == ' ' ) {
if (!insp)
buffer[i++] = c;
insp = yes;
@ -76,16 +77,58 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
buffer[i++] = c;
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++;
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)
break;
}
if (i < len) {
buffer[i++] = '.';
if (i < len) {
buffer[i++] = '.';
if (i < len) {
buffer[i++] = '.';
c = '.';
if ((i < len)&&(cp < bgn)) {
buffer[i++] = c;
cp++;
if ((i < len)&&(cp < bgn)) {
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;
}
}
}