Fix "first code unit" bug.

This commit is contained in:
Philip.Hazel 2014-10-10 16:16:44 +00:00
parent 62d728bb0b
commit 623b497851
5 changed files with 50 additions and 8 deletions

View File

@ -6219,7 +6219,7 @@ for (;; ptr++)
than one can replicate it as reqcu if necessary. If the subpattern has
no firstcu, set "none" for the whole branch. In both cases, a zero
repeat forces firstcu to "none". */
if (firstcuflags == REQ_UNSET && subfirstcuflags != REQ_UNSET)
{
if (subfirstcuflags >= 0)
@ -6750,15 +6750,16 @@ for (;;)
we have to abandon the firstcu for the regex, but if there was
previously no reqcu, it takes on the value of the old firstcu. */
if (firstcuflags >= 0 &&
(firstcuflags != branchfirstcuflags ||
firstcu != branchfirstcu))
if (firstcuflags != branchfirstcuflags || firstcu != branchfirstcu)
{
if (reqcuflags < 0)
if (firstcuflags >= 0)
{
reqcu = firstcu;
reqcuflags = firstcuflags;
}
if (reqcuflags < 0)
{
reqcu = firstcu;
reqcuflags = firstcuflags;
}
}
firstcuflags = REQ_NONE;
}

4
testdata/testinput1 vendored
View File

@ -5698,4 +5698,8 @@ name)/mark
A8B
A9B
/(|ab)*?d/
abd
xyd
# End of testinput1

8
testdata/testinput2 vendored
View File

@ -3995,4 +3995,12 @@ a random value. /Ix
/abcd/I,no_start_optimize
/(|ab)*?d/I
abd
xyd
/(|ab)*?d/I,no_start_optimize
abd
xyd
# End of testinput2

View File

@ -9396,4 +9396,11 @@ No match
A9B
0: A9B
/(|ab)*?d/
abd
0: abd
1: ab
xyd
0: d
# End of testinput1

22
testdata/testoutput2 vendored
View File

@ -13554,4 +13554,26 @@ Capturing subpattern count = 0
Options: no_start_optimize
Subject length lower bound = 0
/(|ab)*?d/I
Capturing subpattern count = 1
Starting code units: a d
Last code unit = 'd'
Subject length lower bound = 1
abd
0: abd
1: ab
xyd
0: d
/(|ab)*?d/I,no_start_optimize
Capturing subpattern count = 1
Options: no_start_optimize
Last code unit = 'd'
Subject length lower bound = 0
abd
0: abd
1: ab
xyd
0: d
# End of testinput2