summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-09-25 15:36:38 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-09-25 15:36:38 +0900
commitb039669355fa5033ca3fa1c30e9b9ccb381eed53 (patch)
tree1d6b91d28dd808543807cf29322143b86c1e28b5
parent35612b8b1de67ece87a87c1a16a498a20fe42347 (diff)
downloadre2-b039669355fa5033ca3fa1c30e9b9ccb381eed53.tar.gz
re2-b039669355fa5033ca3fa1c30e9b9ccb381eed53.tar.bz2
re2-b039669355fa5033ca3fa1c30e9b9ccb381eed53.zip
Imported Upstream version 20190701upstream/20190701
-rw-r--r--re2/dfa.cc6
-rw-r--r--re2/filtered_re2.h7
-rw-r--r--re2/testing/set_test.cc14
3 files changed, 7 insertions, 20 deletions
diff --git a/re2/dfa.cc b/re2/dfa.cc
index 91292d4..81adb30 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -1415,9 +1415,11 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params,
// byte runs at about 0.2 MB/s, while the NFA (nfa.cc) can do the
// same at about 2 MB/s. Unless we're processing an average
// of 10 bytes per state computation, fail so that RE2 can
- // fall back to the NFA.
+ // fall back to the NFA. However, RE2::Set cannot fall back,
+ // so we just have to keep on keeping on in that case.
if (dfa_should_bail_when_slow && resetp != NULL &&
- static_cast<size_t>(p - resetp) < 10*state_cache_.size()) {
+ static_cast<size_t>(p - resetp) < 10*state_cache_.size() &&
+ kind_ != Prog::kManyMatch) {
params->failed = true;
return false;
}
diff --git a/re2/filtered_re2.h b/re2/filtered_re2.h
index 965b5c9..4118acc 100644
--- a/re2/filtered_re2.h
+++ b/re2/filtered_re2.h
@@ -80,11 +80,10 @@ class FilteredRE2 {
// The number of regexps added.
int NumRegexps() const { return static_cast<int>(re2_vec_.size()); }
- private:
-
- // Get the individual RE2 objects. Useful for testing.
- RE2* GetRE2(int regexpid) const { return re2_vec_[regexpid]; }
+ // Get the individual RE2 objects.
+ const RE2& GetRE2(int regexpid) const { return *re2_vec_[regexpid]; }
+ private:
// Print prefilter.
void PrintPrefilter(int regexpid);
diff --git a/re2/testing/set_test.cc b/re2/testing/set_test.cc
index ad20ed7..61d1cf2 100644
--- a/re2/testing/set_test.cc
+++ b/re2/testing/set_test.cc
@@ -201,18 +201,4 @@ TEST(Set, Prefix) {
ASSERT_EQ(v[0], 0);
}
-TEST(Set, OutOfMemory) {
- RE2::Set s(RE2::DefaultOptions, RE2::UNANCHORED);
-
- std::string a(10000, 'a');
- ASSERT_EQ(s.Add(a, NULL), 0);
- ASSERT_EQ(s.Compile(), true);
-
- std::vector<int> v;
- RE2::Set::ErrorInfo ei;
- ASSERT_EQ(s.Match(a, &v, &ei), false);
- ASSERT_EQ(v.size(), 0);
- ASSERT_EQ(ei.kind, RE2::Set::kOutOfMemory);
-}
-
} // namespace re2