word_scoop 2.2.0 → 2.2.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/ext/word_scoop/word_scoop.c +32 -18
- data/ext/word_scoop/word_scoop.h +0 -46
- data/lib/word_scoop/version.rb +1 -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: db11a9d520375459e1bb1f4c955b9a89479df88b420e97e1ac36ed5895e3b200
|
4
|
+
data.tar.gz: b928612fd50a9fbf62595aa6425ceee3f1d2013f4d8323869b7ca881a32f8bb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 162a7ffc6e9a726455a733229199de59cf74afec6eb98353e86449c3f94a9eb2a4181116906a8f718c775151281bc8dfd3c09f4a31132878317609a4d9dc6a2a
|
7
|
+
data.tar.gz: 118469f06e3c14b60894f5e84ae5f6059d76a379491d1016407db0d34af3bbbfe53c35a82615f637df255d94ff745bb8f229da44181c343da5eb99dcdd2665cc
|
data/ext/word_scoop/word_scoop.c
CHANGED
@@ -9,13 +9,16 @@
|
|
9
9
|
#include <stdio.h>
|
10
10
|
#include <stdlib.h>
|
11
11
|
#include <string.h>
|
12
|
+
#include <stdbool.h>
|
12
13
|
#include <ruby.h>
|
13
14
|
#include <ruby/encoding.h>
|
14
15
|
#include "word_scoop.h"
|
15
16
|
|
17
|
+
static VALUE t_add(VALUE, VALUE);
|
16
18
|
|
17
19
|
// initialize node
|
18
|
-
node
|
20
|
+
static node
|
21
|
+
initialize_node(char moji)
|
19
22
|
{
|
20
23
|
node work = (node)malloc(sizeof(struct _node));
|
21
24
|
if (!work) {
|
@@ -32,7 +35,8 @@ node initialize_node(char moji)
|
|
32
35
|
}
|
33
36
|
|
34
37
|
// add child node
|
35
|
-
void
|
38
|
+
static void
|
39
|
+
add_child(node parent, node child)
|
36
40
|
{
|
37
41
|
if (parent->child_head) {
|
38
42
|
child->next = parent->child_head;
|
@@ -41,10 +45,11 @@ void add_child(node parent, node child)
|
|
41
45
|
}
|
42
46
|
|
43
47
|
// search node by use character
|
44
|
-
|
48
|
+
static node
|
49
|
+
search_child(node n, char moji)
|
45
50
|
{
|
46
51
|
node child;
|
47
|
-
|
52
|
+
|
48
53
|
child = n->child_head;
|
49
54
|
while(child) {
|
50
55
|
if (child->moji == moji) {
|
@@ -58,10 +63,11 @@ node search_child(node n, char moji)
|
|
58
63
|
|
59
64
|
// search node by use character.
|
60
65
|
// if nothing, create new node
|
61
|
-
|
66
|
+
static node
|
67
|
+
search_child_or_create(node n, char moji)
|
62
68
|
{
|
63
69
|
node child;
|
64
|
-
|
70
|
+
|
65
71
|
child = search_child(n, moji);
|
66
72
|
if(!child) {
|
67
73
|
child = initialize_node(moji);
|
@@ -72,9 +78,9 @@ node search_child_or_create(node n, char moji)
|
|
72
78
|
}
|
73
79
|
|
74
80
|
// free memory all child and self
|
75
|
-
void
|
81
|
+
static void
|
82
|
+
destroy_node(node n)
|
76
83
|
{
|
77
|
-
int i;
|
78
84
|
node now, next;
|
79
85
|
|
80
86
|
now = n->child_head;
|
@@ -88,7 +94,8 @@ void destroy_node(node n)
|
|
88
94
|
}
|
89
95
|
|
90
96
|
// add encoding info
|
91
|
-
static VALUE
|
97
|
+
static VALUE
|
98
|
+
add_encode(VALUE str, rb_encoding *enc)
|
92
99
|
{
|
93
100
|
rb_enc_associate(str, enc);
|
94
101
|
return str;
|
@@ -101,7 +108,8 @@ static VALUE add_encode(VALUE str, rb_encoding *enc)
|
|
101
108
|
/**
|
102
109
|
* new
|
103
110
|
**/
|
104
|
-
static VALUE
|
111
|
+
static VALUE
|
112
|
+
t_new(int argc, VALUE *argv, VALUE klass)
|
105
113
|
{
|
106
114
|
node root;
|
107
115
|
VALUE obj, array, string;
|
@@ -123,11 +131,12 @@ static VALUE t_new(int argc, VALUE *argv, VALUE klass)
|
|
123
131
|
/**
|
124
132
|
* add
|
125
133
|
**/
|
126
|
-
static VALUE
|
134
|
+
static VALUE
|
135
|
+
t_add(VALUE self, VALUE str)
|
127
136
|
{
|
128
137
|
node root, now;
|
129
138
|
char *keyword;
|
130
|
-
|
139
|
+
long i, len;
|
131
140
|
|
132
141
|
keyword = StringValuePtr(str);
|
133
142
|
|
@@ -156,11 +165,13 @@ static VALUE t_add(VALUE self, VALUE str)
|
|
156
165
|
/**
|
157
166
|
* search
|
158
167
|
**/
|
159
|
-
static VALUE
|
168
|
+
static VALUE
|
169
|
+
t_search(VALUE self, VALUE str)
|
160
170
|
{
|
161
171
|
node root, now, ret;
|
162
172
|
char *text;
|
163
|
-
|
173
|
+
long i, total_len;
|
174
|
+
long head_i, tail_i;
|
164
175
|
VALUE array;
|
165
176
|
rb_encoding *enc;
|
166
177
|
|
@@ -213,12 +224,14 @@ static VALUE t_search(VALUE self, VALUE str)
|
|
213
224
|
/**
|
214
225
|
* filter_html
|
215
226
|
**/
|
216
|
-
static VALUE
|
227
|
+
static VALUE
|
228
|
+
t_filter_html(VALUE self, VALUE str)
|
217
229
|
{
|
218
230
|
node root, now, ret;
|
219
231
|
bool in_tag;
|
220
|
-
char *text
|
221
|
-
|
232
|
+
char *text;
|
233
|
+
const char* inner_tag;
|
234
|
+
long i, head_i, tail_i, copy_head_i, total_len;
|
222
235
|
VALUE change_str, url_base, word;
|
223
236
|
rb_encoding *enc;
|
224
237
|
|
@@ -331,7 +344,8 @@ static VALUE t_filter_html(VALUE self, VALUE str)
|
|
331
344
|
/**
|
332
345
|
* define class
|
333
346
|
**/
|
334
|
-
void
|
347
|
+
void
|
348
|
+
Init_word_scoop() {
|
335
349
|
VALUE cWordScoop;
|
336
350
|
|
337
351
|
cWordScoop = rb_define_class("WordScoop", rb_cObject);
|
data/ext/word_scoop/word_scoop.h
CHANGED
@@ -7,11 +7,6 @@
|
|
7
7
|
//************************************
|
8
8
|
|
9
9
|
|
10
|
-
// bool type
|
11
|
-
#define true 1
|
12
|
-
#define false 0
|
13
|
-
typedef char bool;
|
14
|
-
|
15
10
|
#define CR '\r'
|
16
11
|
#define LF '\n'
|
17
12
|
#define TAB '\t'
|
@@ -39,44 +34,3 @@ typedef struct _node {
|
|
39
34
|
struct _node *child_head;// head of child list
|
40
35
|
struct _node *next; // pointer of sibling node
|
41
36
|
} *node;
|
42
|
-
|
43
|
-
|
44
|
-
// initialize node
|
45
|
-
node initialize_node(char);
|
46
|
-
|
47
|
-
// add child node
|
48
|
-
void add_child(node, node);
|
49
|
-
|
50
|
-
// search node by use character
|
51
|
-
node search_child(node, char);
|
52
|
-
|
53
|
-
// search node by use character.
|
54
|
-
// if nothing, create new node
|
55
|
-
node search_child_or_create(node, char);
|
56
|
-
|
57
|
-
// free memory all child and self
|
58
|
-
void destroy_node(node);
|
59
|
-
|
60
|
-
// add encoding info
|
61
|
-
static VALUE add_encode(VALUE, rb_encoding *);
|
62
|
-
|
63
|
-
//-----------------------------------------------------------
|
64
|
-
// Ruby Methods
|
65
|
-
// ----------------------------------------------------------
|
66
|
-
|
67
|
-
// new
|
68
|
-
static VALUE t_new(int, VALUE *, VALUE);
|
69
|
-
|
70
|
-
// add
|
71
|
-
static VALUE t_add(VALUE, VALUE);
|
72
|
-
|
73
|
-
// search
|
74
|
-
static VALUE t_search(VALUE, VALUE);
|
75
|
-
|
76
|
-
//filter_html
|
77
|
-
static VALUE t_filter_html(VALUE, VALUE);
|
78
|
-
|
79
|
-
|
80
|
-
// defined class
|
81
|
-
void Init_word_scoop();
|
82
|
-
|
data/lib/word_scoop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: word_scoop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tsukasa OISHI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|