re2 2.1.2-x86_64-darwin → 2.1.3-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/ext/re2/re2.cc +72 -52
- data/lib/2.6/re2.bundle +0 -0
- data/lib/2.7/re2.bundle +0 -0
- data/lib/3.0/re2.bundle +0 -0
- data/lib/3.1/re2.bundle +0 -0
- data/lib/3.2/re2.bundle +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: 93a94e5db8e0b2152c1e07fc1f3990d961caced5df2986aac2ef84a328627ea7
|
4
|
+
data.tar.gz: 8fdde3b1e2aac352ead339d36b7ac5a9837724fe66757e1319db19247ce89be5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bae368ab6d6ea149fed7cab56cdbd9ebb1266a673f6d6667920fa0c1bb3d444c8439170e90a608dd1b92dfa0dac58e573d11b7d0f85c4c2a2323b75d0e1275e
|
7
|
+
data.tar.gz: 7baf5050b46c694754a14cfb80331930747bbcb2e61f25e9271d6765bfc0e0652b3f7ee3e5510d17bcd93aa204b935359d440dd335b06202c011765018ffc049
|
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)
|
@@ -264,6 +264,11 @@ Contributions
|
|
264
264
|
using `RE2::Scanner#scan` with an invalid regular expression;
|
265
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;
|
@@ -373,9 +373,9 @@ static VALUE re2_matchdata_begin(const VALUE self, VALUE n) {
|
|
373
373
|
if (match == NULL) {
|
374
374
|
return Qnil;
|
375
375
|
} else {
|
376
|
-
long offset = match->data() -
|
376
|
+
long offset = match->data() - RSTRING_PTR(m->text);
|
377
377
|
|
378
|
-
return LONG2NUM(rb_str_sublen(
|
378
|
+
return LONG2NUM(rb_str_sublen(m->text, offset));
|
379
379
|
}
|
380
380
|
}
|
381
381
|
|
@@ -398,9 +398,9 @@ static VALUE re2_matchdata_end(const VALUE self, VALUE n) {
|
|
398
398
|
if (match == NULL) {
|
399
399
|
return Qnil;
|
400
400
|
} else {
|
401
|
-
long offset = (match->data() -
|
401
|
+
long offset = (match->data() - RSTRING_PTR(m->text)) + match->size();
|
402
402
|
|
403
|
-
return LONG2NUM(rb_str_sublen(
|
403
|
+
return LONG2NUM(rb_str_sublen(m->text, offset));
|
404
404
|
}
|
405
405
|
}
|
406
406
|
|
@@ -564,7 +564,7 @@ static VALUE re2_matchdata_aref(int argc, VALUE *argv, const VALUE self) {
|
|
564
564
|
rb_scan_args(argc, argv, "11", &idx, &rest);
|
565
565
|
|
566
566
|
if (TYPE(idx) == T_STRING) {
|
567
|
-
return re2_matchdata_named_match(
|
567
|
+
return re2_matchdata_named_match(RSTRING_PTR(idx), self);
|
568
568
|
} else if (SYMBOL_P(idx)) {
|
569
569
|
return re2_matchdata_named_match(rb_id2name(SYM2ID(idx)), self);
|
570
570
|
} else if (!NIL_P(rest) || !FIXNUM_P(idx) || FIX2INT(idx) < 0) {
|
@@ -617,7 +617,7 @@ static VALUE re2_matchdata_inspect(const VALUE self) {
|
|
617
617
|
if (match == Qnil) {
|
618
618
|
output << "nil";
|
619
619
|
} else {
|
620
|
-
output << "\"" <<
|
620
|
+
output << "\"" << RSTRING_PTR(match) << "\"";
|
621
621
|
}
|
622
622
|
}
|
623
623
|
|
@@ -742,9 +742,7 @@ static VALUE re2_matchdata_deconstruct_keys(const VALUE self, const VALUE keys)
|
|
742
742
|
* @see RE2::Regexp#initialize
|
743
743
|
*
|
744
744
|
*/
|
745
|
-
static VALUE re2_re2(int argc, VALUE *argv, VALUE
|
746
|
-
UNUSED(self);
|
747
|
-
|
745
|
+
static VALUE re2_re2(int argc, VALUE *argv, VALUE) {
|
748
746
|
return rb_class_new_instance(argc, argv, re2_cRegexp);
|
749
747
|
}
|
750
748
|
|
@@ -788,15 +786,19 @@ static VALUE re2_regexp_initialize(int argc, VALUE *argv, VALUE self) {
|
|
788
786
|
re2_pattern *p;
|
789
787
|
|
790
788
|
rb_scan_args(argc, argv, "11", &pattern, &options);
|
789
|
+
|
790
|
+
/* Ensure pattern is a string. */
|
791
|
+
StringValue(pattern);
|
792
|
+
|
791
793
|
Data_Get_Struct(self, re2_pattern, p);
|
792
794
|
|
793
795
|
if (RTEST(options)) {
|
794
796
|
RE2::Options re2_options;
|
795
797
|
parse_re2_options(&re2_options, options);
|
796
798
|
|
797
|
-
p->pattern = new(std::nothrow) RE2(
|
799
|
+
p->pattern = new(std::nothrow) RE2(RSTRING_PTR(pattern), re2_options);
|
798
800
|
} else {
|
799
|
-
p->pattern = new(std::nothrow) RE2(
|
801
|
+
p->pattern = new(std::nothrow) RE2(RSTRING_PTR(pattern));
|
800
802
|
}
|
801
803
|
|
802
804
|
if (p->pattern == 0) {
|
@@ -1285,10 +1287,10 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
1285
1287
|
|
1286
1288
|
if (n == 0) {
|
1287
1289
|
#ifdef HAVE_ENDPOS_ARGUMENT
|
1288
|
-
bool matched = p->pattern->Match(
|
1290
|
+
bool matched = p->pattern->Match(RSTRING_PTR(text), 0,
|
1289
1291
|
RSTRING_LEN(text), RE2::UNANCHORED, 0, 0);
|
1290
1292
|
#else
|
1291
|
-
bool matched = p->pattern->Match(
|
1293
|
+
bool matched = p->pattern->Match(RSTRING_PTR(text), 0, RE2::UNANCHORED,
|
1292
1294
|
0, 0);
|
1293
1295
|
#endif
|
1294
1296
|
return BOOL2RUBY(matched);
|
@@ -1311,10 +1313,10 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
1311
1313
|
m->number_of_matches = n;
|
1312
1314
|
|
1313
1315
|
#ifdef HAVE_ENDPOS_ARGUMENT
|
1314
|
-
bool matched = p->pattern->Match(
|
1316
|
+
bool matched = p->pattern->Match(RSTRING_PTR(m->text), 0,
|
1315
1317
|
RSTRING_LEN(m->text), RE2::UNANCHORED, m->matches, n);
|
1316
1318
|
#else
|
1317
|
-
bool matched = p->pattern->Match(
|
1319
|
+
bool matched = p->pattern->Match(RSTRING_PTR(m->text), 0,
|
1318
1320
|
RE2::UNANCHORED, m->matches, n);
|
1319
1321
|
#endif
|
1320
1322
|
if (matched) {
|
@@ -1344,6 +1346,9 @@ static VALUE re2_regexp_match_p(const VALUE self, VALUE text) {
|
|
1344
1346
|
* c = RE2::Regexp.new('(\w+)').scan("Foo bar baz")
|
1345
1347
|
*/
|
1346
1348
|
static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
1349
|
+
/* Ensure text is a string. */
|
1350
|
+
StringValue(text);
|
1351
|
+
|
1347
1352
|
re2_pattern *p;
|
1348
1353
|
re2_scanner *c;
|
1349
1354
|
|
@@ -1351,7 +1356,7 @@ static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
|
1351
1356
|
VALUE scanner = rb_class_new_instance(0, 0, re2_cScanner);
|
1352
1357
|
Data_Get_Struct(scanner, re2_scanner, c);
|
1353
1358
|
|
1354
|
-
c->input = new(std::nothrow) re2::StringPiece(
|
1359
|
+
c->input = new(std::nothrow) re2::StringPiece(RSTRING_PTR(text));
|
1355
1360
|
c->regexp = self;
|
1356
1361
|
c->text = text;
|
1357
1362
|
|
@@ -1383,9 +1388,11 @@ static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
|
1383
1388
|
* re2 = RE2::Regexp.new("hel+o")
|
1384
1389
|
* RE2.Replace("hello there", re2, "yo") #=> "yo there"
|
1385
1390
|
*/
|
1386
|
-
static VALUE re2_Replace(VALUE
|
1391
|
+
static VALUE re2_Replace(VALUE, VALUE str, VALUE pattern,
|
1387
1392
|
VALUE rewrite) {
|
1388
|
-
|
1393
|
+
/* Ensure rewrite is a string. */
|
1394
|
+
StringValue(rewrite);
|
1395
|
+
|
1389
1396
|
re2_pattern *p;
|
1390
1397
|
|
1391
1398
|
/* Take a copy of str so it can be modified in-place by
|
@@ -1396,13 +1403,15 @@ static VALUE re2_Replace(VALUE self, VALUE str, VALUE pattern,
|
|
1396
1403
|
/* Do the replacement. */
|
1397
1404
|
if (rb_obj_is_kind_of(pattern, re2_cRegexp)) {
|
1398
1405
|
Data_Get_Struct(pattern, re2_pattern, p);
|
1399
|
-
RE2::Replace(&str_as_string, *p->pattern,
|
1406
|
+
RE2::Replace(&str_as_string, *p->pattern, RSTRING_PTR(rewrite));
|
1400
1407
|
|
1401
1408
|
return encoded_str_new(str_as_string.data(), str_as_string.size(),
|
1402
1409
|
p->pattern->options().encoding());
|
1403
1410
|
} else {
|
1404
|
-
|
1405
|
-
|
1411
|
+
/* Ensure pattern is a string. */
|
1412
|
+
StringValue(pattern);
|
1413
|
+
|
1414
|
+
RE2::Replace(&str_as_string, RSTRING_PTR(pattern), RSTRING_PTR(rewrite));
|
1406
1415
|
|
1407
1416
|
return encoded_str_new(str_as_string.data(), str_as_string.size(), RE2::Options::EncodingUTF8);
|
1408
1417
|
}
|
@@ -1424,9 +1433,10 @@ static VALUE re2_Replace(VALUE self, VALUE str, VALUE pattern,
|
|
1424
1433
|
* RE2.GlobalReplace("whoops-doops", re2, "e") #=> "wheps-deps"
|
1425
1434
|
* RE2.GlobalReplace("hello there", "e", "i") #=> "hillo thiri"
|
1426
1435
|
*/
|
1427
|
-
static VALUE re2_GlobalReplace(VALUE
|
1436
|
+
static VALUE re2_GlobalReplace(VALUE, VALUE str, VALUE pattern,
|
1428
1437
|
VALUE rewrite) {
|
1429
|
-
|
1438
|
+
/* Ensure rewrite is a string. */
|
1439
|
+
StringValue(rewrite);
|
1430
1440
|
|
1431
1441
|
/* Take a copy of str so it can be modified in-place by
|
1432
1442
|
* RE2::GlobalReplace.
|
@@ -1437,13 +1447,16 @@ static VALUE re2_GlobalReplace(VALUE self, VALUE str, VALUE pattern,
|
|
1437
1447
|
/* Do the replacement. */
|
1438
1448
|
if (rb_obj_is_kind_of(pattern, re2_cRegexp)) {
|
1439
1449
|
Data_Get_Struct(pattern, re2_pattern, p);
|
1440
|
-
RE2::GlobalReplace(&str_as_string, *p->pattern,
|
1450
|
+
RE2::GlobalReplace(&str_as_string, *p->pattern, RSTRING_PTR(rewrite));
|
1441
1451
|
|
1442
1452
|
return encoded_str_new(str_as_string.data(), str_as_string.size(),
|
1443
1453
|
p->pattern->options().encoding());
|
1444
1454
|
} else {
|
1445
|
-
|
1446
|
-
|
1455
|
+
/* Ensure pattern is a string. */
|
1456
|
+
StringValue(pattern);
|
1457
|
+
|
1458
|
+
RE2::GlobalReplace(&str_as_string, RSTRING_PTR(pattern),
|
1459
|
+
RSTRING_PTR(rewrite));
|
1447
1460
|
|
1448
1461
|
return encoded_str_new(str_as_string.data(), str_as_string.size(), RE2::Options::EncodingUTF8);
|
1449
1462
|
}
|
@@ -1459,9 +1472,10 @@ static VALUE re2_GlobalReplace(VALUE self, VALUE str, VALUE pattern,
|
|
1459
1472
|
* @example
|
1460
1473
|
* RE2::Regexp.escape("1.5-2.0?") #=> "1\.5\-2\.0\?"
|
1461
1474
|
*/
|
1462
|
-
static VALUE re2_QuoteMeta(VALUE
|
1463
|
-
|
1464
|
-
|
1475
|
+
static VALUE re2_QuoteMeta(VALUE, VALUE unquoted) {
|
1476
|
+
StringValue(unquoted);
|
1477
|
+
|
1478
|
+
std::string quoted_string = RE2::QuoteMeta(RSTRING_PTR(unquoted));
|
1465
1479
|
|
1466
1480
|
return rb_str_new(quoted_string.data(), quoted_string.size());
|
1467
1481
|
}
|
@@ -1524,15 +1538,12 @@ static VALUE re2_set_allocate(VALUE klass) {
|
|
1524
1538
|
static VALUE re2_set_initialize(int argc, VALUE *argv, VALUE self) {
|
1525
1539
|
VALUE anchor, options;
|
1526
1540
|
re2_set *s;
|
1527
|
-
RE2::Anchor re2_anchor = RE2::UNANCHORED;
|
1528
|
-
RE2::Options re2_options;
|
1529
1541
|
|
1530
1542
|
rb_scan_args(argc, argv, "02", &anchor, &options);
|
1531
1543
|
Data_Get_Struct(self, re2_set, s);
|
1532
1544
|
|
1533
|
-
|
1534
|
-
|
1535
|
-
}
|
1545
|
+
RE2::Anchor re2_anchor = RE2::UNANCHORED;
|
1546
|
+
|
1536
1547
|
if (!NIL_P(anchor)) {
|
1537
1548
|
Check_Type(anchor, T_SYMBOL);
|
1538
1549
|
ID id_anchor = SYM2ID(anchor);
|
@@ -1547,6 +1558,12 @@ static VALUE re2_set_initialize(int argc, VALUE *argv, VALUE self) {
|
|
1547
1558
|
}
|
1548
1559
|
}
|
1549
1560
|
|
1561
|
+
RE2::Options re2_options;
|
1562
|
+
|
1563
|
+
if (RTEST(options)) {
|
1564
|
+
parse_re2_options(&re2_options, options);
|
1565
|
+
}
|
1566
|
+
|
1550
1567
|
s->set = new(std::nothrow) RE2::Set(re2_options, re2_anchor);
|
1551
1568
|
if (s->set == 0) {
|
1552
1569
|
rb_raise(rb_eNoMemError, "not enough memory to allocate RE2::Set object");
|
@@ -1569,14 +1586,24 @@ static VALUE re2_set_initialize(int argc, VALUE *argv, VALUE self) {
|
|
1569
1586
|
*/
|
1570
1587
|
static VALUE re2_set_add(VALUE self, VALUE pattern) {
|
1571
1588
|
StringValue(pattern);
|
1572
|
-
|
1573
|
-
std::string err;
|
1589
|
+
|
1574
1590
|
re2_set *s;
|
1575
1591
|
Data_Get_Struct(self, re2_set, s);
|
1576
1592
|
|
1577
|
-
|
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
|
+
|
1578
1605
|
if (index < 0) {
|
1579
|
-
rb_raise(rb_eArgError, "str rejected by RE2::Set->Add(): %s",
|
1606
|
+
rb_raise(rb_eArgError, "str rejected by RE2::Set->Add(): %s", msg);
|
1580
1607
|
}
|
1581
1608
|
|
1582
1609
|
return INT2FIX(index);
|
@@ -1606,8 +1633,7 @@ static VALUE re2_set_compile(VALUE self) {
|
|
1606
1633
|
*
|
1607
1634
|
* @return [Bool] whether the underlying re2 outputs error information from Set matches
|
1608
1635
|
*/
|
1609
|
-
static VALUE re2_set_match_raises_errors_p(VALUE
|
1610
|
-
UNUSED(self);
|
1636
|
+
static VALUE re2_set_match_raises_errors_p(VALUE) {
|
1611
1637
|
#ifdef HAVE_ERROR_INFO_ARGUMENT
|
1612
1638
|
return Qtrue;
|
1613
1639
|
#else
|
@@ -1661,7 +1687,6 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1661
1687
|
rb_scan_args(argc, argv, "11", &str, &options);
|
1662
1688
|
|
1663
1689
|
StringValue(str);
|
1664
|
-
re2::StringPiece data(RSTRING_PTR(str), RSTRING_LEN(str));
|
1665
1690
|
re2_set *s;
|
1666
1691
|
Data_Get_Struct(self, re2_set, s);
|
1667
1692
|
|
@@ -1679,7 +1704,7 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1679
1704
|
if (raise_exception) {
|
1680
1705
|
#ifdef HAVE_ERROR_INFO_ARGUMENT
|
1681
1706
|
RE2::Set::ErrorInfo e;
|
1682
|
-
bool match_failed = !s->set->Match(
|
1707
|
+
bool match_failed = !s->set->Match(RSTRING_PTR(str), &v, &e);
|
1683
1708
|
VALUE result = rb_ary_new2(v.size());
|
1684
1709
|
|
1685
1710
|
if (match_failed) {
|
@@ -1706,7 +1731,7 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1706
1731
|
rb_raise(re2_eSetUnsupportedError, "current version of RE2::Set::Match() does not output error information, :exception option can only be set to false");
|
1707
1732
|
#endif
|
1708
1733
|
} else {
|
1709
|
-
bool matched = s->set->Match(
|
1734
|
+
bool matched = s->set->Match(RSTRING_PTR(str), &v);
|
1710
1735
|
VALUE result = rb_ary_new2(v.size());
|
1711
1736
|
|
1712
1737
|
if (matched) {
|
@@ -1719,12 +1744,7 @@ static VALUE re2_set_match(int argc, VALUE *argv, const VALUE self) {
|
|
1719
1744
|
}
|
1720
1745
|
}
|
1721
1746
|
|
1722
|
-
|
1723
|
-
* that YARD can parse it.
|
1724
|
-
*/
|
1725
|
-
extern "C" void Init_re2(void);
|
1726
|
-
|
1727
|
-
void Init_re2(void) {
|
1747
|
+
extern "C" void Init_re2(void) {
|
1728
1748
|
re2_mRE2 = rb_define_module("RE2");
|
1729
1749
|
re2_cRegexp = rb_define_class_under(re2_mRE2, "Regexp", rb_cObject);
|
1730
1750
|
re2_cMatchData = rb_define_class_under(re2_mRE2, "MatchData", rb_cObject);
|
data/lib/2.6/re2.bundle
CHANGED
Binary file
|
data/lib/2.7/re2.bundle
CHANGED
Binary file
|
data/lib/3.0/re2.bundle
CHANGED
Binary file
|
data/lib/3.1/re2.bundle
CHANGED
Binary file
|
data/lib/3.2/re2.bundle
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: x86_64-darwin
|
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
|