Fix callout display bug in pcre2test.

This commit is contained in:
Philip.Hazel 2016-10-05 16:53:34 +00:00
parent 7fd341c384
commit 1d28e047f3
4 changed files with 28 additions and 8 deletions

View File

@ -54,6 +54,10 @@ not recognize this syntax.
7. Automatic callouts are no longer generated before and after callouts in the 7. Automatic callouts are no longer generated before and after callouts in the
pattern. pattern.
8. When pcre2test was outputing information from a callout, the caret indicator
for the current position in the subject line was incorrect if it was after an
escape sequence for a character whose code point was greater than \x{ff}.
Version 10.22 29-July-2016 Version 10.22 29-July-2016
-------------------------- --------------------------

View File

@ -2528,6 +2528,8 @@ static int
pchar(uint32_t c, BOOL utf, FILE *f) pchar(uint32_t c, BOOL utf, FILE *f)
{ {
int n = 0; int n = 0;
char tempbuffer[16];
if (PRINTOK(c)) if (PRINTOK(c))
{ {
if (f != NULL) fprintf(f, "%c", c); if (f != NULL) fprintf(f, "%c", c);
@ -2549,6 +2551,8 @@ if (c < 0x100)
} }
if (f != NULL) n = fprintf(f, "\\x{%02x}", c); if (f != NULL) n = fprintf(f, "\\x{%02x}", c);
else n = sprintf(tempbuffer, "\\x{%02x}", c);
return n >= 0 ? n : 0; return n >= 0 ? n : 0;
} }
@ -5070,7 +5074,7 @@ during matching. */
#ifdef SUPPORT_PCRE2_8 #ifdef SUPPORT_PCRE2_8
if (test_mode == PCRE8_MODE) if (test_mode == PCRE8_MODE)
{ {
VALGRIND_MAKE_MEM_UNDEFINED(pbuffer8 + valgrind_access_length, VALGRIND_MAKE_MEM_UNDEFINED(pbuffer8 + valgrind_access_length,
pbuffer8_size - valgrind_access_length); pbuffer8_size - valgrind_access_length);
} }
#endif #endif
@ -5360,10 +5364,10 @@ if (post_start > 0)
for (i = 0; i < subject_length - pre_start - post_start + 4; i++) for (i = 0; i < subject_length - pre_start - post_start + 4; i++)
fprintf(outfile, " "); fprintf(outfile, " ");
if (cb->next_item_length != 0) if (cb->next_item_length != 0)
fprintf(outfile, "%.*s", (int)(cb->next_item_length), fprintf(outfile, "%.*s", (int)(cb->next_item_length),
pbuffer8 + cb->pattern_position); pbuffer8 + cb->pattern_position);
fprintf(outfile, "\n"); fprintf(outfile, "\n");
first_callout = FALSE; first_callout = FALSE;
@ -7708,14 +7712,14 @@ while (notdone)
skipping = FALSE; skipping = FALSE;
setlocale(LC_CTYPE, "C"); setlocale(LC_CTYPE, "C");
} }
/* Otherwise, if we are not skipping, and the line is not a data comment /* Otherwise, if we are not skipping, and the line is not a data comment
line starting with "\=", process a data line. */ line starting with "\=", process a data line. */
else if (!skipping && !(p[0] == '\\' && p[1] == '=' && isspace(p[2]))) else if (!skipping && !(p[0] == '\\' && p[1] == '=' && isspace(p[2])))
{ {
rc = process_data(); rc = process_data();
} }
} }
/* We do not have a pattern set up for testing. Lines starting with # are /* We do not have a pattern set up for testing. Lines starting with # are

3
testdata/testinput5 vendored
View File

@ -1733,4 +1733,7 @@
/ab(?<=A\RB)/utf /ab(?<=A\RB)/utf
/../utf,auto_callout
\n\x{123}\x{123}\x{123}\x{123}
# End of testinput5 # End of testinput5

View File

@ -4171,4 +4171,13 @@ Failed: error 125 at offset 1: lookbehind assertion is not fixed length
/ab(?<=A\RB)/utf /ab(?<=A\RB)/utf
Failed: error 125 at offset 2: lookbehind assertion is not fixed length Failed: error 125 at offset 2: lookbehind assertion is not fixed length
/../utf,auto_callout
\n\x{123}\x{123}\x{123}\x{123}
--->\x{0a}\x{123}\x{123}\x{123}\x{123}
+0 ^ .
+0 ^ .
+1 ^ ^ .
+2 ^ ^
0: \x{123}\x{123}
# End of testinput5 # End of testinput5