re2 2.21.0-aarch64-linux-gnu → 2.22.0-aarch64-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 +4 -4
- data/README.md +1 -1
- data/ext/re2/re2.cc +41 -37
- data/lib/3.1/re2.so +0 -0
- data/lib/3.2/re2.so +0 -0
- data/lib/3.3/re2.so +0 -0
- data/lib/3.4/re2.so +0 -0
- data/lib/re2/version.rb +1 -1
- data/spec/re2/regexp_spec.rb +17 -0
- data/spec/re2/set_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a59dacc90ebcc0185f84449a3ae29e140cfe453aee0bab5fcaffbb93e317b37
|
|
4
|
+
data.tar.gz: 21c8c19b55eeb683fb8dfe6d3b46ca0c73517ed7b8e3c6ac6b9a7b26a029120f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62ad90d2ad4af800bd2986b959b6d51a40c34e32538e0cc480717771eff2278c2ef04132868ca6a640ba75fa0ad0b6f350c14c1093a4edbe03ed0668415f6b9c
|
|
7
|
+
data.tar.gz: c4419ce38e7815372202d95c42b54e1f7ff9a4ebbe68eb93b53be6284855df6717c1fd32ce353b7cfbcab1030f4bc8066f51a0e9cea491939ac361df2d2197ea
|
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Python".
|
|
|
6
6
|
|
|
7
7
|
[](https://github.com/mudge/re2/actions)
|
|
8
8
|
|
|
9
|
-
**Current version:** 2.
|
|
9
|
+
**Current version:** 2.22.0
|
|
10
10
|
**Bundled RE2 version:** libre2.11 (2025-11-05)
|
|
11
11
|
|
|
12
12
|
```ruby
|
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 (
|
|
416
|
-
id =
|
|
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) || !
|
|
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(
|
|
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 (
|
|
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
|
-
|
|
1522
|
-
|
|
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
|
-
|
|
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(
|
|
1540
|
-
startpos, endpos, anchor,
|
|
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(
|
|
1544
|
-
startpos, anchor,
|
|
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
|
-
|
|
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
|
-
|
|
1932
|
+
msg = rb_str_new(err.data(), err.size());
|
|
1930
1933
|
}
|
|
1931
1934
|
|
|
1932
1935
|
if (index < 0) {
|
|
1933
|
-
rb_raise(rb_eArgError,
|
|
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/re2/version.rb
CHANGED
data/spec/re2/regexp_spec.rb
CHANGED
|
@@ -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 "
|
|
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<
|
|
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,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: re2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.22.0
|
|
5
5
|
platform: aarch64-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Paul Mucur
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2025-11-
|
|
12
|
+
date: 2025-11-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake-compiler
|