re2 2.26.0-x86_64-linux-gnu → 2.26.1-x86_64-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 +62 -58
- 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/4.0/re2.so +0 -0
- data/lib/re2/version.rb +1 -1
- data/spec/re2/regexp_spec.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f26a7c50adf99ee96e8af8cf72c2807df885f3aea35a56ac56962327b6151cce
|
|
4
|
+
data.tar.gz: 8823d9b232988ec6026e30b4930284a0deed495cbf7fd7c8c2fab09c0244004c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8423cd1e0bfb54c2e7d211c5f9b667cbd3025163adbbb42575e545ef5bbef4e437c955f107bdeb30a0a988e65374c3b601bcaa542716b9a649f0fdd803fc78c3
|
|
7
|
+
data.tar.gz: 55b2b7aa364e94aa1a0e25a344707643974b435d82c8a04a73ac261aa99f3c2b350cd9dd01627e5a21c0b81c5412d5a833ecb7e138bc08a085a5ed87a574e352
|
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.26.
|
|
9
|
+
**Current version:** 2.26.1
|
|
10
10
|
**Bundled RE2 version:** libre2.11 (2025-11-05)
|
|
11
11
|
|
|
12
12
|
```ruby
|
data/ext/re2/re2.cc
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Released under the BSD Licence, please see LICENSE.txt
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
#include <
|
|
11
|
+
#include <cstdint>
|
|
12
12
|
|
|
13
13
|
#include <map>
|
|
14
14
|
#include <sstream>
|
|
@@ -296,12 +296,12 @@ static re2_scanner *unwrap_re2_scanner(VALUE self) {
|
|
|
296
296
|
static VALUE re2_regexp_names(const VALUE self) {
|
|
297
297
|
re2_pattern *p = unwrap_re2_regexp(self);
|
|
298
298
|
|
|
299
|
-
const
|
|
299
|
+
const auto& groups = p->pattern->NamedCapturingGroups();
|
|
300
300
|
VALUE names = rb_ary_new2(groups.size());
|
|
301
301
|
|
|
302
|
-
for (
|
|
302
|
+
for (const auto& group : groups) {
|
|
303
303
|
rb_ary_push(names,
|
|
304
|
-
encoded_str_new(
|
|
304
|
+
encoded_str_new(group.first.data(), group.first.size(),
|
|
305
305
|
p->pattern->options().encoding()));
|
|
306
306
|
}
|
|
307
307
|
|
|
@@ -385,7 +385,7 @@ static VALUE re2_scanner_rewind(VALUE self) {
|
|
|
385
385
|
delete c->input;
|
|
386
386
|
c->input = new(std::nothrow) re2::StringPiece(
|
|
387
387
|
RSTRING_PTR(c->text), RSTRING_LEN(c->text));
|
|
388
|
-
if (c->input ==
|
|
388
|
+
if (c->input == nullptr) {
|
|
389
389
|
rb_raise(rb_eNoMemError,
|
|
390
390
|
"not enough memory to allocate StringPiece for input");
|
|
391
391
|
}
|
|
@@ -412,12 +412,12 @@ static VALUE re2_scanner_initialize_copy(VALUE self, VALUE other) {
|
|
|
412
412
|
|
|
413
413
|
if (other_c->input) {
|
|
414
414
|
self_c->input = new(std::nothrow) re2::StringPiece(*other_c->input);
|
|
415
|
-
if (self_c->input ==
|
|
415
|
+
if (self_c->input == nullptr) {
|
|
416
416
|
rb_raise(rb_eNoMemError,
|
|
417
417
|
"not enough memory to allocate StringPiece for input");
|
|
418
418
|
}
|
|
419
419
|
} else {
|
|
420
|
-
self_c->input =
|
|
420
|
+
self_c->input = nullptr;
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
return self;
|
|
@@ -469,7 +469,7 @@ static VALUE re2_scanner_scan(VALUE self) {
|
|
|
469
469
|
VALUE result = rb_ary_new2(c->number_of_capturing_groups);
|
|
470
470
|
|
|
471
471
|
for (int i = 0; i < c->number_of_capturing_groups; ++i) {
|
|
472
|
-
if (matches[i].data() ==
|
|
472
|
+
if (matches[i].data() == nullptr) {
|
|
473
473
|
rb_ary_push(result, Qnil);
|
|
474
474
|
} else {
|
|
475
475
|
rb_ary_push(result, encoded_str_new(matches[i].data(),
|
|
@@ -501,36 +501,36 @@ static re2::StringPiece *re2_matchdata_find_match(VALUE idx, const VALUE self) {
|
|
|
501
501
|
if (RB_INTEGER_TYPE_P(idx)) {
|
|
502
502
|
id = NUM2INT(idx);
|
|
503
503
|
} else if (SYMBOL_P(idx)) {
|
|
504
|
-
const
|
|
505
|
-
|
|
504
|
+
const auto& groups = p->pattern->NamedCapturingGroups();
|
|
505
|
+
auto search = groups.find(rb_id2name(SYM2ID(idx)));
|
|
506
506
|
|
|
507
507
|
if (search != groups.end()) {
|
|
508
508
|
id = search->second;
|
|
509
509
|
} else {
|
|
510
|
-
return
|
|
510
|
+
return nullptr;
|
|
511
511
|
}
|
|
512
512
|
} else {
|
|
513
513
|
StringValue(idx);
|
|
514
514
|
|
|
515
|
-
const
|
|
516
|
-
|
|
515
|
+
const auto& groups = p->pattern->NamedCapturingGroups();
|
|
516
|
+
auto search = groups.find(std::string(RSTRING_PTR(idx), RSTRING_LEN(idx)));
|
|
517
517
|
|
|
518
518
|
if (search != groups.end()) {
|
|
519
519
|
id = search->second;
|
|
520
520
|
} else {
|
|
521
|
-
return
|
|
521
|
+
return nullptr;
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
if (id >= 0 && id < m->number_of_matches) {
|
|
526
526
|
re2::StringPiece *match = &m->matches[id];
|
|
527
527
|
|
|
528
|
-
if (match->data() !=
|
|
528
|
+
if (match->data() != nullptr) {
|
|
529
529
|
return match;
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
return
|
|
533
|
+
return nullptr;
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
/*
|
|
@@ -564,7 +564,7 @@ static VALUE re2_matchdata_begin(const VALUE self, VALUE n) {
|
|
|
564
564
|
re2_matchdata *m = unwrap_re2_matchdata(self);
|
|
565
565
|
|
|
566
566
|
re2::StringPiece *match = re2_matchdata_find_match(n, self);
|
|
567
|
-
if (match ==
|
|
567
|
+
if (match == nullptr) {
|
|
568
568
|
return Qnil;
|
|
569
569
|
} else {
|
|
570
570
|
long offset = match->data() - RSTRING_PTR(m->text);
|
|
@@ -589,7 +589,7 @@ static VALUE re2_matchdata_end(const VALUE self, VALUE n) {
|
|
|
589
589
|
re2_matchdata *m = unwrap_re2_matchdata(self);
|
|
590
590
|
|
|
591
591
|
re2::StringPiece *match = re2_matchdata_find_match(n, self);
|
|
592
|
-
if (match ==
|
|
592
|
+
if (match == nullptr) {
|
|
593
593
|
return Qnil;
|
|
594
594
|
} else {
|
|
595
595
|
long offset = (match->data() - RSTRING_PTR(m->text)) + match->size();
|
|
@@ -615,7 +615,7 @@ static VALUE re2_matchdata_pre_match(const VALUE self) {
|
|
|
615
615
|
re2_pattern *p = unwrap_re2_regexp(m->regexp);
|
|
616
616
|
|
|
617
617
|
re2::StringPiece *match = &m->matches[0];
|
|
618
|
-
if (match->data() ==
|
|
618
|
+
if (match->data() == nullptr) {
|
|
619
619
|
return Qnil;
|
|
620
620
|
}
|
|
621
621
|
|
|
@@ -642,7 +642,7 @@ static VALUE re2_matchdata_post_match(const VALUE self) {
|
|
|
642
642
|
re2_pattern *p = unwrap_re2_regexp(m->regexp);
|
|
643
643
|
|
|
644
644
|
re2::StringPiece *match = &m->matches[0];
|
|
645
|
-
if (match->data() ==
|
|
645
|
+
if (match->data() == nullptr) {
|
|
646
646
|
return Qnil;
|
|
647
647
|
}
|
|
648
648
|
|
|
@@ -669,7 +669,7 @@ static VALUE re2_matchdata_offset(const VALUE self, VALUE n) {
|
|
|
669
669
|
re2_matchdata *m = unwrap_re2_matchdata(self);
|
|
670
670
|
|
|
671
671
|
re2::StringPiece *match = re2_matchdata_find_match(n, self);
|
|
672
|
-
if (match ==
|
|
672
|
+
if (match == nullptr) {
|
|
673
673
|
return Qnil;
|
|
674
674
|
}
|
|
675
675
|
|
|
@@ -700,7 +700,7 @@ static VALUE re2_matchdata_match_length(const VALUE self, VALUE n) {
|
|
|
700
700
|
re2_matchdata *m = unwrap_re2_matchdata(self);
|
|
701
701
|
|
|
702
702
|
re2::StringPiece *match = re2_matchdata_find_match(n, self);
|
|
703
|
-
if (match ==
|
|
703
|
+
if (match == nullptr) {
|
|
704
704
|
return Qnil;
|
|
705
705
|
}
|
|
706
706
|
|
|
@@ -766,7 +766,7 @@ static VALUE re2_matchdata_to_a(const VALUE self) {
|
|
|
766
766
|
for (int i = 0; i < m->number_of_matches; ++i) {
|
|
767
767
|
re2::StringPiece *match = &m->matches[i];
|
|
768
768
|
|
|
769
|
-
if (match->data() ==
|
|
769
|
+
if (match->data() == nullptr) {
|
|
770
770
|
rb_ary_push(array, Qnil);
|
|
771
771
|
} else {
|
|
772
772
|
rb_ary_push(array, encoded_str_new(match->data(), match->size(),
|
|
@@ -786,7 +786,7 @@ static VALUE re2_matchdata_nth_match(int nth, const VALUE self) {
|
|
|
786
786
|
} else {
|
|
787
787
|
re2::StringPiece *match = &m->matches[nth];
|
|
788
788
|
|
|
789
|
-
if (match->data() ==
|
|
789
|
+
if (match->data() == nullptr) {
|
|
790
790
|
return Qnil;
|
|
791
791
|
} else {
|
|
792
792
|
return encoded_str_new(match->data(), match->size(),
|
|
@@ -799,8 +799,8 @@ static VALUE re2_matchdata_named_match(const std::string &name, const VALUE self
|
|
|
799
799
|
re2_matchdata *m = unwrap_re2_matchdata(self);
|
|
800
800
|
re2_pattern *p = unwrap_re2_regexp(m->regexp);
|
|
801
801
|
|
|
802
|
-
const
|
|
803
|
-
|
|
802
|
+
const auto& groups = p->pattern->NamedCapturingGroups();
|
|
803
|
+
auto search = groups.find(name);
|
|
804
804
|
|
|
805
805
|
if (search != groups.end()) {
|
|
806
806
|
return re2_matchdata_nth_match(search->second, self);
|
|
@@ -955,7 +955,7 @@ static VALUE re2_matchdata_deconstruct(const VALUE self) {
|
|
|
955
955
|
for (int i = 1; i < m->number_of_matches; ++i) {
|
|
956
956
|
re2::StringPiece *match = &m->matches[i];
|
|
957
957
|
|
|
958
|
-
if (match->data() ==
|
|
958
|
+
if (match->data() == nullptr) {
|
|
959
959
|
rb_ary_push(array, Qnil);
|
|
960
960
|
} else {
|
|
961
961
|
rb_ary_push(array, encoded_str_new(match->data(), match->size(),
|
|
@@ -999,14 +999,14 @@ static VALUE re2_matchdata_deconstruct_keys(const VALUE self, const VALUE keys)
|
|
|
999
999
|
re2_matchdata *m = unwrap_re2_matchdata(self);
|
|
1000
1000
|
re2_pattern *p = unwrap_re2_regexp(m->regexp);
|
|
1001
1001
|
|
|
1002
|
-
const
|
|
1002
|
+
const auto& groups = p->pattern->NamedCapturingGroups();
|
|
1003
1003
|
VALUE capturing_groups = rb_hash_new();
|
|
1004
1004
|
|
|
1005
1005
|
if (NIL_P(keys)) {
|
|
1006
|
-
for (
|
|
1006
|
+
for (const auto& group : groups) {
|
|
1007
1007
|
rb_hash_aset(capturing_groups,
|
|
1008
|
-
ID2SYM(rb_intern2(
|
|
1009
|
-
re2_matchdata_nth_match(
|
|
1008
|
+
ID2SYM(rb_intern2(group.first.data(), group.first.size())),
|
|
1009
|
+
re2_matchdata_nth_match(group.second, self));
|
|
1010
1010
|
}
|
|
1011
1011
|
} else {
|
|
1012
1012
|
Check_Type(keys, T_ARRAY);
|
|
@@ -1016,7 +1016,7 @@ static VALUE re2_matchdata_deconstruct_keys(const VALUE self, const VALUE keys)
|
|
|
1016
1016
|
VALUE key = rb_ary_entry(keys, i);
|
|
1017
1017
|
Check_Type(key, T_SYMBOL);
|
|
1018
1018
|
const char *name = rb_id2name(SYM2ID(key));
|
|
1019
|
-
|
|
1019
|
+
auto search = groups.find(name);
|
|
1020
1020
|
|
|
1021
1021
|
if (search != groups.end()) {
|
|
1022
1022
|
rb_hash_aset(capturing_groups, key, re2_matchdata_nth_match(search->second, self));
|
|
@@ -1069,18 +1069,18 @@ static VALUE re2_matchdata_named_captures(int argc, VALUE *argv, const VALUE sel
|
|
|
1069
1069
|
re2_matchdata *m = unwrap_re2_matchdata(self);
|
|
1070
1070
|
re2_pattern *p = unwrap_re2_regexp(m->regexp);
|
|
1071
1071
|
|
|
1072
|
-
const
|
|
1072
|
+
const auto& groups = p->pattern->NamedCapturingGroups();
|
|
1073
1073
|
VALUE result = rb_hash_new();
|
|
1074
1074
|
|
|
1075
|
-
for (
|
|
1075
|
+
for (const auto& group : groups) {
|
|
1076
1076
|
VALUE key;
|
|
1077
1077
|
if (symbolize) {
|
|
1078
|
-
key = ID2SYM(rb_intern2(
|
|
1078
|
+
key = ID2SYM(rb_intern2(group.first.data(), group.first.size()));
|
|
1079
1079
|
} else {
|
|
1080
|
-
key = encoded_str_new(
|
|
1080
|
+
key = encoded_str_new(group.first.data(), group.first.size(),
|
|
1081
1081
|
p->pattern->options().encoding());
|
|
1082
1082
|
}
|
|
1083
|
-
rb_hash_aset(result, key, re2_matchdata_nth_match(
|
|
1083
|
+
rb_hash_aset(result, key, re2_matchdata_nth_match(group.second, self));
|
|
1084
1084
|
}
|
|
1085
1085
|
|
|
1086
1086
|
return result;
|
|
@@ -1160,7 +1160,7 @@ static VALUE re2_matchdata_initialize_copy(VALUE self, VALUE other) {
|
|
|
1160
1160
|
|
|
1161
1161
|
if (other_m->matches) {
|
|
1162
1162
|
self_m->matches = new(std::nothrow) re2::StringPiece[other_m->number_of_matches];
|
|
1163
|
-
if (self_m->matches ==
|
|
1163
|
+
if (self_m->matches == nullptr) {
|
|
1164
1164
|
rb_raise(rb_eNoMemError,
|
|
1165
1165
|
"not enough memory to allocate StringPiece for matches");
|
|
1166
1166
|
}
|
|
@@ -1168,7 +1168,7 @@ static VALUE re2_matchdata_initialize_copy(VALUE self, VALUE other) {
|
|
|
1168
1168
|
self_m->matches[i] = other_m->matches[i];
|
|
1169
1169
|
}
|
|
1170
1170
|
} else {
|
|
1171
|
-
self_m->matches =
|
|
1171
|
+
self_m->matches = nullptr;
|
|
1172
1172
|
}
|
|
1173
1173
|
|
|
1174
1174
|
return self;
|
|
@@ -1244,7 +1244,7 @@ static VALUE re2_regexp_initialize(int argc, VALUE *argv, VALUE self) {
|
|
|
1244
1244
|
re2::StringPiece(RSTRING_PTR(pattern), RSTRING_LEN(pattern)));
|
|
1245
1245
|
}
|
|
1246
1246
|
|
|
1247
|
-
if (p->pattern ==
|
|
1247
|
+
if (p->pattern == nullptr) {
|
|
1248
1248
|
rb_raise(rb_eNoMemError, "not enough memory to allocate RE2 object");
|
|
1249
1249
|
}
|
|
1250
1250
|
|
|
@@ -1263,7 +1263,7 @@ static VALUE re2_regexp_initialize_copy(VALUE self, VALUE other) {
|
|
|
1263
1263
|
|
|
1264
1264
|
self_p->pattern = new(std::nothrow) RE2(other_p->pattern->pattern(),
|
|
1265
1265
|
other_p->pattern->options());
|
|
1266
|
-
if (self_p->pattern ==
|
|
1266
|
+
if (self_p->pattern == nullptr) {
|
|
1267
1267
|
rb_raise(rb_eNoMemError, "not enough memory to allocate RE2 object");
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
@@ -1629,14 +1629,14 @@ static VALUE re2_regexp_number_of_capturing_groups(const VALUE self) {
|
|
|
1629
1629
|
*/
|
|
1630
1630
|
static VALUE re2_regexp_named_capturing_groups(const VALUE self) {
|
|
1631
1631
|
re2_pattern *p = unwrap_re2_regexp(self);
|
|
1632
|
-
const
|
|
1632
|
+
const auto& groups = p->pattern->NamedCapturingGroups();
|
|
1633
1633
|
VALUE capturing_groups = rb_hash_new();
|
|
1634
1634
|
|
|
1635
|
-
for (
|
|
1635
|
+
for (const auto& group : groups) {
|
|
1636
1636
|
rb_hash_aset(capturing_groups,
|
|
1637
|
-
encoded_str_new(
|
|
1637
|
+
encoded_str_new(group.first.data(), group.first.size(),
|
|
1638
1638
|
p->pattern->options().encoding()),
|
|
1639
|
-
INT2FIX(
|
|
1639
|
+
INT2FIX(group.second));
|
|
1640
1640
|
}
|
|
1641
1641
|
|
|
1642
1642
|
return capturing_groups;
|
|
@@ -1737,8 +1737,8 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
|
1737
1737
|
p = unwrap_re2_regexp(self);
|
|
1738
1738
|
|
|
1739
1739
|
int n;
|
|
1740
|
-
|
|
1741
|
-
|
|
1740
|
+
size_t startpos = 0;
|
|
1741
|
+
size_t endpos = RSTRING_LEN(text);
|
|
1742
1742
|
RE2::Anchor anchor = RE2::UNANCHORED;
|
|
1743
1743
|
|
|
1744
1744
|
if (RTEST(options)) {
|
|
@@ -1756,11 +1756,13 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
|
1756
1756
|
VALUE endpos_option = rb_hash_aref(options, ID2SYM(id_endpos));
|
|
1757
1757
|
if (!NIL_P(endpos_option)) {
|
|
1758
1758
|
#ifdef HAVE_ENDPOS_ARGUMENT
|
|
1759
|
-
|
|
1759
|
+
ssize_t endpos_value = NUM2SSIZET(endpos_option);
|
|
1760
1760
|
|
|
1761
|
-
if (
|
|
1761
|
+
if (endpos_value < 0) {
|
|
1762
1762
|
rb_raise(rb_eArgError, "endpos should be >= 0");
|
|
1763
1763
|
}
|
|
1764
|
+
|
|
1765
|
+
endpos = static_cast<size_t>(endpos_value);
|
|
1764
1766
|
#else
|
|
1765
1767
|
rb_raise(re2_eRegexpUnsupportedError, "current version of RE2::Match() does not support endpos argument");
|
|
1766
1768
|
#endif
|
|
@@ -1799,11 +1801,13 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
|
1799
1801
|
|
|
1800
1802
|
VALUE startpos_option = rb_hash_aref(options, ID2SYM(id_startpos));
|
|
1801
1803
|
if (!NIL_P(startpos_option)) {
|
|
1802
|
-
|
|
1804
|
+
ssize_t startpos_value = NUM2SSIZET(startpos_option);
|
|
1803
1805
|
|
|
1804
|
-
if (
|
|
1806
|
+
if (startpos_value < 0) {
|
|
1805
1807
|
rb_raise(rb_eArgError, "startpos should be >= 0");
|
|
1806
1808
|
}
|
|
1809
|
+
|
|
1810
|
+
startpos = static_cast<size_t>(startpos_value);
|
|
1807
1811
|
}
|
|
1808
1812
|
}
|
|
1809
1813
|
} else {
|
|
@@ -1838,7 +1842,7 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
|
1838
1842
|
n += 1;
|
|
1839
1843
|
|
|
1840
1844
|
re2::StringPiece *matches = new(std::nothrow) re2::StringPiece[n];
|
|
1841
|
-
if (matches ==
|
|
1845
|
+
if (matches == nullptr) {
|
|
1842
1846
|
rb_raise(rb_eNoMemError,
|
|
1843
1847
|
"not enough memory to allocate StringPieces for matches");
|
|
1844
1848
|
}
|
|
@@ -1935,7 +1939,7 @@ static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
|
|
1935
1939
|
RB_OBJ_WRITE(scanner, &c->text, rb_str_new_frozen(text));
|
|
1936
1940
|
c->input = new(std::nothrow) re2::StringPiece(
|
|
1937
1941
|
RSTRING_PTR(c->text), RSTRING_LEN(c->text));
|
|
1938
|
-
if (c->input ==
|
|
1942
|
+
if (c->input == nullptr) {
|
|
1939
1943
|
rb_raise(rb_eNoMemError,
|
|
1940
1944
|
"not enough memory to allocate StringPiece for input");
|
|
1941
1945
|
}
|
|
@@ -2293,7 +2297,7 @@ static VALUE re2_set_initialize(int argc, VALUE *argv, VALUE self) {
|
|
|
2293
2297
|
}
|
|
2294
2298
|
|
|
2295
2299
|
s->set = new(std::nothrow) RE2::Set(re2_options, re2_anchor);
|
|
2296
|
-
if (s->set ==
|
|
2300
|
+
if (s->set == nullptr) {
|
|
2297
2301
|
rb_raise(rb_eNoMemError, "not enough memory to allocate RE2::Set object");
|
|
2298
2302
|
}
|
|
2299
2303
|
|
|
@@ -2480,8 +2484,8 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
|
2480
2484
|
rb_raise(re2_eSetMatchError, "Unknown RE2::Set::ErrorKind: %d", e.kind);
|
|
2481
2485
|
}
|
|
2482
2486
|
} else {
|
|
2483
|
-
for (
|
|
2484
|
-
rb_ary_push(result, INT2FIX(
|
|
2487
|
+
for (int index : v) {
|
|
2488
|
+
rb_ary_push(result, INT2FIX(index));
|
|
2485
2489
|
}
|
|
2486
2490
|
}
|
|
2487
2491
|
|
|
@@ -2495,8 +2499,8 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
|
2495
2499
|
VALUE result = rb_ary_new2(v.size());
|
|
2496
2500
|
|
|
2497
2501
|
if (matched) {
|
|
2498
|
-
for (
|
|
2499
|
-
rb_ary_push(result, INT2FIX(
|
|
2502
|
+
for (int index : v) {
|
|
2503
|
+
rb_ary_push(result, INT2FIX(index));
|
|
2500
2504
|
}
|
|
2501
2505
|
}
|
|
2502
2506
|
|
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
CHANGED
|
Binary file
|
data/lib/re2/version.rb
CHANGED
data/spec/re2/regexp_spec.rb
CHANGED
|
@@ -590,6 +590,24 @@ RSpec.describe RE2::Regexp do
|
|
|
590
590
|
expect { re.match("one two three", endpos: 3) }.to raise_error(RE2::Regexp::UnsupportedError)
|
|
591
591
|
end
|
|
592
592
|
|
|
593
|
+
it "does not truncate startpos to 32 bits" do
|
|
594
|
+
skip "Underlying RE2::Match does not have endpos argument" unless RE2::Regexp.match_has_endpos_argument?
|
|
595
|
+
skip "size_t is not larger than a 32-bit int" if RbConfig::SIZEOF.fetch("size_t") <= (32 / 8)
|
|
596
|
+
|
|
597
|
+
re = RE2::Regexp.new('(\w+)', log_errors: false)
|
|
598
|
+
|
|
599
|
+
expect(re.match("one two three", startpos: 2_147_483_648, endpos: 2_147_483_649)).to be_nil
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
it "does not truncate endpos to 32 bits" do
|
|
603
|
+
skip "Underlying RE2::Match does not have endpos argument" unless RE2::Regexp.match_has_endpos_argument?
|
|
604
|
+
skip "size_t is not larger than a 32-bit int" if RbConfig::SIZEOF.fetch("size_t") <= (32 / 8)
|
|
605
|
+
|
|
606
|
+
re = RE2::Regexp.new('(\w+)', log_errors: false)
|
|
607
|
+
|
|
608
|
+
expect(re.match("one two three", endpos: 2_147_483_648)).to be_nil
|
|
609
|
+
end
|
|
610
|
+
|
|
593
611
|
it "does not anchor matches by default when extracting submatches" do
|
|
594
612
|
re = RE2::Regexp.new('(two)')
|
|
595
613
|
|