re2 2.7.0 → 2.15.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8d6ed54b0c51625b38158c82813c6b38f0151a637c224e6b6450ea2ebc9e00c
4
- data.tar.gz: 9550936b7959af3654b58efdc07be5f5c38c3a41a4a657382878f06020f9081e
3
+ metadata.gz: 92d0c12dc899d22cf74c00bbda8f89f29665b32d10fcc9a8eb9ca01f671c62f5
4
+ data.tar.gz: 1aea6bbc6cc7168a5a16fbb52b244535ed422707f63ebac59c2a0d1ae81bfbaf
5
5
  SHA512:
6
- metadata.gz: f9b91c79e3efea56df671b887740c25e09e1d09e12383b6a3071c6bfcfccc01da3ea26431b34c6794fcf710bce17a71459f389911770ea06601048cc038c508f
7
- data.tar.gz: a0f0d0971fa7074d5eccfca90bcdf058fcc02584f87c59531105cf04f1be872b97b213a4e17a5637e560b723f061ca95b2b7f4c782ce13a34234dfd134c3793e
6
+ metadata.gz: ff0c9014a05c741b9bc7f3b9961c9e36a97cc4e48f7546779a4ceca60ff225c84a3930acd7daf5d58225aa051b0d6ee475ce778c66ecd3f3643d522bd105b72b
7
+ data.tar.gz: ea0b6da27aa3e568821dc48a452fcd3e4e16600fe66e3964702d37c56e2f9247d16130e95a60c83684530633937b810539cf45d5c0f842f88d4ccc5b35dafa53
data/Gemfile CHANGED
@@ -1,5 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gemspec
4
6
 
5
7
  gem "rake", "> 12.3.2"
8
+
9
+ group :memcheck, optional: true do
10
+ gem "ruby_memcheck"
11
+ end
data/README.md CHANGED
@@ -6,8 +6,8 @@ Python".
6
6
 
7
7
  [![Build Status](https://github.com/mudge/re2/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mudge/re2/actions)
8
8
 
9
- **Current version:** 2.7.0
10
- **Bundled RE2 version:** libre2.11 (2023-11-01)
9
+ **Current version:** 2.15.0
10
+ **Bundled RE2 version:** libre2.11 (2024-07-02)
11
11
 
12
12
  ```ruby
13
13
  RE2('h.*o').full_match?("hello") #=> true
@@ -257,20 +257,19 @@ RE2(non_latin1_pattern.encode("ISO-8859-1"), utf8: false).match(non_latin1_text.
257
257
 
258
258
  This gem requires the following to run:
259
259
 
260
- * [Ruby](https://www.ruby-lang.org/en/) 2.6 to 3.3
260
+ * [Ruby](https://www.ruby-lang.org/en/) 2.6 to 3.4
261
261
 
262
262
  It supports the following RE2 ABI versions:
263
263
 
264
- * libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to 2023-11-01)
264
+ * libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to 2024-07-02)
265
265
 
266
266
  ### Native gems
267
267
 
268
268
  Where possible, a pre-compiled native gem will be provided for the following platforms:
269
269
 
270
270
  * Linux
271
- * `aarch64-linux` and `arm-linux` (requires [glibc](https://www.gnu.org/software/libc/) 2.29+)
272
- * `x86-linux` and `x86_64-linux` (requires [glibc](https://www.gnu.org/software/libc/) 2.17+)
273
- * [musl](https://musl.libc.org/)-based systems such as [Alpine](https://alpinelinux.org) are supported as long as a [glibc-compatible library is installed](https://wiki.alpinelinux.org/wiki/Running_glibc_programs)
271
+ * `aarch64-linux`, `arm-linux`, `x86-linux` and `x86_64-linux` (requires [glibc](https://www.gnu.org/software/libc/) 2.29+, RubyGems 3.3.22+ and Bundler 2.3.21+)
272
+ * [musl](https://musl.libc.org/)-based systems such as [Alpine](https://alpinelinux.org) are supported with Bundler 2.5.6+
274
273
  * macOS `x86_64-darwin` and `arm64-darwin`
275
274
  * Windows `x64-mingw32` and `x64-mingw-ucrt`
276
275
 
@@ -279,18 +278,18 @@ Where possible, a pre-compiled native gem will be provided for the following pla
279
278
  SHA256 checksums are included in the [release notes](https://github.com/mudge/re2/releases) for each version and can be checked with `sha256sum`, e.g.
280
279
 
281
280
  ```console
282
- $ gem fetch re2 -v 2.6.0
283
- Fetching re2-2.6.0-arm64-darwin.gem
284
- Downloaded re2-2.6.0-arm64-darwin
285
- $ sha256sum re2-2.6.0-arm64-darwin.gem
286
- ba6fda7a29cd16179d5401c1b4917ba204c92e5ca9d25df80d840ed76fca439f re2-2.6.0-arm64-darwin.gem
281
+ $ gem fetch re2 -v 2.14.0
282
+ Fetching re2-2.14.0-arm64-darwin.gem
283
+ Downloaded re2-2.14.0-arm64-darwin
284
+ $ sha256sum re2-2.14.0-arm64-darwin.gem
285
+ 3c922d54a44ac88499f6391bc2f9740559381deaf7f4e49eef5634cf32efc2ce re2-2.14.0-arm64-darwin.gem
287
286
  ```
288
287
 
289
288
  [GPG](https://www.gnupg.org/) signatures are attached to each release (the assets ending in `.sig`) and can be verified if you import [our signing key `0x39AC3530070E0F75`](https://mudge.name/39AC3530070E0F75.asc) (or fetch it from a public keyserver, e.g. `gpg --keyserver keyserver.ubuntu.com --recv-key 0x39AC3530070E0F75`):
290
289
 
291
290
  ```console
292
- $ gpg --verify re2-2.6.0-arm64-darwin.gem.sig re2-2.6.0-arm64-darwin.gem
293
- gpg: Signature made Wed 27 Dec 19:26:53 2023 GMT
291
+ $ gpg --verify re2-2.14.0-arm64-darwin.gem.sig re2-2.14.0-arm64-darwin.gem
292
+ gpg: Signature made Fri 2 Aug 12:39:12 2024 BST
294
293
  gpg: using RSA key 702609D9C790F45B577D7BEC39AC3530070E0F75
295
294
  gpg: Good signature from "Paul Mucur <mudge@mudge.name>" [unknown]
296
295
  gpg: aka "Paul Mucur <paul@ghostcassette.com>" [unknown]
@@ -328,9 +327,10 @@ You will need a full compiler toolchain for compiling Ruby C extensions (see
328
327
  [Nokogiri's "The Compiler
329
328
  Toolchain"](https://nokogiri.org/tutorials/installing_nokogiri.html#appendix-a-the-compiler-toolchain))
330
329
  plus the toolchain required for compiling the vendored version of RE2 and its
331
- dependency [Abseil][] which includes
332
- [CMake](https://cmake.org) and a compiler with C++14 support such as
333
- [clang](http://clang.llvm.org/) 3.4 or [gcc](https://gcc.gnu.org/) 5. On
330
+ dependency [Abseil][] which includes [CMake](https://cmake.org), a compiler
331
+ with C++14 support such as [clang](http://clang.llvm.org/) 3.4 or
332
+ [gcc](https://gcc.gnu.org/) 5 and a recent version of
333
+ [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/). On
334
334
  Windows, you'll also need pkgconf 2.1.0+ to avoid [`undefined reference`
335
335
  errors](https://github.com/pkgconf/pkgconf/issues/322) when attempting to
336
336
  compile Abseil.
data/Rakefile CHANGED
@@ -1,58 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rake/extensiontask'
4
- require 'rspec/core/rake_task'
5
4
  require 'rake_compiler_dock'
6
- require 'yaml'
5
+ require 'rspec/core/rake_task'
7
6
 
8
7
  require_relative 'ext/re2/recipes'
9
8
 
10
- CLEAN.include FileList['**/*{.o,.so,.dylib,.bundle}'],
11
- FileList['**/extconf.h'],
12
- FileList['**/Makefile'],
13
- FileList['pkg/']
14
-
15
- CLOBBER.include FileList['**/tmp'],
16
- FileList['**/*.log'],
17
- FileList['doc/**'],
18
- FileList['tmp/']
19
- CLOBBER.add("ports/*").exclude(%r{ports/archives$})
20
-
21
- RE2_GEM_SPEC = Gem::Specification.load('re2.gemspec')
22
-
23
- task :prepare do
24
- puts "Preparing project for gem building..."
25
- recipes = load_recipes
26
- recipes.each { |recipe| recipe.download }
27
- end
9
+ re2_gemspec = Gem::Specification.load('re2.gemspec')
10
+ abseil_recipe, re2_recipe = load_recipes
28
11
 
29
- task gem: :prepare
12
+ # Add Abseil and RE2's latest archives to the gem files. (Note these will be
13
+ # removed from the precompiled native gems.)
14
+ abseil_archive = File.join("ports/archives", File.basename(abseil_recipe.files[0][:url]))
15
+ re2_archive = File.join("ports/archives", File.basename(re2_recipe.files[0][:url]))
30
16
 
31
- Gem::PackageTask.new(RE2_GEM_SPEC) do |p|
32
- p.need_zip = false
33
- p.need_tar = false
34
- end
17
+ re2_gemspec.files << abseil_archive
18
+ re2_gemspec.files << re2_archive
35
19
 
36
- CROSS_RUBY_VERSIONS = %w[3.3.0 3.2.0 3.1.0 3.0.0 2.7.0 2.6.0].join(':')
37
- CROSS_RUBY_PLATFORMS = %w[
38
- aarch64-linux
39
- arm-linux
20
+ cross_platforms = %w[
21
+ aarch64-linux-gnu
22
+ aarch64-linux-musl
23
+ arm-linux-gnu
24
+ arm-linux-musl
40
25
  arm64-darwin
41
26
  x64-mingw-ucrt
42
27
  x64-mingw32
43
- x86-linux
28
+ x86-linux-gnu
29
+ x86-linux-musl
44
30
  x86-mingw32
45
31
  x86_64-darwin
46
- x86_64-linux
32
+ x86_64-linux-gnu
33
+ x86_64-linux-musl
47
34
  ].freeze
48
35
 
49
- ENV['RUBY_CC_VERSION'] = CROSS_RUBY_VERSIONS
36
+ ENV['RUBY_CC_VERSION'] = '3.4.1:3.3.5:3.2.6:3.1.6:3.0.7:2.7.8:2.6.10'
37
+
38
+ Gem::PackageTask.new(re2_gemspec).define
50
39
 
51
- Rake::ExtensionTask.new('re2', RE2_GEM_SPEC) do |e|
40
+ Rake::ExtensionTask.new('re2', re2_gemspec) do |e|
52
41
  e.cross_compile = true
53
42
  e.cross_config_options << '--enable-cross-build'
54
43
  e.config_options << '--disable-system-libraries'
55
- e.cross_platform = CROSS_RUBY_PLATFORMS
44
+ e.cross_platform = cross_platforms
56
45
  e.cross_compiling do |spec|
57
46
  spec.files.reject! { |path| File.fnmatch?('ports/*', path) }
58
47
  spec.dependencies.reject! { |dep| dep.name == 'mini_portile2' }
@@ -61,72 +50,45 @@ end
61
50
 
62
51
  RSpec::Core::RakeTask.new(:spec)
63
52
 
64
- namespace 'gem' do
65
- def gem_builder(platform)
66
- # use Task#invoke because the pkg/*gem task is defined at runtime
67
- Rake::Task["native:#{platform}"].invoke
68
- Rake::Task["pkg/#{RE2_GEM_SPEC.full_name}-#{Gem::Platform.new(platform)}.gem"].invoke
53
+ begin
54
+ require 'ruby_memcheck'
55
+ require 'ruby_memcheck/rspec/rake_task'
56
+
57
+ namespace :spec do
58
+ RubyMemcheck::RSpec::RakeTask.new(valgrind: :compile)
69
59
  end
60
+ rescue LoadError
61
+ # Only define the spec:valgrind task if ruby_memcheck is installed
62
+ end
70
63
 
71
- CROSS_RUBY_PLATFORMS.each do |platform|
72
- # The Linux x86 image (ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x86_64-linux)
73
- # is based on CentOS 7 and has two versions of cmake installed:
74
- # a 2.8 version in /usr/bin and a 3.25 in /usr/local/bin. The latter is needed by abseil.
75
- cmake =
76
- case platform
77
- when 'x86_64-linux', 'x86-linux'
78
- '/usr/local/bin/cmake'
79
- else
80
- 'cmake'
81
- end
82
-
83
- desc "build native gem for #{platform} platform"
64
+ namespace :gem do
65
+ cross_platforms.each do |platform|
66
+
67
+ # Compile each platform's native gem, packaging up the result. Note we add
68
+ # /usr/local/bin to the PATH as it contains the newest version of CMake in
69
+ # the rake-compiler-dock images.
70
+ desc "Compile and build native gem for #{platform} platform"
84
71
  task platform do
85
72
  RakeCompilerDock.sh <<~SCRIPT, platform: platform, verbose: true
86
73
  gem install bundler --no-document &&
87
74
  bundle &&
88
- bundle exec rake gem:#{platform}:builder CMAKE=#{cmake}
75
+ bundle exec rake native:#{platform} pkg/#{re2_gemspec.full_name}-#{Gem::Platform.new(platform)}.gem PATH="/usr/local/bin:$PATH"
89
76
  SCRIPT
90
77
  end
91
-
92
- namespace platform do
93
- desc "build native gem for #{platform} platform (guest container)"
94
- task 'builder' do
95
- gem_builder(platform)
96
- end
97
- end
98
78
  end
99
-
100
- desc 'build all native gems'
101
- multitask 'native' => CROSS_RUBY_PLATFORMS
102
- end
103
-
104
- def add_file_to_gem(relative_source_path)
105
- dest_path = File.join(gem_build_path, relative_source_path)
106
- dest_dir = File.dirname(dest_path)
107
-
108
- mkdir_p dest_dir unless Dir.exist?(dest_dir)
109
- rm_f dest_path if File.exist?(dest_path)
110
- safe_ln relative_source_path, dest_path
111
-
112
- RE2_GEM_SPEC.files << relative_source_path
113
79
  end
114
80
 
115
- def gem_build_path
116
- File.join 'pkg', RE2_GEM_SPEC.full_name
81
+ # Set up file tasks for Abseil and RE2's archives so they are automatically
82
+ # downloaded when required by the gem task.
83
+ file abseil_archive do
84
+ abseil_recipe.download
117
85
  end
118
86
 
119
- def add_vendored_libraries
120
- dependencies = YAML.load_file(File.join(File.dirname(__FILE__), 'dependencies.yml'))
121
- abseil_archive = File.join('ports', 'archives', "#{dependencies['abseil']['version']}.tar.gz")
122
- libre2_archive = File.join('ports', 'archives', "re2-#{dependencies['libre2']['version']}.tar.gz")
123
-
124
- add_file_to_gem(abseil_archive)
125
- add_file_to_gem(libre2_archive)
87
+ file re2_archive do
88
+ re2_recipe.download
126
89
  end
127
90
 
128
- task gem_build_path do
129
- add_vendored_libraries
130
- end
91
+ task default: :spec
131
92
 
132
- task default: [:compile, :spec]
93
+ CLEAN.add("lib/**/*.{o,so,bundle}", "pkg")
94
+ CLOBBER.add("ports")
data/dependencies.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  libre2:
3
- version: '2023-11-01'
4
- sha256: 4e6593ac3c71de1c0f322735bc8b0492a72f66ffccfad76e259fa21c41d27d8a
3
+ version: '2024-07-02'
4
+ sha256: eb2df807c781601c14a260a507a5bb4509be1ee626024cb45acbd57cb9d4032b
5
5
  abseil:
6
- version: '20230802.1'
7
- sha256: 987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed
6
+ version: '20240722.0'
7
+ sha256: f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3
data/ext/re2/extconf.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # re2 (https://github.com/mudge/re2)
2
4
  # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
3
5
  # backtracking regular expression engines like those used in PCRE, Perl, and
@@ -9,370 +11,322 @@
9
11
  require 'mkmf'
10
12
  require_relative 'recipes'
11
13
 
12
- RE2_HELP_MESSAGE = <<~HELP
13
- USAGE: ruby #{$0} [options]
14
+ module RE2
15
+ class Extconf
16
+ def configure
17
+ configure_cross_compiler
14
18
 
15
- Flags that are always valid:
19
+ if config_system_libraries?
20
+ build_with_system_libraries
21
+ else
22
+ build_with_vendored_libraries
23
+ end
16
24
 
17
- --enable-system-libraries
18
- Use system libraries instead of building and using the packaged libraries.
25
+ build_extension
19
26
 
20
- --disable-system-libraries
21
- Use the packaged libraries, and ignore the system libraries. This is the default.
27
+ create_makefile("re2")
28
+ end
22
29
 
30
+ def print_help
31
+ print(<<~TEXT)
32
+ USAGE: ruby #{$0} [options]
23
33
 
24
- Flags only used when using system libraries:
34
+ Flags that are always valid:
25
35
 
26
- Related to re2 library:
36
+ --enable-system-libraries
37
+ Use system libraries instead of building and using the packaged libraries.
27
38
 
28
- --with-re2-dir=DIRECTORY
29
- Look for re2 headers and library in DIRECTORY.
39
+ --disable-system-libraries
40
+ Use the packaged libraries, and ignore the system libraries. This is the default.
30
41
 
31
42
 
32
- Flags only used when building and using the packaged libraries:
43
+ Flags only used when using system libraries:
33
44
 
34
- --enable-cross-build
35
- Enable cross-build mode. (You probably do not want to set this manually.)
45
+ Related to re2 library:
36
46
 
47
+ --with-re2-dir=DIRECTORY
48
+ Look for re2 headers and library in DIRECTORY.
37
49
 
38
- Environment variables used:
39
50
 
40
- CC
41
- Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
51
+ Flags only used when building and using the packaged libraries:
42
52
 
43
- CPPFLAGS
44
- If this string is accepted by the C preprocessor, add it to the flags passed to the C preprocessor
53
+ --enable-cross-build
54
+ Enable cross-build mode. (You probably do not want to set this manually.)
45
55
 
46
- CFLAGS
47
- If this string is accepted by the compiler, add it to the flags passed to the compiler
48
56
 
49
- LDFLAGS
50
- If this string is accepted by the linker, add it to the flags passed to the linker
57
+ Environment variables used:
51
58
 
52
- LIBS
53
- Add this string to the flags passed to the linker
54
- HELP
59
+ CC
60
+ Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
55
61
 
56
- #
57
- # utility functions
58
- #
59
- def config_system_libraries?
60
- enable_config("system-libraries", ENV.key?('RE2_USE_SYSTEM_LIBRARIES'))
61
- end
62
+ CPPFLAGS
63
+ If this string is accepted by the C preprocessor, add it to the flags passed to the C preprocessor
62
64
 
63
- def config_cross_build?
64
- enable_config("cross-build")
65
- end
65
+ CFLAGS
66
+ If this string is accepted by the compiler, add it to the flags passed to the compiler
66
67
 
67
- def concat_flags(*args)
68
- args.compact.join(" ")
69
- end
68
+ LDFLAGS
69
+ If this string is accepted by the linker, add it to the flags passed to the linker
70
70
 
71
- def do_help
72
- print(RE2_HELP_MESSAGE)
73
- exit!(0)
74
- end
71
+ LIBS
72
+ Add this string to the flags passed to the linker
73
+ TEXT
74
+ end
75
75
 
76
- def darwin?
77
- RbConfig::CONFIG["target_os"].include?("darwin")
78
- end
76
+ private
79
77
 
80
- def windows?
81
- RbConfig::CONFIG["target_os"].match?(/mingw|mswin/)
82
- end
78
+ def configure_cross_compiler
79
+ RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
80
+ RbConfig::CONFIG["CXX"] = RbConfig::MAKEFILE_CONFIG["CXX"] = ENV["CXX"] if ENV["CXX"]
81
+ end
83
82
 
84
- def freebsd?
85
- RbConfig::CONFIG["target_os"].include?("freebsd")
86
- end
83
+ def build_with_system_libraries
84
+ header_dirs = [
85
+ "/usr/local/include",
86
+ "/opt/homebrew/include",
87
+ "/usr/include"
88
+ ]
87
89
 
88
- def target_host
89
- # We use 'host' to set compiler prefix for cross-compiling. Prefer host_alias over host. And
90
- # prefer i686 (what external dev tools use) to i386 (what ruby's configure.ac emits).
91
- host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
92
- host.gsub(/i386/, "i686")
93
- end
90
+ lib_dirs = [
91
+ "/usr/local/lib",
92
+ "/opt/homebrew/lib",
93
+ "/usr/lib"
94
+ ]
94
95
 
95
- def target_arch
96
- RbConfig::CONFIG['arch']
97
- end
96
+ dir_config("re2", header_dirs, lib_dirs)
98
97
 
99
- def with_temp_dir
100
- Dir.mktmpdir do |temp_dir|
101
- Dir.chdir(temp_dir) do
102
- yield
98
+ unless have_library("re2")
99
+ abort "You must have re2 installed and specified with --with-re2-dir, please see https://github.com/google/re2/wiki/Install"
100
+ end
103
101
  end
104
- end
105
- end
106
102
 
107
- #
108
- # main
109
- #
110
- do_help if arg_config('--help')
103
+ def build_with_vendored_libraries
104
+ message "Building re2 using packaged libraries.\n"
111
105
 
112
- if ENV["CC"]
113
- RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
114
- RbConfig::CONFIG["CC"] = ENV["CC"]
115
- end
106
+ abseil_recipe, re2_recipe = load_recipes
116
107
 
117
- if ENV["CXX"]
118
- RbConfig::MAKEFILE_CONFIG["CXX"] = ENV["CXX"]
119
- RbConfig::CONFIG["CXX"] = ENV["CXX"]
120
- end
108
+ process_recipe(abseil_recipe) do |recipe|
109
+ recipe.configure_options << '-DABSL_PROPAGATE_CXX_STD=ON'
110
+ # Workaround for https://github.com/abseil/abseil-cpp/issues/1510
111
+ recipe.configure_options << '-DCMAKE_CXX_FLAGS=-DABSL_FORCE_WAITER_MODE=4' if MiniPortile.windows?
112
+ end
121
113
 
122
- def build_extension(static_p = false)
123
- # Enable optional warnings but disable deprecated register warning for Ruby 2.6 support
124
- $CFLAGS << " -Wall -Wextra -funroll-loops"
125
- $CPPFLAGS << " -Wno-register"
114
+ process_recipe(re2_recipe) do |recipe|
115
+ recipe.configure_options += [
116
+ # Specify Abseil's path so RE2 will prefer that over any system Abseil
117
+ "-DCMAKE_PREFIX_PATH=#{abseil_recipe.path}",
118
+ '-DCMAKE_CXX_FLAGS=-DNDEBUG'
119
+ ]
120
+ end
126
121
 
127
- # Pass -x c++ to force gcc to compile the test program
128
- # as C++ (as it will end in .c by default).
129
- compile_options = "-x c++"
122
+ pc_file = File.join(re2_recipe.lib_path, 'pkgconfig', 're2.pc')
123
+ pkg_config_paths = [
124
+ File.join(abseil_recipe.lib_path, 'pkgconfig'),
125
+ File.join(re2_recipe.lib_path, 'pkgconfig')
126
+ ]
130
127
 
131
- have_library("stdc++")
132
- have_header("stdint.h")
133
- have_func("rb_gc_mark_movable") # introduced in Ruby 2.7
128
+ static_pkg_config(pc_file, pkg_config_paths)
129
+ end
134
130
 
135
- if !static_p and !have_library("re2")
136
- abort "You must have re2 installed and specified with --with-re2-dir, please see https://github.com/google/re2/wiki/Install"
137
- end
131
+ def build_extension
132
+ # Enable optional warnings but disable deprecated register warning for Ruby 2.6 support
133
+ $CFLAGS << " -Wall -Wextra -funroll-loops"
134
+ $CXXFLAGS << " -Wall -Wextra -funroll-loops"
135
+ $CPPFLAGS << " -Wno-register"
138
136
 
139
- minimal_program = <<SRC
140
- #include <re2/re2.h>
141
- int main() { return 0; }
142
- SRC
137
+ # Pass -x c++ to force gcc to compile the test program
138
+ # as C++ (as it will end in .c by default).
139
+ compile_options = +"-x c++"
143
140
 
144
- re2_requires_version_flag = checking_for("re2 that requires explicit C++ version flag") do
145
- !try_compile(minimal_program, compile_options)
146
- end
141
+ have_library("stdc++")
142
+ have_header("stdint.h")
143
+ have_func("rb_gc_mark_movable") # introduced in Ruby 2.7
144
+
145
+ minimal_program = <<~SRC
146
+ #include <re2/re2.h>
147
+ int main() { return 0; }
148
+ SRC
147
149
 
148
- if re2_requires_version_flag
149
- # Recent versions of re2 depend directly on abseil, which requires a
150
- # compiler with C++14 support (see
151
- # https://github.com/abseil/abseil-cpp/issues/1127 and
152
- # https://github.com/abseil/abseil-cpp/issues/1431). However, the
153
- # `std=c++14` flag doesn't appear to suffice; we need at least
154
- # `std=c++17`.
155
- abort "Cannot compile re2 with your compiler: recent versions require C++14 support." unless %w[c++20 c++17 c++11 c++0x].any? do |std|
156
- checking_for("re2 that compiles with #{std} standard") do
157
- if try_compile(minimal_program, compile_options + " -std=#{std}")
158
- compile_options << " -std=#{std}"
159
- $CPPFLAGS << " -std=#{std}"
160
-
161
- true
150
+ re2_requires_version_flag = checking_for("re2 that requires explicit C++ version flag") do
151
+ !try_compile(minimal_program, compile_options)
152
+ end
153
+
154
+ if re2_requires_version_flag
155
+ # Recent versions of re2 depend directly on abseil, which requires a
156
+ # compiler with C++14 support (see
157
+ # https://github.com/abseil/abseil-cpp/issues/1127 and
158
+ # https://github.com/abseil/abseil-cpp/issues/1431). However, the
159
+ # `std=c++14` flag doesn't appear to suffice; we need at least
160
+ # `std=c++17`.
161
+ abort "Cannot compile re2 with your compiler: recent versions require C++14 support." unless %w[c++20 c++17 c++11 c++0x].any? do |std|
162
+ checking_for("re2 that compiles with #{std} standard") do
163
+ if try_compile(minimal_program, compile_options + " -std=#{std}")
164
+ compile_options << " -std=#{std}"
165
+ $CPPFLAGS << " -std=#{std}"
166
+
167
+ true
168
+ end
169
+ end
162
170
  end
163
171
  end
164
- end
165
- end
166
172
 
167
- # Determine which version of re2 the user has installed.
168
- # Revision d9f8806c004d added an `endpos` argument to the
169
- # generic Match() function.
170
- #
171
- # To test for this, try to compile a simple program that uses
172
- # the newer form of Match() and set a flag if it is successful.
173
- checking_for("RE2::Match() with endpos argument") do
174
- test_re2_match_signature = <<SRC
175
- #include <re2/re2.h>
176
-
177
- int main() {
178
- RE2 pattern("test");
179
- re2::StringPiece *match;
180
- pattern.Match("test", 0, 0, RE2::UNANCHORED, match, 0);
181
-
182
- return 0;
183
- }
184
- SRC
185
-
186
- if try_compile(test_re2_match_signature, compile_options)
187
- $defs.push("-DHAVE_ENDPOS_ARGUMENT")
188
- end
189
- end
173
+ # Determine which version of re2 the user has installed.
174
+ # Revision d9f8806c004d added an `endpos` argument to the
175
+ # generic Match() function.
176
+ #
177
+ # To test for this, try to compile a simple program that uses
178
+ # the newer form of Match() and set a flag if it is successful.
179
+ checking_for("RE2::Match() with endpos argument") do
180
+ test_re2_match_signature = <<~SRC
181
+ #include <re2/re2.h>
182
+
183
+ int main() {
184
+ RE2 pattern("test");
185
+ re2::StringPiece *match;
186
+ pattern.Match("test", 0, 0, RE2::UNANCHORED, match, 0);
187
+
188
+ return 0;
189
+ }
190
+ SRC
191
+
192
+ if try_compile(test_re2_match_signature, compile_options)
193
+ $defs.push("-DHAVE_ENDPOS_ARGUMENT")
194
+ end
195
+ end
190
196
 
191
- checking_for("RE2::Set::Match() with error information") do
192
- test_re2_set_match_signature = <<SRC
193
- #include <vector>
194
- #include <re2/re2.h>
195
- #include <re2/set.h>
197
+ checking_for("RE2::Set::Match() with error information") do
198
+ test_re2_set_match_signature = <<~SRC
199
+ #include <vector>
200
+ #include <re2/re2.h>
201
+ #include <re2/set.h>
196
202
 
197
- int main() {
198
- RE2::Set s(RE2::DefaultOptions, RE2::UNANCHORED);
199
- s.Add("foo", NULL);
200
- s.Compile();
203
+ int main() {
204
+ RE2::Set s(RE2::DefaultOptions, RE2::UNANCHORED);
205
+ s.Add("foo", NULL);
206
+ s.Compile();
201
207
 
202
- std::vector<int> v;
203
- RE2::Set::ErrorInfo ei;
204
- s.Match("foo", &v, &ei);
208
+ std::vector<int> v;
209
+ RE2::Set::ErrorInfo ei;
210
+ s.Match("foo", &v, &ei);
205
211
 
206
- return 0;
207
- }
208
- SRC
212
+ return 0;
213
+ }
214
+ SRC
209
215
 
210
- if try_compile(test_re2_set_match_signature, compile_options)
211
- $defs.push("-DHAVE_ERROR_INFO_ARGUMENT")
216
+ if try_compile(test_re2_set_match_signature, compile_options)
217
+ $defs.push("-DHAVE_ERROR_INFO_ARGUMENT")
218
+ end
219
+ end
212
220
  end
213
- end
214
- end
215
-
216
- def process_recipe(recipe)
217
- cross_build_p = config_cross_build?
218
- message "Cross build is #{cross_build_p ? "enabled" : "disabled"}.\n"
219
-
220
- recipe.host = target_host
221
- # Ensure x64-mingw-ucrt and x64-mingw32 use different library paths since the host
222
- # is the same (x86_64-w64-mingw32).
223
- recipe.target = File.join(recipe.target, target_arch) if cross_build_p
224
221
 
225
- yield recipe
226
-
227
- checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
228
- name = recipe.name
229
- version = recipe.version
222
+ def static_pkg_config(pc_file, pkg_config_paths)
223
+ ENV["PKG_CONFIG_PATH"] = [*pkg_config_paths, ENV["PKG_CONFIG_PATH"]].compact.join(File::PATH_SEPARATOR)
224
+
225
+ static_library_paths = minimal_pkg_config(pc_file, '--libs-only-L', '--static')
226
+ .shellsplit
227
+ .map { |flag| flag.delete_prefix('-L') }
228
+
229
+ # Replace all -l flags that can be found in one of the static library
230
+ # paths with the absolute path instead.
231
+ minimal_pkg_config(pc_file, '--libs-only-l', '--static')
232
+ .shellsplit
233
+ .each do |flag|
234
+ lib = "lib#{flag.delete_prefix('-l')}.#{$LIBEXT}"
235
+
236
+ if (static_lib_path = static_library_paths.find { |path| File.exist?(File.join(path, lib)) })
237
+ $libs << ' ' << File.join(static_lib_path, lib).shellescape
238
+ else
239
+ $libs << ' ' << flag.shellescape
240
+ end
241
+ end
230
242
 
231
- if File.exist?(checkpoint)
232
- message("Building re2 with a packaged version of #{name}-#{version}.\n")
233
- else
234
- message(<<~EOM)
235
- ---------- IMPORTANT NOTICE ----------
236
- Building re2 with a packaged version of #{name}-#{version}.
237
- Configuration options: #{recipe.configure_options.shelljoin}
238
- EOM
243
+ append_ldflags(minimal_pkg_config(pc_file, '--libs-only-other', '--static'))
239
244
 
240
- unless recipe.patch_files.empty?
241
- message("The following patches are being applied:\n")
245
+ incflags = minimal_pkg_config(pc_file, '--cflags-only-I')
246
+ $INCFLAGS = [incflags, $INCFLAGS].join(" ").strip
242
247
 
243
- recipe.patch_files.each do |patch|
244
- message(" - %s\n" % File.basename(patch))
245
- end
248
+ cflags = minimal_pkg_config(pc_file, '--cflags-only-other')
249
+ $CFLAGS = [$CFLAGS, cflags].join(" ").strip
250
+ $CXXFLAGS = [$CXXFLAGS, cflags].join(" ").strip
246
251
  end
247
252
 
248
- # Use a temporary base directory to reduce filename lengths since
249
- # Windows can hit a limit of 250 characters (CMAKE_OBJECT_PATH_MAX).
250
- with_temp_dir { recipe.cook }
251
-
252
- FileUtils.touch(checkpoint)
253
- end
253
+ def process_recipe(recipe)
254
+ cross_build_p = config_cross_build?
255
+ message "Cross build is #{cross_build_p ? "enabled" : "disabled"}.\n"
254
256
 
255
- recipe.activate
256
- end
257
+ recipe.host = target_host
258
+ # Ensure x64-mingw-ucrt and x64-mingw32 use different library paths since the host
259
+ # is the same (x86_64-w64-mingw32).
260
+ recipe.target = File.join(recipe.target, target_arch) if cross_build_p
257
261
 
258
- def build_with_system_libraries
259
- header_dirs = [
260
- "/usr/local/include",
261
- "/opt/homebrew/include",
262
- "/usr/include"
263
- ]
262
+ yield recipe
264
263
 
265
- lib_dirs = [
266
- "/usr/local/lib",
267
- "/opt/homebrew/lib",
268
- "/usr/lib"
269
- ]
264
+ checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
265
+ name = recipe.name
266
+ version = recipe.version
270
267
 
271
- dir_config("re2", header_dirs, lib_dirs)
268
+ if File.exist?(checkpoint)
269
+ message("Building re2 with a packaged version of #{name}-#{version}.\n")
270
+ else
271
+ message(<<~EOM)
272
+ ---------- IMPORTANT NOTICE ----------
273
+ Building re2 with a packaged version of #{name}-#{version}.
274
+ Configuration options: #{recipe.configure_options.shelljoin}
275
+ EOM
272
276
 
273
- build_extension
274
- end
277
+ # Use a temporary base directory to reduce filename lengths since
278
+ # Windows can hit a limit of 250 characters (CMAKE_OBJECT_PATH_MAX).
279
+ Dir.mktmpdir { |dir| Dir.chdir(dir) { recipe.cook } }
275
280
 
276
- def libflag_to_filename(ldflag)
277
- case ldflag
278
- when /\A-l(.+)/
279
- "lib#{Regexp.last_match(1)}.#{$LIBEXT}"
280
- end
281
- end
281
+ FileUtils.touch(checkpoint)
282
+ end
283
+ end
282
284
 
283
- # This method does a number of things to ensure the final shared library
284
- # is compiled statically with the vendored libraries:
285
- #
286
- # 1. For -L<path> flags, ensure that any `ports` paths are prioritized just
287
- # in case there are installed libraries that might take precedence.
288
- # 2. For -l<lib> flags, convert the library to the static library with a
289
- # full path and substitute the absolute static library. For example,
290
- # -lre2 maps to /path/to/ports/<arch>/libre2/<version>/lib/libre2.a.
291
- #
292
- # This is needed because when building the extension, Ruby appears to
293
- # insert `-L#{RbConfig::CONFIG['exec_prefix']}/lib` first. If libre2 is
294
- # in installed in that location then the extension will link against the
295
- # system library instead of the vendored library.
296
- def add_flag(arg, lib_paths)
297
- case arg
298
- when /\A-L(.+)\z/
299
- # Prioritize ports' directories
300
- lib_dir = Regexp.last_match(1)
301
- $LIBPATH =
302
- if lib_dir.start_with?(PACKAGE_ROOT_DIR + "/")
303
- [lib_dir] | $LIBPATH
285
+ # See MiniPortile2's minimal_pkg_config:
286
+ # https://github.com/flavorjones/mini_portile/blob/52fb0bc41c89a10f1ac7b5abcf0157e059194374/lib/mini_portile2/mini_portile.rb#L760-L783
287
+ # and Ruby's pkg_config:
288
+ # https://github.com/ruby/ruby/blob/c505bb0ca0fd61c7ae931d26451f11122a2644e9/lib/mkmf.rb#L1916-L2004
289
+ def minimal_pkg_config(pc_file, *options)
290
+ if ($PKGCONFIG ||=
291
+ (pkgconfig = MakeMakefile.with_config("pkg-config") {MakeMakefile.config_string("PKG_CONFIG") || "pkg-config"}) &&
292
+ MakeMakefile.find_executable0(pkgconfig) && pkgconfig)
293
+ pkgconfig = $PKGCONFIG
304
294
  else
305
- $LIBPATH | [lib_dir]
295
+ raise RuntimeError, "pkg-config is not found"
306
296
  end
307
- when /\A-l./
308
- filename = libflag_to_filename(arg)
309
-
310
- added = false
311
- lib_paths.each do |path|
312
- static_lib = File.join(path, filename)
313
297
 
314
- next unless File.exist?(static_lib)
298
+ response = xpopen([pkgconfig, *options, pc_file], err: %i[child out], &:read)
299
+ raise RuntimeError, response unless $?.success?
315
300
 
316
- $LDFLAGS << " " << static_lib
317
- added = true
318
- break
301
+ response.strip
319
302
  end
320
303
 
321
- append_ldflags(arg.shellescape) unless added
322
- else
323
- append_ldflags(arg.shellescape)
324
- end
325
- end
326
-
327
- def add_static_ldflags(flags, lib_paths)
328
- flags.strip.shellsplit.each { |flag| add_flag(flag, lib_paths) }
329
- end
330
-
331
- def build_with_vendored_libraries
332
- message "Building re2 using packaged libraries.\n"
304
+ def config_system_libraries?
305
+ enable_config("system-libraries", ENV.key?('RE2_USE_SYSTEM_LIBRARIES'))
306
+ end
333
307
 
334
- abseil_recipe, re2_recipe = load_recipes
308
+ def config_cross_build?
309
+ enable_config("cross-build")
310
+ end
335
311
 
336
- process_recipe(abseil_recipe) do |recipe|
337
- recipe.configure_options += ['-DABSL_PROPAGATE_CXX_STD=ON', '-DCMAKE_CXX_VISIBILITY_PRESET=hidden']
338
- # Workaround for https://github.com/abseil/abseil-cpp/issues/1510
339
- recipe.configure_options += ['-DCMAKE_CXX_FLAGS=-DABSL_FORCE_WAITER_MODE=4'] if windows?
340
- end
312
+ # We use 'host' to set compiler prefix for cross-compiling. Prefer host_alias over host. And
313
+ # prefer i686 (what external dev tools use) to i386 (what ruby's configure.ac emits).
314
+ def target_host
315
+ host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
316
+ host.gsub(/i386/, "i686")
317
+ end
341
318
 
342
- process_recipe(re2_recipe) do |recipe|
343
- recipe.configure_options += ["-DCMAKE_PREFIX_PATH=#{abseil_recipe.path}", '-DCMAKE_CXX_FLAGS=-DNDEBUG',
344
- '-DCMAKE_CXX_VISIBILITY_PRESET=hidden']
319
+ def target_arch
320
+ RbConfig::CONFIG['arch']
321
+ end
345
322
  end
346
-
347
- dir_config("re2", File.join(re2_recipe.path, 'include'), File.join(re2_recipe.path, 'lib'))
348
- dir_config("abseil", File.join(abseil_recipe.path, 'include'), File.join(abseil_recipe.path, 'lib'))
349
-
350
- pkg_config_paths = [
351
- "#{abseil_recipe.path}/lib/pkgconfig",
352
- "#{re2_recipe.path}/lib/pkgconfig"
353
- ].join(File::PATH_SEPARATOR)
354
-
355
- pkg_config_paths = "#{ENV['PKG_CONFIG_PATH']}#{File::PATH_SEPARATOR}#{pkg_config_paths}" if ENV['PKG_CONFIG_PATH']
356
-
357
- ENV['PKG_CONFIG_PATH'] = pkg_config_paths
358
- pc_file = File.join(re2_recipe.path, 'lib', 'pkgconfig', 're2.pc')
359
-
360
- raise 'Please install the `pkg-config` utility!' unless find_executable('pkg-config')
361
-
362
- # See https://bugs.ruby-lang.org/issues/18490, broken in Ruby 3.1 but fixed in Ruby 3.2.
363
- flags = xpopen(['pkg-config', '--libs', '--static', pc_file], err: %i[child out], &:read)
364
-
365
- raise 'Unable to run pkg-config --libs --static' unless $?.success?
366
-
367
- lib_paths = [File.join(abseil_recipe.path, 'lib'), File.join(re2_recipe.path, 'lib')]
368
- add_static_ldflags(flags, lib_paths)
369
- build_extension(true)
370
323
  end
371
324
 
372
- if config_system_libraries?
373
- build_with_system_libraries
374
- else
375
- build_with_vendored_libraries
325
+ extconf = RE2::Extconf.new
326
+
327
+ if arg_config('--help')
328
+ extconf.print_help
329
+ exit!(true)
376
330
  end
377
331
 
378
- create_makefile("re2")
332
+ extconf.configure
data/ext/re2/re2.cc CHANGED
@@ -743,8 +743,9 @@ static VALUE re2_matchdata_inspect(const VALUE self) {
743
743
  if (match == Qnil) {
744
744
  output << "nil";
745
745
  } else {
746
- output << "\"" << re2::StringPiece(RSTRING_PTR(match),
747
- RSTRING_LEN(match)) << "\"";
746
+ output << "\"";
747
+ output.write(RSTRING_PTR(match), RSTRING_LEN(match));
748
+ output << "\"";
748
749
  }
749
750
  }
750
751
 
data/ext/re2/recipes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # re2 (https://github.com/mudge/re2)
2
4
  # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
3
5
  # backtracking regular expression engines like those used in PCRE, Perl, and
@@ -7,27 +9,7 @@
7
9
  # Released under the BSD Licence, please see LICENSE.txt
8
10
 
9
11
  PACKAGE_ROOT_DIR = File.expand_path('../..', __dir__)
10
- REQUIRED_MINI_PORTILE_VERSION = '~> 2.8.5' # keep this version in sync with the one in the gemspec
11
-
12
- def build_recipe(name, version)
13
- require 'rubygems'
14
- gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
15
- require 'mini_portile2'
16
-
17
- MiniPortileCMake.new(name, version).tap do |recipe|
18
- recipe.target = File.join(PACKAGE_ROOT_DIR, 'ports')
19
- recipe.configure_options += [
20
- # abseil needs a C++14 compiler
21
- '-DCMAKE_CXX_STANDARD=14',
22
- # needed for building the C extension shared library with -fPIC
23
- '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
24
- # ensures pkg-config and installed libraries will be in lib, not lib64
25
- '-DCMAKE_INSTALL_LIBDIR=lib'
26
- ]
27
-
28
- yield recipe
29
- end
30
- end
12
+ REQUIRED_MINI_PORTILE_VERSION = '~> 2.8.7' # keep this version in sync with the one in the gemspec
31
13
 
32
14
  def load_recipes
33
15
  require 'yaml'
@@ -49,3 +31,24 @@ def load_recipes
49
31
 
50
32
  [abseil_recipe, re2_recipe]
51
33
  end
34
+
35
+ def build_recipe(name, version)
36
+ require 'rubygems'
37
+ gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
38
+ require 'mini_portile2'
39
+
40
+ MiniPortileCMake.new(name, version).tap do |recipe|
41
+ recipe.target = File.join(PACKAGE_ROOT_DIR, 'ports')
42
+ recipe.configure_options += [
43
+ # abseil needs a C++14 compiler
44
+ '-DCMAKE_CXX_STANDARD=14',
45
+ # needed for building the C extension shared library with -fPIC
46
+ '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
47
+ # ensures pkg-config and installed libraries will be in lib, not lib64
48
+ '-DCMAKE_INSTALL_LIBDIR=lib',
49
+ '-DCMAKE_CXX_VISIBILITY_PRESET=hidden'
50
+ ]
51
+
52
+ yield recipe
53
+ end
54
+ end
data/lib/re2/regexp.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # re2 (https://github.com/mudge/re2)
2
4
  # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
3
5
  # backtracking regular expression engines like those used in PCRE, Perl, and
data/lib/re2/scanner.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # re2 (https://github.com/mudge/re2)
2
4
  # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
3
5
  # backtracking regular expression engines like those used in PCRE, Perl, and
data/lib/re2/string.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # re2 (https://github.com/mudge/re2)
2
4
  # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
3
5
  # backtracking regular expression engines like those used in PCRE, Perl, and
data/lib/re2/version.rb CHANGED
@@ -10,5 +10,5 @@
10
10
 
11
11
 
12
12
  module RE2
13
- VERSION = "2.7.0"
13
+ VERSION = "2.15.0"
14
14
  end
data/lib/re2.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # re2 (https://github.com/mudge/re2)
2
4
  # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
3
5
  # backtracking regular expression engines like those used in PCRE, Perl, and
Binary file
data/re2.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/re2/version'
2
4
 
3
5
  Gem::Specification.new do |s|
@@ -38,8 +40,8 @@ Gem::Specification.new do |s|
38
40
  "spec/re2/set_spec.rb",
39
41
  "spec/re2/scanner_spec.rb"
40
42
  ]
41
- s.add_development_dependency("rake-compiler", "~> 1.2.5")
42
- s.add_development_dependency("rake-compiler-dock", "~> 1.4.0")
43
+ s.add_development_dependency("rake-compiler", "~> 1.2.7")
44
+ s.add_development_dependency("rake-compiler-dock", "~> 1.8.0")
43
45
  s.add_development_dependency("rspec", "~> 3.2")
44
- s.add_runtime_dependency("mini_portile2", "~> 2.8.5") # keep version in sync with extconf.rb
46
+ s.add_runtime_dependency("mini_portile2", "~> 2.8.7") # keep version in sync with extconf.rb
45
47
  end
data/spec/kernel_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Kernel do
2
4
  describe ".RE2" do
3
5
  it "returns an RE2::Regexp instance given a pattern" do
@@ -1,4 +1,5 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'objspace'
3
4
 
4
5
  RSpec.describe RE2::MatchData do
@@ -142,7 +143,7 @@ RSpec.describe RE2::MatchData do
142
143
  end
143
144
 
144
145
  it "returns a copy, not the actual original" do
145
- string = "bob"
146
+ string = +"bob"
146
147
  re = RE2::Regexp.new('(\D+)').match(string)
147
148
 
148
149
  expect(re.string).to_not equal(string)
@@ -155,7 +156,7 @@ RSpec.describe RE2::MatchData do
155
156
  end
156
157
 
157
158
  it "does not copy the string if it was already frozen" do
158
- string = "bob".freeze
159
+ string = "bob"
159
160
  re = RE2::Regexp.new('(\D+)').match(string)
160
161
 
161
162
  expect(re.string).to equal(string)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe RE2::Regexp do
2
4
  describe "#initialize" do
3
5
  it "returns an instance given only a pattern" do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe RE2::Scanner do
4
4
  describe "#regexp" do
data/spec/re2/set_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe RE2::Set do
2
4
  describe "#initialize" do
3
5
  it "returns an instance given no args" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "re2/string"
2
4
 
3
5
  class String
data/spec/re2_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe RE2 do
2
4
  describe ".Replace" do
3
5
  it "only replaces the first occurrence of the pattern" do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "re2"
2
4
 
3
5
  # To test passing objects that can be coerced to a String.
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: re2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Mucur
8
8
  - Stan Hu
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-01-20 00:00:00.000000000 Z
11
+ date: 2025-01-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake-compiler
@@ -17,28 +16,28 @@ dependencies:
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: 1.2.5
19
+ version: 1.2.7
21
20
  type: :development
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: 1.2.5
26
+ version: 1.2.7
28
27
  - !ruby/object:Gem::Dependency
29
28
  name: rake-compiler-dock
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - "~>"
33
32
  - !ruby/object:Gem::Version
34
- version: 1.4.0
33
+ version: 1.8.0
35
34
  type: :development
36
35
  prerelease: false
37
36
  version_requirements: !ruby/object:Gem::Requirement
38
37
  requirements:
39
38
  - - "~>"
40
39
  - !ruby/object:Gem::Version
41
- version: 1.4.0
40
+ version: 1.8.0
42
41
  - !ruby/object:Gem::Dependency
43
42
  name: rspec
44
43
  requirement: !ruby/object:Gem::Requirement
@@ -59,17 +58,16 @@ dependencies:
59
58
  requirements:
60
59
  - - "~>"
61
60
  - !ruby/object:Gem::Version
62
- version: 2.8.5
61
+ version: 2.8.7
63
62
  type: :runtime
64
63
  prerelease: false
65
64
  version_requirements: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - "~>"
68
67
  - !ruby/object:Gem::Version
69
- version: 2.8.5
68
+ version: 2.8.7
70
69
  description: Ruby bindings to RE2, "a fast, safe, thread-friendly alternative to backtracking
71
70
  regular expression engines like those used in PCRE, Perl, and Python".
72
- email:
73
71
  executables: []
74
72
  extensions:
75
73
  - ext/re2/extconf.rb
@@ -90,8 +88,8 @@ files:
90
88
  - lib/re2/scanner.rb
91
89
  - lib/re2/string.rb
92
90
  - lib/re2/version.rb
93
- - ports/archives/20230802.1.tar.gz
94
- - ports/archives/re2-2023-11-01.tar.gz
91
+ - ports/archives/20240722.0.tar.gz
92
+ - ports/archives/re2-2024-07-02.tar.gz
95
93
  - re2.gemspec
96
94
  - spec/kernel_spec.rb
97
95
  - spec/re2/match_data_spec.rb
@@ -105,7 +103,6 @@ homepage: https://github.com/mudge/re2
105
103
  licenses:
106
104
  - BSD-3-Clause
107
105
  metadata: {}
108
- post_install_message:
109
106
  rdoc_options: []
110
107
  require_paths:
111
108
  - lib
@@ -120,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
117
  - !ruby/object:Gem::Version
121
118
  version: '0'
122
119
  requirements: []
123
- rubygems_version: 3.4.19
124
- signing_key:
120
+ rubygems_version: 3.6.2
125
121
  specification_version: 4
126
122
  summary: Ruby bindings to RE2.
127
123
  test_files:
Binary file
Binary file