re2 2.19.0 → 2.19.1
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/Rakefile +1 -1
- data/ext/re2/re2.cc +9 -12
- data/lib/re2/version.rb +1 -1
- data/spec/re2/scanner_spec.rb +42 -1
- 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: 687a91fb04d7c8f6d5082fd85a53b8cc08d57207dc2dd73a9d2de7ddc5700094
|
|
4
|
+
data.tar.gz: 0f2be0a7f418f1dc21bec364b8464b1e7afbd849ef51dd6fcbbdf9795afad302
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c084f2d6e64dece6fa322d22217bc40cfc82ce9f25360c0e69accf1c22e633a072d8d162698d98f1cc8e5caa6f23bed5843dfbe3f1e0d88f3fe5b92df68edaf3
|
|
7
|
+
data.tar.gz: ab17cd9b2443fb6717d8f6995254cf1547af83914ef9e0ce7c34e5babb8639f04157d6c6239da45b59e5b30a1b014b136dc4945a6ce5a4fe02112e691c159e51
|
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.19.
|
|
9
|
+
**Current version:** 2.19.1
|
|
10
10
|
**Bundled RE2 version:** libre2.11 (2025-08-05)
|
|
11
11
|
|
|
12
12
|
```ruby
|
data/Rakefile
CHANGED
|
@@ -76,7 +76,7 @@ namespace :gem do
|
|
|
76
76
|
sudo apt-get install -y cmake=3.22.2-0kitware1ubuntu20.04.1 cmake-data=3.22.2-0kitware1ubuntu20.04.1 &&
|
|
77
77
|
rbenv shell 3.1.6 &&
|
|
78
78
|
gem install bundler --no-document &&
|
|
79
|
-
bundle &&
|
|
79
|
+
bundle install &&
|
|
80
80
|
bundle exec rake native:#{platform} pkg/#{re2_gemspec.full_name}-#{Gem::Platform.new(platform)}.gem PATH="/usr/local/bin:$PATH"
|
|
81
81
|
SCRIPT
|
|
82
82
|
end
|
data/ext/re2/re2.cc
CHANGED
|
@@ -136,14 +136,13 @@ static void parse_re2_options(RE2::Options* re2_options, const VALUE options) {
|
|
|
136
136
|
static void re2_matchdata_mark(void *ptr) {
|
|
137
137
|
re2_matchdata *m = reinterpret_cast<re2_matchdata *>(ptr);
|
|
138
138
|
rb_gc_mark_movable(m->regexp);
|
|
139
|
-
|
|
139
|
+
rb_gc_mark(m->text);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
|
143
143
|
static void re2_matchdata_compact(void *ptr) {
|
|
144
144
|
re2_matchdata *m = reinterpret_cast<re2_matchdata *>(ptr);
|
|
145
145
|
m->regexp = rb_gc_location(m->regexp);
|
|
146
|
-
m->text = rb_gc_location(m->text);
|
|
147
146
|
}
|
|
148
147
|
#endif
|
|
149
148
|
|
|
@@ -183,14 +182,13 @@ static const rb_data_type_t re2_matchdata_data_type = {
|
|
|
183
182
|
static void re2_scanner_mark(void *ptr) {
|
|
184
183
|
re2_scanner *s = reinterpret_cast<re2_scanner *>(ptr);
|
|
185
184
|
rb_gc_mark_movable(s->regexp);
|
|
186
|
-
|
|
185
|
+
rb_gc_mark(s->text);
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
|
190
189
|
static void re2_scanner_compact(void *ptr) {
|
|
191
190
|
re2_scanner *s = reinterpret_cast<re2_scanner *>(ptr);
|
|
192
191
|
s->regexp = rb_gc_location(s->regexp);
|
|
193
|
-
s->text = rb_gc_location(s->text);
|
|
194
192
|
}
|
|
195
193
|
#endif
|
|
196
194
|
|
|
@@ -290,9 +288,11 @@ static VALUE re2_matchdata_string(const VALUE self) {
|
|
|
290
288
|
}
|
|
291
289
|
|
|
292
290
|
/*
|
|
293
|
-
* Returns the text supplied when incrementally matching with
|
|
291
|
+
* Returns a frozen copy of the text supplied when incrementally matching with
|
|
294
292
|
* {RE2::Regexp#scan}.
|
|
295
293
|
*
|
|
294
|
+
* If the text was already a frozen string, returns the original.
|
|
295
|
+
*
|
|
296
296
|
* @return [String] the original string passed to {RE2::Regexp#scan}
|
|
297
297
|
* @example
|
|
298
298
|
* c = RE2::Regexp.new('(\d+)').scan("foo")
|
|
@@ -1534,10 +1534,7 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, const VALUE self) {
|
|
|
1534
1534
|
TypedData_Get_Struct(matchdata, re2_matchdata, &re2_matchdata_data_type, m);
|
|
1535
1535
|
m->matches = new(std::nothrow) re2::StringPiece[n];
|
|
1536
1536
|
RB_OBJ_WRITE(matchdata, &m->regexp, self);
|
|
1537
|
-
|
|
1538
|
-
text = rb_str_freeze(rb_str_dup(text));
|
|
1539
|
-
}
|
|
1540
|
-
RB_OBJ_WRITE(matchdata, &m->text, text);
|
|
1537
|
+
RB_OBJ_WRITE(matchdata, &m->text, rb_str_new_frozen(text));
|
|
1541
1538
|
|
|
1542
1539
|
if (m->matches == 0) {
|
|
1543
1540
|
rb_raise(rb_eNoMemError,
|
|
@@ -1626,10 +1623,10 @@ static VALUE re2_regexp_scan(const VALUE self, VALUE text) {
|
|
|
1626
1623
|
VALUE scanner = rb_class_new_instance(0, 0, re2_cScanner);
|
|
1627
1624
|
TypedData_Get_Struct(scanner, re2_scanner, &re2_scanner_data_type, c);
|
|
1628
1625
|
|
|
1629
|
-
c->input = new(std::nothrow) re2::StringPiece(
|
|
1630
|
-
RSTRING_PTR(text), RSTRING_LEN(text));
|
|
1631
1626
|
RB_OBJ_WRITE(scanner, &c->regexp, self);
|
|
1632
|
-
RB_OBJ_WRITE(scanner, &c->text, text);
|
|
1627
|
+
RB_OBJ_WRITE(scanner, &c->text, rb_str_new_frozen(text));
|
|
1628
|
+
c->input = new(std::nothrow) re2::StringPiece(
|
|
1629
|
+
RSTRING_PTR(c->text), RSTRING_LEN(c->text));
|
|
1633
1630
|
|
|
1634
1631
|
if (p->pattern->ok()) {
|
|
1635
1632
|
c->number_of_capturing_groups = p->pattern->NumberOfCapturingGroups();
|
data/lib/re2/version.rb
CHANGED
data/spec/re2/scanner_spec.rb
CHANGED
|
@@ -11,7 +11,39 @@ RSpec.describe RE2::Scanner do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
describe "#string" do
|
|
14
|
-
it "returns the
|
|
14
|
+
it "returns the text for the scanner" do
|
|
15
|
+
re = RE2::Regexp.new('(\w+)')
|
|
16
|
+
text = "It is a truth"
|
|
17
|
+
scanner = re.scan(text)
|
|
18
|
+
|
|
19
|
+
expect(scanner.string).to eq("It is a truth")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "returns a frozen string" do
|
|
23
|
+
re = RE2::Regexp.new('(\w+)')
|
|
24
|
+
text = "It is a truth"
|
|
25
|
+
scanner = re.scan(text)
|
|
26
|
+
|
|
27
|
+
expect(scanner.string).to be_frozen
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "freezes unfrozen strings" do
|
|
31
|
+
re = RE2::Regexp.new('(\w+)')
|
|
32
|
+
text = +"It is a truth"
|
|
33
|
+
scanner = re.scan(text)
|
|
34
|
+
|
|
35
|
+
expect(scanner.string).to be_frozen
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "copies unfrozen strings" do
|
|
39
|
+
re = RE2::Regexp.new('(\w+)')
|
|
40
|
+
text = +"It is a truth"
|
|
41
|
+
scanner = re.scan(text)
|
|
42
|
+
|
|
43
|
+
expect(scanner.string).to_not equal(text)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "does not copy the string if it was already frozen" do
|
|
15
47
|
re = RE2::Regexp.new('(\w+)')
|
|
16
48
|
text = "It is a truth"
|
|
17
49
|
scanner = re.scan(text)
|
|
@@ -162,6 +194,15 @@ RSpec.describe RE2::Scanner do
|
|
|
162
194
|
expect(scanner.scan).to eq(["world"])
|
|
163
195
|
expect(scanner.scan).to be_nil
|
|
164
196
|
end
|
|
197
|
+
|
|
198
|
+
it "works even if the original input is mutated" do
|
|
199
|
+
r = RE2::Regexp.new('(\w+)')
|
|
200
|
+
text = +"It is a truth universally acknowledged"
|
|
201
|
+
scanner = r.scan(text)
|
|
202
|
+
text.upcase!
|
|
203
|
+
|
|
204
|
+
expect(scanner.scan).to eq(["It"])
|
|
205
|
+
end
|
|
165
206
|
end
|
|
166
207
|
|
|
167
208
|
it "is enumerable" do
|