re2 1.24.1 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -20
- package/README.md +57 -4
- package/binding.gyp +1 -2
- package/lib/addon.cc +7 -3
- package/lib/exec.cc +4 -4
- package/lib/match.cc +4 -4
- package/lib/pattern.cc +148 -1
- package/lib/replace.cc +34 -8
- package/lib/search.cc +1 -1
- package/lib/set.cc +75 -0
- package/lib/test.cc +1 -1
- package/lib/unicode_properties.h +15840 -0
- package/lib/wrapped_re2.h +11 -4
- package/lib/wrapped_re2_set.h +3 -1
- package/llms-full.txt +37 -7
- package/llms.txt +4 -1
- package/package.json +9 -10
- package/re2.d.ts +2 -0
- package/vendor/abseil-cpp/CMake/AbseilDll.cmake +87 -74
- package/vendor/abseil-cpp/CMakeLists.txt +3 -3
- package/vendor/abseil-cpp/FAQ.md +130 -79
- package/vendor/abseil-cpp/MODULE.bazel +6 -7
- package/vendor/abseil-cpp/absl/BUILD.bazel +6 -0
- package/vendor/abseil-cpp/absl/algorithm/BUILD.bazel +4 -0
- package/vendor/abseil-cpp/absl/algorithm/CMakeLists.txt +4 -0
- package/vendor/abseil-cpp/absl/algorithm/algorithm.h +34 -2
- package/vendor/abseil-cpp/absl/algorithm/container.h +164 -17
- package/vendor/abseil-cpp/absl/algorithm/container_test.cc +390 -13
- package/vendor/abseil-cpp/absl/base/BUILD.bazel +53 -6
- package/vendor/abseil-cpp/absl/base/CMakeLists.txt +28 -4
- package/vendor/abseil-cpp/absl/base/attributes.h +61 -42
- package/vendor/abseil-cpp/absl/base/call_once.h +1 -0
- package/vendor/abseil-cpp/absl/base/casts.h +8 -1
- package/vendor/abseil-cpp/absl/base/casts_test.cc +3 -6
- package/vendor/abseil-cpp/absl/base/config.h +54 -10
- package/vendor/abseil-cpp/absl/base/exception_safety_testing_test.cc +9 -9
- package/vendor/abseil-cpp/absl/base/fast_type_id.h +30 -2
- package/vendor/abseil-cpp/absl/base/fast_type_id_test.cc +3 -0
- package/vendor/abseil-cpp/absl/base/internal/exception_safety_testing.h +15 -12
- package/vendor/abseil-cpp/absl/base/internal/hardening.h +136 -0
- package/vendor/abseil-cpp/absl/base/internal/hardening_test.cc +168 -0
- package/vendor/abseil-cpp/absl/base/internal/iterator_traits.h +2 -2
- package/vendor/abseil-cpp/absl/base/internal/low_level_alloc.cc +6 -0
- package/vendor/abseil-cpp/absl/base/internal/low_level_scheduling.h +77 -15
- package/vendor/abseil-cpp/absl/base/internal/sysinfo.cc +1 -2
- package/vendor/abseil-cpp/absl/base/internal/thread_identity.h +52 -0
- package/vendor/abseil-cpp/absl/base/internal/unscaledcycleclock.h +5 -0
- package/vendor/abseil-cpp/absl/base/macros.h +36 -20
- package/vendor/abseil-cpp/absl/base/nullability.h +4 -3
- package/vendor/abseil-cpp/absl/base/optimization.h +3 -2
- package/vendor/abseil-cpp/absl/base/optimization_test.cc +4 -3
- package/vendor/abseil-cpp/absl/base/options.h +55 -1
- package/vendor/abseil-cpp/absl/base/policy_checks.h +5 -5
- package/vendor/abseil-cpp/absl/base/{internal/throw_delegate.cc → throw_delegate.cc} +9 -7
- package/vendor/abseil-cpp/absl/base/{internal/throw_delegate.h → throw_delegate.h} +4 -14
- package/vendor/abseil-cpp/absl/base/throw_delegate_test.cc +19 -28
- package/vendor/abseil-cpp/absl/cleanup/BUILD.bazel +2 -0
- package/vendor/abseil-cpp/absl/cleanup/CMakeLists.txt +2 -0
- package/vendor/abseil-cpp/absl/cleanup/cleanup.h +3 -2
- package/vendor/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -2
- package/vendor/abseil-cpp/absl/container/BUILD.bazel +19 -7
- package/vendor/abseil-cpp/absl/container/CMakeLists.txt +6 -5
- package/vendor/abseil-cpp/absl/container/btree_benchmark.cc +3 -5
- package/vendor/abseil-cpp/absl/container/btree_set.h +5 -5
- package/vendor/abseil-cpp/absl/container/btree_test.cc +11 -14
- package/vendor/abseil-cpp/absl/container/chunked_queue.h +8 -6
- package/vendor/abseil-cpp/absl/container/chunked_queue_test.cc +5 -5
- package/vendor/abseil-cpp/absl/container/fixed_array.h +14 -13
- package/vendor/abseil-cpp/absl/container/fixed_array_test.cc +3 -3
- package/vendor/abseil-cpp/absl/container/flat_hash_map.h +18 -6
- package/vendor/abseil-cpp/absl/container/flat_hash_map_test.cc +34 -1
- package/vendor/abseil-cpp/absl/container/flat_hash_set.h +21 -7
- package/vendor/abseil-cpp/absl/container/flat_hash_set_test.cc +39 -7
- package/vendor/abseil-cpp/absl/container/inlined_vector.h +29 -29
- package/vendor/abseil-cpp/absl/container/inlined_vector_test.cc +2 -2
- package/vendor/abseil-cpp/absl/container/internal/btree.h +32 -24
- package/vendor/abseil-cpp/absl/container/internal/btree_container.h +16 -17
- package/vendor/abseil-cpp/absl/container/internal/common.h +6 -5
- package/vendor/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
- package/vendor/abseil-cpp/absl/container/internal/compressed_tuple.h +16 -16
- package/vendor/abseil-cpp/absl/container/internal/compressed_tuple_test.cc +13 -13
- package/vendor/abseil-cpp/absl/container/internal/container_memory.h +41 -31
- package/vendor/abseil-cpp/absl/container/internal/hash_function_defaults.h +2 -2
- package/vendor/abseil-cpp/absl/container/internal/hash_generator_testing.h +4 -4
- package/vendor/abseil-cpp/absl/container/internal/hash_policy_traits.h +3 -3
- package/vendor/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +27 -19
- package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +2 -2
- package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler.h +0 -17
- package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler_test.cc +12 -30
- package/vendor/abseil-cpp/absl/container/internal/inlined_vector.h +28 -28
- package/vendor/abseil-cpp/absl/container/internal/layout.h +13 -13
- package/vendor/abseil-cpp/absl/container/internal/layout_test.cc +3 -2
- package/vendor/abseil-cpp/absl/container/internal/raw_hash_map.h +60 -62
- package/vendor/abseil-cpp/absl/container/internal/raw_hash_set.cc +59 -39
- package/vendor/abseil-cpp/absl/container/internal/raw_hash_set.h +619 -326
- package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_benchmark.cc +25 -2
- package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_probe_benchmark.cc +4 -4
- package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_test.cc +575 -159
- package/vendor/abseil-cpp/absl/container/linked_hash_map.h +2 -2
- package/vendor/abseil-cpp/absl/container/node_hash_map.h +27 -15
- package/vendor/abseil-cpp/absl/container/node_hash_map_test.cc +34 -0
- package/vendor/abseil-cpp/absl/container/node_hash_set.h +25 -11
- package/vendor/abseil-cpp/absl/container/node_hash_set_test.cc +39 -7
- package/vendor/abseil-cpp/absl/container/sample_element_size_test.cc +7 -4
- package/vendor/abseil-cpp/absl/crc/BUILD.bazel +0 -1
- package/vendor/abseil-cpp/absl/crc/CMakeLists.txt +2 -3
- package/vendor/abseil-cpp/absl/crc/crc32c_benchmark.cc +2 -1
- package/vendor/abseil-cpp/absl/crc/internal/cpu_detect.cc +6 -6
- package/vendor/abseil-cpp/absl/crc/internal/crc.cc +4 -6
- package/vendor/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +41 -0
- package/vendor/abseil-cpp/absl/crc/internal/crc_internal.h +0 -16
- package/vendor/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +143 -81
- package/vendor/abseil-cpp/absl/debugging/BUILD.bazel +9 -31
- package/vendor/abseil-cpp/absl/debugging/CMakeLists.txt +3 -33
- package/vendor/abseil-cpp/absl/debugging/internal/demangle_rust.h +8 -0
- package/vendor/abseil-cpp/absl/debugging/internal/demangle_test.cc +2 -1
- package/vendor/abseil-cpp/absl/debugging/internal/examine_stack.cc +12 -2
- package/vendor/abseil-cpp/absl/debugging/internal/examine_stack.h +2 -3
- package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +11 -0
- package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +13 -4
- package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +14 -7
- package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +4 -0
- package/vendor/abseil-cpp/absl/debugging/internal/symbolize.h +46 -36
- package/vendor/abseil-cpp/absl/debugging/stacktrace.cc +18 -58
- package/vendor/abseil-cpp/absl/debugging/stacktrace.h +5 -48
- package/vendor/abseil-cpp/absl/debugging/stacktrace_test.cc +10 -124
- package/vendor/abseil-cpp/absl/debugging/symbolize.cc +20 -2
- package/vendor/abseil-cpp/absl/debugging/symbolize_elf.inc +58 -106
- package/vendor/abseil-cpp/absl/debugging/symbolize_test.cc +37 -36
- package/vendor/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +4 -4
- package/vendor/abseil-cpp/absl/flags/BUILD.bazel +6 -3
- package/vendor/abseil-cpp/absl/flags/CMakeLists.txt +1 -1
- package/vendor/abseil-cpp/absl/flags/commandlineflag.h +8 -6
- package/vendor/abseil-cpp/absl/flags/commandlineflag_test.cc +1 -1
- package/vendor/abseil-cpp/absl/flags/flag_benchmark.cc +5 -5
- package/vendor/abseil-cpp/absl/flags/flag_test.cc +30 -30
- package/vendor/abseil-cpp/absl/flags/internal/flag.cc +4 -4
- package/vendor/abseil-cpp/absl/flags/internal/flag.h +6 -6
- package/vendor/abseil-cpp/absl/flags/marshalling.h +2 -28
- package/vendor/abseil-cpp/absl/flags/marshalling_test.cc +12 -11
- package/vendor/abseil-cpp/absl/flags/reflection_test.cc +1 -1
- package/vendor/abseil-cpp/absl/functional/BUILD.bazel +26 -1
- package/vendor/abseil-cpp/absl/functional/CMakeLists.txt +29 -1
- package/vendor/abseil-cpp/absl/functional/any_invocable.h +13 -14
- package/vendor/abseil-cpp/absl/functional/any_invocable_test.cc +46 -47
- package/vendor/abseil-cpp/absl/functional/bind_back.h +79 -0
- package/vendor/abseil-cpp/absl/functional/bind_back_test.cc +237 -0
- package/vendor/abseil-cpp/absl/functional/bind_front.h +7 -1
- package/vendor/abseil-cpp/absl/functional/bind_front_test.cc +4 -4
- package/vendor/abseil-cpp/absl/functional/function_ref_test.cc +2 -2
- package/vendor/abseil-cpp/absl/functional/internal/any_invocable.h +28 -28
- package/vendor/abseil-cpp/absl/functional/internal/back_binder.h +95 -0
- package/vendor/abseil-cpp/absl/functional/internal/front_binder.h +4 -4
- package/vendor/abseil-cpp/absl/functional/internal/function_ref.h +2 -2
- package/vendor/abseil-cpp/absl/functional/overload_test.cc +13 -13
- package/vendor/abseil-cpp/absl/hash/BUILD.bazel +1 -2
- package/vendor/abseil-cpp/absl/hash/CMakeLists.txt +1 -2
- package/vendor/abseil-cpp/absl/hash/hash.h +1 -1
- package/vendor/abseil-cpp/absl/hash/hash_test.cc +14 -20
- package/vendor/abseil-cpp/absl/hash/hash_testing.h +11 -9
- package/vendor/abseil-cpp/absl/hash/internal/city.cc +39 -51
- package/vendor/abseil-cpp/absl/hash/internal/hash.cc +165 -47
- package/vendor/abseil-cpp/absl/hash/internal/hash.h +82 -26
- package/vendor/abseil-cpp/absl/hash/internal/low_level_hash_test.cc +36 -1
- package/vendor/abseil-cpp/absl/hash/internal/spy_hash_state.h +8 -5
- package/vendor/abseil-cpp/absl/log/BUILD.bazel +5 -2
- package/vendor/abseil-cpp/absl/log/CMakeLists.txt +5 -3
- package/vendor/abseil-cpp/absl/log/absl_vlog_is_on.h +0 -2
- package/vendor/abseil-cpp/absl/log/internal/BUILD.bazel +15 -1
- package/vendor/abseil-cpp/absl/log/internal/log_message.cc +5 -4
- package/vendor/abseil-cpp/absl/log/internal/log_message.h +14 -0
- package/vendor/abseil-cpp/absl/log/internal/nullstream.h +1 -1
- package/vendor/abseil-cpp/absl/log/internal/proto.cc +13 -0
- package/vendor/abseil-cpp/absl/log/internal/structured_proto.cc +5 -5
- package/vendor/abseil-cpp/absl/log/internal/structured_proto.h +6 -5
- package/vendor/abseil-cpp/absl/log/internal/structured_proto_test.cc +3 -3
- package/vendor/abseil-cpp/absl/log/internal/vlog_config.cc +2 -2
- package/vendor/abseil-cpp/absl/log/internal/vlog_config_benchmark.cc +3 -3
- package/vendor/abseil-cpp/absl/log/log_format_test.cc +19 -2
- package/vendor/abseil-cpp/absl/log/log_modifier_methods_test.cc +18 -0
- package/vendor/abseil-cpp/absl/log/log_streamer.h +29 -2
- package/vendor/abseil-cpp/absl/log/log_streamer_test.cc +18 -0
- package/vendor/abseil-cpp/absl/log/scoped_mock_log_test.cc +1 -1
- package/vendor/abseil-cpp/absl/log/vlog_is_on.h +0 -2
- package/vendor/abseil-cpp/absl/log/vlog_is_on_test.cc +6 -5
- package/vendor/abseil-cpp/absl/memory/memory.h +55 -5
- package/vendor/abseil-cpp/absl/memory/memory_test.cc +55 -1
- package/vendor/abseil-cpp/absl/meta/BUILD.bazel +2 -0
- package/vendor/abseil-cpp/absl/meta/internal/requires.h +1 -1
- package/vendor/abseil-cpp/absl/meta/type_traits.h +119 -55
- package/vendor/abseil-cpp/absl/meta/type_traits_test.cc +7 -7
- package/vendor/abseil-cpp/absl/numeric/int128_test.cc +6 -6
- package/vendor/abseil-cpp/absl/profiling/BUILD.bazel +3 -1
- package/vendor/abseil-cpp/absl/profiling/hashtable.cc +0 -4
- package/vendor/abseil-cpp/absl/profiling/internal/profile_builder.cc +32 -33
- package/vendor/abseil-cpp/absl/profiling/internal/profile_builder.h +25 -2
- package/vendor/abseil-cpp/absl/profiling/internal/sample_recorder_test.cc +8 -5
- package/vendor/abseil-cpp/absl/random/BUILD.bazel +13 -1
- package/vendor/abseil-cpp/absl/random/CMakeLists.txt +23 -2
- package/vendor/abseil-cpp/absl/random/benchmarks.cc +1 -1
- package/vendor/abseil-cpp/absl/random/beta_distribution.h +2 -2
- package/vendor/abseil-cpp/absl/random/bit_gen_ref.h +26 -53
- package/vendor/abseil-cpp/absl/random/bit_gen_ref_test.cc +43 -0
- package/vendor/abseil-cpp/absl/random/discrete_distribution.h +1 -1
- package/vendor/abseil-cpp/absl/random/distributions.h +17 -17
- package/vendor/abseil-cpp/absl/random/distributions_test.cc +4 -4
- package/vendor/abseil-cpp/absl/random/exponential_distribution.h +1 -1
- package/vendor/abseil-cpp/absl/random/internal/BUILD.bazel +4 -2
- package/vendor/abseil-cpp/absl/random/internal/distribution_caller.h +8 -21
- package/vendor/abseil-cpp/absl/random/internal/fast_uniform_bits.h +1 -1
- package/vendor/abseil-cpp/absl/random/internal/generate_real.h +1 -1
- package/vendor/abseil-cpp/absl/random/internal/iostream_state_saver.h +2 -2
- package/vendor/abseil-cpp/absl/random/internal/iostream_state_saver_test.cc +3 -2
- package/vendor/abseil-cpp/absl/random/internal/mock_helpers.h +14 -40
- package/vendor/abseil-cpp/absl/random/internal/nonsecure_base.h +2 -2
- package/vendor/abseil-cpp/absl/random/internal/nonsecure_base_test.cc +2 -2
- package/vendor/abseil-cpp/absl/random/internal/pcg_engine.h +6 -6
- package/vendor/abseil-cpp/absl/random/internal/pcg_engine_test.cc +3 -2
- package/vendor/abseil-cpp/absl/random/internal/randen_detect.cc +6 -6
- package/vendor/abseil-cpp/absl/random/internal/randen_engine.h +2 -2
- package/vendor/abseil-cpp/absl/random/internal/randen_engine_test.cc +3 -2
- package/vendor/abseil-cpp/absl/random/internal/randen_test.cc +3 -2
- package/vendor/abseil-cpp/absl/random/internal/salted_seed_seq.h +6 -5
- package/vendor/abseil-cpp/absl/random/internal/seed_material.cc +4 -4
- package/vendor/abseil-cpp/absl/random/internal/seed_material.h +2 -1
- package/vendor/abseil-cpp/absl/random/internal/traits.h +21 -0
- package/vendor/abseil-cpp/absl/random/internal/traits_test.cc +5 -0
- package/vendor/abseil-cpp/absl/random/internal/uniform_helper.h +23 -23
- package/vendor/abseil-cpp/absl/random/internal/uniform_helper_test.cc +2 -1
- package/vendor/abseil-cpp/absl/random/mocking_access.h +74 -0
- package/vendor/abseil-cpp/absl/random/mocking_bit_gen.h +9 -19
- package/vendor/abseil-cpp/absl/random/uniform_real_distribution.h +1 -1
- package/vendor/abseil-cpp/absl/status/BUILD.bazel +81 -0
- package/vendor/abseil-cpp/absl/status/CMakeLists.txt +91 -0
- package/vendor/abseil-cpp/absl/status/internal/status_internal.cc +63 -18
- package/vendor/abseil-cpp/absl/status/internal/status_internal.h +26 -2
- package/vendor/abseil-cpp/absl/status/internal/status_matchers.h +22 -8
- package/vendor/abseil-cpp/absl/status/internal/statusor_internal.h +43 -43
- package/vendor/abseil-cpp/absl/status/status.cc +62 -70
- package/vendor/abseil-cpp/absl/status/status.h +249 -23
- package/vendor/abseil-cpp/absl/status/status_benchmark.cc +12 -0
- package/vendor/abseil-cpp/absl/status/status_builder.cc +196 -0
- package/vendor/abseil-cpp/absl/status/status_builder.h +978 -0
- package/vendor/abseil-cpp/absl/status/status_builder_test.cc +380 -0
- package/vendor/abseil-cpp/absl/status/status_macros.h +484 -0
- package/vendor/abseil-cpp/absl/status/status_macros_test.cc +634 -0
- package/vendor/abseil-cpp/absl/status/status_matchers.h +2 -1
- package/vendor/abseil-cpp/absl/status/status_matchers_test.cc +3 -4
- package/vendor/abseil-cpp/absl/status/status_payload_printer.h +3 -2
- package/vendor/abseil-cpp/absl/status/status_test.cc +443 -13
- package/vendor/abseil-cpp/absl/status/statusor.h +69 -36
- package/vendor/abseil-cpp/absl/status/statusor_test.cc +132 -35
- package/vendor/abseil-cpp/absl/strings/BUILD.bazel +42 -7
- package/vendor/abseil-cpp/absl/strings/CMakeLists.txt +33 -4
- package/vendor/abseil-cpp/absl/strings/ascii.h +1 -2
- package/vendor/abseil-cpp/absl/strings/atod_manual_test.cc +5 -5
- package/vendor/abseil-cpp/absl/strings/cord.cc +26 -7
- package/vendor/abseil-cpp/absl/strings/cord.h +23 -13
- package/vendor/abseil-cpp/absl/strings/cord_buffer.h +4 -2
- package/vendor/abseil-cpp/absl/strings/cord_test.cc +85 -9
- package/vendor/abseil-cpp/absl/strings/escaping.cc +176 -30
- package/vendor/abseil-cpp/absl/strings/escaping.h +12 -2
- package/vendor/abseil-cpp/absl/strings/escaping_benchmark.cc +1 -3
- package/vendor/abseil-cpp/absl/strings/escaping_test.cc +18 -18
- package/vendor/abseil-cpp/absl/strings/has_absl_stringify_test.cc +2 -2
- package/vendor/abseil-cpp/absl/strings/has_ostream_operator_test.cc +2 -2
- package/vendor/abseil-cpp/absl/strings/internal/append_and_overwrite.h +10 -10
- package/vendor/abseil-cpp/absl/strings/internal/cordz_sample_token_test.cc +1 -1
- package/vendor/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc +6 -0
- package/vendor/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.h +1 -0
- package/vendor/abseil-cpp/absl/strings/internal/escaping.cc +0 -141
- package/vendor/abseil-cpp/absl/strings/internal/escaping.h +2 -26
- package/vendor/abseil-cpp/absl/strings/internal/generic_printer_internal.h +23 -2
- package/vendor/abseil-cpp/absl/strings/internal/generic_printer_test.cc +6 -2
- package/vendor/abseil-cpp/absl/strings/internal/resize_uninitialized.h +31 -24
- package/vendor/abseil-cpp/absl/strings/internal/resize_uninitialized_test.cc +16 -41
- package/vendor/abseil-cpp/absl/strings/internal/stl_type_traits.h +39 -39
- package/vendor/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -22
- package/vendor/abseil-cpp/absl/strings/internal/str_format/bind.h +2 -2
- package/vendor/abseil-cpp/absl/strings/internal/str_format/convert_test.cc +12 -20
- package/vendor/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +510 -307
- package/vendor/abseil-cpp/absl/strings/internal/str_join_internal.h +0 -1
- package/vendor/abseil-cpp/absl/strings/internal/str_split_internal.h +9 -10
- package/vendor/abseil-cpp/absl/strings/internal/string_constant_test.cc +6 -5
- package/vendor/abseil-cpp/absl/strings/internal/stringify_sink.h +12 -0
- package/vendor/abseil-cpp/absl/strings/internal/stringify_stream.h +119 -0
- package/vendor/abseil-cpp/absl/strings/internal/stringify_stream_test.cc +111 -0
- package/vendor/abseil-cpp/absl/strings/numbers.cc +406 -0
- package/vendor/abseil-cpp/absl/strings/numbers.h +4 -0
- package/vendor/abseil-cpp/absl/strings/numbers_test.cc +33 -0
- package/vendor/abseil-cpp/absl/strings/resize_and_overwrite.h +10 -6
- package/vendor/abseil-cpp/absl/strings/str_cat.h +36 -1
- package/vendor/abseil-cpp/absl/strings/str_cat_benchmark.cc +1 -2
- package/vendor/abseil-cpp/absl/strings/str_cat_test.cc +28 -0
- package/vendor/abseil-cpp/absl/strings/str_join_test.cc +4 -4
- package/vendor/abseil-cpp/absl/strings/str_split.h +11 -6
- package/vendor/abseil-cpp/absl/strings/str_split_test.cc +13 -0
- package/vendor/abseil-cpp/absl/strings/substitute.h +2 -2
- package/vendor/abseil-cpp/absl/synchronization/BUILD.bazel +3 -0
- package/vendor/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +21 -0
- package/vendor/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +5 -0
- package/vendor/abseil-cpp/absl/synchronization/mutex.cc +13 -0
- package/vendor/abseil-cpp/absl/synchronization/mutex.h +32 -2
- package/vendor/abseil-cpp/absl/synchronization/mutex_test.cc +17 -3
- package/vendor/abseil-cpp/absl/time/BUILD.bazel +80 -0
- package/vendor/abseil-cpp/absl/time/CMakeLists.txt +73 -0
- package/vendor/abseil-cpp/absl/time/clock.h +3 -0
- package/vendor/abseil-cpp/absl/time/clock_interface.cc +71 -0
- package/vendor/abseil-cpp/absl/time/clock_interface.h +93 -0
- package/vendor/abseil-cpp/absl/time/clock_interface_test.cc +128 -0
- package/vendor/abseil-cpp/absl/time/format.cc +3 -10
- package/vendor/abseil-cpp/absl/time/format_test.cc +12 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +90 -89
- package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc +80 -5
- package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.cc +1 -2
- package/vendor/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +10 -15
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/version +1 -1
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Vancouver +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Ho_Chi_Minh +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Phnom_Penh +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Saigon +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Tbilisi +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Vientiane +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Pacific +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Chisinau +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Tiraspol +0 -0
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/zone1970.tab +1 -1
- package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/zonenow.tab +3 -3
- package/vendor/abseil-cpp/absl/time/simulated_clock.cc +225 -0
- package/vendor/abseil-cpp/absl/time/simulated_clock.h +109 -0
- package/vendor/abseil-cpp/absl/time/simulated_clock_test.cc +614 -0
- package/vendor/abseil-cpp/absl/types/BUILD.bazel +116 -0
- package/vendor/abseil-cpp/absl/types/CMakeLists.txt +100 -0
- package/vendor/abseil-cpp/absl/types/any.h +26 -4
- package/vendor/abseil-cpp/absl/types/any_span.h +1067 -0
- package/vendor/abseil-cpp/absl/types/any_span_benchmark.cc +258 -0
- package/vendor/abseil-cpp/absl/types/any_span_test.cc +1210 -0
- package/vendor/abseil-cpp/absl/types/compare.h +4 -4
- package/vendor/abseil-cpp/absl/types/internal/any_span.h +477 -0
- package/vendor/abseil-cpp/absl/types/internal/span.h +5 -6
- package/vendor/abseil-cpp/absl/types/optional.h +30 -3
- package/vendor/abseil-cpp/absl/types/optional_ref.h +295 -0
- package/vendor/abseil-cpp/absl/types/optional_ref_test.cc +370 -0
- package/vendor/abseil-cpp/absl/types/source_location.cc +18 -0
- package/vendor/abseil-cpp/absl/types/source_location.h +172 -0
- package/vendor/abseil-cpp/absl/types/source_location_test.cc +139 -0
- package/vendor/abseil-cpp/absl/types/span.h +19 -23
- package/vendor/abseil-cpp/absl/types/variant.h +75 -18
- package/vendor/abseil-cpp/absl/types/variant_test.cc +23 -23
- package/vendor/abseil-cpp/absl/utility/BUILD.bazel +1 -0
- package/vendor/abseil-cpp/absl/utility/CMakeLists.txt +1 -0
- package/vendor/abseil-cpp/absl/utility/utility.h +99 -16
- package/vendor/abseil-cpp/ci/absl_alternate_options.h +2 -0
- package/vendor/abseil-cpp/ci/linux_arm_clang-latest_libcxx_bazel.sh +10 -4
- package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_asan_bazel.sh +13 -6
- package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_bazel.sh +10 -4
- package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_tsan_bazel.sh +12 -5
- package/vendor/abseil-cpp/ci/linux_clang-latest_libstdcxx_bazel.sh +9 -2
- package/vendor/abseil-cpp/ci/linux_docker_containers.sh +4 -4
- package/vendor/abseil-cpp/ci/linux_gcc-floor_libstdcxx_bazel.sh +10 -3
- package/vendor/abseil-cpp/ci/linux_gcc-latest_libstdcxx_bazel.sh +8 -2
- package/vendor/abseil-cpp/ci/macos_xcode_bazel.sh +4 -3
- package/vendor/abseil-cpp/ci/macos_xcode_cmake.sh +2 -2
- package/vendor/abseil-cpp/ci/windows_clangcl_bazel.bat +1 -1
- package/vendor/abseil-cpp/ci/windows_msvc_bazel.bat +1 -1
- package/AGENTS.md +0 -131
- package/ARCHITECTURE.md +0 -152
- package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer.cc +0 -118
- package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer.h +0 -71
- package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer_test.cc +0 -97
package/LICENSE
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
are allowed under licenses which are fundamentally incompatible with the BSD license that this library is distributed under.
|
|
3
|
-
|
|
4
|
-
The text of the BSD license is reproduced below.
|
|
5
|
-
|
|
6
|
-
-------------------------------------------------------------------------------
|
|
7
|
-
The "New" BSD License:
|
|
8
|
-
**********************
|
|
1
|
+
BSD 3-Clause License
|
|
9
2
|
|
|
10
3
|
Copyright (c) 2005-2026, Eugene Lazutkin
|
|
11
4
|
All rights reserved.
|
|
@@ -13,19 +6,21 @@ All rights reserved.
|
|
|
13
6
|
Redistribution and use in source and binary forms, with or without
|
|
14
7
|
modification, are permitted provided that the following conditions are met:
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
24
19
|
|
|
25
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
26
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
27
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
28
|
-
DISCLAIMED.
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
29
24
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
30
25
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
31
26
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
package/README.md
CHANGED
|
@@ -172,6 +172,7 @@ While `test()` can be simulated by combining patterns with `|`, `match()` return
|
|
|
172
172
|
* `patterns` is any iterable of strings, `Buffer`s, `RegExp`, or `RE2` instances; flags (if provided) apply to the whole set.
|
|
173
173
|
* `flagsOrOptions` can be a string/`Buffer` with standard flags (`i`, `m`, `s`, `u`, `g`, `y`, `d`).
|
|
174
174
|
* `options.anchor` can be `'unanchored'` (default), `'start'`, or `'both'`.
|
|
175
|
+
* `options.maxMem` is the DFA memory budget in bytes (positive integer). Default is 8 MiB — raise it to compile sets that would otherwise fail with `"RE2.Set could not be compiled."`.
|
|
175
176
|
* `set.test(str)` returns `true` if any pattern matches and `false` otherwise.
|
|
176
177
|
* `set.match(str)` returns an array of indexes of matching patterns.
|
|
177
178
|
* This is an array of integer indices of patterns that matched sorted in ascending order.
|
|
@@ -179,6 +180,7 @@ While `test()` can be simulated by combining patterns with `|`, `match()` return
|
|
|
179
180
|
* Read-only properties:
|
|
180
181
|
* `set.size` (number of patterns), `set.flags` (`RegExp` flags as a string), `set.anchor` (anchor mode as a string)
|
|
181
182
|
* `set.source` (all patterns joined with `|` as a string), `set.sources` (individual pattern sources as an array of strings)
|
|
183
|
+
* `set.maxMem` (number) — effective DFA memory budget in bytes
|
|
182
184
|
|
|
183
185
|
It is based on [RE2::Set](https://github.com/google/re2/blob/main/re2/set.h).
|
|
184
186
|
|
|
@@ -247,6 +249,39 @@ npm install re2
|
|
|
247
249
|
The project works with other package managers but is not tested with them.
|
|
248
250
|
See the wiki for notes on [yarn](https://github.com/uhop/node-re2/wiki/Using-with-yarn) and [pnpm](https://github.com/uhop/node-re2/wiki/Using-with-pnpm).
|
|
249
251
|
|
|
252
|
+
### Supported Node.js versions
|
|
253
|
+
|
|
254
|
+
`re2` supports every non-EOL Node.js release — current and active LTS lines. As a native (`nan`) addon it runs on Node.js only, not Bun or Deno. The authoritative supported range is the `engines` field in `package.json`; it also pins the minimum patch releases the build toolchain ([`node-gyp`](https://github.com/nodejs/node-gyp) 13) requires. Check `engines` for the exact floor rather than a version repeated here.
|
|
255
|
+
|
|
256
|
+
### Install scripts (npm 12+)
|
|
257
|
+
|
|
258
|
+
`re2` downloads or builds its native binary in an `install` script. Starting with npm 12
|
|
259
|
+
(July 2026), npm does not run dependency install scripts unless the package is listed in the
|
|
260
|
+
`allowScripts` field of your project's `package.json` — without it, `npm install re2`
|
|
261
|
+
fails with `ESTRICTALLOWSCRIPTS`. npm 11.16+ still runs the scripts but prints a warning.
|
|
262
|
+
|
|
263
|
+
Allow `re2` before installing:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
npm pkg set allowScripts.re2=true --json
|
|
267
|
+
npm install re2
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Or use npm's approval tooling — note that `npm approve-scripts` only matches installed
|
|
271
|
+
packages, so under npm 12 the package has to be installed with scripts skipped first:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
npm install re2 --ignore-scripts
|
|
275
|
+
npm approve-scripts re2
|
|
276
|
+
npm rebuild re2
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
`npm approve-scripts` pins the approval to the installed version, so version updates ask again;
|
|
280
|
+
pass `--no-allow-scripts-pin` (or use the `allowScripts.re2=true` form above) to allow all
|
|
281
|
+
versions. No other package in `re2`'s dependency tree runs install scripts. For the full story see
|
|
282
|
+
[NPM 12 and install scripts](https://github.com/uhop/install-artifact-from-github/wiki/NPM-12-and-install-scripts)
|
|
283
|
+
and GitHub's official [announcement of the npm v12 breaking changes](https://github.blog/changelog/2026-06-09-upcoming-breaking-changes-for-npm-v12/).
|
|
284
|
+
|
|
250
285
|
### Precompiled artifacts
|
|
251
286
|
|
|
252
287
|
The [install script](https://github.com/uhop/install-artifact-from-github/blob/master/bin/install-from-cache.js) attempts to download a prebuilt artifact from GitHub Releases. Override the download location with the `RE2_DOWNLOAD_MIRROR` environment variable.
|
|
@@ -377,14 +412,32 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
377
412
|
|
|
378
413
|
#### Unicode classes `\p{...}` and `\P{...}`
|
|
379
414
|
|
|
380
|
-
|
|
415
|
+
node-re2 follows [MDN's Unicode character class escape reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) — the same set of property escapes that JavaScript's native `RegExp` accepts with the `u` flag.
|
|
416
|
+
|
|
417
|
+
Supported categories:
|
|
418
|
+
|
|
419
|
+
- **General_Category** — both short names (e.g., `\p{L}`, `\p{Lu}`) and long names (e.g., `\p{Letter}`, `\p{Uppercase_Letter}`). The `gc=` and `General_Category=` prefixes also work: `\p{gc=Letter}`, `\p{General_Category=Letter}`.
|
|
420
|
+
- **Script** — e.g., `\p{Script=Latin}`, `\p{sc=Cyrillic}`. ISO 15924 four-letter codes are accepted as well: `\p{sc=Latn}`.
|
|
421
|
+
- **Script_Extensions** — e.g., `\p{Script_Extensions=Hani}`, `\p{scx=Latn}`. Matches characters whose Script_Extensions list includes the named script (a superset of `Script=`).
|
|
422
|
+
- **Binary properties** — the full ECMAScript set of binary properties, including:
|
|
423
|
+
- `Alphabetic`, `ASCII`, `ASCII_Hex_Digit`, `Hex_Digit`, `White_Space`, `Math`, `Dash`, `Diacritic`, `Quotation_Mark`, `Bidi_Mirrored`, `Bidi_Control`, `Default_Ignorable_Code_Point`
|
|
424
|
+
- `Lowercase`, `Uppercase`, `Cased`, `Case_Ignorable`, `Changes_When_Lowercased`, `Changes_When_Uppercased`, `Changes_When_Casefolded`, `Changes_When_Casemapped`, `Changes_When_Titlecased`, `Changes_When_NFKC_Casefolded`
|
|
425
|
+
- `ID_Start`, `ID_Continue`, `XID_Start`, `XID_Continue`, `Pattern_Syntax`, `Pattern_White_Space`
|
|
426
|
+
- `Emoji`, `Emoji_Presentation`, `Emoji_Modifier`, `Emoji_Modifier_Base`, `Emoji_Component`, `Extended_Pictographic`, `Regional_Indicator`
|
|
427
|
+
- `Grapheme_Base`, `Grapheme_Extend`, `Extender`, `Variation_Selector`, `Join_Control`, `Logical_Order_Exception`, `Sentence_Terminal`, `Terminal_Punctuation`, `Soft_Dotted`, `Radical`, `Unified_Ideograph`, `Ideographic`, `IDS_Binary_Operator`, `IDS_Trinary_Operator`, `Noncharacter_Code_Point`, `Deprecated`, `Any`, `Assigned`
|
|
428
|
+
|
|
429
|
+
Short aliases listed in [PropertyAliases.txt](https://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt) are accepted alongside the canonical names: `\p{Alpha}` ≡ `\p{Alphabetic}`, `\p{Hex}` ≡ `\p{Hex_Digit}`, `\p{Lower}` ≡ `\p{Lowercase}`, etc.
|
|
430
|
+
|
|
431
|
+
The negated form `\P{...}` and use inside character classes (`[\p{L}\p{Emoji}]`, `[^\p{ASCII}]`) work for every category.
|
|
432
|
+
|
|
433
|
+
**Not supported:** *Properties of Strings* (`\p{Basic_Emoji}`, `\p{RGI_Emoji}`, etc.). These match multi-codepoint sequences and require the `v` flag, which RE2 does not model.
|
|
381
434
|
|
|
382
|
-
|
|
383
|
-
The exception is `Script` and `sc`, e.g., `\p{Script=Latin}` and `\p{sc=Cyrillic}`.
|
|
384
|
-
The same applies to `\P{...}`.
|
|
435
|
+
Tables are baked in at build time from Unicode 17.0. To target a newer Unicode version, bump `@unicode/unicode-XX.X.X` in `devDependencies` and run `node scripts/gen-unicode-properties.mjs`.
|
|
385
436
|
|
|
386
437
|
## Release history
|
|
387
438
|
|
|
439
|
+
- 1.25.1 *Security fix (GHSA-8hcv-x26h-mcgp): a global `replace()` using an output-amplifying template (`$'` or `` $` ``) on very large input could exceed V8's maximum string length and abort the whole process. It now throws a catchable `RangeError`, matching the built-in engine.*
|
|
440
|
+
- 1.25.0 *Full Unicode 17.0.0 property classes (Fixes #226). New `maxMem` option for `RE2.Set`. Faster matching on pure-ASCII inputs. Narrowed Node support — drops Node 25.x and older patch releases.*
|
|
388
441
|
- 1.24.1 *Support for Node 22, 24, 26 + precompiled binaries.*
|
|
389
442
|
- 1.24.0 *Fixed multi-threaded crash in worker threads (#235). Added named import: `import {RE2} from 're2'`. Added CJS test. Updated docs and dependencies.*
|
|
390
443
|
- 1.23.3 *Updated Abseil and dev dependencies.*
|
package/binding.gyp
CHANGED
|
@@ -47,12 +47,11 @@
|
|
|
47
47
|
"vendor/abseil-cpp/absl/base/internal/strerror.cc",
|
|
48
48
|
"vendor/abseil-cpp/absl/base/internal/sysinfo.cc",
|
|
49
49
|
"vendor/abseil-cpp/absl/base/internal/thread_identity.cc",
|
|
50
|
-
"vendor/abseil-cpp/absl/base/
|
|
50
|
+
"vendor/abseil-cpp/absl/base/throw_delegate.cc",
|
|
51
51
|
"vendor/abseil-cpp/absl/base/internal/unscaledcycleclock.cc",
|
|
52
52
|
"vendor/abseil-cpp/absl/container/internal/hashtablez_sampler.cc",
|
|
53
53
|
"vendor/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc",
|
|
54
54
|
"vendor/abseil-cpp/absl/container/internal/raw_hash_set.cc",
|
|
55
|
-
"vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer.cc",
|
|
56
55
|
"vendor/abseil-cpp/absl/debugging/internal/decode_rust_punycode.cc",
|
|
57
56
|
"vendor/abseil-cpp/absl/debugging/internal/demangle.cc",
|
|
58
57
|
"vendor/abseil-cpp/absl/debugging/internal/demangle_rust.cc",
|
package/lib/addon.cc
CHANGED
|
@@ -198,12 +198,15 @@ const StrVal &WrappedRE2::prepareArgument(const v8::Local<v8::Value> &arg, bool
|
|
|
198
198
|
|
|
199
199
|
auto s = t.ToLocalChecked();
|
|
200
200
|
auto argLength = utf8Length(s, isolate);
|
|
201
|
+
// Pure ASCII iff the UTF-16 length (s->Length(), O(1)) equals the UTF-8
|
|
202
|
+
// byte length: any non-ASCII char makes the byte count strictly larger.
|
|
203
|
+
bool isAscii = static_cast<size_t>(s->Length()) == argLength;
|
|
201
204
|
|
|
202
205
|
auto buffer = node::Buffer::New(isolate, s).ToLocalChecked();
|
|
203
206
|
lastCache.Reset(buffer);
|
|
204
207
|
|
|
205
208
|
auto argSize = node::Buffer::Length(buffer);
|
|
206
|
-
lastStringValue.reset(buffer, argSize, argLength, startFrom);
|
|
209
|
+
lastStringValue.reset(buffer, argSize, argLength, startFrom, false, isAscii);
|
|
207
210
|
|
|
208
211
|
return lastStringValue;
|
|
209
212
|
};
|
|
@@ -236,7 +239,7 @@ void StrVal::setIndex(size_t newIndex)
|
|
|
236
239
|
if (newIndex == index)
|
|
237
240
|
return;
|
|
238
241
|
|
|
239
|
-
if (isBuffer)
|
|
242
|
+
if (isBuffer || isAscii)
|
|
240
243
|
{
|
|
241
244
|
byteIndex = index = newIndex;
|
|
242
245
|
return;
|
|
@@ -263,10 +266,11 @@ void StrVal::setIndex(size_t newIndex)
|
|
|
263
266
|
|
|
264
267
|
static char null_buffer[] = {'\0'};
|
|
265
268
|
|
|
266
|
-
void StrVal::reset(const v8::Local<v8::Value> &arg, size_t argSize, size_t argLength, size_t newIndex, bool buffer)
|
|
269
|
+
void StrVal::reset(const v8::Local<v8::Value> &arg, size_t argSize, size_t argLength, size_t newIndex, bool buffer, bool ascii)
|
|
267
270
|
{
|
|
268
271
|
clear();
|
|
269
272
|
isBuffer = buffer;
|
|
273
|
+
isAscii = ascii;
|
|
270
274
|
size = argSize;
|
|
271
275
|
length = argLength;
|
|
272
276
|
data = size ? node::Buffer::Data(arg) : null_buffer;
|
package/lib/exec.cc
CHANGED
|
@@ -89,8 +89,8 @@ NAN_METHOD(WrappedRE2::Exec)
|
|
|
89
89
|
if (re2->hasIndices)
|
|
90
90
|
{
|
|
91
91
|
auto pair = Nan::New<v8::Array>();
|
|
92
|
-
auto offset =
|
|
93
|
-
auto length =
|
|
92
|
+
auto offset = toUtf16Index(str.isAscii, str.data + str.byteIndex, data);
|
|
93
|
+
auto length = toUtf16Index(str.isAscii, data, data + item.size());
|
|
94
94
|
Nan::Set(pair, 0, Nan::New<v8::Integer>(indexOffset + static_cast<int>(offset)));
|
|
95
95
|
Nan::Set(pair, 1, Nan::New<v8::Integer>(indexOffset + static_cast<int>(offset + length)));
|
|
96
96
|
Nan::Set(indices, i, pair);
|
|
@@ -109,13 +109,13 @@ NAN_METHOD(WrappedRE2::Exec)
|
|
|
109
109
|
result,
|
|
110
110
|
Nan::New("index").ToLocalChecked(),
|
|
111
111
|
Nan::New<v8::Integer>(indexOffset +
|
|
112
|
-
static_cast<int>(
|
|
112
|
+
static_cast<int>(toUtf16Index(str.isAscii, str.data + str.byteIndex, groups[0].data()))));
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
if (re2->global || re2->sticky)
|
|
116
116
|
{
|
|
117
117
|
re2->lastIndex +=
|
|
118
|
-
str.isBuffer ? groups[0].data() - str.data + groups[0].size() - str.byteIndex :
|
|
118
|
+
str.isBuffer ? groups[0].data() - str.data + groups[0].size() - str.byteIndex : toUtf16Index(str.isAscii, str.data + str.byteIndex, groups[0].data() + groups[0].size());
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
Nan::Set(result, Nan::New("input").ToLocalChecked(), info[0]);
|
package/lib/match.cc
CHANGED
|
@@ -122,8 +122,8 @@ NAN_METHOD(WrappedRE2::Match)
|
|
|
122
122
|
if (!re2->global && re2->hasIndices)
|
|
123
123
|
{
|
|
124
124
|
auto pair = Nan::New<v8::Array>();
|
|
125
|
-
auto offset =
|
|
126
|
-
auto length =
|
|
125
|
+
auto offset = toUtf16Index(str.isAscii, str.data + byteIndex, data);
|
|
126
|
+
auto length = toUtf16Index(str.isAscii, data, data + item.size());
|
|
127
127
|
Nan::Set(pair, 0, Nan::New<v8::Integer>(static_cast<int>(offset)));
|
|
128
128
|
Nan::Set(pair, 1, Nan::New<v8::Integer>(static_cast<int>(offset + length)));
|
|
129
129
|
Nan::Set(indices, i, pair);
|
|
@@ -140,7 +140,7 @@ NAN_METHOD(WrappedRE2::Match)
|
|
|
140
140
|
}
|
|
141
141
|
if (!re2->global)
|
|
142
142
|
{
|
|
143
|
-
Nan::Set(result, Nan::New("index").ToLocalChecked(), Nan::New<v8::Integer>(static_cast<int>(
|
|
143
|
+
Nan::Set(result, Nan::New("index").ToLocalChecked(), Nan::New<v8::Integer>(static_cast<int>(toUtf16Index(str.isAscii, str.data, groups[0].data()))));
|
|
144
144
|
Nan::Set(result, Nan::New("input").ToLocalChecked(), info[0]);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -152,7 +152,7 @@ NAN_METHOD(WrappedRE2::Match)
|
|
|
152
152
|
else if (re2->sticky)
|
|
153
153
|
{
|
|
154
154
|
re2->lastIndex +=
|
|
155
|
-
str.isBuffer ? groups[0].data() - str.data + groups[0].size() - byteIndex :
|
|
155
|
+
str.isBuffer ? groups[0].data() - str.data + groups[0].size() - byteIndex : toUtf16Index(str.isAscii, str.data + byteIndex, groups[0].data() + groups[0].size());
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
if (!re2->global)
|
package/lib/pattern.cc
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#include "./pattern.h"
|
|
2
|
+
#include "./unicode_properties.h"
|
|
2
3
|
#include "./wrapped_re2.h"
|
|
3
4
|
|
|
5
|
+
#include <cstdint>
|
|
6
|
+
#include <cstdio>
|
|
4
7
|
#include <cstring>
|
|
5
8
|
#include <map>
|
|
6
9
|
#include <string>
|
|
@@ -58,10 +61,107 @@ static std::map<std::string, std::string> unicodeClasses = {
|
|
|
58
61
|
{"Other", "C"},
|
|
59
62
|
};
|
|
60
63
|
|
|
64
|
+
static const UnicodePropertyTable *lookupTable(const UnicodePropertyTable *table, size_t count, const std::string &name)
|
|
65
|
+
{
|
|
66
|
+
for (size_t i = 0; i < count; ++i)
|
|
67
|
+
{
|
|
68
|
+
if (name == table[i].name)
|
|
69
|
+
{
|
|
70
|
+
return &table[i];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return nullptr;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static const UnicodePropertyTable *findBinaryProperty(const std::string &name)
|
|
77
|
+
{
|
|
78
|
+
return lookupTable(kBinaryProperties, kBinaryPropertiesCount, name);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static const UnicodePropertyTable *findScriptExtension(const std::string &name)
|
|
82
|
+
{
|
|
83
|
+
return lookupTable(kScriptExtensions, kScriptExtensionsCount, name);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static void appendHexRange(std::string &out, uint32_t lo, uint32_t hi)
|
|
87
|
+
{
|
|
88
|
+
char buf[32];
|
|
89
|
+
if (lo == hi)
|
|
90
|
+
{
|
|
91
|
+
std::snprintf(buf, sizeof(buf), "\\x{%X}", lo);
|
|
92
|
+
}
|
|
93
|
+
else
|
|
94
|
+
{
|
|
95
|
+
std::snprintf(buf, sizeof(buf), "\\x{%X}-\\x{%X}", lo, hi);
|
|
96
|
+
}
|
|
97
|
+
out += buf;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static void appendPropertyRanges(std::string &out, const UnicodePropertyTable *table)
|
|
101
|
+
{
|
|
102
|
+
for (size_t i = 0; i < table->count; ++i)
|
|
103
|
+
{
|
|
104
|
+
appendHexRange(out, table->ranges[i].lo, table->ranges[i].hi);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static void appendPropertyComplementRanges(std::string &out, const UnicodePropertyTable *table)
|
|
109
|
+
{
|
|
110
|
+
const uint32_t kMaxCp = 0x10FFFFu;
|
|
111
|
+
uint32_t cursor = 0;
|
|
112
|
+
for (size_t i = 0; i < table->count; ++i)
|
|
113
|
+
{
|
|
114
|
+
uint32_t lo = table->ranges[i].lo;
|
|
115
|
+
uint32_t hi = table->ranges[i].hi;
|
|
116
|
+
if (cursor < lo)
|
|
117
|
+
{
|
|
118
|
+
appendHexRange(out, cursor, lo - 1);
|
|
119
|
+
}
|
|
120
|
+
cursor = hi + 1;
|
|
121
|
+
}
|
|
122
|
+
if (cursor <= kMaxCp)
|
|
123
|
+
{
|
|
124
|
+
appendHexRange(out, cursor, kMaxCp);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static void emitProperty(std::string &out, const UnicodePropertyTable *table, bool negate, bool inCharClass)
|
|
129
|
+
{
|
|
130
|
+
if (inCharClass)
|
|
131
|
+
{
|
|
132
|
+
if (negate)
|
|
133
|
+
{
|
|
134
|
+
appendPropertyComplementRanges(out, table);
|
|
135
|
+
}
|
|
136
|
+
else
|
|
137
|
+
{
|
|
138
|
+
appendPropertyRanges(out, table);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else
|
|
142
|
+
{
|
|
143
|
+
out += negate ? "[^" : "[";
|
|
144
|
+
appendPropertyRanges(out, table);
|
|
145
|
+
out += "]";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static bool stripPrefix(const std::string &name, const char *prefix, std::string &out)
|
|
150
|
+
{
|
|
151
|
+
size_t n = std::strlen(prefix);
|
|
152
|
+
if (name.size() > n && !std::strncmp(name.c_str(), prefix, n))
|
|
153
|
+
{
|
|
154
|
+
out = name.substr(n);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
61
160
|
bool translateRegExp(const char *data, size_t size, bool multiline, std::vector<char> &buffer)
|
|
62
161
|
{
|
|
63
162
|
std::string result;
|
|
64
163
|
bool changed = false;
|
|
164
|
+
bool inCharClass = false;
|
|
65
165
|
|
|
66
166
|
if (!size)
|
|
67
167
|
{
|
|
@@ -145,9 +245,48 @@ bool translateRegExp(const char *data, size_t size, bool multiline, std::vector<
|
|
|
145
245
|
size_t j = i + 3;
|
|
146
246
|
while (j < size && data[j] != '}') ++j;
|
|
147
247
|
if (j < size) {
|
|
248
|
+
std::string name(data + i + 3, j - i - 3);
|
|
249
|
+
bool negate = data[i + 1] == 'P';
|
|
250
|
+
std::string stripped;
|
|
251
|
+
|
|
252
|
+
// Script_Extensions=Hani / scx=Hani — RE2 has no native scx;
|
|
253
|
+
// expand to a codepoint-range character class.
|
|
254
|
+
const UnicodePropertyTable *scx = nullptr;
|
|
255
|
+
if (stripPrefix(name, "Script_Extensions=", stripped) || stripPrefix(name, "scx=", stripped))
|
|
256
|
+
{
|
|
257
|
+
scx = findScriptExtension(stripped);
|
|
258
|
+
}
|
|
259
|
+
if (scx)
|
|
260
|
+
{
|
|
261
|
+
emitProperty(result, scx, negate, inCharClass);
|
|
262
|
+
i = j + 1;
|
|
263
|
+
changed = true;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// General_Category=Letter / gc=Letter — strip prefix so the
|
|
268
|
+
// existing long-name → short-name map can resolve it.
|
|
269
|
+
if (stripPrefix(name, "General_Category=", stripped) || stripPrefix(name, "gc=", stripped))
|
|
270
|
+
{
|
|
271
|
+
name = stripped;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Binary property — expand into a codepoint-range character
|
|
275
|
+
// class. Covers Emoji, Alphabetic, ASCII, ID_Start, etc.
|
|
276
|
+
const UnicodePropertyTable *binary = findBinaryProperty(name);
|
|
277
|
+
if (binary)
|
|
278
|
+
{
|
|
279
|
+
emitProperty(result, binary, negate, inCharClass);
|
|
280
|
+
i = j + 1;
|
|
281
|
+
changed = true;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Otherwise, fall through to RE2 (handles General_Category
|
|
286
|
+
// short names and Script names natively). Long GC names get
|
|
287
|
+
// translated to the short form via the existing map.
|
|
148
288
|
result += "\\";
|
|
149
289
|
result += data[i + 1];
|
|
150
|
-
std::string name(data + i + 3, j - i - 3);
|
|
151
290
|
if (unicodeClasses.find(name) != unicodeClasses.end()) {
|
|
152
291
|
name = unicodeClasses[name];
|
|
153
292
|
} else if (name.size() > 7 && !strncmp(name.c_str(), "Script=", 7)) {
|
|
@@ -198,6 +337,14 @@ bool translateRegExp(const char *data, size_t size, bool multiline, std::vector<
|
|
|
198
337
|
continue;
|
|
199
338
|
}
|
|
200
339
|
}
|
|
340
|
+
else if (ch == '[' && !inCharClass)
|
|
341
|
+
{
|
|
342
|
+
inCharClass = true;
|
|
343
|
+
}
|
|
344
|
+
else if (ch == ']' && inCharClass)
|
|
345
|
+
{
|
|
346
|
+
inCharClass = false;
|
|
347
|
+
}
|
|
201
348
|
size_t sym_size = getUtf8CharSize(ch);
|
|
202
349
|
result.append(data + i, sym_size);
|
|
203
350
|
i += sym_size;
|
package/lib/replace.cc
CHANGED
|
@@ -249,7 +249,7 @@ static Nan::Maybe<std::string> replace(
|
|
|
249
249
|
if (!re2->global && re2->sticky)
|
|
250
250
|
{
|
|
251
251
|
re2->lastIndex +=
|
|
252
|
-
replacee.isBuffer ? offset + match.size() - byteIndex :
|
|
252
|
+
replacee.isBuffer ? offset + match.size() - byteIndex : toUtf16Index(replacee.isAscii, data + byteIndex, match.data() + match.size());
|
|
253
253
|
}
|
|
254
254
|
if (match.data() == data || offset > static_cast<long>(byteIndex))
|
|
255
255
|
{
|
|
@@ -300,6 +300,7 @@ inline Nan::Maybe<std::string> replace(
|
|
|
300
300
|
const re2::StringPiece &str,
|
|
301
301
|
const v8::Local<v8::Value> &input,
|
|
302
302
|
bool useBuffers,
|
|
303
|
+
bool isAscii,
|
|
303
304
|
const std::map<std::string, int> &namedGroups)
|
|
304
305
|
{
|
|
305
306
|
std::vector<v8::Local<v8::Value>> argv;
|
|
@@ -314,7 +315,13 @@ inline Nan::Maybe<std::string> replace(
|
|
|
314
315
|
const auto data = item.data();
|
|
315
316
|
if (data)
|
|
316
317
|
{
|
|
317
|
-
|
|
318
|
+
auto buffer = Nan::CopyBuffer(data, item.size());
|
|
319
|
+
if (buffer.IsEmpty())
|
|
320
|
+
{
|
|
321
|
+
Nan::ThrowRangeError("Invalid string length");
|
|
322
|
+
return Nan::Nothing<std::string>();
|
|
323
|
+
}
|
|
324
|
+
argv.push_back(buffer.ToLocalChecked());
|
|
318
325
|
}
|
|
319
326
|
else
|
|
320
327
|
{
|
|
@@ -331,14 +338,20 @@ inline Nan::Maybe<std::string> replace(
|
|
|
331
338
|
const auto data = item.data();
|
|
332
339
|
if (data)
|
|
333
340
|
{
|
|
334
|
-
|
|
341
|
+
auto text = Nan::New(data, item.size());
|
|
342
|
+
if (text.IsEmpty())
|
|
343
|
+
{
|
|
344
|
+
Nan::ThrowRangeError("Invalid string length");
|
|
345
|
+
return Nan::Nothing<std::string>();
|
|
346
|
+
}
|
|
347
|
+
argv.push_back(text.ToLocalChecked());
|
|
335
348
|
}
|
|
336
349
|
else
|
|
337
350
|
{
|
|
338
351
|
argv.push_back(Nan::Undefined());
|
|
339
352
|
}
|
|
340
353
|
}
|
|
341
|
-
argv.push_back(Nan::New(static_cast<int>(
|
|
354
|
+
argv.push_back(Nan::New(static_cast<int>(toUtf16Index(isAscii, str.data(), groups[0].data()))));
|
|
342
355
|
}
|
|
343
356
|
argv.push_back(input);
|
|
344
357
|
|
|
@@ -418,13 +431,13 @@ static Nan::Maybe<std::string> replace(
|
|
|
418
431
|
auto offset = match.data() - data;
|
|
419
432
|
if (!re2->global && re2->sticky)
|
|
420
433
|
{
|
|
421
|
-
re2->lastIndex += replacee.isBuffer ? offset + match.size() - byteIndex :
|
|
434
|
+
re2->lastIndex += replacee.isBuffer ? offset + match.size() - byteIndex : toUtf16Index(replacee.isAscii, data + byteIndex, match.data() + match.size());
|
|
422
435
|
}
|
|
423
436
|
if (match.data() == data || offset > static_cast<long>(byteIndex))
|
|
424
437
|
{
|
|
425
438
|
result += std::string(data + byteIndex, offset - byteIndex);
|
|
426
439
|
}
|
|
427
|
-
const auto part = replace(replacer, groups, str, input, useBuffers, namedGroups);
|
|
440
|
+
const auto part = replace(replacer, groups, str, input, useBuffers, replacee.isAscii, namedGroups);
|
|
428
441
|
if (part.IsNothing())
|
|
429
442
|
{
|
|
430
443
|
return part;
|
|
@@ -550,8 +563,21 @@ NAN_METHOD(WrappedRE2::Replace)
|
|
|
550
563
|
|
|
551
564
|
if (replacee.isBuffer)
|
|
552
565
|
{
|
|
553
|
-
|
|
566
|
+
auto buffer = Nan::CopyBuffer(result.data(), result.size());
|
|
567
|
+
if (buffer.IsEmpty())
|
|
568
|
+
{
|
|
569
|
+
Nan::ThrowRangeError("Invalid string length");
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
info.GetReturnValue().Set(buffer.ToLocalChecked());
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
// over-max-length result -> empty MaybeLocal; ToLocalChecked() would abort()
|
|
576
|
+
auto text = Nan::New(result);
|
|
577
|
+
if (text.IsEmpty())
|
|
578
|
+
{
|
|
579
|
+
Nan::ThrowRangeError("Invalid string length");
|
|
554
580
|
return;
|
|
555
581
|
}
|
|
556
|
-
info.GetReturnValue().Set(
|
|
582
|
+
info.GetReturnValue().Set(text.ToLocalChecked());
|
|
557
583
|
}
|
package/lib/search.cc
CHANGED
|
@@ -25,7 +25,7 @@ NAN_METHOD(WrappedRE2::Search)
|
|
|
25
25
|
|
|
26
26
|
if (re2->regexp.Match(str, 0, str.size, re2->sticky ? re2::RE2::ANCHOR_START : re2::RE2::UNANCHORED, &match, 1))
|
|
27
27
|
{
|
|
28
|
-
info.GetReturnValue().Set(static_cast<int>(str.isBuffer ? match.data() - str.data :
|
|
28
|
+
info.GetReturnValue().Set(static_cast<int>(str.isBuffer ? match.data() - str.data : toUtf16Index(str.isAscii, str.data, match.data())));
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
|
package/lib/set.cc
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include "./wrapped_re2.h"
|
|
5
5
|
|
|
6
6
|
#include <algorithm>
|
|
7
|
+
#include <cmath>
|
|
7
8
|
#include <memory>
|
|
8
9
|
#include <string>
|
|
9
10
|
#include <vector>
|
|
@@ -270,6 +271,58 @@ static bool parseAnchor(const v8::Local<v8::Value> &arg, re2::RE2::Anchor &ancho
|
|
|
270
271
|
return false;
|
|
271
272
|
}
|
|
272
273
|
|
|
274
|
+
static bool parseMaxMem(const v8::Local<v8::Value> &arg, int64_t &maxMem, bool &assigned)
|
|
275
|
+
{
|
|
276
|
+
assigned = false;
|
|
277
|
+
|
|
278
|
+
if (arg.IsEmpty() || arg->IsUndefined() || arg->IsNull())
|
|
279
|
+
{
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
if (!arg->IsObject() || arg->IsString())
|
|
283
|
+
{
|
|
284
|
+
return true; // string-only form: anchor; no maxMem possible
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
auto context = Nan::GetCurrentContext();
|
|
288
|
+
auto object = arg->ToObject(context).ToLocalChecked();
|
|
289
|
+
auto maybe = Nan::Get(object, Nan::New("maxMem").ToLocalChecked());
|
|
290
|
+
if (maybe.IsEmpty())
|
|
291
|
+
{
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
auto value = maybe.ToLocalChecked();
|
|
295
|
+
if (value->IsUndefined() || value->IsNull())
|
|
296
|
+
{
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
if (!value->IsNumber())
|
|
300
|
+
{
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
auto maybeNum = value->NumberValue(context);
|
|
305
|
+
if (maybeNum.IsNothing())
|
|
306
|
+
{
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
double num = maybeNum.FromJust();
|
|
310
|
+
if (!std::isfinite(num) || num < 1.0 || std::floor(num) != num)
|
|
311
|
+
{
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
// Keep within safe integer range; RE2's max_mem is int64_t but JS Number
|
|
315
|
+
// can only represent integers exactly up to 2^53 - 1.
|
|
316
|
+
if (num > 9007199254740991.0)
|
|
317
|
+
{
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
maxMem = static_cast<int64_t>(num);
|
|
322
|
+
assigned = true;
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
|
|
273
326
|
static bool fillInput(const v8::Local<v8::Value> &arg, StrVal &str, v8::Local<v8::Object> &keepAlive)
|
|
274
327
|
{
|
|
275
328
|
if (node::Buffer::HasInstance(arg))
|
|
@@ -389,12 +442,18 @@ NAN_METHOD(WrappedRE2Set::New)
|
|
|
389
442
|
}
|
|
390
443
|
|
|
391
444
|
re2::RE2::Anchor anchor = re2::RE2::UNANCHORED;
|
|
445
|
+
int64_t maxMem = 0;
|
|
446
|
+
bool maxMemAssigned = false;
|
|
392
447
|
if (!optionsArg.IsEmpty())
|
|
393
448
|
{
|
|
394
449
|
if (!parseAnchor(optionsArg, anchor))
|
|
395
450
|
{
|
|
396
451
|
return Nan::ThrowTypeError("Invalid anchor option for RE2.Set.");
|
|
397
452
|
}
|
|
453
|
+
if (!parseMaxMem(optionsArg, maxMem, maxMemAssigned))
|
|
454
|
+
{
|
|
455
|
+
return Nan::ThrowTypeError("Invalid maxMem option for RE2.Set: must be a positive integer.");
|
|
456
|
+
}
|
|
398
457
|
}
|
|
399
458
|
|
|
400
459
|
std::vector<v8::Local<v8::Value>> patterns;
|
|
@@ -488,6 +547,10 @@ NAN_METHOD(WrappedRE2Set::New)
|
|
|
488
547
|
options.set_one_line(!flags.multiline);
|
|
489
548
|
options.set_dot_nl(flags.dotAll);
|
|
490
549
|
options.set_log_errors(false);
|
|
550
|
+
if (maxMemAssigned)
|
|
551
|
+
{
|
|
552
|
+
options.set_max_mem(maxMem);
|
|
553
|
+
}
|
|
491
554
|
|
|
492
555
|
std::unique_ptr<WrappedRE2Set> set(new WrappedRE2Set(options, anchor, flagsToString(flags)));
|
|
493
556
|
std::vector<char> buffer;
|
|
@@ -754,6 +817,17 @@ NAN_GETTER(WrappedRE2Set::GetAnchor)
|
|
|
754
817
|
info.GetReturnValue().Set(Nan::New(anchorToString(re2set->anchor)).ToLocalChecked());
|
|
755
818
|
}
|
|
756
819
|
|
|
820
|
+
NAN_GETTER(WrappedRE2Set::GetMaxMem)
|
|
821
|
+
{
|
|
822
|
+
auto re2set = Nan::ObjectWrap::Unwrap<WrappedRE2Set>(info.This());
|
|
823
|
+
if (!re2set)
|
|
824
|
+
{
|
|
825
|
+
info.GetReturnValue().Set(0);
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(static_cast<double>(re2set->maxMem)));
|
|
829
|
+
}
|
|
830
|
+
|
|
757
831
|
v8::Local<v8::Function> WrappedRE2Set::Init()
|
|
758
832
|
{
|
|
759
833
|
Nan::EscapableHandleScope scope;
|
|
@@ -772,6 +846,7 @@ v8::Local<v8::Function> WrappedRE2Set::Init()
|
|
|
772
846
|
Nan::SetAccessor(instanceTemplate, Nan::New("source").ToLocalChecked(), GetSource);
|
|
773
847
|
Nan::SetAccessor(instanceTemplate, Nan::New("size").ToLocalChecked(), GetSize);
|
|
774
848
|
Nan::SetAccessor(instanceTemplate, Nan::New("anchor").ToLocalChecked(), GetAnchor);
|
|
849
|
+
Nan::SetAccessor(instanceTemplate, Nan::New("maxMem").ToLocalChecked(), GetMaxMem);
|
|
775
850
|
|
|
776
851
|
auto isolate = v8::Isolate::GetCurrent();
|
|
777
852
|
auto data = getAddonData(isolate);
|
package/lib/test.cc
CHANGED
|
@@ -37,7 +37,7 @@ NAN_METHOD(WrappedRE2::Test)
|
|
|
37
37
|
if (re2->regexp.Match(str, str.byteIndex, str.size, re2->sticky ? re2::RE2::ANCHOR_START : re2::RE2::UNANCHORED, &match, 1))
|
|
38
38
|
{
|
|
39
39
|
re2->lastIndex +=
|
|
40
|
-
str.isBuffer ? match.data() - str.data + match.size() - str.byteIndex :
|
|
40
|
+
str.isBuffer ? match.data() - str.data + match.size() - str.byteIndex : toUtf16Index(str.isAscii, str.data + str.byteIndex, match.data() + match.size());
|
|
41
41
|
info.GetReturnValue().Set(true);
|
|
42
42
|
return;
|
|
43
43
|
}
|