summaryrefslogtreecommitdiff
path: root/pcrecpp.cc
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-06-13 08:53:45 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-06-13 08:53:45 +0000
commitfb6cb91d5a1156bf15b5d3b83b2ac6a8f54c369f (patch)
tree203a35eb5e866541a010733ff6e0acfe12b09c4b /pcrecpp.cc
parentcc7768ebfd86be3e6126739dd2c66c76bc197ca1 (diff)
downloadpcre-fb6cb91d5a1156bf15b5d3b83b2ac6a8f54c369f.tar.gz
Apply C++ patch to fix a bad optimization.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@179 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcrecpp.cc')
-rw-r--r--pcrecpp.cc26
1 files changed, 4 insertions, 22 deletions
diff --git a/pcrecpp.cc b/pcrecpp.cc
index 3fb7411..ffb873f 100644
--- a/pcrecpp.cc
+++ b/pcrecpp.cc
@@ -77,25 +77,14 @@ void RE::Init(const string& pat, const RE_Options* options) {
re_partial_ = Compile(UNANCHORED);
if (re_partial_ != NULL) {
- // Check for complicated patterns. The following change is
- // conservative in that it may treat some "simple" patterns
- // as "complex" (e.g., if the vertical bar is in a character
- // class or is escaped). But it seems good enough.
- if (strchr(pat.c_str(), '|') == NULL) {
- // Simple pattern: we can use position-based checks to perform
- // fully anchored matches
- re_full_ = re_partial_;
- } else {
- // We need a special pattern for anchored matches
- re_full_ = Compile(ANCHOR_BOTH);
- }
+ re_full_ = Compile(ANCHOR_BOTH);
}
}
void RE::Cleanup() {
- if (re_full_ != NULL && re_full_ != re_partial_) (*pcre_free)(re_full_);
- if (re_partial_ != NULL) (*pcre_free)(re_partial_);
- if (error_ != &empty_string) delete error_;
+ if (re_full_ != NULL) (*pcre_free)(re_full_);
+ if (re_partial_ != NULL) (*pcre_free)(re_partial_);
+ if (error_ != &empty_string) delete error_;
}
@@ -507,13 +496,6 @@ int RE::TryMatch(const StringPiece& text,
rc = vecsize / 2;
}
- if ((anchor == ANCHOR_BOTH) && (re_full_ == re_partial_)) {
- // We need an extra check to make sure that the match extended
- // to the end of the input string
- assert(vec[0] == 0); // PCRE_ANCHORED forces starting match
- if (vec[1] != text.size()) return 0; // Did not get ending match
- }
-
return rc;
}