diff --git a/ChangeLog b/ChangeLog index ffe84b0..8faf636 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 ----------------------------- diff --git a/doc/pcre2test.1 b/doc/pcre2test.1 index d73f817..f639ec2 100644 --- a/doc/pcre2test.1 +++ b/doc/pcre2test.1 @@ -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 "". +are output as "". 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 diff --git a/src/pcre2test.c b/src/pcre2test.c index 9ce37a5..1e24f7d 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -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, diff --git a/testdata/testinput6 b/testdata/testinput6 index a19bff3..de9227e 100644 --- a/testdata/testinput6 +++ b/testdata/testinput6 @@ -4878,4 +4878,8 @@ /abcd/null_context abcd\=null_context +/()()a+/no_auto_possess + aaa\=dfa,allcaptures + a\=dfa,allcaptures + # End of testinput6 diff --git a/testdata/testoutput6 b/testdata/testoutput6 index e4074cd..17616c8 100644 --- a/testdata/testoutput6 +++ b/testdata/testoutput6 @@ -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