[Pcre-svn] [957] code/trunk: Fix bug in VERSION number readi…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [957] code/trunk: Fix bug in VERSION number reading.
Revision: 957
          http://www.exim.org/viewvc/pcre2?view=rev&revision=957
Author:   ph10
Date:     2018-07-02 13:26:04 +0100 (Mon, 02 Jul 2018)
Log Message:
-----------
Fix bug in VERSION number reading.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-07-02 11:23:45 UTC (rev 956)
+++ code/trunk/ChangeLog    2018-07-02 12:26:04 UTC (rev 957)
@@ -104,6 +104,9 @@
 22. When checking to see if a lookbehind is of fixed length, lookaheads were 
 correctly ignored, but qualifiers on lookaheads were not being ignored, leading 
 to an incorrect "lookbehind assertion is not fixed length" error.
+
+23. The VERSION condition test was reading fractional PCRE2 version numbers 
+such as the 04 in 10.04 incorrectly and hence giving wrong results.



Version 10.31 12-February-2018

Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2018-07-02 11:23:45 UTC (rev 956)
+++ code/trunk/src/pcre2_compile.c    2018-07-02 12:26:04 UTC (rev 957)
@@ -3896,9 +3896,8 @@
         if (*ptr == CHAR_DOT)
           {
           if (++ptr >= ptrend || !IS_DIGIT(*ptr)) goto BAD_VERSION_CONDITION;
-          if (!read_number(&ptr, ptrend, -1, 99 , ERR79, &minor, &errorcode))
-            goto FAILED;
-          if (minor < 10) minor *= 10;
+          minor = (*ptr++ - CHAR_0) * 10;
+          if (IS_DIGIT(*ptr)) minor += *ptr++ - CHAR_0; 
           if (ptr >= ptrend || *ptr != CHAR_RIGHT_PARENTHESIS)
             goto BAD_VERSION_CONDITION;
           }


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2018-07-02 11:23:45 UTC (rev 956)
+++ code/trunk/testdata/testinput2    2018-07-02 12:26:04 UTC (rev 957)
@@ -4007,6 +4007,9 @@
 /(?(VERSION>=10.0)yes|no)/I
     yesno


+/(?(VERSION>=10.04)yes|no)/
+    yesno
+
 /(?(VERSION=8)yes){3}/BI,aftertext
     yesno



Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2018-07-02 11:23:45 UTC (rev 956)
+++ code/trunk/testdata/testoutput2    2018-07-02 12:26:04 UTC (rev 957)
@@ -13483,6 +13483,10 @@
     yesno
  0: yes


+/(?(VERSION>=10.04)yes|no)/
+    yesno
+ 0: yes
+
 /(?(VERSION=8)yes){3}/BI,aftertext
 ------------------------------------------------------------------
         Bra
@@ -13537,7 +13541,7 @@
 Failed: error 179 at offset 16: syntax error or number too big in (?(VERSION condition


/(?(VERSION=10.101)yes|no)/
-Failed: error 179 at offset 17: syntax error or number too big in (?(VERSION condition
+Failed: error 179 at offset 16: syntax error or number too big in (?(VERSION condition

/abcd/I
Capturing subpattern count = 0