re2 2.1.1-arm-linux → 2.1.3-arm-linux
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 +7 -2
- data/ext/re2/re2.cc +78 -55
- data/lib/2.6/re2.so +0 -0
- data/lib/2.7/re2.so +0 -0
- data/lib/3.0/re2.so +0 -0
- data/lib/3.1/re2.so +0 -0
- data/lib/3.2/re2.so +0 -0
- data/lib/re2/version.rb +1 -1
- data/spec/re2/set_spec.rb +14 -1
- 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: 4d84f14fbd3d483f8b80f432d0ac98edc58aef4b21dfdafa7bc94be84df41aaa
|
4
|
+
data.tar.gz: 1b4810380634f57bfe2d7610a71e68efd9df448e7b38786e944af3aa704b7e34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa2ce14419db4c055374d36435909451d7d09d638aa84e72cdef5ab5a3d0248d76588aff34824ee3028f8fe69cfa7e8e7b32c76f7992020b72815941aebf48f7
|
7
|
+
data.tar.gz: 649417d1a9c0472bbec648f4189cd5f0dbf0a0df9b6dc2d6060e8c307aff12137e1c06884d39916db8c31f3eead1087269957b9f446236d531cc0d07b36cb75a
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Ruby bindings to [RE2][], a "fast, safe, thread-friendly alternative to
|
|
5
5
|
backtracking regular expression engines like those used in PCRE, Perl, and
|
6
6
|
Python".
|
7
7
|
|
8
|
-
**Current version:** 2.1.
|
8
|
+
**Current version:** 2.1.3
|
9
9
|
**Supported Ruby versions:** 2.6, 2.7, 3.0, 3.1, 3.2
|
10
10
|
**Bundled RE2 version:** libre2.11 (2023-09-01)
|
11
11
|
**Supported RE2 versions:** libre2.0 (< 2020-03-02), libre2.1 (2020-03-02), libre2.6 (2020-03-03), libre2.7 (2020-05-01), libre2.8 (2020-07-06), libre2.9 (2020-11-01), libre2.10 (2022-12-01), libre2.11 (2023-07-01)
|
@@ -262,8 +262,13 @@ Contributions
|
|
262
262
|
the deprecation and removal of the `utf8` encoding option in RE2;
|
263
263
|
* Thanks to [Sergio Medina](https://github.com/serch) for reporting a bug when
|
264
264
|
using `RE2::Scanner#scan` with an invalid regular expression;
|
265
|
-
* Thanks to [Pritam Baral](https://github.com/pritambaral) for
|
265
|
+
* Thanks to [Pritam Baral](https://github.com/pritambaral) for contributing the
|
266
266
|
initial support for `RE2::Set`.
|
267
|
+
* Thanks to [Mike Dalessio](https://github.com/flavorjones) for reviewing the
|
268
|
+
precompilation of native gems in 2.0.
|
269
|
+
* Thanks to [Peter Zhu](https://github.com/peterzhu2118) for
|
270
|
+
[ruby_memcheck](https://github.com/Shopify/ruby_memcheck) and helping find
|
271
|
+
the memory leaks fixed in 2.1.3.
|
267
272
|
|
268
273
|
Contact
|
269
274
|
-------
|
data/ext/re2/re2.cc
CHANGED
@@ -19,7 +19,6 @@
|
|
19
19
|
#include <ruby/encoding.h>
|
20
20
|
|
21
21
|
#define BOOL2RUBY(v) (v ? Qtrue : Qfalse)
|
22
|
-
#define UNUSED(x) ((void)x)
|
23
22
|
|
24
23
|
typedef struct {
|
25
24
|
RE2 *pattern;
|
@@ -228,7 +227,8 @@ static VALUE re2_scanner_rewind(VALUE self) {
|
|
228
227
|
re2_scanner *c;
|
229
228
|
Data_Get_Struct(self, re2_scanner, c);
|
230
229
|
|
231
|
-
c->input
|
230
|
+
delete c->input;
|
231
|
+
c->input = new(std::nothrow) re2::StringPiece(RSTRING_PTR(c->text));
|
232
232
|
c->eof = false;
|
233
233
|
|
234
234
|
return self;
|
@@ -270,7 +270,7 @@ static VALUE re2_scanner_scan(VALUE self) {
|
|
270
270
|
args[i] = &argv[i];
|
271
271
|
}
|
272
272
|
|
273
|
-
if (RE2::FindAndConsumeN(c->input, *p->pattern,
|
273
|
+
if (RE2::FindAndConsumeN(c->input, *p->pattern, args.data(),
|
274
274
|
c->number_of_capturing_groups)) {
|
275
275
|
re2::StringPiece::size_type new_input_size = c->input->size();
|
276
276
|
bool input_advanced = new_input_size < original_input_size;
|
@@ -318,8 +318,9 @@ static re2::StringPiece *re2_matchdata_find_match(VALUE idx, const VALUE self) {
|
|
318
318
|
} else {
|
319
319
|
const char *name = SYMBOL_P(idx) ? rb_id2name(SYM2ID(idx)) : StringValuePtr(idx);
|
320
320
|
const std::map<std::string, int>& groups = p->pattern->NamedCapturingGroups();
|
321
|
+
std::map<std::string, int>::const_iterator search = groups.find(name);
|
321
322
|
|
322
|
-
if (
|
323
|
+
if (search != groups.end()) {
|
323
324
|
id = search->second;
|
324
325
|
} else {
|
325
326
|
return NULL;
|
@@ -372,9 +373,9 @@ static VALUE re2_matchdata_begin(const VALUE self, VALUE n) {
|
|
372
373
|
if (match == NULL) {
|
373
374
|
return Qnil;
|
374
375
|
} else {
|
375
|
-
long offset = match->data() -
|
376
|
+
long offset = match->data() - RSTRING_PTR(m->text);
|
376
377
|
|
377
|
-
return LONG2NUM(rb_str_sublen(
|
378
|
+
return LONG2NUM(rb_str_sublen(m->text, offset));
|
378
379
|
}
|
379
380
|
}
|
380
381
|
|
@@ -397,9 +398,9 @@ static VALUE re2_matchdata_end(const VALUE self, VALUE n) {
|
|
397
398
|
if (match == NULL) {
|
398
399
|
return Qnil;
|
399
400
|
} else {
|
400
|
-
long offset = (match->data() -
|
401
|
+
long offset = (match->data() - RSTRING_PTR(m->text)) + match->size();
|
401
402
|
|
402
|
-
return LONG2NUM(rb_str_sublen(
|
403
|
+
return LONG2NUM(rb_str_sublen(m->text, offset));
|
403
404
|
}
|
404
405
|
}
|
405
406
|
|
@@ -502,8 +503,9 @@ static VALUE re2_matchdata_named_match(const char* name, const VALUE self) {
|
|
502
503
|
Data_Get_Struct(m->regexp, re2_pattern, p);
|
503
504
|
|
504
505
|
const std::map<std::string, int>& groups = p->pattern->NamedCapturingGroups();
|
506
|
+
std::map<std::string, int>::const_iterator search = groups.find(name);
|
505
507
|
|
506
|
-
if (
|
508
|
+
if (search != groups.end()) {
|
507
509
|
return re2_matchdata_nth_match(search->second, self);
|
508
510
|
} else {
|
509
511
|
return Qnil;
|
@@ -562,7 +564,7 @@ static VALUE re2_matchdata_aref(int argc, VALUE *argv, const VALUE self) {
|
|
562
564
|
rb_scan_args(argc, argv, "11", &idx, &rest);
|
563
565
|
|
564
566
|
if (TYPE(idx) == T_STRING) {
|
565
|
-
return re2_matchdata_named_match(
|
567
|
+
return re2_matchdata_named_match(RSTRING_PTR(idx), self);
|
566
568
|
} else if (SYMBOL_P(idx)) {
|
567
569
|
return re2_matchdata_named_match(rb_id2name(SYM2ID(idx)), self);
|
568
570
|
} else if (!NIL_P(rest) || !FIXNUM_P(idx) || FIX2INT(idx) < 0) {
|
@@ -615,7 +617,7 @@ static VALUE re2_matchdata_inspect(const VALUE self) {
|
|
615
617
|
if (match == Qnil) {
|
616
618
|
output << "nil";
|
617
619
|
} else {
|
618
|
-
output << "\"" <<
|
620
|
+
output << "\"" << RSTRING_PTR(match) << "\"";
|
619
621
|
}
|
620
622
|
}
|
621
623
|
|
@@ -719,8 +721,9 @@ static VALUE re2_matchdata_deconstruct_keys(const VALUE self, const VALUE keys)
|
|
719
721
|
VALUE key = rb_ary_entry(keys, i);
|
720
722
|
Check_Type(key, T_SYMBOL);
|
721
723
|
const char *name = rb_id2name(SYM2ID(key));
|
724
|
+
std::map<std::string, int>::const_iterator search = groups.find(name);
|
722
725
|
|
723
|
-
if (
|
726
|
+
if (search != groups.end()) {
|
724
727
|
rb_hash_aset(capturing_groups, key, re2_matchdata_nth_match(search->second, self));
|
725
728
|
} else {
|
726
729
|
break;
|
@@ -739,9 +742,7 @@ static VALUE re2_matchdata_deconstruct_keys(const VALUE self, const VALUE keys)
|
|
739
742
|
* @see RE2::Regexp#initialize
|
740
743
|
*
|
741
744
|
*/
|
742
|
-
static VALUE re2_re2(int argc, VALUE *argv, VALUE
|
743
|
-
UNUSED(self);
|
744
|
-
|
745
|
+
static VALUE re2_re2(int argc, VALUE *argv, VALUE) {
|
745
746
|
return rb_class_new_instance(argc, argv, re2_cRegexp);
|
746
747
|
}
|
747
748
|
|
@@ -785,15 +786,19 @@ static VALUE re2_regexp_initialize(int argc, VALUE *argv, VALUE self) {
|
|
785
786
|
re2_pattern *p;
|
786
787
|
|
787
788
|
rb_scan_args(argc, argv, "11", &pattern, &options);
|
789
|
+
|
790
|
+
/* Ensure pattern is a string. */
|
791
|
+
StringValue(pattern);
|
792
|
+
|
788
793
|
Data_Get_Struct(self, re2_pattern, p);
|
789
794
|
|
790
795
|
if (RTEST(options)) {
|
791
796
|
RE2::Options re2_options;
|
792
797
|
parse_re2_options(&re2_options, options);
|
793
798
|
|
794
|
-
p->pattern = new(std::nothrow) RE2(
|
799
|
+
p->pattern = new(std::nothrow) RE2(RSTRING_PTR(pattern), re2_options);
|
795
800
|
} else {
|
796
|
-
p->pattern = new(std::nothrow) RE2(
|
801
|
+
p->pattern = new(std::nothrow) RE2(RSTRING_PTR(pattern));
|
797
802
|
}
|
798
803
|
|
799
804
|
if (p->pattern == 0) {
|
@@ -1282,10 +1287,10 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
1282
1287
|
|
1283
1288
|
if (n == 0) {
|
1284
1289
|
#ifdef HAVE_ENDPOS_ARGUMENT
|
1285
|
-
bool matched = p->pattern->Match(
|
1290
|
+
bool matched = p->pattern->Match(RSTRING_PTR(text), 0,
|
1286
1291
|
RSTRING_LEN(text), RE2::UNANCHORED, 0, 0);
|
1287
1292
|
#else
|
1288
|
-
bool matched = p->pattern->Match(
|
1293
|
+
bool matched = p->pattern->Match(RSTRING_PTR(text), 0, RE2::UNANCHORED,
|
1289
1294
|
0, 0);
|
1290
1295
|
#endif
|
1291
1296
|
return BOOL2RUBY(matched);
|
@@ -1308,10 +1313,10 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
1308
1313
|
m->number_of_matches = n;
|
1309
1314
|
|
1310
1315
|
#ifdef HAVE_ENDPOS_ARGUMENT
|
1311
|
-
bool matched = p->pattern->Match(
|
1316
|
+
bool matched = p->pattern->Match(RSTRING_PTR(m->text), 0,
|
1312
1317
|
RSTRING_LEN(m->text), RE2::UNANCHORED, m->matches, n);
|
1313
1318
|
#else
|
1314
|
-
bool matched = p->pattern->Match(
|
1319
|
+
bool matched = p->pattern->Match(RSTRING_PTR(m->text), 0,
|
1315
1320
|
RE2::UNANCHORED, m->matches, n);
|
1316
1321
|
#endif
|
1317
1322
|
if (matched) {
|
@@ -1341,6 +1346,9 @@ static VALUE re2_regexp_match_p(const VALUE self, VALUE text) {
|
|
1341
1346
|
* c = RE2::Regexp.new('(\w+)').scan("Foo bar baz")
|
1342
1347
|
*/
|
1343
1348
|
static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
1349
|
+
/* Ensure text is a string. */
|
1350
|
+
StringValue(text);
|
1351
|
+
|
1344
1352
|
re2_pattern *p;
|
1345
1353
|
re2_scanner *c;
|
1346
1354
|
|
@@ -1348,7 +1356,7 @@ static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
|
1348
1356
|
VALUE scanner = rb_class_new_instance(0, 0, re2_cScanner);
|
1349
1357
|
Data_Get_Struct(scanner, re2_scanner, c);
|
1350
1358
|
|
1351
|
-
c->input = new(std::nothrow) re2::StringPiece(
|
1359
|
+
c->input = new(std::nothrow) re2::StringPiece(RSTRING_PTR(text));
|
1352
1360
|
c->regexp = self;
|
1353
1361
|
c->text = text;
|
1354
1362
|
|
@@ -1380,9 +1388,11 @@ static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
|
1380
1388
|
* re2 = RE2::Regexp.new("hel+o")
|
1381
1389
|
* RE2.Replace("hello there", re2, "yo") #=> "yo there"
|
1382
1390
|
*/
|
1383
|
-
static VALUE re2_Replace(VALUE
|
1391
|
+
static VALUE re2_Replace(VALUE, VALUE str, VALUE pattern,
|
1384
1392
|
VALUE rewrite) {
|
1385
|
-
|
1393
|
+
/* Ensure rewrite is a string. */
|
1394
|
+
StringValue(rewrite);
|
1395
|
+
|
1386
1396
|
re2_pattern *p;
|
1387
1397
|
|
1388
1398
|
/* Take a copy of str so it can be modified in-place by
|
@@ -1393,13 +1403,15 @@ static VALUE re2_Replace(VALUE self, VALUE str, VALUE pattern,
|
|
1393
1403
|
/* Do the replacement. */
|
1394
1404
|
if (rb_obj_is_kind_of(pattern, re2_cRegexp)) {
|
1395
1405
|
Data_Get_Struct(pattern, re2_pattern, p);
|
1396
|
-
RE2::Replace(&str_as_string, *p->pattern,
|
1406
|
+
RE2::Replace(&str_as_string, *p->pattern, RSTRING_PTR(rewrite));
|
1397
1407
|
|
1398
1408
|
return encoded_str_new(str_as_string.data(), str_as_string.size(),
|
1399
1409
|
p->pattern->options().encoding());
|
1400
1410
|
} else {
|
1401
|
-
|
1402
|
-
|
1411
|
+
/* Ensure pattern is a string. */
|
1412
|
+
StringValue(pattern);
|
1413
|
+
|
1414
|
+
RE2::Replace(&str_as_string, RSTRING_PTR(pattern), RSTRING_PTR(rewrite));
|
1403
1415
|
|
1404
1416
|
return encoded_str_new(str_as_string.data(), str_as_string.size(), RE2::Options::EncodingUTF8);
|
1405
1417
|
}
|
@@ -1421,9 +1433,10 @@ static VALUE re2_Replace(VALUE self, VALUE str, VALUE pattern,
|
|
1421
1433
|
* RE2.GlobalReplace("whoops-doops", re2, "e") #=> "wheps-deps"
|
1422
1434
|
* RE2.GlobalReplace("hello there", "e", "i") #=> "hillo thiri"
|
1423
1435
|
*/
|
1424
|
-
static VALUE re2_GlobalReplace(VALUE
|
1436
|
+
static VALUE re2_GlobalReplace(VALUE, VALUE str, VALUE pattern,
|
1425
1437
|
VALUE rewrite) {
|
1426
|
-
|
1438
|
+
/* Ensure rewrite is a string. */
|
1439
|
+
StringValue(rewrite);
|
1427
1440
|
|
1428
1441
|
/* Take a copy of str so it can be modified in-place by
|
1429
1442
|
* RE2::GlobalReplace.
|
@@ -1434,13 +1447,16 @@ static VALUE re2_GlobalReplace(VALUE self, VALUE str, VALUE pattern,
|
|
1434
1447
|
/* Do the replacement. */
|
1435
1448
|
if (rb_obj_is_kind_of(pattern, re2_cRegexp)) {
|
1436
1449
|
Data_Get_Struct(pattern, re2_pattern, p);
|
1437
|
-
RE2::GlobalReplace(&str_as_string, *p->pattern,
|
1450
|
+
RE2::GlobalReplace(&str_as_string, *p->pattern, RSTRING_PTR(rewrite));
|
1438
1451
|
|
1439
1452
|
return encoded_str_new(str_as_string.data(), str_as_string.size(),
|
1440
1453
|
p->pattern->options().encoding());
|
1441
1454
|
} else {
|
1442
|
-
|
1443
|
-
|
1455
|
+
/* Ensure pattern is a string. */
|
1456
|
+
StringValue(pattern);
|
1457
|
+
|
1458
|
+
RE2::GlobalReplace(&str_as_string, RSTRING_PTR(pattern),
|
1459
|
+
RSTRING_PTR(rewrite));
|
1444
1460
|
|
1445
1461
|
return encoded_str_new(str_as_string.data(), str_as_string.size(), RE2::Options::EncodingUTF8);
|
1446
1462
|
}
|
@@ -1456,9 +1472,10 @@ static VALUE re2_GlobalReplace(VALUE self, VALUE str, VALUE pattern,
|
|
1456
1472
|
* @example
|
1457
1473
|
* RE2::Regexp.escape("1.5-2.0?") #=> "1\.5\-2\.0\?"
|
1458
1474
|
*/
|
1459
|
-
static VALUE re2_QuoteMeta(VALUE
|
1460
|
-
|
1461
|
-
|
1475
|
+
static VALUE re2_QuoteMeta(VALUE, VALUE unquoted) {
|
1476
|
+
StringValue(unquoted);
|
1477
|
+
|
1478
|
+
std::string quoted_string = RE2::QuoteMeta(RSTRING_PTR(unquoted));
|
1462
1479
|
|
1463
1480
|
return rb_str_new(quoted_string.data(), quoted_string.size());
|
1464
1481
|
}
|
@@ -1521,15 +1538,12 @@ static VALUE re2_set_allocate(VALUE klass) {
|
|
1521
1538
|
static VALUE re2_set_initialize(int argc, VALUE *argv, VALUE self) {
|
1522
1539
|
VALUE anchor, options;
|
1523
1540
|
re2_set *s;
|
1524
|
-
RE2::Anchor re2_anchor = RE2::UNANCHORED;
|
1525
|
-
RE2::Options re2_options;
|
1526
1541
|
|
1527
1542
|
rb_scan_args(argc, argv, "02", &anchor, &options);
|
1528
1543
|
Data_Get_Struct(self, re2_set, s);
|
1529
1544
|
|
1530
|
-
|
1531
|
-
|
1532
|
-
}
|
1545
|
+
RE2::Anchor re2_anchor = RE2::UNANCHORED;
|
1546
|
+
|
1533
1547
|
if (!NIL_P(anchor)) {
|
1534
1548
|
Check_Type(anchor, T_SYMBOL);
|
1535
1549
|
ID id_anchor = SYM2ID(anchor);
|
@@ -1544,6 +1558,12 @@ static VALUE re2_set_initialize(int argc, VALUE *argv, VALUE self) {
|
|
1544
1558
|
}
|
1545
1559
|
}
|
1546
1560
|
|
1561
|
+
RE2::Options re2_options;
|
1562
|
+
|
1563
|
+
if (RTEST(options)) {
|
1564
|
+
parse_re2_options(&re2_options, options);
|
1565
|
+
}
|
1566
|
+
|
1547
1567
|
s->set = new(std::nothrow) RE2::Set(re2_options, re2_anchor);
|
1548
1568
|
if (s->set == 0) {
|
1549
1569
|
rb_raise(rb_eNoMemError, "not enough memory to allocate RE2::Set object");
|
@@ -1566,14 +1586,24 @@ static VALUE re2_set_initialize(int argc, VALUE *argv, VALUE self) {
|
|
1566
1586
|
*/
|
1567
1587
|
static VALUE re2_set_add(VALUE self, VALUE pattern) {
|
1568
1588
|
StringValue(pattern);
|
1569
|
-
|
1570
|
-
std::string err;
|
1589
|
+
|
1571
1590
|
re2_set *s;
|
1572
1591
|
Data_Get_Struct(self, re2_set, s);
|
1573
1592
|
|
1574
|
-
|
1593
|
+
/* To prevent the memory of the err string leaking when we call rb_raise,
|
1594
|
+
* take a copy of it and let it go out of scope.
|
1595
|
+
*/
|
1596
|
+
char msg[100];
|
1597
|
+
int index;
|
1598
|
+
|
1599
|
+
{
|
1600
|
+
std::string err;
|
1601
|
+
index = s->set->Add(RSTRING_PTR(pattern), &err);
|
1602
|
+
strlcpy(msg, err.c_str(), sizeof(msg));
|
1603
|
+
}
|
1604
|
+
|
1575
1605
|
if (index < 0) {
|
1576
|
-
rb_raise(rb_eArgError, "str rejected by RE2::Set->Add(): %s",
|
1606
|
+
rb_raise(rb_eArgError, "str rejected by RE2::Set->Add(): %s", msg);
|
1577
1607
|
}
|
1578
1608
|
|
1579
1609
|
return INT2FIX(index);
|
@@ -1603,8 +1633,7 @@ static VALUE re2_set_compile(VALUE self) {
|
|
1603
1633
|
*
|
1604
1634
|
* @return [Bool] whether the underlying re2 outputs error information from Set matches
|
1605
1635
|
*/
|
1606
|
-
static VALUE re2_set_match_raises_errors_p(VALUE
|
1607
|
-
UNUSED(self);
|
1636
|
+
static VALUE re2_set_match_raises_errors_p(VALUE) {
|
1608
1637
|
#ifdef HAVE_ERROR_INFO_ARGUMENT
|
1609
1638
|
return Qtrue;
|
1610
1639
|
#else
|
@@ -1658,7 +1687,6 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1658
1687
|
rb_scan_args(argc, argv, "11", &str, &options);
|
1659
1688
|
|
1660
1689
|
StringValue(str);
|
1661
|
-
re2::StringPiece data(RSTRING_PTR(str), RSTRING_LEN(str));
|
1662
1690
|
re2_set *s;
|
1663
1691
|
Data_Get_Struct(self, re2_set, s);
|
1664
1692
|
|
@@ -1676,7 +1704,7 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1676
1704
|
if (raise_exception) {
|
1677
1705
|
#ifdef HAVE_ERROR_INFO_ARGUMENT
|
1678
1706
|
RE2::Set::ErrorInfo e;
|
1679
|
-
bool match_failed = !s->set->Match(
|
1707
|
+
bool match_failed = !s->set->Match(RSTRING_PTR(str), &v, &e);
|
1680
1708
|
VALUE result = rb_ary_new2(v.size());
|
1681
1709
|
|
1682
1710
|
if (match_failed) {
|
@@ -1703,7 +1731,7 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1703
1731
|
rb_raise(re2_eSetUnsupportedError, "current version of RE2::Set::Match() does not output error information, :exception option can only be set to false");
|
1704
1732
|
#endif
|
1705
1733
|
} else {
|
1706
|
-
bool matched = s->set->Match(
|
1734
|
+
bool matched = s->set->Match(RSTRING_PTR(str), &v);
|
1707
1735
|
VALUE result = rb_ary_new2(v.size());
|
1708
1736
|
|
1709
1737
|
if (matched) {
|
@@ -1716,12 +1744,7 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1716
1744
|
}
|
1717
1745
|
}
|
1718
1746
|
|
1719
|
-
|
1720
|
-
* that YARD can parse it.
|
1721
|
-
*/
|
1722
|
-
extern "C" void Init_re2(void);
|
1723
|
-
|
1724
|
-
void Init_re2(void) {
|
1747
|
+
extern "C" void Init_re2(void) {
|
1725
1748
|
re2_mRE2 = rb_define_module("RE2");
|
1726
1749
|
re2_cRegexp = rb_define_class_under(re2_mRE2, "Regexp", rb_cObject);
|
1727
1750
|
re2_cMatchData = rb_define_class_under(re2_mRE2, "MatchData", rb_cObject);
|
data/lib/2.6/re2.so
CHANGED
Binary file
|
data/lib/2.7/re2.so
CHANGED
Binary file
|
data/lib/3.0/re2.so
CHANGED
Binary file
|
data/lib/3.1/re2.so
CHANGED
Binary file
|
data/lib/3.2/re2.so
CHANGED
Binary file
|
data/lib/re2/version.rb
CHANGED
data/spec/re2/set_spec.rb
CHANGED
@@ -40,6 +40,13 @@ RSpec.describe RE2::Set do
|
|
40
40
|
"anchor should be one of: :unanchored, :anchor_start, :anchor_both"
|
41
41
|
)
|
42
42
|
end
|
43
|
+
|
44
|
+
it "raises an error if given an invalid anchor and options" do
|
45
|
+
expect { RE2::Set.new(:not_a_valid_anchor, :case_sensitive => false) }.to raise_error(
|
46
|
+
ArgumentError,
|
47
|
+
"anchor should be one of: :unanchored, :anchor_start, :anchor_both"
|
48
|
+
)
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
describe "#add" do
|
@@ -54,7 +61,13 @@ RSpec.describe RE2::Set do
|
|
54
61
|
it "rejects invalid patterns when added" do
|
55
62
|
set = RE2::Set.new(:unanchored, :log_errors => false)
|
56
63
|
|
57
|
-
expect { set.add("???") }.to raise_error(ArgumentError, /str rejected by RE2::Set->Add()/)
|
64
|
+
expect { set.add("???") }.to raise_error(ArgumentError, /str rejected by RE2::Set->Add\(\)/)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "truncates error messages to 100 characters" do
|
68
|
+
set = RE2::Set.new(:unanchored, :log_errors => false)
|
69
|
+
|
70
|
+
expect { set.add("(?P<#{'o' * 200}") }.to raise_error(ArgumentError, "str rejected by RE2::Set->Add(): invalid named capture group: (?P<oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo")
|
58
71
|
end
|
59
72
|
|
60
73
|
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.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: arm-linux
|
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: 2023-09-
|
12
|
+
date: 2023-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|