summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2018-02-20 15:33:30 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2018-02-20 15:33:30 +0900
commita505f5bb519f934c2cd2f1c7f80f5c0466900636 (patch)
tree15a425d198f941db026f28791060ff3094c87ca3
parent78801a28ef790790945eb3cfe5389a554a4ac044 (diff)
downloadre2-a505f5bb519f934c2cd2f1c7f80f5c0466900636.tar.gz
re2-a505f5bb519f934c2cd2f1c7f80f5c0466900636.tar.bz2
re2-a505f5bb519f934c2cd2f1c7f80f5c0466900636.zip
Imported Upstream version 20170101upstream/20170101
Change-Id: I6280eca50b009db2d5fb74e32239c36bbfbf1b9b Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
-rw-r--r--CMakeLists.txt2
-rw-r--r--kokoro/ubuntu-bazel.cfg1
-rwxr-xr-xkokoro/ubuntu-bazel.sh (renamed from kokoro/ubuntu/continuous-bazel.sh)0
-rw-r--r--kokoro/ubuntu/continuous-bazel.cfg1
-rwxr-xr-xkokoro/windows-cmake.bat (renamed from kokoro/windows/continuous-cmake.bat)0
-rw-r--r--kokoro/windows-cmake.cfg1
-rw-r--r--kokoro/windows/continuous-cmake.cfg1
-rw-r--r--re2/bitstate.cc2
-rw-r--r--re2/dfa.cc4
-rw-r--r--re2/fuzzing/re2_fuzzer.cc3
-rw-r--r--re2/parse.cc14
-rw-r--r--re2/re2.cc2
-rw-r--r--re2/set.h1
-rw-r--r--re2/simplify.cc12
-rw-r--r--re2/testing/backtrack.cc2
-rw-r--r--re2/testing/dfa_test.cc23
-rw-r--r--re2/testing/re2_test.cc10
-rw-r--r--re2/testing/regexp_benchmark.cc24
-rw-r--r--re2/testing/string_generator.cc2
-rw-r--r--re2/testing/tester.cc2
-rw-r--r--re2/testing/tester.h2
21 files changed, 57 insertions, 52 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c90f5d..0afdbc7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -128,4 +128,4 @@ set(RE2_HEADERS
)
install(FILES ${RE2_HEADERS} DESTINATION include/re2)
-install(TARGETS re2 ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
+install(TARGETS re2 ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
diff --git a/kokoro/ubuntu-bazel.cfg b/kokoro/ubuntu-bazel.cfg
new file mode 100644
index 0000000..884d14f
--- /dev/null
+++ b/kokoro/ubuntu-bazel.cfg
@@ -0,0 +1 @@
+build_file: "re2/kokoro/ubuntu-bazel.sh"
diff --git a/kokoro/ubuntu/continuous-bazel.sh b/kokoro/ubuntu-bazel.sh
index 6f25982..6f25982 100755
--- a/kokoro/ubuntu/continuous-bazel.sh
+++ b/kokoro/ubuntu-bazel.sh
diff --git a/kokoro/ubuntu/continuous-bazel.cfg b/kokoro/ubuntu/continuous-bazel.cfg
deleted file mode 100644
index 5a48a4f..0000000
--- a/kokoro/ubuntu/continuous-bazel.cfg
+++ /dev/null
@@ -1 +0,0 @@
-build_file: "re2/kokoro/ubuntu/continuous-bazel.sh"
diff --git a/kokoro/windows/continuous-cmake.bat b/kokoro/windows-cmake.bat
index b6d2f6f..b6d2f6f 100755
--- a/kokoro/windows/continuous-cmake.bat
+++ b/kokoro/windows-cmake.bat
diff --git a/kokoro/windows-cmake.cfg b/kokoro/windows-cmake.cfg
new file mode 100644
index 0000000..4453eb6
--- /dev/null
+++ b/kokoro/windows-cmake.cfg
@@ -0,0 +1 @@
+build_file: "re2/kokoro/windows-cmake.bat"
diff --git a/kokoro/windows/continuous-cmake.cfg b/kokoro/windows/continuous-cmake.cfg
deleted file mode 100644
index cc6d4aa..0000000
--- a/kokoro/windows/continuous-cmake.cfg
+++ /dev/null
@@ -1 +0,0 @@
-build_file: "re2/kokoro/windows/continuous-cmake.bat"
diff --git a/re2/bitstate.cc b/re2/bitstate.cc
index 4b92fee..5ca2aa3 100644
--- a/re2/bitstate.cc
+++ b/re2/bitstate.cc
@@ -324,7 +324,7 @@ bool BitState::Search(const StringPiece& text, const StringPiece& context,
submatch_ = submatch;
nsubmatch_ = nsubmatch;
for (int i = 0; i < nsubmatch_; i++)
- submatch_[i] = NULL;
+ submatch_[i] = StringPiece();
// Allocate scratch space.
nvisited_ = (prog_->size() * (text.size()+1) + VisitedBits-1) / VisitedBits;
diff --git a/re2/dfa.cc b/re2/dfa.cc
index 417efc1..2e60910 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -1891,7 +1891,7 @@ int DFA::BuildAllStates() {
// Pick out start state for unanchored search
// at beginning of text.
RWLocker l(&cache_mutex_);
- SearchParams params(NULL, NULL, &l);
+ SearchParams params(StringPiece(), StringPiece(), &l);
params.anchored = false;
if (!AnalyzeSearch(&params) || params.start <= SpecialStateMax)
return 0;
@@ -1950,7 +1950,7 @@ bool DFA::PossibleMatchRange(string* min, string* max, int maxlen) {
// Pick out start state for anchored search at beginning of text.
RWLocker l(&cache_mutex_);
- SearchParams params(NULL, NULL, &l);
+ SearchParams params(StringPiece(), StringPiece(), &l);
params.anchored = true;
if (!AnalyzeSearch(&params))
return false;
diff --git a/re2/fuzzing/re2_fuzzer.cc b/re2/fuzzing/re2_fuzzer.cc
index 6bf771f..f9326cf 100644
--- a/re2/fuzzing/re2_fuzzer.cc
+++ b/re2/fuzzing/re2_fuzzer.cc
@@ -21,9 +21,10 @@ void Test(StringPiece pattern, const RE2::Options& options, StringPiece text) {
return;
// Don't waste time fuzzing high-fanout programs.
+ // (They can also cause bug reports due to fuzzer timeouts.)
std::map<int, int> histogram;
int fanout = re.ProgramFanout(&histogram);
- if (fanout > 10)
+ if (fanout > 9)
return;
StringPiece sp1, sp2, sp3, sp4;
diff --git a/re2/parse.cc b/re2/parse.cc
index b71b3ea..03a43a9 100644
--- a/re2/parse.cc
+++ b/re2/parse.cc
@@ -1289,7 +1289,7 @@ static int StringPieceToRune(Rune *r, StringPiece *sp, RegexpStatus* status) {
}
status->set_code(kRegexpBadUTF8);
- status->set_error_arg(NULL);
+ status->set_error_arg(StringPiece());
return -1;
}
@@ -1333,12 +1333,12 @@ static bool ParseEscape(StringPiece* s, Rune* rp,
if (s->size() < 1 || (*s)[0] != '\\') {
// Should not happen - caller always checks.
status->set_code(kRegexpInternalError);
- status->set_error_arg(NULL);
+ status->set_error_arg(StringPiece());
return false;
}
if (s->size() < 2) {
status->set_code(kRegexpTrailingBackslash);
- status->set_error_arg(NULL);
+ status->set_error_arg(StringPiece());
return false;
}
Rune c, c1;
@@ -1793,7 +1793,7 @@ bool Regexp::ParseState::ParseCharClass(StringPiece* s,
if (s->size() == 0 || (*s)[0] != '[') {
// Caller checked this.
status->set_code(kRegexpInternalError);
- status->set_error_arg(NULL);
+ status->set_error_arg(StringPiece());
return false;
}
bool negated = false;
@@ -2108,9 +2108,9 @@ Regexp* Regexp::Parse(const StringPiece& s, ParseFlags global_flags,
return ps.DoFinish();
}
- StringPiece lastunary = NULL;
+ StringPiece lastunary = StringPiece();
while (t.size() > 0) {
- StringPiece isunary = NULL;
+ StringPiece isunary = StringPiece();
switch (t[0]) {
default: {
Rune r;
@@ -2133,7 +2133,7 @@ Regexp* Regexp::Parse(const StringPiece& s, ParseFlags global_flags,
if (!ps.DoLeftParenNoCapture())
return NULL;
} else {
- if (!ps.DoLeftParen(NULL))
+ if (!ps.DoLeftParen(StringPiece()))
return NULL;
}
t.remove_prefix(1); // '('
diff --git a/re2/re2.cc b/re2/re2.cc
index 132257b..fa29100 100644
--- a/re2/re2.cc
+++ b/re2/re2.cc
@@ -785,7 +785,7 @@ bool RE2::Match(const StringPiece& text,
// Zero submatches that don't exist in the regexp.
for (int i = ncap; i < nsubmatch; i++)
- submatch[i] = NULL;
+ submatch[i] = StringPiece();
return true;
}
diff --git a/re2/set.h b/re2/set.h
index 54d75a0..c31d500 100644
--- a/re2/set.h
+++ b/re2/set.h
@@ -41,6 +41,7 @@ class RE2::Set {
// Match returns true if text matches any of the regexps in the set.
// If so, it fills v (if not NULL) with the indices of the matching regexps.
+ // Callers must not expect v to be sorted.
bool Match(const StringPiece& text, std::vector<int>* v) const;
private:
diff --git a/re2/simplify.cc b/re2/simplify.cc
index 06f0386..910ebcc 100644
--- a/re2/simplify.cc
+++ b/re2/simplify.cc
@@ -589,12 +589,12 @@ Regexp* SimplifyWalker::SimplifyRepeat(Regexp* re, int min, int max,
return Regexp::Plus(re->Incref(), f);
// General case: x{4,} is xxxx+
- Regexp* nre = new Regexp(kRegexpConcat, f);
- nre->AllocSub(min);
- Regexp** nre_subs = nre->sub();
+ Regexp** nre_subs = new Regexp*[min];
for (int i = 0; i < min-1; i++)
nre_subs[i] = re->Incref();
nre_subs[min-1] = Regexp::Plus(re->Incref(), f);
+ Regexp* nre = Regexp::Concat(nre_subs, min, f);
+ delete[] nre_subs;
return nre;
}
@@ -613,11 +613,11 @@ Regexp* SimplifyWalker::SimplifyRepeat(Regexp* re, int min, int max,
// Build leading prefix: xx. Capturing only on the last one.
Regexp* nre = NULL;
if (min > 0) {
- nre = new Regexp(kRegexpConcat, f);
- nre->AllocSub(min);
- Regexp** nre_subs = nre->sub();
+ Regexp** nre_subs = new Regexp*[min];
for (int i = 0; i < min; i++)
nre_subs[i] = re->Incref();
+ nre = Regexp::Concat(nre_subs, min, f);
+ delete[] nre_subs;
}
// Build and attach suffix: (x(x(x)?)?)?
diff --git a/re2/testing/backtrack.cc b/re2/testing/backtrack.cc
index a16b54f..d535dd4 100644
--- a/re2/testing/backtrack.cc
+++ b/re2/testing/backtrack.cc
@@ -126,7 +126,7 @@ bool Backtracker::Search(const StringPiece& text, const StringPiece& context,
submatch_ = &sp0;
nsubmatch_ = 1;
}
- submatch_[0] = NULL;
+ submatch_[0] = StringPiece();
// Allocate new visited_ bitmap -- size is proportional
// to text, so have to reallocate on each call to Search.
diff --git a/re2/testing/dfa_test.cc b/re2/testing/dfa_test.cc
index e56b3e0..55b3be4 100644
--- a/re2/testing/dfa_test.cc
+++ b/re2/testing/dfa_test.cc
@@ -192,14 +192,12 @@ TEST(SingleThreaded, SearchDFA) {
for (int i = 0; i < 10; i++) {
bool matched = false;
bool failed = false;
- matched = prog->SearchDFA(match, NULL,
- Prog::kUnanchored, Prog::kFirstMatch,
- NULL, &failed, NULL);
+ matched = prog->SearchDFA(match, StringPiece(), Prog::kUnanchored,
+ Prog::kFirstMatch, NULL, &failed, NULL);
CHECK(!failed);
CHECK(matched);
- matched = prog->SearchDFA(no_match, NULL,
- Prog::kUnanchored, Prog::kFirstMatch,
- NULL, &failed, NULL);
+ matched = prog->SearchDFA(no_match, StringPiece(), Prog::kUnanchored,
+ Prog::kFirstMatch, NULL, &failed, NULL);
CHECK(!failed);
CHECK(!matched);
}
@@ -226,14 +224,12 @@ static void DoSearch(Prog* prog, const StringPiece& match,
for (int i = 0; i < 2; i++) {
bool matched = false;
bool failed = false;
- matched = prog->SearchDFA(match, NULL,
- Prog::kUnanchored, Prog::kFirstMatch,
- NULL, &failed, NULL);
+ matched = prog->SearchDFA(match, StringPiece(), Prog::kUnanchored,
+ Prog::kFirstMatch, NULL, &failed, NULL);
CHECK(!failed);
CHECK(matched);
- matched = prog->SearchDFA(no_match, NULL,
- Prog::kUnanchored, Prog::kFirstMatch,
- NULL, &failed, NULL);
+ matched = prog->SearchDFA(no_match, StringPiece(), Prog::kUnanchored,
+ Prog::kFirstMatch, NULL, &failed, NULL);
CHECK(!failed);
CHECK(!matched);
}
@@ -306,7 +302,8 @@ TEST(DFA, ReverseMatch) {
Prog *prog = re->CompileToReverseProg(0);
CHECK(prog);
bool failed = false;
- bool matched = prog->SearchDFA(t.text, NULL, Prog::kUnanchored, Prog::kFirstMatch, NULL, &failed, NULL);
+ bool matched = prog->SearchDFA(t.text, StringPiece(), Prog::kUnanchored,
+ Prog::kFirstMatch, NULL, &failed, NULL);
if (matched != t.match) {
LOG(ERROR) << t.regexp << " on " << t.text << ": want " << t.match;
nfail++;
diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc
index d42d597..2b05333 100644
--- a/re2/testing/re2_test.cc
+++ b/re2/testing/re2_test.cc
@@ -1458,7 +1458,7 @@ TEST(RE2, NullVsEmptyStringSubmatches) {
EXPECT_TRUE(re.Match(null, 0, null.size(), RE2::UNANCHORED,
matches, arraysize(matches)));
for (int i = 0; i < arraysize(matches); i++) {
- EXPECT_TRUE(matches[i] == NULL);
+ EXPECT_TRUE(matches[i] == StringPiece());
EXPECT_TRUE(matches[i].data() == NULL); // always null
EXPECT_TRUE(matches[i] == "");
}
@@ -1469,16 +1469,16 @@ TEST(RE2, NullVsEmptyStringSubmatches) {
StringPiece empty("");
EXPECT_TRUE(re.Match(empty, 0, empty.size(), RE2::UNANCHORED,
matches, arraysize(matches)));
- EXPECT_TRUE(matches[0] == NULL);
+ EXPECT_TRUE(matches[0] == StringPiece());
EXPECT_TRUE(matches[0].data() != NULL); // empty, not null
EXPECT_TRUE(matches[0] == "");
- EXPECT_TRUE(matches[1] == NULL);
+ EXPECT_TRUE(matches[1] == StringPiece());
EXPECT_TRUE(matches[1].data() != NULL); // empty, not null
EXPECT_TRUE(matches[1] == "");
- EXPECT_TRUE(matches[2] == NULL);
+ EXPECT_TRUE(matches[2] == StringPiece());
EXPECT_TRUE(matches[2].data() == NULL);
EXPECT_TRUE(matches[2] == "");
- EXPECT_TRUE(matches[3] == NULL);
+ EXPECT_TRUE(matches[3] == StringPiece());
EXPECT_TRUE(matches[3].data() == NULL);
EXPECT_TRUE(matches[3] == "");
}
diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc
index 8f437b5..efd8450 100644
--- a/re2/testing/regexp_benchmark.cc
+++ b/re2/testing/regexp_benchmark.cc
@@ -886,7 +886,7 @@ void SearchDFA(int iters, const char* regexp, const StringPiece& text,
Prog* prog = re->CompileToProg(0);
CHECK(prog);
bool failed = false;
- CHECK_EQ(prog->SearchDFA(text, NULL, anchor, Prog::kFirstMatch,
+ CHECK_EQ(prog->SearchDFA(text, StringPiece(), anchor, Prog::kFirstMatch,
NULL, &failed, NULL),
expect_match);
CHECK(!failed);
@@ -902,7 +902,8 @@ void SearchNFA(int iters, const char* regexp, const StringPiece& text,
CHECK(re);
Prog* prog = re->CompileToProg(0);
CHECK(prog);
- CHECK_EQ(prog->SearchNFA(text, NULL, anchor, Prog::kFirstMatch, NULL, 0),
+ CHECK_EQ(prog->SearchNFA(text, StringPiece(), anchor, Prog::kFirstMatch,
+ NULL, 0),
expect_match);
delete prog;
re->Decref();
@@ -974,8 +975,8 @@ void SearchCachedDFA(int iters, const char* regexp, const StringPiece& text,
CHECK(prog);
for (int i = 0; i < iters; i++) {
bool failed = false;
- CHECK_EQ(prog->SearchDFA(text, NULL, anchor,
- Prog::kFirstMatch, NULL, &failed, NULL),
+ CHECK_EQ(prog->SearchDFA(text, StringPiece(), anchor, Prog::kFirstMatch,
+ NULL, &failed, NULL),
expect_match);
CHECK(!failed);
}
@@ -990,7 +991,8 @@ void SearchCachedNFA(int iters, const char* regexp, const StringPiece& text,
Prog* prog = re->CompileToProg(0);
CHECK(prog);
for (int i = 0; i < iters; i++) {
- CHECK_EQ(prog->SearchNFA(text, NULL, anchor, Prog::kFirstMatch, NULL, 0),
+ CHECK_EQ(prog->SearchNFA(text, StringPiece(), anchor, Prog::kFirstMatch,
+ NULL, 0),
expect_match);
}
delete prog;
@@ -1059,7 +1061,8 @@ void Parse3NFA(int iters, const char* regexp, const StringPiece& text) {
Prog* prog = re->CompileToProg(0);
CHECK(prog);
StringPiece sp[4]; // 4 because sp[0] is whole match.
- CHECK(prog->SearchNFA(text, NULL, Prog::kAnchored, Prog::kFullMatch, sp, 4));
+ CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
+ Prog::kFullMatch, sp, 4));
delete prog;
re->Decref();
}
@@ -1130,7 +1133,8 @@ void Parse3CachedNFA(int iters, const char* regexp, const StringPiece& text) {
CHECK(prog);
StringPiece sp[4]; // 4 because sp[0] is whole match.
for (int i = 0; i < iters; i++) {
- CHECK(prog->SearchNFA(text, NULL, Prog::kAnchored, Prog::kFullMatch, sp, 4));
+ CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
+ Prog::kFullMatch, sp, 4));
}
delete prog;
re->Decref();
@@ -1202,7 +1206,8 @@ void Parse1NFA(int iters, const char* regexp, const StringPiece& text) {
Prog* prog = re->CompileToProg(0);
CHECK(prog);
StringPiece sp[2]; // 2 because sp[0] is whole match.
- CHECK(prog->SearchNFA(text, NULL, Prog::kAnchored, Prog::kFullMatch, sp, 2));
+ CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
+ Prog::kFullMatch, sp, 2));
delete prog;
re->Decref();
}
@@ -1260,7 +1265,8 @@ void Parse1CachedNFA(int iters, const char* regexp, const StringPiece& text) {
CHECK(prog);
StringPiece sp[2]; // 2 because sp[0] is whole match.
for (int i = 0; i < iters; i++) {
- CHECK(prog->SearchNFA(text, NULL, Prog::kAnchored, Prog::kFullMatch, sp, 2));
+ CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
+ Prog::kFullMatch, sp, 2));
}
delete prog;
re->Decref();
diff --git a/re2/testing/string_generator.cc b/re2/testing/string_generator.cc
index b789950..b659d34 100644
--- a/re2/testing/string_generator.cc
+++ b/re2/testing/string_generator.cc
@@ -85,7 +85,7 @@ const StringPiece& StringGenerator::Next() {
CHECK(hasnext_);
if (generate_null_) {
generate_null_ = false;
- sp_ = NULL;
+ sp_ = StringPiece();
return sp_;
}
s_.clear();
diff --git a/re2/testing/tester.cc b/re2/testing/tester.cc
index 59779f7..d7fe319 100644
--- a/re2/testing/tester.cc
+++ b/re2/testing/tester.cc
@@ -473,7 +473,7 @@ void TestInstance::RunSearch(Engine type,
// StringPiece(text.begin() - 1, 0). Oops.
for (int i = 0; i < nsubmatch; i++)
if (result->submatch[i].begin() == text.begin() - 1)
- result->submatch[i] = NULL;
+ result->submatch[i] = StringPiece();
delete[] argptr;
delete[] a;
break;
diff --git a/re2/testing/tester.h b/re2/testing/tester.h
index 112c6ec..47d0c43 100644
--- a/re2/testing/tester.h
+++ b/re2/testing/tester.h
@@ -72,7 +72,7 @@ class TestInstance {
void LogMatch(const char* prefix, Engine e, const StringPiece& text,
const StringPiece& context, Prog::Anchor anchor);
- const StringPiece& regexp_str_; // regexp being tested
+ const StringPiece regexp_str_; // regexp being tested
Prog::MatchKind kind_; // kind of match
Regexp::ParseFlags flags_; // flags for parsing regexp_str_
bool error_; // error during constructor?