multi_string_replace 1.0.4 → 1.0.6
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/Gemfile.lock +3 -3
- data/ext/multi_string_replace/.sitearchdir.-.multi_string_replace.time +0 -0
- data/ext/multi_string_replace/aho_trie.c +8 -2
- data/ext/multi_string_replace/ahocorasick.c +5 -2
- data/ext/multi_string_replace/multi_string_replace.c +1 -1
- data/lib/multi_string_replace/version.rb +1 -1
- data/multi_string_replace.gemspec +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72d264c0f004c543ee366c43752b7d80b411a8cb95143c6e875a3426fe714b37
|
4
|
+
data.tar.gz: f7f1fc6527d23d292608b177af9522c250b18b9d8edda50159c50a3da728ec4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1a23c3980abb96c2016063b67c05aec5931af39606736763e427809ba6aec4892a321372bd4ff775108581192be19d992efab17509fc64ea83672015a29966
|
7
|
+
data.tar.gz: 365a8a589f2950c7b9641a03ac56ca29a3cbf865579013df03c0a52b61fc4d58a7c51e09ad435b7b3876ebfc22dc33c27df63a931b2972bd66afd63aad0ccf14
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
multi_string_replace (1.0.
|
4
|
+
multi_string_replace (1.0.6)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -28,11 +28,11 @@ PLATFORMS
|
|
28
28
|
ruby
|
29
29
|
|
30
30
|
DEPENDENCIES
|
31
|
-
bundler (~>
|
31
|
+
bundler (~> 2.3.26)
|
32
32
|
multi_string_replace!
|
33
33
|
rake
|
34
34
|
rake-compiler
|
35
35
|
rspec (~> 3.0)
|
36
36
|
|
37
37
|
BUNDLED WITH
|
38
|
-
|
38
|
+
2.3.26
|
File without changes
|
@@ -88,13 +88,16 @@ bool __aho_connect_link(struct aho_trie_node* p, struct aho_trie_node* q)
|
|
88
88
|
struct aho_trie_node *pf = NULL;
|
89
89
|
int i = 0;
|
90
90
|
/* is root node */
|
91
|
-
if (p->parent == NULL)
|
91
|
+
if (p->failure_link == NULL || p->parent == NULL)
|
92
92
|
{
|
93
93
|
q->failure_link = p;
|
94
94
|
return true;
|
95
95
|
}
|
96
96
|
|
97
97
|
pf = p->failure_link;
|
98
|
+
|
99
|
+
if( pf == NULL )
|
100
|
+
return true;
|
98
101
|
|
99
102
|
/* check child node of failure link(p) */
|
100
103
|
if (pf->child_list[q->text] != NULL)
|
@@ -207,6 +210,9 @@ bool __aho_find_trie_node(struct aho_trie_node** restrict start, const unsigned
|
|
207
210
|
|
208
211
|
search_node = *start;
|
209
212
|
|
213
|
+
if (search_node == NULL)
|
214
|
+
return false;
|
215
|
+
|
210
216
|
if (search_node->child_list[(unsigned int)text] != NULL)
|
211
217
|
{
|
212
218
|
/* find it! move to find child node! */
|
@@ -225,7 +231,7 @@ struct aho_text_t* aho_find_trie_node(struct aho_trie_node** restrict start, con
|
|
225
231
|
/* not found!
|
226
232
|
* when root node stop
|
227
233
|
*/
|
228
|
-
if( (*start)->parent == NULL)
|
234
|
+
if( *start == NULL || (*start)->parent == NULL)
|
229
235
|
{
|
230
236
|
return NULL;
|
231
237
|
}
|
@@ -49,7 +49,7 @@ int aho_add_match_text(struct ahocorasick * restrict aho, const char* text, unsi
|
|
49
49
|
|
50
50
|
a_text->id = aho->accumulate_text_id++;
|
51
51
|
|
52
|
-
memcpy(a_text->text, text, len);
|
52
|
+
memcpy(a_text->text, text, len + 1);
|
53
53
|
|
54
54
|
a_text->len = len;
|
55
55
|
a_text->prev = NULL;
|
@@ -90,15 +90,18 @@ bool aho_del_match_text(struct ahocorasick * restrict aho, const int id)
|
|
90
90
|
if (iter == aho->text_list_head)
|
91
91
|
{
|
92
92
|
aho->text_list_head = iter->next;
|
93
|
+
free(iter->text);
|
93
94
|
}
|
94
95
|
else if (iter == aho->text_list_tail)
|
95
96
|
{
|
96
97
|
aho->text_list_tail = iter->prev;
|
98
|
+
free(iter->text);
|
97
99
|
}
|
98
100
|
else
|
99
101
|
{
|
100
102
|
iter->prev->next = iter->next;
|
101
103
|
iter->next->prev = iter->prev;
|
104
|
+
free(iter->text);
|
102
105
|
}
|
103
106
|
free(iter);
|
104
107
|
aho->text_list_len--;
|
@@ -226,7 +229,7 @@ VALUE aho_replace_text(struct ahocorasick * restrict aho, const char* data,
|
|
226
229
|
last_concat_pos = i + 1;
|
227
230
|
}
|
228
231
|
|
229
|
-
if (last_concat_pos < data_len
|
232
|
+
if (last_concat_pos < data_len) {
|
230
233
|
rb_str_cat(main_result, &data[last_concat_pos], data_len - last_concat_pos);
|
231
234
|
}
|
232
235
|
|
@@ -55,6 +55,7 @@ VALUE multi_string_match(VALUE self, VALUE body, VALUE keys)
|
|
55
55
|
|
56
56
|
aho_create_trie(&aho);
|
57
57
|
aho_register_match_callback(result, &aho, callback_match_pos, (void*)target);
|
58
|
+
|
58
59
|
aho_findtext(&aho, target, RSTRING_LEN(body));
|
59
60
|
aho_destroy(&aho);
|
60
61
|
return result;
|
@@ -99,7 +100,6 @@ VALUE multi_string_replace(VALUE self, VALUE body, VALUE replace)
|
|
99
100
|
aho_add_match_text(&aho, StringValuePtr(entry), RSTRING_LEN(entry));
|
100
101
|
}
|
101
102
|
aho_create_trie(&aho);
|
102
|
-
|
103
103
|
VALUE result = aho_replace_text(&aho, target, RSTRING_LEN(body), values, value_sizes, ruby_val);
|
104
104
|
aho_destroy(&aho);
|
105
105
|
return result;
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.require_paths = ["lib"]
|
34
34
|
spec.extensions = ["ext/multi_string_replace/extconf.rb"]
|
35
35
|
|
36
|
-
spec.add_development_dependency "bundler", "~>
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.3.26"
|
37
37
|
spec.add_development_dependency "rake"
|
38
38
|
spec.add_development_dependency "rspec", "~> 3.0"
|
39
39
|
spec.add_development_dependency "rake-compiler"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_string_replace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Dayo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.3.26
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.3.26
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- bin/benchmark.rb
|
88
88
|
- bin/console
|
89
89
|
- bin/setup
|
90
|
+
- ext/multi_string_replace/.sitearchdir.-.multi_string_replace.time
|
90
91
|
- ext/multi_string_replace/aho_queue.c
|
91
92
|
- ext/multi_string_replace/aho_queue.h
|
92
93
|
- ext/multi_string_replace/aho_text.h
|
@@ -106,7 +107,7 @@ licenses:
|
|
106
107
|
- MIT
|
107
108
|
metadata:
|
108
109
|
allowed_push_host: https://rubygems.org
|
109
|
-
post_install_message:
|
110
|
+
post_install_message:
|
110
111
|
rdoc_options: []
|
111
112
|
require_paths:
|
112
113
|
- lib
|
@@ -121,9 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
122
|
- !ruby/object:Gem::Version
|
122
123
|
version: '0'
|
123
124
|
requirements: []
|
124
|
-
|
125
|
-
|
126
|
-
signing_key:
|
125
|
+
rubygems_version: 3.1.6
|
126
|
+
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: A fast multiple string replace library for ruby. Uses a C implementation
|
129
129
|
of the Aho–Corasick Algorithm
|