summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2009-12-11 15:11:55 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2009-12-11 15:11:55 +0000
commitb84f61cc8c29b9d3c36794906770fe8b22bf2e0c (patch)
treef6398398a9afb57148418f1145e9319f52868a23
parent6613bb987ce876549e6bfd94e62ce0d909879ff2 (diff)
downloadpcre-b84f61cc8c29b9d3c36794906770fe8b22bf2e0c.tar.gz
Fix study bug with single-branch conditions, including (DEFINE).
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@471 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog9
-rw-r--r--configure.ac4
-rw-r--r--pcre_study.c19
-rw-r--r--testdata/testinput26
-rw-r--r--testdata/testoutput223
5 files changed, 57 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 40600b8..749a674 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
----------------------
diff --git a/configure.ac b/configure.ac
index 612810b..fc96ec4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,9 +7,9 @@ dnl be defined as -RC2, for example. For real releases, it should be defined
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])
diff --git a/pcre_study.c b/pcre_study.c
index 2462e3b..957a1fe 100644
--- a/pcre_study.c
+++ b/pcre_study.c
@@ -96,13 +96,28 @@ for (;;)
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;
diff --git a/testdata/testinput2 b/testdata/testinput2
index 3319bb7..c49b94f 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -3169,4 +3169,10 @@ a random value. /Ix
/(\3)(\1)(a)/SI
cat
+/i(?(DEFINE)(?<s>a))/SI
+ i
+
+/()i(?(1)a)/SI
+ ia
+
/-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 30ea63b..be968da 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -10463,4 +10463,27 @@ No set of starting bytes
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 --/