re2 2.21.0-arm-linux-gnu → 2.23.0-arm-linux-gnu

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: dbdd9a1a46ac6e196b2bbf90e31684c9559f87d9ab4febad73a5f4cf34c9ed77
4
- data.tar.gz: 44e9874ed9f6e4454d5707144553d1abd79be711fdfcea9727bb2480179d9924
3
+ metadata.gz: 2fccb691ddb9d1034842da5f68bd6490c343808dc0b2f21c8be78174ae34cd1e
4
+ data.tar.gz: 5a0b4a51a247c7106e964bc488ffe19b963b0131b3db8bc49acc4c941bd23ceb
5
5
  SHA512:
6
- metadata.gz: 283e6f9ae2614b8ac86d0dda2fcb8b3f24f52ea4a0bfd1a0abfef467a5aed358408adc8718ae35357c885b39e8e197a39129556d9e07bc69c1d9ff19b05a2ecf
7
- data.tar.gz: 6b98326df023569622d7906f1a4b7e83a2a8c0038413aaad6cc9ea2f1200f6340adb927313818c600bbe84ebcae3a7d2819cc7d773e9c82a9458993c00aad437
6
+ metadata.gz: 33a2cfa82572b1a02a6ff18ac3c218386851c4617b70063b62b2dc7cc1ed529291717aaee8d945226fce588009d62aa7580e13712813aebe7930a640145b995b
7
+ data.tar.gz: a31470e62fc7105d5ecddeff40dc41ac2c1b1da11e8ee2794d12529f6855969e1c930823f36a79976e38d15d0f62b714d5458f71ec52d9e011b0d2093c3fdc2d
data/README.md CHANGED
@@ -6,7 +6,7 @@ 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.21.0
9
+ **Current version:** 2.23.0
10
10
  **Bundled RE2 version:** libre2.11 (2025-11-05)
11
11
 
12
12
  ```ruby
@@ -260,7 +260,7 @@ RE2(non_latin1_pattern.encode("ISO-8859-1"), utf8: false).match(non_latin1_text.
260
260
 
261
261
  This gem requires the following to run:
262
262
 
263
- * [Ruby](https://www.ruby-lang.org/en/) 3.1 to 3.4
263
+ * [Ruby](https://www.ruby-lang.org/en/) 3.1 to 4.0
264
264
 
265
265
  It supports the following RE2 ABI versions:
266
266
 
data/Rakefile CHANGED
@@ -33,7 +33,7 @@ cross_platforms = %w[
33
33
  x86_64-linux-musl
34
34
  ].freeze
35
35
 
36
- RakeCompilerDock.set_ruby_cc_version("~> 3.1")
36
+ RakeCompilerDock.set_ruby_cc_version("~> 3.1", "~> 4.0")
37
37
 
38
38
  Gem::PackageTask.new(re2_gemspec).define
39
39
 
@@ -74,7 +74,6 @@ namespace :gem do
74
74
  echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null &&
75
75
  sudo apt-get update &&
76
76
  sudo apt-get install -y cmake=3.22.2-0kitware1ubuntu20.04.1 cmake-data=3.22.2-0kitware1ubuntu20.04.1 &&
77
- rbenv shell 3.1.6 &&
78
77
  gem install bundler --no-document &&
79
78
  bundle install &&
80
79
  bundle exec rake native:#{platform} pkg/#{re2_gemspec.full_name}-#{Gem::Platform.new(platform)}.gem PATH="/usr/local/bin:$PATH"
data/ext/re2/re2.cc CHANGED
@@ -326,6 +326,11 @@ static VALUE re2_scanner_rewind(VALUE self) {
326
326
  delete c->input;
327
327
  c->input = new(std::nothrow) re2::StringPiece(
328
328
  RSTRING_PTR(c->text), RSTRING_LEN(c->text));
329
+ if (c->input == 0) {
330
+ rb_raise(rb_eNoMemError,
331
+ "not enough memory to allocate StringPiece for input");
332
+ }
333
+
329
334
  c->eof = false;
330
335
 
331
336
  return self;
@@ -412,8 +417,8 @@ static re2::StringPiece *re2_matchdata_find_match(VALUE idx, const VALUE self) {
412
417
 
413
418
  int id;
414
419
 
415
- if (FIXNUM_P(idx)) {
416
- id = FIX2INT(idx);
420
+ if (RB_INTEGER_TYPE_P(idx)) {
421
+ id = NUM2INT(idx);
417
422
  } else if (SYMBOL_P(idx)) {
418
423
  const std::map<std::string, int>& groups = p->pattern->NamedCapturingGroups();
419
424
  std::map<std::string, int>::const_iterator search = groups.find(rb_id2name(SYM2ID(idx)));
@@ -681,10 +686,10 @@ static VALUE re2_matchdata_aref(int argc, VALUE *argv, const VALUE self) {
681
686
  std::string(RSTRING_PTR(idx), RSTRING_LEN(idx)), self);
682
687
  } else if (SYMBOL_P(idx)) {
683
688
  return re2_matchdata_named_match(rb_id2name(SYM2ID(idx)), self);
684
- } else if (!NIL_P(rest) || !FIXNUM_P(idx) || FIX2INT(idx) < 0) {
689
+ } else if (!NIL_P(rest) || !RB_INTEGER_TYPE_P(idx) || NUM2INT(idx) < 0) {
685
690
  return rb_ary_aref(argc, argv, re2_matchdata_to_a(self));
686
691
  } else {
687
- return re2_matchdata_nth_match(FIX2INT(idx), self);
692
+ return re2_matchdata_nth_match(NUM2INT(idx), self);
688
693
  }
689
694
  }
690
695
 
@@ -1421,7 +1426,7 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
1421
1426
  RE2::Anchor anchor = RE2::UNANCHORED;
1422
1427
 
1423
1428
  if (RTEST(options)) {
1424
- if (FIXNUM_P(options)) {
1429
+ if (RB_INTEGER_TYPE_P(options)) {
1425
1430
  n = NUM2INT(options);
1426
1431
 
1427
1432
  if (n < 0) {
@@ -1435,8 +1440,6 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
1435
1440
  VALUE endpos_option = rb_hash_aref(options, ID2SYM(id_endpos));
1436
1441
  if (!NIL_P(endpos_option)) {
1437
1442
  #ifdef HAVE_ENDPOS_ARGUMENT
1438
- Check_Type(endpos_option, T_FIXNUM);
1439
-
1440
1443
  endpos = NUM2INT(endpos_option);
1441
1444
 
1442
1445
  if (endpos < 0) {
@@ -1465,8 +1468,6 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
1465
1468
 
1466
1469
  VALUE submatches_option = rb_hash_aref(options, ID2SYM(id_submatches));
1467
1470
  if (!NIL_P(submatches_option)) {
1468
- Check_Type(submatches_option, T_FIXNUM);
1469
-
1470
1471
  n = NUM2INT(submatches_option);
1471
1472
 
1472
1473
  if (n < 0) {
@@ -1482,8 +1483,6 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
1482
1483
 
1483
1484
  VALUE startpos_option = rb_hash_aref(options, ID2SYM(id_startpos));
1484
1485
  if (!NIL_P(startpos_option)) {
1485
- Check_Type(startpos_option, T_FIXNUM);
1486
-
1487
1486
  startpos = NUM2INT(startpos_option);
1488
1487
 
1489
1488
  if (startpos < 0) {
@@ -1515,37 +1514,43 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
1515
1514
  #endif
1516
1515
  return BOOL2RUBY(matched);
1517
1516
  } else {
1517
+ if (n == INT_MAX) {
1518
+ rb_raise(rb_eRangeError, "number of matches should be < %d", INT_MAX);
1519
+ }
1520
+
1518
1521
  /* Because match returns the whole match as well. */
1519
1522
  n += 1;
1520
1523
 
1521
- VALUE matchdata = rb_class_new_instance(0, 0, re2_cMatchData);
1522
- TypedData_Get_Struct(matchdata, re2_matchdata, &re2_matchdata_data_type, m);
1523
- m->matches = new(std::nothrow) re2::StringPiece[n];
1524
- RB_OBJ_WRITE(matchdata, &m->regexp, self);
1525
- if (!RTEST(rb_obj_frozen_p(text))) {
1526
- text = rb_str_freeze(rb_str_dup(text));
1527
- }
1528
- RB_OBJ_WRITE(matchdata, &m->text, text);
1529
-
1530
- if (m->matches == 0) {
1524
+ re2::StringPiece *matches = new(std::nothrow) re2::StringPiece[n];
1525
+ if (matches == 0) {
1531
1526
  rb_raise(rb_eNoMemError,
1532
1527
  "not enough memory to allocate StringPieces for matches");
1533
1528
  }
1534
1529
 
1535
- m->number_of_matches = n;
1530
+ text = rb_str_new_frozen(text);
1536
1531
 
1537
1532
  #ifdef HAVE_ENDPOS_ARGUMENT
1538
1533
  bool matched = p->pattern->Match(
1539
- re2::StringPiece(RSTRING_PTR(m->text), RSTRING_LEN(m->text)),
1540
- startpos, endpos, anchor, m->matches, n);
1534
+ re2::StringPiece(RSTRING_PTR(text), RSTRING_LEN(text)),
1535
+ startpos, endpos, anchor, matches, n);
1541
1536
  #else
1542
1537
  bool matched = p->pattern->Match(
1543
- re2::StringPiece(RSTRING_PTR(m->text), RSTRING_LEN(m->text)),
1544
- startpos, anchor, m->matches, n);
1538
+ re2::StringPiece(RSTRING_PTR(text), RSTRING_LEN(text)),
1539
+ startpos, anchor, matches, n);
1545
1540
  #endif
1546
1541
  if (matched) {
1542
+ VALUE matchdata = rb_class_new_instance(0, 0, re2_cMatchData);
1543
+ TypedData_Get_Struct(matchdata, re2_matchdata, &re2_matchdata_data_type, m);
1544
+
1545
+ RB_OBJ_WRITE(matchdata, &m->regexp, self);
1546
+ RB_OBJ_WRITE(matchdata, &m->text, text);
1547
+ m->matches = matches;
1548
+ m->number_of_matches = n;
1549
+
1547
1550
  return matchdata;
1548
1551
  } else {
1552
+ delete[] matches;
1553
+
1549
1554
  return Qnil;
1550
1555
  }
1551
1556
  }
@@ -1615,12 +1620,13 @@ static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
1615
1620
  TypedData_Get_Struct(scanner, re2_scanner, &re2_scanner_data_type, c);
1616
1621
 
1617
1622
  RB_OBJ_WRITE(scanner, &c->regexp, self);
1618
- if (!RTEST(rb_obj_frozen_p(text))) {
1619
- text = rb_str_freeze(rb_str_dup(text));
1620
- }
1621
- RB_OBJ_WRITE(scanner, &c->text, text);
1623
+ RB_OBJ_WRITE(scanner, &c->text, rb_str_new_frozen(text));
1622
1624
  c->input = new(std::nothrow) re2::StringPiece(
1623
- RSTRING_PTR(text), RSTRING_LEN(text));
1625
+ RSTRING_PTR(c->text), RSTRING_LEN(c->text));
1626
+ if (c->input == 0) {
1627
+ rb_raise(rb_eNoMemError,
1628
+ "not enough memory to allocate StringPiece for input");
1629
+ }
1624
1630
 
1625
1631
  if (p->pattern->ok()) {
1626
1632
  c->number_of_capturing_groups = p->pattern->NumberOfCapturingGroups();
@@ -1916,21 +1922,19 @@ static VALUE re2_set_add(VALUE self, VALUE pattern) {
1916
1922
  re2_set *s;
1917
1923
  TypedData_Get_Struct(self, re2_set, &re2_set_data_type, s);
1918
1924
 
1919
- /* To prevent the memory of the err string leaking when we call rb_raise,
1920
- * take a copy of it and let it go out of scope.
1921
- */
1922
- char msg[100];
1923
1925
  int index;
1926
+ VALUE msg;
1924
1927
 
1925
1928
  {
1926
1929
  std::string err;
1927
1930
  index = s->set->Add(
1928
1931
  re2::StringPiece(RSTRING_PTR(pattern), RSTRING_LEN(pattern)), &err);
1929
- strlcpy(msg, err.c_str(), sizeof(msg));
1932
+ msg = rb_str_new(err.data(), err.size());
1930
1933
  }
1931
1934
 
1932
1935
  if (index < 0) {
1933
- rb_raise(rb_eArgError, "str rejected by RE2::Set->Add(): %s", msg);
1936
+ rb_raise(rb_eArgError,
1937
+ "str rejected by RE2::Set->Add(): %s", RSTRING_PTR(msg));
1934
1938
  }
1935
1939
 
1936
1940
  return INT2FIX(index);
data/lib/3.1/re2.so CHANGED
Binary file
data/lib/3.2/re2.so CHANGED
Binary file
data/lib/3.3/re2.so CHANGED
Binary file
data/lib/3.4/re2.so CHANGED
Binary file
data/lib/4.0/re2.so ADDED
Binary file
data/lib/re2/version.rb CHANGED
@@ -10,5 +10,5 @@
10
10
 
11
11
 
12
12
  module RE2
13
- VERSION = "2.21.0"
13
+ VERSION = "2.23.0"
14
14
  end
data/re2.gemspec CHANGED
@@ -40,8 +40,8 @@ Gem::Specification.new do |s|
40
40
  "spec/re2/set_spec.rb",
41
41
  "spec/re2/scanner_spec.rb"
42
42
  ]
43
- s.add_development_dependency("rake-compiler", "~> 1.3.0")
44
- s.add_development_dependency("rake-compiler-dock", "~> 1.9.1")
43
+ s.add_development_dependency("rake-compiler", "~> 1.3.1")
44
+ s.add_development_dependency("rake-compiler-dock", "~> 1.11.0")
45
45
  s.add_development_dependency("rspec", "~> 3.2")
46
46
  s.add_runtime_dependency("mini_portile2", "~> 2.8.9") # keep version in sync with extconf.rb
47
47
  end
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rbconfig/sizeof"
4
+
3
5
  RSpec.describe RE2::Regexp do
6
+ INT_MAX = 2**(RbConfig::SIZEOF.fetch("int") * 8 - 1) - 1
7
+
4
8
  describe "#initialize" do
5
9
  it "returns an instance given only a pattern" do
6
10
  re = RE2::Regexp.new('woo')
@@ -566,6 +570,12 @@ RSpec.describe RE2::Regexp do
566
570
  expect { re.match("one two three", submatches: :invalid) }.to raise_error(TypeError)
567
571
  end
568
572
 
573
+ it "raises an exception when given too large a number of submatches" do
574
+ re = RE2::Regexp.new('(\w+) (\w+) (\w+)')
575
+
576
+ expect { re.match("one two three", submatches: INT_MAX) }.to raise_error(RangeError, "number of matches should be < #{INT_MAX}")
577
+ end
578
+
569
579
  it "defaults to extracting all submatches when given nil", :aggregate_failures do
570
580
  re = RE2::Regexp.new('(\w+) (\w+) (\w+)')
571
581
  md = re.match("one two three", submatches: nil)
@@ -584,6 +594,13 @@ RSpec.describe RE2::Regexp do
584
594
  expect(md[3]).to be_nil
585
595
  end
586
596
 
597
+ it "raises an exception if given too large a number of submatches instead of options" do
598
+ re = RE2::Regexp.new('(\w+) (\w+) (\w+)')
599
+ md = re.match("one two three", 2)
600
+
601
+ expect { re.match("one two three", INT_MAX) }.to raise_error(RangeError, "number of matches should be < #{INT_MAX}")
602
+ end
603
+
587
604
  it "raises an exception when given invalid options" do
588
605
  re = RE2::Regexp.new('(\w+) (\w+) (\w+)')
589
606
 
data/spec/re2/set_spec.rb CHANGED
@@ -66,10 +66,10 @@ RSpec.describe RE2::Set do
66
66
  expect { set.add("???") }.to raise_error(ArgumentError, /str rejected by RE2::Set->Add\(\)/)
67
67
  end
68
68
 
69
- it "truncates error messages to 100 characters" do
69
+ it "includes the full error message" do
70
70
  set = RE2::Set.new(:unanchored, log_errors: false)
71
71
 
72
- expect { set.add("(?P<#{'o' * 200}") }.to raise_error(ArgumentError, "str rejected by RE2::Set->Add(): invalid named capture group: (?P<oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo")
72
+ expect { set.add("(?P<#{'o' * 200}") }.to raise_error(ArgumentError, "str rejected by RE2::Set->Add(): invalid named capture group: (?P<oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo")
73
73
  end
74
74
 
75
75
  it "raises an error if called after #compile" do
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.21.0
4
+ version: 2.23.0
5
5
  platform: arm-linux-gnu
6
6
  authors:
7
7
  - Paul Mucur
8
8
  - Stan Hu
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-11-10 00:00:00.000000000 Z
11
+ date: 1980-01-02 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.3.0
19
+ version: 1.3.1
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.3.0
26
+ version: 1.3.1
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.9.1
33
+ version: 1.11.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.9.1
40
+ version: 1.11.0
42
41
  - !ruby/object:Gem::Dependency
43
42
  name: rspec
44
43
  requirement: !ruby/object:Gem::Requirement
@@ -55,7 +54,6 @@ dependencies:
55
54
  version: '3.2'
56
55
  description: Ruby bindings to RE2, "a fast, safe, thread-friendly alternative to backtracking
57
56
  regular expression engines like those used in PCRE, Perl, and Python".
58
- email:
59
57
  executables: []
60
58
  extensions: []
61
59
  extra_rdoc_files: []
@@ -74,6 +72,7 @@ files:
74
72
  - lib/3.2/re2.so
75
73
  - lib/3.3/re2.so
76
74
  - lib/3.4/re2.so
75
+ - lib/4.0/re2.so
77
76
  - lib/re2.rb
78
77
  - lib/re2/regexp.rb
79
78
  - lib/re2/scanner.rb
@@ -92,7 +91,6 @@ homepage: https://github.com/mudge/re2
92
91
  licenses:
93
92
  - BSD-3-Clause
94
93
  metadata: {}
95
- post_install_message:
96
94
  rdoc_options: []
97
95
  require_paths:
98
96
  - lib
@@ -103,24 +101,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
101
  version: '3.1'
104
102
  - - "<"
105
103
  - !ruby/object:Gem::Version
106
- version: 3.5.dev
104
+ version: 4.1.dev
107
105
  required_rubygems_version: !ruby/object:Gem::Requirement
108
106
  requirements:
109
107
  - - ">="
110
108
  - !ruby/object:Gem::Version
111
109
  version: 3.3.22
112
110
  requirements: []
113
- rubygems_version: 3.3.27
114
- signing_key:
111
+ rubygems_version: 4.0.3
115
112
  specification_version: 4
116
113
  summary: Ruby bindings to RE2.
117
114
  test_files:
118
115
  - ".rspec"
119
- - spec/spec_helper.rb
120
- - spec/re2_spec.rb
121
116
  - spec/kernel_spec.rb
122
- - spec/re2/regexp_spec.rb
123
117
  - spec/re2/match_data_spec.rb
124
- - spec/re2/string_spec.rb
125
- - spec/re2/set_spec.rb
118
+ - spec/re2/regexp_spec.rb
126
119
  - spec/re2/scanner_spec.rb
120
+ - spec/re2/set_spec.rb
121
+ - spec/re2/string_spec.rb
122
+ - spec/re2_spec.rb
123
+ - spec/spec_helper.rb