diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2018-02-20 15:37:55 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2018-02-20 15:37:55 +0900 |
commit | a019c763979d470e277ab79d1d0797941e5fb0f4 (patch) | |
tree | e48aba698963684ab0c1b95a2ad6b7c77bed1453 | |
parent | a3a5ffe62bc766304e422d5ce04d22638cf6eacd (diff) | |
download | re2-a019c763979d470e277ab79d1d0797941e5fb0f4.tar.gz re2-a019c763979d470e277ab79d1d0797941e5fb0f4.tar.bz2 re2-a019c763979d470e277ab79d1d0797941e5fb0f4.zip |
Imported Upstream version 20180201upstream/20180201
Change-Id: I7f77468eb010f6abf5b789382b16619abd261a51
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
-rw-r--r-- | BUILD | 34 | ||||
-rw-r--r-- | re2/re2.h | 2 | ||||
-rw-r--r-- | re2/testing/re2_test.cc | 8 |
3 files changed, 37 insertions, 7 deletions
@@ -8,6 +8,16 @@ licenses(["notice"]) exports_files(["LICENSE"]) +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + +config_setting( + name = "windows_msvc", + values = {"cpu": "x64_windows_msvc"}, +) + cc_library( name = "re2", srcs = [ @@ -57,8 +67,16 @@ cc_library( "re2/set.h", "re2/stringpiece.h", ], - copts = ["-pthread"], - linkopts = ["-pthread"], + copts = select({ + ":windows": [], + ":windows_msvc": [], + "//conditions:default": ["-pthread"], + }), + linkopts = select({ + ":windows": [], + ":windows_msvc": [], + "//conditions:default": ["-pthread"], + }), visibility = ["//visibility:public"], ) @@ -207,9 +225,13 @@ cc_binary( name = "regexp_benchmark", testonly = 1, srcs = ["re2/testing/regexp_benchmark.cc"], - linkopts = [ - "-lm", - "-lrt", - ], + linkopts = select({ + ":windows": [], + ":windows_msvc": [], + "//conditions:default": [ + "-lm", + "-lrt", + ], + }), deps = [":benchmark"], ) @@ -774,6 +774,7 @@ class RE2::Arg { // Constructor specially designed for NULL arguments Arg(void*); + Arg(std::nullptr_t); typedef bool (*Parser)(const char* str, size_t n, void* dest); @@ -849,6 +850,7 @@ class RE2::Arg { inline RE2::Arg::Arg() : arg_(NULL), parser_(parse_null) { } inline RE2::Arg::Arg(void* p) : arg_(p), parser_(parse_null) { } +inline RE2::Arg::Arg(std::nullptr_t p) : arg_(p), parser_(parse_null) { } inline bool RE2::Arg::Parse(const char* str, size_t n) const { return (*parser_)(str, n, arg_); diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index d71dce7..7fdc836 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -707,10 +707,16 @@ TEST(RE2, FullMatchN) { TEST(RE2, FullMatchIgnoredArg) { int i; string s; - // Ignored arg + + // Old-school NULL should be ignored. CHECK(RE2::FullMatch("ruby:1234", "(\\w+)(:)(\\d+)", &s, (void*)NULL, &i)); CHECK_EQ(s, string("ruby")); CHECK_EQ(i, 1234); + + // C++11 nullptr should also be ignored. + CHECK(RE2::FullMatch("rubz:1235", "(\\w+)(:)(\\d+)", &s, nullptr, &i)); + CHECK_EQ(s, string("rubz")); + CHECK_EQ(i, 1235); } TEST(RE2, FullMatchTypedNullArg) { |