Save compile-time work when PCRE2_NO_START_OPTIMIZE is set.
This commit is contained in:
parent
df93e05c2e
commit
ccd5ac9014
|
@ -7883,9 +7883,11 @@ if ((re->overall_options & PCRE2_ANCHORED) == 0 &&
|
||||||
|
|
||||||
/* If the pattern is still not anchored and we do not have a first code unit,
|
/* If the pattern is still not anchored and we do not have a first code unit,
|
||||||
see if there is one that is asserted (these are not saved during the compile
|
see if there is one that is asserted (these are not saved during the compile
|
||||||
because they can cause conflicts with actual literals that follow). */
|
because they can cause conflicts with actual literals that follow). This code
|
||||||
|
need not be obeyed if PCRE2_NO_START_OPTIMIZE is set, as the data it would
|
||||||
|
create will not be used. */
|
||||||
|
|
||||||
if ((re->overall_options & PCRE2_ANCHORED) == 0)
|
if ((re->overall_options & (PCRE2_ANCHORED|PCRE2_NO_START_OPTIMIZE)) == 0)
|
||||||
{
|
{
|
||||||
if (firstcuflags < 0)
|
if (firstcuflags < 0)
|
||||||
firstcu = find_firstassertedcu(codestart, &firstcuflags, FALSE);
|
firstcu = find_firstassertedcu(codestart, &firstcuflags, FALSE);
|
||||||
|
@ -7928,10 +7930,11 @@ if ((re->overall_options & PCRE2_ANCHORED) == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the "required code unit", if one is set. In the case of an anchored
|
/* Handle the "required code unit", if one is set. In the case of an anchored
|
||||||
pattern, do this only if it follows a variable length item in the pattern. */
|
pattern, do this only if it follows a variable length item in the pattern.
|
||||||
|
Again, skip this if PCRE2_NO_START_OPTIMIZE is set. */
|
||||||
|
|
||||||
if (reqcuflags >= 0 &&
|
if (reqcuflags >= 0 &&
|
||||||
((re->overall_options & PCRE2_ANCHORED) == 0 ||
|
((re->overall_options & (PCRE2_ANCHORED|PCRE2_NO_START_OPTIMIZE)) == 0 ||
|
||||||
(reqcuflags & REQ_VARY) != 0))
|
(reqcuflags & REQ_VARY) != 0))
|
||||||
{
|
{
|
||||||
re->last_codeunit = reqcu;
|
re->last_codeunit = reqcu;
|
||||||
|
@ -7966,10 +7969,12 @@ do
|
||||||
}
|
}
|
||||||
while (*codestart == OP_ALT);
|
while (*codestart == OP_ALT);
|
||||||
|
|
||||||
/* Finally, study the compiled pattern to set up information such as a bitmap
|
/* Finally, unless PCRE2_NO_START_OPTIMIZE is set, study the compiled pattern
|
||||||
of starting code units and a minimum matching length. */
|
to set up information such as a bitmap of starting code units and a minimum
|
||||||
|
matching length. */
|
||||||
|
|
||||||
if (PRIV(study)(re) != 0)
|
if ((re->overall_options & PCRE2_NO_START_OPTIMIZE) == 0 &&
|
||||||
|
PRIV(study)(re) != 0)
|
||||||
{
|
{
|
||||||
errorcode = ERR31;
|
errorcode = ERR31;
|
||||||
goto HAD_ERROR;
|
goto HAD_ERROR;
|
||||||
|
|
|
@ -4091,4 +4091,8 @@ a random value. /Ix
|
||||||
|
|
||||||
/(?(VERSION>=10.0.0)yes|no)/
|
/(?(VERSION>=10.0.0)yes|no)/
|
||||||
|
|
||||||
|
/abcd/I
|
||||||
|
|
||||||
|
/abcd/I,no_start_optimize
|
||||||
|
|
||||||
# End of testinput2
|
# End of testinput2
|
||||||
|
|
|
@ -13769,4 +13769,15 @@ Failed: error 179 at offset 11: syntax error in (?(VERSION condition
|
||||||
/(?(VERSION>=10.0.0)yes|no)/
|
/(?(VERSION>=10.0.0)yes|no)/
|
||||||
Failed: error 179 at offset 16: syntax error in (?(VERSION condition
|
Failed: error 179 at offset 16: syntax error in (?(VERSION condition
|
||||||
|
|
||||||
|
/abcd/I
|
||||||
|
Capturing subpattern count = 0
|
||||||
|
First code unit = 'a'
|
||||||
|
Last code unit = 'd'
|
||||||
|
Subject length lower bound = 4
|
||||||
|
|
||||||
|
/abcd/I,no_start_optimize
|
||||||
|
Capturing subpattern count = 0
|
||||||
|
Options: no_start_optimize
|
||||||
|
Subject length lower bound = 0
|
||||||
|
|
||||||
# End of testinput2
|
# End of testinput2
|
||||||
|
|
|
@ -7127,8 +7127,7 @@ No match
|
||||||
/(abc|def|xyz)/I,no_start_optimize
|
/(abc|def|xyz)/I,no_start_optimize
|
||||||
Capturing subpattern count = 1
|
Capturing subpattern count = 1
|
||||||
Options: no_start_optimize
|
Options: no_start_optimize
|
||||||
Starting code units: a d x
|
Subject length lower bound = 0
|
||||||
Subject length lower bound = 3
|
|
||||||
terhjk;abcdaadsfe
|
terhjk;abcdaadsfe
|
||||||
0: abc
|
0: abc
|
||||||
the quick xyz brown fox
|
the quick xyz brown fox
|
||||||
|
|
Loading…
Reference in New Issue