Make /()a/ set the "first character must be" data.

This commit is contained in:
Philip.Hazel 2014-08-30 16:21:17 +00:00
parent fbb4db531a
commit 7b2707fcf7
4 changed files with 17 additions and 7 deletions

View File

@ -11,8 +11,8 @@ item 20 for release 8.36.
The code of the library was heavily revised as part of the new API
implementation. Details of each and every modification were not individually
logged. In addition to the API changes, the following changes were made. They
are either new functionality, or bugs that were fixed after the code had been
forked.
are either new functionality, or bug fixes and other noticeable changes of
behaviour that were implemented after the code had been forked.
1. The test program, now called pcre2test, was re-specified and almost
completely re-written. Its input is not compatible with input for pcretest.
@ -38,4 +38,8 @@ Incorrect backtracking meant that group 2 captured only the last two bytes.
This bug has been fixed; the new code is slower, but it is used only when the
strings matched by the repetition are not all the same length.
5. A pattern such as /()a/ was not setting the "first character must be 'a'"
information. This applied to any pattern with a group that matched no
characters, for example: /(?:(?=.)|(?<!x))a/.
****

View File

@ -6217,7 +6217,7 @@ for (;; ptr++)
no firstcu, set "none" for the whole branch. In both cases, a zero
repeat forces firstcu to "none". */
if (firstcuflags == REQ_UNSET)
if (firstcuflags == REQ_UNSET && subfirstcuflags != REQ_UNSET)
{
if (subfirstcuflags >= 0)
{

2
testdata/testinput2 vendored
View File

@ -975,6 +975,8 @@
/()a/I
/(?:(?=.)|(?<!x))a/I
/(?(1)ab|ac)(.)/I
/(?(1)abz|acz)(.)/I

12
testdata/testoutput2 vendored
View File

@ -3327,8 +3327,13 @@ Subject length lower bound = 2
/()a/I
Capturing subpattern count = 1
Starting code units: a
Last code unit = 'a'
First code unit = 'a'
Subject length lower bound = 1
/(?:(?=.)|(?<!x))a/I
Capturing subpattern count = 0
Max lookbehind = 1
First code unit = 'a'
Subject length lower bound = 1
/(?(1)ab|ac)(.)/I
@ -10000,8 +10005,7 @@ Subject length lower bound = 1
/()i(?(1)a)/I
Capturing subpattern count = 1
Starting code units: i
Last code unit = 'i'
First code unit = 'i'
Subject length lower bound = 1
ia
0: ia