Ignore "allcaptures" after DFA matching.

This commit is contained in:
Philip.Hazel 2016-07-06 15:02:24 +00:00
parent 9b741ad59d
commit 6a5acedf08
5 changed files with 33 additions and 8 deletions

View File

@ -170,6 +170,8 @@ large stack size when testing with clang.
43. Detect integer overflow in pcre2test pattern and data repetition counts.
44. In pcre2test, ignore "allcaptures" after DFA matching.
Version 10.21 12-January-2016
-----------------------------

View File

@ -1,4 +1,4 @@
.TH PCRE2TEST 1 "17 June 2016" "PCRE 10.22"
.TH PCRE2TEST 1 "06 July 2016" "PCRE 10.22"
.SH NAME
pcre2test - a program for testing Perl-compatible regular expressions.
.SH SYNOPSIS
@ -1055,7 +1055,8 @@ The \fBallcaptures\fP modifier requests that the values of all potential
captured parentheses be output after a match. By default, only those up to the
highest one actually used in the match are output (corresponding to the return
code from \fBpcre2_match()\fP). Groups that did not take part in the match
are output as "<unset>".
are output as "<unset>". This modifier is not relevant for DFA matching (which
does no capturing); it is ignored, with a warning message, if present.
.
.
.SS "Testing callouts"
@ -1681,6 +1682,6 @@ Cambridge, England.
.rs
.sp
.nf
Last updated: 17 June 2016
Last updated: 06 July 2016
Copyright (c) 1997-2016 University of Cambridge.
.fi

View File

@ -6436,15 +6436,23 @@ else for (gmatched = 0;; gmatched++)
/* "allcaptures" requests showing of all captures in the pattern, to check
unset ones at the end. It may be set on the pattern or the data. Implement
by setting capcount to the maximum. */
by setting capcount to the maximum. This is not relevant for DFA matching,
so ignore it. */
if ((dat_datctl.control & CTL_ALLCAPTURES) != 0)
{
uint32_t maxcapcount;
if (pattern_info(PCRE2_INFO_CAPTURECOUNT, &maxcapcount, FALSE) < 0)
return PR_SKIP;
capcount = maxcapcount + 1; /* Allow for full match */
if (capcount > (int)oveccount) capcount = oveccount;
if ((dat_datctl.control & CTL_DFA) != 0)
{
fprintf(outfile, "** Ignored after DFA matching: allcaptures\n");
}
else
{
if (pattern_info(PCRE2_INFO_CAPTURECOUNT, &maxcapcount, FALSE) < 0)
return PR_SKIP;
capcount = maxcapcount + 1; /* Allow for full match */
if (capcount > (int)oveccount) capcount = oveccount;
}
}
/* Output the captured substrings. Note that, for the matched string,

4
testdata/testinput6 vendored
View File

@ -4878,4 +4878,8 @@
/abcd/null_context
abcd\=null_context
/()()a+/no_auto_possess
aaa\=dfa,allcaptures
a\=dfa,allcaptures
# End of testinput6

10
testdata/testoutput6 vendored
View File

@ -7672,4 +7672,14 @@ No match
abcd\=null_context
0: abcd
/()()a+/no_auto_possess
aaa\=dfa,allcaptures
** Ignored after DFA matching: allcaptures
0: aaa
1: aa
2: a
a\=dfa,allcaptures
** Ignored after DFA matching: allcaptures
0: a
# End of testinput6