Revision: 471
http://vcs.pcre.org/viewvc?view=rev&revision=471
Author: ph10
Date: 2009-12-11 15:11:55 +0000 (Fri, 11 Dec 2009)
Log Message:
-----------
Fix study bug with single-branch conditions, including (DEFINE).
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/configure.ac
code/trunk/pcre_study.c
code/trunk/testdata/testinput2
code/trunk/testdata/testoutput2
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2009-10-29 09:18:01 UTC (rev 470)
+++ code/trunk/ChangeLog 2009-12-11 15:11:55 UTC (rev 471)
@@ -1,6 +1,15 @@
ChangeLog for PCRE
------------------
+Version 8.01 11-Dec-09
+----------------------
+
+1. If a pattern contained a conditional subpattern with only one branch (in
+ particular, this includes all (DEFINE) patterns), a call to pcre_study()
+ computed the wrong minimum data length (which is of course zero for such
+ subpatterns).
+
+
Version 8.00 19-Oct-09
----------------------
Modified: code/trunk/configure.ac
===================================================================
--- code/trunk/configure.ac 2009-10-29 09:18:01 UTC (rev 470)
+++ code/trunk/configure.ac 2009-12-11 15:11:55 UTC (rev 471)
@@ -7,9 +7,9 @@
dnl empty.
m4_define(pcre_major, [8])
-m4_define(pcre_minor, [00])
+m4_define(pcre_minor, [01])
m4_define(pcre_prerelease, [])
-m4_define(pcre_date, [2009-10-19])
+m4_define(pcre_date, [2009-12-11])
# Libtool shared library interface versions (current:revision:age)
m4_define(libpcre_version, [0:1:0])
Modified: code/trunk/pcre_study.c
===================================================================
--- code/trunk/pcre_study.c 2009-10-29 09:18:01 UTC (rev 470)
+++ code/trunk/pcre_study.c 2009-12-11 15:11:55 UTC (rev 471)
@@ -96,13 +96,28 @@
switch (op)
{
+ case OP_COND:
+ case OP_SCOND:
+
+ /* If there is only one branch in a condition, the implied branch has zero
+ length, so we don't add anything. This covers the DEFINE "condition"
+ automatically. */
+
+ cs = cc + GET(cc, 1);
+ if (*cs != OP_ALT)
+ {
+ cc = cs + 1 + LINK_SIZE;
+ break;
+ }
+
+ /* Otherwise we can fall through and treat it the same as any other
+ subpattern. */
+
case OP_CBRA:
case OP_SCBRA:
case OP_BRA:
case OP_SBRA:
case OP_ONCE:
- case OP_COND:
- case OP_SCOND:
d = find_minlength(cc, startcode, options);
if (d < 0) return d;
branchlength += d;
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2009-10-29 09:18:01 UTC (rev 470)
+++ code/trunk/testdata/testinput2 2009-12-11 15:11:55 UTC (rev 471)
@@ -3169,4 +3169,10 @@
/(\3)(\1)(a)/SI
cat
+/i(?(DEFINE)(?<s>a))/SI
+ i
+
+/()i(?(1)a)/SI
+ ia
+
/-- End of testinput2 --/
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2009-10-29 09:18:01 UTC (rev 470)
+++ code/trunk/testdata/testoutput2 2009-12-11 15:11:55 UTC (rev 471)
@@ -10463,4 +10463,27 @@
cat
No match
+/i(?(DEFINE)(?<s>a))/SI
+Capturing subpattern count = 1
+Named capturing subpatterns:
+ s 1
+No options
+First char = 'i'
+No need char
+Subject length lower bound = 1
+No set of starting bytes
+ i
+ 0: i
+
+/()i(?(1)a)/SI
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'i'
+Subject length lower bound = 1
+Starting byte set: i
+ ia
+ 0: ia
+ 1:
+
/-- End of testinput2 --/