Fix VERSION condition bug.

This commit is contained in:
Philip.Hazel 2015-11-01 16:28:13 +00:00
parent a15528e565
commit f72b753f73
5 changed files with 17 additions and 5 deletions

View File

@ -240,6 +240,11 @@ second and subsequent calls to pcre2_match().
pcre2_substitute(). An added check for a number greater than the largest group
number in the pattern means this is not now needed.
70. The PCRE2-specific VERSION condition didn't work correctly if only one
digit was given after the decimal point, or if more than two digits were given.
It now works with one or two digits, and gives a compile time error if more are
given.
Version 10.20 30-June-2015
--------------------------

View File

@ -1,4 +1,4 @@
.TH PCRE2PATTERN 3 "16 October 2015" "PCRE2 10.21"
.TH PCRE2PATTERN 3 "01 November 2015" "PCRE2 10.21"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH "PCRE2 REGULAR EXPRESSION DETAILS"
@ -2534,7 +2534,8 @@ For example:
(?(VERSION>=10.4)yes|no)
.sp
This pattern matches "yes" if the PCRE2 version is greater or equal to 10.4, or
"no" otherwise.
"no" otherwise. The fractional part of the version number may not contain more
than two digits.
.
.
.SS "Assertion conditions"
@ -3392,6 +3393,6 @@ Cambridge, England.
.rs
.sp
.nf
Last updated: 16 October 2015
Last updated: 01 November 2015
Copyright (c) 1997-2015 University of Cambridge.
.fi

View File

@ -3731,7 +3731,7 @@ for (;; ptr++)
if (code > cb->start_workspace + cb->workspace_size -
WORK_SIZE_SAFETY_MARGIN) /* Check for overrun */
{
*errorcodeptr = (code >= cb->start_workspace + cb->workspace_size)?
*errorcodeptr = (code >= cb->start_workspace + cb->workspace_size)?
ERR52 : ERR86;
goto FAILED;
}
@ -5885,9 +5885,10 @@ for (;; ptr++)
{
ptr++;
while (IS_DIGIT(*ptr)) minor = minor * 10 + *ptr++ - '0';
if (minor < 10) minor *= 10;
}
if (*ptr != CHAR_RIGHT_PARENTHESIS)
if (*ptr != CHAR_RIGHT_PARENTHESIS || minor > 99)
{
*errorcodeptr = ERR79;
goto FAILED;

2
testdata/testinput2 vendored
View File

@ -4018,6 +4018,8 @@
/(?(VERSION>=10.0.0)yes|no)/
/(?(VERSION=10.101)yes|no)/
/abcd/I
/abcd/I,no_start_optimize

View File

@ -13386,6 +13386,9 @@ Failed: error 179 at offset 11: syntax error in (?(VERSION condition
/(?(VERSION>=10.0.0)yes|no)/
Failed: error 179 at offset 16: syntax error in (?(VERSION condition
/(?(VERSION=10.101)yes|no)/
Failed: error 179 at offset 17: syntax error in (?(VERSION condition
/abcd/I
Capturing subpattern count = 0
First code unit = 'a'