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
91
src/lexer.c
91
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,31 +61,74 @@ 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;
|
||||||
c = *cp;
|
while (cp < end) {
|
||||||
if (c == '\n') {
|
c = *cp;
|
||||||
buffer[i++] = '\\';
|
cp++;
|
||||||
buffer[i++] = 'n';
|
if (c == '\n') {
|
||||||
insp = yes;
|
buffer[i++] = '\\';
|
||||||
} else if (c == ' ') {
|
buffer[i++] = 'n';
|
||||||
if (!insp)
|
} else if ( c == ' ' ) {
|
||||||
|
if (!insp)
|
||||||
|
buffer[i++] = c;
|
||||||
|
insp = yes;
|
||||||
|
} else {
|
||||||
buffer[i++] = c;
|
buffer[i++] = c;
|
||||||
insp = yes;
|
insp = no;
|
||||||
} else {
|
}
|
||||||
buffer[i++] = c;
|
|
||||||
insp = no;
|
|
||||||
}
|
}
|
||||||
cp++;
|
} else {
|
||||||
if (i >= MX_TXT)
|
char *end1 = cp + MX_TXT;
|
||||||
break;
|
char *bgn = cp + (len - MX_TXT);
|
||||||
}
|
buffer[0] = 0;
|
||||||
if (i < len) {
|
if (bgn < end1)
|
||||||
buffer[i++] = '.';
|
bgn = end1;
|
||||||
if (i < len) {
|
while (cp < end1) {
|
||||||
buffer[i++] = '.';
|
c = *cp;
|
||||||
if (i < len) {
|
cp++;
|
||||||
buffer[i++] = '.';
|
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;
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue