Fix printing of *MARK names containing binary zeroes in pcre2test.

This commit is contained in:
Philip.Hazel 2015-12-16 18:44:24 +00:00
parent 255974ed28
commit 57c44eec15
4 changed files with 51 additions and 9 deletions

View File

@ -1,8 +1,8 @@
Change Log for PCRE2
--------------------
Version 10.21 xx-xxx-xxxx
-------------------------
Version 10.21-RC1 15-December-2015
----------------------------------
1. Improve matching speed of patterns starting with + or * in JIT.
@ -389,6 +389,8 @@ command line arguments.
112. Implemented PCRE2_SUBSTITUTE_UNKNOWN_UNSET and PCRE2_SUBSTITUTE_OVERFLOW_
LENGTH.
113. Fix printing of *MARK names that contain binary zeroes in pcre2test.
Version 10.20 30-June-2015
--------------------------

View File

@ -2545,13 +2545,14 @@ return (int)(pp - p);
*************************************************/
/* Must handle UTF-8 strings in utf8 mode. Yields number of characters printed.
If handed a NULL file, just counts chars without printing. */
For printing *MARK strings, a negative length is given. If handed a NULL file,
just counts chars without printing. */
static int pchars8(PCRE2_SPTR8 p, int length, BOOL utf, FILE *f)
{
uint32_t c = 0;
int yield = 0;
if (length < 0) length = strlen((char *)p);
if (length < 0) length = p[-1];
while (length-- > 0)
{
if (utf)
@ -2579,12 +2580,13 @@ return yield;
*************************************************/
/* Must handle UTF-16 strings in utf mode. Yields number of characters printed.
If handed a NULL file, just counts chars without printing. */
For printing *MARK strings, a negative length is given. If handed a NULL file,
just counts chars without printing. */
static int pchars16(PCRE2_SPTR16 p, int length, BOOL utf, FILE *f)
{
int yield = 0;
if (length < 0) length = strlen16(p);
if (length < 0) length = p[-1];
while (length-- > 0)
{
uint32_t c = *p++ & 0xffff;
@ -2612,13 +2614,14 @@ return yield;
*************************************************/
/* Must handle UTF-32 strings in utf mode. Yields number of characters printed.
If handed a NULL file, just counts chars without printing. */
For printing *MARK strings, a negative length is given.If handed a NULL file,
just counts chars without printing. */
static int pchars32(PCRE2_SPTR32 p, int length, BOOL utf, FILE *f)
{
int yield = 0;
(void)(utf); /* Avoid compiler warning */
if (length < 0) length = strlen32(p);
if (length < 0) length = p[-1];
while (length-- > 0)
{
uint32_t c = *p++;
@ -6402,7 +6405,8 @@ else for (gmatched = 0;; gmatched++)
TESTFLD(match_data, mark, !=, NULL))
{
fprintf(outfile, ", mark=");
PCHARS(rubriclength, CASTFLD(void *, match_data, mark), 0, -1, utf, outfile);
PCHARS(rubriclength, CASTFLD(void *, match_data, mark), 0, -1, utf,
outfile);
rubriclength += 7;
}
fprintf(outfile, ": ");

14
testdata/testinput2 vendored
View File

@ -4786,4 +4786,18 @@ a)"xI
\=offset_limit=1100000000000000000000
\=copy=11000000000
/(*MARK:A\x00b)/mark
abc
/(*MARK:A\x00b)/mark,alt_verbnames
abc
# /(*MARK:A\x00b)/
/28 2a 4d 41 52 4b 3a 41 00 62 29/mark,hex
abc
# /(*MARK:A\x00b)/
/28 2a 4d 41 52 4b 3a 41 00 62 29/mark,hex,alt_verbnames
abc
# End of testinput2

22
testdata/testoutput2 vendored
View File

@ -15136,4 +15136,26 @@ Failed: error -55 at offset 3 in replacement: requested value is not set
\=copy=11000000000
** Invalid value in 'copy=11000000000'
/(*MARK:A\x00b)/mark
abc
0:
MK: A\x00b
/(*MARK:A\x00b)/mark,alt_verbnames
abc
0:
MK: A\x00b
# /(*MARK:A\x00b)/
/28 2a 4d 41 52 4b 3a 41 00 62 29/mark,hex
abc
0:
MK: A\x00b
# /(*MARK:A\x00b)/
/28 2a 4d 41 52 4b 3a 41 00 62 29/mark,hex,alt_verbnames
abc
0:
MK: A\x00b
# End of testinput2