diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2018-02-20 15:35:31 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2018-02-20 15:35:31 +0900 |
commit | 322178004d7dd9ce4f6c7b4a836fb811ab9ce580 (patch) | |
tree | e95c7b6c9ecf91778a66f3944ba8e4b93c1965d3 | |
parent | 3a47f479d31e110ddf0f3c72eaba760299b96a53 (diff) | |
download | re2-322178004d7dd9ce4f6c7b4a836fb811ab9ce580.tar.gz re2-322178004d7dd9ce4f6c7b4a836fb811ab9ce580.tar.bz2 re2-322178004d7dd9ce4f6c7b4a836fb811ab9ce580.zip |
Imported Upstream version 20170601upstream/20170601
Change-Id: I4011959bfb6216c467975179d81185aadcac2592
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
-rw-r--r-- | CMakeLists.txt | 105 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | re2/re2.cc | 2 | ||||
-rw-r--r-- | re2/regexp.cc | 2 | ||||
-rw-r--r-- | re2/regexp.h | 6 | ||||
-rw-r--r-- | re2/testing/required_prefix_test.cc | 8 |
6 files changed, 65 insertions, 60 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cfb946c..dd302a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") cmake_minimum_required(VERSION 3.4) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() + # CMake defaults to /W3, but some users like /W4 (or /Wall) and /WX, + # so we disable various warnings that aren't particularly helpful. + add_compile_options(/wd4100 /wd4201 /wd4456 /wd4457 /wd4702 /wd4815) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_compile_options(-std=c++11) endif() @@ -72,59 +75,59 @@ set(RE2_SOURCES add_library(re2 ${RE2_SOURCES}) -set(TESTING_SOURCES - re2/testing/backtrack.cc - re2/testing/dump.cc - re2/testing/exhaustive_tester.cc - re2/testing/null_walker.cc - re2/testing/regexp_generator.cc - re2/testing/string_generator.cc - re2/testing/tester.cc - util/pcre.cc - ) - -add_library(testing STATIC ${TESTING_SOURCES}) - -set(TEST_TARGETS - charclass_test - compile_test - filtered_re2_test - mimics_pcre_test - parse_test - possible_match_test - re2_test - re2_arg_test - regexp_test - required_prefix_test - search_test - set_test - simplify_test - string_generator_test - - dfa_test - exhaustive1_test - exhaustive2_test - exhaustive3_test - exhaustive_test - random_test - ) - -set(BENCHMARK_TARGETS - regexp_benchmark - ) - -foreach(target ${TEST_TARGETS}) - add_executable(${target} re2/testing/${target}.cc util/test.cc) - target_link_libraries(${target} testing re2 ${EXTRA_TARGET_LINK_LIBRARIES}) - if(RE2_BUILD_TESTING) +if(RE2_BUILD_TESTING) + set(TESTING_SOURCES + re2/testing/backtrack.cc + re2/testing/dump.cc + re2/testing/exhaustive_tester.cc + re2/testing/null_walker.cc + re2/testing/regexp_generator.cc + re2/testing/string_generator.cc + re2/testing/tester.cc + util/pcre.cc + ) + + add_library(testing STATIC ${TESTING_SOURCES}) + + set(TEST_TARGETS + charclass_test + compile_test + filtered_re2_test + mimics_pcre_test + parse_test + possible_match_test + re2_test + re2_arg_test + regexp_test + required_prefix_test + search_test + set_test + simplify_test + string_generator_test + + dfa_test + exhaustive1_test + exhaustive2_test + exhaustive3_test + exhaustive_test + random_test + ) + + set(BENCHMARK_TARGETS + regexp_benchmark + ) + + foreach(target ${TEST_TARGETS}) + add_executable(${target} re2/testing/${target}.cc util/test.cc) + target_link_libraries(${target} testing re2 ${EXTRA_TARGET_LINK_LIBRARIES}) add_test(NAME ${target} COMMAND ${target}) - endif() -endforeach(target) + endforeach(target) -foreach(target ${BENCHMARK_TARGETS}) - add_executable(${target} re2/testing/${target}.cc util/benchmark.cc) - target_link_libraries(${target} testing re2 ${EXTRA_TARGET_LINK_LIBRARIES}) -endforeach(target) + foreach(target ${BENCHMARK_TARGETS}) + add_executable(${target} re2/testing/${target}.cc util/benchmark.cc) + target_link_libraries(${target} testing re2 ${EXTRA_TARGET_LINK_LIBRARIES}) + endforeach(target) +endif() set(RE2_HEADERS re2/filtered_re2.h @@ -55,7 +55,7 @@ ifeq ($(shell uname),Darwin) SOEXT=dylib SOEXTVER=$(SONAME).$(SOEXT) SOEXTVER00=$(SONAME).0.0.$(SOEXT) -MAKE_SHARED_LIBRARY=$(CXX) -dynamiclib -Wl,-install_name,@rpath/libre2.$(SOEXTVER),-exported_symbols_list,libre2.symbols.darwin $(RE2_LDFLAGS) $(LDFLAGS) +MAKE_SHARED_LIBRARY=$(CXX) -dynamiclib -Wl,-install_name,$(libdir)/libre2.$(SOEXTVER),-exported_symbols_list,libre2.symbols.darwin $(RE2_LDFLAGS) $(LDFLAGS) else ifeq ($(shell uname),SunOS) SOEXT=so SOEXTVER=$(SOEXT).$(SONAME) @@ -200,8 +200,6 @@ void RE2::Init(const StringPiece& pattern, const Options& options) { return; } - prefix_.clear(); - prefix_foldcase_ = false; re2::Regexp* suffix; if (entire_regexp_->RequiredPrefix(&prefix_, &prefix_foldcase_, &suffix)) suffix_regexp_ = suffix; diff --git a/re2/regexp.cc b/re2/regexp.cc index 712f92d..34209bc 100644 --- a/re2/regexp.cc +++ b/re2/regexp.cc @@ -653,7 +653,7 @@ std::map<int, string>* Regexp::CaptureNames() { // with a fixed string prefix. If so, returns the prefix and // the regexp that remains after the prefix. The prefix might // be ASCII case-insensitive. -bool Regexp::RequiredPrefix(string *prefix, bool *foldcase, Regexp** suffix) { +bool Regexp::RequiredPrefix(string* prefix, bool* foldcase, Regexp** suffix) { // No need for a walker: the regexp must be of the form // 1. some number of ^ anchors // 2. a literal char or string diff --git a/re2/regexp.h b/re2/regexp.h index f0e3faa..fcc7c0f 100644 --- a/re2/regexp.h +++ b/re2/regexp.h @@ -436,7 +436,9 @@ class Regexp { // begin with a non-empty fixed string (perhaps after ASCII // case-folding). If so, returns the prefix and the sub-regexp that // follows it. - bool RequiredPrefix(string* prefix, bool *foldcase, Regexp** suffix); + // Callers should expect *prefix, *foldcase and *suffix to be "zeroed" + // regardless of the return value. + bool RequiredPrefix(string* prefix, bool* foldcase, Regexp** suffix); private: // Constructor allocates vectors as appropriate for operator. @@ -505,7 +507,7 @@ class Regexp { DCHECK(n >= 0 && static_cast<uint16_t>(n) == n); if (n > 1) submany_ = new Regexp*[n]; - nsub_ = n; + nsub_ = static_cast<uint16_t>(n); } // Add Rune to LiteralString diff --git a/re2/testing/required_prefix_test.cc b/re2/testing/required_prefix_test.cc index d535e87..04a1ee4 100644 --- a/re2/testing/required_prefix_test.cc +++ b/re2/testing/required_prefix_test.cc @@ -48,11 +48,13 @@ TEST(RequiredPrefix, SimpleTests) { flags = flags | Regexp::Latin1; Regexp* re = Regexp::Parse(t.regexp, flags, NULL); CHECK(re) << " " << t.regexp; + string p; - bool f = false; - Regexp* s = NULL; + bool f; + Regexp* s; CHECK_EQ(t.return_value, re->RequiredPrefix(&p, &f, &s)) - << " " << t.regexp << " " << (j==0 ? "latin1" : "utf") << " " << re->Dump(); + << " " << t.regexp << " " << (j==0 ? "latin1" : "utf") + << " " << re->Dump(); if (t.return_value) { CHECK_EQ(p, string(t.prefix)) << " " << t.regexp << " " << (j==0 ? "latin1" : "utf"); |