multi_string_replace 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce55106984f5b33c6b5dfe633fffb82c42cab34a1bd0516ef98025e8498bd172
4
- data.tar.gz: cf3fc9d870bbf27f7d6869fefe0e2513871b2fb667ce83812b7e5630f9c06530
3
+ metadata.gz: f1a53ef0a40acd23f625842f8ce1335b69e28b4334896ef50989c09936f4601b
4
+ data.tar.gz: 64880e395d26638853ab4501d76f9c882628410df8a1a41bea533249b8d0b447
5
5
  SHA512:
6
- metadata.gz: cae97ff557266b797ea98e429218d0d39c95ad898d81cb82015746f80316cbe7f671af556c9b11f670730806370896a302f314290b026420a5e04d4e9e0226f1
7
- data.tar.gz: f3e5e05f96c38df6f9f1782f03f76ba68d77e4f1aa278bcc902bbaeeff363922116d05b3c58fa492525c51db26c923a4bfdbdad3bba1cae39fbf380bccd8564f
6
+ metadata.gz: 2b3f3479e79dbca29630549b6895c714069d6baa134e184a8f87488203b4aac551b5b2e8759de5dfd4bd9b30d4abc5d5a8c8cb9fd56742801361f504c9d21829
7
+ data.tar.gz: e88071ce970e38300297472214eb73bb368308e924bb57ee80488228ac57eb820348d3e573566ca7fb4148083434e1071d96e53725307a50e0b9f21041f61c25
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- multi_string_replace (1.0.4)
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 (~> 1.16)
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
- 1.16.5
38
+ 2.3.26
@@ -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
  }
@@ -42,14 +42,14 @@ int aho_add_match_text(struct ahocorasick * restrict aho, const char* text, unsi
42
42
  if (!a_text)
43
43
  goto lack_free_mem;
44
44
 
45
- a_text->text = (char*) malloc(sizeof(char)*len);
45
+ a_text->text = (char*) malloc(sizeof(char)*(len + 1));
46
46
 
47
47
  if (!a_text->text)
48
48
  goto lack_free_mem;
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--;
@@ -1,3 +1,3 @@
1
1
  module MultiStringReplace
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -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", "~> 1.16"
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.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Dayo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-14 00:00:00.000000000 Z
11
+ date: 2022-12-16 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: '1.16'
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: '1.16'
26
+ version: 2.3.26
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement