diff --git a/ChangeLog b/ChangeLog index 1d0f960..f58c3c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 -------------------------- diff --git a/doc/pcre2pattern.3 b/doc/pcre2pattern.3 index 7ab5aac..8b54910 100644 --- a/doc/pcre2pattern.3 +++ b/doc/pcre2pattern.3 @@ -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 diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index e185db7..5a0e817 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -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; diff --git a/testdata/testinput2 b/testdata/testinput2 index 9885ff8..c25b14d 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4018,6 +4018,8 @@ /(?(VERSION>=10.0.0)yes|no)/ +/(?(VERSION=10.101)yes|no)/ + /abcd/I /abcd/I,no_start_optimize diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 5040fbc..798cc24 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -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'