From 731086cd3fd1b3ec74fc657262d313bed6123159 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 13 Feb 2024 13:02:36 +0000 Subject: [PATCH 01/56] Try using `p0deje/setup-bazel` everywhere. Change-Id: If5d32fdb715be0b3b4ecdcf4d762ca92eb2c99d6 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62670 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 4 +++- .github/workflows/pages.yml | 4 +++- .github/workflows/python.yml | 17 +++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index 174ed68a9..6c4423377 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -15,6 +15,8 @@ jobs: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 - - uses: bazelbuild/setup-bazelisk@v3 + - uses: p0deje/setup-bazel@0.5.0 + with: + bazelisk-version: '1.x' - run: .github/bazel.sh shell: bash diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 0810aa8bd..52ba22940 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -18,7 +18,9 @@ jobs: USER: runner steps: - uses: actions/checkout@v4 - - uses: bazelbuild/setup-bazelisk@v3 + - uses: p0deje/setup-bazel@0.5.0 + with: + bazelisk-version: '1.x' - run: app/build.sh shell: bash - uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c69081bda..afa318559 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -35,7 +35,9 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazelbuild/setup-bazelisk@v3 + - uses: p0deje/setup-bazel@0.5.0 + with: + bazelisk-version: '1.x' - name: Prepare Python ${{ matrix.ver }} environment run: | "${PYTHON}" -m pip install --upgrade pip @@ -86,7 +88,9 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazelbuild/setup-bazelisk@v3 + - uses: p0deje/setup-bazel@0.5.0 + with: + bazelisk-version: '1.x' - uses: actions/setup-python@v5 with: python-version: ${{ matrix.ver }} @@ -135,12 +139,9 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - # Avoid the Chocolatey install of Bazel getting in the way; - # `bazelbuild/setup-bazelisk` doesn't work for some reason. - - run: | - choco uninstall -y bazel - choco install -y bazelisk - shell: bash + - uses: p0deje/setup-bazel@0.5.0 + with: + bazelisk-version: '1.x' # Lowercase the architecture name for `actions/setup-python`. - run: | ARCHITECTURE=${{ matrix.arch.name }} From b4c6fe091b74b65f706ff9c9ff369b396c2a3177 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 13 Feb 2024 17:17:22 +0000 Subject: [PATCH 02/56] Bump version of `p0deje/setup-bazel` to address warnings. Change-Id: I06faef205ed686ed82974454fe8dffcf6b10ef91 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62671 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 2 +- .github/workflows/pages.yml | 2 +- .github/workflows/python.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index 6c4423377..a12a7c580 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -15,7 +15,7 @@ jobs: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 - - uses: p0deje/setup-bazel@0.5.0 + - uses: p0deje/setup-bazel@0.6.0 with: bazelisk-version: '1.x' - run: .github/bazel.sh diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 52ba22940..0f0a57a15 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -18,7 +18,7 @@ jobs: USER: runner steps: - uses: actions/checkout@v4 - - uses: p0deje/setup-bazel@0.5.0 + - uses: p0deje/setup-bazel@0.6.0 with: bazelisk-version: '1.x' - run: app/build.sh diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index afa318559..892922e48 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -35,7 +35,7 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: p0deje/setup-bazel@0.5.0 + - uses: p0deje/setup-bazel@0.6.0 with: bazelisk-version: '1.x' - name: Prepare Python ${{ matrix.ver }} environment @@ -88,7 +88,7 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: p0deje/setup-bazel@0.5.0 + - uses: p0deje/setup-bazel@0.6.0 with: bazelisk-version: '1.x' - uses: actions/setup-python@v5 @@ -139,7 +139,7 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: p0deje/setup-bazel@0.5.0 + - uses: p0deje/setup-bazel@0.6.0 with: bazelisk-version: '1.x' # Lowercase the architecture name for `actions/setup-python`. From ed9fc269e2fdb299afe59e912928d31ad3fdcf7d Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 15 Feb 2024 14:09:57 +0000 Subject: [PATCH 03/56] Update @apple_support to version 1.12.0. Fixes #474. Change-Id: I9b93d7d8942d9da502ed79782c6a14ccaded5970 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62690 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index f99fcd259..8ce4339b7 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -11,7 +11,7 @@ module( ) bazel_dep(name = "platforms", version = "0.0.8") -bazel_dep(name = "apple_support", version = "1.11.1", repo_name = "build_bazel_apple_support") +bazel_dep(name = "apple_support", version = "1.12.0", repo_name = "build_bazel_apple_support") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "com_google_absl") bazel_dep(name = "rules_python", version = "0.29.0") From 2aa303b697ee0511cc3095b93877631fe26ca43c Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 16 Feb 2024 16:30:47 +0000 Subject: [PATCH 04/56] Update @pybind11_bazel to version 2.11.1.bzl.2. It now uses rules_python, which makes it drastically simpler and also means that hermetic Python toolchains are used by default. However, we want local Python toolchains to be used when building wheels, so we have to do a little dance there. Change-Id: I0dcd55522aca40aae0de0535439b714eeb85911a Reviewed-on: https://code-review.googlesource.com/c/re2/+/62710 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- MODULE.bazel | 8 ++--- python/setup.py | 91 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 11 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 8ce4339b7..f3e840e0d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -14,18 +14,14 @@ bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "apple_support", version = "1.12.0", repo_name = "build_bazel_apple_support") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "com_google_absl") -bazel_dep(name = "rules_python", version = "0.29.0") -bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.1") +bazel_dep(name = "rules_python", version = "0.31.0") +bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.2") # This is a temporary hack for `x64_x86_windows`. # TODO(junyer): Remove whenever no longer needed. cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension") use_repo(cc_configure, "local_config_cc") -python_configure = use_extension("@pybind11_bazel//:python_configure.bzl", "extension") -python_configure.toolchain(python_version = "3") # ignored when non-root module -use_repo(python_configure, "local_config_python", "pybind11") - # These dependencies will be ignored when the `re2` module is not # the root module (or when `--ignore_dev_dependency` is enabled). bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True) diff --git a/python/setup.py b/python/setup.py index df65415ee..62d3e0cd0 100644 --- a/python/setup.py +++ b/python/setup.py @@ -7,6 +7,7 @@ import setuptools.command.build_ext import shutil import sys +import sysconfig long_description = r"""A drop-in replacement for the re module. @@ -48,9 +49,6 @@ def build_extension(self, ext): if 'GITHUB_ACTIONS' not in os.environ: return super().build_extension(ext) - # For @pybind11_bazel's `python_configure()`. - os.environ['PYTHON_BIN_PATH'] = sys.executable - cmd = ['bazel', 'build'] try: cpu = os.environ['BAZEL_CPU'] @@ -63,8 +61,9 @@ def build_extension(self, ext): cmd.append(f'--extra_toolchains=@local_config_cc//:cc-toolchain-{cpu}') except KeyError: pass - # Register the local Python toolchain with highest priority. - cmd.append('--extra_toolchains=@local_config_python//:py_toolchain') + # Register the local Python toolchains with highest priority. + self.generate_python_toolchains() + cmd.append('--extra_toolchains=//python/toolchains:all') # Print debug information during toolchain resolution. cmd.append('--toolchain_resolution_debug=.*') cmd += ['--compilation_mode=opt', '--', ':all'] @@ -78,6 +77,88 @@ def build_extension(self, ext): cmd = ['bazel', 'clean', '--expunge'] self.spawn(cmd) + def generate_python_toolchains(self): + include = sysconfig.get_path('include') + libs = os.path.join(include, '../libs') + + os.makedirs('toolchains') + shutil.copytree(include, 'toolchains/include') + try: + shutil.copytree(libs, 'toolchains/libs') + except FileNotFoundError: + # We must not be running on Windows. :) + pass + + with open('toolchains/BUILD.bazel', 'x') as file: + file.write( + """\ +load("@rules_python//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain") +load("@rules_python//python:py_runtime.bzl", "py_runtime") +load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair") + +package(default_visibility = ["//visibility:public"]) + +toolchain( + name = "py", + toolchain = ":py_toolchain", + toolchain_type = "@rules_python//python:toolchain_type", +) + +py_runtime_pair( + name = "py_toolchain", + py3_runtime = ":interpreter", +) + +py_runtime( + name = "interpreter", + interpreter_path = "{interpreter_path}", + interpreter_version_info = {{ + "major": "{major}", + "minor": "{minor}", + }}, + python_version = "PY3", +) + +toolchain( + name = "py_cc", + toolchain = ":py_cc_toolchain", + toolchain_type = "@rules_python//python/cc:toolchain_type", +) + +py_cc_toolchain( + name = "py_cc_toolchain", + headers = ":headers", + libs = ":libraries", + python_version = "{major}.{minor}", +) + +cc_library( + name = "headers", + hdrs = glob(["include/**/*.h"]), + includes = ["include"], + deps = select({{ + "@platforms//os:windows": [":interface_library"], + "//conditions:default": [], + }}), +) + +cc_import( + name = "interface_library", + interface_library = select({{ + "@platforms//os:windows": "libs/python{major}{minor}.lib", + "//conditions:default": None, + }}), + system_provided = True, +) + +# Not actually necessary for our purposes. :) +cc_library( + name = "libraries", +) +""".format(interpreter_path=sys.executable, + major=sys.version_info.major, + minor=sys.version_info.minor)) + def options(): bdist_wheel = {} From d00d1e93781e6ebe415771a952689dff8f260d44 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 16 Feb 2024 17:55:42 +0000 Subject: [PATCH 05/56] Avoid `invalid escape sequence` errors on Windows. Change-Id: I3ed566fb37f235190b5fe91dfd07f575173a6aca Reviewed-on: https://code-review.googlesource.com/c/re2/+/62711 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index 62d3e0cd0..93de80376 100644 --- a/python/setup.py +++ b/python/setup.py @@ -155,7 +155,7 @@ def generate_python_toolchains(self): cc_library( name = "libraries", ) -""".format(interpreter_path=sys.executable, +""".format(interpreter_path=sys.executable.replace('\\', '/'), major=sys.version_info.major, minor=sys.version_info.minor)) From 477b9f96d577785309c84507342be72a61c9e909 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sun, 18 Feb 2024 10:04:56 +0000 Subject: [PATCH 06/56] Clean up uses of `repo_name` in `MODULE.bazel`. Change-Id: Ie0d82540cdb7804830c7f6a9a9a3e7e33e3b38f5 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62712 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- BUILD.bazel | 78 +++++++++++++++++++++++----------------------- MODULE.bazel | 4 +-- python/BUILD.bazel | 2 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index ffe56c0c5..169c4d754 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -76,17 +76,17 @@ cc_library( }), visibility = ["//visibility:public"], deps = [ - "@com_google_absl//absl/base", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/container:fixed_array", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/container:inlined_vector", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/strings:str_format", - "@com_google_absl//absl/synchronization", - "@com_google_absl//absl/types:optional", - "@com_google_absl//absl/types:span", + "@abseil-cpp//absl/base", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/container:fixed_array", + "@abseil-cpp//absl/container:flat_hash_map", + "@abseil-cpp//absl/container:flat_hash_set", + "@abseil-cpp//absl/container:inlined_vector", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/strings:str_format", + "@abseil-cpp//absl/synchronization", + "@abseil-cpp//absl/types:optional", + "@abseil-cpp//absl/types:span", ], ) @@ -130,11 +130,11 @@ cc_library( visibility = [":__subpackages__"], deps = [ ":re2", - "@com_google_absl//absl/base", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/strings:str_format", + "@abseil-cpp//absl/base", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", ], ) @@ -145,8 +145,8 @@ cc_test( srcs = ["re2/testing/charclass_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/strings:str_format", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -158,7 +158,7 @@ cc_test( srcs = ["re2/testing/compile_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -171,7 +171,7 @@ cc_test( deps = [ ":re2", ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -183,7 +183,7 @@ cc_test( srcs = ["re2/testing/mimics_pcre_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -195,7 +195,7 @@ cc_test( srcs = ["re2/testing/parse_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -208,8 +208,8 @@ cc_test( deps = [ ":re2", ":testing", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/strings", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/strings", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -222,7 +222,7 @@ cc_test( deps = [ ":re2", ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -235,8 +235,8 @@ cc_test( deps = [ ":re2", ":testing", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/strings:str_format", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -259,7 +259,7 @@ cc_test( srcs = ["re2/testing/required_prefix_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -271,7 +271,7 @@ cc_test( srcs = ["re2/testing/search_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -295,7 +295,7 @@ cc_test( srcs = ["re2/testing/simplify_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/base:core_headers", + "@abseil-cpp//absl/base:core_headers", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -319,9 +319,9 @@ cc_test( deps = [ ":re2", ":testing", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/strings:str_format", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -377,8 +377,8 @@ cc_test( srcs = ["re2/testing/random_test.cc"], deps = [ ":testing", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/strings:str_format", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -391,10 +391,10 @@ cc_binary( deps = [ ":re2", ":testing", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/strings:str_format", - "@com_google_absl//absl/synchronization", + "@abseil-cpp//absl/container:flat_hash_map", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/strings:str_format", + "@abseil-cpp//absl/synchronization", "@google_benchmark//:benchmark_main", ], ) diff --git a/MODULE.bazel b/MODULE.bazel index f3e840e0d..77a8a2e29 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -11,9 +11,9 @@ module( ) bazel_dep(name = "platforms", version = "0.0.8") -bazel_dep(name = "apple_support", version = "1.12.0", repo_name = "build_bazel_apple_support") +bazel_dep(name = "apple_support", version = "1.12.0") bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "com_google_absl") +bazel_dep(name = "abseil-cpp", version = "20240116.0") bazel_dep(name = "rules_python", version = "0.31.0") bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.2") diff --git a/python/BUILD.bazel b/python/BUILD.bazel index 48d7d3f58..ed1726ba3 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel @@ -12,7 +12,7 @@ pybind_extension( srcs = ["_re2.cc"], deps = [ "//:re2", - "@com_google_absl//absl/strings", + "@abseil-cpp//absl/strings", ], ) From 6bb550b05724a4abb85f2527eac3fcaab0cd70a6 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sat, 17 Feb 2024 23:19:09 -0800 Subject: [PATCH 07/56] Disable warning for missing-field-initializers as well for clang. The same warning shows up with clang++. Tested with clang-16 and clang-17. Change-Id: I4181f7eb20a17b83aef1d4d0c4a34d42818f53a1 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62730 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- re2/re2.h | 2 +- util/pcre.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/re2/re2.h b/re2/re2.h index 68fbed1d8..7ea44e044 100644 --- a/re2/re2.h +++ b/re2/re2.h @@ -972,7 +972,7 @@ inline RE2::Arg RE2::Octal(T* ptr) { } // Silence warnings about missing initializers for members of LazyRE2. -#if !defined(__clang__) && defined(__GNUC__) +#if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif diff --git a/util/pcre.cc b/util/pcre.cc index f54cb28f8..27aee3dc4 100644 --- a/util/pcre.cc +++ b/util/pcre.cc @@ -21,7 +21,7 @@ #include "util/pcre.h" // Silence warnings about the wacky formatting in the operator() functions. -#if !defined(__clang__) && defined(__GNUC__) +#if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wmisleading-indentation" #endif From 0ff0fabc78d27337d11eb90744c13e5f9a2a41bb Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 19 Feb 2024 13:02:28 +0000 Subject: [PATCH 08/56] Fix an ancient bug in prefix factoring. Regexp::LeadingString didn't output Latin1 into flags. In the given pattern, 0xA5 should be factored out, but shouldn't lose its Latin1-ness in the process. Because that was happening, the prefix for accel was 0xC2 0xA5 instead of 0xA5. Note that the former doesn't occur in the given input and so replacements weren't occurring. Fixes #477. Change-Id: Icd36ba0905684d93d6db58e8047c9787918d0cf4 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62713 Reviewed-by: Paul Wankadia Reviewed-by: Jashank Jeremy --- re2/parse.cc | 3 ++- re2/testing/re2_test.cc | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/re2/parse.cc b/re2/parse.cc index 904599280..a02791747 100644 --- a/re2/parse.cc +++ b/re2/parse.cc @@ -776,7 +776,8 @@ Rune* Regexp::LeadingString(Regexp* re, int* nrune, while (re->op() == kRegexpConcat && re->nsub() > 0) re = re->sub()[0]; - *flags = static_cast(re->parse_flags_ & Regexp::FoldCase); + *flags = static_cast(re->parse_flags_ & + (Regexp::FoldCase | Regexp::Latin1)); if (re->op() == kRegexpLiteral) { *nrune = 1; diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index 151525f2d..ddf8dbf8f 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -1658,4 +1658,23 @@ TEST(RE2, Issue310) { ASSERT_EQ(m, "") << " got m='" << m << "', want ''"; } +TEST(RE2, Issue477) { + // Regexp::LeadingString didn't output Latin1 into flags. + // In the given pattern, 0xA5 should be factored out, but + // shouldn't lose its Latin1-ness in the process. Because + // that was happening, the prefix for accel was 0xC2 0xA5 + // instead of 0xA5. Note that the former doesn't occur in + // the given input and so replacements weren't occurring. + + const char bytes[] = { + (char)0xa5, (char)0xd1, (char)0xa5, (char)0xd1, + (char)0x61, (char)0x63, (char)0xa5, (char)0x64, + }; + std::string s(bytes, ABSL_ARRAYSIZE(bytes)); + RE2 re("\xa5\xd1|\xa5\x64", RE2::Latin1); + int n = RE2::GlobalReplace(&s, re, ""); + ASSERT_EQ(n, 3); + ASSERT_EQ(s, "\x61\x63"); +} + } // namespace re2 From f9550c3f7207f946a45bbccd1814b12b136aae72 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 19 Feb 2024 16:23:29 +0000 Subject: [PATCH 09/56] Fix more ancient bugs around Latin-1 handling. It turned out that case folding assumed UTF-8 mode, so we would fold, say, 0xD1 to 0xF1 even in Latin-1 mode. Fixes #477. Change-Id: I73aa5c8e33ee0c6041c54e3a7268635915960f64 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62714 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- re2/parse.cc | 60 ++++++++++++++++++++++++++++----------- re2/testing/dump.cc | 20 +++++++++---- re2/testing/parse_test.cc | 25 +++++++++++++++- 3 files changed, 82 insertions(+), 23 deletions(-) diff --git a/re2/parse.cc b/re2/parse.cc index a02791747..2558b2a2e 100644 --- a/re2/parse.cc +++ b/re2/parse.cc @@ -337,6 +337,20 @@ Rune CycleFoldRune(Rune r) { return ApplyFold(f, r); } +// Add lo-hi to the class, along with their fold-equivalent characters. +static void AddFoldedRangeLatin1(CharClassBuilder* cc, Rune lo, Rune hi) { + while (lo <= hi) { + cc->AddRange(lo, lo); + if ('A' <= lo && lo <= 'Z') { + cc->AddRange(lo - 'A' + 'a', lo - 'A' + 'a'); + } + if ('a' <= lo && lo <= 'z') { + cc->AddRange(lo - 'a' + 'A', lo - 'a' + 'A'); + } + lo++; + } +} + // Add lo-hi to the class, along with their fold-equivalent characters. // If lo-hi is already in the class, assume that the fold-equivalent // chars are there too, so there's no work to do. @@ -394,17 +408,26 @@ static void AddFoldedRange(CharClassBuilder* cc, Rune lo, Rune hi, int depth) { // Pushes the literal rune r onto the stack. bool Regexp::ParseState::PushLiteral(Rune r) { // Do case folding if needed. - if ((flags_ & FoldCase) && CycleFoldRune(r) != r) { - Regexp* re = new Regexp(kRegexpCharClass, flags_ & ~FoldCase); - re->ccb_ = new CharClassBuilder; - Rune r1 = r; - do { - if (!(flags_ & NeverNL) || r != '\n') { - re->ccb_->AddRange(r, r); - } - r = CycleFoldRune(r); - } while (r != r1); - return PushRegexp(re); + if (flags_ & FoldCase) { + if (flags_ & Latin1 && (('A' <= r && r <= 'Z') || + ('a' <= r && r <= 'z'))) { + Regexp* re = new Regexp(kRegexpCharClass, flags_ & ~FoldCase); + re->ccb_ = new CharClassBuilder; + AddFoldedRangeLatin1(re->ccb_, r, r); + return PushRegexp(re); + } + if (!(flags_ & Latin1) && CycleFoldRune(r) != r) { + Regexp* re = new Regexp(kRegexpCharClass, flags_ & ~FoldCase); + re->ccb_ = new CharClassBuilder; + Rune r1 = r; + do { + if (!(flags_ & NeverNL) || r != '\n') { + re->ccb_->AddRange(r, r); + } + r = CycleFoldRune(r); + } while (r != r1); + return PushRegexp(re); + } } // Exclude newline if applicable. @@ -1176,7 +1199,7 @@ void FactorAlternationImpl::Round3(Regexp** sub, int nsub, if (re->op() == kRegexpCharClass) { CharClass* cc = re->cc(); for (CharClass::iterator it = cc->begin(); it != cc->end(); ++it) - ccb.AddRange(it->lo, it->hi); + ccb.AddRangeFlags(it->lo, it->hi, re->parse_flags()); } else if (re->op() == kRegexpLiteral) { if (re->parse_flags() & Regexp::FoldCase) { // AddFoldedRange() can terminate prematurely if the character class @@ -1195,7 +1218,7 @@ void FactorAlternationImpl::Round3(Regexp** sub, int nsub, } re->Decref(); } - Regexp* re = Regexp::NewCharClass(ccb.GetCharClass(), flags); + Regexp* re = Regexp::NewCharClass(ccb.GetCharClass(), flags & ~Regexp::FoldCase); splices->emplace_back(re, sub + start, i - start); } @@ -1623,10 +1646,15 @@ void CharClassBuilder::AddRangeFlags( } // If folding case, add fold-equivalent characters too. - if (parse_flags & Regexp::FoldCase) - AddFoldedRange(this, lo, hi, 0); - else + if (parse_flags & Regexp::FoldCase) { + if (parse_flags & Regexp::Latin1) { + AddFoldedRangeLatin1(this, lo, hi); + } else { + AddFoldedRange(this, lo, hi, 0); + } + } else { AddRange(lo, hi); + } } // Look for a group with the given name. diff --git a/re2/testing/dump.cc b/re2/testing/dump.cc index 5cddd2334..9e3c94a69 100644 --- a/re2/testing/dump.cc +++ b/re2/testing/dump.cc @@ -96,17 +96,25 @@ static void DumpRegexpAppending(Regexp* re, std::string* s) { break; case kRegexpLiteral: { Rune r = re->rune(); - char buf[UTFmax+1]; - buf[runetochar(buf, &r)] = 0; - s->append(buf); + if (re->parse_flags() & Regexp::Latin1) { + s->push_back(r); + } else { + char buf[UTFmax+1]; + buf[runetochar(buf, &r)] = 0; + s->append(buf); + } break; } case kRegexpLiteralString: for (int i = 0; i < re->nrunes(); i++) { Rune r = re->runes()[i]; - char buf[UTFmax+1]; - buf[runetochar(buf, &r)] = 0; - s->append(buf); + if (re->parse_flags() & Regexp::Latin1) { + s->push_back(r); + } else { + char buf[UTFmax+1]; + buf[runetochar(buf, &r)] = 0; + s->append(buf); + } } break; case kRegexpConcat: diff --git a/re2/testing/parse_test.cc b/re2/testing/parse_test.cc index 7684b62a4..95294d5ff 100644 --- a/re2/testing/parse_test.cc +++ b/re2/testing/parse_test.cc @@ -225,6 +225,29 @@ static Test tests[] = { // Bug in Regexp::ToString() that emitted [^], which // would (obviously) fail to parse when fed back in. { "[\\s\\S]", "cc{0-0x10ffff}" }, + + // As per https://github.com/google/re2/issues/477, + // there were long-standing bugs involving Latin-1. + // Here, we exercise it WITHOUT case folding... + { "\xa5\x64\xd1", "str{\xa5""d\xd1}", Regexp::Latin1 }, + { "\xa5\xd1\x64", "str{\xa5\xd1""d}", Regexp::Latin1 }, + { "\xa5\x64[\xd1\xd2]", "cat{str{\xa5""d}cc{0xd1-0xd2}}", Regexp::Latin1 }, + { "\xa5[\xd1\xd2]\x64", "cat{lit{\xa5}cc{0xd1-0xd2}lit{d}}", Regexp::Latin1 }, + { "\xa5\x64|\xa5\xd1", "cat{lit{\xa5}cc{0x64 0xd1}}", Regexp::Latin1 }, + { "\xa5\xd1|\xa5\x64", "cat{lit{\xa5}cc{0x64 0xd1}}", Regexp::Latin1 }, + { "\xa5\x64|\xa5[\xd1\xd2]", "cat{lit{\xa5}cc{0x64 0xd1-0xd2}}", Regexp::Latin1 }, + { "\xa5[\xd1\xd2]|\xa5\x64", "cat{lit{\xa5}cc{0x64 0xd1-0xd2}}", Regexp::Latin1 }, + // Here, we exercise it WITH case folding... + // 0x64 should fold to 0x44, but neither 0xD1 nor 0xD2 + // should fold to 0xF1 and 0xF2, respectively. + { "\xa5\x64\xd1", "strfold{\xa5""d\xd1}", Regexp::Latin1 | Regexp::FoldCase }, + { "\xa5\xd1\x64", "strfold{\xa5\xd1""d}", Regexp::Latin1 | Regexp::FoldCase }, + { "\xa5\x64[\xd1\xd2]", "cat{strfold{\xa5""d}cc{0xd1-0xd2}}", Regexp::Latin1 | Regexp::FoldCase }, + { "\xa5[\xd1\xd2]\x64", "cat{lit{\xa5}cc{0xd1-0xd2}litfold{d}}", Regexp::Latin1 | Regexp::FoldCase }, + { "\xa5\x64|\xa5\xd1", "cat{lit{\xa5}cc{0x44 0x64 0xd1}}", Regexp::Latin1 | Regexp::FoldCase }, + { "\xa5\xd1|\xa5\x64", "cat{lit{\xa5}cc{0x44 0x64 0xd1}}", Regexp::Latin1 | Regexp::FoldCase }, + { "\xa5\x64|\xa5[\xd1\xd2]", "cat{lit{\xa5}cc{0x44 0x64 0xd1-0xd2}}", Regexp::Latin1 | Regexp::FoldCase }, + { "\xa5[\xd1\xd2]|\xa5\x64", "cat{lit{\xa5}cc{0x44 0x64 0xd1-0xd2}}", Regexp::Latin1 | Regexp::FoldCase }, }; bool RegexpEqualTestingOnly(Regexp* a, Regexp* b) { @@ -492,7 +515,7 @@ TEST(TestToString, EquivalentParse) { // << " t=" << t << " regexp=" << tests[i].regexp; // Test that if we parse the new regexp we get the same structure. - Regexp* nre = Regexp::Parse(t, Regexp::MatchNL | Regexp::PerlX, &status); + Regexp* nre = Regexp::Parse(t, f, &status); ASSERT_TRUE(nre != NULL) << " reparse " << t << " " << status.Text(); std::string ss = nre->Dump(); std::string tt = nre->ToString(); From 2d866a3d0753f4f4fce93cccc6c59c4b052d7db4 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 29 Feb 2024 08:43:35 +0000 Subject: [PATCH 10/56] Prepare to tag release `2024-03-01`. Change-Id: I6adb5dcd1c0b3d3551c04867d9e3390b22694b86 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62750 Reviewed-by: Perry Lorier Reviewed-by: Paul Wankadia --- MODULE.bazel | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 77a8a2e29..d98dbbd16 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,14 +6,14 @@ module( name = "re2", - version = "2024-02-01", + version = "2024-03-01", compatibility_level = 1, ) bazel_dep(name = "platforms", version = "0.0.8") -bazel_dep(name = "apple_support", version = "1.12.0") +bazel_dep(name = "apple_support", version = "1.14.0") bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "abseil-cpp", version = "20240116.0") +bazel_dep(name = "abseil-cpp", version = "20240116.1") bazel_dep(name = "rules_python", version = "0.31.0") bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.2") From 45c99850921711bd4483a8312d25145f4e4340bc Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sat, 2 Mar 2024 18:10:21 +0000 Subject: [PATCH 11/56] Update @pybind11_bazel to version 2.11.1.bzl.3. At long last, we can test the Python bindings in the CI because they should actually work on Windows as well... Change-Id: Iede307a2cc059fd3230d238e0861439971b4169f Reviewed-on: https://code-review.googlesource.com/c/re2/+/62751 Reviewed-by: Perry Lorier Reviewed-by: Paul Wankadia --- .github/bazel.sh | 35 ++++++++++++++++------------------- .github/cmake.sh | 13 ++++++------- MODULE.bazel | 2 +- python/BUILD.bazel | 2 +- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/bazel.sh b/.github/bazel.sh index 7295ec6a8..cc2b6e5fe 100755 --- a/.github/bazel.sh +++ b/.github/bazel.sh @@ -1,24 +1,21 @@ #!/bin/bash set -eux -bazel clean -bazel build --compilation_mode=dbg -- //:all -bazel test --compilation_mode=dbg -- //:all \ - -//:dfa_test \ - -//:exhaustive1_test \ - -//:exhaustive2_test \ - -//:exhaustive3_test \ - -//:exhaustive_test \ - -//:random_test - -bazel clean -bazel build --compilation_mode=opt -- //:all -bazel test --compilation_mode=opt -- //:all \ - -//:dfa_test \ - -//:exhaustive1_test \ - -//:exhaustive2_test \ - -//:exhaustive3_test \ - -//:exhaustive_test \ - -//:random_test +for compilation_mode in dbg opt +do + bazel clean + bazel build --compilation_mode=${compilation_mode} -- \ + //:re2 \ + //python:re2 + bazel test --compilation_mode=${compilation_mode} -- \ + //:all \ + -//:dfa_test \ + -//:exhaustive1_test \ + -//:exhaustive2_test \ + -//:exhaustive3_test \ + -//:exhaustive_test \ + -//:random_test \ + //python:all +done exit 0 diff --git a/.github/cmake.sh b/.github/cmake.sh index 782334e81..5e42d3703 100755 --- a/.github/cmake.sh +++ b/.github/cmake.sh @@ -1,12 +1,11 @@ #!/bin/bash set -eux -cmake . -D CMAKE_BUILD_TYPE=Debug -D RE2_BUILD_TESTING=ON "$@" -cmake --build . --config Debug --clean-first -ctest -C Debug --output-on-failure -E 'dfa|exhaustive|random' - -cmake . -D CMAKE_BUILD_TYPE=Release -D RE2_BUILD_TESTING=ON "$@" -cmake --build . --config Release --clean-first -ctest -C Release --output-on-failure -E 'dfa|exhaustive|random' +for CMAKE_BUILD_TYPE in Debug Release +do + cmake . -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -D RE2_BUILD_TESTING=ON "$@" + cmake --build . --config ${CMAKE_BUILD_TYPE} --clean-first + ctest -C ${CMAKE_BUILD_TYPE} --output-on-failure -E 'dfa|exhaustive|random' +done exit 0 diff --git a/MODULE.bazel b/MODULE.bazel index d98dbbd16..423572761 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -15,7 +15,7 @@ bazel_dep(name = "apple_support", version = "1.14.0") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.1") bazel_dep(name = "rules_python", version = "0.31.0") -bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.2") +bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.3") # This is a temporary hack for `x64_x86_windows`. # TODO(junyer): Remove whenever no longer needed. diff --git a/python/BUILD.bazel b/python/BUILD.bazel index ed1726ba3..74b7339a5 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel @@ -19,7 +19,7 @@ pybind_extension( py_library( name = "re2", srcs = ["re2.py"], - data = [":_re2.so"], + data = [":_re2"], imports = ["."], visibility = ["//visibility:public"], ) From 8695a6386748cca453f359d96c9bed5abae26708 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 4 Mar 2024 12:03:23 +0000 Subject: [PATCH 12/56] Disable MSYS/MSYS2 path conversion, which interferes with Bazel. Change-Id: I0a0966667baf39310eba885078b99200612e014e Reviewed-on: https://code-review.googlesource.com/c/re2/+/62790 Reviewed-by: Perry Lorier Reviewed-by: Paul Wankadia --- .github/bazel.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/bazel.sh b/.github/bazel.sh index cc2b6e5fe..1fe309fab 100755 --- a/.github/bazel.sh +++ b/.github/bazel.sh @@ -1,6 +1,10 @@ #!/bin/bash set -eux +# Disable MSYS/MSYS2 path conversion, which interferes with Bazel. +export MSYS_NO_PATHCONV='1' +export MSYS2_ARG_CONV_EXCL='*' + for compilation_mode in dbg opt do bazel clean From dbf15a205c5b28fe7e8c43df2e036bbf47c9cb57 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sat, 2 Mar 2024 13:50:38 -0800 Subject: [PATCH 13/56] Use try-import to load an optional user-specific user.bazelrc This is very useful for setting local configurations such as extra warnings, --config, etc. Name `user.bazelrc` like bazel best practices describe it: https://bazel.build/configure/best-practices#bazelrc-file Change-Id: If531d682668b4cb2421cfba79848102964634189 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62770 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- .bazelrc | 3 +++ .gitignore | 1 + 2 files changed, 4 insertions(+) diff --git a/.bazelrc b/.bazelrc index c8ff98fa2..12631a07a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -19,3 +19,6 @@ build:windows --cxxopt=/std:c++14 # Print test logs for failed tests. test --test_output=errors + +# https://bazel.build/configure/best-practices#bazelrc-file +try-import %workspace%/user.bazelrc diff --git a/.gitignore b/.gitignore index a671fe2cf..56f0a3153 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ core obj/ benchlog.* +user.bazelrc From 27536b0d187fbce6cd6df693f64688c126dbb036 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 7 Mar 2024 15:01:13 +0000 Subject: [PATCH 14/56] Delete an old comment. Change-Id: Iafd06023ceaf5023a99a0d54be846d6ae8ab1035 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62810 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .bazelrc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index 12631a07a..0311dd3e0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -8,10 +8,6 @@ build --features=layering_check build --features=parse_headers # Abseil requires C++14 at minimum. -# Previously, the flag was set via `BAZEL_CXXOPTS`. On macOS, we also had to set -# `BAZEL_USE_CPP_ONLY_TOOLCHAIN` since Bazel wouldn't respect the former without -# the latter. However, the latter stopped Bazel from using Xcode and `-framework -# Foundation`, which CCTZ (vendored into Abseil) requires. build --enable_platform_specific_config build:linux --cxxopt=-std=c++14 build:macos --cxxopt=-std=c++14 From ddb3414a8f65ff03e63bbd1932fb2164cec69bf1 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 11 Mar 2024 10:59:15 +0000 Subject: [PATCH 15/56] Add Clang 18 to the build matrix. ... and remove Clang 15 so that we continue to test with only the three most recent releases. Change-Id: Ib1eaa20b2c988bb53027dd3e01551d5d95058e24 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62830 Reviewed-by: Perry Lorier Reviewed-by: Paul Wankadia --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 445da78d6..a7107db8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: strategy: fail-fast: false matrix: - ver: [15, 16, 17] + ver: [16, 17, 18] env: CC: clang-${{ matrix.ver }} CXX: clang++-${{ matrix.ver }} From 108914d28a79243d4300e7e651cd0a0d5883ca0f Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 11 Mar 2024 11:04:25 +0000 Subject: [PATCH 16/56] `p0deje/setup-bazel` has been transferred to `bazel-contrib`. While I'm here, update to the latest release. Change-Id: I785222dc8afb9b5fec838261c632f81bb24ab48c Reviewed-on: https://code-review.googlesource.com/c/re2/+/62831 Reviewed-by: Perry Lorier Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 2 +- .github/workflows/pages.yml | 2 +- .github/workflows/python.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index a12a7c580..eb4657049 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -15,7 +15,7 @@ jobs: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 - - uses: p0deje/setup-bazel@0.6.0 + - uses: bazel-contrib/setup-bazel@0.8.0 with: bazelisk-version: '1.x' - run: .github/bazel.sh diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 0f0a57a15..7736a263a 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -18,7 +18,7 @@ jobs: USER: runner steps: - uses: actions/checkout@v4 - - uses: p0deje/setup-bazel@0.6.0 + - uses: bazel-contrib/setup-bazel@0.8.0 with: bazelisk-version: '1.x' - run: app/build.sh diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 892922e48..ba7841ec8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -35,7 +35,7 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: p0deje/setup-bazel@0.6.0 + - uses: bazel-contrib/setup-bazel@0.8.0 with: bazelisk-version: '1.x' - name: Prepare Python ${{ matrix.ver }} environment @@ -88,7 +88,7 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: p0deje/setup-bazel@0.6.0 + - uses: bazel-contrib/setup-bazel@0.8.0 with: bazelisk-version: '1.x' - uses: actions/setup-python@v5 @@ -139,7 +139,7 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: p0deje/setup-bazel@0.6.0 + - uses: bazel-contrib/setup-bazel@0.8.0 with: bazelisk-version: '1.x' # Lowercase the architecture name for `actions/setup-python`. From 58f6cdd82bc158245d0a91f86656fde4f8a0e5e6 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 15 Mar 2024 19:04:01 +0200 Subject: [PATCH 17/56] doc/mksyntaxgo: use standard generated Go header Change generated commment to follow https://go.dev/s/generatedcode Change-Id: I61e0da6583a5f8df2da63d669388cce83ad91d0d Reviewed-on: https://code-review.googlesource.com/c/re2/+/62850 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- doc/mksyntaxgo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mksyntaxgo b/doc/mksyntaxgo index 1a09b87cc..10a253efa 100755 --- a/doc/mksyntaxgo +++ b/doc/mksyntaxgo @@ -19,7 +19,7 @@ sam -d $out <<'!' // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// DO NOT EDIT. This file is generated by mksyntaxgo from the RE2 distribution. +// Code generated by mksyntaxgo from the RE2 distribution. DO NOT EDIT. /* Package syntax parses regular expressions into parse trees and compiles From 5c5c8ed6a6e8195e6f7916ca739ddb9b3754db23 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sun, 17 Mar 2024 09:01:49 +0000 Subject: [PATCH 18/56] Fix the link to the Python wrapper. Change-Id: I9fdb4ce637857acb6d7c9979a910bf35db99fa75 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62870 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 469d6f397..21a4358c8 100644 --- a/README +++ b/README @@ -32,7 +32,7 @@ under the BSD-style license found in the LICENSE file. RE2's native language is C++. -The Python wrapper is at https://github.com/google/re2/tree/abseil/python +The Python wrapper is at https://github.com/google/re2/tree/main/python and on PyPI (https://pypi.org/project/google-re2/). A C wrapper is at https://github.com/marcomaggi/cre2/. From db46d1e11eee1ad501e8e08411747468d1d6a87e Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sun, 17 Mar 2024 09:10:10 +0000 Subject: [PATCH 19/56] Bump versions of actions to latest releases. Note that this isn't the same as pinning to commits as in specifying their hashes. Note also that this isn't as ugly either. It's a minor improvement over "floating" (i.e. major version only) tags/branches. Change-Id: Id88fe81281885aff41f2625b3b71f945266c8677 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62871 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 4 ++-- .github/workflows/ci-cmake.yml | 6 +++--- .github/workflows/ci.yml | 6 +++--- .github/workflows/pages.yml | 10 +++++----- .github/workflows/pr.yml | 4 ++-- .github/workflows/python.yml | 30 +++++++++++++++--------------- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index eb4657049..4eea110fb 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -14,8 +14,8 @@ jobs: env: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 - - uses: bazel-contrib/setup-bazel@0.8.0 + - uses: actions/checkout@v4.1.1 + - uses: bazel-contrib/setup-bazel@0.8.1 with: bazelisk-version: '1.x' - run: .github/bazel.sh diff --git a/.github/workflows/ci-cmake.yml b/.github/workflows/ci-cmake.yml index a49fd53b1..6e131fe1a 100644 --- a/.github/workflows/ci-cmake.yml +++ b/.github/workflows/ci-cmake.yml @@ -15,7 +15,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 - name: Install CMake run: | apt update -y @@ -35,7 +35,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -50,7 +50,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7107db8b..27ce6ece7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: # (The other two flags are the default provided for CXXFLAGS in Makefile.) CXXFLAGS: -O3 -g -std=c++${{ matrix.ver }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -39,7 +39,7 @@ jobs: CC: clang-${{ matrix.ver }} CXX: clang++-${{ matrix.ver }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 - name: Install Clang ${{ matrix.ver }} run: | # Avoid `Conflicts: python3-lldb-x.y` between packages. @@ -65,7 +65,7 @@ jobs: CC: gcc-${{ matrix.ver }} CXX: g++-${{ matrix.ver }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 - name: Install Abseil, GoogleTest and Benchmark run: | sudo apt update -y diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 7736a263a..5bff8306c 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -17,13 +17,13 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4 - - uses: bazel-contrib/setup-bazel@0.8.0 + - uses: actions/checkout@v4.1.1 + - uses: bazel-contrib/setup-bazel@0.8.1 with: bazelisk-version: '1.x' - run: app/build.sh shell: bash - - uses: actions/upload-pages-artifact@v3 + - uses: actions/upload-pages-artifact@v3.0.1 with: path: app/deploy deploy: @@ -37,5 +37,5 @@ jobs: environment: github-pages runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/deploy-pages@v4 + - uses: actions/checkout@v4.1.1 + - uses: actions/deploy-pages@v4.0.4 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 267dd5d7d..805f0fa4a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,8 +15,8 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/github-script@v7 + - uses: actions/checkout@v4.1.1 + - uses: actions/github-script@v7.0.1 with: script: | const fs = require('fs'); diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index ba7841ec8..7d9048c09 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,11 +31,11 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.0 + - uses: bazel-contrib/setup-bazel@0.8.1 with: bazelisk-version: '1.x' - name: Prepare Python ${{ matrix.ver }} environment @@ -58,7 +58,7 @@ jobs: "${PYTHON}" re2_test.py shell: bash working-directory: python - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v4.3.1 with: name: ${{ hashFiles('python/google_re2-*.whl') }} path: python/google_re2-*.whl @@ -84,14 +84,14 @@ jobs: # Otherwise, Python refuses to install the built wheel! SYSTEM_VERSION_COMPAT: 0 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.0 + - uses: bazel-contrib/setup-bazel@0.8.1 with: bazelisk-version: '1.x' - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5.0.0 with: python-version: ${{ matrix.ver }} - name: Prepare Python ${{ matrix.ver }} environment @@ -115,7 +115,7 @@ jobs: python re2_test.py shell: bash working-directory: python - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v4.3.1 with: name: ${{ hashFiles('python/google_re2-*.whl') }} path: python/google_re2-*.whl @@ -135,11 +135,11 @@ jobs: BAZEL_CPU: ${{ matrix.arch.bazel-name }}_windows PLAT_NAME: ${{ matrix.arch.python-name }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.0 + - uses: bazel-contrib/setup-bazel@0.8.1 with: bazelisk-version: '1.x' # Lowercase the architecture name for `actions/setup-python`. @@ -147,7 +147,7 @@ jobs: ARCHITECTURE=${{ matrix.arch.name }} echo "architecture=${ARCHITECTURE,,}" >> "${GITHUB_ENV}" shell: bash - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5.0.0 with: python-version: ${{ matrix.ver }} architecture: ${{ env.architecture }} @@ -171,7 +171,7 @@ jobs: python re2_test.py shell: bash working-directory: python - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v4.3.1 with: name: ${{ hashFiles('python/google_re2-*.whl') }} path: python/google_re2-*.whl @@ -183,11 +183,11 @@ jobs: - wheel-windows runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.1 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5.0.0 with: python-version: '3.x' - name: Prepare Python 3.x environment @@ -203,7 +203,7 @@ jobs: python -m build --sdist shell: bash working-directory: python - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v4.1.4 with: path: python - name: Set build number to ${{ inputs.build }} @@ -219,7 +219,7 @@ jobs: shell: bash working-directory: python - if: inputs.build >= 1 - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@v1.8.14 with: password: ${{ secrets.PYPI_API_TOKEN }} packages-dir: python/dist From 1250a99301b9f2d2d2e2b55413b8adb130eea516 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sun, 17 Mar 2024 13:23:12 +0000 Subject: [PATCH 20/56] Raise `re2.error` instead of crashing. Fixes #484. Change-Id: I152b5ed8a6358d2d74f553bde2e66f2e50cfba1d Reviewed-on: https://code-review.googlesource.com/c/re2/+/62890 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- python/_re2.cc | 7 +++++++ python/re2.py | 5 +++-- python/re2_test.py | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/python/_re2.cc b/python/_re2.cc index 8564f8a4f..07e33cec2 100644 --- a/python/_re2.cc +++ b/python/_re2.cc @@ -219,6 +219,10 @@ class Filter { } std::vector Match(py::buffer buffer, bool potential) const { + if (set_ == nullptr) { + py::pybind11_fail("Match() called before compiling"); + } + auto bytes = buffer.request(); auto text = FromBytes(bytes); std::vector atoms; @@ -243,6 +247,9 @@ class Filter { }; PYBIND11_MODULE(_re2, module) { + // Translate exceptions thrown by py::pybind11_fail() into Python. + py::register_local_exception(module, "Error"); + module.def("CharLenToBytes", &CharLenToBytes); module.def("BytesToCharLen", &BytesToCharLen); diff --git a/python/re2.py b/python/re2.py index 8a6d98539..d5023e767 100644 --- a/python/re2.py +++ b/python/re2.py @@ -33,8 +33,9 @@ import _re2 -class error(Exception): - pass +# pybind11 translates C++ exceptions to Python exceptions. +# We use that same Python exception class for consistency. +error = _re2.Error class Options(_re2.RE2.Options): diff --git a/python/re2_test.py b/python/re2_test.py index 86aa9ae51..df1a9eb70 100644 --- a/python/re2_test.py +++ b/python/re2_test.py @@ -477,6 +477,13 @@ def test_match(self): # Verify whether the underlying RE2 object is usable. self.assertEqual(0, f.re(2).groups) + def test_issue_484(self): + # Previously, the shim would dereference a null pointer and crash. + f = re2.Filter() + with self.assertRaisesRegex(re2.error, + r'Match\(\) called before compiling'): + f.Match('') + if __name__ == '__main__': absltest.main() From 6598a8ecd57724c8c7d43b2fca8eb9f9969ce57c Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 18 Mar 2024 07:46:48 +0000 Subject: [PATCH 21/56] Make compiling a no-op if it's attempted before adding any patterns. Fixes #485. Change-Id: Id7900ab2d034432016d425aeceb60a814225f10e Reviewed-on: https://code-review.googlesource.com/c/re2/+/62872 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- re2/filtered_re2.cc | 3 ++- re2/prefilter_tree.cc | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/re2/filtered_re2.cc b/re2/filtered_re2.cc index 49cf68601..1ce26a38e 100644 --- a/re2/filtered_re2.cc +++ b/re2/filtered_re2.cc @@ -70,8 +70,9 @@ void FilteredRE2::Compile(std::vector* atoms) { return; } + // Similarly to PrefilterTree::Compile(), make compiling + // a no-op if it's attempted before adding any patterns. if (re2_vec_.empty()) { - LOG(ERROR) << "Compile called before Add."; return; } diff --git a/re2/prefilter_tree.cc b/re2/prefilter_tree.cc index 3afb241c9..299a680fb 100644 --- a/re2/prefilter_tree.cc +++ b/re2/prefilter_tree.cc @@ -57,8 +57,9 @@ void PrefilterTree::Compile(std::vector* atom_vec) { // Some legacy users of PrefilterTree call Compile() before // adding any regexps and expect Compile() to have no effect. - if (prefilter_vec_.empty()) + if (prefilter_vec_.empty()) { return; + } compiled_ = true; @@ -272,8 +273,9 @@ void PrefilterTree::RegexpsGivenStrings( // Some legacy users of PrefilterTree call Compile() before // adding any regexps and expect Compile() to have no effect. // This kludge is a counterpart to that kludge. - if (prefilter_vec_.empty()) + if (prefilter_vec_.empty()) { return; + } LOG(ERROR) << "RegexpsGivenStrings called before Compile."; for (size_t i = 0; i < prefilter_vec_.size(); i++) From c0f9f1746f3e0d017eb5c2826a10bab1c04f598a Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 28 Mar 2024 14:16:46 +0000 Subject: [PATCH 22/56] Prepare to tag release `2024-04-01`. Change-Id: Ib26837e1d2d63ce13b1ef171c5c1af8168b94448 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62910 Reviewed-by: Jeff Bailey Reviewed-by: Paul Wankadia --- .github/workflows/pages.yml | 2 +- .github/workflows/python.yml | 6 +++--- MODULE.bazel | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 5bff8306c..85e54d876 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -38,4 +38,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 - - uses: actions/deploy-pages@v4.0.4 + - uses: actions/deploy-pages@v4.0.5 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7d9048c09..e024eba43 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -91,7 +91,7 @@ jobs: - uses: bazel-contrib/setup-bazel@0.8.1 with: bazelisk-version: '1.x' - - uses: actions/setup-python@v5.0.0 + - uses: actions/setup-python@v5.1.0 with: python-version: ${{ matrix.ver }} - name: Prepare Python ${{ matrix.ver }} environment @@ -147,7 +147,7 @@ jobs: ARCHITECTURE=${{ matrix.arch.name }} echo "architecture=${ARCHITECTURE,,}" >> "${GITHUB_ENV}" shell: bash - - uses: actions/setup-python@v5.0.0 + - uses: actions/setup-python@v5.1.0 with: python-version: ${{ matrix.ver }} architecture: ${{ env.architecture }} @@ -187,7 +187,7 @@ jobs: # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: actions/setup-python@v5.0.0 + - uses: actions/setup-python@v5.1.0 with: python-version: '3.x' - name: Prepare Python 3.x environment diff --git a/MODULE.bazel b/MODULE.bazel index 423572761..07df7cb99 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,11 +6,11 @@ module( name = "re2", - version = "2024-03-01", + version = "2024-04-01", compatibility_level = 1, ) -bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "platforms", version = "0.0.9") bazel_dep(name = "apple_support", version = "1.14.0") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.1") From 553f6df3b42cd7959c2c0c61c228fa94a9c8f7af Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 28 Mar 2024 18:45:53 +0000 Subject: [PATCH 23/56] Force a specific target version of macOS. Otherwise, `delocate` renames the wheels! Change-Id: I03bf330332a1586deed0519b7983b1a29574ec64 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62911 Reviewed-by: Jeff Bailey Reviewed-by: Paul Wankadia --- .github/workflows/python.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e024eba43..7b09f2982 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -80,6 +80,9 @@ jobs: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BAZEL_CPU: darwin_${{ matrix.arch.bazel-name }} PLAT_NAME: macosx-${{ matrix.os }}.0-${{ matrix.arch.python-name }} + # Force a specific target version of macOS. + # Otherwise, `delocate` renames the wheels! + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os }}.0 # Stop macOS from reporting the system version as 10.x. # Otherwise, Python refuses to install the built wheel! SYSTEM_VERSION_COMPAT: 0 From 917047f3606d3ba9e2de0d383c3cd80c94ed732c Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 28 Mar 2024 19:56:42 +0000 Subject: [PATCH 24/56] Tell Bazel the specific target version of macOS too. Sigh. Change-Id: I4f50d5299a0462d279042a2175995fff00ff97e4 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62912 Reviewed-by: Paul Wankadia Reviewed-by: Jeff Bailey --- python/setup.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/setup.py b/python/setup.py index 93de80376..0f49f6cd5 100644 --- a/python/setup.py +++ b/python/setup.py @@ -61,6 +61,11 @@ def build_extension(self, ext): cmd.append(f'--extra_toolchains=@local_config_cc//:cc-toolchain-{cpu}') except KeyError: pass + try: + ver = os.environ['MACOSX_DEPLOYMENT_TARGET'] + cmd.append(f'--macos_minimum_os={ver}') + except KeyError: + pass # Register the local Python toolchains with highest priority. self.generate_python_toolchains() cmd.append('--extra_toolchains=//python/toolchains:all') From ac82d4f628a2045d89964ae11c48403d3b091af1 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 29 Mar 2024 08:55:52 +0000 Subject: [PATCH 25/56] Don't specify `-pthread` on Emscripten either. Change-Id: I6b23bb04f0caaa2a65a23c941b1aea1eeb4da25d Reviewed-on: https://code-review.googlesource.com/c/re2/+/62913 Reviewed-by: Ash Liu Reviewed-by: Paul Wankadia --- BUILD.bazel | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index 169c4d754..a1664761f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -58,6 +58,7 @@ cc_library( # WebAssembly support for threads is... fraught at every level. "@platforms//cpu:wasm32": [], "@platforms//cpu:wasm64": [], + "@platforms//os:emscripten": [], "@platforms//os:wasi": [], "@platforms//os:windows": [], "//conditions:default": ["-pthread"], @@ -70,6 +71,7 @@ cc_library( # WebAssembly support for threads is... fraught at every level. "@platforms//cpu:wasm32": [], "@platforms//cpu:wasm64": [], + "@platforms//os:emscripten": [], "@platforms//os:wasi": [], "@platforms//os:windows": [], "//conditions:default": ["-pthread"], From 9ebe4a22cad8a025b68a9594bdff3c047a111333 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 8 Apr 2024 12:21:18 +0000 Subject: [PATCH 26/56] Stop setting `re2_INCLUDE_DIR`. It was probably neither needed nor used and will start causing problems as of CMake 3.29, which removes `PACKAGE_PREFIX_DIR`. Fixes #488. Change-Id: I707dc903234309698a6745d2b61279fd3b7bd6dc Reviewed-on: https://code-review.googlesource.com/c/re2/+/62930 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- re2Config.cmake.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/re2Config.cmake.in b/re2Config.cmake.in index 6a177c615..be7b6bc64 100644 --- a/re2Config.cmake.in +++ b/re2Config.cmake.in @@ -6,8 +6,6 @@ include(CMakeFindDependencyMacro) -set_and_check(re2_INCLUDE_DIR ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@) - if(UNIX) set(THREADS_PREFER_PTHREAD_FLAG ON) find_dependency(Threads REQUIRED) From 4f6f815179266d3b6fd2b806f10471d5cc5f0efc Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 8 Apr 2024 22:03:29 +0000 Subject: [PATCH 27/56] Bump some versions in `MODULE.bazel`. Change-Id: I528b54aa604dcca48a915c8d87a23d7cbbe10659 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62950 Reviewed-by: Jashank Jeremy Reviewed-by: Paul Wankadia --- MODULE.bazel | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 07df7cb99..efc44b8e7 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -11,11 +11,11 @@ module( ) bazel_dep(name = "platforms", version = "0.0.9") -bazel_dep(name = "apple_support", version = "1.14.0") +bazel_dep(name = "apple_support", version = "1.15.1") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.1") bazel_dep(name = "rules_python", version = "0.31.0") -bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.3") +bazel_dep(name = "pybind11_bazel", version = "2.12.0") # This is a temporary hack for `x64_x86_windows`. # TODO(junyer): Remove whenever no longer needed. From b0e64237bac20b72a9e32c9afa4cf16e5073b551 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 8 Apr 2024 22:28:14 +0000 Subject: [PATCH 28/56] Add a GitHub Actions workflow for releases. Triggering off a pushed tag, it creates the corresponding release, then downloads the source code archives and uploads them as release assets using Sigstore for signature. Someday, it will be convenient to switch to using SLSA for signature and provenance, but that day is not today. Yours truly has been wanting to automate away this dance for years. In light of CVE-2024-3094, now seemed like a really good time to do that. Change-Id: I0972ae5dcae7193ef457e23553a7dbe22adbfb1c Reviewed-on: https://code-review.googlesource.com/c/re2/+/62970 Reviewed-by: Ash Liu Reviewed-by: Paul Wankadia --- .github/workflows/release.yml | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..18ee6da2f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Release +on: + push: + tags: ['**'] +permissions: + contents: read +jobs: + create: + permissions: + # Required to create the release + # and upload the release assets. + contents: write + # Required for Sigstore signing. + id-token: write + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4.1.1 + - run: | + gh release create "${GITHUB_REF_NAME}" \ + --generate-notes --latest --verify-tag \ + --repo "${GITHUB_REPOSITORY}" + gh release download "${GITHUB_REF_NAME}" \ + --archive tar.gz \ + --repo "${GITHUB_REPOSITORY}" + gh release download "${GITHUB_REF_NAME}" \ + --archive zip \ + --repo "${GITHUB_REPOSITORY}" + shell: bash + - uses: sigstore/gh-action-sigstore-python@v2.1.1 + with: + inputs: *.tar.gz *.zip + - run: | + gh release upload "${GITHUB_REF_NAME}" \ + *.tar.gz *.zip *.sigstore \ + --repo "${GITHUB_REPOSITORY}" + shell: bash From e76b306b847f9c8f42f5f1ba1000affa2691142b Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 8 Apr 2024 23:16:04 +0000 Subject: [PATCH 29/56] Fix the Sigstore inputs. Sigh. Change-Id: I5ee5e77240952d4927959e2cdbe1b2f82cfa4d92 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62971 Reviewed-by: Paul Wankadia Reviewed-by: Ash Liu --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18ee6da2f..dd150a3a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,8 @@ jobs: shell: bash - uses: sigstore/gh-action-sigstore-python@v2.1.1 with: - inputs: *.tar.gz *.zip + # N.B. This is a whitespace-separated string! + inputs: '*.tar.gz *.zip' - run: | gh release upload "${GITHUB_REF_NAME}" \ *.tar.gz *.zip *.sigstore \ From 3c7e162c8eefa8db556df680cf01b0c2cde71230 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 9 Apr 2024 10:22:42 +0000 Subject: [PATCH 30/56] Switch to PyPI publishing via a trusted publisher. Change-Id: Ie94c5e6931f8fa70f238c9a5360874ff8833876a Reviewed-on: https://code-review.googlesource.com/c/re2/+/62972 Reviewed-by: Perry Lorier Reviewed-by: Paul Wankadia --- .github/workflows/python.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7b09f2982..7f97adc23 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -184,6 +184,10 @@ jobs: - wheel-linux - wheel-macos - wheel-windows + permissions: + contents: read + # Required for PyPI publishing. + id-token: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 @@ -224,5 +228,4 @@ jobs: - if: inputs.build >= 1 uses: pypa/gh-action-pypi-publish@v1.8.14 with: - password: ${{ secrets.PYPI_API_TOKEN }} packages-dir: python/dist From b84e3ff189980a33d4a0c6fa1201aa0b3b8bab4a Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 9 Apr 2024 18:32:14 +0000 Subject: [PATCH 31/56] Bring back `.YYYYMMDD` suffixes for `google-re2` versioning. While I'm here, update @abseil-cpp to version 20240116.2. Fixes #486. Change-Id: I86ec3bd1860e2bd1424a67eb5590eaaa7cc4ea71 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62990 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- MODULE.bazel | 2 +- python/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index efc44b8e7..583cbdca2 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,7 +13,7 @@ module( bazel_dep(name = "platforms", version = "0.0.9") bazel_dep(name = "apple_support", version = "1.15.1") bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "abseil-cpp", version = "20240116.1") +bazel_dep(name = "abseil-cpp", version = "20240116.2") bazel_dep(name = "rules_python", version = "0.31.0") bazel_dep(name = "pybind11_bazel", version = "2.12.0") diff --git a/python/setup.py b/python/setup.py index 0f49f6cd5..8b40c238d 100644 --- a/python/setup.py +++ b/python/setup.py @@ -192,7 +192,7 @@ def include_dirs(): setuptools.setup( name='google-re2', - version='1.1', + version='1.1.20240401', description='RE2 Python bindings', long_description=long_description, long_description_content_type='text/plain', From fbb52d987e3156b96da0809f5b61e1946eb26cdb Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 29 Apr 2024 18:55:47 +0000 Subject: [PATCH 32/56] Prepare to tag release `2024-05-01`. Bump versions of actions and dependencies. Change-Id: Ifb798e7c320b092e2faed2cd4d03fc962b8c009e Reviewed-on: https://code-review.googlesource.com/c/re2/+/63010 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 4 ++-- .github/workflows/ci-cmake.yml | 6 +++--- .github/workflows/ci.yml | 6 +++--- .github/workflows/pages.yml | 6 +++--- .github/workflows/pr.yml | 2 +- .github/workflows/python.yml | 22 +++++++++++----------- .github/workflows/release.yml | 2 +- MODULE.bazel | 4 ++-- python/setup.py | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index 4eea110fb..e49cd2ac7 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -14,8 +14,8 @@ jobs: env: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4.1.1 - - uses: bazel-contrib/setup-bazel@0.8.1 + - uses: actions/checkout@v4.1.4 + - uses: bazel-contrib/setup-bazel@0.8.2 with: bazelisk-version: '1.x' - run: .github/bazel.sh diff --git a/.github/workflows/ci-cmake.yml b/.github/workflows/ci-cmake.yml index 6e131fe1a..07ecdfbe0 100644 --- a/.github/workflows/ci-cmake.yml +++ b/.github/workflows/ci-cmake.yml @@ -15,7 +15,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - name: Install CMake run: | apt update -y @@ -35,7 +35,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -50,7 +50,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27ce6ece7..b83b4e52d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: # (The other two flags are the default provided for CXXFLAGS in Makefile.) CXXFLAGS: -O3 -g -std=c++${{ matrix.ver }} steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -39,7 +39,7 @@ jobs: CC: clang-${{ matrix.ver }} CXX: clang++-${{ matrix.ver }} steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - name: Install Clang ${{ matrix.ver }} run: | # Avoid `Conflicts: python3-lldb-x.y` between packages. @@ -65,7 +65,7 @@ jobs: CC: gcc-${{ matrix.ver }} CXX: g++-${{ matrix.ver }} steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - name: Install Abseil, GoogleTest and Benchmark run: | sudo apt update -y diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 85e54d876..af2c45ddb 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -17,8 +17,8 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4.1.1 - - uses: bazel-contrib/setup-bazel@0.8.1 + - uses: actions/checkout@v4.1.4 + - uses: bazel-contrib/setup-bazel@0.8.2 with: bazelisk-version: '1.x' - run: app/build.sh @@ -37,5 +37,5 @@ jobs: environment: github-pages runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - uses: actions/deploy-pages@v4.0.5 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 805f0fa4a..b8f94cdcb 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,7 +15,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - uses: actions/github-script@v7.0.1 with: script: | diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7f97adc23..7607a2551 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,11 +31,11 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.1 + - uses: bazel-contrib/setup-bazel@0.8.2 with: bazelisk-version: '1.x' - name: Prepare Python ${{ matrix.ver }} environment @@ -58,7 +58,7 @@ jobs: "${PYTHON}" re2_test.py shell: bash working-directory: python - - uses: actions/upload-artifact@v4.3.1 + - uses: actions/upload-artifact@v4.3.3 with: name: ${{ hashFiles('python/google_re2-*.whl') }} path: python/google_re2-*.whl @@ -87,11 +87,11 @@ jobs: # Otherwise, Python refuses to install the built wheel! SYSTEM_VERSION_COMPAT: 0 steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.1 + - uses: bazel-contrib/setup-bazel@0.8.2 with: bazelisk-version: '1.x' - uses: actions/setup-python@v5.1.0 @@ -118,7 +118,7 @@ jobs: python re2_test.py shell: bash working-directory: python - - uses: actions/upload-artifact@v4.3.1 + - uses: actions/upload-artifact@v4.3.3 with: name: ${{ hashFiles('python/google_re2-*.whl') }} path: python/google_re2-*.whl @@ -138,11 +138,11 @@ jobs: BAZEL_CPU: ${{ matrix.arch.bazel-name }}_windows PLAT_NAME: ${{ matrix.arch.python-name }} steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.1 + - uses: bazel-contrib/setup-bazel@0.8.2 with: bazelisk-version: '1.x' # Lowercase the architecture name for `actions/setup-python`. @@ -174,7 +174,7 @@ jobs: python re2_test.py shell: bash working-directory: python - - uses: actions/upload-artifact@v4.3.1 + - uses: actions/upload-artifact@v4.3.3 with: name: ${{ hashFiles('python/google_re2-*.whl') }} path: python/google_re2-*.whl @@ -190,7 +190,7 @@ jobs: id-token: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash @@ -210,7 +210,7 @@ jobs: python -m build --sdist shell: bash working-directory: python - - uses: actions/download-artifact@v4.1.4 + - uses: actions/download-artifact@v4.1.7 with: path: python - name: Set build number to ${{ inputs.build }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dd150a3a5..59bd537be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.4 - run: | gh release create "${GITHUB_REF_NAME}" \ --generate-notes --latest --verify-tag \ diff --git a/MODULE.bazel b/MODULE.bazel index 583cbdca2..602097462 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,11 +6,11 @@ module( name = "re2", - version = "2024-04-01", + version = "2024-05-01", compatibility_level = 1, ) -bazel_dep(name = "platforms", version = "0.0.9") +bazel_dep(name = "platforms", version = "0.0.10") bazel_dep(name = "apple_support", version = "1.15.1") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.2") diff --git a/python/setup.py b/python/setup.py index 8b40c238d..27782bf57 100644 --- a/python/setup.py +++ b/python/setup.py @@ -192,7 +192,7 @@ def include_dirs(): setuptools.setup( name='google-re2', - version='1.1.20240401', + version='1.1.20240501', description='RE2 Python bindings', long_description=long_description, long_description_content_type='text/plain', From 2b354c6ad0d0479dcff68dab23fb0d1143a482c2 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 30 Apr 2024 01:36:19 +0000 Subject: [PATCH 33/56] Use `pkg-config` to find GoogleTest and Benchmark. The GNU make CI workflow is currently broken on macOS because the Homebrew prefix differs between X64 and ARM64. It turns out that the compiler can't find GoogleTest (and Benchmark) anymore via the default path(s). We should really have been specifying the path(s) explicitly long before now anyway. Change-Id: If526389aa89b20b64ccfcc486769050c351e759f Reviewed-on: https://code-review.googlesource.com/c/re2/+/63030 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- Makefile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 017ab5567..65b52f6ca 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,13 @@ LDABSL=$(shell $(PKG_CONFIG) $(ABSL_DEPS) --libs | sed -e 's/-Wl / /g') # CCICU=$(shell $(PKG_CONFIG) icu-uc --cflags) -DRE2_USE_ICU # LDICU=$(shell $(PKG_CONFIG) icu-uc --libs) +# Build against GoogleTest and Benchmark for... testing and benchmarking. +# Capture only the `-L` flags for now; we will pass the `-l` flags later. +CCGTEST=$(shell $(PKG_CONFIG) gtest --cflags) +LDGTEST=$(shell $(PKG_CONFIG) gtest --libs-only-L) +CCBENCHMARK=$(shell $(PKG_CONFIG) benchmark --cflags) +LDBENCHMARK=$(shell $(PKG_CONFIG) benchmark --libs-only-L) + # To build against PCRE for testing and benchmarking, # uncomment the next two lines: # CCPCRE=-I/usr/local/include -DUSEPCRE @@ -39,8 +46,8 @@ CXX?=g++ CXXFLAGS?=-O3 -g LDFLAGS?= # required -RE2_CXXFLAGS?=-pthread -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -I. $(CCABSL) $(CCICU) $(CCPCRE) -RE2_LDFLAGS?=-pthread $(LDABSL) $(LDICU) $(LDPCRE) +RE2_CXXFLAGS?=-pthread -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -I. $(CCABSL) $(CCICU) $(CCGTEST) $(CCBENCHMARK) $(CCPCRE) +RE2_LDFLAGS?=-pthread $(LDABSL) $(LDICU) $(LDGTEST) $(LDBENCHMARK) $(LDPCRE) AR?=ar ARFLAGS?=rsc NM?=nm @@ -233,22 +240,22 @@ obj/so/libre2.$(SOEXT): $(SOFILES) libre2.symbols libre2.symbols.darwin .PRECIOUS: obj/dbg/test/% obj/dbg/test/%: obj/dbg/libre2.a obj/dbg/re2/testing/%.o $(DTESTOFILES) @mkdir -p obj/dbg/test - $(CXX) -o $@ obj/dbg/re2/testing/$*.o $(DTESTOFILES) -lgtest -lgtest_main obj/dbg/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) + $(CXX) -o $@ obj/dbg/re2/testing/$*.o $(DTESTOFILES) obj/dbg/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) -lgtest -lgtest_main .PRECIOUS: obj/test/% obj/test/%: obj/libre2.a obj/re2/testing/%.o $(TESTOFILES) @mkdir -p obj/test - $(CXX) -o $@ obj/re2/testing/$*.o $(TESTOFILES) -lgtest -lgtest_main obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) + $(CXX) -o $@ obj/re2/testing/$*.o $(TESTOFILES) obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) -lgtest -lgtest_main # Test the shared lib, falling back to the static lib for private symbols .PRECIOUS: obj/so/test/% obj/so/test/%: obj/so/libre2.$(SOEXT) obj/libre2.a obj/re2/testing/%.o $(TESTOFILES) @mkdir -p obj/so/test - $(CXX) -o $@ obj/re2/testing/$*.o $(TESTOFILES) -lgtest -lgtest_main -Lobj/so -lre2 obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) + $(CXX) -o $@ obj/re2/testing/$*.o $(TESTOFILES) -Lobj/so -lre2 obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) -lgtest -lgtest_main obj/test/regexp_benchmark: obj/libre2.a obj/re2/testing/regexp_benchmark.o $(TESTOFILES) @mkdir -p obj/test - $(CXX) -o $@ obj/re2/testing/regexp_benchmark.o $(TESTOFILES) -lgtest -lbenchmark -lbenchmark_main obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) + $(CXX) -o $@ obj/re2/testing/regexp_benchmark.o $(TESTOFILES) obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS) -lgtest -lbenchmark -lbenchmark_main obj/test/re2_fuzzer: obj/libre2.a obj/re2/fuzzing/re2_fuzzer.o @mkdir -p obj/test From f31c2c6f380331ddc862e37c7dea0bcf440b29dc Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 13 May 2024 18:23:14 +0000 Subject: [PATCH 34/56] Restore `bool T::ParseFrom(const char*, size_t)` support for MSVC. IIRC, it was problematic for MSVC 2017 and/or MSVC 2019, but https://github.com/google/oss-policies-info/commit/dca3ce04cd812e03c71107a7fdea419acbd6432c raised the support baseline to MSVC 2022, so let's try it... Change-Id: Id00483381c1f6c499a2da0c2d40d235c95dedfaa Reviewed-on: https://code-review.googlesource.com/c/re2/+/63050 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- re2/re2.h | 6 ------ re2/testing/re2_arg_test.cc | 2 -- 2 files changed, 8 deletions(-) diff --git a/re2/re2.h b/re2/re2.h index 7ea44e044..13bf39fbe 100644 --- a/re2/re2.h +++ b/re2/re2.h @@ -890,14 +890,12 @@ class RE2::Arg { re2_internal::Parse4ary::value, int>::type; -#if !defined(_MSC_VER) template using CanParseFrom = typename std::enable_if< std::is_member_function_pointer< decltype(static_cast( &T::ParseFrom))>::value, int>::type; -#endif public: Arg() : Arg(nullptr) {} @@ -909,10 +907,8 @@ class RE2::Arg { template = 0> Arg(T* ptr) : arg_(ptr), parser_(DoParse4ary) {} -#if !defined(_MSC_VER) template = 0> Arg(T* ptr) : arg_(ptr), parser_(DoParseFrom) {} -#endif typedef bool (*Parser)(const char* str, size_t n, void* dest); @@ -938,13 +934,11 @@ class RE2::Arg { return re2_internal::Parse(str, n, reinterpret_cast(dest), 10); } -#if !defined(_MSC_VER) template static bool DoParseFrom(const char* str, size_t n, void* dest) { if (dest == NULL) return true; return reinterpret_cast(dest)->ParseFrom(str, n); } -#endif void* arg_; Parser parser_; diff --git a/re2/testing/re2_arg_test.cc b/re2/testing/re2_arg_test.cc index 4b00be358..78d4aee43 100644 --- a/re2/testing/re2_arg_test.cc +++ b/re2/testing/re2_arg_test.cc @@ -135,7 +135,6 @@ TEST(RE2ArgTest, Uint64Test) { } TEST(RE2ArgTest, ParseFromTest) { -#if !defined(_MSC_VER) struct { bool ParseFrom(const char* str, size_t n) { LOG(INFO) << "str = " << str << ", n = " << n; @@ -155,7 +154,6 @@ TEST(RE2ArgTest, ParseFromTest) { } obj2; RE2::Arg arg2(&obj2); EXPECT_FALSE(arg2.Parse("two", 3)); -#endif } TEST(RE2ArgTest, OptionalDoubleTest) { From b7e96b34c0945fccb8b5282404f82c7ab0843717 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 14 May 2024 08:39:55 +0000 Subject: [PATCH 35/56] Bump some versions in `MODULE.bazel`. Change-Id: Ibf4f297ccf4a198cdf663ec424d988ee2603ecc5 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63051 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- MODULE.bazel | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 602097462..a14365c6d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -14,7 +14,7 @@ bazel_dep(name = "platforms", version = "0.0.10") bazel_dep(name = "apple_support", version = "1.15.1") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.2") -bazel_dep(name = "rules_python", version = "0.31.0") +bazel_dep(name = "rules_python", version = "0.32.2") bazel_dep(name = "pybind11_bazel", version = "2.12.0") # This is a temporary hack for `x64_x86_windows`. @@ -26,4 +26,4 @@ use_repo(cc_configure, "local_config_cc") # the root module (or when `--ignore_dev_dependency` is enabled). bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True) bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) -bazel_dep(name = "abseil-py", version = "1.4.0", dev_dependency = True) +bazel_dep(name = "abseil-py", version = "2.1.0", dev_dependency = True) From a67d6c1d5308b0950a91fed8e03e5c048d22d5cd Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 17 May 2024 17:49:17 +0000 Subject: [PATCH 36/56] Switch to vcpkg for dependencies. Ubuntu ships very old versions and it's cramping my style. (In particular, I want to be able to use Abseil logging.) While I'm here, add GCC 14 to the build matrix. ... and remove GCC 11 so that we continue to test with only the three most recent releases. Change-Id: If7eb226005d8d9e56d3523e6e255d29814646d10 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63070 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-cmake.yml | 16 +++++----------- .github/workflows/ci.yml | 15 +++++++++------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci-cmake.yml b/.github/workflows/ci-cmake.yml index 07ecdfbe0..c4f21ac40 100644 --- a/.github/workflows/ci-cmake.yml +++ b/.github/workflows/ci-cmake.yml @@ -7,26 +7,20 @@ permissions: jobs: build-linux: runs-on: ubuntu-latest - # The Benchmark package on Ubuntu 22.04 LTS is problematic whereas this - # Docker container is based on Debian bookworm and has a newer version. - container: gcc:13 strategy: fail-fast: false matrix: build_shared_libs: [OFF, ON] steps: - uses: actions/checkout@v4.1.4 - - name: Install CMake - run: | - apt update -y - apt install -y cmake - shell: bash - name: Install Abseil, GoogleTest and Benchmark run: | - apt update -y - apt install -y libabsl-dev libgtest-dev libbenchmark-dev + vcpkg update + vcpkg install abseil gtest benchmark shell: bash - - run: .github/cmake.sh -D BUILD_SHARED_LIBS=${{ matrix.build_shared_libs }} + - run: | + .github/cmake.sh -D BUILD_SHARED_LIBS=${{ matrix.build_shared_libs }} \ + -D CMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake shell: bash build-macos: runs-on: macos-latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b83b4e52d..b367ca242 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,7 @@ jobs: env: CC: clang-${{ matrix.ver }} CXX: clang++-${{ matrix.ver }} + PKG_CONFIG_PATH: /usr/local/share/vcpkg/installed/x64-linux/lib/pkgconfig steps: - uses: actions/checkout@v4.1.4 - name: Install Clang ${{ matrix.ver }} @@ -50,26 +51,28 @@ jobs: shell: bash - name: Install Abseil, GoogleTest and Benchmark run: | - sudo apt update -y - sudo apt install -y libabsl-dev libgtest-dev libbenchmark-dev + vcpkg update + vcpkg install abseil gtest benchmark shell: bash - run: make && make test shell: bash build-gcc: - runs-on: ubuntu-latest + # TODO(junyer): Switch back to `ubuntu-latest` when this becomes that. + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: - ver: [11, 12, 13] + ver: [12, 13, 14] env: CC: gcc-${{ matrix.ver }} CXX: g++-${{ matrix.ver }} + PKG_CONFIG_PATH: /usr/local/share/vcpkg/installed/x64-linux/lib/pkgconfig steps: - uses: actions/checkout@v4.1.4 - name: Install Abseil, GoogleTest and Benchmark run: | - sudo apt update -y - sudo apt install -y libabsl-dev libgtest-dev libbenchmark-dev + vcpkg update + vcpkg install abseil gtest benchmark shell: bash - run: make && make test shell: bash From b664e418a10d79f5ef207db69e1b9c0cf29ddde9 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 17 May 2024 18:22:29 +0000 Subject: [PATCH 37/56] Ask `pkg-config` about `gtest_main` as well. vcpkg installs `libgtest_main.a` into a `manual-link` subdirectory for some reason... Change-Id: I0842281094dae10ee82e72c22c165d3a8141cbe9 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63090 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 65b52f6ca..5d6d6c072 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,8 @@ LDABSL=$(shell $(PKG_CONFIG) $(ABSL_DEPS) --libs | sed -e 's/-Wl / /g') # Build against GoogleTest and Benchmark for... testing and benchmarking. # Capture only the `-L` flags for now; we will pass the `-l` flags later. -CCGTEST=$(shell $(PKG_CONFIG) gtest --cflags) -LDGTEST=$(shell $(PKG_CONFIG) gtest --libs-only-L) +CCGTEST=$(shell $(PKG_CONFIG) gtest gtest_main --cflags) +LDGTEST=$(shell $(PKG_CONFIG) gtest gtest_main --libs-only-L) CCBENCHMARK=$(shell $(PKG_CONFIG) benchmark --cflags) LDBENCHMARK=$(shell $(PKG_CONFIG) benchmark --libs-only-L) From 4f5fd7a5da8bb8168815d31e9e0e2d0599f5b8ca Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 17 May 2024 19:12:40 +0000 Subject: [PATCH 38/56] Switch to Abseil logging. Fixes #494. Change-Id: Ie8bd23d44a6f2609b72f115c3b2344a2a91637be Reviewed-on: https://code-review.googlesource.com/c/re2/+/63091 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- BUILD.bazel | 32 +++++++- CMakeLists.txt | 2 + Makefile | 3 +- re2/bitmap256.cc | 3 +- re2/bitmap256.h | 3 +- re2/bitstate.cc | 3 +- re2/compile.cc | 3 +- re2/dfa.cc | 3 +- re2/filtered_re2.cc | 3 +- re2/mimics_pcre.cc | 3 +- re2/nfa.cc | 3 +- re2/onepass.cc | 3 +- re2/parse.cc | 3 +- re2/prefilter.cc | 3 +- re2/prefilter.h | 3 +- re2/prefilter_tree.cc | 3 +- re2/prefilter_tree.h | 3 +- re2/prog.cc | 3 +- re2/prog.h | 3 +- re2/re2.cc | 3 +- re2/regexp.cc | 3 +- re2/regexp.h | 3 +- re2/set.cc | 3 +- re2/simplify.cc | 3 +- re2/testing/backtrack.cc | 3 +- re2/testing/compile_test.cc | 3 +- re2/testing/dfa_test.cc | 3 +- re2/testing/dump.cc | 3 +- re2/testing/exhaustive_tester.cc | 3 +- re2/testing/filtered_re2_test.cc | 3 +- re2/testing/mimics_pcre_test.cc | 3 +- re2/testing/null_walker.cc | 3 +- re2/testing/parse_test.cc | 3 +- re2/testing/possible_match_test.cc | 3 +- re2/testing/re2_arg_test.cc | 3 +- re2/testing/re2_test.cc | 3 +- re2/testing/regexp_benchmark.cc | 3 +- re2/testing/regexp_generator.cc | 3 +- re2/testing/regexp_test.cc | 3 +- re2/testing/required_prefix_test.cc | 3 +- re2/testing/set_test.cc | 3 +- re2/testing/simplify_test.cc | 3 +- re2/testing/string_generator.cc | 3 +- re2/testing/tester.cc | 3 +- re2/tostring.cc | 3 +- re2/walker-inl.h | 3 +- util/logging.h | 109 ---------------------------- util/pcre.cc | 3 +- 48 files changed, 122 insertions(+), 156 deletions(-) delete mode 100644 util/logging.h diff --git a/BUILD.bazel b/BUILD.bazel index a1664761f..dcb096953 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -42,7 +42,6 @@ cc_library( "re2/unicode_groups.cc", "re2/unicode_groups.h", "re2/walker-inl.h", - "util/logging.h", "util/rune.cc", "util/strutil.cc", "util/strutil.h", @@ -84,6 +83,8 @@ cc_library( "@abseil-cpp//absl/container:flat_hash_map", "@abseil-cpp//absl/container:flat_hash_set", "@abseil-cpp//absl/container:inlined_vector", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@abseil-cpp//absl/synchronization", @@ -125,7 +126,6 @@ cc_library( "re2/unicode_casefold.h", "re2/unicode_groups.h", "re2/walker-inl.h", - "util/logging.h", "util/strutil.h", "util/utf.h", ], @@ -135,6 +135,8 @@ cc_library( "@abseil-cpp//absl/base", "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", @@ -161,6 +163,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -174,6 +178,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -186,6 +192,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -198,6 +206,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -211,6 +221,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -225,6 +237,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -238,6 +252,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", @@ -250,6 +266,8 @@ cc_test( srcs = ["re2/testing/regexp_test.cc"], deps = [ ":testing", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -262,6 +280,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -286,6 +306,8 @@ cc_test( deps = [ ":re2", ":testing", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -298,6 +320,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -323,6 +347,8 @@ cc_test( ":testing", "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", @@ -395,6 +421,8 @@ cc_binary( ":testing", "@abseil-cpp//absl/container:flat_hash_map", "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings:str_format", "@abseil-cpp//absl/synchronization", "@google_benchmark//:benchmark_main", diff --git a/CMakeLists.txt b/CMakeLists.txt index bdac5afd6..36e7e7156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,12 +61,14 @@ endif() set(ABSL_DEPS absl_base + absl_check absl_core_headers absl_fixed_array absl_flags absl_flat_hash_map absl_flat_hash_set absl_inlined_vector + absl_log absl_optional absl_span absl_str_format diff --git a/Makefile b/Makefile index 5d6d6c072..51a1034d0 100644 --- a/Makefile +++ b/Makefile @@ -5,12 +5,14 @@ # Build against Abseil. ABSL_DEPS=\ absl_base\ + absl_check\ absl_core_headers\ absl_fixed_array\ absl_flags\ absl_flat_hash_map\ absl_flat_hash_set\ absl_inlined_vector\ + absl_log\ absl_optional\ absl_span\ absl_str_format\ @@ -113,7 +115,6 @@ INSTALL_HFILES=\ re2/stringpiece.h\ HFILES=\ - util/logging.h\ util/malloc_counter.h\ util/pcre.h\ util/strutil.h\ diff --git a/re2/bitmap256.cc b/re2/bitmap256.cc index f6fbca304..e455fde76 100644 --- a/re2/bitmap256.cc +++ b/re2/bitmap256.cc @@ -7,7 +7,8 @@ #include #include "absl/base/macros.h" -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace re2 { diff --git a/re2/bitmap256.h b/re2/bitmap256.h index 293b31d85..29e2984a0 100644 --- a/re2/bitmap256.h +++ b/re2/bitmap256.h @@ -11,7 +11,8 @@ #include #include -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace re2 { diff --git a/re2/bitstate.cc b/re2/bitstate.cc index 38a0b87cc..cac8aa0af 100644 --- a/re2/bitstate.cc +++ b/re2/bitstate.cc @@ -23,7 +23,8 @@ #include #include -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/compile.cc b/re2/compile.cc index aa798872e..17e31481b 100644 --- a/re2/compile.cc +++ b/re2/compile.cc @@ -14,7 +14,8 @@ #include "absl/base/macros.h" #include "absl/container/flat_hash_map.h" -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "util/utf.h" #include "re2/pod_array.h" #include "re2/prog.h" diff --git a/re2/dfa.cc b/re2/dfa.cc index e35fcb281..9b8a43758 100644 --- a/re2/dfa.cc +++ b/re2/dfa.cc @@ -38,10 +38,11 @@ #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "absl/types/span.h" -#include "util/logging.h" #include "util/strutil.h" #include "re2/pod_array.h" #include "re2/prog.h" diff --git a/re2/filtered_re2.cc b/re2/filtered_re2.cc index 1ce26a38e..1ef675856 100644 --- a/re2/filtered_re2.cc +++ b/re2/filtered_re2.cc @@ -8,7 +8,8 @@ #include #include -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "re2/prefilter.h" #include "re2/prefilter_tree.h" diff --git a/re2/mimics_pcre.cc b/re2/mimics_pcre.cc index ac0c69d7e..1e4d0d751 100644 --- a/re2/mimics_pcre.cc +++ b/re2/mimics_pcre.cc @@ -22,7 +22,8 @@ // // Regexp::MimicsPCRE checks for any of these conditions. -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "re2/regexp.h" #include "re2/walker-inl.h" diff --git a/re2/nfa.cc b/re2/nfa.cc index a655884d7..3ef8287c6 100644 --- a/re2/nfa.cc +++ b/re2/nfa.cc @@ -32,8 +32,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/onepass.cc b/re2/onepass.cc index 7931cf911..9831cc828 100644 --- a/re2/onepass.cc +++ b/re2/onepass.cc @@ -59,8 +59,9 @@ #include "absl/container/fixed_array.h" #include "absl/container/inlined_vector.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "util/utf.h" #include "re2/pod_array.h" #include "re2/prog.h" diff --git a/re2/parse.cc b/re2/parse.cc index 2558b2a2e..003b14c86 100644 --- a/re2/parse.cc +++ b/re2/parse.cc @@ -26,8 +26,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/ascii.h" -#include "util/logging.h" #include "util/utf.h" #include "re2/pod_array.h" #include "re2/regexp.h" diff --git a/re2/prefilter.cc b/re2/prefilter.cc index 3c7886f83..53290b02f 100644 --- a/re2/prefilter.cc +++ b/re2/prefilter.cc @@ -10,8 +10,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "util/utf.h" #include "re2/re2.h" #include "re2/unicode_casefold.h" diff --git a/re2/prefilter.h b/re2/prefilter.h index 018691dcd..cf32bd674 100644 --- a/re2/prefilter.h +++ b/re2/prefilter.h @@ -13,7 +13,8 @@ #include #include -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace re2 { diff --git a/re2/prefilter_tree.cc b/re2/prefilter_tree.cc index 299a680fb..b7a7408f4 100644 --- a/re2/prefilter_tree.cc +++ b/re2/prefilter_tree.cc @@ -12,8 +12,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "re2/prefilter.h" #include "re2/re2.h" diff --git a/re2/prefilter_tree.h b/re2/prefilter_tree.h index 71e7a294f..ba23282d4 100644 --- a/re2/prefilter_tree.h +++ b/re2/prefilter_tree.h @@ -20,9 +20,10 @@ #include #include "absl/container/flat_hash_set.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "re2/prefilter.h" #include "re2/sparse_array.h" -#include "util/logging.h" namespace re2 { diff --git a/re2/prog.cc b/re2/prog.cc index 6cadcfa83..423e1769e 100644 --- a/re2/prog.cc +++ b/re2/prog.cc @@ -20,8 +20,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "re2/bitmap256.h" namespace re2 { diff --git a/re2/prog.h b/re2/prog.h index 41923f314..5db21c45f 100644 --- a/re2/prog.h +++ b/re2/prog.h @@ -16,8 +16,9 @@ #include #include "absl/base/call_once.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/string_view.h" -#include "util/logging.h" #include "re2/pod_array.h" #include "re2/re2.h" #include "re2/sparse_array.h" diff --git a/re2/re2.cc b/re2/re2.cc index 61d9d1f0c..332157ebc 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -26,9 +26,10 @@ #include "absl/base/macros.h" #include "absl/container/fixed_array.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/ascii.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "util/strutil.h" #include "util/utf.h" #include "re2/prog.h" diff --git a/re2/regexp.cc b/re2/regexp.cc index 4ea81cfcd..f374c1546 100644 --- a/re2/regexp.cc +++ b/re2/regexp.cc @@ -18,8 +18,9 @@ #include "absl/base/call_once.h" #include "absl/base/macros.h" #include "absl/container/flat_hash_map.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/synchronization/mutex.h" -#include "util/logging.h" #include "util/utf.h" #include "re2/pod_array.h" #include "re2/walker-inl.h" diff --git a/re2/regexp.h b/re2/regexp.h index df4989479..9c05cc855 100644 --- a/re2/regexp.h +++ b/re2/regexp.h @@ -92,8 +92,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/string_view.h" -#include "util/logging.h" #include "util/utf.h" namespace re2 { diff --git a/re2/set.cc b/re2/set.cc index b9c918e07..4f269075e 100644 --- a/re2/set.cc +++ b/re2/set.cc @@ -9,7 +9,8 @@ #include #include -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/re2.h" diff --git a/re2/simplify.cc b/re2/simplify.cc index cea100b08..06966128d 100644 --- a/re2/simplify.cc +++ b/re2/simplify.cc @@ -9,7 +9,8 @@ #include #include -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "util/utf.h" #include "re2/pod_array.h" #include "re2/regexp.h" diff --git a/re2/testing/backtrack.cc b/re2/testing/backtrack.cc index 90071bb0f..2ea98e8e6 100644 --- a/re2/testing/backtrack.cc +++ b/re2/testing/backtrack.cc @@ -28,7 +28,8 @@ #include #include "absl/base/macros.h" -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/compile_test.cc b/re2/testing/compile_test.cc index f6899d3d2..532f8965b 100644 --- a/re2/testing/compile_test.cc +++ b/re2/testing/compile_test.cc @@ -7,8 +7,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/regexp.h" #include "re2/prog.h" diff --git a/re2/testing/dfa_test.cc b/re2/testing/dfa_test.cc index b0759f7c7..aa9546569 100644 --- a/re2/testing/dfa_test.cc +++ b/re2/testing/dfa_test.cc @@ -9,9 +9,10 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "util/malloc_counter.h" #include "re2/prog.h" #include "re2/re2.h" diff --git a/re2/testing/dump.cc b/re2/testing/dump.cc index 9e3c94a69..074c6a20a 100644 --- a/re2/testing/dump.cc +++ b/re2/testing/dump.cc @@ -19,9 +19,10 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "util/utf.h" #include "re2/regexp.h" diff --git a/re2/testing/exhaustive_tester.cc b/re2/testing/exhaustive_tester.cc index a57f700bc..4d1ff0f02 100644 --- a/re2/testing/exhaustive_tester.cc +++ b/re2/testing/exhaustive_tester.cc @@ -15,9 +15,10 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/testing/exhaustive_tester.h" #include "re2/testing/tester.h" diff --git a/re2/testing/filtered_re2_test.cc b/re2/testing/filtered_re2_test.cc index a8d2dfc72..aea311b58 100644 --- a/re2/testing/filtered_re2_test.cc +++ b/re2/testing/filtered_re2_test.cc @@ -10,8 +10,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/filtered_re2.h" #include "re2/re2.h" diff --git a/re2/testing/mimics_pcre_test.cc b/re2/testing/mimics_pcre_test.cc index 829659d67..d12e511c7 100644 --- a/re2/testing/mimics_pcre_test.cc +++ b/re2/testing/mimics_pcre_test.cc @@ -3,8 +3,9 @@ // license that can be found in the LICENSE file. #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/null_walker.cc b/re2/testing/null_walker.cc index 745364b3c..4e64f823c 100644 --- a/re2/testing/null_walker.cc +++ b/re2/testing/null_walker.cc @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/regexp.h" #include "re2/walker-inl.h" diff --git a/re2/testing/parse_test.cc b/re2/testing/parse_test.cc index 95294d5ff..350720081 100644 --- a/re2/testing/parse_test.cc +++ b/re2/testing/parse_test.cc @@ -7,8 +7,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/regexp.h" namespace re2 { diff --git a/re2/testing/possible_match_test.cc b/re2/testing/possible_match_test.cc index fe199c662..16e169d04 100644 --- a/re2/testing/possible_match_test.cc +++ b/re2/testing/possible_match_test.cc @@ -7,9 +7,10 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/escaping.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/prog.h" #include "re2/re2.h" #include "re2/regexp.h" diff --git a/re2/testing/re2_arg_test.cc b/re2/testing/re2_arg_test.cc index 78d4aee43..a9b044d73 100644 --- a/re2/testing/re2_arg_test.cc +++ b/re2/testing/re2_arg_test.cc @@ -11,8 +11,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/re2.h" namespace re2 { diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index ddf8dbf8f..95bf461fb 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -19,9 +19,10 @@ #endif #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/re2.h" #include "re2/regexp.h" diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc index 5352b3101..319289558 100644 --- a/re2/testing/regexp_benchmark.cc +++ b/re2/testing/regexp_benchmark.cc @@ -13,10 +13,11 @@ #include "absl/container/flat_hash_map.h" #include "absl/flags/flag.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "benchmark/benchmark.h" -#include "util/logging.h" #include "util/malloc_counter.h" #include "re2/prog.h" #include "re2/re2.h" diff --git a/re2/testing/regexp_generator.cc b/re2/testing/regexp_generator.cc index b1761ed93..4d9346fb6 100644 --- a/re2/testing/regexp_generator.cc +++ b/re2/testing/regexp_generator.cc @@ -30,10 +30,11 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "util/utf.h" #include "re2/testing/regexp_generator.h" diff --git a/re2/testing/regexp_test.cc b/re2/testing/regexp_test.cc index ef8f59d36..54aa8ada9 100644 --- a/re2/testing/regexp_test.cc +++ b/re2/testing/regexp_test.cc @@ -9,8 +9,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/regexp.h" namespace re2 { diff --git a/re2/testing/required_prefix_test.cc b/re2/testing/required_prefix_test.cc index 231fd3485..83e2c3e8e 100644 --- a/re2/testing/required_prefix_test.cc +++ b/re2/testing/required_prefix_test.cc @@ -5,8 +5,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/set_test.cc b/re2/testing/set_test.cc index fdbc0b2c7..abd0fa48b 100644 --- a/re2/testing/set_test.cc +++ b/re2/testing/set_test.cc @@ -7,8 +7,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/re2.h" #include "re2/set.h" diff --git a/re2/testing/simplify_test.cc b/re2/testing/simplify_test.cc index 5b683f580..4a182d1a0 100644 --- a/re2/testing/simplify_test.cc +++ b/re2/testing/simplify_test.cc @@ -8,8 +8,9 @@ #include #include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/regexp.h" namespace re2 { diff --git a/re2/testing/string_generator.cc b/re2/testing/string_generator.cc index 1891b14a7..90ec46f1d 100644 --- a/re2/testing/string_generator.cc +++ b/re2/testing/string_generator.cc @@ -11,8 +11,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" -#include "util/logging.h" #include "re2/testing/string_generator.h" namespace re2 { diff --git a/re2/testing/tester.cc b/re2/testing/tester.cc index a094cb4ff..e0161be09 100644 --- a/re2/testing/tester.cc +++ b/re2/testing/tester.cc @@ -11,9 +11,10 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "re2/testing/tester.h" #include "re2/prog.h" #include "re2/re2.h" diff --git a/re2/tostring.cc b/re2/tostring.cc index 33179fdeb..e1e870ba7 100644 --- a/re2/tostring.cc +++ b/re2/tostring.cc @@ -8,8 +8,9 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "util/utf.h" #include "re2/regexp.h" #include "re2/walker-inl.h" diff --git a/re2/walker-inl.h b/re2/walker-inl.h index 45763a7b2..fe0dc8c7b 100644 --- a/re2/walker-inl.h +++ b/re2/walker-inl.h @@ -16,7 +16,8 @@ #include #include "absl/base/macros.h" -#include "util/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "re2/regexp.h" namespace re2 { diff --git a/util/logging.h b/util/logging.h deleted file mode 100644 index 946962b39..000000000 --- a/util/logging.h +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2009 The RE2 Authors. All Rights Reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#ifndef UTIL_LOGGING_H_ -#define UTIL_LOGGING_H_ - -// Simplified version of Google's logging. - -#include -#include -#include -#include -#include - -#include "absl/base/attributes.h" - -// Debug-only checking. -#define DCHECK(condition) assert(condition) -#define DCHECK_EQ(val1, val2) assert((val1) == (val2)) -#define DCHECK_NE(val1, val2) assert((val1) != (val2)) -#define DCHECK_LE(val1, val2) assert((val1) <= (val2)) -#define DCHECK_LT(val1, val2) assert((val1) < (val2)) -#define DCHECK_GE(val1, val2) assert((val1) >= (val2)) -#define DCHECK_GT(val1, val2) assert((val1) > (val2)) - -// Always-on checking -#define CHECK(x) if(x){}else LogMessageFatal(__FILE__, __LINE__).stream() << "Check failed: " #x -#define CHECK_LT(x, y) CHECK((x) < (y)) -#define CHECK_GT(x, y) CHECK((x) > (y)) -#define CHECK_LE(x, y) CHECK((x) <= (y)) -#define CHECK_GE(x, y) CHECK((x) >= (y)) -#define CHECK_EQ(x, y) CHECK((x) == (y)) -#define CHECK_NE(x, y) CHECK((x) != (y)) - -#define LOG_INFO LogMessage(__FILE__, __LINE__) -#define LOG_WARNING LogMessage(__FILE__, __LINE__) -#define LOG_ERROR LogMessage(__FILE__, __LINE__) -#define LOG_FATAL LogMessageFatal(__FILE__, __LINE__) -#define LOG_QFATAL LOG_FATAL - -// It seems that one of the Windows header files defines ERROR as 0. -#ifdef _WIN32 -#define LOG_0 LOG_INFO -#endif - -#ifdef NDEBUG -#define LOG_DFATAL LOG_ERROR -#else -#define LOG_DFATAL LOG_FATAL -#endif - -#define LOG(severity) LOG_ ## severity.stream() - -#define VLOG(x) if((x)>0){}else LOG_INFO.stream() - -class LogMessage { - public: - LogMessage(const char* file, int line) - : flushed_(false) { - stream() << file << ":" << line << ": "; - } - void Flush() { - stream() << "\n"; - std::string s = str_.str(); - size_t n = s.size(); - if (fwrite(s.data(), 1, n, stderr) < n) {} // shut up gcc - flushed_ = true; - } - ~LogMessage() { - if (!flushed_) { - Flush(); - } - } - std::ostream& stream() { return str_; } - - private: - bool flushed_; - std::ostringstream str_; - - LogMessage(const LogMessage&) = delete; - LogMessage& operator=(const LogMessage&) = delete; -}; - -// Silence "destructor never returns" warning for ~LogMessageFatal(). -// Since this is a header file, push and then pop to limit the scope. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4722) -#endif - -class LogMessageFatal : public LogMessage { - public: - LogMessageFatal(const char* file, int line) - : LogMessage(file, line) {} - ABSL_ATTRIBUTE_NORETURN ~LogMessageFatal() { - Flush(); - abort(); - } - private: - LogMessageFatal(const LogMessageFatal&) = delete; - LogMessageFatal& operator=(const LogMessageFatal&) = delete; -}; - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif // UTIL_LOGGING_H_ diff --git a/util/pcre.cc b/util/pcre.cc index 27aee3dc4..71e5329a4 100644 --- a/util/pcre.cc +++ b/util/pcre.cc @@ -16,8 +16,9 @@ #include #include "absl/flags/flag.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "util/pcre.h" // Silence warnings about the wacky formatting in the operator() functions. From 630d0115f2d14a93472703079fb0ab4dd12270b9 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sat, 18 May 2024 11:09:29 +0000 Subject: [PATCH 39/56] Use the `ABSL_`-prefixed Abseil logging macros. This is done primarily for the sake of Chromium, which bans the unprefixed Abseil logging macros. I mostly baked the following slices of Perl pie: ``` 's,//absl/log:check",//absl/log:absl_check",' 's,//absl/log",//absl/log:absl_log",' 's,"absl/log/check.h","absl/log/absl_check.h",' 's,"absl/log/log.h","absl/log/absl_log.h",' 's,D?CHECK(_(EQ|NE|LE|LT|GE|GT))?\(,ABSL_$&,' 's,V?LOG\(,ABSL_$&,' ``` Change-Id: I65493aff42abab6865f8e2b5b769b6a651dbef3a Reviewed-on: https://code-review.googlesource.com/c/re2/+/63092 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- BUILD.bazel | 60 ++--- CMakeLists.txt | 4 +- Makefile | 4 +- re2/bitmap256.cc | 8 +- re2/bitmap256.h | 14 +- re2/bitstate.cc | 14 +- re2/compile.cc | 20 +- re2/dfa.cc | 40 ++-- re2/filtered_re2.cc | 12 +- re2/mimics_pcre.cc | 8 +- re2/nfa.cc | 36 +-- re2/onepass.cc | 28 +-- re2/parse.cc | 22 +- re2/prefilter.cc | 24 +- re2/prefilter.h | 6 +- re2/prefilter_tree.cc | 34 +-- re2/prefilter_tree.h | 10 +- re2/prog.cc | 48 ++-- re2/prog.h | 56 +++-- re2/re2.cc | 90 ++++---- re2/re2.h | 35 +-- re2/regexp.cc | 22 +- re2/regexp.h | 51 ++++- re2/set.cc | 22 +- re2/simplify.cc | 19 +- re2/testing/backtrack.cc | 14 +- re2/testing/compile_test.cc | 14 +- re2/testing/dfa_test.cc | 23 +- re2/testing/dump.cc | 8 +- re2/testing/exhaustive_tester.cc | 10 +- re2/testing/filtered_re2_test.cc | 18 +- re2/testing/mimics_pcre_test.cc | 4 +- re2/testing/null_walker.cc | 6 +- re2/testing/parse_test.cc | 6 +- re2/testing/possible_match_test.cc | 15 +- re2/testing/re2_arg_test.cc | 8 +- re2/testing/re2_test.cc | 10 +- re2/testing/regexp_benchmark.cc | 338 +++++++++++++++------------- re2/testing/regexp_generator.cc | 12 +- re2/testing/regexp_test.cc | 4 +- re2/testing/required_prefix_test.cc | 4 +- re2/testing/set_test.cc | 4 +- re2/testing/simplify_test.cc | 6 +- re2/testing/string_generator.cc | 14 +- re2/testing/tester.cc | 81 +++---- re2/tostring.cc | 8 +- re2/walker-inl.h | 8 +- util/pcre.cc | 6 +- util/pcre.h | 32 +-- 49 files changed, 716 insertions(+), 624 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index dcb096953..f1ceaedf1 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -83,8 +83,8 @@ cc_library( "@abseil-cpp//absl/container:flat_hash_map", "@abseil-cpp//absl/container:flat_hash_set", "@abseil-cpp//absl/container:inlined_vector", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@abseil-cpp//absl/synchronization", @@ -135,8 +135,8 @@ cc_library( "@abseil-cpp//absl/base", "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/flags:flag", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", @@ -163,8 +163,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -178,8 +178,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -192,8 +192,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -206,8 +206,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -221,8 +221,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@abseil-cpp//absl/strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -237,8 +237,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -252,8 +252,8 @@ cc_test( ":re2", ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", @@ -266,8 +266,8 @@ cc_test( srcs = ["re2/testing/regexp_test.cc"], deps = [ ":testing", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -280,8 +280,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -306,8 +306,8 @@ cc_test( deps = [ ":re2", ":testing", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -320,8 +320,8 @@ cc_test( deps = [ ":testing", "@abseil-cpp//absl/base:core_headers", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -347,8 +347,8 @@ cc_test( ":testing", "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/flags:flag", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", @@ -421,8 +421,8 @@ cc_binary( ":testing", "@abseil-cpp//absl/container:flat_hash_map", "@abseil-cpp//absl/flags:flag", - "@abseil-cpp//absl/log", - "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/log:absl_check", + "@abseil-cpp//absl/log:absl_log", "@abseil-cpp//absl/strings:str_format", "@abseil-cpp//absl/synchronization", "@google_benchmark//:benchmark_main", diff --git a/CMakeLists.txt b/CMakeLists.txt index 36e7e7156..2f8a1c77c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,15 +60,15 @@ if(UNIX) endif() set(ABSL_DEPS + absl_absl_check + absl_absl_log absl_base - absl_check absl_core_headers absl_fixed_array absl_flags absl_flat_hash_map absl_flat_hash_set absl_inlined_vector - absl_log absl_optional absl_span absl_str_format diff --git a/Makefile b/Makefile index 51a1034d0..887d82d29 100644 --- a/Makefile +++ b/Makefile @@ -4,15 +4,15 @@ # Build against Abseil. ABSL_DEPS=\ + absl_absl_check\ + absl_absl_log\ absl_base\ - absl_check\ absl_core_headers\ absl_fixed_array\ absl_flags\ absl_flat_hash_map\ absl_flat_hash_set\ absl_inlined_vector\ - absl_log\ absl_optional\ absl_span\ absl_str_format\ diff --git a/re2/bitmap256.cc b/re2/bitmap256.cc index e455fde76..fe2ba7e4a 100644 --- a/re2/bitmap256.cc +++ b/re2/bitmap256.cc @@ -7,14 +7,14 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" namespace re2 { int Bitmap256::FindNextSetBit(int c) const { - DCHECK_GE(c, 0); - DCHECK_LE(c, 255); + ABSL_DCHECK_GE(c, 0); + ABSL_DCHECK_LE(c, 255); // Check the word that contains the bit. Mask out any lower bits. int i = c / 64; diff --git a/re2/bitmap256.h b/re2/bitmap256.h index 29e2984a0..45913a615 100644 --- a/re2/bitmap256.h +++ b/re2/bitmap256.h @@ -11,8 +11,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" namespace re2 { @@ -29,16 +29,16 @@ class Bitmap256 { // Tests the bit with index c. bool Test(int c) const { - DCHECK_GE(c, 0); - DCHECK_LE(c, 255); + ABSL_DCHECK_GE(c, 0); + ABSL_DCHECK_LE(c, 255); return (words_[c / 64] & (uint64_t{1} << (c % 64))) != 0; } // Sets the bit with index c. void Set(int c) { - DCHECK_GE(c, 0); - DCHECK_LE(c, 255); + ABSL_DCHECK_GE(c, 0); + ABSL_DCHECK_LE(c, 255); words_[c / 64] |= (uint64_t{1} << (c % 64)); } @@ -50,7 +50,7 @@ class Bitmap256 { private: // Finds the least significant non-zero bit in n. static int FindLSBSet(uint64_t n) { - DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, 0); #if defined(__GNUC__) return __builtin_ctzll(n); #elif defined(_MSC_VER) && defined(_M_X64) diff --git a/re2/bitstate.cc b/re2/bitstate.cc index cac8aa0af..e69c1067e 100644 --- a/re2/bitstate.cc +++ b/re2/bitstate.cc @@ -23,8 +23,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" @@ -108,9 +108,9 @@ void BitState::Push(int id, const char* p) { if (njob_ >= job_.size()) { GrowStack(); if (njob_ >= job_.size()) { - LOG(DFATAL) << "GrowStack() failed: " - << "njob_ = " << njob_ << ", " - << "job_.size() = " << job_.size(); + ABSL_LOG(DFATAL) << "GrowStack() failed: " + << "njob_ = " << njob_ << ", " + << "job_.size() = " << job_.size(); return; } } @@ -168,7 +168,7 @@ bool BitState::TrySearch(int id0, const char* p0) { Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "Unexpected opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "Unexpected opcode: " << ip->opcode(); return false; case kInstFail: @@ -234,7 +234,7 @@ bool BitState::TrySearch(int id0, const char* p0) { CheckAndLoop: // Sanity check: id is the head of its list, which must // be the case if id-1 is the last of *its* list. :) - DCHECK(id == 0 || prog_->inst(id-1)->last()); + ABSL_DCHECK(id == 0 || prog_->inst(id-1)->last()); if (ShouldVisit(id, p)) goto Loop; break; diff --git a/re2/compile.cc b/re2/compile.cc index 17e31481b..ce3c32e23 100644 --- a/re2/compile.cc +++ b/re2/compile.cc @@ -14,8 +14,8 @@ #include "absl/base/macros.h" #include "absl/container/flat_hash_map.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "util/utf.h" #include "re2/pod_array.h" #include "re2/prog.h" @@ -523,8 +523,8 @@ void Compiler::AddSuffix(int id) { } int Compiler::AddSuffixRecursive(int root, int id) { - DCHECK(inst_[root].opcode() == kInstAlt || - inst_[root].opcode() == kInstByteRange); + ABSL_DCHECK(inst_[root].opcode() == kInstAlt || + inst_[root].opcode() == kInstByteRange); Frag f = FindByteRange(root, id); if (IsNoMatch(f)) { @@ -566,7 +566,7 @@ int Compiler::AddSuffixRecursive(int root, int id) { if (!IsCachedRuneByteSuffix(id)) { // The head should be the instruction most recently allocated, so free it // instead of leaving it unreachable. - DCHECK_EQ(id, ninst_-1); + ABSL_DCHECK_EQ(id, ninst_-1); inst_[id].out_opcode_ = 0; inst_[id].out1_ = 0; ninst_--; @@ -614,7 +614,7 @@ Frag Compiler::FindByteRange(int root, int id) { return NoMatch(); } - LOG(DFATAL) << "should never happen"; + ABSL_LOG(DFATAL) << "should never happen"; return NoMatch(); } @@ -739,7 +739,7 @@ void Compiler::AddRuneRangeUTF8(Rune lo, Rune hi, bool foldcase) { int n = runetochar(reinterpret_cast(ulo), &lo); int m = runetochar(reinterpret_cast(uhi), &hi); (void)m; // USED(m) - DCHECK_EQ(n, m); + ABSL_DCHECK_EQ(n, m); // The logic below encodes this thinking: // @@ -792,7 +792,7 @@ void Compiler::AddRuneRangeUTF8(Rune lo, Rune hi, bool foldcase) { Frag Compiler::Copy(Frag arg) { // We're using WalkExponential; there should be no copying. failed_ = true; - LOG(DFATAL) << "Compiler::Copy called!"; + ABSL_LOG(DFATAL) << "Compiler::Copy called!"; return NoMatch(); } @@ -919,7 +919,7 @@ Frag Compiler::PostVisit(Regexp* re, Frag, Frag, Frag* child_frags, if (cc->empty()) { // This can't happen. failed_ = true; - LOG(DFATAL) << "No ranges in char class"; + ABSL_LOG(DFATAL) << "No ranges in char class"; return NoMatch(); } @@ -977,7 +977,7 @@ Frag Compiler::PostVisit(Regexp* re, Frag, Frag, Frag* child_frags, return EmptyWidth(kEmptyNonWordBoundary); } failed_ = true; - LOG(DFATAL) << "Missing case in Compiler: " << re->op(); + ABSL_LOG(DFATAL) << "Missing case in Compiler: " << re->op(); return NoMatch(); } diff --git a/re2/dfa.cc b/re2/dfa.cc index 9b8a43758..808f87242 100644 --- a/re2/dfa.cc +++ b/re2/dfa.cc @@ -38,8 +38,8 @@ #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "absl/types/span.h" @@ -150,15 +150,15 @@ class DFA { struct StateHash { size_t operator()(const State* a) const { - DCHECK(a != NULL); + ABSL_DCHECK(a != NULL); return absl::Hash()(*a); } }; struct StateEqual { bool operator()(const State* a, const State* b) const { - DCHECK(a != NULL); - DCHECK(b != NULL); + ABSL_DCHECK(a != NULL); + ABSL_DCHECK(b != NULL); return *a == *b; } }; @@ -660,7 +660,7 @@ DFA::State* DFA::WorkqToCachedState(Workq* q, Workq* mq, uint32_t flag) { break; } } - DCHECK_LE(n, q->size()); + ABSL_DCHECK_LE(n, q->size()); if (n > 0 && inst[n-1] == Mark) n--; @@ -848,7 +848,7 @@ void DFA::AddToQueue(Workq* q, int id, uint32_t flag) { stk[nstk++] = id; while (nstk > 0) { - DCHECK_LE(nstk, stack_.size()); + ABSL_DCHECK_LE(nstk, stack_.size()); id = stk[--nstk]; Loop: @@ -873,7 +873,7 @@ void DFA::AddToQueue(Workq* q, int id, uint32_t flag) { Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstByteRange: // just save these on the queue @@ -899,7 +899,7 @@ void DFA::AddToQueue(Workq* q, int id, uint32_t flag) { goto Loop; case kInstAltMatch: - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); id = id+1; goto Loop; @@ -962,7 +962,7 @@ void DFA::RunWorkqOnByte(Workq* oldq, Workq* newq, Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstFail: // never succeeds @@ -1030,14 +1030,14 @@ DFA::State* DFA::RunStateOnByte(State* state, int c) { return FullMatchState; } if (state == DeadState) { - LOG(DFATAL) << "DeadState in RunStateOnByte"; + ABSL_LOG(DFATAL) << "DeadState in RunStateOnByte"; return NULL; } if (state == NULL) { - LOG(DFATAL) << "NULL state in RunStateOnByte"; + ABSL_LOG(DFATAL) << "NULL state in RunStateOnByte"; return NULL; } - LOG(DFATAL) << "Unexpected special state in RunStateOnByte"; + ABSL_LOG(DFATAL) << "Unexpected special state in RunStateOnByte"; return NULL; } @@ -1268,7 +1268,7 @@ DFA::State* DFA::StateSaver::Restore() { absl::MutexLock l(&dfa_->mutex_); State* s = dfa_->CachedState(inst_, ninst_, flag_); if (s == NULL) - LOG(DFATAL) << "StateSaver failed to restore state."; + ABSL_LOG(DFATAL) << "StateSaver failed to restore state."; return s; } @@ -1452,13 +1452,13 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params) { // Restore start and s so we can continue. if ((start = save_start.Restore()) == NULL || (s = save_s.Restore()) == NULL) { - // Restore already did LOG(DFATAL). + // Restore already did ABSL_LOG(DFATAL). params->failed = true; return false; } ns = RunStateOnByteUnlocked(s, c); if (ns == NULL) { - LOG(DFATAL) << "RunStateOnByteUnlocked failed after ResetCache"; + ABSL_LOG(DFATAL) << "RunStateOnByteUnlocked failed after ResetCache"; params->failed = true; return false; } @@ -1530,7 +1530,7 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params) { } ns = RunStateOnByteUnlocked(s, lastbyte); if (ns == NULL) { - LOG(DFATAL) << "RunStateOnByteUnlocked failed after Reset"; + ABSL_LOG(DFATAL) << "RunStateOnByteUnlocked failed after Reset"; params->failed = true; return false; } @@ -1647,7 +1647,7 @@ bool DFA::AnalyzeSearch(SearchParams* params) { // Sanity check: make sure that text lies within context. if (BeginPtr(text) < BeginPtr(context) || EndPtr(text) > EndPtr(context)) { - LOG(DFATAL) << "context does not contain text"; + ABSL_LOG(DFATAL) << "context does not contain text"; params->start = DeadState; return true; } @@ -1695,7 +1695,7 @@ bool DFA::AnalyzeSearch(SearchParams* params) { ResetCache(params->cache_lock); if (!AnalyzeSearchHelper(params, info, flags)) { params->failed = true; - LOG(DFATAL) << "Failed to analyze start state."; + ABSL_LOG(DFATAL) << "Failed to analyze start state."; return false; } } @@ -1769,7 +1769,7 @@ bool DFA::Search(absl::string_view text, absl::string_view context, params.want_earliest_match = want_earliest_match; params.run_forward = run_forward; // matches should be null except when using RE2::Set. - DCHECK(matches == NULL || kind_ == Prog::kManyMatch); + ABSL_DCHECK(matches == NULL || kind_ == Prog::kManyMatch); params.matches = matches; if (!AnalyzeSearch(¶ms)) { diff --git a/re2/filtered_re2.cc b/re2/filtered_re2.cc index 1ef675856..78e4a5675 100644 --- a/re2/filtered_re2.cc +++ b/re2/filtered_re2.cc @@ -8,8 +8,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/prefilter.h" #include "re2/prefilter_tree.h" @@ -53,8 +53,8 @@ RE2::ErrorCode FilteredRE2::Add(absl::string_view pattern, if (!re->ok()) { if (options.log_errors()) { - LOG(ERROR) << "Couldn't compile regular expression, skipping: " - << pattern << " due to error " << re->error(); + ABSL_LOG(ERROR) << "Couldn't compile regular expression, skipping: " + << pattern << " due to error " << re->error(); } delete re; } else { @@ -67,7 +67,7 @@ RE2::ErrorCode FilteredRE2::Add(absl::string_view pattern, void FilteredRE2::Compile(std::vector* atoms) { if (compiled_) { - LOG(ERROR) << "Compile called already."; + ABSL_LOG(ERROR) << "Compile called already."; return; } @@ -96,7 +96,7 @@ int FilteredRE2::SlowFirstMatch(absl::string_view text) const { int FilteredRE2::FirstMatch(absl::string_view text, const std::vector& atoms) const { if (!compiled_) { - LOG(DFATAL) << "FirstMatch called before Compile."; + ABSL_LOG(DFATAL) << "FirstMatch called before Compile."; return -1; } std::vector regexps; diff --git a/re2/mimics_pcre.cc b/re2/mimics_pcre.cc index 1e4d0d751..43860a6a1 100644 --- a/re2/mimics_pcre.cc +++ b/re2/mimics_pcre.cc @@ -22,8 +22,8 @@ // // Regexp::MimicsPCRE checks for any of these conditions. -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/regexp.h" #include "re2/walker-inl.h" @@ -45,7 +45,7 @@ class PCREWalker : public Regexp::Walker { virtual bool ShortVisit(Regexp* re, bool a) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "PCREWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "PCREWalker::ShortVisit called"; #endif return a; } @@ -129,7 +129,7 @@ class EmptyStringWalker : public Regexp::Walker { virtual bool ShortVisit(Regexp* re, bool a) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "EmptyStringWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "EmptyStringWalker::ShortVisit called"; #endif return a; } diff --git a/re2/nfa.cc b/re2/nfa.cc index 3ef8287c6..9ad522c91 100644 --- a/re2/nfa.cc +++ b/re2/nfa.cc @@ -32,8 +32,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "re2/pod_array.h" #include "re2/prog.h" @@ -173,17 +173,17 @@ NFA::Thread* NFA::AllocThread() { } NFA::Thread* NFA::Incref(Thread* t) { - DCHECK(t != NULL); + ABSL_DCHECK(t != NULL); t->ref++; return t; } void NFA::Decref(Thread* t) { - DCHECK(t != NULL); + ABSL_DCHECK(t != NULL); t->ref--; if (t->ref > 0) return; - DCHECK_EQ(t->ref, 0); + ABSL_DCHECK_EQ(t->ref, 0); t->next = freelist_; freelist_ = t; } @@ -209,7 +209,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, absl::string_view context, stk[nstk++] = {id0, NULL}; while (nstk > 0) { - DCHECK_LE(nstk, stack_.size()); + ABSL_DCHECK_LE(nstk, stack_.size()); AddState a = stk[--nstk]; Loop: @@ -239,7 +239,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, absl::string_view context, Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled " << ip->opcode() << " in AddToThreadq"; + ABSL_LOG(DFATAL) << "unhandled " << ip->opcode() << " in AddToThreadq"; break; case kInstFail: @@ -250,7 +250,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, absl::string_view context, t = Incref(t0); *tp = t; - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); a = {id+1, NULL}; goto Loop; @@ -351,7 +351,7 @@ int NFA::Step(Threadq* runq, Threadq* nextq, int c, absl::string_view context, switch (ip->opcode()) { default: // Should only see the values handled below. - LOG(DFATAL) << "Unhandled " << ip->opcode() << " in step"; + ABSL_LOG(DFATAL) << "Unhandled " << ip->opcode() << " in step"; break; case kInstByteRange: @@ -456,7 +456,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, // Sanity check: make sure that text lies within context. if (BeginPtr(text) < BeginPtr(context) || EndPtr(text) > EndPtr(context)) { - LOG(DFATAL) << "context does not contain text"; + ABSL_LOG(DFATAL) << "context does not contain text"; return false; } @@ -471,7 +471,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, } if (nsubmatch < 0) { - LOG(DFATAL) << "Bad args: nsubmatch=" << nsubmatch; + ABSL_LOG(DFATAL) << "Bad args: nsubmatch=" << nsubmatch; return false; } @@ -528,7 +528,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, // This is a no-op the first time around the loop because runq is empty. int id = Step(runq, nextq, p < etext_ ? p[0] & 0xFF : -1, context, p); - DCHECK_EQ(runq->size(), 0); + ABSL_DCHECK_EQ(runq->size(), 0); using std::swap; swap(nextq, runq); nextq->clear(); @@ -539,7 +539,8 @@ bool NFA::Search(absl::string_view text, absl::string_view context, Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "Unexpected opcode in short circuit: " << ip->opcode(); + ABSL_LOG(DFATAL) << "Unexpected opcode in short circuit: " + << ip->opcode(); break; case kInstCapture: @@ -600,7 +601,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, // This complements the special case in NFA::Step(). if (p == NULL) { (void) Step(runq, nextq, -1, context, p); - DCHECK_EQ(runq->size(), 0); + ABSL_DCHECK_EQ(runq->size(), 0); using std::swap; swap(nextq, runq); nextq->clear(); @@ -656,7 +657,7 @@ bool Prog::SearchNFA(absl::string_view text, absl::string_view context, // fanout holds the results and is also the work queue for the outer iteration. // reachable holds the reached nodes for the inner iteration. void Prog::Fanout(SparseArray* fanout) { - DCHECK_EQ(fanout->max_size(), size()); + ABSL_DCHECK_EQ(fanout->max_size(), size()); SparseSet reachable(size()); fanout->clear(); fanout->set_new(start(), 0); @@ -669,7 +670,8 @@ void Prog::Fanout(SparseArray* fanout) { Prog::Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled " << ip->opcode() << " in Prog::Fanout()"; + ABSL_LOG(DFATAL) << "unhandled " << ip->opcode() + << " in Prog::Fanout()"; break; case kInstByteRange: @@ -683,7 +685,7 @@ void Prog::Fanout(SparseArray* fanout) { break; case kInstAltMatch: - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); reachable.insert(id+1); break; diff --git a/re2/onepass.cc b/re2/onepass.cc index 9831cc828..20edd111d 100644 --- a/re2/onepass.cc +++ b/re2/onepass.cc @@ -59,8 +59,8 @@ #include "absl/container/fixed_array.h" #include "absl/container/inlined_vector.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/utf.h" #include "re2/pod_array.h" @@ -216,7 +216,7 @@ bool Prog::SearchOnePass(absl::string_view text, absl::string_view context, Anchor anchor, MatchKind kind, absl::string_view* match, int nmatch) { if (anchor != kAnchored && kind != kFullMatch) { - LOG(DFATAL) << "Cannot use SearchOnePass for unanchored matches."; + ABSL_LOG(DFATAL) << "Cannot use SearchOnePass for unanchored matches."; return false; } @@ -443,13 +443,13 @@ bool Prog::IsOnePass() { Prog::Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: // TODO(rsc): Ignoring kInstAltMatch optimization. // Should implement it in this engine, but it's subtle. - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); // If already on work queue, (1) is violated: bail out. if (!AddQ(&workq, id+1)) goto fail; @@ -461,7 +461,7 @@ bool Prog::IsOnePass() { if (nextindex == -1) { if (nalloc >= maxnodes) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: hit node limit %d >= %d", nalloc, maxnodes); goto fail; } @@ -486,7 +486,7 @@ bool Prog::IsOnePass() { node->action[b] = newact; } else if (act != newact) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: conflict on byte %#x at state %d", c, *it); goto fail; } @@ -507,7 +507,7 @@ bool Prog::IsOnePass() { node->action[b] = newact; } else if (act != newact) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: conflict on byte %#x at state %d", c, *it); goto fail; } @@ -548,7 +548,7 @@ bool Prog::IsOnePass() { // If already on work queue, (1) is violated: bail out. if (!AddQ(&workq, ip->out())) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: multiple paths %d -> %d", *it, ip->out()); goto fail; } @@ -559,7 +559,7 @@ bool Prog::IsOnePass() { if (matched) { // (3) is violated if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: multiple matches from %d", *it); goto fail; } @@ -580,9 +580,9 @@ bool Prog::IsOnePass() { } } - if (ExtraDebug) { // For debugging, dump one-pass NFA to LOG(ERROR). - LOG(ERROR) << "bytemap:\n" << DumpByteMap(); - LOG(ERROR) << "prog:\n" << Dump(); + if (ExtraDebug) { // For debugging, dump one-pass NFA to ABSL_LOG(ERROR). + ABSL_LOG(ERROR) << "bytemap:\n" << DumpByteMap(); + ABSL_LOG(ERROR) << "prog:\n" << Dump(); std::map idmap; for (int i = 0; i < size; i++) @@ -607,7 +607,7 @@ bool Prog::IsOnePass() { idmap[node->action[i] >> kIndexShift]); } } - LOG(ERROR) << "nodes:\n" << dump; + ABSL_LOG(ERROR) << "nodes:\n" << dump; } dfa_mem_ -= nalloc*statesize; diff --git a/re2/parse.cc b/re2/parse.cc index 003b14c86..6b30bcf38 100644 --- a/re2/parse.cc +++ b/re2/parse.cc @@ -26,8 +26,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "util/utf.h" #include "re2/pod_array.h" @@ -361,7 +361,7 @@ static void AddFoldedRange(CharClassBuilder* cc, Rune lo, Rune hi, int depth) { // current Unicode tables. make_unicode_casefold.py checks that // the cycles are not too long, and we double-check here using depth. if (depth > 10) { - LOG(DFATAL) << "AddFoldedRange recurses too much."; + ABSL_LOG(DFATAL) << "AddFoldedRange recurses too much."; return; } @@ -580,7 +580,7 @@ int RepetitionWalker::PostVisit(Regexp* re, int parent_arg, int pre_arg, int RepetitionWalker::ShortVisit(Regexp* re, int parent_arg) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "RepetitionWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "RepetitionWalker::ShortVisit called"; #endif return 0; } @@ -868,7 +868,7 @@ void Regexp::RemoveLeadingString(Regexp* re, int n) { case 0: case 1: // Impossible. - LOG(DFATAL) << "Concat of " << re->nsub(); + ABSL_LOG(DFATAL) << "Concat of " << re->nsub(); re->submany_ = NULL; re->op_ = kRegexpEmptyMatch; break; @@ -998,7 +998,7 @@ int Regexp::FactorAlternation(Regexp** sub, int nsub, ParseFlags flags) { i += iter->nsub; break; default: - LOG(DFATAL) << "unknown round: " << round; + ABSL_LOG(DFATAL) << "unknown round: " << round; break; } // If we are done, copy until the end of sub. @@ -1037,7 +1037,7 @@ int Regexp::FactorAlternation(Regexp** sub, int nsub, ParseFlags flags) { continue; } default: - LOG(DFATAL) << "unknown round: " << round; + ABSL_LOG(DFATAL) << "unknown round: " << round; break; } @@ -1214,8 +1214,8 @@ void FactorAlternationImpl::Round3(Regexp** sub, int nsub, ccb.AddRangeFlags(re->rune(), re->rune(), re->parse_flags()); } } else { - LOG(DFATAL) << "RE2: unexpected op: " << re->op() << " " - << re->ToString(); + ABSL_LOG(DFATAL) << "RE2: unexpected op: " << re->op() << " " + << re->ToString(); } re->Decref(); } @@ -1476,7 +1476,7 @@ static int UnHex(int c) { return c - 'A' + 10; if ('a' <= c && c <= 'f') return c - 'a' + 10; - LOG(DFATAL) << "Bad hex digit " << c; + ABSL_LOG(DFATAL) << "Bad hex digit " << c; return 0; } @@ -2096,7 +2096,7 @@ bool Regexp::ParseState::ParsePerlFlags(absl::string_view* s) { // Caller is supposed to check this. if (!(flags_ & PerlX) || t.size() < 2 || t[0] != '(' || t[1] != '?') { status_->set_code(kRegexpInternalError); - LOG(DFATAL) << "Bad call to ParseState::ParsePerlFlags"; + ABSL_LOG(DFATAL) << "Bad call to ParseState::ParsePerlFlags"; return false; } diff --git a/re2/prefilter.cc b/re2/prefilter.cc index 53290b02f..529b58ced 100644 --- a/re2/prefilter.cc +++ b/re2/prefilter.cc @@ -10,8 +10,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/utf.h" #include "re2/re2.h" @@ -301,8 +301,8 @@ void Prefilter::CrossProduct(const SSet& a, const SSet& b, SSet* dst) { Prefilter::Info* Prefilter::Info::Concat(Info* a, Info* b) { if (a == NULL) return b; - DCHECK(a->is_exact_); - DCHECK(b && b->is_exact_); + ABSL_DCHECK(a->is_exact_); + ABSL_DCHECK(b && b->is_exact_); Info *ab = new Info(); CrossProduct(a->exact_, b->exact_, &ab->exact_); @@ -451,9 +451,9 @@ typedef CharClass::iterator CCIter; Prefilter::Info* Prefilter::Info::CClass(CharClass *cc, bool latin1) { if (ExtraDebug) { - LOG(ERROR) << "CharClassInfo:"; + ABSL_LOG(ERROR) << "CharClassInfo:"; for (CCIter i = cc->begin(); i != cc->end(); ++i) - LOG(ERROR) << " " << i->lo << "-" << i->hi; + ABSL_LOG(ERROR) << " " << i->lo << "-" << i->hi; } // If the class is too large, it's okay to overestimate. @@ -474,7 +474,7 @@ Prefilter::Info* Prefilter::Info::CClass(CharClass *cc, a->is_exact_ = true; if (ExtraDebug) - LOG(ERROR) << " = " << a->ToString(); + ABSL_LOG(ERROR) << " = " << a->ToString(); return a; } @@ -502,7 +502,7 @@ class Prefilter::Info::Walker : public Regexp::Walker { Prefilter::Info* Prefilter::BuildInfo(Regexp* re) { if (ExtraDebug) - LOG(ERROR) << "BuildPrefilter::Info: " << re->ToString(); + ABSL_LOG(ERROR) << "BuildPrefilter::Info: " << re->ToString(); bool latin1 = (re->parse_flags() & Regexp::Latin1) != 0; Prefilter::Info::Walker w(latin1); @@ -532,7 +532,7 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit( default: case kRegexpRepeat: info = EmptyString(); - LOG(DFATAL) << "Bad regexp op " << re->op(); + ABSL_LOG(DFATAL) << "Bad regexp op " << re->op(); break; case kRegexpNoMatch: @@ -635,8 +635,8 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit( } if (ExtraDebug) - LOG(ERROR) << "BuildInfo " << re->ToString() - << ": " << (info ? info->ToString() : ""); + ABSL_LOG(ERROR) << "BuildInfo " << re->ToString() + << ": " << (info ? info->ToString() : ""); return info; } @@ -663,7 +663,7 @@ Prefilter* Prefilter::FromRegexp(Regexp* re) { std::string Prefilter::DebugString() const { switch (op_) { default: - LOG(DFATAL) << "Bad op in Prefilter::DebugString: " << op_; + ABSL_LOG(DFATAL) << "Bad op in Prefilter::DebugString: " << op_; return absl::StrFormat("op%d", op_); case NONE: return "*no-matches*"; diff --git a/re2/prefilter.h b/re2/prefilter.h index cf32bd674..2645790cf 100644 --- a/re2/prefilter.h +++ b/re2/prefilter.h @@ -13,8 +13,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" namespace re2 { @@ -43,7 +43,7 @@ class Prefilter { // The children of the Prefilter node. std::vector* subs() { - DCHECK(op_ == AND || op_ == OR); + ABSL_DCHECK(op_ == AND || op_ == OR); return subs_; } diff --git a/re2/prefilter_tree.cc b/re2/prefilter_tree.cc index b7a7408f4..e59608684 100644 --- a/re2/prefilter_tree.cc +++ b/re2/prefilter_tree.cc @@ -12,8 +12,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "re2/prefilter.h" #include "re2/re2.h" @@ -39,7 +39,7 @@ PrefilterTree::~PrefilterTree() { void PrefilterTree::Add(Prefilter* prefilter) { if (compiled_) { - LOG(DFATAL) << "Add called after Compile."; + ABSL_LOG(DFATAL) << "Add called after Compile."; return; } if (prefilter != NULL && !KeepNode(prefilter)) { @@ -52,7 +52,7 @@ void PrefilterTree::Add(Prefilter* prefilter) { void PrefilterTree::Compile(std::vector* atom_vec) { if (compiled_) { - LOG(DFATAL) << "Compile called already."; + ABSL_LOG(DFATAL) << "Compile called already."; return; } @@ -84,7 +84,7 @@ bool PrefilterTree::KeepNode(Prefilter* node) const { switch (node->op()) { default: - LOG(DFATAL) << "Unexpected op in KeepNode: " << node->op(); + ABSL_LOG(DFATAL) << "Unexpected op in KeepNode: " << node->op(); return false; case Prefilter::ALL: @@ -179,7 +179,7 @@ void PrefilterTree::AssignUniqueIds(NodeSet* nodes, int id = prefilter->unique_id(); switch (prefilter->op()) { default: - LOG(DFATAL) << "Unexpected op: " << prefilter->op(); + ABSL_LOG(DFATAL) << "Unexpected op: " << prefilter->op(); return; case Prefilter::ATOM: @@ -213,7 +213,7 @@ void PrefilterTree::AssignUniqueIds(NodeSet* nodes, if (prefilter_vec_[i] == NULL) continue; int id = CanonicalNode(nodes, prefilter_vec_[i])->unique_id(); - DCHECK_LE(0, id); + ABSL_DCHECK_LE(0, id); Entry* entry = &entries_[id]; entry->regexps.push_back(static_cast(i)); } @@ -278,7 +278,7 @@ void PrefilterTree::RegexpsGivenStrings( return; } - LOG(ERROR) << "RegexpsGivenStrings called before Compile."; + ABSL_LOG(ERROR) << "RegexpsGivenStrings called before Compile."; for (size_t i = 0; i < prefilter_vec_.size(); i++) regexps->push_back(static_cast(i)); } else { @@ -332,31 +332,31 @@ void PrefilterTree::PropagateMatch(const std::vector& atom_ids, // Debugging help. void PrefilterTree::PrintPrefilter(int regexpid) { - LOG(ERROR) << DebugNodeString(prefilter_vec_[regexpid]); + ABSL_LOG(ERROR) << DebugNodeString(prefilter_vec_[regexpid]); } void PrefilterTree::PrintDebugInfo(NodeSet* nodes) { - LOG(ERROR) << "#Unique Atoms: " << atom_index_to_id_.size(); - LOG(ERROR) << "#Unique Nodes: " << entries_.size(); + ABSL_LOG(ERROR) << "#Unique Atoms: " << atom_index_to_id_.size(); + ABSL_LOG(ERROR) << "#Unique Nodes: " << entries_.size(); for (size_t i = 0; i < entries_.size(); i++) { const std::vector& parents = entries_[i].parents; const std::vector& regexps = entries_[i].regexps; - LOG(ERROR) << "EntryId: " << i - << " N: " << parents.size() << " R: " << regexps.size(); + ABSL_LOG(ERROR) << "EntryId: " << i + << " N: " << parents.size() << " R: " << regexps.size(); for (int parent : parents) - LOG(ERROR) << parent; + ABSL_LOG(ERROR) << parent; } - LOG(ERROR) << "Set:"; + ABSL_LOG(ERROR) << "Set:"; for (NodeSet::const_iterator iter = nodes->begin(); iter != nodes->end(); ++iter) - LOG(ERROR) << "NodeId: " << (*iter)->unique_id(); + ABSL_LOG(ERROR) << "NodeId: " << (*iter)->unique_id(); } std::string PrefilterTree::DebugNodeString(Prefilter* node) const { std::string node_string = ""; if (node->op() == Prefilter::ATOM) { - DCHECK(!node->atom().empty()); + ABSL_DCHECK(!node->atom().empty()); node_string += node->atom(); } else { // Adding the operation disambiguates AND and OR nodes. diff --git a/re2/prefilter_tree.h b/re2/prefilter_tree.h index ba23282d4..885170df8 100644 --- a/re2/prefilter_tree.h +++ b/re2/prefilter_tree.h @@ -20,8 +20,8 @@ #include #include "absl/container/flat_hash_set.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/prefilter.h" #include "re2/sparse_array.h" @@ -63,15 +63,15 @@ class PrefilterTree { struct PrefilterHash { size_t operator()(const Prefilter* a) const { - DCHECK(a != NULL); + ABSL_DCHECK(a != NULL); return absl::Hash()(*a); } }; struct PrefilterEqual { bool operator()(const Prefilter* a, const Prefilter* b) const { - DCHECK(a != NULL); - DCHECK(b != NULL); + ABSL_DCHECK(a != NULL); + ABSL_DCHECK(b != NULL); return *a == *b; } }; diff --git a/re2/prog.cc b/re2/prog.cc index 423e1769e..277de2602 100644 --- a/re2/prog.cc +++ b/re2/prog.cc @@ -20,8 +20,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "re2/bitmap256.h" @@ -30,13 +30,13 @@ namespace re2 { // Constructors per Inst opcode void Prog::Inst::InitAlt(uint32_t out, uint32_t out1) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstAlt); out1_ = out1; } void Prog::Inst::InitByteRange(int lo, int hi, int foldcase, uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstByteRange); lo_ = lo & 0xFF; hi_ = hi & 0xFF; @@ -44,30 +44,30 @@ void Prog::Inst::InitByteRange(int lo, int hi, int foldcase, uint32_t out) { } void Prog::Inst::InitCapture(int cap, uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstCapture); cap_ = cap; } void Prog::Inst::InitEmptyWidth(EmptyOp empty, uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstEmptyWidth); empty_ = empty; } void Prog::Inst::InitMatch(int32_t id) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_opcode(kInstMatch); match_id_ = id; } void Prog::Inst::InitNop(uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_opcode(kInstNop); } void Prog::Inst::InitFail() { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_opcode(kInstFail); } @@ -199,7 +199,7 @@ static bool IsMatch(Prog* prog, Prog::Inst* ip) { for (;;) { switch (ip->opcode()) { default: - LOG(DFATAL) << "Unexpected opcode in IsMatch: " << ip->opcode(); + ABSL_LOG(DFATAL) << "Unexpected opcode in IsMatch: " << ip->opcode(); return false; case kInstAlt: @@ -363,11 +363,11 @@ class ByteMapBuilder { }; void ByteMapBuilder::Mark(int lo, int hi) { - DCHECK_GE(lo, 0); - DCHECK_GE(hi, 0); - DCHECK_LE(lo, 255); - DCHECK_LE(hi, 255); - DCHECK_LE(lo, hi); + ABSL_DCHECK_GE(lo, 0); + ABSL_DCHECK_GE(hi, 0); + ABSL_DCHECK_LE(lo, 255); + ABSL_DCHECK_LE(hi, 255); + ABSL_DCHECK_LE(lo, hi); // Ignore any [0-255] ranges. They cause us to recolor every range, which // has no effect on the eventual result and is therefore a waste of time. @@ -512,7 +512,7 @@ void Prog::ComputeByteMap() { builder.Build(bytemap_, &bytemap_range_); if ((0)) { // For debugging, use trivial bytemap. - LOG(ERROR) << "Using trivial bytemap."; + ABSL_LOG(ERROR) << "Using trivial bytemap."; for (int i = 0; i < 256; i++) bytemap_[i] = static_cast(i); bytemap_range_ = 256; @@ -616,12 +616,12 @@ void Prog::Flatten() { size_t total = 0; for (int i = 0; i < kNumInst; i++) total += inst_count_[i]; - CHECK_EQ(total, flat.size()); + ABSL_CHECK_EQ(total, flat.size()); #endif // Remap start_unanchored and start. if (start_unanchored() == 0) { - DCHECK_EQ(start(), 0); + ABSL_DCHECK_EQ(start(), 0); } else if (start_unanchored() == start()) { set_start_unanchored(flatmap[1]); set_start(flatmap[1]); @@ -678,7 +678,7 @@ void Prog::MarkSuccessors(SparseArray* rootmap, Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: @@ -738,7 +738,7 @@ void Prog::MarkDominator(int root, SparseArray* rootmap, Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: @@ -805,7 +805,7 @@ void Prog::EmitList(int root, SparseArray* rootmap, Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: @@ -1106,7 +1106,7 @@ const void* Prog::PrefixAccel_ShiftDFA(const void* data, size_t size) { #if defined(__AVX2__) // Finds the least significant non-zero bit in n. static int FindLSBSet(uint32_t n) { - DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, 0); #if defined(__GNUC__) return __builtin_ctz(n); #elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) @@ -1128,7 +1128,7 @@ static int FindLSBSet(uint32_t n) { #endif const void* Prog::PrefixAccel_FrontAndBack(const void* data, size_t size) { - DCHECK_GE(prefix_size_, 2); + ABSL_DCHECK_GE(prefix_size_, 2); if (size < prefix_size_) return NULL; // Don't bother searching the last prefix_size_-1 bytes for prefix_front_. @@ -1165,7 +1165,7 @@ const void* Prog::PrefixAccel_FrontAndBack(const void* data, size_t size) { const char* p0 = reinterpret_cast(data); for (const char* p = p0;; p++) { - DCHECK_GE(size, static_cast(p-p0)); + ABSL_DCHECK_GE(size, static_cast(p-p0)); p = reinterpret_cast(memchr(p, prefix_front_, size - (p-p0))); if (p == NULL || p[prefix_size_-1] == prefix_back_) return p; diff --git a/re2/prog.h b/re2/prog.h index 5db21c45f..6851832cb 100644 --- a/re2/prog.h +++ b/re2/prog.h @@ -16,8 +16,8 @@ #include #include "absl/base/call_once.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/re2.h" @@ -80,20 +80,44 @@ class Prog { // Getters int id(Prog* p) { return static_cast(this - p->inst_.data()); } - InstOp opcode() { return static_cast(out_opcode_&7); } - int last() { return (out_opcode_>>3)&1; } - int out() { return out_opcode_>>4; } - int out1() { DCHECK(opcode() == kInstAlt || opcode() == kInstAltMatch); return out1_; } - int cap() { DCHECK_EQ(opcode(), kInstCapture); return cap_; } - int lo() { DCHECK_EQ(opcode(), kInstByteRange); return lo_; } - int hi() { DCHECK_EQ(opcode(), kInstByteRange); return hi_; } - int foldcase() { DCHECK_EQ(opcode(), kInstByteRange); return hint_foldcase_&1; } - int hint() { DCHECK_EQ(opcode(), kInstByteRange); return hint_foldcase_>>1; } - int match_id() { DCHECK_EQ(opcode(), kInstMatch); return match_id_; } - EmptyOp empty() { DCHECK_EQ(opcode(), kInstEmptyWidth); return empty_; } + InstOp opcode() { return static_cast(out_opcode_ & 7); } + int last() { return (out_opcode_ >> 3) & 1; } + int out() { return out_opcode_ >> 4; } + int out1() { + ABSL_DCHECK(opcode() == kInstAlt || opcode() == kInstAltMatch); + return out1_; + } + int cap() { + ABSL_DCHECK_EQ(opcode(), kInstCapture); + return cap_; + } + int lo() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return lo_; + } + int hi() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return hi_; + } + int foldcase() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return hint_foldcase_ & 1; + } + int hint() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return hint_foldcase_ >> 1; + } + int match_id() { + ABSL_DCHECK_EQ(opcode(), kInstMatch); + return match_id_; + } + EmptyOp empty() { + ABSL_DCHECK_EQ(opcode(), kInstEmptyWidth); + return empty_; + } bool greedy(Prog* p) { - DCHECK_EQ(opcode(), kInstAltMatch); + ABSL_DCHECK_EQ(opcode(), kInstAltMatch); return p->inst(out())->opcode() == kInstByteRange || (p->inst(out())->opcode() == kInstNop && p->inst(p->inst(out())->out())->opcode() == kInstByteRange); @@ -101,7 +125,7 @@ class Prog { // Does this inst (an kInstByteRange) match c? inline bool Matches(int c) { - DCHECK_EQ(opcode(), kInstByteRange); + ABSL_DCHECK_EQ(opcode(), kInstByteRange); if (foldcase() && 'A' <= c && c <= 'Z') c += 'a' - 'A'; return lo_ <= c && c <= hi_; @@ -222,7 +246,7 @@ class Prog { // Accelerates to the first likely occurrence of the prefix. // Returns a pointer to the first byte or NULL if not found. const void* PrefixAccel(const void* data, size_t size) { - DCHECK(can_prefix_accel()); + ABSL_DCHECK(can_prefix_accel()); if (prefix_foldcase_) { return PrefixAccel_ShiftDFA(data, size); } else if (prefix_size_ != 1) { diff --git a/re2/re2.cc b/re2/re2.cc index 332157ebc..74b75265b 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -26,8 +26,8 @@ #include "absl/base/macros.h" #include "absl/container/fixed_array.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/str_format.h" #include "util/strutil.h" @@ -159,7 +159,7 @@ int RE2::Options::ParseFlags() const { switch (encoding()) { default: if (log_errors()) - LOG(ERROR) << "Unknown encoding " << encoding(); + ABSL_LOG(ERROR) << "Unknown encoding " << encoding(); break; case RE2::Options::EncodingUTF8: break; @@ -230,8 +230,8 @@ void RE2::Init(absl::string_view pattern, const Options& options) { &status); if (entire_regexp_ == NULL) { if (options_.log_errors()) { - LOG(ERROR) << "Error parsing '" << trunc(*pattern_) << "': " - << status.Text(); + ABSL_LOG(ERROR) << "Error parsing '" << trunc(*pattern_) << "': " + << status.Text(); } error_ = new std::string(status.Text()); error_code_ = RegexpErrorToRE2(status.code()); @@ -255,7 +255,7 @@ void RE2::Init(absl::string_view pattern, const Options& options) { prog_ = suffix_regexp_->CompileToProg(options_.max_mem()*2/3); if (prog_ == NULL) { if (options_.log_errors()) - LOG(ERROR) << "Error compiling '" << trunc(*pattern_) << "'"; + ABSL_LOG(ERROR) << "Error compiling '" << trunc(*pattern_) << "'"; error_ = new std::string("pattern too large - compile failed"); error_code_ = RE2::ErrorPatternTooLarge; return; @@ -281,8 +281,8 @@ re2::Prog* RE2::ReverseProg() const { re->suffix_regexp_->CompileToReverseProg(re->options_.max_mem() / 3); if (re->rprog_ == NULL) { if (re->options_.log_errors()) - LOG(ERROR) << "Error reverse compiling '" << trunc(*re->pattern_) - << "'"; + ABSL_LOG(ERROR) << "Error reverse compiling '" << trunc(*re->pattern_) + << "'"; // We no longer touch error_ and error_code_ because failing to compile // the reverse Prog is not a showstopper: falling back to NFA execution // is fine. More importantly, an RE2 object is supposed to be logically @@ -328,7 +328,7 @@ int RE2::ReverseProgramSize() const { // Finds the most significant non-zero bit in n. static int FindMSBSet(uint32_t n) { - DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, 0); #if defined(__GNUC__) return 31 ^ __builtin_clz(n); #elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) @@ -454,8 +454,8 @@ bool RE2::Replace(std::string* str, if (!re.Rewrite(&s, rewrite, vec, nvec)) return false; - DCHECK_GE(vec[0].data(), str->data()); - DCHECK_LE(vec[0].data() + vec[0].size(), str->data() + str->size()); + ABSL_DCHECK_GE(vec[0].data(), str->data()); + ABSL_DCHECK_LE(vec[0].data() + vec[0].size(), str->data() + str->size()); str->replace(vec[0].data() - str->data(), vec[0].size(), s); return true; } @@ -654,16 +654,16 @@ bool RE2::Match(absl::string_view text, int nsubmatch) const { if (!ok()) { if (options_.log_errors()) - LOG(ERROR) << "Invalid RE2: " << *error_; + ABSL_LOG(ERROR) << "Invalid RE2: " << *error_; return false; } if (startpos > endpos || endpos > text.size()) { if (options_.log_errors()) - LOG(ERROR) << "RE2: invalid startpos, endpos pair. [" - << "startpos: " << startpos << ", " - << "endpos: " << endpos << ", " - << "text size: " << text.size() << "]"; + ABSL_LOG(ERROR) << "RE2: invalid startpos, endpos pair. [" + << "startpos: " << startpos << ", " + << "endpos: " << endpos << ", " + << "text size: " << text.size() << "]"; return false; } @@ -733,7 +733,7 @@ bool RE2::Match(absl::string_view text, bool skipped_test = false; switch (re_anchor) { default: - LOG(DFATAL) << "Unexpected re_anchor value: " << re_anchor; + ABSL_LOG(DFATAL) << "Unexpected re_anchor value: " << re_anchor; return false; case UNANCHORED: { @@ -751,11 +751,11 @@ bool RE2::Match(absl::string_view text, Prog::kLongestMatch, matchp, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog->size() << ", " - << "list count " << prog->list_count() << ", " - << "bytemap range " << prog->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog->size() << ", " + << "list count " << prog->list_count() << ", " + << "bytemap range " << prog->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; @@ -771,11 +771,11 @@ bool RE2::Match(absl::string_view text, matchp, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog_->size() << ", " - << "list count " << prog_->list_count() << ", " - << "bytemap range " << prog_->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog_->size() << ", " + << "list count " << prog_->list_count() << ", " + << "bytemap range " << prog_->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; @@ -797,17 +797,17 @@ bool RE2::Match(absl::string_view text, Prog::kLongestMatch, &match, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog->size() << ", " - << "list count " << prog->list_count() << ", " - << "bytemap range " << prog->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog->size() << ", " + << "list count " << prog->list_count() << ", " + << "bytemap range " << prog->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; } if (options_.log_errors()) - LOG(ERROR) << "SearchDFA inconsistency"; + ABSL_LOG(ERROR) << "SearchDFA inconsistency"; return false; } break; @@ -840,11 +840,11 @@ bool RE2::Match(absl::string_view text, &match, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog_->size() << ", " - << "list count " << prog_->list_count() << ", " - << "bytemap range " << prog_->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog_->size() << ", " + << "list count " << prog_->list_count() << ", " + << "bytemap range " << prog_->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; @@ -876,20 +876,20 @@ bool RE2::Match(absl::string_view text, if (can_one_pass && anchor != Prog::kUnanchored) { if (!prog_->SearchOnePass(subtext1, text, anchor, kind, submatch, ncap)) { if (!skipped_test && options_.log_errors()) - LOG(ERROR) << "SearchOnePass inconsistency"; + ABSL_LOG(ERROR) << "SearchOnePass inconsistency"; return false; } } else if (can_bit_state && subtext1.size() <= bit_state_text_max_size) { if (!prog_->SearchBitState(subtext1, text, anchor, kind, submatch, ncap)) { if (!skipped_test && options_.log_errors()) - LOG(ERROR) << "SearchBitState inconsistency"; + ABSL_LOG(ERROR) << "SearchBitState inconsistency"; return false; } } else { if (!prog_->SearchNFA(subtext1, text, anchor, kind, submatch, ncap)) { if (!skipped_test && options_.log_errors()) - LOG(ERROR) << "SearchNFA inconsistency"; + ABSL_LOG(ERROR) << "SearchNFA inconsistency"; return false; } } @@ -914,7 +914,7 @@ bool RE2::DoMatch(absl::string_view text, int n) const { if (!ok()) { if (options_.log_errors()) - LOG(ERROR) << "Invalid RE2: " << *error_; + ABSL_LOG(ERROR) << "Invalid RE2: " << *error_; return false; } @@ -1034,8 +1034,8 @@ bool RE2::Rewrite(std::string* out, int n = (c - '0'); if (n >= veclen) { if (options_.log_errors()) { - LOG(ERROR) << "invalid substitution \\" << n - << " from " << veclen << " groups"; + ABSL_LOG(ERROR) << "invalid substitution \\" << n + << " from " << veclen << " groups"; } return false; } @@ -1046,7 +1046,7 @@ bool RE2::Rewrite(std::string* out, out->push_back('\\'); } else { if (options_.log_errors()) - LOG(ERROR) << "invalid rewrite pattern: " << rewrite.data(); + ABSL_LOG(ERROR) << "invalid rewrite pattern: " << rewrite.data(); return false; } } diff --git a/re2/re2.h b/re2/re2.h index 13bf39fbe..0f859a179 100644 --- a/re2/re2.h +++ b/re2/re2.h @@ -50,10 +50,10 @@ // supplied pattern exactly. // // Example: successful match -// CHECK(RE2::FullMatch("hello", "h.*o")); +// ABSL_CHECK(RE2::FullMatch("hello", "h.*o")); // // Example: unsuccessful match (requires full match): -// CHECK(!RE2::FullMatch("hello", "e")); +// ABSL_CHECK(!RE2::FullMatch("hello", "e")); // // ----------------------------------------------------------------------- // UTF-8 AND THE MATCHING INTERFACE: @@ -62,8 +62,9 @@ // The RE2::Latin1 option causes them to be interpreted as Latin-1. // // Example: -// CHECK(RE2::FullMatch(utf8_string, RE2(utf8_pattern))); -// CHECK(RE2::FullMatch(latin1_string, RE2(latin1_pattern, RE2::Latin1))); +// ABSL_CHECK(RE2::FullMatch(utf8_string, RE2(utf8_pattern))); +// ABSL_CHECK(RE2::FullMatch(latin1_string, RE2(latin1_pattern, +// RE2::Latin1))); // // ----------------------------------------------------------------------- // SUBMATCH EXTRACTION: @@ -83,27 +84,27 @@ // Example: extracts "ruby" into "s" and 1234 into "i" // int i; // std::string s; -// CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); +// ABSL_CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); // // Example: extracts "ruby" into "s" and no value into "i" // absl::optional i; // std::string s; -// CHECK(RE2::FullMatch("ruby", "(\\w+)(?::(\\d+))?", &s, &i)); +// ABSL_CHECK(RE2::FullMatch("ruby", "(\\w+)(?::(\\d+))?", &s, &i)); // // Example: fails because string cannot be stored in integer -// CHECK(!RE2::FullMatch("ruby", "(.*)", &i)); +// ABSL_CHECK(!RE2::FullMatch("ruby", "(.*)", &i)); // // Example: fails because there aren't enough sub-patterns -// CHECK(!RE2::FullMatch("ruby:1234", "\\w+:\\d+", &s)); +// ABSL_CHECK(!RE2::FullMatch("ruby:1234", "\\w+:\\d+", &s)); // // Example: does not try to extract any extra sub-patterns -// CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); +// ABSL_CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); // // Example: does not try to extract into NULL -// CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); +// ABSL_CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); // // Example: integer overflow causes failure -// CHECK(!RE2::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); +// ABSL_CHECK(!RE2::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); // // NOTE(rsc): Asking for submatches slows successful matches quite a bit. // This may get a little faster in the future, but right now is slower @@ -117,12 +118,12 @@ // to match any substring of the text. // // Example: simple search for a string: -// CHECK(RE2::PartialMatch("hello", "ell")); +// ABSL_CHECK(RE2::PartialMatch("hello", "ell")); // // Example: find first number in a string // int number; -// CHECK(RE2::PartialMatch("x*100 + 20", "(\\d+)", &number)); -// CHECK_EQ(number, 100); +// ABSL_CHECK(RE2::PartialMatch("x*100 + 20", "(\\d+)", &number)); +// ABSL_CHECK_EQ(number, 100); // // ----------------------------------------------------------------------- // PRE-COMPILED REGULAR EXPRESSIONS @@ -203,7 +204,7 @@ // // Example: // int a, b, c, d; -// CHECK(RE2::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", +// ABSL_CHECK(RE2::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", // RE2::Octal(&a), RE2::Hex(&b), RE2::CRadix(&c), RE2::CRadix(&d)); // will leave 64 in a, b, c, and d. @@ -469,7 +470,7 @@ class RE2 { // text. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(RE2::Replace(&s, "b+", "d")); + // ABSL_CHECK(RE2::Replace(&s, "b+", "d")); // // will leave "s" containing "yada dabba doo" // @@ -483,7 +484,7 @@ class RE2 { // of the pattern in the string with the rewrite. E.g. // // std::string s = "yabba dabba doo"; - // CHECK(RE2::GlobalReplace(&s, "b+", "d")); + // ABSL_CHECK(RE2::GlobalReplace(&s, "b+", "d")); // // will leave "s" containing "yada dada doo" // Replacements are not subject to re-matching. diff --git a/re2/regexp.cc b/re2/regexp.cc index f374c1546..d07756164 100644 --- a/re2/regexp.cc +++ b/re2/regexp.cc @@ -18,8 +18,8 @@ #include "absl/base/call_once.h" #include "absl/base/macros.h" #include "absl/container/flat_hash_map.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" #include "util/utf.h" #include "re2/pod_array.h" @@ -46,7 +46,7 @@ Regexp::Regexp(RegexpOp op, ParseFlags parse_flags) // required Decref() to have handled them for us. Regexp::~Regexp() { if (nsub_ > 0) - LOG(DFATAL) << "Regexp not destroyed."; + ABSL_LOG(DFATAL) << "Regexp not destroyed."; switch (op_) { default: @@ -155,7 +155,7 @@ void Regexp::Destroy() { Regexp* re = stack; stack = re->down_; if (re->ref_ != 0) - LOG(DFATAL) << "Bad reference count " << re->ref_; + ABSL_LOG(DFATAL) << "Bad reference count " << re->ref_; if (re->nsub_ > 0) { Regexp** subs = re->sub(); for (int i = 0; i < re->nsub_; i++) { @@ -180,7 +180,7 @@ void Regexp::Destroy() { } void Regexp::AddRuneToString(Rune r) { - DCHECK(op_ == kRegexpLiteralString); + ABSL_DCHECK(op_ == kRegexpLiteralString); if (nrunes_ == 0) { // start with 8 runes_ = new Rune[8]; @@ -422,7 +422,7 @@ static bool TopEqual(Regexp* a, Regexp* b) { } } - LOG(DFATAL) << "Unexpected op in Regexp::Equal: " << a->op(); + ABSL_LOG(DFATAL) << "Unexpected op in Regexp::Equal: " << a->op(); return 0; } @@ -497,7 +497,7 @@ bool Regexp::Equal(Regexp* a, Regexp* b) { if (n == 0) break; - DCHECK_GE(n, 2); + ABSL_DCHECK_GE(n, 2); a = stk[n-2]; b = stk[n-1]; stk.resize(n-2); @@ -563,7 +563,7 @@ class NumCapturesWalker : public Regexp::Walker { virtual Ignored ShortVisit(Regexp* re, Ignored ignored) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "NumCapturesWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "NumCapturesWalker::ShortVisit called"; #endif return ignored; } @@ -610,7 +610,7 @@ class NamedCapturesWalker : public Regexp::Walker { virtual Ignored ShortVisit(Regexp* re, Ignored ignored) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "NamedCapturesWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "NamedCapturesWalker::ShortVisit called"; #endif return ignored; } @@ -654,7 +654,7 @@ class CaptureNamesWalker : public Regexp::Walker { virtual Ignored ShortVisit(Regexp* re, Ignored ignored) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "CaptureNamesWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "CaptureNamesWalker::ShortVisit called"; #endif return ignored; } @@ -994,7 +994,7 @@ CharClass* CharClassBuilder::GetCharClass() { for (iterator it = begin(); it != end(); ++it) cc->ranges_[n++] = *it; cc->nranges_ = n; - DCHECK_LE(n, static_cast(ranges_.size())); + ABSL_DCHECK_LE(n, static_cast(ranges_.size())); cc->nrunes_ = nrunes_; cc->folds_ascii_ = FoldsASCII(); return cc; diff --git a/re2/regexp.h b/re2/regexp.h index 9c05cc855..a782b2a6e 100644 --- a/re2/regexp.h +++ b/re2/regexp.h @@ -92,8 +92,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/string_view.h" #include "util/utf.h" @@ -333,15 +333,42 @@ class Regexp { return submany_; } - int min() { DCHECK_EQ(op_, kRegexpRepeat); return min_; } - int max() { DCHECK_EQ(op_, kRegexpRepeat); return max_; } - Rune rune() { DCHECK_EQ(op_, kRegexpLiteral); return rune_; } - CharClass* cc() { DCHECK_EQ(op_, kRegexpCharClass); return cc_; } - int cap() { DCHECK_EQ(op_, kRegexpCapture); return cap_; } - const std::string* name() { DCHECK_EQ(op_, kRegexpCapture); return name_; } - Rune* runes() { DCHECK_EQ(op_, kRegexpLiteralString); return runes_; } - int nrunes() { DCHECK_EQ(op_, kRegexpLiteralString); return nrunes_; } - int match_id() { DCHECK_EQ(op_, kRegexpHaveMatch); return match_id_; } + int min() { + ABSL_DCHECK_EQ(op_, kRegexpRepeat); + return min_; + } + int max() { + ABSL_DCHECK_EQ(op_, kRegexpRepeat); + return max_; + } + Rune rune() { + ABSL_DCHECK_EQ(op_, kRegexpLiteral); + return rune_; + } + CharClass* cc() { + ABSL_DCHECK_EQ(op_, kRegexpCharClass); + return cc_; + } + int cap() { + ABSL_DCHECK_EQ(op_, kRegexpCapture); + return cap_; + } + const std::string* name() { + ABSL_DCHECK_EQ(op_, kRegexpCapture); + return name_; + } + Rune* runes() { + ABSL_DCHECK_EQ(op_, kRegexpLiteralString); + return runes_; + } + int nrunes() { + ABSL_DCHECK_EQ(op_, kRegexpLiteralString); + return nrunes_; + } + int match_id() { + ABSL_DCHECK_EQ(op_, kRegexpHaveMatch); + return match_id_; + } // Increments reference count, returns object as convenience. Regexp* Incref(); @@ -516,7 +543,7 @@ class Regexp { // Allocate space for n sub-regexps. void AllocSub(int n) { - DCHECK(n >= 0 && static_cast(n) == n); + ABSL_DCHECK(n >= 0 && static_cast(n) == n); if (n > 1) submany_ = new Regexp*[n]; nsub_ = static_cast(n); diff --git a/re2/set.cc b/re2/set.cc index 4f269075e..b6ff03019 100644 --- a/re2/set.cc +++ b/re2/set.cc @@ -9,8 +9,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/re2.h" @@ -53,7 +53,7 @@ RE2::Set& RE2::Set::operator=(Set&& other) { int RE2::Set::Add(absl::string_view pattern, std::string* error) { if (compiled_) { - LOG(DFATAL) << "RE2::Set::Add() called after compiling"; + ABSL_LOG(DFATAL) << "RE2::Set::Add() called after compiling"; return -1; } @@ -65,7 +65,7 @@ int RE2::Set::Add(absl::string_view pattern, std::string* error) { if (error != NULL) *error = status.Text(); if (options_.log_errors()) - LOG(ERROR) << "Error parsing '" << pattern << "': " << status.Text(); + ABSL_LOG(ERROR) << "Error parsing '" << pattern << "': " << status.Text(); return -1; } @@ -92,7 +92,7 @@ int RE2::Set::Add(absl::string_view pattern, std::string* error) { bool RE2::Set::Compile() { if (compiled_) { - LOG(DFATAL) << "RE2::Set::Compile() called more than once"; + ABSL_LOG(DFATAL) << "RE2::Set::Compile() called more than once"; return false; } compiled_ = true; @@ -129,7 +129,7 @@ bool RE2::Set::Match(absl::string_view text, std::vector* v, if (!compiled_) { if (error_info != NULL) error_info->kind = kNotCompiled; - LOG(DFATAL) << "RE2::Set::Match() called before compiling"; + ABSL_LOG(DFATAL) << "RE2::Set::Match() called before compiling"; return false; } #ifdef RE2_HAVE_THREAD_LOCAL @@ -145,10 +145,10 @@ bool RE2::Set::Match(absl::string_view text, std::vector* v, NULL, &dfa_failed, matches.get()); if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "program size " << prog_->size() << ", " - << "list count " << prog_->list_count() << ", " - << "bytemap range " << prog_->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "program size " << prog_->size() << ", " + << "list count " << prog_->list_count() << ", " + << "bytemap range " << prog_->bytemap_range(); if (error_info != NULL) error_info->kind = kOutOfMemory; return false; @@ -162,7 +162,7 @@ bool RE2::Set::Match(absl::string_view text, std::vector* v, if (matches->empty()) { if (error_info != NULL) error_info->kind = kInconsistent; - LOG(DFATAL) << "RE2::Set::Match() matched, but no matches returned?!"; + ABSL_LOG(DFATAL) << "RE2::Set::Match() matched, but no matches returned"; return false; } v->assign(matches->begin(), matches->end()); diff --git a/re2/simplify.cc b/re2/simplify.cc index 06966128d..b88093605 100644 --- a/re2/simplify.cc +++ b/re2/simplify.cc @@ -9,8 +9,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "util/utf.h" #include "re2/pod_array.h" #include "re2/regexp.h" @@ -95,7 +95,7 @@ bool Regexp::ComputeSimple() { case kRegexpRepeat: return false; } - LOG(DFATAL) << "Case not handled in ComputeSimple: " << op_; + ABSL_LOG(DFATAL) << "Case not handled in ComputeSimple: " << op_; return false; } @@ -223,7 +223,7 @@ Regexp* CoalesceWalker::Copy(Regexp* re) { Regexp* CoalesceWalker::ShortVisit(Regexp* re, Regexp* parent_arg) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "CoalesceWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "CoalesceWalker::ShortVisit called"; #endif return re->Incref(); } @@ -373,7 +373,7 @@ void CoalesceWalker::DoCoalesce(Regexp** r1ptr, Regexp** r2ptr) { default: nre->Decref(); - LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op(); + ABSL_LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op(); return; } @@ -434,7 +434,7 @@ void CoalesceWalker::DoCoalesce(Regexp** r1ptr, Regexp** r2ptr) { default: nre->Decref(); - LOG(DFATAL) << "DoCoalesce failed: r2->op() is " << r2->op(); + ABSL_LOG(DFATAL) << "DoCoalesce failed: r2->op() is " << r2->op(); return; } @@ -449,7 +449,7 @@ Regexp* SimplifyWalker::Copy(Regexp* re) { Regexp* SimplifyWalker::ShortVisit(Regexp* re, Regexp* parent_arg) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "SimplifyWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "SimplifyWalker::ShortVisit called"; #endif return re->Incref(); } @@ -565,7 +565,7 @@ Regexp* SimplifyWalker::PostVisit(Regexp* re, } } - LOG(ERROR) << "Simplify case not handled: " << re->op(); + ABSL_LOG(ERROR) << "Simplify case not handled: " << re->op(); return re->Incref(); } @@ -662,7 +662,8 @@ Regexp* SimplifyWalker::SimplifyRepeat(Regexp* re, int min, int max, if (nre == NULL) { // Some degenerate case, like min > max, or min < max < 0. // This shouldn't happen, because the parser rejects such regexps. - LOG(DFATAL) << "Malformed repeat " << re->ToString() << " " << min << " " << max; + ABSL_LOG(DFATAL) << "Malformed repeat of " << re->ToString() + << " min " << min << " max " << max; return new Regexp(kRegexpNoMatch, f); } diff --git a/re2/testing/backtrack.cc b/re2/testing/backtrack.cc index 2ea98e8e6..790a50d02 100644 --- a/re2/testing/backtrack.cc +++ b/re2/testing/backtrack.cc @@ -13,7 +13,7 @@ // THIS CODE SHOULD NEVER BE USED IN PRODUCTION: // - It uses a ton of memory. // - It uses a ton of stack. -// - It uses CHECK and LOG(FATAL). +// - It uses ABSL_CHECK() and ABSL_LOG(FATAL). // - It implements unanchored search by repeated anchored search. // // On the other hand, it is very simple and a good reference @@ -28,8 +28,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" @@ -112,7 +112,7 @@ bool Backtracker::Search(absl::string_view text, absl::string_view context, endmatch_ = prog_->anchor_end(); submatch_ = submatch; nsubmatch_ = nsubmatch; - CHECK_LT(2*nsubmatch_, static_cast(ABSL_ARRAYSIZE(cap_))); + ABSL_CHECK_LT(2*nsubmatch_, static_cast(ABSL_ARRAYSIZE(cap_))); memset(cap_, 0, sizeof cap_); // We use submatch_[0] for our own bookkeeping, @@ -158,10 +158,10 @@ bool Backtracker::Visit(int id, const char* p) { // Check bitmap. If we've already explored from here, // either it didn't match or it did but we're hoping for a better match. // Either way, don't go down that road again. - CHECK(p <= text_.data() + text_.size()); + ABSL_CHECK(p <= text_.data() + text_.size()); int n = id * static_cast(text_.size()+1) + static_cast(p-text_.data()); - CHECK_LT(n/32, visited_.size()); + ABSL_CHECK_LT(n/32, visited_.size()); if (visited_[n/32] & (1 << (n&31))) return false; visited_[n/32] |= 1 << (n&31); @@ -189,7 +189,7 @@ bool Backtracker::Try(int id, const char* p) { Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(FATAL) << "Unexpected opcode: " << (int)ip->opcode(); + ABSL_LOG(FATAL) << "Unexpected opcode: " << ip->opcode(); return false; // not reached case kInstAltMatch: diff --git a/re2/testing/compile_test.cc b/re2/testing/compile_test.cc index 532f8965b..2f7a94d51 100644 --- a/re2/testing/compile_test.cc +++ b/re2/testing/compile_test.cc @@ -7,8 +7,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" #include "re2/prog.h" @@ -133,13 +133,13 @@ TEST(TestRegexpCompileToProg, Simple) { const re2::Test& t = tests[i]; Regexp* re = Regexp::Parse(t.regexp, Regexp::PerlX|Regexp::Latin1, NULL); if (re == NULL) { - LOG(ERROR) << "Cannot parse: " << t.regexp; + ABSL_LOG(ERROR) << "Cannot parse: " << t.regexp; failed++; continue; } Prog* prog = re->CompileToProg(0); if (prog == NULL) { - LOG(ERROR) << "Cannot compile: " << t.regexp; + ABSL_LOG(ERROR) << "Cannot compile: " << t.regexp; re->Decref(); failed++; continue; @@ -147,9 +147,9 @@ TEST(TestRegexpCompileToProg, Simple) { ASSERT_TRUE(re->CompileToProg(1) == NULL); std::string s = prog->Dump(); if (s != t.code) { - LOG(ERROR) << "Incorrect compiled code for: " << t.regexp; - LOG(ERROR) << "Want:\n" << t.code; - LOG(ERROR) << "Got:\n" << s; + ABSL_LOG(ERROR) << "Incorrect compiled code for: " << t.regexp; + ABSL_LOG(ERROR) << "Want:\n" << t.code; + ABSL_LOG(ERROR) << "Got:\n" << s; failed++; } delete prog; diff --git a/re2/testing/dfa_test.cc b/re2/testing/dfa_test.cc index aa9546569..1b8f0f28c 100644 --- a/re2/testing/dfa_test.cc +++ b/re2/testing/dfa_test.cc @@ -9,8 +9,8 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "util/malloc_counter.h" @@ -112,10 +112,10 @@ TEST(SingleThreaded, BuildEntireDFA) { delete prog; } if (UsingMallocCounter) { - //LOG(INFO) << "limit " << limit << ", " - // << "prog usage " << progusage << ", " - // << "DFA budget " << dfamem << ", " - // << "total " << usage; + //ABSL_LOG(INFO) << "limit " << limit << ", " + // << "prog usage " << progusage << ", " + // << "DFA budget " << dfamem << ", " + // << "total " << usage; // Tolerate +/- 10%. ASSERT_GT(usage, limit*9/10); ASSERT_LT(usage, limit*11/10); @@ -190,8 +190,8 @@ TEST(SingleThreaded, SearchDFA) { delete prog; } if (UsingMallocCounter) { - //LOG(INFO) << "usage " << usage << ", " - // << "peak usage " << peak_usage; + //ABSL_LOG(INFO) << "usage " << usage << ", " + // << "peak usage " << peak_usage; ASSERT_LT(usage, 1<SearchDFA(t.text, absl::string_view(), Prog::kUnanchored, Prog::kFirstMatch, NULL, &failed, NULL); if (matched != t.match) { - LOG(ERROR) << t.regexp << " on " << t.text << ": want " << t.match; + ABSL_LOG(ERROR) << t.regexp << " on " << t.text << ": want " << t.match; nfail++; } delete prog; @@ -361,8 +361,9 @@ TEST(DFA, Callback) { dump += match ? "]]" : "]"; }); if (dump != t.dump) { - LOG(ERROR) << t.regexp << " bytemap:\n" << prog->DumpByteMap(); - LOG(ERROR) << t.regexp << " dump:\ngot " << dump << "\nwant " << t.dump; + ABSL_LOG(ERROR) << t.regexp << " bytemap:\n" << prog->DumpByteMap(); + ABSL_LOG(ERROR) << t.regexp << " dump:\n" << "got " << dump << "\n" + << "want " << t.dump; nfail++; } delete prog; diff --git a/re2/testing/dump.cc b/re2/testing/dump.cc index 074c6a20a..9beda81d5 100644 --- a/re2/testing/dump.cc +++ b/re2/testing/dump.cc @@ -19,8 +19,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "util/utf.h" @@ -130,7 +130,7 @@ static void DumpRegexpAppending(Regexp* re, std::string* s) { break; case kRegexpCapture: if (re->cap() == 0) - LOG(DFATAL) << "kRegexpCapture cap() == 0"; + ABSL_LOG(DFATAL) << "kRegexpCapture cap() == 0"; if (re->name()) { s->append(*re->name()); s->append(":"); @@ -162,7 +162,7 @@ static void DumpRegexpAppending(Regexp* re, std::string* s) { std::string Regexp::Dump() { // Make sure that we are being called from a unit test. // Should cause a link error if used outside of testing. - CHECK(!::testing::TempDir().empty()); + ABSL_CHECK(!::testing::TempDir().empty()); std::string s; DumpRegexpAppending(this, &s); diff --git a/re2/testing/exhaustive_tester.cc b/re2/testing/exhaustive_tester.cc index 4d1ff0f02..7d63be902 100644 --- a/re2/testing/exhaustive_tester.cc +++ b/re2/testing/exhaustive_tester.cc @@ -15,8 +15,8 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "re2/testing/exhaustive_tester.h" @@ -41,7 +41,7 @@ static char* escape(absl::string_view sp) { *p++ = '\"'; for (size_t i = 0; i < sp.size(); i++) { if(p+5 >= buf+sizeof buf) - LOG(FATAL) << "ExhaustiveTester escape: too long"; + ABSL_LOG(FATAL) << "ExhaustiveTester escape: too long"; if(sp[i] == '\\' || sp[i] == '\"') { *p++ = '\\'; *p++ = sp[i]; @@ -83,7 +83,7 @@ void ExhaustiveTester::HandleRegexp(const std::string& const_regexp) { std::string regexp = const_regexp; if (!topwrapper_.empty()) { auto fmt = absl::ParsedFormat<'s'>::New(topwrapper_); - CHECK(fmt != nullptr); + ABSL_CHECK(fmt != nullptr); regexp = absl::StrFormat(*fmt, regexp); } @@ -96,7 +96,7 @@ void ExhaustiveTester::HandleRegexp(const std::string& const_regexp) { // Write out test cases and answers for use in testing // other implementations, such as Go's regexp package. if (randomstrings_) - LOG(ERROR) << "Cannot log with random strings."; + ABSL_LOG(ERROR) << "Cannot log with random strings."; if (regexps_ == 1) { // first absl::PrintF("strings\n"); strgen_.Reset(); diff --git a/re2/testing/filtered_re2_test.cc b/re2/testing/filtered_re2_test.cc index aea311b58..172389d9e 100644 --- a/re2/testing/filtered_re2_test.cc +++ b/re2/testing/filtered_re2_test.cc @@ -10,8 +10,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/filtered_re2.h" #include "re2/re2.h" @@ -173,13 +173,13 @@ bool CheckExpectedAtoms(const char* atoms[], pass = pass && expected[i] == v->atoms[i]; if (!pass) { - LOG(ERROR) << "Failed " << testname; - LOG(ERROR) << "Expected #atoms = " << expected.size(); + ABSL_LOG(ERROR) << "Failed " << testname; + ABSL_LOG(ERROR) << "Expected #atoms = " << expected.size(); for (size_t i = 0; i < expected.size(); i++) - LOG(ERROR) << expected[i]; - LOG(ERROR) << "Found #atoms = " << v->atoms.size(); + ABSL_LOG(ERROR) << expected[i]; + ABSL_LOG(ERROR) << "Found #atoms = " << v->atoms.size(); for (size_t i = 0; i < v->atoms.size(); i++) - LOG(ERROR) << v->atoms[i]; + ABSL_LOG(ERROR) << v->atoms[i]; } return pass; @@ -274,9 +274,9 @@ TEST(FilteredRE2Test, MatchTests) { atoms.push_back("yyy"); atoms.push_back("yyyzzz"); FindAtomIndices(v.atoms, atoms, &atom_ids); - LOG(INFO) << "S: " << atom_ids.size(); + ABSL_LOG(INFO) << "S: " << atom_ids.size(); for (size_t i = 0; i < atom_ids.size(); i++) - LOG(INFO) << "i: " << i << " : " << atom_ids[i]; + ABSL_LOG(INFO) << "i: " << i << " : " << atom_ids[i]; v.f.AllMatches(text, atom_ids, &matching_regexps); EXPECT_EQ(2, matching_regexps.size()); } diff --git a/re2/testing/mimics_pcre_test.cc b/re2/testing/mimics_pcre_test.cc index d12e511c7..72e7feea5 100644 --- a/re2/testing/mimics_pcre_test.cc +++ b/re2/testing/mimics_pcre_test.cc @@ -3,8 +3,8 @@ // license that can be found in the LICENSE file. #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/null_walker.cc b/re2/testing/null_walker.cc index 4e64f823c..da54c28b8 100644 --- a/re2/testing/null_walker.cc +++ b/re2/testing/null_walker.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" #include "re2/walker-inl.h" @@ -22,7 +22,7 @@ class NullWalker : public Regexp::Walker { virtual bool ShortVisit(Regexp* re, bool a) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "NullWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "NullWalker::ShortVisit called"; #endif return a; } diff --git a/re2/testing/parse_test.cc b/re2/testing/parse_test.cc index 350720081..e7838953e 100644 --- a/re2/testing/parse_test.cc +++ b/re2/testing/parse_test.cc @@ -7,8 +7,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" @@ -521,7 +521,7 @@ TEST(TestToString, EquivalentParse) { std::string ss = nre->Dump(); std::string tt = nre->ToString(); if (s != ss || t != tt) - LOG(INFO) << "ToString(" << tests[i].regexp << ") = " << t; + ABSL_LOG(INFO) << "ToString(" << tests[i].regexp << ") = " << t; EXPECT_EQ(s, ss); EXPECT_EQ(t, tt); nre->Decref(); diff --git a/re2/testing/possible_match_test.cc b/re2/testing/possible_match_test.cc index 16e169d04..e6073ef0d 100644 --- a/re2/testing/possible_match_test.cc +++ b/re2/testing/possible_match_test.cc @@ -7,8 +7,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "gtest/gtest.h" #include "re2/prog.h" @@ -114,7 +114,7 @@ TEST(PossibleMatchRange, HandWritten) { const PrefixTest& t = tests[i]; std::string min, max; if (j == 0) { - LOG(INFO) << "Checking regexp=" << absl::CEscape(t.regexp); + ABSL_LOG(INFO) << "Checking regexp=" << absl::CEscape(t.regexp); Regexp* re = Regexp::Parse(t.regexp, Regexp::LikePerl, NULL); ASSERT_TRUE(re != NULL); Prog* prog = re->CompileToProg(0); @@ -203,7 +203,7 @@ class PossibleMatchTester : public RegexpGenerator { void PossibleMatchTester::HandleRegexp(const std::string& regexp) { regexps_++; - VLOG(3) << absl::CEscape(regexp); + ABSL_VLOG(3) << absl::CEscape(regexp); RE2 re(regexp, RE2::Latin1); ASSERT_EQ(re.error(), ""); @@ -215,7 +215,8 @@ void PossibleMatchTester::HandleRegexp(const std::string& regexp) { // complicated expressions. if(strstr(regexp.c_str(), "\\C*")) return; - LOG(QFATAL) << "PossibleMatchRange failed on: " << absl::CEscape(regexp); + ABSL_LOG(QFATAL) << "PossibleMatchRange failed on: " + << absl::CEscape(regexp); } strgen_.Reset(); @@ -242,8 +243,8 @@ TEST(PossibleMatchRange, Exhaustive) { RegexpGenerator::EgrepOps(), stringlen, Explode("ab4")); t.Generate(); - LOG(INFO) << t.regexps() << " regexps, " - << t.tests() << " tests"; + ABSL_LOG(INFO) << t.regexps() << " regexps, " + << t.tests() << " tests"; } } // namespace re2 diff --git a/re2/testing/re2_arg_test.cc b/re2/testing/re2_arg_test.cc index a9b044d73..db1868aeb 100644 --- a/re2/testing/re2_arg_test.cc +++ b/re2/testing/re2_arg_test.cc @@ -11,8 +11,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/re2.h" @@ -138,7 +138,7 @@ TEST(RE2ArgTest, Uint64Test) { TEST(RE2ArgTest, ParseFromTest) { struct { bool ParseFrom(const char* str, size_t n) { - LOG(INFO) << "str = " << str << ", n = " << n; + ABSL_LOG(INFO) << "str = " << str << ", n = " << n; return true; } } obj1; @@ -147,7 +147,7 @@ TEST(RE2ArgTest, ParseFromTest) { struct { bool ParseFrom(const char* str, size_t n) { - LOG(INFO) << "str = " << str << ", n = " << n; + ABSL_LOG(INFO) << "str = " << str << ", n = " << n; return false; } // Ensure that RE2::Arg works even with overloaded ParseFrom(). diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index 95bf461fb..0a602070f 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -19,8 +19,8 @@ #endif #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "re2/re2.h" @@ -774,7 +774,7 @@ TEST(RE2, NULTerminated) { v = static_cast(mmap(NULL, 2*pagesize, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)); ASSERT_TRUE(v != reinterpret_cast(-1)); - LOG(INFO) << "Memory at " << (void*)v; + ABSL_LOG(INFO) << "Memory at " << reinterpret_cast(v); ASSERT_EQ(munmap(v + pagesize, pagesize), 0) << " error " << errno; v[pagesize - 1] = '1'; @@ -1563,7 +1563,7 @@ TEST(RE2, Bug18391750) { TEST(RE2, Bug18458852) { // Bug in parser accepting invalid (too large) rune, - // causing compiler to fail in DCHECK in UTF-8 + // causing compiler to fail in ABSL_DCHECK() in UTF-8 // character class code. const char b[] = { (char)0x28, (char)0x05, (char)0x05, (char)0x41, (char)0x41, (char)0x28, @@ -1599,7 +1599,7 @@ TEST(RE2, Bug18523943) { TEST(RE2, Bug21371806) { // Bug in parser accepting Unicode groups in Latin-1 mode, - // causing compiler to fail in DCHECK in prog.cc. + // causing compiler to fail in ABSL_DCHECK() in prog.cc. RE2::Options opt; opt.set_encoding(RE2::Options::EncodingLatin1); diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc index 319289558..33211fe0d 100644 --- a/re2/testing/regexp_benchmark.cc +++ b/re2/testing/regexp_benchmark.cc @@ -13,8 +13,8 @@ #include "absl/container/flat_hash_map.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "benchmark/benchmark.h" @@ -35,21 +35,22 @@ namespace re2 { void Test() { Regexp* re = Regexp::Parse("(\\d+)-(\\d+)-(\\d+)", Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->CanBitState()); const char* text = "650-253-0001"; absl::string_view sp[4]; - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); - CHECK_EQ(sp[0], "650-253-0001"); - CHECK_EQ(sp[1], "650"); - CHECK_EQ(sp[2], "253"); - CHECK_EQ(sp[3], "0001"); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, + sp, 4)); + ABSL_CHECK_EQ(sp[0], "650-253-0001"); + ABSL_CHECK_EQ(sp[1], "650"); + ABSL_CHECK_EQ(sp[2], "253"); + ABSL_CHECK_EQ(sp[3], "0001"); delete prog; re->Decref(); - LOG(INFO) << "test passed\n"; + ABSL_LOG(INFO) << "test passed\n"; } void MemoryUsage() { @@ -58,23 +59,25 @@ void MemoryUsage() { { MallocCounter mc(MallocCounter::THIS_THREAD_ONLY); Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); - // Can't pass mc.HeapGrowth() and mc.PeakHeapGrowth() to LOG(INFO) directly, - // because LOG(INFO) might do a big allocation before they get evaluated. + ABSL_CHECK(re); + // Can't pass mc.HeapGrowth() and mc.PeakHeapGrowth() to ABSL_LOG(INFO) + // directly because ABSL_LOG(INFO) might do a big allocation before they + // get evaluated. absl::FPrintF(stderr, "Regexp: %7d bytes (peak=%d)\n", mc.HeapGrowth(), mc.PeakHeapGrowth()); mc.Reset(); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->CanBitState()); absl::FPrintF(stderr, "Prog: %7d bytes (peak=%d)\n", mc.HeapGrowth(), mc.PeakHeapGrowth()); mc.Reset(); absl::string_view sp[4]; - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); absl::FPrintF(stderr, "Search: %7d bytes (peak=%d)\n", mc.HeapGrowth(), mc.PeakHeapGrowth()); delete prog; @@ -169,7 +172,7 @@ std::string RandomText(int64_t nbytes) { } return text; }(); - CHECK_LE(nbytes, 16<<20); + ABSL_CHECK_LE(nbytes, 16<<20); return text->substr(0, nbytes); } @@ -320,8 +323,8 @@ void FindAndConsume(benchmark::State& state) { for (auto _ : state) { absl::string_view t = s; absl::string_view u; - CHECK(RE2::FindAndConsume(&t, re, &u)); - CHECK_EQ(u, "Hello World"); + ABSL_CHECK(RE2::FindAndConsume(&t, re, &u)); + ABSL_CHECK_EQ(u, "Hello World"); } state.SetBytesProcessed(state.iterations() * state.range(0)); } @@ -661,7 +664,7 @@ BENCHMARK(Parse_CachedSplitBig2_RE2)->ThreadRange(1, NumCPUs()); void ParseRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); re->Decref(); } } @@ -669,9 +672,9 @@ void ParseRegexp(benchmark::State& state, const std::string& regexp) { void SimplifyRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Regexp* sre = re->Simplify(); - CHECK(sre); + ABSL_CHECK(sre); sre->Decref(); re->Decref(); } @@ -679,7 +682,7 @@ void SimplifyRegexp(benchmark::State& state, const std::string& regexp) { void NullWalkRegexp(benchmark::State& state, const std::string& regexp) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); for (auto _ : state) { re->NullWalk(); } @@ -689,11 +692,11 @@ void NullWalkRegexp(benchmark::State& state, const std::string& regexp) { void SimplifyCompileRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Regexp* sre = re->Simplify(); - CHECK(sre); + ABSL_CHECK(sre); Prog* prog = sre->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); delete prog; sre->Decref(); re->Decref(); @@ -703,9 +706,9 @@ void SimplifyCompileRegexp(benchmark::State& state, const std::string& regexp) { void CompileRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); delete prog; re->Decref(); } @@ -713,10 +716,10 @@ void CompileRegexp(benchmark::State& state, const std::string& regexp) { void CompileToProg(benchmark::State& state, const std::string& regexp) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); for (auto _ : state) { Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); delete prog; } re->Decref(); @@ -724,9 +727,9 @@ void CompileToProg(benchmark::State& state, const std::string& regexp) { void CompileByteMap(benchmark::State& state, const std::string& regexp) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); for (auto _ : state) { prog->ComputeByteMap(); } @@ -737,14 +740,14 @@ void CompileByteMap(benchmark::State& state, const std::string& regexp) { void CompilePCRE(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); } } void CompileRE2(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); } } @@ -863,14 +866,14 @@ void SearchDFA(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); bool failed = false; - CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, - Prog::kFirstMatch, NULL, &failed, NULL), - expect_match); - CHECK(!failed); + ABSL_CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, + Prog::kFirstMatch, NULL, &failed, NULL), + expect_match); + ABSL_CHECK(!failed); delete prog; re->Decref(); } @@ -881,12 +884,12 @@ void SearchNFA(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, - Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK(prog); + ABSL_CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, + Prog::kFirstMatch, NULL, 0), + expect_match); delete prog; re->Decref(); } @@ -897,12 +900,13 @@ void SearchOnePass(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); - CHECK_EQ(prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); + ABSL_CHECK_EQ( + prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); delete prog; re->Decref(); } @@ -913,12 +917,13 @@ void SearchBitState(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->CanBitState()); - CHECK_EQ(prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK(prog); + ABSL_CHECK(prog->CanBitState()); + ABSL_CHECK_EQ( + prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); delete prog; re->Decref(); } @@ -929,11 +934,12 @@ void SearchPCRE(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); - if (anchor == Prog::kAnchored) - CHECK_EQ(PCRE::FullMatch(text, re), expect_match); - else - CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + ABSL_CHECK_EQ(re.error(), ""); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(PCRE::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + } } } @@ -942,11 +948,12 @@ void SearchRE2(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); - if (anchor == Prog::kAnchored) - CHECK_EQ(RE2::FullMatch(text, re), expect_match); - else - CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + ABSL_CHECK_EQ(re.error(), ""); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(RE2::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + } } } @@ -961,9 +968,9 @@ Prog* GetCachedProg(const char* regexp) { Prog* prog = cache[regexp]; if (prog == NULL) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); prog = re->CompileToProg(int64_t{1}<<31); // mostly for the DFA - CHECK(prog); + ABSL_CHECK(prog); cache[regexp] = prog; re->Decref(); // We must call this here - while we have exclusive access. @@ -979,7 +986,7 @@ PCRE* GetCachedPCRE(const char* regexp) { PCRE* re = cache[regexp]; if (re == NULL) { re = new PCRE(regexp, PCRE::UTF8); - CHECK_EQ(re->error(), ""); + ABSL_CHECK_EQ(re->error(), ""); cache[regexp] = re; } return re; @@ -992,7 +999,7 @@ RE2* GetCachedRE2(const char* regexp) { RE2* re = cache[regexp]; if (re == NULL) { re = new RE2(regexp); - CHECK_EQ(re->error(), ""); + ABSL_CHECK_EQ(re->error(), ""); cache[regexp] = re; } return re; @@ -1004,10 +1011,10 @@ void SearchCachedDFA(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); for (auto _ : state) { bool failed = false; - CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, + ABSL_CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, Prog::kFirstMatch, NULL, &failed, NULL), expect_match); - CHECK(!failed); + ABSL_CHECK(!failed); } } @@ -1016,7 +1023,7 @@ void SearchCachedNFA(benchmark::State& state, const char* regexp, bool expect_match) { Prog* prog = GetCachedProg(regexp); for (auto _ : state) { - CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, + ABSL_CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, Prog::kFirstMatch, NULL, 0), expect_match); } @@ -1026,10 +1033,11 @@ void SearchCachedOnePass(benchmark::State& state, const char* regexp, absl::string_view text, Prog::Anchor anchor, bool expect_match) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->IsOnePass()); for (auto _ : state) { - CHECK_EQ(prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK_EQ( + prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); } } @@ -1037,10 +1045,11 @@ void SearchCachedBitState(benchmark::State& state, const char* regexp, absl::string_view text, Prog::Anchor anchor, bool expect_match) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog->CanBitState()); for (auto _ : state) { - CHECK_EQ(prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK_EQ( + prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); } } @@ -1049,10 +1058,11 @@ void SearchCachedPCRE(benchmark::State& state, const char* regexp, bool expect_match) { PCRE& re = *GetCachedPCRE(regexp); for (auto _ : state) { - if (anchor == Prog::kAnchored) - CHECK_EQ(PCRE::FullMatch(text, re), expect_match); - else - CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(PCRE::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + } } } @@ -1061,10 +1071,11 @@ void SearchCachedRE2(benchmark::State& state, const char* regexp, bool expect_match) { RE2& re = *GetCachedRE2(regexp); for (auto _ : state) { - if (anchor == Prog::kAnchored) - CHECK_EQ(RE2::FullMatch(text, re), expect_match); - else - CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(RE2::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + } } } @@ -1075,11 +1086,11 @@ void Parse3NFA(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); @@ -1090,12 +1101,13 @@ void Parse3OnePass(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); } @@ -1105,12 +1117,13 @@ void Parse3BitState(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); } @@ -1120,11 +1133,12 @@ void Parse3Backtrack(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); } @@ -1134,9 +1148,9 @@ void Parse3PCRE(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1, sp2, sp3; - CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1144,9 +1158,9 @@ void Parse3RE2(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1, sp2, sp3; - CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1155,7 +1169,7 @@ void Parse3CachedNFA(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, Prog::kFullMatch, sp, 4)); } } @@ -1163,20 +1177,22 @@ void Parse3CachedNFA(benchmark::State& state, const char* regexp, void Parse3CachedOnePass(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); } } void Parse3CachedBitState(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); } } @@ -1185,7 +1201,8 @@ void Parse3CachedBacktrack(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); } } @@ -1194,7 +1211,7 @@ void Parse3CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); absl::string_view sp1, sp2, sp3; for (auto _ : state) { - CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1203,7 +1220,7 @@ void Parse3CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); absl::string_view sp1, sp2, sp3; for (auto _ : state) { - CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1214,12 +1231,12 @@ void Parse1NFA(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); absl::string_view sp[2]; // 2 because sp[0] is whole match. - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, - Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + Prog::kFullMatch, sp, 2)); delete prog; re->Decref(); } @@ -1229,12 +1246,13 @@ void Parse1OnePass(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[2]; // 2 because sp[0] is whole match. - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); delete prog; re->Decref(); } @@ -1244,12 +1262,13 @@ void Parse1BitState(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[2]; // 2 because sp[0] is whole match. - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); delete prog; re->Decref(); } @@ -1259,9 +1278,9 @@ void Parse1PCRE(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1; - CHECK(PCRE::FullMatch(text, re, &sp1)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1)); } } @@ -1269,9 +1288,9 @@ void Parse1RE2(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1; - CHECK(RE2::FullMatch(text, re, &sp1)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1)); } } @@ -1280,7 +1299,7 @@ void Parse1CachedNFA(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, Prog::kFullMatch, sp, 2)); } } @@ -1288,20 +1307,22 @@ void Parse1CachedNFA(benchmark::State& state, const char* regexp, void Parse1CachedOnePass(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); } } void Parse1CachedBitState(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); } } @@ -1310,7 +1331,8 @@ void Parse1CachedBacktrack(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); } } @@ -1319,7 +1341,7 @@ void Parse1CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); absl::string_view sp1; for (auto _ : state) { - CHECK(PCRE::FullMatch(text, re, &sp1)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1)); } } @@ -1328,7 +1350,7 @@ void Parse1CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); absl::string_view sp1; for (auto _ : state) { - CHECK(RE2::FullMatch(text, re, &sp1)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1)); } } @@ -1337,7 +1359,7 @@ void SearchParse2CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); for (auto _ : state) { absl::string_view sp1, sp2; - CHECK(PCRE::PartialMatch(text, re, &sp1, &sp2)); + ABSL_CHECK(PCRE::PartialMatch(text, re, &sp1, &sp2)); } } @@ -1346,7 +1368,7 @@ void SearchParse2CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); for (auto _ : state) { absl::string_view sp1, sp2; - CHECK(RE2::PartialMatch(text, re, &sp1, &sp2)); + ABSL_CHECK(RE2::PartialMatch(text, re, &sp1, &sp2)); } } @@ -1355,7 +1377,7 @@ void SearchParse1CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); for (auto _ : state) { absl::string_view sp1; - CHECK(PCRE::PartialMatch(text, re, &sp1)); + ABSL_CHECK(PCRE::PartialMatch(text, re, &sp1)); } } @@ -1364,7 +1386,7 @@ void SearchParse1CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); for (auto _ : state) { absl::string_view sp1; - CHECK(RE2::PartialMatch(text, re, &sp1)); + ABSL_CHECK(RE2::PartialMatch(text, re, &sp1)); } } @@ -1500,7 +1522,7 @@ void FullMatchPCRE(benchmark::State& state, const char *regexp) { s += "ABCDEFGHIJ"; PCRE re(regexp); for (auto _ : state) { - CHECK(PCRE::FullMatch(s, re)); + ABSL_CHECK(PCRE::FullMatch(s, re)); } state.SetBytesProcessed(state.iterations() * state.range(0)); } @@ -1510,19 +1532,31 @@ void FullMatchRE2(benchmark::State& state, const char *regexp) { s += "ABCDEFGHIJ"; RE2 re(regexp, RE2::Latin1); for (auto _ : state) { - CHECK(RE2::FullMatch(s, re)); + ABSL_CHECK(RE2::FullMatch(s, re)); } state.SetBytesProcessed(state.iterations() * state.range(0)); } -void FullMatch_DotStar_CachedPCRE(benchmark::State& state) { FullMatchPCRE(state, "(?s).*"); } -void FullMatch_DotStar_CachedRE2(benchmark::State& state) { FullMatchRE2(state, "(?s).*"); } +void FullMatch_DotStar_CachedPCRE(benchmark::State& state) { + FullMatchPCRE(state, "(?s).*"); +} +void FullMatch_DotStar_CachedRE2(benchmark::State& state) { + FullMatchRE2(state, "(?s).*"); +} -void FullMatch_DotStarDollar_CachedPCRE(benchmark::State& state) { FullMatchPCRE(state, "(?s).*$"); } -void FullMatch_DotStarDollar_CachedRE2(benchmark::State& state) { FullMatchRE2(state, "(?s).*$"); } +void FullMatch_DotStarDollar_CachedPCRE(benchmark::State& state) { + FullMatchPCRE(state, "(?s).*$"); +} +void FullMatch_DotStarDollar_CachedRE2(benchmark::State& state) { + FullMatchRE2(state, "(?s).*$"); +} -void FullMatch_DotStarCapture_CachedPCRE(benchmark::State& state) { FullMatchPCRE(state, "(?s)((.*)()()($))"); } -void FullMatch_DotStarCapture_CachedRE2(benchmark::State& state) { FullMatchRE2(state, "(?s)((.*)()()($))"); } +void FullMatch_DotStarCapture_CachedPCRE(benchmark::State& state) { + FullMatchPCRE(state, "(?s)((.*)()()($))"); +} +void FullMatch_DotStarCapture_CachedRE2(benchmark::State& state) { + FullMatchRE2(state, "(?s)((.*)()()($))"); +} #ifdef USEPCRE BENCHMARK_RANGE(FullMatch_DotStar_CachedPCRE, 8, 2<<20); @@ -1545,7 +1579,7 @@ void PossibleMatchRangeCommon(benchmark::State& state, const char* regexp) { std::string max; const int kMaxLen = 16; for (auto _ : state) { - CHECK(re.PossibleMatchRange(&min, &max, kMaxLen)); + ABSL_CHECK(re.PossibleMatchRange(&min, &max, kMaxLen)); } } diff --git a/re2/testing/regexp_generator.cc b/re2/testing/regexp_generator.cc index 4d9346fb6..baf73d2d3 100644 --- a/re2/testing/regexp_generator.cc +++ b/re2/testing/regexp_generator.cc @@ -30,8 +30,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" @@ -197,13 +197,13 @@ void RegexpGenerator::RunPostfix(const std::vector& post) { for (size_t i = 0; i < post.size(); i++) { switch (CountArgs(post[i])) { default: - LOG(FATAL) << "Bad operator: " << post[i]; + ABSL_LOG(FATAL) << "Bad operator: " << post[i]; case 0: regexps.push(post[i]); break; case 1: { auto fmt = absl::ParsedFormat<'s'>::New(post[i]); - CHECK(fmt != nullptr); + ABSL_CHECK(fmt != nullptr); std::string a = regexps.top(); regexps.pop(); regexps.push("(?:" + absl::StrFormat(*fmt, a) + ")"); @@ -211,7 +211,7 @@ void RegexpGenerator::RunPostfix(const std::vector& post) { } case 2: { auto fmt = absl::ParsedFormat<'s', 's'>::New(post[i]); - CHECK(fmt != nullptr); + ABSL_CHECK(fmt != nullptr); std::string b = regexps.top(); regexps.pop(); std::string a = regexps.top(); @@ -233,7 +233,7 @@ void RegexpGenerator::RunPostfix(const std::vector& post) { absl::PrintF(" %s\n", absl::CEscape(regexps.top())); regexps.pop(); } - LOG(FATAL) << "Bad regexp program."; + ABSL_LOG(FATAL) << "Bad regexp program."; } HandleRegexp(regexps.top()); diff --git a/re2/testing/regexp_test.cc b/re2/testing/regexp_test.cc index 54aa8ada9..1403a7477 100644 --- a/re2/testing/regexp_test.cc +++ b/re2/testing/regexp_test.cc @@ -9,8 +9,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" diff --git a/re2/testing/required_prefix_test.cc b/re2/testing/required_prefix_test.cc index 83e2c3e8e..bf46f7aa1 100644 --- a/re2/testing/required_prefix_test.cc +++ b/re2/testing/required_prefix_test.cc @@ -5,8 +5,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/set_test.cc b/re2/testing/set_test.cc index abd0fa48b..f8d301887 100644 --- a/re2/testing/set_test.cc +++ b/re2/testing/set_test.cc @@ -7,8 +7,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/re2.h" #include "re2/set.h" diff --git a/re2/testing/simplify_test.cc b/re2/testing/simplify_test.cc index 4a182d1a0..9c4e38c14 100644 --- a/re2/testing/simplify_test.cc +++ b/re2/testing/simplify_test.cc @@ -8,8 +8,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" @@ -265,7 +265,7 @@ static Test tests[] = { TEST(TestSimplify, SimpleRegexps) { for (size_t i = 0; i < ABSL_ARRAYSIZE(tests); i++) { RegexpStatus status; - VLOG(1) << "Testing " << tests[i].regexp; + ABSL_VLOG(1) << "Testing " << tests[i].regexp; Regexp* re = Regexp::Parse(tests[i].regexp, Regexp::MatchNL | (Regexp::LikePerl & ~Regexp::OneLine), diff --git a/re2/testing/string_generator.cc b/re2/testing/string_generator.cc index 90ec46f1d..24397df1b 100644 --- a/re2/testing/string_generator.cc +++ b/re2/testing/string_generator.cc @@ -11,8 +11,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/testing/string_generator.h" @@ -83,7 +83,7 @@ bool StringGenerator::RandomDigits() { // after computing the string, so that it knows the answer // for subsequent HasNext() calls. absl::string_view StringGenerator::Next() { - CHECK(hasnext_); + ABSL_CHECK(hasnext_); if (generate_null_) { generate_null_ = false; sp_ = absl::string_view(); @@ -113,8 +113,8 @@ void StringGenerator::GenerateNULL() { } std::string DeBruijnString(int n) { - CHECK_GE(n, 1); - CHECK_LE(n, 29); + ABSL_CHECK_GE(n, 1); + ABSL_CHECK_LE(n, 29); const size_t size = size_t{1} << static_cast(n); const size_t mask = size - 1; std::vector did(size, false); @@ -132,10 +132,10 @@ std::string DeBruijnString(int n) { } else { s += '0'; } - CHECK(!did[bits]); + ABSL_CHECK(!did[bits]); did[bits] = true; } - CHECK_EQ(s.size(), static_cast(n - 1) + size); + ABSL_CHECK_EQ(s.size(), static_cast(n - 1) + size); return s; } diff --git a/re2/testing/tester.cc b/re2/testing/tester.cc index e0161be09..fc68a8a5a 100644 --- a/re2/testing/tester.cc +++ b/re2/testing/tester.cc @@ -11,8 +11,8 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" #include "re2/testing/tester.h" @@ -51,9 +51,9 @@ const char* engine_names[kEngineMax] = { // Returns the name of the engine. static const char* EngineName(Engine e) { - CHECK_GE(e, 0); - CHECK_LT(e, ABSL_ARRAYSIZE(engine_names)); - CHECK(engine_names[e] != NULL); + ABSL_CHECK_GE(e, 0); + ABSL_CHECK_LT(e, ABSL_ARRAYSIZE(engine_names)); + ABSL_CHECK(engine_names[e] != NULL); return engine_names[e]; } @@ -74,12 +74,12 @@ static uint32_t Engines() { } if (cached_engines == 0) - LOG(INFO) << "Warning: no engines enabled."; + ABSL_LOG(INFO) << "Warning: no engines enabled."; if (!UsingPCRE) cached_engines &= ~(1<(0); i < kEngineMax; i++) { if (cached_engines & (1<NumCaptures(); prog_ = regexp_->CompileToProg(0); if (prog_ == NULL) { - LOG(INFO) << "Cannot compile: " << absl::CEscape(regexp_str_); + ABSL_LOG(INFO) << "Cannot compile: " << absl::CEscape(regexp_str_); error_ = true; return; } if (absl::GetFlag(FLAGS_dump_prog)) { - LOG(INFO) << "Prog for " - << " regexp " - << absl::CEscape(regexp_str_) - << " (" << FormatKind(kind_) - << ", " << FormatMode(flags_) - << ")\n" - << prog_->Dump(); + ABSL_LOG(INFO) << "Prog for " + << " regexp " + << absl::CEscape(regexp_str_) + << " (" << FormatKind(kind_) + << ", " << FormatMode(flags_) + << ")\n" + << prog_->Dump(); } // Compile regexp to reversed prog. Only needed for DFA engines. if (Engines() & ((1<CompileToReverseProg(0); if (rprog_ == NULL) { - LOG(INFO) << "Cannot reverse compile: " << absl::CEscape(regexp_str_); + ABSL_LOG(INFO) << "Cannot reverse compile: " + << absl::CEscape(regexp_str_); error_ = true; return; } if (absl::GetFlag(FLAGS_dump_rprog)) - LOG(INFO) << rprog_->Dump(); + ABSL_LOG(INFO) << rprog_->Dump(); } // Create re string that will be used for RE and RE2. @@ -258,7 +259,7 @@ TestInstance::TestInstance(absl::string_view regexp_str, Prog::MatchKind kind, options.set_longest_match(true); re2_ = new RE2(re, options); if (!re2_->error().empty()) { - LOG(INFO) << "Cannot RE2: " << absl::CEscape(re); + ABSL_LOG(INFO) << "Cannot RE2: " << absl::CEscape(re); error_ = true; return; } @@ -284,7 +285,7 @@ TestInstance::TestInstance(absl::string_view regexp_str, Prog::MatchKind kind, // add one more layer of parens. re_ = new PCRE("("+re+")", o); if (!re_->error().empty()) { - LOG(INFO) << "Cannot PCRE: " << absl::CEscape(re); + ABSL_LOG(INFO) << "Cannot PCRE: " << absl::CEscape(re); error_ = true; return; } @@ -319,7 +320,7 @@ void TestInstance::RunSearch(Engine type, absl::string_view orig_text, switch (type) { default: - LOG(FATAL) << "Bad RunSearch type: " << (int)type; + ABSL_LOG(FATAL) << "Bad RunSearch type: " << (int)type; case kEngineBacktrack: if (prog_ == NULL) { @@ -367,9 +368,9 @@ void TestInstance::RunSearch(Engine type, absl::string_view orig_text, Prog::kAnchored, Prog::kLongestMatch, result->submatch, &result->skipped, NULL)) { - LOG(ERROR) << "Reverse DFA inconsistency: " - << absl::CEscape(regexp_str_) - << " on " << absl::CEscape(text); + ABSL_LOG(ERROR) << "Reverse DFA inconsistency: " + << absl::CEscape(regexp_str_) + << " on " << absl::CEscape(text); result->matched = false; } } @@ -521,16 +522,16 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, if (correct.skipped) { if (regexp_ == NULL) return true; - LOG(ERROR) << "Skipped backtracking! " << absl::CEscape(regexp_str_) - << " " << FormatMode(flags_); + ABSL_LOG(ERROR) << "Skipped backtracking! " << absl::CEscape(regexp_str_) + << " " << FormatMode(flags_); return false; } - VLOG(1) << "Try: regexp " << absl::CEscape(regexp_str_) - << " text " << absl::CEscape(text) - << " (" << FormatKind(kind_) - << ", " << FormatAnchor(anchor) - << ", " << FormatMode(flags_) - << ")"; + ABSL_VLOG(1) << "Try: regexp " << absl::CEscape(regexp_str_) + << " text " << absl::CEscape(text) + << " (" << FormatKind(kind_) + << ", " << FormatAnchor(anchor) + << ", " << FormatMode(flags_) + << ")"; // Compare the others. bool all_okay = true; @@ -561,22 +562,22 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, context, anchor); if (r.matched != correct.matched) { if (r.matched) { - LOG(INFO) << " Should not match (but does)."; + ABSL_LOG(INFO) << " Should not match (but does)."; } else { - LOG(INFO) << " Should match (but does not)."; + ABSL_LOG(INFO) << " Should match (but does not)."; continue; } } for (int i = 0; i < 1+num_captures_; i++) { if (r.submatch[i].data() != correct.submatch[i].data() || r.submatch[i].size() != correct.submatch[i].size()) { - LOG(INFO) << + ABSL_LOG(INFO) << absl::StrFormat(" $%d: should be %s is %s", i, FormatCapture(text, correct.submatch[i]), FormatCapture(text, r.submatch[i])); } else { - LOG(INFO) << + ABSL_LOG(INFO) << absl::StrFormat(" $%d: %s ok", i, FormatCapture(text, r.submatch[i])); } @@ -588,7 +589,7 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, // and that is desirable because we want to enforce a global limit. static int max_regexp_failures = absl::GetFlag(FLAGS_max_regexp_failures); if (max_regexp_failures > 0 && --max_regexp_failures == 0) - LOG(QFATAL) << "Too many regexp failures."; + ABSL_LOG(QFATAL) << "Too many regexp failures."; } return all_okay; @@ -597,7 +598,7 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, void TestInstance::LogMatch(const char* prefix, Engine e, absl::string_view text, absl::string_view context, Prog::Anchor anchor) { - LOG(INFO) << prefix + ABSL_LOG(INFO) << prefix << EngineName(e) << " regexp " << absl::CEscape(regexp_str_) diff --git a/re2/tostring.cc b/re2/tostring.cc index e1e870ba7..c1ec69926 100644 --- a/re2/tostring.cc +++ b/re2/tostring.cc @@ -8,8 +8,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/utf.h" #include "re2/regexp.h" @@ -102,7 +102,7 @@ int ToStringWalker::PreVisit(Regexp* re, int parent_arg, bool* stop) { case kRegexpCapture: t_->append("("); if (re->cap() == 0) - LOG(DFATAL) << "kRegexpCapture cap() == 0"; + ABSL_LOG(DFATAL) << "kRegexpCapture cap() == 0"; if (re->name()) { t_->append("?P<"); t_->append(*re->name()); @@ -185,7 +185,7 @@ int ToStringWalker::PostVisit(Regexp* re, int parent_arg, int pre_arg, if ((*t_)[t_->size()-1] == '|') t_->erase(t_->size()-1); else - LOG(DFATAL) << "Bad final char: " << t_; + ABSL_LOG(DFATAL) << "Bad final char: " << t_; if (prec < PrecAlternate) t_->append(")"); break; diff --git a/re2/walker-inl.h b/re2/walker-inl.h index fe0dc8c7b..2283d6daf 100644 --- a/re2/walker-inl.h +++ b/re2/walker-inl.h @@ -16,8 +16,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/regexp.h" namespace re2 { @@ -148,7 +148,7 @@ template Regexp::Walker::~Walker() { // Logs DFATAL if stack is not already clear. template void Regexp::Walker::Reset() { if (!stack_.empty()) { - LOG(DFATAL) << "Stack not empty."; + ABSL_LOG(DFATAL) << "Stack not empty."; while (!stack_.empty()) { if (stack_.top().re->nsub_ > 1) delete[] stack_.top().child_args; @@ -162,7 +162,7 @@ template T Regexp::Walker::WalkInternal(Regexp* re, T top_arg, Reset(); if (re == NULL) { - LOG(DFATAL) << "Walk NULL"; + ABSL_LOG(DFATAL) << "Walk NULL"; return top_arg; } diff --git a/util/pcre.cc b/util/pcre.cc index 71e5329a4..94a88b7c9 100644 --- a/util/pcre.cc +++ b/util/pcre.cc @@ -16,8 +16,8 @@ #include #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/pcre.h" @@ -26,7 +26,7 @@ #pragma GCC diagnostic ignored "-Wmisleading-indentation" #endif -#define PCREPORT(level) LOG(level) +#define PCREPORT(level) ABSL_LOG(level) // Default PCRE limits. // Defaults chosen to allow a plausible amount of CPU and diff --git a/util/pcre.h b/util/pcre.h index 846f30019..c0e944e02 100644 --- a/util/pcre.h +++ b/util/pcre.h @@ -39,10 +39,10 @@ // supplied pattern exactly. // // Example: successful match -// CHECK(PCRE::FullMatch("hello", "h.*o")); +// ABSL_CHECK(PCRE::FullMatch("hello", "h.*o")); // // Example: unsuccessful match (requires full match): -// CHECK(!PCRE::FullMatch("hello", "e")); +// ABSL_CHECK(!PCRE::FullMatch("hello", "e")); // // ----------------------------------------------------------------------- // UTF-8 AND THE MATCHING INTERFACE: @@ -58,7 +58,7 @@ // // Example: // PCRE re(utf8_pattern, PCRE::UTF8); -// CHECK(PCRE::FullMatch(utf8_string, re)); +// ABSL_CHECK(PCRE::FullMatch(utf8_string, re)); // // ----------------------------------------------------------------------- // MATCHING WITH SUBSTRING EXTRACTION: @@ -68,22 +68,22 @@ // Example: extracts "ruby" into "s" and 1234 into "i" // int i; // std::string s; -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); // // Example: fails because string cannot be stored in integer -// CHECK(!PCRE::FullMatch("ruby", "(.*)", &i)); +// ABSL_CHECK(!PCRE::FullMatch("ruby", "(.*)", &i)); // // Example: fails because there aren't enough sub-patterns: -// CHECK(!PCRE::FullMatch("ruby:1234", "\\w+:\\d+", &s)); +// ABSL_CHECK(!PCRE::FullMatch("ruby:1234", "\\w+:\\d+", &s)); // // Example: does not try to extract any extra sub-patterns -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); // // Example: does not try to extract into NULL -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); // // Example: integer overflow causes failure -// CHECK(!PCRE::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); +// ABSL_CHECK(!PCRE::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); // // ----------------------------------------------------------------------- // PARTIAL MATCHES @@ -92,12 +92,12 @@ // to match any substring of the text. // // Example: simple search for a string: -// CHECK(PCRE::PartialMatch("hello", "ell")); +// ABSL_CHECK(PCRE::PartialMatch("hello", "ell")); // // Example: find first number in a string // int number; -// CHECK(PCRE::PartialMatch("x*100 + 20", "(\\d+)", &number)); -// CHECK_EQ(number, 100); +// ABSL_CHECK(PCRE::PartialMatch("x*100 + 20", "(\\d+)", &number)); +// ABSL_CHECK_EQ(number, 100); // // ----------------------------------------------------------------------- // PPCRE-COMPILED PCREGULAR EXPPCRESSIONS @@ -157,7 +157,7 @@ // // Example: // int a, b, c, d; -// CHECK(PCRE::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", +// ABSL_CHECK(PCRE::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", // Octal(&a), Hex(&b), CRadix(&c), CRadix(&d)); // will leave 64 in a, b, c, and d. @@ -379,7 +379,7 @@ class PCRE { // text. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(PCRE::Replace(&s, "b+", "d")); + // ABSL_CHECK(PCRE::Replace(&s, "b+", "d")); // // will leave "s" containing "yada dabba doo" // @@ -393,7 +393,7 @@ class PCRE { // re-matching. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(PCRE::GlobalReplace(&s, "b+", "d")); + // ABSL_CHECK(PCRE::GlobalReplace(&s, "b+", "d")); // // will leave "s" containing "yada dada doo" // @@ -417,7 +417,7 @@ class PCRE { // * The @p rewrite string doesn't have any syntax errors // ('\' followed by anything besides [0-9] and '\'). // Making this test will guarantee that "replace" and "extract" - // operations won't LOG(ERROR) or fail because of a bad rewrite + // operations won't ABSL_LOG(ERROR) or fail because of a bad rewrite // string. // @param rewrite The proposed rewrite string. // @param error An error message is recorded here, iff we return false. From a771d3fbe7c432dc4db68360c6c0004fdde5646b Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 20 May 2024 13:47:14 +0000 Subject: [PATCH 40/56] Work around a bug in CMake that breaks `^` anchors. https://gitlab.kitware.com/cmake/cmake/-/issues/16899 was reported seven years ago. The bug existed at least ten years ago. It hasn't been fixed. Change-Id: Ifbe3e77ce6371091b24303d5c4953d401ed29826 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63071 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f8a1c77c..b838a3a0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,7 +152,9 @@ if(UNIX) endif() foreach(dep ${ABSL_DEPS}) - string(REGEX REPLACE "^absl_" "absl::" dep ${dep}) + # Work around https://gitlab.kitware.com/cmake/cmake/-/issues/16899. >:( + string(PREPEND dep "^") + string(REGEX REPLACE "\\^absl_" "absl::" dep ${dep}) target_link_libraries(re2 PUBLIC ${dep}) endforeach() From 9d2c82552a6ef68675883561d375dce06b16c123 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 28 May 2024 14:19:18 +0000 Subject: [PATCH 41/56] Bump some versions in `MODULE.bazel`. Change-Id: I32465e8e875a35a6e8b8fb29ad952b4a1b7293c2 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63110 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 4 ++-- .github/workflows/ci-cmake.yml | 6 +++--- .github/workflows/ci.yml | 6 +++--- .github/workflows/pages.yml | 6 +++--- .github/workflows/pr.yml | 2 +- .github/workflows/python.yml | 14 +++++++------- .github/workflows/release.yml | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index e49cd2ac7..b0279bb29 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -14,8 +14,8 @@ jobs: env: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4.1.4 - - uses: bazel-contrib/setup-bazel@0.8.2 + - uses: actions/checkout@v4.1.6 + - uses: bazel-contrib/setup-bazel@0.8.4 with: bazelisk-version: '1.x' - run: .github/bazel.sh diff --git a/.github/workflows/ci-cmake.yml b/.github/workflows/ci-cmake.yml index c4f21ac40..113c1eafd 100644 --- a/.github/workflows/ci-cmake.yml +++ b/.github/workflows/ci-cmake.yml @@ -12,7 +12,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update @@ -29,7 +29,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -44,7 +44,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b367ca242..9b5cb2ca6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: # (The other two flags are the default provided for CXXFLAGS in Makefile.) CXXFLAGS: -O3 -g -std=c++${{ matrix.ver }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -40,7 +40,7 @@ jobs: CXX: clang++-${{ matrix.ver }} PKG_CONFIG_PATH: /usr/local/share/vcpkg/installed/x64-linux/lib/pkgconfig steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - name: Install Clang ${{ matrix.ver }} run: | # Avoid `Conflicts: python3-lldb-x.y` between packages. @@ -68,7 +68,7 @@ jobs: CXX: g++-${{ matrix.ver }} PKG_CONFIG_PATH: /usr/local/share/vcpkg/installed/x64-linux/lib/pkgconfig steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index af2c45ddb..297e897af 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -17,8 +17,8 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4.1.4 - - uses: bazel-contrib/setup-bazel@0.8.2 + - uses: actions/checkout@v4.1.6 + - uses: bazel-contrib/setup-bazel@0.8.4 with: bazelisk-version: '1.x' - run: app/build.sh @@ -37,5 +37,5 @@ jobs: environment: github-pages runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - uses: actions/deploy-pages@v4.0.5 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b8f94cdcb..af29512cd 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,7 +15,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - uses: actions/github-script@v7.0.1 with: script: | diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7607a2551..0ae6ef394 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,11 +31,11 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.2 + - uses: bazel-contrib/setup-bazel@0.8.4 with: bazelisk-version: '1.x' - name: Prepare Python ${{ matrix.ver }} environment @@ -87,11 +87,11 @@ jobs: # Otherwise, Python refuses to install the built wheel! SYSTEM_VERSION_COMPAT: 0 steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.2 + - uses: bazel-contrib/setup-bazel@0.8.4 with: bazelisk-version: '1.x' - uses: actions/setup-python@v5.1.0 @@ -138,11 +138,11 @@ jobs: BAZEL_CPU: ${{ matrix.arch.bazel-name }}_windows PLAT_NAME: ${{ matrix.arch.python-name }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.2 + - uses: bazel-contrib/setup-bazel@0.8.4 with: bazelisk-version: '1.x' # Lowercase the architecture name for `actions/setup-python`. @@ -190,7 +190,7 @@ jobs: id-token: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59bd537be..25721ae05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - run: | gh release create "${GITHUB_REF_NAME}" \ --generate-notes --latest --verify-tag \ From 71f37d08479154e53b52863d78ec880588f1d748 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 28 May 2024 15:42:14 +0000 Subject: [PATCH 42/56] Clean and format `#include` directives. Change-Id: Iba5a0f3a18245a22f68ba1c3d533200cc577a596 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63130 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- BUILD.bazel | 7 +++++++ CMakeLists.txt | 1 + Makefile | 1 + python/_re2.cc | 10 ++++++++-- re2/bitmap256.cc | 3 +-- re2/bitmap256.h | 7 ++++--- re2/bitstate.cc | 2 ++ re2/compile.cc | 6 ++++-- re2/dfa.cc | 9 ++++++--- re2/filtered_re2.cc | 4 +++- re2/fuzzing/re2_fuzzer.cc | 2 ++ re2/mimics_pcre.cc | 1 - re2/nfa.cc | 3 ++- re2/onepass.cc | 5 +++-- re2/parse.cc | 8 ++++---- re2/prefilter.cc | 5 +++-- re2/prefilter_tree.cc | 3 +-- re2/prog.cc | 23 +++++++++++++++-------- re2/prog.h | 3 ++- re2/re2.cc | 18 +++++++++++------- re2/re2.h | 9 +++++---- re2/regexp.cc | 3 ++- re2/regexp.h | 1 + re2/set.cc | 6 +++++- re2/simplify.cc | 6 ++++-- re2/sparse_array.h | 16 +++++++++------- re2/sparse_set.h | 16 +++++++++------- re2/testing/backtrack.cc | 1 + re2/testing/charclass_test.cc | 2 +- re2/testing/compile_test.cc | 6 ++++-- re2/testing/dfa_test.cc | 7 ++++--- re2/testing/dump.cc | 2 +- re2/testing/exhaustive1_test.cc | 1 + re2/testing/exhaustive2_test.cc | 4 ++-- re2/testing/exhaustive3_test.cc | 6 +++--- re2/testing/exhaustive_test.cc | 1 - re2/testing/exhaustive_tester.cc | 10 +++++++++- re2/testing/exhaustive_tester.h | 1 + re2/testing/filtered_re2_test.cc | 8 ++++---- re2/testing/mimics_pcre_test.cc | 4 ++-- re2/testing/null_walker.cc | 2 -- re2/testing/parse_test.cc | 3 ++- re2/testing/possible_match_test.cc | 3 ++- re2/testing/random_test.cc | 2 +- re2/testing/re2_arg_test.cc | 2 +- re2/testing/re2_test.cc | 15 +++++++++------ re2/testing/regexp_benchmark.cc | 5 +++-- re2/testing/regexp_generator.cc | 7 +++++-- re2/testing/regexp_generator.h | 1 + re2/testing/regexp_test.cc | 6 +++--- re2/testing/required_prefix_test.cc | 4 ++-- re2/testing/search_test.cc | 9 ++++++--- re2/testing/set_test.cc | 9 ++++----- re2/testing/simplify_test.cc | 2 -- re2/testing/string_generator.cc | 8 +++++--- re2/testing/string_generator.h | 1 + re2/testing/string_generator_test.cc | 8 ++++++-- re2/testing/tester.cc | 6 +++++- re2/testing/tester.h | 2 +- re2/tostring.cc | 4 ++-- 60 files changed, 207 insertions(+), 123 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index f1ceaedf1..c765cfd51 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -83,6 +83,7 @@ cc_library( "@abseil-cpp//absl/container:flat_hash_map", "@abseil-cpp//absl/container:flat_hash_set", "@abseil-cpp//absl/container:inlined_vector", + "@abseil-cpp//absl/hash", "@abseil-cpp//absl/log:absl_check", "@abseil-cpp//absl/log:absl_log", "@abseil-cpp//absl/strings", @@ -165,6 +166,7 @@ cc_test( "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/log:absl_check", "@abseil-cpp//absl/log:absl_log", + "@abseil-cpp//absl/strings", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -239,6 +241,7 @@ cc_test( "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/log:absl_check", "@abseil-cpp//absl/log:absl_log", + "@abseil-cpp//absl/types:optional", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -254,6 +257,7 @@ cc_test( "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/log:absl_check", "@abseil-cpp//absl/log:absl_log", + "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", @@ -333,6 +337,7 @@ cc_test( srcs = ["re2/testing/string_generator_test.cc"], deps = [ ":testing", + "@abseil-cpp//absl/strings", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -349,6 +354,7 @@ cc_test( "@abseil-cpp//absl/flags:flag", "@abseil-cpp//absl/log:absl_check", "@abseil-cpp//absl/log:absl_log", + "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest", "@googletest//:gtest_main", @@ -423,6 +429,7 @@ cc_binary( "@abseil-cpp//absl/flags:flag", "@abseil-cpp//absl/log:absl_check", "@abseil-cpp//absl/log:absl_log", + "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@abseil-cpp//absl/synchronization", "@google_benchmark//:benchmark_main", diff --git a/CMakeLists.txt b/CMakeLists.txt index b838a3a0a..a2ade77a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ set(ABSL_DEPS absl_flags absl_flat_hash_map absl_flat_hash_set + absl_hash absl_inlined_vector absl_optional absl_span diff --git a/Makefile b/Makefile index 887d82d29..e01529b2e 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ ABSL_DEPS=\ absl_flags\ absl_flat_hash_map\ absl_flat_hash_set\ + absl_hash\ absl_inlined_vector\ absl_optional\ absl_span\ diff --git a/python/_re2.cc b/python/_re2.cc index 07e33cec2..385492d88 100644 --- a/python/_re2.cc +++ b/python/_re2.cc @@ -2,15 +2,21 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include +#include + #include +#include #include #include #include #include -#include -#include #include "absl/strings/string_view.h" +#include "pybind11/buffer_info.h" +#include "pybind11/gil.h" +#include "pybind11/pybind11.h" +#include "pybind11/pytypes.h" #include "re2/filtered_re2.h" #include "re2/re2.h" #include "re2/set.h" diff --git a/re2/bitmap256.cc b/re2/bitmap256.cc index fe2ba7e4a..4b9eee430 100644 --- a/re2/bitmap256.cc +++ b/re2/bitmap256.cc @@ -6,9 +6,8 @@ #include -#include "absl/base/macros.h" +#include "absl/base/attributes.h" #include "absl/log/absl_check.h" -#include "absl/log/absl_log.h" namespace re2 { diff --git a/re2/bitmap256.h b/re2/bitmap256.h index 45913a615..e16a570a5 100644 --- a/re2/bitmap256.h +++ b/re2/bitmap256.h @@ -5,15 +5,16 @@ #ifndef RE2_BITMAP256_H_ #define RE2_BITMAP256_H_ -#ifdef _MSC_VER -#include -#endif #include #include #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#ifdef _MSC_VER +#include +#endif + namespace re2 { class Bitmap256 { diff --git a/re2/bitstate.cc b/re2/bitstate.cc index e69c1067e..71f41c383 100644 --- a/re2/bitstate.cc +++ b/re2/bitstate.cc @@ -20,11 +20,13 @@ #include #include #include + #include #include #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/compile.cc b/re2/compile.cc index ce3c32e23..95c1b32dd 100644 --- a/re2/compile.cc +++ b/re2/compile.cc @@ -10,18 +10,20 @@ #include #include + +#include #include -#include "absl/base/macros.h" #include "absl/container/flat_hash_map.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" -#include "util/utf.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/re2.h" #include "re2/regexp.h" #include "re2/walker-inl.h" +#include "util/utf.h" namespace re2 { diff --git a/re2/dfa.cc b/re2/dfa.cc index 808f87242..1619614ea 100644 --- a/re2/dfa.cc +++ b/re2/dfa.cc @@ -25,29 +25,32 @@ #include #include #include + #include #include #include -#include +#include #include #include #include +#include "absl/base/attributes.h" #include "absl/base/call_once.h" -#include "absl/base/macros.h" #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" +#include "absl/hash/hash.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "absl/types/span.h" -#include "util/strutil.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/re2.h" #include "re2/sparse_set.h" +#include "util/strutil.h" // Silence "zero-sized array in struct/union" warning for DFA::State::next_. #ifdef _MSC_VER diff --git a/re2/filtered_re2.cc b/re2/filtered_re2.cc index 78e4a5675..f0995a10b 100644 --- a/re2/filtered_re2.cc +++ b/re2/filtered_re2.cc @@ -5,11 +5,13 @@ #include "re2/filtered_re2.h" #include + #include #include +#include -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#include "absl/strings/string_view.h" #include "re2/prefilter.h" #include "re2/prefilter_tree.h" diff --git a/re2/fuzzing/re2_fuzzer.cc b/re2/fuzzing/re2_fuzzer.cc index 9a7af08a7..8a8c2acc8 100644 --- a/re2/fuzzing/re2_fuzzer.cc +++ b/re2/fuzzing/re2_fuzzer.cc @@ -5,10 +5,12 @@ #include #include #include + #include #include #include +#include "absl/strings/string_view.h" #include "re2/filtered_re2.h" #include "re2/re2.h" #include "re2/regexp.h" diff --git a/re2/mimics_pcre.cc b/re2/mimics_pcre.cc index 43860a6a1..172406366 100644 --- a/re2/mimics_pcre.cc +++ b/re2/mimics_pcre.cc @@ -22,7 +22,6 @@ // // Regexp::MimicsPCRE checks for any of these conditions. -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "re2/regexp.h" #include "re2/walker-inl.h" diff --git a/re2/nfa.cc b/re2/nfa.cc index 9ad522c91..a35976f25 100644 --- a/re2/nfa.cc +++ b/re2/nfa.cc @@ -26,15 +26,16 @@ #include #include + #include #include #include #include -#include #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/onepass.cc b/re2/onepass.cc index 20edd111d..fb7f69431 100644 --- a/re2/onepass.cc +++ b/re2/onepass.cc @@ -52,20 +52,21 @@ #include #include + #include #include #include -#include #include "absl/container/fixed_array.h" #include "absl/container/inlined_vector.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" -#include "util/utf.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/sparse_set.h" +#include "util/utf.h" // Silence "zero-sized array in struct/union" warning for OneState::action. #ifdef _MSC_VER diff --git a/re2/parse.cc b/re2/parse.cc index 6b30bcf38..6f7a5612f 100644 --- a/re2/parse.cc +++ b/re2/parse.cc @@ -16,25 +16,25 @@ // and recognizes the Perl escape sequences \d, \s, \w, \D, \S, and \W. // See regexp.h for rationale. -#include #include #include #include + #include -#include #include #include +#include "absl/base/attributes.h" #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/ascii.h" -#include "util/utf.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/regexp.h" #include "re2/unicode_casefold.h" #include "re2/unicode_groups.h" #include "re2/walker-inl.h" +#include "util/utf.h" #if defined(RE2_USE_ICU) #include "unicode/uniset.h" diff --git a/re2/prefilter.cc b/re2/prefilter.cc index 529b58ced..decc412ba 100644 --- a/re2/prefilter.cc +++ b/re2/prefilter.cc @@ -5,7 +5,7 @@ #include "re2/prefilter.h" #include -#include + #include #include #include @@ -13,10 +13,11 @@ #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" -#include "util/utf.h" #include "re2/re2.h" +#include "re2/regexp.h" #include "re2/unicode_casefold.h" #include "re2/walker-inl.h" +#include "util/utf.h" namespace re2 { diff --git a/re2/prefilter_tree.cc b/re2/prefilter_tree.cc index e59608684..0a7bea984 100644 --- a/re2/prefilter_tree.cc +++ b/re2/prefilter_tree.cc @@ -5,9 +5,9 @@ #include "re2/prefilter_tree.h" #include + #include #include -#include #include #include #include @@ -16,7 +16,6 @@ #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "re2/prefilter.h" -#include "re2/re2.h" namespace re2 { diff --git a/re2/prog.cc b/re2/prog.cc index 277de2602..d3ff26eff 100644 --- a/re2/prog.cc +++ b/re2/prog.cc @@ -7,23 +7,30 @@ #include "re2/prog.h" -#if defined(__AVX2__) -#include -#ifdef _MSC_VER -#include -#endif -#endif #include #include + #include -#include +#include #include +#include -#include "absl/base/macros.h" +#include "absl/base/attributes.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "re2/bitmap256.h" +#include "re2/pod_array.h" +#include "re2/sparse_array.h" +#include "re2/sparse_set.h" + +#if defined(__AVX2__) +#include +#ifdef _MSC_VER +#include +#endif +#endif namespace re2 { diff --git a/re2/prog.h b/re2/prog.h index 6851832cb..d0889bdca 100644 --- a/re2/prog.h +++ b/re2/prog.h @@ -10,10 +10,11 @@ // expression symbolically. #include + #include #include -#include #include +#include #include "absl/base/call_once.h" #include "absl/log/absl_check.h" diff --git a/re2/re2.cc b/re2/re2.cc index 74b75265b..2e25b64f3 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -9,32 +9,36 @@ #include "re2/re2.h" -#include #include -#ifdef _MSC_VER -#include -#endif +#include #include #include #include + #include #include -#include +#include #include #include #include +#include "absl/base/call_once.h" #include "absl/base/macros.h" #include "absl/container/fixed_array.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/str_format.h" -#include "util/strutil.h" -#include "util/utf.h" +#include "absl/strings/string_view.h" #include "re2/prog.h" #include "re2/regexp.h" #include "re2/sparse_array.h" +#include "util/strutil.h" +#include "util/utf.h" + +#ifdef _MSC_VER +#include +#endif namespace re2 { diff --git a/re2/re2.h b/re2/re2.h index 0f859a179..d797bc040 100644 --- a/re2/re2.h +++ b/re2/re2.h @@ -210,21 +210,22 @@ #include #include + #include #include #include #include #include -#if defined(__APPLE__) -#include -#endif - #include "absl/base/call_once.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "re2/stringpiece.h" +#if defined(__APPLE__) +#include +#endif + namespace re2 { class Prog; class Regexp; diff --git a/re2/regexp.cc b/re2/regexp.cc index d07756164..1e5ae9071 100644 --- a/re2/regexp.cc +++ b/re2/regexp.cc @@ -10,6 +10,7 @@ #include #include #include + #include #include #include @@ -21,9 +22,9 @@ #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" -#include "util/utf.h" #include "re2/pod_array.h" #include "re2/walker-inl.h" +#include "util/utf.h" namespace re2 { diff --git a/re2/regexp.h b/re2/regexp.h index a782b2a6e..531b42044 100644 --- a/re2/regexp.h +++ b/re2/regexp.h @@ -88,6 +88,7 @@ #include #include + #include #include #include diff --git a/re2/set.cc b/re2/set.cc index b6ff03019..caebd24e4 100644 --- a/re2/set.cc +++ b/re2/set.cc @@ -5,16 +5,20 @@ #include "re2/set.h" #include + #include #include +#include #include +#include -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/re2.h" #include "re2/regexp.h" +#include "re2/sparse_set.h" namespace re2 { diff --git a/re2/simplify.cc b/re2/simplify.cc index b88093605..d0524aff5 100644 --- a/re2/simplify.cc +++ b/re2/simplify.cc @@ -6,15 +6,17 @@ // to use simple extended regular expression features. // Also sort and simplify character classes. +#include + #include #include -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" -#include "util/utf.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/regexp.h" #include "re2/walker-inl.h" +#include "util/utf.h" namespace re2 { diff --git a/re2/sparse_array.h b/re2/sparse_array.h index 09ffe086b..8174d9a0a 100644 --- a/re2/sparse_array.h +++ b/re2/sparse_array.h @@ -88,21 +88,23 @@ // // A moved-from SparseArray will be empty. +#include +#include + +#include +#include +#include + +#include "re2/pod_array.h" + // Doing this simplifies the logic below. #ifndef __has_feature #define __has_feature(x) 0 #endif -#include -#include #if __has_feature(memory_sanitizer) #include #endif -#include -#include -#include - -#include "re2/pod_array.h" namespace re2 { diff --git a/re2/sparse_set.h b/re2/sparse_set.h index 06ed88d81..c08e93d29 100644 --- a/re2/sparse_set.h +++ b/re2/sparse_set.h @@ -47,21 +47,23 @@ // // See sparse_array.h for implementation details. +#include +#include + +#include +#include +#include + +#include "re2/pod_array.h" + // Doing this simplifies the logic below. #ifndef __has_feature #define __has_feature(x) 0 #endif -#include -#include #if __has_feature(memory_sanitizer) #include #endif -#include -#include -#include - -#include "re2/pod_array.h" namespace re2 { diff --git a/re2/testing/backtrack.cc b/re2/testing/backtrack.cc index 790a50d02..7504e1a46 100644 --- a/re2/testing/backtrack.cc +++ b/re2/testing/backtrack.cc @@ -30,6 +30,7 @@ #include "absl/base/macros.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/charclass_test.cc b/re2/testing/charclass_test.cc index ad95d6c26..efe38aec1 100644 --- a/re2/testing/charclass_test.cc +++ b/re2/testing/charclass_test.cc @@ -9,8 +9,8 @@ #include "absl/base/macros.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" -#include "util/utf.h" #include "re2/regexp.h" +#include "util/utf.h" namespace re2 { diff --git a/re2/testing/compile_test.cc b/re2/testing/compile_test.cc index 2f7a94d51..7ac01f9b1 100644 --- a/re2/testing/compile_test.cc +++ b/re2/testing/compile_test.cc @@ -4,14 +4,16 @@ // Test prog.cc, compile.cc +#include + #include #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#include "absl/strings/string_view.h" #include "gtest/gtest.h" -#include "re2/regexp.h" #include "re2/prog.h" +#include "re2/regexp.h" namespace re2 { diff --git a/re2/testing/dfa_test.cc b/re2/testing/dfa_test.cc index 1b8f0f28c..a8178c889 100644 --- a/re2/testing/dfa_test.cc +++ b/re2/testing/dfa_test.cc @@ -2,23 +2,24 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include #include + #include #include #include #include "absl/base/macros.h" #include "absl/flags/flag.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "gtest/gtest.h" -#include "util/malloc_counter.h" #include "re2/prog.h" #include "re2/re2.h" #include "re2/regexp.h" -#include "re2/testing/regexp_generator.h" #include "re2/testing/string_generator.h" +#include "util/malloc_counter.h" static const bool UsingMallocCounter = false; diff --git a/re2/testing/dump.cc b/re2/testing/dump.cc index 9beda81d5..382ac208a 100644 --- a/re2/testing/dump.cc +++ b/re2/testing/dump.cc @@ -23,8 +23,8 @@ #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" -#include "util/utf.h" #include "re2/regexp.h" +#include "util/utf.h" namespace re2 { diff --git a/re2/testing/exhaustive1_test.cc b/re2/testing/exhaustive1_test.cc index 933798995..0056cf232 100644 --- a/re2/testing/exhaustive1_test.cc +++ b/re2/testing/exhaustive1_test.cc @@ -9,6 +9,7 @@ #include "gtest/gtest.h" #include "re2/testing/exhaustive_tester.h" +#include "re2/testing/regexp_generator.h" namespace re2 { diff --git a/re2/testing/exhaustive2_test.cc b/re2/testing/exhaustive2_test.cc index 14f629d4a..31079fb38 100644 --- a/re2/testing/exhaustive2_test.cc +++ b/re2/testing/exhaustive2_test.cc @@ -5,12 +5,13 @@ // Exhaustive testing of regular expression matching. #include -#include + #include #include #include "gtest/gtest.h" #include "re2/testing/exhaustive_tester.h" +#include "re2/testing/regexp_generator.h" namespace re2 { @@ -69,4 +70,3 @@ TEST(LineEnds, Exhaustive) { // } } // namespace re2 - diff --git a/re2/testing/exhaustive3_test.cc b/re2/testing/exhaustive3_test.cc index de703c00e..afc387f9a 100644 --- a/re2/testing/exhaustive3_test.cc +++ b/re2/testing/exhaustive3_test.cc @@ -5,13 +5,14 @@ // Exhaustive testing of regular expression matching. #include -#include + #include #include #include "gtest/gtest.h" -#include "util/utf.h" #include "re2/testing/exhaustive_tester.h" +#include "re2/testing/regexp_generator.h" +#include "util/utf.h" namespace re2 { @@ -97,4 +98,3 @@ TEST(InterestingUTF8, AB) { } } // namespace re2 - diff --git a/re2/testing/exhaustive_test.cc b/re2/testing/exhaustive_test.cc index 5e586f1fe..1bae2f3c7 100644 --- a/re2/testing/exhaustive_test.cc +++ b/re2/testing/exhaustive_test.cc @@ -33,4 +33,3 @@ TEST(EgrepLiterals, UTF8) { } } // namespace re2 - diff --git a/re2/testing/exhaustive_tester.cc b/re2/testing/exhaustive_tester.cc index 7d63be902..d8fa1ffa8 100644 --- a/re2/testing/exhaustive_tester.cc +++ b/re2/testing/exhaustive_tester.cc @@ -11,15 +11,23 @@ // the NFA, DFA, and a trivial backtracking implementation agree about // the location of the match. +#include "re2/testing/exhaustive_tester.h" + #include +#include +#include + #include "absl/base/macros.h" #include "absl/flags/flag.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "gtest/gtest.h" -#include "re2/testing/exhaustive_tester.h" +#include "re2/prog.h" +#include "re2/re2.h" +#include "re2/testing/regexp_generator.h" #include "re2/testing/tester.h" // For target `log' in the Makefile. diff --git a/re2/testing/exhaustive_tester.h b/re2/testing/exhaustive_tester.h index 906be0c8c..8b0421d71 100644 --- a/re2/testing/exhaustive_tester.h +++ b/re2/testing/exhaustive_tester.h @@ -6,6 +6,7 @@ #define RE2_TESTING_EXHAUSTIVE_TESTER_H_ #include + #include #include diff --git a/re2/testing/filtered_re2_test.cc b/re2/testing/filtered_re2_test.cc index 172389d9e..b951d7c7f 100644 --- a/re2/testing/filtered_re2_test.cc +++ b/re2/testing/filtered_re2_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include "re2/filtered_re2.h" + #include + #include -#include #include -#include #include +#include #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "gtest/gtest.h" -#include "re2/filtered_re2.h" #include "re2/re2.h" namespace re2 { diff --git a/re2/testing/mimics_pcre_test.cc b/re2/testing/mimics_pcre_test.cc index 72e7feea5..36a348f02 100644 --- a/re2/testing/mimics_pcre_test.cc +++ b/re2/testing/mimics_pcre_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include + #include "absl/base/macros.h" -#include "absl/log/absl_check.h" -#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/null_walker.cc b/re2/testing/null_walker.cc index da54c28b8..3e17bc39e 100644 --- a/re2/testing/null_walker.cc +++ b/re2/testing/null_walker.cc @@ -2,9 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" -#include "gtest/gtest.h" #include "re2/regexp.h" #include "re2/walker-inl.h" diff --git a/re2/testing/parse_test.cc b/re2/testing/parse_test.cc index e7838953e..53ef24ec7 100644 --- a/re2/testing/parse_test.cc +++ b/re2/testing/parse_test.cc @@ -4,10 +4,11 @@ // Test parse.cc, dump.cc, and tostring.cc. +#include + #include #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" diff --git a/re2/testing/possible_match_test.cc b/re2/testing/possible_match_test.cc index e6073ef0d..f217947d6 100644 --- a/re2/testing/possible_match_test.cc +++ b/re2/testing/possible_match_test.cc @@ -3,13 +3,14 @@ // license that can be found in the LICENSE file. #include + #include #include #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/escaping.h" +#include "absl/strings/string_view.h" #include "gtest/gtest.h" #include "re2/prog.h" #include "re2/re2.h" diff --git a/re2/testing/random_test.cc b/re2/testing/random_test.cc index d076b39b1..6ff358762 100644 --- a/re2/testing/random_test.cc +++ b/re2/testing/random_test.cc @@ -4,7 +4,6 @@ // Random testing of regular expression matching. -#include #include #include @@ -12,6 +11,7 @@ #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "re2/testing/exhaustive_tester.h" +#include "re2/testing/regexp_generator.h" ABSL_FLAG(int, regexpseed, 404, "Random regexp seed."); ABSL_FLAG(int, regexpcount, 100, "How many random regexps to generate."); diff --git a/re2/testing/re2_arg_test.cc b/re2/testing/re2_arg_test.cc index db1868aeb..c895c30a9 100644 --- a/re2/testing/re2_arg_test.cc +++ b/re2/testing/re2_arg_test.cc @@ -11,8 +11,8 @@ #include #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#include "absl/types/optional.h" #include "gtest/gtest.h" #include "re2/re2.h" diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index 0a602070f..d46666bea 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -5,27 +5,30 @@ // TODO: Test extractions for PartialMatch/Consume +#include "re2/re2.h" + #include #include #include #include + #include #include #include #include -#if !defined(_MSC_VER) && !defined(__CYGWIN__) && !defined(__MINGW32__) -#include -#include /* for sysconf */ -#endif #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "gtest/gtest.h" -#include "re2/re2.h" #include "re2/regexp.h" +#if !defined(_MSC_VER) && !defined(__CYGWIN__) && !defined(__MINGW32__) +#include +#include +#endif + namespace re2 { TEST(RE2, HexTests) { diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc index 33211fe0d..3b0a5330b 100644 --- a/re2/testing/regexp_benchmark.cc +++ b/re2/testing/regexp_benchmark.cc @@ -7,21 +7,22 @@ #include #include #include + #include #include -#include #include "absl/container/flat_hash_map.h" #include "absl/flags/flag.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "benchmark/benchmark.h" -#include "util/malloc_counter.h" #include "re2/prog.h" #include "re2/re2.h" #include "re2/regexp.h" +#include "util/malloc_counter.h" #include "util/pcre.h" namespace re2 { diff --git a/re2/testing/regexp_generator.cc b/re2/testing/regexp_generator.cc index baf73d2d3..a702e7d83 100644 --- a/re2/testing/regexp_generator.cc +++ b/re2/testing/regexp_generator.cc @@ -20,11 +20,15 @@ // Then RunPostfix turns each sequence into a regular expression // and passes the regexp to HandleRegexp. +#include "re2/testing/regexp_generator.h" + #include #include #include #include + #include +#include #include #include #include @@ -34,9 +38,8 @@ #include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" -#include "gtest/gtest.h" +#include "absl/strings/string_view.h" #include "util/utf.h" -#include "re2/testing/regexp_generator.h" namespace re2 { diff --git a/re2/testing/regexp_generator.h b/re2/testing/regexp_generator.h index e1be1a93d..bb2128da8 100644 --- a/re2/testing/regexp_generator.h +++ b/re2/testing/regexp_generator.h @@ -9,6 +9,7 @@ // regular expressions within given parameters (see below for details). #include + #include #include #include diff --git a/re2/testing/regexp_test.cc b/re2/testing/regexp_test.cc index 1403a7477..e971bd0b3 100644 --- a/re2/testing/regexp_test.cc +++ b/re2/testing/regexp_test.cc @@ -4,15 +4,15 @@ // Test parse.cc, dump.cc, and tostring.cc. +#include "re2/regexp.h" + #include + #include #include #include -#include "absl/log/absl_check.h" -#include "absl/log/absl_log.h" #include "gtest/gtest.h" -#include "re2/regexp.h" namespace re2 { diff --git a/re2/testing/required_prefix_test.cc b/re2/testing/required_prefix_test.cc index bf46f7aa1..ab7f4121f 100644 --- a/re2/testing/required_prefix_test.cc +++ b/re2/testing/required_prefix_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include + #include #include "absl/base/macros.h" -#include "absl/log/absl_check.h" -#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/search_test.cc b/re2/testing/search_test.cc index 166652a2d..0d0cb78b1 100644 --- a/re2/testing/search_test.cc +++ b/re2/testing/search_test.cc @@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include + +#include +#include + #include "absl/base/macros.h" #include "gtest/gtest.h" -#include "re2/prog.h" -#include "re2/regexp.h" -#include "re2/testing/tester.h" #include "re2/testing/exhaustive_tester.h" +#include "re2/testing/tester.h" // For target `log' in the Makefile. #ifndef LOGGING diff --git a/re2/testing/set_test.cc b/re2/testing/set_test.cc index f8d301887..5962295e2 100644 --- a/re2/testing/set_test.cc +++ b/re2/testing/set_test.cc @@ -2,16 +2,15 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include "re2/set.h" + #include -#include -#include + #include +#include -#include "absl/log/absl_check.h" -#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/re2.h" -#include "re2/set.h" namespace re2 { diff --git a/re2/testing/simplify_test.cc b/re2/testing/simplify_test.cc index 9c4e38c14..efbe96745 100644 --- a/re2/testing/simplify_test.cc +++ b/re2/testing/simplify_test.cc @@ -5,10 +5,8 @@ // Test simplify.cc. #include -#include #include "absl/base/macros.h" -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" diff --git a/re2/testing/string_generator.cc b/re2/testing/string_generator.cc index 24397df1b..6e450a942 100644 --- a/re2/testing/string_generator.cc +++ b/re2/testing/string_generator.cc @@ -6,15 +6,17 @@ // maxlen letters using the set of letters in alpha. // Fetch strings using a Java-like Next()/HasNext() interface. +#include "re2/testing/string_generator.h" + #include #include + +#include #include #include #include "absl/log/absl_check.h" -#include "absl/log/absl_log.h" -#include "gtest/gtest.h" -#include "re2/testing/string_generator.h" +#include "absl/strings/string_view.h" namespace re2 { diff --git a/re2/testing/string_generator.h b/re2/testing/string_generator.h index 0d6f5fcba..acdb3d5f1 100644 --- a/re2/testing/string_generator.h +++ b/re2/testing/string_generator.h @@ -10,6 +10,7 @@ // Fetch strings using a Java-like Next()/HasNext() interface. #include + #include #include #include diff --git a/re2/testing/string_generator_test.cc b/re2/testing/string_generator_test.cc index b1273d9f6..62868d507 100644 --- a/re2/testing/string_generator_test.cc +++ b/re2/testing/string_generator_test.cc @@ -4,13 +4,17 @@ // Test StringGenerator. +#include "re2/testing/string_generator.h" + +#include #include + #include +#include "absl/strings/string_view.h" #include "gtest/gtest.h" -#include "util/utf.h" -#include "re2/testing/string_generator.h" #include "re2/testing/regexp_generator.h" +#include "util/utf.h" namespace re2 { diff --git a/re2/testing/tester.cc b/re2/testing/tester.cc index fc68a8a5a..72925e392 100644 --- a/re2/testing/tester.cc +++ b/re2/testing/tester.cc @@ -4,9 +4,12 @@ // Regular expression engine tester -- test all the implementations against each other. +#include "re2/testing/tester.h" + #include #include #include + #include #include "absl/base/macros.h" @@ -15,10 +18,11 @@ #include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" -#include "re2/testing/tester.h" +#include "absl/strings/string_view.h" #include "re2/prog.h" #include "re2/re2.h" #include "re2/regexp.h" +#include "util/pcre.h" ABSL_FLAG(bool, dump_prog, false, "dump regexp program"); ABSL_FLAG(bool, log_okay, false, "log successful runs"); diff --git a/re2/testing/tester.h b/re2/testing/tester.h index 59be5ea0a..9a87138e8 100644 --- a/re2/testing/tester.h +++ b/re2/testing/tester.h @@ -12,8 +12,8 @@ #include "absl/strings/string_view.h" #include "re2/prog.h" -#include "re2/regexp.h" #include "re2/re2.h" +#include "re2/regexp.h" #include "util/pcre.h" namespace re2 { diff --git a/re2/tostring.cc b/re2/tostring.cc index c1ec69926..24a530e64 100644 --- a/re2/tostring.cc +++ b/re2/tostring.cc @@ -6,14 +6,14 @@ // Tested by parse_test.cc #include + #include -#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/strings/str_format.h" -#include "util/utf.h" #include "re2/regexp.h" #include "re2/walker-inl.h" +#include "util/utf.h" namespace re2 { From 8e87559194f84d8a880fcd8a8984174df006fb43 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 28 May 2024 17:15:56 +0000 Subject: [PATCH 43/56] Add `pybind11/stl.h` again. ... and make sure it stays. Change-Id: Iab9f9e9445545a9c97aefd4d83691a70fde2b1c8 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63111 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- python/_re2.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/python/_re2.cc b/python/_re2.cc index 385492d88..22f092b23 100644 --- a/python/_re2.cc +++ b/python/_re2.cc @@ -17,6 +17,7 @@ #include "pybind11/gil.h" #include "pybind11/pybind11.h" #include "pybind11/pytypes.h" +#include "pybind11/stl.h" // IWYU pragma: keep #include "re2/filtered_re2.h" #include "re2/re2.h" #include "re2/set.h" From 1db129ff30e1151ca22baa4da826e9363f49eefb Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 30 May 2024 20:08:43 +0000 Subject: [PATCH 44/56] Prepare to tag release `2024-06-01`. Change-Id: Ic0d6aa382308afbf6ccbb6c34b7fa3575443875c Reviewed-on: https://code-review.googlesource.com/c/re2/+/63150 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- MODULE.bazel | 2 +- python/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index a14365c6d..995ebd1b5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,7 +6,7 @@ module( name = "re2", - version = "2024-05-01", + version = "2024-06-01", compatibility_level = 1, ) diff --git a/python/setup.py b/python/setup.py index 27782bf57..7548c6ef6 100644 --- a/python/setup.py +++ b/python/setup.py @@ -192,7 +192,7 @@ def include_dirs(): setuptools.setup( name='google-re2', - version='1.1.20240501', + version='1.1.20240601', description='RE2 Python bindings', long_description=long_description, long_description_content_type='text/plain', From b91097e3989a8c8b463c0b6d7ffe96dafa5d6fad Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 31 May 2024 15:01:36 +0000 Subject: [PATCH 45/56] Add a `force-sdist` input to the Python release workflow. The first run for this month's release failed after uploading some of the wheels, but before uploading the sdist, so we need a way to force the sdist on a rerun if necessary. Change-Id: I3851d20cdeba02caad5f450e77cd7ef8704990d2 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63170 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/python.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 0ae6ef394..b0f01644d 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -5,6 +5,10 @@ on: build: required: true type: number + force-sdist: + required: false + type: boolean + default: false permissions: contents: read jobs: @@ -202,7 +206,7 @@ jobs: python -m pip install --upgrade pip python -m pip install --upgrade build wheel shell: bash - - if: inputs.build == 1 + - if: inputs.build == 1 || inputs.force-sdist == true name: Build source env: SOURCE_DATE_EPOCH: ${{ env.timestamp }} From e38a588a09495409575df9ec5af55cdb61831bb5 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 6 Jun 2024 20:25:07 +0000 Subject: [PATCH 46/56] Try GitHub-hosted runners for Linux on ARM64. Change-Id: I453072c1a19dabc2d3ed0672ec9936d56f637f7c Reviewed-on: https://code-review.googlesource.com/c/re2/+/63210 Reviewed-by: Ash Liu Reviewed-by: Paul Wankadia --- .github/workflows/python.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b0f01644d..cd05bcf8a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -25,8 +25,9 @@ jobs: fail-fast: false matrix: arch: - - { name: X64, python-name: x86_64, runs-on: [ubuntu-latest] } - - { name: ARM64, python-name: aarch64, runs-on: [self-hosted, linux, arm64] } + - { name: X64, python-name: x86_64, runs-on: [ubuntu-latest] } + # TODO(junyer): Update the label after ARM64 graduates from beta. + - { name: ARM64, python-name: aarch64, runs-on: [arm-ubuntu-arm-22.04-4core] } os: [manylinux_2_28] ver: ['3.8', '3.9', '3.10', '3.11', '3.12'] env: From e29afa1844861971a4cbf5fe559069b42161e97a Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 7 Jun 2024 20:37:50 +0000 Subject: [PATCH 47/56] Make the Bazel CI workflow use the local Python environment. This is setting up to run mypy as per #496. Change-Id: I48e67387313ac01d493086be8481b34f26bafe82 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63230 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/bazel.sh | 8 ++- .github/workflows/ci-bazel.yml | 10 ++++ .github/workflows/python.yml | 11 ++-- app/build.sh | 4 +- python/setup.py | 87 ------------------------------ python/toolchains/generate.py | 98 ++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 95 deletions(-) create mode 100644 python/toolchains/generate.py diff --git a/.github/bazel.sh b/.github/bazel.sh index 1fe309fab..f9f925cd6 100755 --- a/.github/bazel.sh +++ b/.github/bazel.sh @@ -8,10 +8,14 @@ export MSYS2_ARG_CONV_EXCL='*' for compilation_mode in dbg opt do bazel clean - bazel build --compilation_mode=${compilation_mode} -- \ + bazel build \ + --extra_toolchains=//python/toolchains:all \ + --compilation_mode=${compilation_mode} -- \ //:re2 \ //python:re2 - bazel test --compilation_mode=${compilation_mode} -- \ + bazel test \ + --extra_toolchains=//python/toolchains:all \ + --compilation_mode=${compilation_mode} -- \ //:all \ -//:dfa_test \ -//:exhaustive1_test \ diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index b0279bb29..a9b9fc2c3 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -18,5 +18,15 @@ jobs: - uses: bazel-contrib/setup-bazel@0.8.4 with: bazelisk-version: '1.x' + - uses: actions/setup-python@v5.1.0 + with: + python-version: '3.x' + - name: Prepare Python 3.x environment + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade mypy + python python/toolchains/generate.py + shell: bash - run: .github/bazel.sh shell: bash + # TODO(junyer): Run mypy as per https://github.com/google/re2/issues/496. diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index cd05bcf8a..3c731128d 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -46,8 +46,9 @@ jobs: - name: Prepare Python ${{ matrix.ver }} environment run: | "${PYTHON}" -m pip install --upgrade pip - "${PYTHON}" -m pip install --upgrade build wheel auditwheel + "${PYTHON}" -m pip install --upgrade setuptools build wheel auditwheel "${PYTHON}" -m pip install --upgrade absl-py + "${PYTHON}" python/toolchains/generate.py shell: bash - name: Build wheel env: @@ -105,8 +106,9 @@ jobs: - name: Prepare Python ${{ matrix.ver }} environment run: | python -m pip install --upgrade pip - python -m pip install --upgrade build wheel delocate + python -m pip install --upgrade setuptools build wheel delocate python -m pip install --upgrade absl-py + python python/toolchains/generate.py shell: bash - name: Build wheel env: @@ -162,8 +164,9 @@ jobs: - name: Prepare Python ${{ matrix.ver }} environment run: | python -m pip install --upgrade pip - python -m pip install --upgrade build wheel delvewheel + python -m pip install --upgrade setuptools build wheel delvewheel python -m pip install --upgrade absl-py + python python/toolchains/generate.py shell: bash - name: Build wheel env: @@ -205,7 +208,7 @@ jobs: - name: Prepare Python 3.x environment run: | python -m pip install --upgrade pip - python -m pip install --upgrade build wheel + python -m pip install --upgrade setuptools build wheel shell: bash - if: inputs.build == 1 || inputs.force-sdist == true name: Build source diff --git a/app/build.sh b/app/build.sh index a46374446..c8a2ae50e 100755 --- a/app/build.sh +++ b/app/build.sh @@ -7,9 +7,9 @@ DSTDIR=$(mktemp --directory --tmpdir $(basename $0).XXXXXXXXXX) cd ${SRCDIR} # Emscripten doesn't support `-fstack-protector`. AR=emar CC=emcc \ - bazel build --compilation_mode=opt \ + bazel build \ --copt=-fno-stack-protector \ - -- :all + --compilation_mode=opt -- :all cp ../bazel-bin/app/_re2.js ${DSTDIR} bazel clean --expunge cp app.ts index.html _re2.d.ts ${DSTDIR} diff --git a/python/setup.py b/python/setup.py index 7548c6ef6..c65aefa1d 100644 --- a/python/setup.py +++ b/python/setup.py @@ -6,8 +6,6 @@ import setuptools import setuptools.command.build_ext import shutil -import sys -import sysconfig long_description = r"""A drop-in replacement for the re module. @@ -67,10 +65,7 @@ def build_extension(self, ext): except KeyError: pass # Register the local Python toolchains with highest priority. - self.generate_python_toolchains() cmd.append('--extra_toolchains=//python/toolchains:all') - # Print debug information during toolchain resolution. - cmd.append('--toolchain_resolution_debug=.*') cmd += ['--compilation_mode=opt', '--', ':all'] self.spawn(cmd) @@ -82,88 +77,6 @@ def build_extension(self, ext): cmd = ['bazel', 'clean', '--expunge'] self.spawn(cmd) - def generate_python_toolchains(self): - include = sysconfig.get_path('include') - libs = os.path.join(include, '../libs') - - os.makedirs('toolchains') - shutil.copytree(include, 'toolchains/include') - try: - shutil.copytree(libs, 'toolchains/libs') - except FileNotFoundError: - # We must not be running on Windows. :) - pass - - with open('toolchains/BUILD.bazel', 'x') as file: - file.write( - """\ -load("@rules_python//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain") -load("@rules_python//python:py_runtime.bzl", "py_runtime") -load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair") - -package(default_visibility = ["//visibility:public"]) - -toolchain( - name = "py", - toolchain = ":py_toolchain", - toolchain_type = "@rules_python//python:toolchain_type", -) - -py_runtime_pair( - name = "py_toolchain", - py3_runtime = ":interpreter", -) - -py_runtime( - name = "interpreter", - interpreter_path = "{interpreter_path}", - interpreter_version_info = {{ - "major": "{major}", - "minor": "{minor}", - }}, - python_version = "PY3", -) - -toolchain( - name = "py_cc", - toolchain = ":py_cc_toolchain", - toolchain_type = "@rules_python//python/cc:toolchain_type", -) - -py_cc_toolchain( - name = "py_cc_toolchain", - headers = ":headers", - libs = ":libraries", - python_version = "{major}.{minor}", -) - -cc_library( - name = "headers", - hdrs = glob(["include/**/*.h"]), - includes = ["include"], - deps = select({{ - "@platforms//os:windows": [":interface_library"], - "//conditions:default": [], - }}), -) - -cc_import( - name = "interface_library", - interface_library = select({{ - "@platforms//os:windows": "libs/python{major}{minor}.lib", - "//conditions:default": None, - }}), - system_provided = True, -) - -# Not actually necessary for our purposes. :) -cc_library( - name = "libraries", -) -""".format(interpreter_path=sys.executable.replace('\\', '/'), - major=sys.version_info.major, - minor=sys.version_info.minor)) - def options(): bdist_wheel = {} diff --git a/python/toolchains/generate.py b/python/toolchains/generate.py new file mode 100644 index 000000000..84fef7800 --- /dev/null +++ b/python/toolchains/generate.py @@ -0,0 +1,98 @@ +# Copyright 2019 The RE2 Authors. All Rights Reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +import os +import shutil +import sys +import sysconfig + + +def generate(): + include = sysconfig.get_path('include') + libs = os.path.join(include, '../libs') + + mydir = os.path.dirname(sys.argv[0]) or '.' + shutil.copytree(include, f'{mydir}/include') + try: + shutil.copytree(libs, f'{mydir}/libs') + except FileNotFoundError: + # We must not be running on Windows. :) + pass + + with open(f'{mydir}/BUILD.bazel', 'x') as file: + file.write( + """\ +load("@rules_python//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain") +load("@rules_python//python:py_runtime.bzl", "py_runtime") +load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair") + +package(default_visibility = ["//visibility:public"]) + +toolchain( + name = "py", + toolchain = ":py_toolchain", + toolchain_type = "@rules_python//python:toolchain_type", +) + +py_runtime_pair( + name = "py_toolchain", + py3_runtime = ":interpreter", +) + +py_runtime( + name = "interpreter", + interpreter_path = "{interpreter_path}", + interpreter_version_info = {{ + "major": "{major}", + "minor": "{minor}", + }}, + python_version = "PY3", +) + +toolchain( + name = "py_cc", + toolchain = ":py_cc_toolchain", + toolchain_type = "@rules_python//python/cc:toolchain_type", +) + +py_cc_toolchain( + name = "py_cc_toolchain", + headers = ":headers", + libs = ":libraries", + python_version = "{major}.{minor}", +) + +cc_library( + name = "headers", + hdrs = glob(["include/**/*.h"]), + includes = ["include"], + deps = select({{ + "@platforms//os:windows": [":interface_library"], + "//conditions:default": [], + }}), +) + +cc_import( + name = "interface_library", + interface_library = select({{ + "@platforms//os:windows": "libs/python{major}{minor}.lib", + "//conditions:default": None, + }}), + system_provided = True, +) + +# Not actually necessary for our purposes. :) +cc_library( + name = "libraries", +) +""".format( + interpreter_path=sys.executable.replace('\\', '/'), + major=sys.version_info.major, + minor=sys.version_info.minor, + ) + ) + + +if __name__ == '__main__': + generate() From 273fb4ae39c922c1aca7a3dd20d45be9e0486afe Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sat, 8 Jun 2024 15:20:46 +0000 Subject: [PATCH 48/56] Tweak the sdist step to exercise it on dry runs. Change-Id: I1acea938fe9fc033a65ae87a725064c1cb658839 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63250 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3c731128d..3f5d9a7ec 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -210,8 +210,8 @@ jobs: python -m pip install --upgrade pip python -m pip install --upgrade setuptools build wheel shell: bash - - if: inputs.build == 1 || inputs.force-sdist == true - name: Build source + - if: inputs.build <= 1 || inputs.force-sdist == true + name: Build sdist env: SOURCE_DATE_EPOCH: ${{ env.timestamp }} run: | From 10f876d27355f393eb683587991ac90206271cb3 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sun, 9 Jun 2024 15:38:18 +0000 Subject: [PATCH 49/56] More setting up to run mypy as per #496. We need `re2` to be a package, not a module, because it appears that modules can't have `.pyi` files, so munge the module into a package. Change-Id: I1a268875743390c32c0fb9cd58f6d83a670ce928 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63270 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- python/setup.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index c65aefa1d..726f5b344 100644 --- a/python/setup.py +++ b/python/setup.py @@ -3,6 +3,7 @@ # license that can be found in the LICENSE file. import os +import re import setuptools import setuptools.command.build_ext import shutil @@ -103,6 +104,16 @@ def include_dirs(): extra_compile_args=['-fvisibility=hidden'], ) +# We need `re2` to be a package, not a module, because it appears that +# modules can't have `.pyi` files, so munge the module into a package. +os.makedirs('re2') +with open('re2.py', 'r') as file: + contents = file.read() +contents = re.sub(r'^(?=import _)', 'from . ', contents, flags=re.MULTILINE) +with open(f're2/__init__.py', 'x') as file: + file.write(contents) +# TODO(junyer): `.pyi` files as per https://github.com/google/re2/issues/496. + setuptools.setup( name='google-re2', version='1.1.20240601', @@ -112,7 +123,8 @@ def include_dirs(): author='The RE2 Authors', author_email='re2-dev@googlegroups.com', url='https://github.com/google/re2', - py_modules=['re2'], + packages=['re2'], + ext_package='re2', ext_modules=[ext_module], classifiers=[ 'Development Status :: 5 - Production/Stable', @@ -125,3 +137,5 @@ def include_dirs(): cmdclass={'build_ext': BuildExt}, python_requires='~=3.8', ) + +shutil.rmtree('re2') From 33eba105f662c99c8f7d6a264c84ed350bd1dc39 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 10 Jun 2024 16:12:49 +0000 Subject: [PATCH 50/56] Pivot out of the repository so that we test the wheel. Change-Id: Ie291a4c1f1e847d9ffb86112df027cc6bc2100c2 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63290 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/python.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3f5d9a7ec..39c106e8c 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -61,6 +61,10 @@ jobs: - name: Test wheel run: | "${PYTHON}" -m pip install google_re2-*.whl + # Pivot out of the repository so that we test the wheel. + DIR=$(mktemp -d) + cp re2_test.py "${DIR}" + cd "${DIR}" "${PYTHON}" re2_test.py shell: bash working-directory: python @@ -122,6 +126,10 @@ jobs: name: Test wheel run: | python -m pip install google_re2-*.whl + # Pivot out of the repository so that we test the wheel. + DIR=$(mktemp -d) + cp re2_test.py "${DIR}" + cd "${DIR}" python re2_test.py shell: bash working-directory: python @@ -179,6 +187,10 @@ jobs: - name: Test wheel run: | python -m pip install google_re2-*.whl + # Pivot out of the repository so that we test the wheel. + DIR=$(mktemp -d) + cp re2_test.py "${DIR}" + cd "${DIR}" python re2_test.py shell: bash working-directory: python From 4a8cee3dd3c3d81b6fe8b867811e193d5819df07 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 13 Jun 2024 18:15:38 +0000 Subject: [PATCH 51/56] Make the Bazel CI workflow test different Python versions. Change-Id: I84b078f47e3754c0a10bc58a54cba3f3987bbb80 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63330 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index a9b9fc2c3..252448f31 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -11,6 +11,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] + ver: ['3.8', '3.9', '3.10', '3.11', '3.12'] env: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: @@ -20,11 +21,11 @@ jobs: bazelisk-version: '1.x' - uses: actions/setup-python@v5.1.0 with: - python-version: '3.x' - - name: Prepare Python 3.x environment + python-version: ${{ matrix.ver }} + - name: Prepare Python ${{ matrix.ver }} environment run: | python -m pip install --upgrade pip - python -m pip install --upgrade mypy + python -m pip install --upgrade absl-py mypy python python/toolchains/generate.py shell: bash - run: .github/bazel.sh From 67570dea85d20f2a4cf030ad757dcc26baddab40 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 20 Jun 2024 12:53:23 +0000 Subject: [PATCH 52/56] Address some `-Wsign-compare` warnings. Fixes #499. Change-Id: I076d4fb4a51e0589176fdd175045ac90b0e361cb Reviewed-on: https://code-review.googlesource.com/c/re2/+/63350 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- BUILD.bazel | 1 + re2/bitmap256.h | 2 +- re2/prog.cc | 18 +++++++++--------- re2/re2.cc | 2 +- re2/regexp.cc | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index c765cfd51..643d71f3f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -135,6 +135,7 @@ cc_library( ":re2", "@abseil-cpp//absl/base", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/container:flat_hash_set", "@abseil-cpp//absl/flags:flag", "@abseil-cpp//absl/log:absl_check", "@abseil-cpp//absl/log:absl_log", diff --git a/re2/bitmap256.h b/re2/bitmap256.h index e16a570a5..e303e7155 100644 --- a/re2/bitmap256.h +++ b/re2/bitmap256.h @@ -51,7 +51,7 @@ class Bitmap256 { private: // Finds the least significant non-zero bit in n. static int FindLSBSet(uint64_t n) { - ABSL_DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, uint64_t{0}); #if defined(__GNUC__) return __builtin_ctzll(n); #elif defined(_MSC_VER) && defined(_M_X64) diff --git a/re2/prog.cc b/re2/prog.cc index d3ff26eff..9f1cc0082 100644 --- a/re2/prog.cc +++ b/re2/prog.cc @@ -37,13 +37,13 @@ namespace re2 { // Constructors per Inst opcode void Prog::Inst::InitAlt(uint32_t out, uint32_t out1) { - ABSL_DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, uint32_t{0}); set_out_opcode(out, kInstAlt); out1_ = out1; } void Prog::Inst::InitByteRange(int lo, int hi, int foldcase, uint32_t out) { - ABSL_DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, uint32_t{0}); set_out_opcode(out, kInstByteRange); lo_ = lo & 0xFF; hi_ = hi & 0xFF; @@ -51,30 +51,30 @@ void Prog::Inst::InitByteRange(int lo, int hi, int foldcase, uint32_t out) { } void Prog::Inst::InitCapture(int cap, uint32_t out) { - ABSL_DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, uint32_t{0}); set_out_opcode(out, kInstCapture); cap_ = cap; } void Prog::Inst::InitEmptyWidth(EmptyOp empty, uint32_t out) { - ABSL_DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, uint32_t{0}); set_out_opcode(out, kInstEmptyWidth); empty_ = empty; } void Prog::Inst::InitMatch(int32_t id) { - ABSL_DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, uint32_t{0}); set_opcode(kInstMatch); match_id_ = id; } void Prog::Inst::InitNop(uint32_t out) { - ABSL_DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, uint32_t{0}); set_opcode(kInstNop); } void Prog::Inst::InitFail() { - ABSL_DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, uint32_t{0}); set_opcode(kInstFail); } @@ -1113,7 +1113,7 @@ const void* Prog::PrefixAccel_ShiftDFA(const void* data, size_t size) { #if defined(__AVX2__) // Finds the least significant non-zero bit in n. static int FindLSBSet(uint32_t n) { - ABSL_DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, uint32_t{0}); #if defined(__GNUC__) return __builtin_ctz(n); #elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) @@ -1135,7 +1135,7 @@ static int FindLSBSet(uint32_t n) { #endif const void* Prog::PrefixAccel_FrontAndBack(const void* data, size_t size) { - ABSL_DCHECK_GE(prefix_size_, 2); + ABSL_DCHECK_GE(prefix_size_, size_t{2}); if (size < prefix_size_) return NULL; // Don't bother searching the last prefix_size_-1 bytes for prefix_front_. diff --git a/re2/re2.cc b/re2/re2.cc index 2e25b64f3..5978035ea 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -332,7 +332,7 @@ int RE2::ReverseProgramSize() const { // Finds the most significant non-zero bit in n. static int FindMSBSet(uint32_t n) { - ABSL_DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, uint32_t{0}); #if defined(__GNUC__) return 31 ^ __builtin_clz(n); #elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) diff --git a/re2/regexp.cc b/re2/regexp.cc index 1e5ae9071..f7e5ba297 100644 --- a/re2/regexp.cc +++ b/re2/regexp.cc @@ -498,7 +498,7 @@ bool Regexp::Equal(Regexp* a, Regexp* b) { if (n == 0) break; - ABSL_DCHECK_GE(n, 2); + ABSL_DCHECK_GE(n, size_t{2}); a = stk[n-2]; b = stk[n-1]; stk.resize(n-2); From 85dd7ad833a73095ecf3e3baea608ba051bbe2c7 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 20 Jun 2024 14:11:28 +0000 Subject: [PATCH 53/56] Address some more `-Wsign-compare` warnings. Fixes #499. Change-Id: I5405db7dff30ba84387c89a6064902f948b1ee3c Reviewed-on: https://code-review.googlesource.com/c/re2/+/63370 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- re2/testing/filtered_re2_test.cc | 38 +++++++++++----------- re2/testing/re2_test.cc | 25 +++++++++------ re2/testing/regexp_test.cc | 6 ++-- re2/testing/set_test.cc | 48 ++++++++++++++-------------- re2/testing/string_generator_test.cc | 2 +- 5 files changed, 63 insertions(+), 56 deletions(-) diff --git a/re2/testing/filtered_re2_test.cc b/re2/testing/filtered_re2_test.cc index b951d7c7f..6da76b228 100644 --- a/re2/testing/filtered_re2_test.cc +++ b/re2/testing/filtered_re2_test.cc @@ -33,14 +33,14 @@ TEST(FilteredRE2Test, EmptyTest) { FilterTestVars v; v.f.Compile(&v.atoms); - EXPECT_EQ(0, v.atoms.size()); + EXPECT_EQ(size_t{0}, v.atoms.size()); // Compile has no effect at all when called before Add: it will not // record that it has been called and it will not clear the vector. // The second point does not matter here, but the first point means // that an error will be logged during the call to AllMatches. v.f.AllMatches("foo", v.atom_indices, &v.matches); - EXPECT_EQ(0, v.matches.size()); + EXPECT_EQ(size_t{0}, v.matches.size()); } TEST(FilteredRE2Test, SmallOrTest) { @@ -49,10 +49,10 @@ TEST(FilteredRE2Test, SmallOrTest) { v.f.Add("(foo|bar)", v.opts, &id); v.f.Compile(&v.atoms); - EXPECT_EQ(0, v.atoms.size()); + EXPECT_EQ(size_t{0}, v.atoms.size()); v.f.AllMatches("lemurs bar", v.atom_indices, &v.matches); - EXPECT_EQ(1, v.matches.size()); + EXPECT_EQ(size_t{1}, v.matches.size()); EXPECT_EQ(id, v.matches[0]); } @@ -63,12 +63,12 @@ TEST(FilteredRE2Test, SmallLatinTest) { v.opts.set_encoding(RE2::Options::EncodingLatin1); v.f.Add("\xde\xadQ\xbe\xef", v.opts, &id); v.f.Compile(&v.atoms); - EXPECT_EQ(1, v.atoms.size()); + EXPECT_EQ(size_t{1}, v.atoms.size()); EXPECT_EQ(v.atoms[0], "\xde\xadq\xbe\xef"); v.atom_indices.push_back(0); v.f.AllMatches("foo\xde\xadQ\xbe\xeflemur", v.atom_indices, &v.matches); - EXPECT_EQ(1, v.matches.size()); + EXPECT_EQ(size_t{1}, v.matches.size()); EXPECT_EQ(id, v.matches[0]); } @@ -256,7 +256,7 @@ TEST(FilteredRE2Test, MatchTests) { FindAtomIndices(v.atoms, atoms, &atom_ids); std::vector matching_regexps; v.f.AllMatches(text, atom_ids, &matching_regexps); - EXPECT_EQ(1, matching_regexps.size()); + EXPECT_EQ(size_t{1}, matching_regexps.size()); text = "abc12312yyyzzz"; atoms.clear(); @@ -265,7 +265,7 @@ TEST(FilteredRE2Test, MatchTests) { atoms.push_back("yyyzzz"); FindAtomIndices(v.atoms, atoms, &atom_ids); v.f.AllMatches(text, atom_ids, &matching_regexps); - EXPECT_EQ(1, matching_regexps.size()); + EXPECT_EQ(size_t{1}, matching_regexps.size()); text = "abcd12yyy32yyyzzz"; atoms.clear(); @@ -278,7 +278,7 @@ TEST(FilteredRE2Test, MatchTests) { for (size_t i = 0; i < atom_ids.size(); i++) ABSL_LOG(INFO) << "i: " << i << " : " << atom_ids[i]; v.f.AllMatches(text, atom_ids, &matching_regexps); - EXPECT_EQ(2, matching_regexps.size()); + EXPECT_EQ(size_t{2}, matching_regexps.size()); } TEST(FilteredRE2Test, EmptyStringInStringSetBug) { @@ -301,43 +301,43 @@ TEST(FilteredRE2Test, MoveSemantics) { v1.f.Add("foo\\d+", v1.opts, &id); EXPECT_EQ(0, id); v1.f.Compile(&v1.atoms); - EXPECT_EQ(1, v1.atoms.size()); + EXPECT_EQ(size_t{1}, v1.atoms.size()); EXPECT_EQ("foo", v1.atoms[0]); v1.f.AllMatches("abc foo1 xyz", {0}, &v1.matches); - EXPECT_EQ(1, v1.matches.size()); + EXPECT_EQ(size_t{1}, v1.matches.size()); EXPECT_EQ(0, v1.matches[0]); v1.f.AllMatches("abc bar2 xyz", {0}, &v1.matches); - EXPECT_EQ(0, v1.matches.size()); + EXPECT_EQ(size_t{0}, v1.matches.size()); // The moved-to object should do what the moved-from object did. FilterTestVars v2; v2.f = std::move(v1.f); v2.f.AllMatches("abc foo1 xyz", {0}, &v2.matches); - EXPECT_EQ(1, v2.matches.size()); + EXPECT_EQ(size_t{1}, v2.matches.size()); EXPECT_EQ(0, v2.matches[0]); v2.f.AllMatches("abc bar2 xyz", {0}, &v2.matches); - EXPECT_EQ(0, v2.matches.size()); + EXPECT_EQ(size_t{0}, v2.matches.size()); // The moved-from object should have been reset and be reusable. v1.f.Add("bar\\d+", v1.opts, &id); EXPECT_EQ(0, id); v1.f.Compile(&v1.atoms); - EXPECT_EQ(1, v1.atoms.size()); + EXPECT_EQ(size_t{1}, v1.atoms.size()); EXPECT_EQ("bar", v1.atoms[0]); v1.f.AllMatches("abc foo1 xyz", {0}, &v1.matches); - EXPECT_EQ(0, v1.matches.size()); + EXPECT_EQ(size_t{0}, v1.matches.size()); v1.f.AllMatches("abc bar2 xyz", {0}, &v1.matches); - EXPECT_EQ(1, v1.matches.size()); + EXPECT_EQ(size_t{1}, v1.matches.size()); EXPECT_EQ(0, v1.matches[0]); // Verify that "overwriting" works and also doesn't leak memory. // (The latter will need a leak detector such as LeakSanitizer.) v1.f = std::move(v2.f); v1.f.AllMatches("abc foo1 xyz", {0}, &v1.matches); - EXPECT_EQ(1, v1.matches.size()); + EXPECT_EQ(size_t{1}, v1.matches.size()); EXPECT_EQ(0, v1.matches[0]); v1.f.AllMatches("abc bar2 xyz", {0}, &v1.matches); - EXPECT_EQ(0, v1.matches.size()); + EXPECT_EQ(size_t{0}, v1.matches.size()); } } // namespace re2 diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index d46666bea..04c040e9e 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -558,14 +558,14 @@ TEST(Capture, NamedGroups) { RE2 re("(hello world)"); ASSERT_EQ(re.NumberOfCapturingGroups(), 1); const std::map& m = re.NamedCapturingGroups(); - ASSERT_EQ(m.size(), 0); + ASSERT_EQ(m.size(), size_t{0}); } { RE2 re("(?Pexpr(?Pexpr)(?Pexpr))((expr)(?Pexpr))"); ASSERT_EQ(re.NumberOfCapturingGroups(), 6); const std::map& m = re.NamedCapturingGroups(); - ASSERT_EQ(m.size(), 4); + ASSERT_EQ(m.size(), size_t{4}); ASSERT_EQ(m.find("A")->second, 1); ASSERT_EQ(m.find("B")->second, 2); ASSERT_EQ(m.find("C")->second, 3); @@ -687,7 +687,7 @@ TEST(RE2, FullMatchStringViewArg) { absl::string_view sp; // string_view-arg ASSERT_TRUE(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &sp, &i)); - ASSERT_EQ(sp.size(), 4); + ASSERT_EQ(sp.size(), size_t{4}); ASSERT_TRUE(memcmp(sp.data(), "ruby", 4) == 0); ASSERT_EQ(i, 1234); } @@ -796,6 +796,11 @@ TEST(RE2, FullMatchTypeTests) { ASSERT_TRUE(RE2::FullMatch("Hello", "(H)ello", &c)); ASSERT_EQ(c, 'H'); } + { + signed char c; + ASSERT_TRUE(RE2::FullMatch("Hello", "(H)ello", &c)); + ASSERT_EQ(c, static_cast('H')); + } { unsigned char c; ASSERT_TRUE(RE2::FullMatch("Hello", "(H)ello", &c)); @@ -841,7 +846,7 @@ TEST(RE2, FullMatchTypeTests) { { uint32_t v; static const uint32_t max = UINT32_C(0xffffffff); - ASSERT_TRUE(RE2::FullMatch("100", "(\\d+)", &v)); ASSERT_EQ(v, 100); + ASSERT_TRUE(RE2::FullMatch("100", "(\\d+)", &v)); ASSERT_EQ(v, uint32_t{100}); ASSERT_TRUE(RE2::FullMatch("4294967295", "(\\d+)", &v)); ASSERT_EQ(v, max); ASSERT_FALSE(RE2::FullMatch("4294967296", "(\\d+)", &v)); ASSERT_FALSE(RE2::FullMatch("-1", "(\\d+)", &v)); @@ -879,7 +884,7 @@ TEST(RE2, FullMatchTypeTests) { static const uint64_t max = UINT64_C(0xffffffffffffffff); std::string str; - ASSERT_TRUE(RE2::FullMatch("100", "(-?\\d+)", &v)); ASSERT_EQ(v, 100); + ASSERT_TRUE(RE2::FullMatch("100", "(-?\\d+)", &v)); ASSERT_EQ(v, uint64_t{100}); ASSERT_TRUE(RE2::FullMatch("-100", "(-?\\d+)", &v2)); ASSERT_EQ(v2, -100); str = std::to_string(max); @@ -897,11 +902,11 @@ TEST(RE2, FloatingPointFullMatchTypes) { float v; ASSERT_TRUE(RE2::FullMatch("100", "(.*)", &v)); ASSERT_EQ(v, 100); ASSERT_TRUE(RE2::FullMatch("-100.", "(.*)", &v)); ASSERT_EQ(v, -100); - ASSERT_TRUE(RE2::FullMatch("1e23", "(.*)", &v)); ASSERT_EQ(v, float(1e23)); + ASSERT_TRUE(RE2::FullMatch("1e23", "(.*)", &v)); ASSERT_EQ(v, float{1e23}); ASSERT_TRUE(RE2::FullMatch(" 100", "(.*)", &v)); ASSERT_EQ(v, 100); ASSERT_TRUE(RE2::FullMatch(zeros + "1e23", "(.*)", &v)); - ASSERT_EQ(v, float(1e23)); + ASSERT_EQ(v, float{1e23}); // 6700000000081920.1 is an edge case. // 6700000000081920 is exactly halfway between @@ -930,9 +935,11 @@ TEST(RE2, FloatingPointFullMatchTypes) { double v; ASSERT_TRUE(RE2::FullMatch("100", "(.*)", &v)); ASSERT_EQ(v, 100); ASSERT_TRUE(RE2::FullMatch("-100.", "(.*)", &v)); ASSERT_EQ(v, -100); - ASSERT_TRUE(RE2::FullMatch("1e23", "(.*)", &v)); ASSERT_EQ(v, 1e23); + ASSERT_TRUE(RE2::FullMatch("1e23", "(.*)", &v)); ASSERT_EQ(v, double{1e23}); + ASSERT_TRUE(RE2::FullMatch(" 100", "(.*)", &v)); ASSERT_EQ(v, 100); + ASSERT_TRUE(RE2::FullMatch(zeros + "1e23", "(.*)", &v)); - ASSERT_EQ(v, double(1e23)); + ASSERT_EQ(v, double{1e23}); ASSERT_TRUE(RE2::FullMatch("0.1", "(.*)", &v)); ASSERT_EQ(v, 0.1) << absl::StrFormat("%.17g != %.17g", v, 0.1); diff --git a/re2/testing/regexp_test.cc b/re2/testing/regexp_test.cc index e971bd0b3..edbbe0839 100644 --- a/re2/testing/regexp_test.cc +++ b/re2/testing/regexp_test.cc @@ -54,8 +54,8 @@ TEST(Regexp, NamedCaptures) { EXPECT_EQ(4, x->NumCaptures()); const std::map* have = x->NamedCaptures(); EXPECT_TRUE(have != NULL); - EXPECT_EQ(2, have->size()); // there are only two named groups in - // the regexp: 'g1' and 'g2'. + // there are only two named groups in the regexp: 'g1' and 'g2'. + EXPECT_EQ(size_t{2}, have->size()); std::map want; want["g1"] = 1; want["g2"] = 3; @@ -73,7 +73,7 @@ TEST(Regexp, CaptureNames) { EXPECT_EQ(4, x->NumCaptures()); const std::map* have = x->CaptureNames(); EXPECT_TRUE(have != NULL); - EXPECT_EQ(3, have->size()); + EXPECT_EQ(size_t{3}, have->size()); std::map want; want[1] = "g1"; want[3] = "g2"; diff --git a/re2/testing/set_test.cc b/re2/testing/set_test.cc index 5962295e2..b4aaf92a1 100644 --- a/re2/testing/set_test.cc +++ b/re2/testing/set_test.cc @@ -28,16 +28,16 @@ TEST(Set, Unanchored) { std::vector v; ASSERT_EQ(s.Match("foobar", &v), true); - ASSERT_EQ(v.size(), 2); + ASSERT_EQ(v.size(), size_t{2}); ASSERT_EQ(v[0], 0); ASSERT_EQ(v[1], 1); ASSERT_EQ(s.Match("fooba", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); ASSERT_EQ(s.Match("oobar", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 1); } @@ -56,21 +56,21 @@ TEST(Set, UnanchoredFactored) { std::vector v; ASSERT_EQ(s.Match("foobar", &v), true); - ASSERT_EQ(v.size(), 2); + ASSERT_EQ(v.size(), size_t{2}); ASSERT_EQ(v[0], 0); ASSERT_EQ(v[1], 1); ASSERT_EQ(s.Match("obarfoobaroo", &v), true); - ASSERT_EQ(v.size(), 2); + ASSERT_EQ(v.size(), size_t{2}); ASSERT_EQ(v[0], 0); ASSERT_EQ(v[1], 1); ASSERT_EQ(s.Match("fooba", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); ASSERT_EQ(s.Match("oobar", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); } TEST(Set, UnanchoredDollar) { @@ -84,11 +84,11 @@ TEST(Set, UnanchoredDollar) { std::vector v; ASSERT_EQ(s.Match("foo", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); ASSERT_EQ(s.Match("foobar", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); } TEST(Set, UnanchoredWordBoundary) { @@ -103,14 +103,14 @@ TEST(Set, UnanchoredWordBoundary) { std::vector v; ASSERT_EQ(s.Match("foo", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); ASSERT_EQ(s.Match("foobar", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); ASSERT_EQ(s.Match("foo bar", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); } @@ -130,20 +130,20 @@ TEST(Set, Anchored) { std::vector v; ASSERT_EQ(s.Match("foobar", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); ASSERT_EQ(s.Match("fooba", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); ASSERT_EQ(s.Match("oobar", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); ASSERT_EQ(s.Match("foo", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); ASSERT_EQ(s.Match("bar", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 1); } @@ -157,10 +157,10 @@ TEST(Set, EmptyUnanchored) { std::vector v; ASSERT_EQ(s.Match("", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); ASSERT_EQ(s.Match("foobar", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); } TEST(Set, EmptyAnchored) { @@ -173,10 +173,10 @@ TEST(Set, EmptyAnchored) { std::vector v; ASSERT_EQ(s.Match("", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); ASSERT_EQ(s.Match("foobar", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); } TEST(Set, Prefix) { @@ -191,14 +191,14 @@ TEST(Set, Prefix) { std::vector v; ASSERT_EQ(s.Match("/prefix", &v), false); - ASSERT_EQ(v.size(), 0); + ASSERT_EQ(v.size(), size_t{0}); ASSERT_EQ(s.Match("/prefix/", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); ASSERT_EQ(s.Match("/prefix/42", &v), true); - ASSERT_EQ(v.size(), 1); + ASSERT_EQ(v.size(), size_t{1}); ASSERT_EQ(v[0], 0); } diff --git a/re2/testing/string_generator_test.cc b/re2/testing/string_generator_test.cc index 62868d507..909843425 100644 --- a/re2/testing/string_generator_test.cc +++ b/re2/testing/string_generator_test.cc @@ -47,7 +47,7 @@ static void RunTest(int len, const std::string& alphabet, bool donull) { EXPECT_TRUE(g.HasNext()); absl::string_view sp = g.Next(); EXPECT_EQ(sp.data(), static_cast(NULL)); - EXPECT_EQ(sp.size(), 0); + EXPECT_EQ(sp.size(), size_t{0}); } while (g.HasNext()) { From f3c0709cd071a1802eaca1a38995a3445dec12d7 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 21 Jun 2024 17:28:16 +0000 Subject: [PATCH 54/56] Bump versions of actions and dependencies. Change-Id: Ia4272f8c10eb5e4d1b93049e7516d2ccd0090100 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63351 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- .github/workflows/ci-bazel.yml | 4 ++-- .github/workflows/ci-cmake.yml | 6 +++--- .github/workflows/ci.yml | 6 +++--- .github/workflows/pages.yml | 6 +++--- .github/workflows/pr.yml | 2 +- .github/workflows/python.yml | 16 ++++++++-------- .github/workflows/release.yml | 2 +- MODULE.bazel | 4 ++-- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci-bazel.yml b/.github/workflows/ci-bazel.yml index 252448f31..2b56d9954 100644 --- a/.github/workflows/ci-bazel.yml +++ b/.github/workflows/ci-bazel.yml @@ -15,8 +15,8 @@ jobs: env: BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4.1.6 - - uses: bazel-contrib/setup-bazel@0.8.4 + - uses: actions/checkout@v4.1.7 + - uses: bazel-contrib/setup-bazel@0.8.5 with: bazelisk-version: '1.x' - uses: actions/setup-python@v5.1.0 diff --git a/.github/workflows/ci-cmake.yml b/.github/workflows/ci-cmake.yml index 113c1eafd..8c3e8d679 100644 --- a/.github/workflows/ci-cmake.yml +++ b/.github/workflows/ci-cmake.yml @@ -12,7 +12,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update @@ -29,7 +29,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -44,7 +44,7 @@ jobs: matrix: build_shared_libs: [OFF, ON] steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b5cb2ca6..494563894 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: # (The other two flags are the default provided for CXXFLAGS in Makefile.) CXXFLAGS: -O3 -g -std=c++${{ matrix.ver }} steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - name: Install Abseil, GoogleTest and Benchmark run: | brew update @@ -40,7 +40,7 @@ jobs: CXX: clang++-${{ matrix.ver }} PKG_CONFIG_PATH: /usr/local/share/vcpkg/installed/x64-linux/lib/pkgconfig steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - name: Install Clang ${{ matrix.ver }} run: | # Avoid `Conflicts: python3-lldb-x.y` between packages. @@ -68,7 +68,7 @@ jobs: CXX: g++-${{ matrix.ver }} PKG_CONFIG_PATH: /usr/local/share/vcpkg/installed/x64-linux/lib/pkgconfig steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - name: Install Abseil, GoogleTest and Benchmark run: | vcpkg update diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 297e897af..e3653142a 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -17,8 +17,8 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4.1.6 - - uses: bazel-contrib/setup-bazel@0.8.4 + - uses: actions/checkout@v4.1.7 + - uses: bazel-contrib/setup-bazel@0.8.5 with: bazelisk-version: '1.x' - run: app/build.sh @@ -37,5 +37,5 @@ jobs: environment: github-pages runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - uses: actions/deploy-pages@v4.0.5 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index af29512cd..e3f99a4f5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,7 +15,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - uses: actions/github-script@v7.0.1 with: script: | diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 39c106e8c..24e32aec3 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -36,11 +36,11 @@ jobs: # Bazel fails if the username is unknown. USER: runner steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.4 + - uses: bazel-contrib/setup-bazel@0.8.5 with: bazelisk-version: '1.x' - name: Prepare Python ${{ matrix.ver }} environment @@ -97,11 +97,11 @@ jobs: # Otherwise, Python refuses to install the built wheel! SYSTEM_VERSION_COMPAT: 0 steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.4 + - uses: bazel-contrib/setup-bazel@0.8.5 with: bazelisk-version: '1.x' - uses: actions/setup-python@v5.1.0 @@ -153,11 +153,11 @@ jobs: BAZEL_CPU: ${{ matrix.arch.bazel-name }}_windows PLAT_NAME: ${{ matrix.arch.python-name }} steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash - - uses: bazel-contrib/setup-bazel@0.8.4 + - uses: bazel-contrib/setup-bazel@0.8.5 with: bazelisk-version: '1.x' # Lowercase the architecture name for `actions/setup-python`. @@ -210,7 +210,7 @@ jobs: id-token: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 # Stash the timestamp for the commit SHA that triggered the workflow. - run: echo "timestamp=$(git log -1 --pretty=%ct)" >> "${GITHUB_ENV}" shell: bash @@ -246,6 +246,6 @@ jobs: shell: bash working-directory: python - if: inputs.build >= 1 - uses: pypa/gh-action-pypi-publish@v1.8.14 + uses: pypa/gh-action-pypi-publish@v1.9.0 with: packages-dir: python/dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25721ae05..6c513923b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4.1.6 + - uses: actions/checkout@v4.1.7 - run: | gh release create "${GITHUB_REF_NAME}" \ --generate-notes --latest --verify-tag \ diff --git a/MODULE.bazel b/MODULE.bazel index 995ebd1b5..dbcee1007 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -14,7 +14,7 @@ bazel_dep(name = "platforms", version = "0.0.10") bazel_dep(name = "apple_support", version = "1.15.1") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "abseil-cpp", version = "20240116.2") -bazel_dep(name = "rules_python", version = "0.32.2") +bazel_dep(name = "rules_python", version = "0.33.2") bazel_dep(name = "pybind11_bazel", version = "2.12.0") # This is a temporary hack for `x64_x86_windows`. @@ -24,6 +24,6 @@ use_repo(cc_configure, "local_config_cc") # These dependencies will be ignored when the `re2` module is not # the root module (or when `--ignore_dev_dependency` is enabled). -bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True) +bazel_dep(name = "google_benchmark", version = "1.8.4", dev_dependency = True) bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) bazel_dep(name = "abseil-py", version = "2.1.0", dev_dependency = True) From 0d992b4cefeb7070bbf265fe4838628120a03fe5 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 21 Jun 2024 19:46:22 +0000 Subject: [PATCH 55/56] Even more setting up to run mypy as per #496. Change-Id: Ib1250ec954c0fecdaed606c41bbbbe00ff7bc1de Reviewed-on: https://code-review.googlesource.com/c/re2/+/63371 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- .github/workflows/python.yml | 6 +-- python/setup.py | 79 +++++++++++++++++++++--------------- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 24e32aec3..d97fcb62b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -47,7 +47,7 @@ jobs: run: | "${PYTHON}" -m pip install --upgrade pip "${PYTHON}" -m pip install --upgrade setuptools build wheel auditwheel - "${PYTHON}" -m pip install --upgrade absl-py + "${PYTHON}" -m pip install --upgrade absl-py mypy "${PYTHON}" python/toolchains/generate.py shell: bash - name: Build wheel @@ -111,7 +111,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade setuptools build wheel delocate - python -m pip install --upgrade absl-py + python -m pip install --upgrade absl-py mypy python python/toolchains/generate.py shell: bash - name: Build wheel @@ -173,7 +173,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade setuptools build wheel delvewheel - python -m pip install --upgrade absl-py + python -m pip install --upgrade absl-py mypy python python/toolchains/generate.py shell: bash - name: Build wheel diff --git a/python/setup.py b/python/setup.py index 726f5b344..e695cb0f9 100644 --- a/python/setup.py +++ b/python/setup.py @@ -106,36 +106,49 @@ def include_dirs(): # We need `re2` to be a package, not a module, because it appears that # modules can't have `.pyi` files, so munge the module into a package. -os.makedirs('re2') -with open('re2.py', 'r') as file: - contents = file.read() -contents = re.sub(r'^(?=import _)', 'from . ', contents, flags=re.MULTILINE) -with open(f're2/__init__.py', 'x') as file: - file.write(contents) -# TODO(junyer): `.pyi` files as per https://github.com/google/re2/issues/496. - -setuptools.setup( - name='google-re2', - version='1.1.20240601', - description='RE2 Python bindings', - long_description=long_description, - long_description_content_type='text/plain', - author='The RE2 Authors', - author_email='re2-dev@googlegroups.com', - url='https://github.com/google/re2', - packages=['re2'], - ext_package='re2', - ext_modules=[ext_module], - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: C++', - 'Programming Language :: Python :: 3.8', - ], - options=options(), - cmdclass={'build_ext': BuildExt}, - python_requires='~=3.8', -) - -shutil.rmtree('re2') +PACKAGE = 're2' +try: + os.makedirs(PACKAGE) + for filename in ( + 're2.py', + # TODO(junyer): Populate as per https://github.com/google/re2/issues/496. + # 're2.pyi', + # '_re2.pyi', + ): + with open(filename, 'r') as file: + contents = file.read() + filename = re.sub(r'^re2(?=\.py)', '__init__', contents) + contents = re.sub(r'^(?=import _)', 'from . ', contents, flags=re.MULTILINE) + with open(f'{PACKAGE}/{filename}', 'x') as file: + file.write(contents) + # TODO(junyer): Populate as per https://github.com/google/re2/issues/496. + # with open(f'{PACKAGE}/py.typed', 'x') as file: + # pass + + setuptools.setup( + name='google-re2', + version='1.1.20240601', + description='RE2 Python bindings', + long_description=long_description, + long_description_content_type='text/plain', + author='The RE2 Authors', + author_email='re2-dev@googlegroups.com', + url='https://github.com/google/re2', + packages=[PACKAGE], + ext_package=PACKAGE, + ext_modules=[ext_module], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: C++', + 'Programming Language :: Python :: 3.8', + ], + options=options(), + cmdclass={'build_ext': BuildExt}, + python_requires='~=3.8', + ) +except: + raise +else: + shutil.rmtree(PACKAGE) From 6144b62bece50a4af8bcdb166f04f6ec5af3d6d8 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 21 Jun 2024 19:58:35 +0000 Subject: [PATCH 56/56] Fix a silly bug. Sigh. Change-Id: Ia67342d56907053228895ed6cd65c98949bd7c43 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63352 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index e695cb0f9..e128cf9f6 100644 --- a/python/setup.py +++ b/python/setup.py @@ -117,7 +117,7 @@ def include_dirs(): ): with open(filename, 'r') as file: contents = file.read() - filename = re.sub(r'^re2(?=\.py)', '__init__', contents) + filename = re.sub(r'^re2(?=\.py)', '__init__', filename) contents = re.sub(r'^(?=import _)', 'from . ', contents, flags=re.MULTILINE) with open(f'{PACKAGE}/{filename}', 'x') as file: file.write(contents)