Extractor.xs

filter: Statementstmt 66.4% 1707 / 2570 Branchbran 48.1% 730 / 1516 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 59.6% 2437 / 4086 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/HTML/Content/Extractor.pm »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 #include "html.h"
6  
7 #define M_ADD_TO_NEW_BUFF(nc) {if(++n >= lsize) {lsize += 128; new_buff = realloc(new_buff, sizeof(char) * lsize); memset(&new_buff[n], 0, 128);} new_buff[n] = nc;}
8  
9 typedef htmltag_t * HTML__Content__Extractor;
10  
11 1 void clean_text(struct tree_entity *entities, struct lbuffer *lbuff) {
12 1 ▶ if(lbuff->i < 0)
Branch: 1 branch
BranchTrueFalseTotal
if(lbuff->i < 0) 0 1 1
13 0 return;
14
15 1 long lsize = lbuff->i + 128;
16 1 char *new_buff = (char *)malloc(sizeof(char) * lsize);
17 1 memset(new_buff, 0, lbuff->i + 1);
18
19 1 long i = 0;
20 1 ▶ for (i = 0; i <= lbuff->i; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= lbuff->i; i++) { 1 0 1
21 1 ▶ if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t' && lbuff->buff[i] != '\n')
Branch: 3 branches
BranchTrueFalseTotal
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t' && lbuff->buff[i] != '\n') 1 0 1
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t' && lbuff->buff[i] != '\n') 1 0 1
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t' && lbuff->buff[i] != '\n') 1 0 1
22 1 break;
23 }
24
25 1 long n = -1, count, next_i;
26 22 ▶ while (i <= lbuff->i) {
Branch: 1 branch
BranchTrueFalseTotal
while (i <= lbuff->i) { 21 1 22
27 21 count = 0;
28
29 21 switch (lbuff->buff[i]) {
30 0 case '\n':
31 0 ▶ for (i = i; i <= lbuff->i; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = i; i <= lbuff->i; i++) { 0 0 0
32 0 count++;
33
34 0 ▶ if(lbuff->buff[i] != '\n' && lbuff->buff[i] != ' ') {
Branch: 2 branches
BranchTrueFalseTotal
if(lbuff->buff[i] != '\n' && lbuff->buff[i] != ' ') { 0 0 0
if(lbuff->buff[i] != '\n' && lbuff->buff[i] != ' ') { 0 0 0
35 0 i--;
36 0 break;
37 }
38 0 ▶ else if(count <= 2) {
Branch: 1 branch
BranchTrueFalseTotal
else if(count <= 2) { 0 0 0
39 0 ▶ M_ADD_TO_NEW_BUFF(lbuff->buff[i]);
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(lbuff->buff[i]); 0 0 0
40 }
41 }
42
43 0 break;
44 0 case '\r':
45 0 ▶ for (i = i; i <= lbuff->i; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = i; i <= lbuff->i; i++) { 0 0 0
46 0 count++;
47
48 0 ▶ if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\r') {
Branch: 2 branches
BranchTrueFalseTotal
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\r') { 0 0 0
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\r') { 0 0 0
49 0 i--;
50 0 break;
51 }
52 0 ▶ else if(count <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
else if(count <= 1) { 0 0 0
53 0 ▶ M_ADD_TO_NEW_BUFF(' ');
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(' '); 0 0 0
54 }
55 }
56
57 0 break;
58 4 case ' ':
59 8 ▶ for (i = i; i <= lbuff->i; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = i; i <= lbuff->i; i++) { 8 0 8
60 8 count++;
61
62 8 ▶ if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t') {
Branch: 2 branches
BranchTrueFalseTotal
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t') { 4 4 8
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t') { 4 0 4
63 4 i--;
64 4 break;
65 }
66 4 ▶ else if(count <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
else if(count <= 1) { 4 0 4
67 4 ▶ M_ADD_TO_NEW_BUFF(' ');
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(' '); 0 4 4
68 }
69 }
70
71 4 break;
72 0 case '\t':
73 0 ▶ for (i = i; i <= lbuff->i; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = i; i <= lbuff->i; i++) { 0 0 0
74 0 count++;
75
76 0 ▶ if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t') {
Branch: 2 branches
BranchTrueFalseTotal
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t') { 0 0 0
if(lbuff->buff[i] != ' ' && lbuff->buff[i] != '\t') { 0 0 0
77 0 i--;
78 0 break;
79 }
80 0 ▶ else if(count <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
else if(count <= 1) { 0 0 0
81 0 ▶ M_ADD_TO_NEW_BUFF(' ');
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(' '); 0 0 0
82 }
83 }
84
85 0 break;
86 0 case '&':
87 0 next_i = i + 1;
88 0 ▶ if(lbuff->buff[next_i] != '\0') {
Branch: 1 branch
BranchTrueFalseTotal
if(lbuff->buff[next_i] != '\0') { 0 0 0
89 0 ▶ if(lbuff->buff[next_i] == '#') {
Branch: 1 branch
BranchTrueFalseTotal
if(lbuff->buff[next_i] == '#') { 0 0 0
90 0 char *lm = NULL;
91 0 ▶ int hex = lbuff->buff[next_i + 1] == 'x' || lbuff->buff[next_i + 1] == 'X';
Branch: 2 branches
BranchTrueFalseTotal
int hex = lbuff->buff[next_i + 1] == 'x' || lbuff->buff[next_i + 1] == 'X'; 0 0 0
int hex = lbuff->buff[next_i + 1] == 'x' || lbuff->buff[next_i + 1] == 'X'; 0 0 0
92
93 0 ▶ unsigned long cp = strtoul(&lbuff->buff[ (hex ? (next_i+2) : (next_i+1)) ], &lm, hex ? 16 : 10);
Branch: 2 branches
BranchTrueFalseTotal
unsigned long cp = strtoul(&lbuff->buff[ (hex ? (next_i+2) : (next_i+1)) ], &lm, hex ? 16 : 10); 0 0 0
unsigned long cp = strtoul(&lbuff->buff[ (hex ? (next_i+2) : (next_i+1)) ], &lm, hex ? 16 : 10); 0 0 0
94 0 long end_pos = lm - &lbuff->buff[i];
95
96 0 ▶ if(end_pos <= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if(end_pos <= 2) { 0 0 0
97 0 ▶ M_ADD_TO_NEW_BUFF(lbuff->buff[i]);
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(lbuff->buff[i]); 0 0 0
98 0 break;
99 }
100
101 0 ▶ if(*lm == ';') {
Branch: 1 branch
BranchTrueFalseTotal
if(*lm == ';') { 0 0 0
102 0 i += end_pos;
103 } else {
104 0 i += end_pos - 1;
105 }
106
107 0 ▶ if(cp <= 0x007Ful)
Branch: 1 branch
BranchTrueFalseTotal
if(cp <= 0x007Ful) 0 0 0
108 {
109 0 ▶ if(n + 1 >= lsize) {
Branch: 1 branch
BranchTrueFalseTotal
if(n + 1 >= lsize) { 0 0 0
110 0 lsize += 128;
111 0 new_buff = (char*)realloc(new_buff, sizeof(char) * lsize);
112 0 memset(&new_buff[n + 1], 0, 128);
113 }
114
115 0 new_buff[n + 1] = (unsigned char)cp;
116 0 n++;
117 }
118 0 ▶ else if(cp <= 0x07FFul)
Branch: 1 branch
BranchTrueFalseTotal
else if(cp <= 0x07FFul) 0 0 0
119 {
120 0 ▶ if(n + 2 >= lsize) {
Branch: 1 branch
BranchTrueFalseTotal
if(n + 2 >= lsize) { 0 0 0
121 0 lsize += 128;
122 0 new_buff = (char*)realloc(new_buff, sizeof(char) * lsize);
123 0 memset(&new_buff[n + 1], 0, 128);
124 }
125
126 0 new_buff[n + 2] = (unsigned char)((2 << 6) | (cp & 0x3F));
127 0 new_buff[n + 1] = (unsigned char)((6 << 5) | (cp >> 6));
128 0 n += 2;
129 }
130 0 ▶ else if(cp <= 0xFFFFul)
Branch: 1 branch
BranchTrueFalseTotal
else if(cp <= 0xFFFFul) 0 0 0
131 {
132 0 ▶ if(n + 3 >= lsize) {
Branch: 1 branch
BranchTrueFalseTotal
if(n + 3 >= lsize) { 0 0 0
133 0 lsize += 128;
134 0 new_buff = (char*)realloc(new_buff, sizeof(char) * lsize);
135 0 memset(&new_buff[n + 1], 0, 128);
136 }
137
138 0 new_buff[n + 3] = (unsigned char)(( 2 << 6) | ( cp & 0x3F));
139 0 new_buff[n + 2] = (unsigned char)(( 2 << 6) | ((cp >> 6) & 0x3F));
140 0 new_buff[n + 1] = (unsigned char)((14 << 4) | (cp >> 12));
141 0 n += 3;
142
143 }
144 0 ▶ else if(cp <= 0x10FFFFul)
Branch: 1 branch
BranchTrueFalseTotal
else if(cp <= 0x10FFFFul) 0 0 0
145 {
146 0 ▶ if(n + 4 >= lsize) {
Branch: 1 branch
BranchTrueFalseTotal
if(n + 4 >= lsize) { 0 0 0
147 0 lsize += 128;
148 0 new_buff = (char*)realloc(new_buff, sizeof(char) * lsize);
149 0 memset(&new_buff[n + 1], 0, 128);
150 }
151
152 0 new_buff[n + 4] = (unsigned char)(( 2 << 6) | ( cp & 0x3F));
153 0 new_buff[n + 3] = (unsigned char)(( 2 << 6) | ((cp >> 6) & 0x3F));
154 0 new_buff[n + 2] = (unsigned char)(( 2 << 6) | ((cp >> 12) & 0x3F));
155 0 new_buff[n + 1] = (unsigned char)((30 << 3) | (cp >> 18));
156 0 n += 4;
157 }
158 }
159 else {
160 0 struct tree_entity *entity = check_entity(entities, &lbuff->buff[next_i]);
161 0 ▶ if(entity) {
Branch: 1 branch
BranchTrueFalseTotal
if(entity) { 0 0 0
162 0 int m = -1;
163 0 ▶ while(entity->value[++m]) {
Branch: 1 branch
BranchTrueFalseTotal
while(entity->value[++m]) { 0 0 0
164 0 ▶ M_ADD_TO_NEW_BUFF(entity->value[m]);
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(entity->value[m]); 0 0 0
165 }
166
167 0 i += entity->level + 1;
168
169 0 ▶ if(lbuff->buff[i + 1] != '\0' && lbuff->buff[i + 1] == ';')
Branch: 2 branches
BranchTrueFalseTotal
if(lbuff->buff[i + 1] != '\0' && lbuff->buff[i + 1] == ';') 0 0 0
if(lbuff->buff[i + 1] != '\0' && lbuff->buff[i + 1] == ';') 0 0 0
170 0 i++;
171 } else {
172 0 ▶ M_ADD_TO_NEW_BUFF(lbuff->buff[i]);
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(lbuff->buff[i]); 0 0 0
173 }
174 }
175 }
176
177 0 break;
178
179 17 default:
180 17 ▶ M_ADD_TO_NEW_BUFF(lbuff->buff[i]);
Branch: 1 branch
BranchTrueFalseTotal
M_ADD_TO_NEW_BUFF(lbuff->buff[i]); 0 17 17
181 17 break;
182 }
183
184 21 i++;
185 }
186
187 2 ▶ for (i = n; i >= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = n; i >= 0; i--) { 2 0 2
188 2 ▶ if(new_buff[i] != ' ' && new_buff[i] != '\t' && new_buff[i] != '\n' && new_buff[i] != '\0') {
Branch: 4 branches
BranchTrueFalseTotal
if(new_buff[i] != ' ' && new_buff[i] != '\t' && new_buff[i] != '\n' && new_buff[i] != '\0') { 2 0 2
if(new_buff[i] != ' ' && new_buff[i] != '\t' && new_buff[i] != '\n' && new_buff[i] != '\0') { 2 0 2
if(new_buff[i] != ' ' && new_buff[i] != '\t' && new_buff[i] != '\n' && new_buff[i] != '\0') { 2 0 2
if(new_buff[i] != ' ' && new_buff[i] != '\t' && new_buff[i] != '\n' && new_buff[i] != '\0') { 1 1 2
189 1 new_buff[++n] = '\0';
190 1 break;
191 }
192
193 1 n--;
194 }
195
196 1 free(lbuff->buff);
197 1 lbuff->buff = new_buff;
198 1 lbuff->i = n;
199 }
200  
201 55 void _add_to_lbuff(struct lbuffer *lbuff, char nc) {
202 55 ▶ if(++lbuff->i == lbuff->buff_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(++lbuff->i == lbuff->buff_size) { 0 55 55
203 0 lbuff->buff_size += 4096;
204 0 lbuff->buff = (char *)realloc(lbuff->buff, sizeof(char) * lbuff->buff_size);
205 }
206
207 55 lbuff->buff[lbuff->i] = nc;
208 55 }
209  
210 1 void get_text_without_element(struct tree_list *my_r, struct lbuffer *lbuff) {
211 1 struct html_tree * tag = NULL;
212 1 int element_p_id = get_tag_id(my_r->tags, "p");
213 1 int element_id_form = get_tag_id(my_r->tags, "form");
214
215 1 long save_nco_pos = my_r->nco_pos;
216
217 1 lbuff->buff = (char *)malloc(sizeof(char) * lbuff->buff_size);
218
219 5 ▶ while ((tag = get_next_element_in_level(my_r))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((tag = get_next_element_in_level(my_r))) { 4 1 5
220
221 4 ▶ if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_SYS || tag->tag_id == element_id_form) {
Branch: 2 branches
BranchTrueFalseTotal
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_SYS || tag->tag_id == element_id_form) { 4 0 4
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_SYS || tag->tag_id == element_id_form) { 0 4 4
222 0 ▶ if(get_next_element_in_level_skip_curr(my_r) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(get_next_element_in_level_skip_curr(my_r) == NULL) 0 0 0
223 0 break;
224
225 0 get_prev_element_in_level(my_r);
226 0 continue;
227 }
228
229 4 ▶ if(tag->my_id > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag->my_id > 0) { 1 3 4
230 1 ▶ if( find_stop_word_param(my_r->swords, &my_r->my[tag->my_id]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if( find_stop_word_param(my_r->swords, &my_r->my[tag->my_id]) ) { 0 1 1
231 0 ▶ if(get_next_element_in_level_skip_curr(my_r) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(get_next_element_in_level_skip_curr(my_r) == NULL) 0 0 0
232 0 break;
233
234 0 get_prev_element_in_level(my_r);
235 0 continue;
236 }
237 }
238
239 4 ▶ if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK || my_r->tags->type[ tag->tag_id ] == TYPE_TAG_ONE) {
Branch: 2 branches
BranchTrueFalseTotal
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK || my_r->tags->type[ tag->tag_id ] == TYPE_TAG_ONE) { 4 0 4
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK || my_r->tags->type[ tag->tag_id ] == TYPE_TAG_ONE) { 0 4 4
240 0 _add_to_lbuff(lbuff, '\n');
241
242 0 ▶ if(tag->tag_id == element_p_id) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag->tag_id == element_p_id) { 0 0 0
243 0 _add_to_lbuff(lbuff, '\n');
244 }
245
246 0 continue;
247 }
248
249 4 ▶ if(my_r->tags->type[ tag->tag_id ] != TYPE_TAG_TEXT) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->type[ tag->tag_id ] != TYPE_TAG_TEXT) { 1 3 4
250 1 continue;
251 }
252
253 3 long il; int semp = 0;
254 23 ▶ for (il = tag->tag_body_start; il <= tag->tag_body_stop; il++) {
Branch: 1 branch
BranchTrueFalseTotal
for (il = tag->tag_body_start; il <= tag->tag_body_stop; il++) { 20 3 23
255 20 ▶ if(semp == 0 && (my_r->html[il] == '\n' || my_r->html[il] == '\r')) {
Branch: 3 branches
BranchTrueFalseTotal
if(semp == 0 && (my_r->html[il] == '\n' || my_r->html[il] == '\r')) { 3 17 20
if(semp == 0 && (my_r->html[il] == '\n' || my_r->html[il] == '\r')) { 3 0 3
if(semp == 0 && (my_r->html[il] == '\n' || my_r->html[il] == '\r')) { 0 3 3
256 0 continue;
257 }
258
259 20 semp = 1;
260
261 20 ▶ if(my_r->html[il] == '\n') {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->html[il] == '\n') { 0 20 20
262 0 _add_to_lbuff(lbuff, '\r');
263 0 continue;
264 }
265
266 20 _add_to_lbuff(lbuff, my_r->html[il]);
267 }
268 }
269
270 1 _add_to_lbuff(lbuff, '\0');
271
272 1 my_r->nco_pos = save_nco_pos;
273 1 }
274  
275 2 void _get_text_with_element_cl(struct tree_list *my_r, struct lbuffer *lbuff, char **elements, int ei_size) {
276 2 struct html_tree * tag = NULL;
277 2 int element_p_id = get_tag_id(my_r->tags, "p");
278 2 int element_br_id = get_tag_id(my_r->tags, "br");
279 2 int element_id_form = get_tag_id(my_r->tags, "form");
280
281 9 ▶ while ((tag = get_next_element_in_level(my_r))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((tag = get_next_element_in_level(my_r))) { 7 2 9
282
283 7 int is, it, ip = -1, in = -1;
284 14 ▶ for (is = 0; is <= ei_size; is++) {
Branch: 1 branch
BranchTrueFalseTotal
for (is = 0; is <= ei_size; is++) { 7 7 14
285 7 it = -1;
286 10 ▶ while (elements[is][++it]) {
Branch: 1 branch
BranchTrueFalseTotal
while (elements[is][++it]) { 10 0 10
287 10 in = it + 1;
288 10 ▶ if((my_r->tags->name[tag->tag_id][in] == '\0' && elements[is][in] != '\0') ||
Branch: 2 branches
BranchTrueFalseTotal
if((my_r->tags->name[tag->tag_id][in] == '\0' && elements[is][in] != '\0') || 2 8 10
if((my_r->tags->name[tag->tag_id][in] == '\0' && elements[is][in] != '\0') || 1 1 2
289 9 ▶ (my_r->tags->name[tag->tag_id][in] != '\0' && elements[is][in] == '\0') ||
Branch: 2 branches
BranchTrueFalseTotal
(my_r->tags->name[tag->tag_id][in] != '\0' && elements[is][in] == '\0') || 8 1 9
(my_r->tags->name[tag->tag_id][in] != '\0' && elements[is][in] == '\0') || 8 0 8
290 9 ▶ my_r->tags->name[tag->tag_id][it] != elements[is][it]
Branch: 1 branch
BranchTrueFalseTotal
my_r->tags->name[tag->tag_id][it] != elements[is][it] 4 5 9
291 ) {
292 break;
293 }
294 4 ▶ else if(my_r->tags->name[tag->tag_id][in] == '\0' && elements[is][in] == '\0') {
Branch: 2 branches
BranchTrueFalseTotal
else if(my_r->tags->name[tag->tag_id][in] == '\0' && elements[is][in] == '\0') { 1 3 4
else if(my_r->tags->name[tag->tag_id][in] == '\0' && elements[is][in] == '\0') { 1 0 1
295 1 ip = tag->tag_id;
296 1 break;
297 }
298 }
299 }
300
301 7 ▶ if(ip != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(ip != -1) { 1 6 7
302 long il;
303 7 ▶ for (il = tag->tag_start; il < tag->tag_body_start; il++) {
Branch: 1 branch
BranchTrueFalseTotal
for (il = tag->tag_start; il < tag->tag_body_start; il++) { 6 1 7
304 6 _add_to_lbuff(lbuff, my_r->html[il]);
305 }
306
307 1 long save_nco_pos = my_r->nco_pos;
308 1 long save_cur_pos = my_r->cur_pos;
309 1 my_r->nco_pos = tag->id;
310 1 my_r->cur_pos = tag->id;
311
312 1 _get_text_with_element_cl(my_r, lbuff, elements, ei_size);
313
314 8 ▶ for (il = tag->tag_body_stop + 1; il <= tag->tag_stop; il++) {
Branch: 1 branch
BranchTrueFalseTotal
for (il = tag->tag_body_stop + 1; il <= tag->tag_stop; il++) { 7 1 8
315 7 _add_to_lbuff(lbuff, my_r->html[il]);
316 }
317
318 1 my_r->nco_pos = save_nco_pos;
319 1 my_r->cur_pos = save_cur_pos;
320
321 1 ▶ if(get_next_element_in_level_skip_curr(my_r) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(get_next_element_in_level_skip_curr(my_r) == NULL) 0 1 1
322 0 break;
323
324 1 get_prev_element_in_level(my_r);
325
326 //continue;
327 }
328
329 7 ▶ if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_SYS || tag->tag_id == element_id_form) {
Branch: 2 branches
BranchTrueFalseTotal
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_SYS || tag->tag_id == element_id_form) { 7 0 7
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_SYS || tag->tag_id == element_id_form) { 0 7 7
330 0 ▶ if(get_next_element_in_level_skip_curr(my_r) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(get_next_element_in_level_skip_curr(my_r) == NULL) 0 0 0
331 0 break;
332
333 0 get_prev_element_in_level(my_r);
334 0 continue;
335 }
336
337 7 ▶ if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK || my_r->tags->type[ tag->tag_id ] == TYPE_TAG_ONE) {
Branch: 2 branches
BranchTrueFalseTotal
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK || my_r->tags->type[ tag->tag_id ] == TYPE_TAG_ONE) { 7 0 7
if(my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK || my_r->tags->type[ tag->tag_id ] == TYPE_TAG_ONE) { 0 7 7
338 0 ▶ if((tag->tag_id == element_br_id && ip != element_br_id) || (my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK))
Branch: 3 branches
BranchTrueFalseTotal
if((tag->tag_id == element_br_id && ip != element_br_id) || (my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK)) 0 0 0
if((tag->tag_id == element_br_id && ip != element_br_id) || (my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK)) 0 0 0
if((tag->tag_id == element_br_id && ip != element_br_id) || (my_r->tags->type[ tag->tag_id ] == TYPE_TAG_BLOCK)) 0 0 0
339 0 _add_to_lbuff(lbuff, '\n');
340
341 0 ▶ if(tag->tag_id == element_p_id && ip != element_p_id) {
Branch: 2 branches
BranchTrueFalseTotal
if(tag->tag_id == element_p_id && ip != element_p_id) { 0 0 0
if(tag->tag_id == element_p_id && ip != element_p_id) { 0 0 0
342 0 _add_to_lbuff(lbuff, '\n');
343 }
344
345 0 continue;
346 }
347
348 7 ▶ if(my_r->tags->type[ tag->tag_id ] != TYPE_TAG_TEXT) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->type[ tag->tag_id ] != TYPE_TAG_TEXT) { 2 5 7
349 2 continue;
350 }
351
352 long il;
353 25 ▶ for (il = tag->tag_body_start; il <= tag->tag_body_stop; il++) {
Branch: 1 branch
BranchTrueFalseTotal
for (il = tag->tag_body_start; il <= tag->tag_body_stop; il++) { 20 5 25
354 20 ▶ if(my_r->html[il] != '\n')
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->html[il] != '\n') 20 0 20
355 20 _add_to_lbuff(lbuff, my_r->html[il]);
356 }
357 }
358 2 }
359  
360 1 void get_text_with_element(struct tree_list *my_r, struct lbuffer *lbuff, char **elements, int ei_size) {
361 1 long save_nco_pos = my_r->nco_pos;
362
363 1 lbuff->buff = (char *)malloc(sizeof(char) * lbuff->buff_size);
364
365 1 _get_text_with_element_cl(my_r, lbuff, elements, ei_size);
366 1 _add_to_lbuff(lbuff, '\0');
367
368 1 my_r->nco_pos = save_nco_pos;
369 1 }
370  
371 1 void get_raw_text(struct tree_list *my_r, struct lbuffer *lbuff) {
372 1 struct html_tree * tag = get_curr_element(my_r);
373
374 1 lbuff->i = -1;
375 1 lbuff->buff_size = (tag->tag_stop - tag->tag_start) + 2;
376 1 lbuff->buff = (char *)malloc(sizeof(char) * lbuff->buff_size);
377
378 long il;
379 45 ▶ for (il = tag->tag_start; il <= tag->tag_stop; il++) {
Branch: 1 branch
BranchTrueFalseTotal
for (il = tag->tag_start; il <= tag->tag_stop; il++) { 44 1 45
380 44 lbuff->buff[++lbuff->i] = my_r->html[il];
381 }
382
383 1 lbuff->buff[++lbuff->i] = '\0';
384 1 }
385  
386 0 int _check_img_size(char *str) {
387 0 int rv = 0;
388
389 0 ▶ if(str){
Branch: 1 branch
BranchTrueFalseTotal
if(str){ 0 0 0
390 0 ▶ while ( *str ) {
Branch: 1 branch
BranchTrueFalseTotal
while ( *str ) { 0 0 0
391 0 ▶ if(*str <= '9' && *str >= '0') {
Branch: 2 branches
BranchTrueFalseTotal
if(*str <= '9' && *str >= '0') { 0 0 0
if(*str <= '9' && *str >= '0') { 0 0 0
392 0 rv = (rv * 10) + (*str - '0');
393 }
394 0 ▶ else if(rv != 0) {
Branch: 1 branch
BranchTrueFalseTotal
else if(rv != 0) { 0 0 0
395 0 rv = 0;
396 0 break;
397 }
398
399 0 str++;
400 }
401 }
402
403 0 return rv;
404 }
405  
406 4 struct return_list * get_text_images_href(struct tree_list *my_r, struct return_list *return_list, int inc, struct mem_stop_words *stop_words, int min_width) {
407 4 struct html_tree * tag = NULL;
408
409 4 long save_nco_pos = my_r->nco_pos;
410
411 4 ▶ if(return_list == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(return_list == NULL) { 1 3 4
412 1 return_list = (struct return_list *)malloc(sizeof(struct return_list));
413
414 1 return_list->count = sizeof(struct return_list) * 1024;
415 1 return_list->real_count = -1;
416 1 return_list->list = (struct mem_tag *)malloc(sizeof(struct mem_tag) * return_list->count);
417 }
418
419 25 ▶ while ((tag = get_next_element_in_level(my_r))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((tag = get_next_element_in_level(my_r))) { 17 4 21
420 17 ▶ if(my_r->tags->ai[ tag->tag_id ] == AI_IMG) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->ai[ tag->tag_id ] == AI_IMG) { 14 3 17
421 3 struct mem_params * param = find_param_by_key_in_element(&my_r->my[tag->my_id], "src");
422 3 ▶ if(param == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(param == NULL) 0 3 3
423 0 continue;
424
425 3 ▶ if(tag->my_id > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag->my_id > 0) { 3 0 3
426 3 ▶ if( find_stop_word_param(stop_words, &my_r->my[tag->my_id]) )
Branch: 1 branch
BranchTrueFalseTotal
if( find_stop_word_param(stop_words, &my_r->my[tag->my_id]) ) 0 3 3
427 0 continue;
428 }
429
430 3 struct mem_params * width = find_param_by_key_in_element(&my_r->my[tag->my_id], "width");
431 3 ▶ if( width == NULL || min_width == 0 || (min_width > 0 && _check_img_size(width->value) >= min_width) ) {
Branch: 4 branches
BranchTrueFalseTotal
if( width == NULL || min_width == 0 || (min_width > 0 && _check_img_size(width->value) >= min_width) ) { 0 3 3
if( width == NULL || min_width == 0 || (min_width > 0 && _check_img_size(width->value) >= min_width) ) { 0 0 0
if( width == NULL || min_width == 0 || (min_width > 0 && _check_img_size(width->value) >= min_width) ) { 0 0 0
if( width == NULL || min_width == 0 || (min_width > 0 && _check_img_size(width->value) >= min_width) ) { 0 0 0
432 3 ▶ if(param->lvalue > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(param->lvalue > -1) { 3 0 3
433 3 return_list->real_count++;
434 3 return_list->list[ return_list->real_count ] = my_r->my[tag->my_id];
435 }
436 }
437 }
438 }
439
440 4 ▶ if(inc < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(inc < 1) { 1 3 4
441 1 struct html_tree *curr_pos = get_curr_element(my_r);
442 1 get_prev_element_curr_level(my_r);
443 1 get_text_images_href(my_r, return_list, ++inc, stop_words, min_width);
444 1 set_position(my_r, curr_pos);
445 }
446
447 4 ▶ if(inc == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(inc == 1) { 2 2 4
448 2 my_r->nco_pos = save_nco_pos;
449 2 get_next_element_curr_level(my_r);
450 2 get_text_images_href(my_r, return_list, ++inc, stop_words, min_width);
451 }
452
453 4 my_r->nco_pos = save_nco_pos;
454
455 4 return return_list;
456 }
457  
458 43 struct html_tree * check_html(struct tree_list *my_r, struct max_element *max) {
459 struct html_tree * tag;
460 43 long i = -1;
461
462 43 size_t istags= 26;
463 43 int skip_tags[istags];
464 43 skip_tags[0] = get_tag_id(my_r->tags, "address");
465 43 skip_tags[1] = get_tag_id(my_r->tags, "applet");
466 43 skip_tags[2] = get_tag_id(my_r->tags, "audio");
467 43 skip_tags[3] = get_tag_id(my_r->tags, "video");
468 43 skip_tags[4] = get_tag_id(my_r->tags, "source");
469 43 skip_tags[5] = get_tag_id(my_r->tags, "track");
470 43 skip_tags[6] = get_tag_id(my_r->tags, "bgsound");
471 43 skip_tags[7] = get_tag_id(my_r->tags, "canvas");
472 43 skip_tags[8] = get_tag_id(my_r->tags, "datalist");
473 43 skip_tags[9] = get_tag_id(my_r->tags, "button");
474 43 skip_tags[10] = get_tag_id(my_r->tags, "fieldset");
475 43 skip_tags[11] = get_tag_id(my_r->tags, "legend");
476 43 skip_tags[12] = get_tag_id(my_r->tags, "input");
477 43 skip_tags[13] = get_tag_id(my_r->tags, "keygen");
478 43 skip_tags[14] = get_tag_id(my_r->tags, "textarea");
479 43 skip_tags[15] = get_tag_id(my_r->tags, "frameset");
480 43 skip_tags[16] = get_tag_id(my_r->tags, "noframes");
481 43 skip_tags[17] = get_tag_id(my_r->tags, "label");
482 43 skip_tags[18] = get_tag_id(my_r->tags, "link");
483 43 skip_tags[19] = get_tag_id(my_r->tags, "map");
484 43 skip_tags[20] = get_tag_id(my_r->tags, "object");
485 43 skip_tags[21] = get_tag_id(my_r->tags, "progress");
486 43 skip_tags[22] = get_tag_id(my_r->tags, "time");
487 43 skip_tags[23] = get_tag_id(my_r->tags, "xmp");
488 43 skip_tags[24] = get_tag_id(my_r->tags, "footer");
489 43 skip_tags[25] = get_tag_id(my_r->tags, "noindex");
490
491 43 struct html_tree *curr_element = get_curr_element(my_r);
492
493 43 ▶ if(curr_element->tag_id != get_tag_id(my_r->tags, "form"))
Branch: 1 branch
BranchTrueFalseTotal
if(curr_element->tag_id != get_tag_id(my_r->tags, "form")) 43 0 43
494 {
495 43 long count_words = curr_element->count_word;
496 43 long count_link = curr_element->counts[AI_LINK];
497
498 87 ▶ while((tag = get_child_n(my_r, ++i))) {
Branch: 1 branch
BranchTrueFalseTotal
while((tag = get_child_n(my_r, ++i))) { 44 43 87
499 44 count_link += tag->counts[AI_LINK];
500
501 44 ▶ if(my_r->tags->ai[ tag->tag_id ] == AI_TEXT) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->ai[ tag->tag_id ] == AI_TEXT) { 5 39 44
502 5 count_words += tag->count_word;
503 }
504 }
505
506 43 ▶ if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1) && max->count_words < count_words) || (max->count_words < count_words && count_link == 0))
Branch: 6 branches
BranchTrueFalseTotal
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1) && max->count_words < count_words) || (max->count_words < count_words && count_link == 0)) 9 34 43
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1) && max->count_words < count_words) || (max->count_words < count_words && count_link == 0)) 0 9 9
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1) && max->count_words < count_words) || (max->count_words < count_words && count_link == 0)) 0 0 0
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1) && max->count_words < count_words) || (max->count_words < count_words && count_link == 0)) 0 0 0
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1) && max->count_words < count_words) || (max->count_words < count_words && count_link == 0)) 4 39 43
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1) && max->count_words < count_words) || (max->count_words < count_words && count_link == 0)) 4 0 4
507 {
508 4 max->count_words = count_words;
509 4 max->element = get_curr_element(my_r);
510 }
511 }
512
513 43 int n = 0, t;
514 43 i = -1;
515
516 87 ▶ while((tag = get_child_n(my_r, ++i))) {
Branch: 1 branch
BranchTrueFalseTotal
while((tag = get_child_n(my_r, ++i))) { 44 43 87
517 44 ▶ if(my_r->tags->ai[ tag->tag_id ] == AI_LINK) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->ai[ tag->tag_id ] == AI_LINK) { 4 40 44
518 4 continue;
519 }
520
521 40 n = 0;
522 1080 ▶ for (t = 0; t < istags; t++) {
Branch: 1 branch
BranchTrueFalseTotal
for (t = 0; t < istags; t++) { 1040 40 1080
523 1040 ▶ if(tag->tag_id == skip_tags[t]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag->tag_id == skip_tags[t]) { 0 1040 1040
524 0 n = 1;
525 0 break;
526 }
527 }
528
529 40 ▶ if (n == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (n == 1) 0 40 40
530 0 continue;
531
532 40 ▶ if(my_r->tags->family[tag->tag_id] == FAMILY_SELECT) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->family[tag->tag_id] == FAMILY_SELECT) { 0 40 40
533 0 continue;
534 }
535
536 40 ▶ if(my_r->tags->type[tag->tag_id] == TYPE_TAG_ONE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SIMPLE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SYS) {
Branch: 3 branches
BranchTrueFalseTotal
if(my_r->tags->type[tag->tag_id] == TYPE_TAG_ONE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SIMPLE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SYS) { 39 1 40
if(my_r->tags->type[tag->tag_id] == TYPE_TAG_ONE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SIMPLE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SYS) { 39 0 39
if(my_r->tags->type[tag->tag_id] == TYPE_TAG_ONE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SIMPLE || my_r->tags->type[tag->tag_id] == TYPE_TAG_SYS) { 0 39 39
537 1 continue;
538 }
539
540 39 ▶ if(my_r->tags->extra[tag->tag_id] == EXTRA_TAG_SIMPLE) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->extra[tag->tag_id] == EXTRA_TAG_SIMPLE) { 0 39 39
541 0 continue;
542 }
543
544 39 ▶ if(tag->my_id > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag->my_id > 0) { 17 22 39
545 17 ▶ if( find_stop_word_param(my_r->swords, &my_r->my[tag->my_id]) )
Branch: 1 branch
BranchTrueFalseTotal
if( find_stop_word_param(my_r->swords, &my_r->my[tag->my_id]) ) 0 17 17
546 0 continue;
547 }
548
549 39 set_position(my_r, tag);
550 39 check_html(my_r, max);
551 39 set_position(my_r, curr_element);
552 }
553
554 43 return max->element;
555 }
556  
557 0 void check_html_with_all_text(struct tree_list *my_r, struct max_element_list *max_list) {
558 struct html_tree * tag;
559 0 long i = -1;
560 0 long count_words = 0, count_link = 0;
561 0 int element_id_form = get_tag_id(my_r->tags, "form");
562
563 0 struct html_tree *curr_element = get_curr_element(my_r);
564
565 0 ▶ while((tag = get_child_n(my_r, ++i))) {
Branch: 1 branch
BranchTrueFalseTotal
while((tag = get_child_n(my_r, ++i))) { 0 0 0
566 0 count_link += tag->counts[AI_LINK];
567
568 0 ▶ if(my_r->tags->ai[ tag->tag_id ] == AI_TEXT) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->ai[ tag->tag_id ] == AI_TEXT) { 0 0 0
569 0 count_words += tag->count_word;
570 }
571 }
572
573 0 ▶ if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1)) || (count_words && count_link == 0))
Branch: 5 branches
BranchTrueFalseTotal
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1)) || (count_words && count_link == 0)) 0 0 0
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1)) || (count_words && count_link == 0)) 0 0 0
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1)) || (count_words && count_link == 0)) 0 0 0
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1)) || (count_words && count_link == 0)) 0 0 0
if((count_words > 0 && count_link > 0 && ((count_words / count_link) > 1)) || (count_words && count_link == 0)) 0 0 0
574 {
575 0 max_list->lelements++;
576 0 ▶ if(max_list->lelements >= max_list->lelements_size){
Branch: 1 branch
BranchTrueFalseTotal
if(max_list->lelements >= max_list->lelements_size){ 0 0 0
577 0 max_list->lelements_size += 1024;
578 0 max_list->elements = (struct max_element*)realloc(max_list->elements, max_list->lelements_size);
579 }
580
581 0 max_list->elements[max_list->lelements].element = curr_element;
582 0 max_list->elements[max_list->lelements].count_words = count_words;
583 }
584
585 0 i = -1;
586 0 ▶ while((tag = get_child_n(my_r, ++i))) {
Branch: 1 branch
BranchTrueFalseTotal
while((tag = get_child_n(my_r, ++i))) { 0 0 0
587 0 ▶ if(my_r->tags->ai[ tag->tag_id ] == AI_LINK) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->ai[ tag->tag_id ] == AI_LINK) { 0 0 0
588 0 continue;
589 }
590
591 // skip form
592 0 ▶ if(tag->tag_id == element_id_form || my_r->tags->type[tag->tag_id] == TYPE_TAG_SIMPLE) {
Branch: 2 branches
BranchTrueFalseTotal
if(tag->tag_id == element_id_form || my_r->tags->type[tag->tag_id] == TYPE_TAG_SIMPLE) { 0 0 0
if(tag->tag_id == element_id_form || my_r->tags->type[tag->tag_id] == TYPE_TAG_SIMPLE) { 0 0 0
593 0 continue;
594 }
595
596 0 set_position(my_r, tag);
597 0 check_html_with_all_text(my_r, max_list);
598 0 set_position(my_r, curr_element);
599 }
600 0 }
601  
602 33 int init_tags(struct tags *tags) {
603 33 ▶ if(tags->csize > -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tags->csize > -1) 0 33 33
604 0 return -1;
605
606 33 tags->csize = 2048;
607
608 33 tags->name = (char **)malloc(sizeof(char *) * tags->csize);
609
610 33 tags->priority = (int *)malloc(sizeof(int) * tags->csize);
611 33 tags->type = (int *)malloc(sizeof(int) * tags->csize);
612 33 tags->extra = (int *)malloc(sizeof(int) * tags->csize);
613 33 tags->ai = (int *)malloc(sizeof(int) * tags->csize);
614 33 tags->family = (int *)malloc(sizeof(int) * tags->csize);
615 33 tags->option = (int *)malloc(sizeof(int) * tags->csize);
616
617 33 tags->index.tag_id = (long **)malloc(sizeof(long *) * tags->csize);
618 33 tags->index.tag_count = (int *)malloc(sizeof(int) * tags->csize);
619 33 tags->index.tag_csize = (int *)malloc(sizeof(int) * tags->csize);
620
621 // default tags !!!NOT EDIT!!!
622 // нулевой элемент для текста, то есть для элементов которые внутри тега
623 33 add_tag_R(tags, "" , 0, 0 , 0, TYPE_TAG_TEXT , 0, OPTION_NULL, AI_NULL);
624 // end default tags
625
626 33 add_tag_R(tags, "!doctype", 8, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
627
628 33 add_tag_R(tags, "html", 4, 400, FAMILY_HTML, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
629 33 add_tag_R(tags, "head", 4, 200, FAMILY_HTML, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_NULL);
630 33 add_tag_R(tags, "body", 4, 200, FAMILY_HTML, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_NULL);
631
632 33 add_tag_R(tags, "a", 1, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_IF_SELF, OPTION_NULL, AI_LINK);
633 33 add_tag_R(tags, "abbr", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
634 33 add_tag_R(tags, "acronym", 7, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
635 33 add_tag_R(tags, "address", 7, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
636 33 add_tag_R(tags, "applet", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
637 33 add_tag_R(tags, "article", 7, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
638 33 add_tag_R(tags, "aside", 5, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
639
640 // ++ audio, video ++
641 33 add_tag_R(tags, "audio", 5, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
642 33 add_tag_R(tags, "video", 5, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
643 33 add_tag_R(tags, "source", 6, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
644 33 add_tag_R(tags, "track", 5, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
645 // -- audio, video --
646
647 33 add_tag_R(tags, "b", 1, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
648
649 33 add_tag_R(tags, "base", 4, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
650 33 add_tag_R(tags, "basefont", 8, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
651
652 33 add_tag_R(tags, "bdi", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
653 33 add_tag_R(tags, "bdo", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
654
655 33 add_tag_R(tags, "bgsound", 7, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
656
657 33 add_tag_R(tags, "big", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
658 33 add_tag_R(tags, "blink", 5, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
659 33 add_tag_R(tags, "blockquote", 10, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
660
661 33 add_tag_R(tags, "br", 2, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
662
663 33 add_tag_R(tags, "canvas", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
664 33 add_tag_R(tags, "center", 6, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_TEXT);
665 33 add_tag_R(tags, "cite", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
666 33 add_tag_R(tags, "code", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
667 33 add_tag_R(tags, "comment", 7, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
668
669 // ++ datalist ++
670 33 add_tag_R(tags, "datalist", 8, 20, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
671 //add_tag_R(tags, "option", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
672 // -- datalist --
673
674 33 add_tag_R(tags, "del", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
675
676 // ++ details ++
677 33 add_tag_R(tags, "details", 7, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
678 33 add_tag_R(tags, "summary", 7, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
679 // -- details --
680
681 33 add_tag_R(tags, "dfn", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
682
683 // ++ dir ++
684 33 add_tag_R(tags, "dir", 3, 20, FAMILY_LIST, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL); // out of test
685 //add_tag_R(tags, "li", 2, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_IF_SELF, OPTION_NULL, AI_NULL);
686 // -- dir --
687
688 33 add_tag_R(tags, "div", 3, 50, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
689
690 // ++ dl ++
691 33 add_tag_R(tags, "dl", 2, 20, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
692 33 add_tag_R(tags, "dt", 2, 19, 0, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_PRIORITY_FAMILY, OPTION_NULL, AI_NULL);
693 33 add_tag_R(tags, "dd", 2, 19, 0, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_PRIORITY_FAMILY, OPTION_NULL, AI_NULL);
694 // -- dl --
695
696 33 add_tag_R(tags, "em", 2, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
697
698 33 add_tag_R(tags, "embed", 5, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
699
700 // ++ figure ++
701 33 add_tag_R(tags, "figure", 6, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
702 33 add_tag_R(tags, "figcaption", 10, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
703 // -- figure --
704
705 33 add_tag_R(tags, "font", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
706 33 add_tag_R(tags, "footer", 6, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
707
708 // ++ form ++
709 33 add_tag_R(tags, "form", 4, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
710 33 add_tag_R(tags, "button", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
711
712 // ++ form: fieldset ++
713 33 add_tag_R(tags, "fieldset", 8, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
714 33 add_tag_R(tags, "legend", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
715 // -- form: fieldset --
716
717 // ++ form: select ++
718 33 add_tag_R(tags, "select", 6, 20, FAMILY_SELECT, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_PRIORITY, OPTION_CLEAN_TAGS, AI_NULL);
719 33 add_tag_R(tags, "optgroup", 8, 19, FAMILY_SELECT, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_PRIORITY, OPTION_CLEAN_TAGS_SAVE, AI_NULL);
720 33 add_tag_R(tags, "option", 6, 18, FAMILY_SELECT, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_PRIORITY, OPTION_CLEAN_TAGS_SAVE, AI_NULL);
721 // -- form: select --
722
723 33 add_tag_R(tags, "input", 5, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
724 33 add_tag_R(tags, "keygen", 6, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
725 33 add_tag_R(tags, "textarea", 8, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_SIMPLE, OPTION_NULL, AI_NULL);
726 // -- form --
727
728 // ++ frameset ++
729 33 add_tag_R(tags, "frameset", 8, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
730 33 add_tag_R(tags, "frame", 5, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
731 33 add_tag_R(tags, "noframes", 8, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_SIMPLE_TREE, OPTION_NULL, AI_NULL);
732 // -- frameset --
733
734 // ++ isindex ++ // hm, crazy tag
735 33 add_tag_R(tags, "isindex", 7, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
736 // -- isindex --
737
738 33 add_tag_R(tags, "h1", 2, 0, FAMILY_H, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_TEXT);
739 33 add_tag_R(tags, "h2", 2, 0, FAMILY_H, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_TEXT);
740 33 add_tag_R(tags, "h3", 2, 0, FAMILY_H, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_TEXT);
741 33 add_tag_R(tags, "h4", 2, 0, FAMILY_H, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_TEXT);
742 33 add_tag_R(tags, "h5", 2, 0, FAMILY_H, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_TEXT);
743 33 add_tag_R(tags, "h6", 2, 0, FAMILY_H, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_SELF_FAMILY, OPTION_NULL, AI_TEXT);
744
745 33 add_tag_R(tags, "header", 6, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
746 33 add_tag_R(tags, "hgroup", 6, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
747
748 33 add_tag_R(tags, "hr", 2, 0, 0, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_NOW, OPTION_NULL, AI_NULL); // TYPE_TAG_ONE :)
749
750 33 add_tag_R(tags, "i", 1, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
751
752 33 add_tag_R(tags, "iframe", 6, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_SIMPLE, OPTION_NULL, AI_NULL);
753
754 33 add_tag_R(tags, "img", 3, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_IMG);
755
756 33 add_tag_R(tags, "ins", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
757 33 add_tag_R(tags, "kbd", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
758 33 add_tag_R(tags, "label", 5, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
759
760 // ++ link ++
761 33 add_tag_R(tags, "link", 4, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
762 // -- link --
763
764 // ++ map ++
765 33 add_tag_R(tags, "map", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
766 33 add_tag_R(tags, "area", 4, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
767 // -- map --
768
769 33 add_tag_R(tags, "mark", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
770 33 add_tag_R(tags, "marquee", 7, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
771
772 // ++ menu ++
773 33 add_tag_R(tags, "menu", 4, 20, FAMILY_LIST, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
774 33 add_tag_R(tags, "command", 7, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
775 //add_tag_R(tags, "li", 2, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_IF_SELF, OPTION_NULL, AI_NULL);
776 // -- menu --
777
778 // ++ meta ++
779 33 add_tag_R(tags, "meta", 4, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
780 // -- meta --
781
782 33 add_tag_R(tags, "meter", 5, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
783 33 add_tag_R(tags, "nav", 3, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
784
785 33 add_tag_R(tags, "nobr", 4, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_IF_SELF, OPTION_NULL, AI_NULL);
786
787 33 add_tag_R(tags, "noembed", 7, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_SIMPLE, OPTION_NULL, AI_NULL);
788
789 33 add_tag_R(tags, "noscript", 8, 0, 0, TYPE_TAG_SYS, EXTRA_TAG_SIMPLE, OPTION_NULL, AI_NULL);
790
791 33 add_tag_R(tags, "object", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
792
793 // ++ ol ++
794 33 add_tag_R(tags, "ol", 2, 20, FAMILY_LIST, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
795 //add_tag_R(tags, "li", 2, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_IF_SELF, OPTION_NULL, AI_NULL);
796 // -- ol --
797
798 33 add_tag_R(tags, "output", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
799 33 add_tag_R(tags, "p", 1, 30, 0, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_IF_BLOCK, OPTION_NULL, AI_TEXT);
800
801 33 add_tag_R(tags, "param", 5, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
802
803 //add_tag_R(tags, "plaintext", 9, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL); // out of test -- ?????
804
805 33 add_tag_R(tags, "pre", 3, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_TEXT);
806 33 add_tag_R(tags, "progress", 8, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
807
808 33 add_tag_R(tags, "q", 1, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
809
810 // ++ ruby ++
811 33 add_tag_R(tags, "ruby", 4, 20, FAMILY_RUBY, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
812 33 add_tag_R(tags, "rt", 2, 19, FAMILY_RUBY, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_PRIORITY_FAMILY, OPTION_NULL, AI_NULL);
813 33 add_tag_R(tags, "rp", 2, 19, FAMILY_RUBY, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_PRIORITY_FAMILY, OPTION_NULL, AI_NULL);
814 // -- ruby --
815
816 33 add_tag_R(tags, "s", 1, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
817 33 add_tag_R(tags, "samp", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
818
819 33 add_tag_R(tags, "script", 6, 0, 0, TYPE_TAG_SYS, EXTRA_TAG_SIMPLE, OPTION_NULL, AI_NULL);
820
821 33 add_tag_R(tags, "section", 7, 0, 0, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
822 33 add_tag_R(tags, "small", 5, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
823 33 add_tag_R(tags, "span", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
824 33 add_tag_R(tags, "strike", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_TEXT);
825 33 add_tag_R(tags, "strong", 6, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
826
827 // ++ style ++
828 33 add_tag_R(tags, "style", 5, 0, 0, TYPE_TAG_SYS, EXTRA_TAG_SIMPLE, OPTION_NULL, AI_NULL);
829 // -- style --
830
831 33 add_tag_R(tags, "sub", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
832 33 add_tag_R(tags, "sup", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
833
834 // ++ table ++
835 33 add_tag_R(tags, "table" , 5, 55, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_IF_SELF, OPTION_NULL, AI_NULL);
836 33 add_tag_R(tags, "caption" , 7, 54, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_NULL);
837 33 add_tag_R(tags, "col" , 3, 53, FAMILY_TABLE, TYPE_TAG_ONE , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_NULL);
838 33 add_tag_R(tags, "colgroup" , 8, 54, FAMILY_TABLE, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_NULL);
839 33 add_tag_R(tags, "tbody" , 5, 54, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_NULL);
840 33 add_tag_R(tags, "tfoot" , 5, 54, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_NULL);
841 33 add_tag_R(tags, "thead" , 5, 54, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_NULL);
842 33 add_tag_R(tags, "tr" , 2, 53, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_NULL);
843 33 add_tag_R(tags, "td" , 2, 52, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_TEXT);
844 33 add_tag_R(tags, "th" , 2, 52, FAMILY_TABLE, TYPE_TAG_BLOCK , EXTRA_TAG_CLOSE_FAMILY_LIST, OPTION_NULL, AI_TEXT);
845 // -- table --
846
847 33 add_tag_R(tags, "time", 4, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
848
849 33 add_tag_R(tags, "title", 5, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_SIMPLE_TREE, OPTION_NULL, AI_NULL);
850
851 33 add_tag_R(tags, "tt", 2, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
852 33 add_tag_R(tags, "u", 1, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
853
854 // ++ ul ++
855 33 add_tag_R(tags, "ul", 2, 20, FAMILY_LIST, TYPE_TAG_BLOCK, 0, OPTION_NULL, AI_NULL);
856 33 add_tag_R(tags, "li", 2, 19, FAMILY_LIST, TYPE_TAG_BLOCK, EXTRA_TAG_CLOSE_PRIORITY_FAMILY, OPTION_NULL, AI_TEXT);
857 //add_tag_R(tags, "li", 2, 0, 0, TYPE_TAG_NORMAL, EXTRA_TAG_CLOSE_IF_SELF, OPTION_NULL, AI_NULL); -- orig
858 // -- ul --
859
860 33 add_tag_R(tags, "var", 3, 0, 0, TYPE_TAG_NORMAL, 0, OPTION_NULL, AI_NULL);
861
862 33 add_tag_R(tags, "wbr", 3, 0, 0, TYPE_TAG_ONE, 0, OPTION_NULL, AI_NULL);
863
864 33 add_tag_R(tags, "xmp", 3, 0, 0, TYPE_TAG_BLOCK, EXTRA_TAG_SIMPLE, OPTION_NULL, AI_NULL);
865
866 33 return tags->csize;
867 }
868  
869 152 int check_open_tag_family_tree(struct tags_family *tags_family, struct elements *tree_curr, long ti, int tag_id)
870 {
871 152 int tf = -1; int is_true = 1;
872 240 ▶ while (tags_family->tags[tag_id][++tf]) {
Branch: 1 branch
BranchTrueFalseTotal
while (tags_family->tags[tag_id][++tf]) { 192 48 240
873 192 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].tag_id == tags_family->tags[tag_id][tf]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].tag_id == tags_family->tags[tag_id][tf]) { 97 95 192
874 97 is_true = 2; break;
875 }
876
877 95 ▶ if(is_true == 1 && tags_family->tags[ tags_family->tags[tag_id][tf] ] != 0) {
Branch: 2 branches
BranchTrueFalseTotal
if(is_true == 1 && tags_family->tags[ tags_family->tags[tag_id][tf] ] != 0) { 95 0 95
if(is_true == 1 && tags_family->tags[ tags_family->tags[tag_id][tf] ] != 0) { 49 46 95
878 49 is_true = check_open_tag_family_tree(tags_family, tree_curr, ti, tags_family->tags[tag_id][tf]);
879 49 ▶ if(is_true == 2)
Branch: 1 branch
BranchTrueFalseTotal
if(is_true == 2) 7 42 49
880 7 break;
881 }
882 }
883
884 152 return is_true;
885 }
886  
887 1044 int check_open_tag (struct tree_list *my_r, struct elements *tree_curr, long ti, int tag_id)
888 {
889 1044 struct tags *tags = my_r->tags;
890 1044 int res = 0;
891
892 1044 if(
893 1044 ▶ tags->option[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == OPTION_CLEAN_TAGS &&
Branch: 1 branch
BranchTrueFalseTotal
tags->option[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == OPTION_CLEAN_TAGS && 3 1041 1044
894 3 ▶ tags->option[ tag_id ] != OPTION_CLEAN_TAGS_SAVE
Branch: 1 branch
BranchTrueFalseTotal
tags->option[ tag_id ] != OPTION_CLEAN_TAGS_SAVE 2 1 3
895 ){
896 2 return OPTION_CLEAN_TAGS;
897 }
898
899 1042 if(
900 1042 ▶ tags->extra[tag_id] == EXTRA_TAG_CLOSE_PRIORITY_FAMILY &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[tag_id] == EXTRA_TAG_CLOSE_PRIORITY_FAMILY && 112 930 1042
901 112 ▶ tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_BLOCK
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_BLOCK 11 101 112
902 ){
903 long ir;
904 19 ▶ for(ir = ti - 1; ir >= 1; ir--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ir = ti - 1; ir >= 1; ir--) { 15 4 19
905 15 if(
906 15 ▶ tags->family[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] == tags->family[ tag_id ] &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] == tags->family[ tag_id ] && 7 8 15
907 7 ▶ tags->priority[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] > tags->priority[ tag_id ]
Branch: 1 branch
BranchTrueFalseTotal
tags->priority[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] > tags->priority[ tag_id ] 7 0 7
908 ){
909 7 return 1;
910 }
911 }
912 }
913
914 1035 if(
915 1035 ▶ tags->extra[tag_id] == EXTRA_TAG_CLOSE_PRIORITY_FAMILY &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[tag_id] == EXTRA_TAG_CLOSE_PRIORITY_FAMILY && 105 930 1035
916 105 ▶ tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->family[tag_id] &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->family[tag_id] && 95 10 105
917 95 ▶ tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[tag_id]
Branch: 1 branch
BranchTrueFalseTotal
tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[tag_id] 54 41 95
918 ){
919 54 return 2;
920 }
921 981 else if(
922 981 ▶ tags->extra[tag_id] == EXTRA_TAG_CLOSE_PRIORITY_FAMILY &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[tag_id] == EXTRA_TAG_CLOSE_PRIORITY_FAMILY && 51 930 981
923 51 ▶ tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->family[tag_id] &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->family[tag_id] && 41 10 51
924 41 ▶ tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->priority[tag_id]
Branch: 1 branch
BranchTrueFalseTotal
tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->priority[tag_id] 31 10 41
925 ){
926 long ir;
927 45 ▶ for(ir = ti - 1; ir >= 1; ir--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ir = ti - 1; ir >= 1; ir--) { 42 3 45
928 42 if(
929 42 ▶ tags->family[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] == tags->family[ tag_id ] &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] == tags->family[ tag_id ] && 30 12 42
930 30 ▶ tags->priority[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] > tags->priority[ tag_id ]
Branch: 1 branch
BranchTrueFalseTotal
tags->priority[ tree_curr->tree[ tree_curr->index[ir] ].tag_id ] > tags->priority[ tag_id ] 28 2 30
931 ){
932 28 return 1;
933 }
934 }
935 }
936
937 953 ▶ if(tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_FAMILY_LIST && tags->extra[tag_id] == EXTRA_TAG_CLOSE_FAMILY_LIST) {
Branch: 2 branches
BranchTrueFalseTotal
if(tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_FAMILY_LIST && tags->extra[tag_id] == EXTRA_TAG_CLOSE_FAMILY_LIST) { 110 843 953
if(tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_FAMILY_LIST && tags->extra[tag_id] == EXTRA_TAG_CLOSE_FAMILY_LIST) { 103 7 110
938 103 struct tags_family *tags_family = my_r->tags_family;
939
940 103 ▶ if(tag_id <= tags_family->itags && tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ] != 0){
Branch: 2 branches
BranchTrueFalseTotal
if(tag_id <= tags_family->itags && tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ] != 0){ 103 0 103
if(tag_id <= tags_family->itags && tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ] != 0){ 103 0 103
941 103 return check_open_tag_family_tree(tags_family, tree_curr, ti, tag_id);
942 }
943 }
944 850 else if(
945 //4) Закрываются только встречая себя:
946 850 ▶ (tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_SELF && tree_curr->tree[ tree_curr->index[ti] ].tag_id == tag_id) ||
Branch: 2 branches
BranchTrueFalseTotal
(tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_SELF && tree_curr->tree[ tree_curr->index[ti] ].tag_id == tag_id) || 120 730 850
(tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_SELF && tree_curr->tree[ tree_curr->index[ti] ].tag_id == tag_id) || 33 87 120
947 //5) Закрываются только при встрече блочных элементов:
948 763 ▶ (tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_BLOCK && tags->type[tag_id] == TYPE_TAG_BLOCK) ||
Branch: 2 branches
BranchTrueFalseTotal
(tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_BLOCK && tags->type[tag_id] == TYPE_TAG_BLOCK) || 23 740 763
(tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_BLOCK && tags->type[tag_id] == TYPE_TAG_BLOCK) || 9 14 23
949 (
950 749 ▶ tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_SELF_FAMILY &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_SELF_FAMILY && 347 402 749
951 347 ▶ tags->family[tag_id] == tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[tag_id] == tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] && 4 343 347
952 4 ▶ tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] != 0
Branch: 1 branch
BranchTrueFalseTotal
tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] != 0 0 4 4
953 745 ) ||
954 (
955 745 ▶ tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_SELF_FAMILY &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_IF_SELF_FAMILY && 343 402 745
956 343 ▶ tree_curr->tree[ tree_curr->index[ti] ].tag_id == tag_id
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[ti] ].tag_id == tag_id 343 0 343
957 745 ) ||
958 (
959 745 ▶ tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_PRIORITY &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == EXTRA_TAG_CLOSE_PRIORITY && 6 739 745
960 6 ▶ tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->family[tag_id] &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == tags->family[tag_id] && 5 1 6
961 5 ▶ tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] <= tags->priority[tag_id]
Branch: 1 branch
BranchTrueFalseTotal
tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] <= tags->priority[tag_id] 4 1 5
962 //EXTRA_TAG_CLOSE_PRIORITY
963 )
964 ) {
965 109 return 1;
966 }
967 741 else if(
968 741 ▶ tags->type[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == TYPE_TAG_BLOCK &&
Branch: 1 branch
BranchTrueFalseTotal
tags->type[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] == TYPE_TAG_BLOCK && 696 45 741
969 696 ▶ tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] != 0 && tags->priority[tag_id] != 0 &&
Branch: 2 branches
BranchTrueFalseTotal
tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] != 0 && tags->priority[tag_id] != 0 && 696 0 696
tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] != 0 && tags->priority[tag_id] != 0 && 217 479 696
970 217 ▶ tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] >= tags->priority[tag_id]
Branch: 1 branch
BranchTrueFalseTotal
tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] >= tags->priority[tag_id] 194 23 217
971 ){
972 194 return 2;
973 }
974
975 547 return res;
976 }
977  
978 114 void add_to_tree(struct tree_list *my_r, struct elements *tree_curr, long my_buff, long i, int tag_id) {
979 114 struct tags *tags = my_r->tags;
980
981 114 tree_curr->ltree++;
982
983 114 ▶ if(tree_curr->is_base == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 1) { 95 19 114
984 95 tags->index.tag_count[tag_id]++;
985 95 ▶ if(tags->index.tag_count[tag_id] >= tags->index.tag_csize[tag_id]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->index.tag_count[tag_id] >= tags->index.tag_csize[tag_id]) { 0 95 95
986 0 tags->index.tag_csize[tag_id] += 128;
987 0 tags->index.tag_id[tag_id] = (long *)realloc(tags->index.tag_id[tag_id], sizeof(long) * tags->index.tag_csize[tag_id]);
988 }
989
990 95 tags->index.tag_id[tag_id][ tags->index.tag_count[tag_id] ] = tree_curr->ltree;
991 }
992
993 114 ▶ if(tree_curr->ltree >= tree_curr->ltree_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->ltree >= tree_curr->ltree_size) { 0 114 114
994 0 tree_curr->ltree_size += 1024;
995 0 tree_curr->tree = (struct html_tree *)realloc(tree_curr->tree, sizeof(struct html_tree) * tree_curr->ltree_size);
996
997 0 ▶ if(tree_curr->is_base == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 1) 0 0 0
998 0 my_r->list = tree_curr->tree;
999 }
1000
1001 114 tree_curr->tree[tree_curr->ltree].id = tree_curr->ltree;
1002 114 tree_curr->tree[tree_curr->ltree].tag_id = tag_id;
1003 114 tree_curr->tree[tree_curr->ltree].my_id = my_buff;
1004 114 tree_curr->tree[tree_curr->ltree].tag_body_start = i;
1005 114 tree_curr->tree[tree_curr->ltree].tag_body_stop = -1;
1006 114 tree_curr->tree[tree_curr->ltree].tag_stop = -1;
1007 114 tree_curr->tree[tree_curr->ltree].count_element = 0;
1008 114 tree_curr->tree[tree_curr->ltree].count_element_in = 0;
1009 114 tree_curr->tree[tree_curr->ltree].count_word = 0;
1010
1011 114 ▶ if(my_buff > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_buff > -1) { 19 95 114
1012 19 tree_curr->tree[tree_curr->ltree].tag_start = my_r->my[my_buff].start_otag - 1;
1013 } else {
1014 95 tree_curr->tree[tree_curr->ltree].tag_start = -1;
1015 }
1016
1017 114 memset(tree_curr->tree[tree_curr->ltree].counts, 0, AI_BUFF);
1018 114 memset(tree_curr->tree[tree_curr->ltree].counts_in, 0, AI_BUFF);
1019
1020 114 tree_curr->lindex++;
1021
1022 114 ▶ if(tree_curr->lindex >= tree_curr->lindex_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->lindex >= tree_curr->lindex_size) { 0 114 114
1023 0 tree_curr->lindex_size += 1024;
1024 0 tree_curr->index = (long *)realloc(tree_curr->index, sizeof(long) * tree_curr->lindex_size);
1025 }
1026
1027 114 tree_curr->index[tree_curr->lindex] = tree_curr->ltree;
1028 114 tree_curr->tree[ tree_curr->ltree ].inc = tree_curr->lindex;
1029
1030 114 ▶ if(tree_curr->lindex > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->lindex > 0) { 114 0 114
1031 114 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].count_element++;
1032 114 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].count_element_in++;
1033
1034 114 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].counts[ tags->ai[ tree_curr->tree[ tree_curr->ltree ].tag_id ] ]++;
1035 114 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].counts_in[ tags->ai[ tree_curr->tree[ tree_curr->ltree ].tag_id ] ]++;
1036 }
1037 114 }
1038  
1039 594 void add_tag_family(struct tags_family *tags_family, int tag_from, int tag_to) {
1040
1041 594 ▶ if(tags_family->itags_size <= tag_from) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags_family->itags_size <= tag_from) { 0 594 594
1042 0 tags_family->itags_size += 1024;
1043 0 tags_family->tags = (int **)realloc(tags_family->tags, sizeof(int *) * tags_family->itags_size);
1044 0 memset(tags_family->tags[tags_family->itags_size - 1024], 0, 1024);
1045 }
1046
1047 594 ▶ if(tags_family->itags < tag_from) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags_family->itags < tag_from) { 231 363 594
1048 231 tags_family->itags = tag_from;
1049 }
1050
1051 594 int i = -1;
1052 594 ▶ if(tags_family->tags[tag_from] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags_family->tags[tag_from] != 0) { 66 528 594
1053 165 ▶ while (tags_family->tags[tag_from][++i]){}
Branch: 1 branch
BranchTrueFalseTotal
while (tags_family->tags[tag_from][++i]){} 99 66 165
1054 66 tags_family->tags[tag_from][i] = tag_to;
1055 66 tags_family->tags[tag_from][++i] = '\0';
1056 } else {
1057 528 tags_family->tags[tag_from] = (int*)malloc(sizeof(int) * 128);
1058 528 tags_family->tags[tag_from][++i] = tag_to;
1059 528 tags_family->tags[tag_from][++i] = '\0';
1060 }
1061
1062 594 ▶ if(tags_family->irtags_size <= tag_to) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags_family->irtags_size <= tag_to) { 0 594 594
1063 0 tags_family->irtags_size += 1024;
1064 0 tags_family->rtags = (int **)realloc(tags_family->rtags, sizeof(int *) * tags_family->irtags_size);
1065 0 memset(tags_family->rtags[tags_family->irtags_size - 1024], 0, 1024);
1066 }
1067
1068 594 ▶ if(tags_family->irtags < tag_to) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags_family->irtags < tag_to) { 165 429 594
1069 165 tags_family->irtags = tag_to;
1070 }
1071
1072 594 i = -1;
1073 594 ▶ if(tags_family->rtags[tag_to] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags_family->rtags[tag_to] != 0) { 363 231 594
1074 1518 ▶ while (tags_family->rtags[tag_to][++i]){}
Branch: 1 branch
BranchTrueFalseTotal
while (tags_family->rtags[tag_to][++i]){} 1155 363 1518
1075 363 tags_family->rtags[tag_to][i] = tag_from;
1076 363 tags_family->rtags[tag_to][++i] = '\0';
1077 } else {
1078 231 tags_family->rtags[tag_to] = (int*)malloc(sizeof(int) * 128);
1079 231 tags_family->rtags[tag_to][++i] = tag_from;
1080 231 tags_family->rtags[tag_to][++i] = '\0';
1081 }
1082 594 }
1083  
1084 33 struct tags_family * init_tags_family(struct tags *tags){
1085 33 struct tags_family *tags_family = (struct tags_family*)malloc(sizeof(struct tags_family));
1086
1087 33 tags_family->itags = -1;
1088 33 tags_family->itags_size = 2048;
1089 33 tags_family->tags = (int **)malloc(sizeof(int *) * tags_family->itags_size);
1090 33 memset(tags_family->tags, 0, tags_family->itags_size);
1091
1092 33 tags_family->irtags = -1;
1093 33 tags_family->irtags_size = 2048;
1094 33 tags_family->rtags = (int **)malloc(sizeof(int *) * tags_family->irtags_size);
1095 33 memset(tags_family->rtags, 0, tags_family->irtags_size);
1096
1097 33 int tag_id_table = get_tag_id(tags, "table");
1098 33 int tag_id_tr = get_tag_id(tags, "tr");
1099 33 int tag_id_td = get_tag_id(tags, "td");
1100 33 int tag_id_th = get_tag_id(tags, "th");
1101
1102 33 add_tag_family(tags_family, get_tag_id(tags, "tbody"), tag_id_table);
1103 33 add_tag_family(tags_family, get_tag_id(tags, "tfoot"), tag_id_table);
1104 33 add_tag_family(tags_family, get_tag_id(tags, "thead"), tag_id_table);
1105
1106 33 add_tag_family(tags_family, get_tag_id(tags, "colgroup"), tag_id_table);
1107
1108 33 add_tag_family(tags_family, tag_id_tr, get_tag_id(tags, "tbody"));
1109 33 add_tag_family(tags_family, tag_id_tr, get_tag_id(tags, "tfoot"));
1110 33 add_tag_family(tags_family, tag_id_tr, get_tag_id(tags, "thead"));
1111
1112 33 add_tag_family(tags_family, tag_id_td, tag_id_tr);
1113 33 add_tag_family(tags_family, tag_id_th, tag_id_tr);
1114
1115 33 add_tag_family(tags_family, get_tag_id(tags, "col"), get_tag_id(tags, "colgroup"));
1116
1117 33 add_tag_family(tags_family, get_tag_id(tags, "base"), get_tag_id(tags, "head"));
1118 33 add_tag_family(tags_family, get_tag_id(tags, "basefont"), get_tag_id(tags, "head"));
1119 33 add_tag_family(tags_family, get_tag_id(tags, "noscript"), get_tag_id(tags, "head"));
1120 33 add_tag_family(tags_family, get_tag_id(tags, "script"), get_tag_id(tags, "head"));
1121 33 add_tag_family(tags_family, get_tag_id(tags, "meta"), get_tag_id(tags, "head"));
1122 33 add_tag_family(tags_family, get_tag_id(tags, "style"), get_tag_id(tags, "head"));
1123 33 add_tag_family(tags_family, get_tag_id(tags, "title"), get_tag_id(tags, "head"));
1124 33 add_tag_family(tags_family, get_tag_id(tags, "link"), get_tag_id(tags, "head"));
1125
1126 33 return tags_family;
1127 }
1128  
1129 603 int check_family_exists(struct tags_family *tags_family, int from_id, int to_id) {
1130 603 ▶ if(tags_family->tags[from_id] == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(tags_family->tags[from_id] == 0) 473 130 603
1131 473 return 0;
1132
1133 130 int tf = -1; int is_true = 0;
1134 352 ▶ while (tags_family->tags[from_id][++tf]) {
Branch: 1 branch
BranchTrueFalseTotal
while (tags_family->tags[from_id][++tf]) { 222 130 352
1135 222 ▶ if(to_id == tags_family->tags[from_id][tf]) {
Branch: 1 branch
BranchTrueFalseTotal
if(to_id == tags_family->tags[from_id][tf]) { 0 222 222
1136 0 is_true = 1; break;
1137 }
1138 }
1139
1140 130 return is_true;
1141 }
1142  
1143 167 int check_struct_level_up(struct tree_list *my_r, struct elements *tree_curr, long my_buff, long i, int tag_id) {
1144 167 struct tags_family *tags_family = my_r->tags_family;
1145
1146 167 long ir; long level = -1;
1147 451 ▶ for(ir = tree_curr->ltree - 1; ir >= 1; ir--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ir = tree_curr->ltree - 1; ir >= 1; ir--) { 433 18 451
1148 433 ▶ if(tree_curr->tree[ir].inc < tree_curr->tree[ tree_curr->ltree ].inc && tree_curr->tree[ir].tag_stop == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->tree[ir].inc < tree_curr->tree[ tree_curr->ltree ].inc && tree_curr->tree[ir].tag_stop == -1) { 149 284 433
if(tree_curr->tree[ir].inc < tree_curr->tree[ tree_curr->ltree ].inc && tree_curr->tree[ir].tag_stop == -1) { 149 0 149
1149 149 level = ir;
1150 149 break;
1151 }
1152 }
1153
1154 167 ▶ if(tree_curr->tree[ tree_curr->ltree ].tag_id <= tags_family->itags &&
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->ltree ].tag_id <= tags_family->itags && 167 0 167
1155 167 ▶ tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ] != 0
Branch: 1 branch
BranchTrueFalseTotal
tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ] != 0 149 18 167
1156 ){
1157 149 int tf = -1; int is_true = 0;
1158 222 ▶ while (tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ][++tf]) {
Branch: 1 branch
BranchTrueFalseTotal
while (tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ][++tf]) { 203 19 222
1159 203 ▶ if(tree_curr->tree[level].tag_id == tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ][tf]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[level].tag_id == tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ][tf]) { 130 73 203
1160 130 is_true = 1; break;
1161 }
1162 }
1163
1164 149 ▶ if(is_true == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_true == 0) { 19 130 149
1165 19 tree_curr->tree[tree_curr->ltree].tag_id = tags_family->tags[ tree_curr->tree[ tree_curr->ltree ].tag_id ][0];
1166 19 tree_curr->tree[tree_curr->ltree].my_id = -1;
1167 19 tree_curr->tree[tree_curr->ltree].tag_body_start = tree_curr->tree[tree_curr->ltree].tag_start;
1168 19 tree_curr->tree[tree_curr->ltree].count_element = 0;
1169 19 tree_curr->tree[tree_curr->ltree].count_element_in = 0;
1170
1171 19 check_struct_level_up(my_r, tree_curr, my_buff, i, tree_curr->tree[ tree_curr->ltree ].tag_id);
1172 19 add_to_tree(my_r, tree_curr, my_buff, i, tag_id);
1173 }
1174 }
1175
1176 167 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 18 149 167
1177 18 return -1;
1178
1179 149 return tree_curr->tree[level].inc;
1180 }
1181  
1182 7 void check_struct_level_down(struct tree_list *my_r, struct elements *tree_curr, long my_buff, long i, int tag_id) {
1183 7 struct tags_family *tags_family = my_r->tags_family;
1184
1185 7 long ir; long level = -1;
1186 12 ▶ for(ir = tree_curr->ltree - 1; ir >= 1; ir--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ir = tree_curr->ltree - 1; ir >= 1; ir--) { 12 0 12
1187 12 ▶ if(tree_curr->tree[ir].inc < tree_curr->tree[ tree_curr->ltree ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ir].inc < tree_curr->tree[ tree_curr->ltree ].inc) { 7 5 12
1188 7 level = ir;
1189 7 break;
1190 }
1191 }
1192
1193 7 if(
1194 7 ▶ my_r->tags->extra[ tree_curr->tree[level].tag_id ] == EXTRA_TAG_CLOSE_FAMILY_LIST &&
Branch: 1 branch
BranchTrueFalseTotal
my_r->tags->extra[ tree_curr->tree[level].tag_id ] == EXTRA_TAG_CLOSE_FAMILY_LIST && 4 3 7
1195 4 ▶ tree_curr->tree[level].tag_id <= tags_family->irtags &&
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[level].tag_id <= tags_family->irtags && 0 4 4
1196 0 ▶ tags_family->rtags[ tree_curr->tree[level].tag_id ] != 0
Branch: 1 branch
BranchTrueFalseTotal
tags_family->rtags[ tree_curr->tree[level].tag_id ] != 0 0 0 0
1197 )
1198 {
1199 0 int tf = -1; int is_true = 0;
1200 0 ▶ while (tags_family->rtags[ tree_curr->tree[level].tag_id ][++tf]) {
Branch: 1 branch
BranchTrueFalseTotal
while (tags_family->rtags[ tree_curr->tree[level].tag_id ][++tf]) { 0 0 0
1201 0 ▶ if(tag_id == tags_family->rtags[ tree_curr->tree[level].tag_id ][tf]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id == tags_family->rtags[ tree_curr->tree[level].tag_id ][tf]) { 0 0 0
1202 0 is_true = 1; break;
1203 }
1204 }
1205
1206 0 ▶ if(is_true == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_true == 0) { 0 0 0
1207 0 int res = check_open_tag(my_r, tree_curr, level, tags_family->rtags[ tree_curr->tree[level].tag_id ][0]);
1208
1209 0 tree_curr->tree[tree_curr->ltree].tag_id = tags_family->rtags[ tree_curr->tree[level].tag_id ][0];
1210 0 tree_curr->tree[tree_curr->ltree].my_id = -1;
1211 0 tree_curr->tree[tree_curr->ltree].tag_body_start = tree_curr->tree[tree_curr->ltree].tag_start;
1212 0 tree_curr->tree[tree_curr->ltree].count_element = 0;
1213 0 tree_curr->tree[tree_curr->ltree].count_element_in = 0;
1214 0 tree_curr->tree[tree_curr->ltree].inc -= res;
1215
1216 0 check_struct_level_down(my_r, tree_curr, my_buff, i, tree_curr->tree[tree_curr->ltree].tag_id);
1217
1218 0 add_to_tree(my_r, tree_curr, my_buff, i, tag_id);
1219 }
1220 }
1221 7 }
1222  
1223 172 int close_all_element_with_id(struct mem_tag *my, struct elements *tree_curr, long my_buff, long i) {
1224 172 int ti; int tag_ool = tree_curr->lindex;
1225 236 ▶ for(ti = tag_ool; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tag_ool; ti >= 1; ti--) { 236 0 236
1226 236 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){ 0 236 236
1227 0 continue;
1228 }
1229
1230 236 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].id < tree_curr->tree[ tree_curr->last_element_id ].id) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].id < tree_curr->tree[ tree_curr->last_element_id ].id) { 119 117 236
1231 119 break;
1232 }
1233
1234 117 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = my[ my_buff ].start_otag - 2;
1235 117 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
1236
1237 117 tree_curr->lindex = tree_curr->tree[ tree_curr->index[ti] ].inc - 1;
1238 117 tree_curr->tree[ tree_curr->index[ti - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ti] ].count_element_in;
1239
1240 int si;
1241 585 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 468 117 585
1242 468 tree_curr->tree[ tree_curr->index[ti - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ti] ].counts_in[ si ];
1243 }
1244
1245 117 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].id == tree_curr->last_element_id) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].id == tree_curr->last_element_id) { 53 64 117
1246 53 break;
1247 }
1248 }
1249
1250 172 return ti;
1251 }
1252  
1253 29 int close_all_element_by_tag_id(struct mem_tag *my, struct elements *tree_curr, struct tags *tags, int tag_id, long my_buff, long i) {
1254 29 int ti; int tag_ool = tree_curr->lindex;
1255 29 ▶ for(ti = tag_ool; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tag_ool; ti >= 1; ti--) { 29 0 29
1256 29 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){ 0 29 29
1257 0 continue;
1258 }
1259
1260 29 ▶ if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[ tag_id ]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[ tag_id ]) { 0 29 29
1261 0 break;
1262 }
1263
1264 29 ▶ if(my_buff > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_buff > 0) { 0 29 29
1265 0 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = my[ my_buff ].start_otag - 2;
1266 0 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
1267 } else {
1268 29 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
1269 29 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = tree_curr->tree[ tree_curr->index[ti] ].tag_stop;
1270 }
1271
1272 29 tree_curr->lindex = tree_curr->tree[ tree_curr->index[ti] ].inc - 1;
1273 29 tree_curr->tree[ tree_curr->index[ti - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ti] ].count_element_in;
1274
1275 int si;
1276 145 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 116 29 145
1277 116 tree_curr->tree[ tree_curr->index[ti - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ti] ].counts_in[ si ];
1278 }
1279
1280 29 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].tag_id == tag_id) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].tag_id == tag_id) { 29 0 29
1281 29 break;
1282 }
1283 }
1284
1285 29 return ti;
1286 }
1287  
1288 18 long close_this_jail(struct tree_list *my_r, struct tree_jail *tree_jail, struct elements *tree_curr, long i) {
1289 long ie, ei;
1290
1291 // закрываем все не закрытые теги внутри изолированной обработки
1292 18 int ti; long ni = i - 2;
1293 22 ▶ for(ti = tree_jail->elements[tree_jail->curr_element].lindex; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tree_jail->elements[tree_jail->curr_element].lindex; ti >= 1; ti--) { 4 18 22
1294 4 ▶ if(tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti] ].tag_body_stop == -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti] ].tag_body_stop == -1){ 4 0 4
1295 // сохраняем общее количество тегов
1296 4 tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti - 1] ].count_element_in +=
1297 4 tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti] ].count_element_in;
1298
1299 int si;
1300 20 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 16 4 20
1301 16 tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti - 1] ].counts_in[ si ] +=
1302 16 tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti] ].counts_in[ si ];
1303 }
1304
1305 4 tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti] ].tag_body_stop = ni;
1306 4 tree_jail->elements[tree_jail->curr_element].tree[ tree_jail->elements[tree_jail->curr_element].index[ti] ].tag_stop = ni;
1307 }
1308 }
1309
1310 18 ie = tree_jail->elements[tree_jail->curr_element].prev;
1311
1312 // проверка будет ли входит в последний элемент родителя этот изолированный тег
1313 18 int tag_ool = tree_jail->elements[ie].lindex;
1314 21 ▶ for(ti = tag_ool; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tag_ool; ti >= 1; ti--) { 21 0 21
1315 21 ▶ if(tree_jail->elements[ie].tree[ tree_jail->elements[ie].index[ti] ].tag_body_stop != -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail->elements[ie].tree[ tree_jail->elements[ie].index[ti] ].tag_body_stop != -1){ 0 21 21
1316 0 continue;
1317 }
1318
1319 21 ▶ if(check_open_tag(my_r, &tree_jail->elements[ie], ti, tree_curr->tree[1].tag_id) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(check_open_tag(my_r, &tree_jail->elements[ie], ti, tree_curr->tree[1].tag_id) == 1) { 3 18 21
1320 3 continue;
1321 }
1322
1323 18 break;
1324 }
1325
1326 // копируем статистику она архиважна для нас
1327 // мы типа уверены, что тут только один главный тег
1328 18 tree_jail->elements[ie].tree[ tree_jail->elements[ie].index[ti] ].count_element += 1;
1329
1330 18 tree_jail->elements[ie].tree[ tree_jail->elements[ie].index[ti] ].count_element_in +=
1331 18 tree_jail->elements[tree_jail->curr_element].tree[1].count_element_in + 1;
1332
1333 int si;
1334 90 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 72 18 90
1335 72 tree_jail->elements[ie].tree[ tree_jail->elements[ie].index[ti] ].counts_in[ si ] +=
1336 72 tree_jail->elements[tree_jail->curr_element].tree[1].counts_in[ si ];
1337 }
1338
1339 18 ▶ if((tree_jail->elements[ie].ltree + tree_jail->elements[tree_jail->curr_element].ltree) >= tree_jail->elements[ie].ltree_size) {
Branch: 1 branch
BranchTrueFalseTotal
if((tree_jail->elements[ie].ltree + tree_jail->elements[tree_jail->curr_element].ltree) >= tree_jail->elements[ie].ltree_size) { 0 18 18
1340 0 tree_jail->elements[ie].ltree_size += 1024 + tree_jail->elements[tree_jail->curr_element].ltree;
1341 0 tree_jail->elements[ie].tree = (struct html_tree *)realloc(tree_jail->elements[ie].tree, sizeof(struct html_tree) * tree_jail->elements[ie].ltree_size);
1342
1343 0 ▶ if(tree_jail->elements[ie].is_base == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail->elements[ie].is_base == 1) 0 0 0
1344 0 my_r->list = tree_jail->elements[ie].tree;
1345 }
1346
1347 18 long last_max_id = tree_jail->elements[ie].ltree;
1348 int tag_id;
1349 // копирование всех изолированных тегов в родителя
1350 18 ▶ if(tree_jail->elements[ie].is_base == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail->elements[ie].is_base == 1) { 14 4 18
1351 250 ▶ for(ei = 1; ei <= tree_jail->elements[tree_jail->curr_element].ltree; ei++) {
Branch: 1 branch
BranchTrueFalseTotal
for(ei = 1; ei <= tree_jail->elements[tree_jail->curr_element].ltree; ei++) { 236 14 250
1352 236 tree_jail->elements[ie].ltree++;
1353 236 tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree] = tree_jail->elements[tree_jail->curr_element].tree[ei];
1354 236 tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree].inc += tree_jail->elements[ie].tree[ tree_jail->elements[ie].index[ti] ].inc;
1355 236 tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree].id += last_max_id;
1356
1357 236 tag_id = tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree].tag_id;
1358
1359 236 my_r->tags->index.tag_count[tag_id]++;
1360 236 ▶ if(my_r->tags->index.tag_count[tag_id] >= my_r->tags->index.tag_csize[tag_id]) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->index.tag_count[tag_id] >= my_r->tags->index.tag_csize[tag_id]) { 0 236 236
1361 0 my_r->tags->index.tag_csize[tag_id] += 128;
1362 0 my_r->tags->index.tag_id[tag_id] = (long *)realloc(my_r->tags->index.tag_id[tag_id], sizeof(long) * my_r->tags->index.tag_csize[tag_id]);
1363 }
1364
1365 236 my_r->tags->index.tag_id[tag_id][ my_r->tags->index.tag_count[tag_id] ] = tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree].id;
1366 }
1367 } else {
1368 24 ▶ for(ei = 1; ei <= tree_jail->elements[tree_jail->curr_element].ltree; ei++) {
Branch: 1 branch
BranchTrueFalseTotal
for(ei = 1; ei <= tree_jail->elements[tree_jail->curr_element].ltree; ei++) { 20 4 24
1369 20 tree_jail->elements[ie].ltree++;
1370 20 tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree] = tree_jail->elements[tree_jail->curr_element].tree[ei];
1371 20 tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree].inc += tree_jail->elements[ie].tree[ tree_jail->elements[ie].index[ti] ].inc;
1372 20 tree_jail->elements[ie].tree[tree_jail->elements[ie].ltree].id += last_max_id;
1373 }
1374 }
1375
1376 18 return ie;
1377 }
1378  
1379 33 void html_tree(struct tree_list *my_r)
1380 {
1381 33 char *html = my_r->html;
1382 33 struct tags *tags = my_r->tags;
1383
1384 // инициализируем список тегов
1385 33 init_tags(tags);
1386
1387 33 int tag_id_table = get_tag_id(tags, "table");
1388 33 int tag_id_td = get_tag_id(tags, "td");
1389 33 int tag_id_th = get_tag_id(tags, "th");
1390
1391 33 int tag_id_html = get_tag_id(tags, "html");
1392 33 int tag_id_head = get_tag_id(tags, "head");
1393 33 int tag_id_body = get_tag_id(tags, "body");
1394
1395 33 int tag_id_doctype = get_tag_id(tags, "!doctype");
1396
1397 // ирнициализируем зависимости тегов
1398 33 struct tags_family *tags_family = init_tags_family(tags);
1399 33 my_r->tags_family = tags_family;
1400
1401 // инициализируем временные буфер для тегов, там хранится их начало, окончание
1402 33 long my_buff = -1, my_real_buff = -1;
1403 33 long my_buff_size = 1024 * 10;
1404 33 struct mem_tag* my = (struct mem_tag *)malloc(sizeof(struct mem_tag) * my_buff_size);
1405
1406 33 my_r->my = my;
1407
1408 // инициализируем клетку для отдельных структур, таблицы и прочее
1409 // root находится в нулевом элементе клетки
1410 struct tree_jail tree_jail;
1411 33 tree_jail.lelements = 0;
1412 33 tree_jail.lelements_size = 1024;
1413 33 tree_jail.elements = (struct elements*)malloc(sizeof(struct elements) * tree_jail.lelements_size);
1414
1415 33 tree_jail.curr_element = 0;
1416
1417 struct elements *tree_curr;
1418 33 tree_curr = &tree_jail.elements[tree_jail.lelements];
1419
1420 // заполняем информацию для root-а
1421 // это основной элемент, его власть непоколебима
1422 33 tree_curr->lindex = 0;
1423 33 tree_curr->lindex_size = 1024;
1424 33 tree_curr->index = (long *)malloc(sizeof(long) * tree_curr->lindex_size);
1425
1426 33 tree_curr->ltree = 0;
1427 33 tree_curr->ltree_size = 1024 * 10;
1428 33 tree_curr->tree = (struct html_tree *)malloc(sizeof(struct html_tree) * tree_curr->ltree_size);
1429
1430 33 tree_curr->count = -1;
1431 33 tree_curr->is_base = 1;
1432
1433 33 tree_curr->tree[tree_curr->ltree].id = 0;
1434 33 tree_curr->tree[tree_curr->ltree].tag_id = -1;
1435 33 tree_curr->tree[tree_curr->ltree].my_id = -1;
1436 33 tree_curr->tree[tree_curr->ltree].tag_body_start = 0;
1437 33 tree_curr->tree[tree_curr->ltree].tag_body_stop = -1;
1438 33 tree_curr->tree[tree_curr->ltree].tag_start = 0;
1439 33 tree_curr->tree[tree_curr->ltree].tag_stop = -1;
1440 33 tree_curr->tree[tree_curr->ltree].count_element = 0;
1441 33 tree_curr->tree[tree_curr->ltree].count_element_in = 0;
1442 33 tree_curr->tree[tree_curr->ltree].count_word = 0;
1443
1444 33 memset(tree_curr->tree[tree_curr->ltree].counts, 0, AI_BUFF);
1445 33 memset(tree_curr->tree[tree_curr->ltree].counts_in, 0, AI_BUFF);
1446
1447 33 tree_curr->index[tree_curr->lindex] = tree_curr->ltree;
1448 33 tree_curr->tree[tree_curr->ltree].inc = tree_curr->lindex;
1449
1450 33 tree_curr->next = -1;
1451 33 tree_curr->prev = -1;
1452 33 tree_curr->last_element_id = -1;
1453
1454 33 my_r->list = tree_jail.elements[0].tree;
1455
1456 // инициализируем ременные данные для анализа html
1457 33 long i = 0, pos = 0, count_tag = 1;
1458 33 char nc; long next_tag = 0;
1459 33 long text_position = -1;
1460
1461 33 int is_comment = 0, is_open_key = 0; int spl_word = 0;
1462 33 int body_is_open = 0, head_is_open = 0;
1463
1464 6282 ▶ while( (nc = html[i++]) ) {
Branch: 1 branch
BranchTrueFalseTotal
while( (nc = html[i++]) ) { 6249 33 6282
1465 6249 ▶ if(
Branch: 1 branch
BranchTrueFalseTotal
if( 838 5411 6249
1466 838 ▶ (nc == '>' && is_open_key == 1) &&
Branch: 2 branches
BranchTrueFalseTotal
(nc == '>' && is_open_key == 1) && 838 0 838
(nc == '>' && is_open_key == 1) && 838 0 838
1467 (
1468 838 ▶ (my_buff != -1 && (my[my_buff].qo == '\0' || my[my_buff].qo == ' ')) ||
Branch: 3 branches
BranchTrueFalseTotal
(my_buff != -1 && (my[my_buff].qo == '\0' || my[my_buff].qo == ' ')) || 0 838 838
(my_buff != -1 && (my[my_buff].qo == '\0' || my[my_buff].qo == ' ')) || 0 0 0
(my_buff != -1 && (my[my_buff].qo == '\0' || my[my_buff].qo == ' ')) || 0 0 0
1469 (is_comment != 0)
1470 )
1471 )
1472 {
1473 838 ▶ if(is_comment != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_comment != 0) { 0 838 838
1474 0 ▶ if(is_comment == 1 && html[i-2] == '-' && html[i-3] == '-') {
Branch: 3 branches
BranchTrueFalseTotal
if(is_comment == 1 && html[i-2] == '-' && html[i-3] == '-') { 0 0 0
if(is_comment == 1 && html[i-2] == '-' && html[i-3] == '-') { 0 0 0
if(is_comment == 1 && html[i-2] == '-' && html[i-3] == '-') { 0 0 0
1475 0 is_comment = 0;
1476 0 is_open_key = 0;
1477 0 pos = 0;
1478 }
1479 0 ▶ else if(is_comment == 2) {
Branch: 1 branch
BranchTrueFalseTotal
else if(is_comment == 2) { 0 0 0
1480 0 is_comment = 0;
1481 0 is_open_key = 0;
1482 0 pos = 0;
1483 }
1484
1485 0 continue;
1486 }
1487
1488 838 is_open_key = 0;
1489
1490 838 ▶ if(my_buff == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(my_buff == -1) 0 838 838
1491 0 continue;
1492
1493 // если пришел закрывающий тег
1494 838 ▶ if(html[ my[my_buff].start_otag ] == '/') {
Branch: 1 branch
BranchTrueFalseTotal
if(html[ my[my_buff].start_otag ] == '/') { 264 574 838
1495 // если тег пустой и небыло данных об окончании
1496 264 ▶ if(my[my_buff].stop_otag == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(my[my_buff].stop_otag == 0) 264 0 264
1497 264 my[my_buff].stop_otag = i - 2;
1498
1499 264 int tag_id = cmp_tags(tags, html, &my[my_buff], 1);
1500
1501 264 ▶ if(tag_id == tag_id_head || tag_id == tag_id_body || tag_id == tag_id_html) {
Branch: 3 branches
BranchTrueFalseTotal
if(tag_id == tag_id_head || tag_id == tag_id_body || tag_id == tag_id_html) { 264 0 264
if(tag_id == tag_id_head || tag_id == tag_id_body || tag_id == tag_id_html) { 260 4 264
if(tag_id == tag_id_head || tag_id == tag_id_body || tag_id == tag_id_html) { 4 256 260
1502 8 pos = 0;
1503 8 next_tag = 0;
1504 8 my_buff--;
1505 8 continue;
1506 }
1507
1508 256 ▶ if(tree_curr->next != -1 && tree_curr->last_element_id != -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->next != -1 && tree_curr->last_element_id != -1) { 123 133 256
if(tree_curr->next != -1 && tree_curr->last_element_id != -1) { 123 0 123
1509 123 ▶ if(tags->family[tag_id] == FAMILY_TABLE) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->family[tag_id] == FAMILY_TABLE) { 71 52 123
1510 71 close_all_element_with_id(my, tree_curr, my_buff, i);
1511
1512 71 tree_curr->last_element_id = -1;
1513
1514 71 tree_jail.curr_element = tree_curr->next;
1515 71 tree_curr->next = -1;
1516 71 tree_curr = &tree_jail.elements[tree_jail.curr_element];
1517 }
1518 }
1519
1520 256 ▶ if(tree_curr->lindex > -1 && tag_id > -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->lindex > -1 && tag_id > -1) { 256 0 256
if(tree_curr->lindex > -1 && tag_id > -1) { 256 0 256
1521 // проверяем открывался ли вообще пришедший тег
1522 256 int ti; int is_open = 0;
1523 302 ▶ for(ti = tree_curr->lindex; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tree_curr->lindex; ti >= 1; ti--) { 302 0 302
1524 302 ▶ if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[tag_id]){
Branch: 1 branch
BranchTrueFalseTotal
if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[tag_id]){ 10 292 302
1525 10 break;
1526 }
1527
1528 292 ▶ if(tag_id == tree_curr->tree[ tree_curr->index[ti] ].tag_id && tree_curr->tree[ tree_curr->index[ti] ].tag_stop == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tag_id == tree_curr->tree[ tree_curr->index[ti] ].tag_id && tree_curr->tree[ tree_curr->index[ti] ].tag_stop == -1) { 246 46 292
if(tag_id == tree_curr->tree[ tree_curr->index[ti] ].tag_id && tree_curr->tree[ tree_curr->index[ti] ].tag_stop == -1) { 246 0 246
1529 246 is_open = 1;
1530 246 break;
1531 }
1532 }
1533
1534 // проверка евляется ли тег "простым", то есть, тег съедал все внутри себя, а теперь пришло его закрытие
1535 // для таких тегов закрытием считается самое первое попавшееся, не важно что было до этого (хоть он 9000+ раз открывался внутри)
1536 256 ▶ if(tree_curr->ltree > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->ltree > 0) { 256 0 256
1537 256 ▶ if(tags->extra[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ] == EXTRA_TAG_SIMPLE &&
Branch: 1 branch
BranchTrueFalseTotal
if(tags->extra[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ] == EXTRA_TAG_SIMPLE && 0 256 256
1538 0 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_body_stop == -1 &&
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_body_stop == -1 && 0 0 0
1539 0 ▶ tag_id != tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id
Branch: 1 branch
BranchTrueFalseTotal
tag_id != tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id 0 0 0
1540 ) {
1541 0 pos = 0;
1542 0 next_tag = 0;
1543 0 my_buff--;
1544 0 continue;
1545 }
1546 }
1547
1548 // пришедший закрывающий тег открывался ранее и еще не был закрыт, ну что же, закроем его
1549 256 ▶ if(is_open == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_open == 1) { 246 10 256
1550 // если пришедший закрывающий тег не равен последнему то нужен анализ как закрыть предшественников
1551 246 ▶ if(tag_id != tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id != tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id) { 27 219 246
1552 27 int ti; long min_id = 0;
1553 63 ▶ for(ti = tree_curr->lindex; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tree_curr->lindex; ti >= 1; ti--) { 63 0 63
1554
1555 // если пришедший закрывающий тег является простым, но внутри его строится структура
1556 // такой так же закроется сразу же как пришло его закрытие, и не важно сколько ему подобных было открыто внутри его
1557 63 ▶ if(tags->extra[tag_id] == EXTRA_TAG_SIMPLE_TREE && tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tags->extra[tag_id] == EXTRA_TAG_SIMPLE_TREE && tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1) { 0 63 63
if(tags->extra[tag_id] == EXTRA_TAG_SIMPLE_TREE && tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1) { 0 0 0
1558 0 ▶ if(min_id == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(min_id == 0) { 0 0 0
1559 int oi;
1560 0 ▶ for(oi = 1; oi <= tree_curr->lindex; oi++) {
Branch: 1 branch
BranchTrueFalseTotal
for(oi = 1; oi <= tree_curr->lindex; oi++) { 0 0 0
1561 0 ▶ if(tree_curr->tree[ tree_curr->index[oi] ].tag_id == tag_id && tree_curr->tree[ tree_curr->index[oi] ].tag_stop == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[oi] ].tag_id == tag_id && tree_curr->tree[ tree_curr->index[oi] ].tag_stop == -1) { 0 0 0
if(tree_curr->tree[ tree_curr->index[oi] ].tag_id == tag_id && tree_curr->tree[ tree_curr->index[oi] ].tag_stop == -1) { 0 0 0
1562 0 min_id = tree_curr->tree[ tree_curr->index[oi] ].id;
1563 0 break;
1564 }
1565 }
1566 }
1567
1568 0 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = my[ my_buff ].start_otag - 2;
1569 0 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
1570
1571 // сохраняем общее количество тегов
1572 0 tree_curr->tree[ tree_curr->index[ti - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ti] ].count_element_in;
1573
1574 int si;
1575 0 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 0 0 0
1576 0 tree_curr->tree[ tree_curr->index[ti - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ti] ].counts_in[ si ];
1577 }
1578
1579 0 ▶ if(min_id == tree_curr->tree[ tree_curr->index[ti] ].id)
Branch: 1 branch
BranchTrueFalseTotal
if(min_id == tree_curr->tree[ tree_curr->index[ti] ].id) 0 0 0
1580 0 tree_curr->lindex--;
1581 0 break;
1582 }
1583
1584 // проверка на приоритет тегов
1585 63 ▶ if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[tag_id]){
Branch: 1 branch
BranchTrueFalseTotal
if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] > tags->priority[tag_id]){ 0 63 63
1586 0 break;
1587 }
1588 else
1589 63 ▶ if(tag_id == tree_curr->tree[ tree_curr->index[ti] ].tag_id && tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tag_id == tree_curr->tree[ tree_curr->index[ti] ].tag_id && tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1) { 27 36 63
if(tag_id == tree_curr->tree[ tree_curr->index[ti] ].tag_id && tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1) { 27 0 27
1590 27 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = my[ my_buff ].start_otag - 2;
1591 27 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
1592
1593 // сохраняем общее количество тегов
1594 27 tree_curr->tree[ tree_curr->index[ti - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ti] ].count_element_in;
1595
1596 int si;
1597 135 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 108 27 135
1598 108 tree_curr->tree[ tree_curr->index[ti - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ti] ].counts_in[ si ];
1599 }
1600
1601 27 tree_curr->lindex--;
1602 27 break;
1603 }
1604 36 ▶ else if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1){
Branch: 1 branch
BranchTrueFalseTotal
else if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop == -1){ 36 0 36
1605 36 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = my[ my_buff ].start_otag - 2;
1606 36 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
1607 }
1608
1609 36 ▶ if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] <= tags->priority[tag_id]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->priority[ tree_curr->tree[ tree_curr->index[ti] ].tag_id ] <= tags->priority[tag_id]) { 36 0 36
1610 36 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = my[ my_buff ].start_otag - 2;
1611 36 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
1612 }
1613
1614 // сохраняем общее количество тегов
1615 36 tree_curr->tree[ tree_curr->index[ti - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ti] ].count_element_in;
1616
1617 int si;
1618 180 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 144 36 180
1619 144 tree_curr->tree[ tree_curr->index[ti - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ti] ].counts_in[ si ];
1620 }
1621
1622 // уменьшаем уровень дерева
1623 36 tree_curr->lindex--;
1624 }
1625 } else {
1626 219 tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_body_stop = my[ my_buff ].start_otag - 2;
1627 219 tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_stop = i - 1;
1628
1629 // сохраняем общее количество тегов
1630 219 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].count_element_in +=
1631 219 tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].count_element_in;
1632
1633 int si;
1634 1095 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 876 219 1095
1635 876 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].counts_in[ si ] +=
1636 876 tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].counts_in[ si ];
1637 }
1638
1639 // уменьшаем уровень дерева
1640 219 tree_curr->lindex--;
1641 }
1642 }
1643 }
1644
1645 // если мы в решетке, то есть идет изолированная обработка тега и он закрылся то переносим данные в родителя
1646 256 ▶ if(tree_curr->is_base == 0 && tree_curr->tree[1].tag_stop != -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->is_base == 0 && tree_curr->tree[1].tag_stop != -1) { 143 113 256
if(tree_curr->is_base == 0 && tree_curr->tree[1].tag_stop != -1) { 16 127 143
1647 16 long ie = close_this_jail(my_r, &tree_jail, tree_curr, i);
1648
1649 // устанавливаем как основной предыдущий элемент
1650 16 tree_jail.curr_element = ie;
1651 16 tree_curr = &tree_jail.elements[ie];
1652 }
1653
1654 // если мы на время возвращались к родителю и тег ради которого возвращались закрылся то переходим на уровень выше
1655 // if(tree_curr->last_element_id != -1 && tree_curr->tree[tree_curr->last_element_id].tag_stop != -1) {
1656 // tree_curr->last_element_id = -1;
1657 //
1658 // tree_jail.curr_element = tree_curr->next;
1659 // tree_curr->next = -1;
1660 // tree_curr = &tree_jail.elements[tree_jail.curr_element];
1661 // }
1662
1663 256 my_buff--;
1664 }
1665 else {
1666 // если тег сразу закрылся "<span>" то проверяем тут пропускать его или нет
1667 574 ▶ if(my[my_buff].stop_otag == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(my[my_buff].stop_otag == 0) { 569 5 574
1668 // если тег пустой и небыло данных об окончании
1669 569 my[my_buff].stop_otag = i - 2;
1670 }
1671
1672 574 int tag_id = cmp_tags(tags, html, &my[my_buff], 0);
1673
1674 574 ▶ if(tag_id == tag_id_doctype) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id == tag_id_doctype) { 0 574 574
1675 0 ▶ if(tree_curr->is_base == 1 && tree_curr->ltree == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->is_base == 1 && tree_curr->ltree == 0) { 0 0 0
if(tree_curr->is_base == 1 && tree_curr->ltree == 0) { 0 0 0
1676 0 add_to_tree(my_r, tree_curr, my_buff, i, tag_id_doctype);
1677
1678 long si;
1679 0 ▶ for(si = 2; si <= my_r->my[my_buff].lparams; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 2; si <= my_r->my[my_buff].lparams; si++) { 0 0 0
1680 0 free(my_r->my[my_buff].params[si].key);
1681 0 free(my_r->my[my_buff].params[si].value);
1682 }
1683
1684 0 ▶ if(my_r->my[my_buff].lparams > 1)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->my[my_buff].lparams > 1) 0 0 0
1685 0 my_r->my[my_buff].lparams = 1;
1686
1687 0 close_all_element_by_tag_id(my, tree_curr, tags, tag_id_doctype, my_buff, i);
1688 }
1689
1690 0 pos = 0;
1691 0 next_tag = 0;
1692 0 continue;
1693 }
1694
1695 574 ▶ if(tag_id == tag_id_html) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id == tag_id_html) { 4 570 574
1696 4 struct html_tree *tag_html = get_element_by_tag_id(my_r, tag_id_html, 0);
1697
1698 4 ▶ if(tag_html == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_html == NULL) { 4 0 4
1699 4 add_to_tree(my_r, tree_curr, -1, i, tag_id_html);
1700 4 tree_curr->tree[ tree_curr->ltree ].inc = 1;
1701 4 tag_html = get_element_by_tag_id(my_r, tag_id_html, 0);
1702 }
1703
1704 4 ▶ if(tag_html->my_id == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_html->my_id == -1) { 4 0 4
1705 4 tag_html->my_id = my_buff;
1706 }
1707 else {
1708 0 ▶ if(my[my_buff].lparams > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(my[my_buff].lparams > -1) { 0 0 0
1709 long lp;
1710 0 ▶ for(lp = 0; lp <= my[my_buff].lparams; lp++) {
Branch: 1 branch
BranchTrueFalseTotal
for(lp = 0; lp <= my[my_buff].lparams; lp++) { 0 0 0
1711 0 my[tag_html->my_id].lparams++;
1712
1713 0 ▶ if(my[tag_html->my_id].lparams >= my[tag_html->my_id].lparams_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(my[tag_html->my_id].lparams >= my[tag_html->my_id].lparams_size) { 0 0 0
1714 0 my[tag_html->my_id].lparams_size += 256;
1715 0 my[tag_html->my_id].params = (struct mem_params *)realloc(my[tag_html->my_id].params, sizeof(struct mem_params) * my[tag_html->my_id].lparams_size);
1716 }
1717
1718 0 my[tag_html->my_id].params[my[tag_html->my_id].lparams] = my[my_buff].params[lp];
1719 }
1720
1721 0 my[my_buff].lparams = -1;
1722 }
1723 }
1724
1725 4 pos = 0;
1726 4 next_tag = 0;
1727 4 continue;
1728 }
1729 570 ▶ else if(tag_id == tag_id_head && head_is_open == 1) {
Branch: 2 branches
BranchTrueFalseTotal
else if(tag_id == tag_id_head && head_is_open == 1) { 0 570 570
else if(tag_id == tag_id_head && head_is_open == 1) { 0 0 0
1730 0 pos = 0;
1731 0 next_tag = 0;
1732 0 continue;
1733 }
1734 570 ▶ else if(tag_id == tag_id_body && body_is_open == 1) {
Branch: 2 branches
BranchTrueFalseTotal
else if(tag_id == tag_id_body && body_is_open == 1) { 4 566 570
else if(tag_id == tag_id_body && body_is_open == 1) { 0 4 4
1735 0 struct html_tree *tag_html = get_element_by_tag_id(my_r, tag_id_body, 0);
1736
1737 0 ▶ if(tag_html->my_id == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_html->my_id == -1) { 0 0 0
1738 0 tag_html->my_id = my_buff;
1739 }
1740 else {
1741 0 ▶ if(my[my_buff].lparams > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(my[my_buff].lparams > -1) { 0 0 0
1742 long lp;
1743 0 ▶ for(lp = 0; lp <= my[my_buff].lparams; lp++) {
Branch: 1 branch
BranchTrueFalseTotal
for(lp = 0; lp <= my[my_buff].lparams; lp++) { 0 0 0
1744 0 my[tag_html->my_id].lparams++;
1745
1746 0 ▶ if(my[tag_html->my_id].lparams >= my[tag_html->my_id].lparams_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(my[tag_html->my_id].lparams >= my[tag_html->my_id].lparams_size) { 0 0 0
1747 0 my[tag_html->my_id].lparams_size += 256;
1748 0 my[tag_html->my_id].params = (struct mem_params *)realloc(my[tag_html->my_id].params, sizeof(struct mem_params) * my[tag_html->my_id].lparams_size);
1749 }
1750
1751 0 my[tag_html->my_id].params[my[tag_html->my_id].lparams] = my[my_buff].params[lp];
1752 }
1753
1754 0 my[my_buff].lparams = -1;
1755 }
1756 }
1757
1758 0 pos = 0;
1759 0 next_tag = 0;
1760 0 continue;
1761 }
1762
1763 570 int body_check = 1;
1764
1765 570 ▶ if(head_is_open == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(head_is_open == 0) { 570 0 570
1766 570 int is_in = check_family_exists(tags_family, tag_id, tag_id_head);
1767 570 ▶ if(is_in == 1 && tag_id != tag_id_head) {
Branch: 2 branches
BranchTrueFalseTotal
if(is_in == 1 && tag_id != tag_id_head) { 0 570 570
if(is_in == 1 && tag_id != tag_id_head) { 0 0 0
1768 0 struct html_tree *tag_html = get_element_by_tag_id(my_r, tag_id_html, 0);
1769 0 ▶ if(tag_html == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_html == NULL) { 0 0 0
1770 0 add_to_tree(my_r, tree_curr, -1, 0, tag_id_html);
1771 }
1772
1773 0 struct html_tree *tag_head = get_element_by_tag_id(my_r, tag_id_head, 0);
1774 0 ▶ if(tag_head == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_head == NULL) { 0 0 0
1775 0 add_to_tree(my_r, tree_curr, -1, 0, tag_id_head);
1776 0 tree_curr->tree[ tree_curr->ltree ].inc = 2;
1777 }
1778
1779 0 head_is_open = 1;
1780 0 body_check = 0;
1781 }
1782 570 ▶ else if(is_in == 0 && body_is_open == 0) {
Branch: 2 branches
BranchTrueFalseTotal
else if(is_in == 0 && body_is_open == 0) { 570 0 570
else if(is_in == 0 && body_is_open == 0) { 33 537 570
1783 33 struct html_tree *tag_html = get_element_by_tag_id(my_r, tag_id_html, 0);
1784 33 ▶ if(tag_html == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_html == NULL) { 29 4 33
1785 29 add_to_tree(my_r, tree_curr, -1, 0, tag_id_html);
1786 }
1787 }
1788
1789 570 ▶ if(tag_id == tag_id_head) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id == tag_id_head) { 0 570 570
1790 0 head_is_open = 1;
1791 0 body_check = 0;
1792 }
1793 }
1794
1795 570 ▶ if(body_is_open == 0 && body_check == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if(body_is_open == 0 && body_check == 1) { 33 537 570
if(body_is_open == 0 && body_check == 1) { 33 0 33
1796 33 int is_in = check_family_exists(tags_family, tag_id, tag_id_head);
1797 33 ▶ if(is_in == 0 && tag_id != tag_id_body) {
Branch: 2 branches
BranchTrueFalseTotal
if(is_in == 0 && tag_id != tag_id_body) { 33 0 33
if(is_in == 0 && tag_id != tag_id_body) { 29 4 33
1798 29 struct html_tree *tag_html = get_element_by_tag_id(my_r, tag_id_html, 0);
1799 29 ▶ if(tag_html == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_html == NULL) { 0 29 29
1800 0 add_to_tree(my_r, tree_curr, -1, 0, tag_id_html);
1801 }
1802
1803 29 struct html_tree *tag_head = get_element_by_tag_id(my_r, tag_id_head, 0);
1804 29 ▶ if(tag_head == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_head == NULL) { 29 0 29
1805 29 add_to_tree(my_r, tree_curr, -1, 0, tag_id_head);
1806 29 tree_curr->tree[ tree_curr->ltree ].inc = 2;
1807 }
1808
1809 29 close_all_element_by_tag_id(my, tree_curr, tags, tag_id_head, my_buff, i);
1810 29 add_to_tree(my_r, tree_curr, -1, 0, tag_id_body);
1811 //tree_curr->tree[ tree_curr->ltree ].inc = 2;
1812
1813 29 body_is_open = 1;
1814 }
1815 4 ▶ else if(is_in == 0) {
Branch: 1 branch
BranchTrueFalseTotal
else if(is_in == 0) { 4 0 4
1816 4 struct html_tree *tag_html = get_element_by_tag_id(my_r, tag_id_html, 0);
1817 4 ▶ if(tag_html == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_html == NULL) { 0 4 4
1818 0 add_to_tree(my_r, tree_curr, -1, 0, tag_id_html);
1819 }
1820
1821 4 struct html_tree *tag_head = get_element_by_tag_id(my_r, tag_id_head, 0);
1822 4 ▶ if(tag_head == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_head == NULL) { 4 0 4
1823 4 add_to_tree(my_r, tree_curr, -1, 0, tag_id_head);
1824 4 tree_curr->tree[ tree_curr->ltree ].inc = 2;
1825 }
1826 }
1827
1828 33 ▶ if(tag_id == tag_id_body) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id == tag_id_body) { 4 29 33
1829 4 body_is_open = 1;
1830 }
1831 }
1832
1833 // TYPE_TAG_SIMPLE
1834 570 ▶ if(tree_curr->ltree > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->ltree > 0) { 570 0 570
1835 570 if(
1836 570 ▶ tags->extra[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ] == EXTRA_TAG_SIMPLE &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ] == EXTRA_TAG_SIMPLE && 0 570 570
1837 0 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_stop == -1
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_stop == -1 0 0 0
1838 ){
1839 0 pos = 0;
1840 0 next_tag = 0;
1841
1842 0 continue;
1843 }
1844 }
1845
1846 570 ▶ if(tree_curr->next != -1 && tree_curr->last_element_id != -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->next != -1 && tree_curr->last_element_id != -1) { 190 380 570
if(tree_curr->next != -1 && tree_curr->last_element_id != -1) { 190 0 190
1847 190 ▶ if(tags->family[tag_id] == FAMILY_TABLE) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->family[tag_id] == FAMILY_TABLE) { 101 89 190
1848 101 close_all_element_with_id(my, tree_curr, my_buff, i);
1849
1850 101 tree_curr->last_element_id = -1;
1851
1852 101 tree_jail.curr_element = tree_curr->next;
1853 101 tree_curr->next = -1;
1854 101 tree_curr = &tree_jail.elements[tree_jail.curr_element];
1855 }
1856 }
1857
1858 570 ▶ if(tree_curr->is_base == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 0) { 307 263 570
1859 // проверка на расположение пришедшего элемента, если он не внутри тега TD ил TH то переносим её на уровень ниже
1860 307 ▶ if(tree_jail.family == FAMILY_TABLE) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail.family == FAMILY_TABLE) { 307 0 307
1861 307 if(
1862 307 ▶ tags->family[tag_id] != FAMILY_TABLE &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[tag_id] != FAMILY_TABLE && 172 135 307
1863 172 ▶ tags->family[tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id] == FAMILY_TABLE &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id] == FAMILY_TABLE && 170 2 172
1864 170 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td &&
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td && 167 3 170
1865 167 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th 167 0 167
1866 ){
1867 167 long next_element = tree_jail.curr_element;
1868
1869 167 tree_jail.curr_element = tree_curr->prev;
1870 167 tree_curr = &tree_jail.elements[tree_jail.curr_element];
1871 167 tree_curr->last_element_id = tree_curr->ltree + 1;
1872 167 tree_curr->next = next_element;
1873 }
1874 }
1875 }
1876
1877 // отлавливаем таблицу, если тег является таблицей то создаем новый изолированный уровень для ее обработки
1878 570 ▶ if(tag_id_table == tag_id) {
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id_table == tag_id) { 18 552 570
1879 // проверка на расположение таблицы, если она не внутри тега TD ил TH то переносим её на уровень ниже
1880 18 if(
1881 18 ▶ tree_curr->is_base == 0 &&
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->is_base == 0 && 5 13 18
1882 5 ▶ tags->family[tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id] == FAMILY_TABLE &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id] == FAMILY_TABLE && 3 2 5
1883 3 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td &&
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td && 2 1 3
1884 2 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th 2 0 2
1885 ) {
1886 2 long ie = close_this_jail(my_r, &tree_jail, tree_curr, i);
1887
1888 2 tree_jail.curr_element = ie;
1889 2 tree_curr = &tree_jail.elements[ie];
1890 }
1891
1892 18 long prev_element = tree_jail.curr_element;
1893
1894 18 tree_jail.lelements++;
1895 18 tree_jail.family = FAMILY_TABLE;
1896
1897 18 tree_jail.curr_element = tree_jail.lelements;
1898
1899 18 ▶ if(tree_jail.lelements == tree_jail.lelements_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail.lelements == tree_jail.lelements_size) { 0 18 18
1900 0 tree_jail.lelements_size += 1024;
1901 0 tree_jail.elements = (struct elements*)realloc(tree_jail.elements, tree_jail.lelements_size);
1902 }
1903
1904 18 tree_curr = &tree_jail.elements[tree_jail.lelements];
1905
1906 // для каждой новой клетки создаем root эллемент
1907
1908 18 tree_curr->lindex = 0;
1909 18 tree_curr->ltree = 0;
1910
1911 18 tree_curr->lindex_size = 1024;
1912 18 tree_curr->index = (long *)malloc(sizeof(long) * tree_curr->lindex_size);
1913
1914 18 tree_curr->ltree_size = 1024 * 10;
1915 18 tree_curr->tree = (struct html_tree *)malloc(sizeof(struct html_tree) * tree_curr->ltree_size);
1916
1917 18 tree_curr->count = -1;
1918 18 tree_curr->is_base = 0;
1919
1920 18 tree_curr->tree[tree_curr->ltree].id = 0;
1921 18 tree_curr->tree[tree_curr->ltree].tag_id = -1;
1922 18 tree_curr->tree[tree_curr->ltree].my_id = -1;
1923 18 tree_curr->tree[tree_curr->ltree].tag_body_start = 0;
1924 18 tree_curr->tree[tree_curr->ltree].tag_body_stop = -1;
1925 18 tree_curr->tree[tree_curr->ltree].tag_start = 0;
1926 18 tree_curr->tree[tree_curr->ltree].tag_stop = -1;
1927 18 tree_curr->tree[tree_curr->ltree].count_element = 0;
1928 18 tree_curr->tree[tree_curr->ltree].count_element_in = 0;
1929 18 tree_curr->tree[tree_curr->ltree].count_word = 0;
1930
1931 18 memset(tree_curr->tree[tree_curr->ltree].counts, 0, AI_BUFF);
1932 18 memset(tree_curr->tree[tree_curr->ltree].counts_in, 0, AI_BUFF);
1933
1934 18 tree_curr->index[tree_curr->lindex] = tree_curr->ltree;
1935 18 tree_curr->tree[tree_curr->ltree].inc = tree_curr->lindex;
1936
1937 18 tree_curr->prev = prev_element;
1938 18 tree_curr->next = -1;
1939 18 tree_curr->last_element_id = -1;
1940 }
1941
1942 // если пришел элемент таблицы, но таблица не была открыта то забираем из него текст, а элемент пропускаем
1943 570 ▶ if(tags->family[tag_id] == FAMILY_TABLE) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->family[tag_id] == FAMILY_TABLE) { 148 422 570
1944 148 ▶ if(tree_jail.curr_element == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail.curr_element == 0) { 0 148 148
1945 0 pos = 0;
1946 0 next_tag = 0;
1947 0 continue;
1948 }
1949 }
1950
1951 570 tree_curr->ltree++;
1952
1953 570 ▶ if(tree_curr->is_base == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 1) { 415 155 570
1954 415 tags->index.tag_count[tag_id]++;
1955 415 ▶ if(tags->index.tag_count[tag_id] >= tags->index.tag_csize[tag_id]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->index.tag_count[tag_id] >= tags->index.tag_csize[tag_id]) { 0 415 415
1956 0 tags->index.tag_csize[tag_id] += 128;
1957 0 tags->index.tag_id[tag_id] = (long *)realloc(tags->index.tag_id[tag_id], sizeof(long) * tags->index.tag_csize[tag_id]);
1958 }
1959
1960 415 tags->index.tag_id[tag_id][ tags->index.tag_count[tag_id] ] = tree_curr->ltree;
1961 }
1962
1963 570 ▶ if(tree_curr->ltree >= tree_curr->ltree_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->ltree >= tree_curr->ltree_size) { 0 570 570
1964 0 tree_curr->ltree_size += 1024;
1965 0 tree_curr->tree = (struct html_tree *)realloc(tree_curr->tree, sizeof(struct html_tree) * tree_curr->ltree_size);
1966
1967 0 ▶ if(tree_curr->is_base == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 1) 0 0 0
1968 0 my_r->list = tree_curr->tree;
1969 }
1970
1971 570 tree_curr->tree[tree_curr->ltree].id = tree_curr->ltree;
1972 570 tree_curr->tree[tree_curr->ltree].tag_id = tag_id;
1973 570 tree_curr->tree[tree_curr->ltree].my_id = my_buff;
1974 570 tree_curr->tree[tree_curr->ltree].tag_body_start = i;
1975 570 tree_curr->tree[tree_curr->ltree].tag_body_stop = -1;
1976 570 tree_curr->tree[tree_curr->ltree].tag_start = my[my_buff].start_otag - 1;
1977 570 tree_curr->tree[tree_curr->ltree].tag_stop = -1;
1978 570 tree_curr->tree[tree_curr->ltree].count_element = 0;
1979 570 tree_curr->tree[tree_curr->ltree].count_element_in = 0;
1980 570 tree_curr->tree[tree_curr->ltree].count_word = 0;
1981
1982 570 memset(tree_curr->tree[tree_curr->ltree].counts, 0, AI_BUFF);
1983 570 memset(tree_curr->tree[tree_curr->ltree].counts_in, 0, AI_BUFF);
1984
1985 570 ▶ if(tree_curr->ltree > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->ltree > 0) { 570 0 570
1986 570 int ti, res = 0; int tag_ool = tree_curr->lindex;
1987 1256 ▶ for(ti = tag_ool; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tag_ool; ti >= 1; ti--) { 1016 240 1256
1988 1016 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){ 0 1016 1016
1989 0 continue;
1990 }
1991
1992 1016 res = check_open_tag(my_r, tree_curr, ti, tag_id);
1993
1994 1016 ▶ if(res == 1 || (tags->option[tree_curr->tree[ tree_curr->index[ti] ].tag_id] == OPTION_CLEAN_TAGS && tags->option[tag_id] == OPTION_CLEAN_TAGS))
Branch: 3 branches
BranchTrueFalseTotal
if(res == 1 || (tags->option[tree_curr->tree[ tree_curr->index[ti] ].tag_id] == OPTION_CLEAN_TAGS && tags->option[tag_id] == OPTION_CLEAN_TAGS)) 872 144 1016
if(res == 1 || (tags->option[tree_curr->tree[ tree_curr->index[ti] ].tag_id] == OPTION_CLEAN_TAGS && tags->option[tag_id] == OPTION_CLEAN_TAGS)) 3 869 872
if(res == 1 || (tags->option[tree_curr->tree[ tree_curr->index[ti] ].tag_id] == OPTION_CLEAN_TAGS && tags->option[tag_id] == OPTION_CLEAN_TAGS)) 1 2 3
1995 145 {
1996 145 int ri; int tag_oole = tree_curr->lindex;
1997 159 ▶ for(ri = tag_oole; ri > ti; ri--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ri = tag_oole; ri > ti; ri--) { 14 145 159
1998 14 ▶ if(tree_curr->tree[ tree_curr->index[ri] ].tag_body_stop != -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ri] ].tag_body_stop != -1){ 0 14 14
1999 0 continue;
2000 }
2001 // сохраняем общее количество тегов
2002 14 tree_curr->tree[ tree_curr->index[ri - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ri] ].count_element_in;
2003
2004 int si;
2005 70 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 56 14 70
2006 56 tree_curr->tree[ tree_curr->index[ri - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ri] ].counts_in[ si ];
2007 }
2008
2009 14 tree_curr->tree[ tree_curr->index[ri] ].tag_body_stop = my[ my_buff ].start_otag - 2;
2010 14 tree_curr->tree[ tree_curr->index[ri] ].tag_stop = i - 1;
2011 }
2012
2013 145 tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop = my[ my_buff ].start_otag - 2;
2014 145 tree_curr->tree[ tree_curr->index[ti] ].tag_stop = i - 1;
2015
2016 145 tree_curr->lindex = tree_curr->tree[ tree_curr->index[ti] ].inc - 1;
2017
2018 // сохраняем общее количество тегов
2019 145 tree_curr->tree[ tree_curr->index[ti - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ti] ].count_element_in;
2020
2021 int si;
2022 725 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 580 145 725
2023 580 tree_curr->tree[ tree_curr->index[ti - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ti] ].counts_in[ si ];
2024 }
2025 }
2026 871 ▶ else if(res == 2) {
Branch: 1 branch
BranchTrueFalseTotal
else if(res == 2) { 328 543 871
2027 328 break;
2028 }
2029
2030 688 ▶ if(res > OPTION_NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(res > OPTION_NULL) { 2 686 688
2031 2 break;
2032 }
2033 }
2034
2035 570 ▶ if(res > OPTION_NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(res > OPTION_NULL) { 2 568 570
2036 2 ▶ if(res == OPTION_CLEAN_TAGS) {
Branch: 1 branch
BranchTrueFalseTotal
if(res == OPTION_CLEAN_TAGS) { 2 0 2
2037 2 tree_curr->tree[tree_curr->ltree].id = -1;
2038 2 tree_curr->tree[tree_curr->ltree].tag_id = -1;
2039 2 tree_curr->tree[tree_curr->ltree].my_id = -1;
2040 2 tree_curr->tree[tree_curr->ltree].tag_body_start = -1;
2041 2 tree_curr->tree[tree_curr->ltree].tag_start = -1;
2042
2043 2 ▶ if(tree_curr->is_base == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 1) 2 0 2
2044 2 tags->index.tag_count[tag_id]--;
2045
2046 2 tree_curr->ltree--;
2047
2048 2 pos = 0;
2049 2 next_tag = 0;
2050 2 continue;
2051 }
2052 }
2053 }
2054
2055 568 tree_curr->lindex++;
2056
2057 568 ▶ if(tree_curr->lindex == tree_curr->lindex_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->lindex == tree_curr->lindex_size) { 0 568 568
2058 0 tree_curr->lindex_size += 1024;
2059 0 tree_curr->index = (long *)realloc(tree_curr->index, sizeof(long) * tree_curr->lindex_size);
2060 }
2061
2062 568 tree_curr->index[tree_curr->lindex] = tree_curr->ltree;
2063 568 tree_curr->tree[ tree_curr->ltree ].inc = tree_curr->lindex;
2064
2065 // собираем статистику для пред. эллементов
2066 568 ▶ if(tree_curr->lindex > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->lindex > 0) { 568 0 568
2067 568 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].count_element++;
2068 568 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].count_element_in++;
2069
2070 568 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].counts[ tags->ai[ tree_curr->tree[ tree_curr->ltree ].tag_id ] ]++;
2071 568 tree_curr->tree[ tree_curr->index[tree_curr->lindex - 1] ].counts_in[ tags->ai[ tree_curr->tree[ tree_curr->ltree ].tag_id ] ]++;
2072 }
2073
2074 // Одиночные теги, не требуют закрытия и потому мы закрываем их сразу
2075 568 ▶ if((tags->type[ tag_id ] == TYPE_TAG_ONE && tags->extra[ tag_id ] == 0) || tags->extra[ tag_id ] == EXTRA_TAG_CLOSE_NOW) {
Branch: 3 branches
BranchTrueFalseTotal
if((tags->type[ tag_id ] == TYPE_TAG_ONE && tags->extra[ tag_id ] == 0) || tags->extra[ tag_id ] == EXTRA_TAG_CLOSE_NOW) { 1 567 568
if((tags->type[ tag_id ] == TYPE_TAG_ONE && tags->extra[ tag_id ] == 0) || tags->extra[ tag_id ] == EXTRA_TAG_CLOSE_NOW) { 0 1 1
if((tags->type[ tag_id ] == TYPE_TAG_ONE && tags->extra[ tag_id ] == 0) || tags->extra[ tag_id ] == EXTRA_TAG_CLOSE_NOW) { 0 567 567
2076 1 tree_curr->tree[ tree_curr->ltree ].tag_body_stop = tree_curr->tree[ tree_curr->ltree ].tag_body_start;
2077 1 tree_curr->tree[ tree_curr->ltree ].tag_stop = i - 1;
2078 1 tree_curr->lindex--;
2079 }
2080
2081 // если текущий тег евляется табличным (из семейства таблиц) то смотрим и востанавливаем его структуру
2082 568 ▶ if(tags->family[tag_id] == FAMILY_TABLE) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->family[tag_id] == FAMILY_TABLE) { 148 420 568
2083 148 ▶ if(tree_jail.curr_element != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail.curr_element != 0) { 148 0 148
2084 148 check_struct_level_up(my_r, tree_curr, my_buff, i, tag_id);
2085 }
2086 } else {
2087 420 ▶ if(tree_jail.curr_element != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail.curr_element != 0) { 7 413 420
2088 7 check_struct_level_down(my_r, tree_curr, my_buff, i, tag_id);
2089 }
2090 }
2091
2092 568 ▶ if(tree_curr->is_base == 0 && tree_curr->tree[1].tag_stop != -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->is_base == 0 && tree_curr->tree[1].tag_stop != -1) { 155 413 568
if(tree_curr->is_base == 0 && tree_curr->tree[1].tag_stop != -1) { 0 155 155
2093 0 long ie = close_this_jail(my_r, &tree_jail, tree_curr, i);
2094
2095 0 tree_jail.curr_element = ie;
2096 0 tree_curr = &tree_jail.elements[ie];
2097 }
2098
2099 // если текущая решетка была вызвана для добавления не нужных данных из последующей, и данные эти закрыты то возвращаемся к ней
2100 // if(tree_curr->last_element_id != -1 && tree_curr->tree[tree_curr->last_element_id].tag_stop != -1) {
2101 // tree_curr->last_element_id = -1;
2102 //
2103 // tree_jail.curr_element = tree_curr->next;
2104 // tree_curr->next = -1;
2105 //
2106 // tree_curr = &tree_jail.elements[tree_jail.curr_element];
2107 // }
2108 }
2109
2110 824 pos = 0;
2111 824 next_tag = 0;
2112
2113 824 continue;
2114 }
2115
2116 5411 switch (pos) {
2117 2762 case 0:
2118 2762 ▶ if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) {
Branch: 7 branches
BranchTrueFalseTotal
if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) { 838 1924 2762
if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) { 574 264 838
if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) { 0 574 574
if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) { 0 264 264
if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) { 0 0 0
if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) { 0 264 264
if(nc == '<' && ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || html[i] == '/' || html[i] == '!')) { 0 0 0
2119 838 is_open_key = 1;
2120
2121 838 ▶ if(tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != -1 &&
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != -1 && 805 33 838
2122 805 ▶ tags->extra[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ] == EXTRA_TAG_SIMPLE &&
Branch: 1 branch
BranchTrueFalseTotal
tags->extra[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ] == EXTRA_TAG_SIMPLE && 0 805 805
2123 0 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_stop == -1
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_stop == -1 0 0 0
2124 ) {
2125 0 ▶ if(html[i] == '!'){
Branch: 1 branch
BranchTrueFalseTotal
if(html[i] == '!'){ 0 0 0
2126 0 ▶ if(html[i+1] == '-' && html[i+2] == '-') {
Branch: 2 branches
BranchTrueFalseTotal
if(html[i+1] == '-' && html[i+2] == '-') { 0 0 0
if(html[i+1] == '-' && html[i+2] == '-') { 0 0 0
2127 0 is_comment = 1;
2128 } else {
2129 0 is_comment = 2;
2130 }
2131
2132 0 pos = 6;
2133 0 break;
2134 }
2135
2136 0 int tl = 0, is_on = 1; long tu = 0;
2137 0 ▶ while (tags->name[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ][++tl]) {
Branch: 1 branch
BranchTrueFalseTotal
while (tags->name[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ][++tl]) { 0 0 0
2138 0 tu = tl + i + 1;
2139 0 ▶ if(tags->name[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ][tl] != html[tu]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->name[ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id ][tl] != html[tu]) { 0 0 0
2140 0 is_on = 0;
2141 0 break;
2142 }
2143 0 ▶ else if(html[tu] == '\0') {
Branch: 1 branch
BranchTrueFalseTotal
else if(html[tu] == '\0') { 0 0 0
2144 0 is_on = 0;
2145 0 break;
2146 }
2147 }
2148
2149 0 ▶ if(is_on == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_on == 0) { 0 0 0
2150 0 break;
2151 }
2152 }
2153
2154 838 ▶ if(tree_curr->tree[ tree_curr->ltree ].tag_id == DEFAULT_TAG_ID && tree_curr->tree[ tree_curr->ltree ].tag_body_stop == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->ltree ].tag_id == DEFAULT_TAG_ID && tree_curr->tree[ tree_curr->ltree ].tag_body_stop == -1) { 572 266 838
if(tree_curr->tree[ tree_curr->ltree ].tag_id == DEFAULT_TAG_ID && tree_curr->tree[ tree_curr->ltree ].tag_body_stop == -1) { 338 234 572
2155 338 tree_curr->tree[ tree_curr->ltree ].tag_body_stop = i - 2;
2156 338 tree_curr->tree[ tree_curr->ltree ].tag_stop = tree_curr->tree[ tree_curr->ltree ].tag_body_stop;
2157
2158 // если текущая решетка была вызвана для добавления не нужных данных из последующей, и данные эти закрыты то возвращаемся к ней
2159 // это нужно для того, что бы правельно закрылся текстовый элемент (таг_ид 0) если он оказался между табличными тегами, но не в TD или TH
2160 // if(tree_curr->last_element_id != -1 && tree_curr->tree[tree_curr->last_element_id].tag_stop != -1) {
2161 // tree_curr->last_element_id = -1;
2162 //
2163 // tree_jail.curr_element = tree_curr->next;
2164 // tree_curr->next = -1;
2165 //
2166 // tree_curr = &tree_jail.elements[tree_jail.curr_element];
2167 // }
2168 }
2169
2170 838 text_position = -1;
2171
2172 838 ▶ if(html[i] == '!'){
Branch: 1 branch
BranchTrueFalseTotal
if(html[i] == '!'){ 0 838 838
2173 0 ▶ if(html[i+1] == '-' && html[i+2] == '-') {
Branch: 2 branches
BranchTrueFalseTotal
if(html[i+1] == '-' && html[i+2] == '-') { 0 0 0
if(html[i+1] == '-' && html[i+2] == '-') { 0 0 0
2174 0 is_comment = 1;
2175 } else {
2176 0 is_comment = 2;
2177 }
2178
2179 0 pos = 6;
2180 0 break;
2181 }
2182
2183 838 my_buff++;
2184 838 my_real_buff = my_buff;
2185
2186 838 ▶ if(count_tag != my_buff) {
Branch: 1 branch
BranchTrueFalseTotal
if(count_tag != my_buff) { 599 239 838
2187 599 count_tag = my_buff;
2188
2189 599 ▶ if(my_buff_size <= my_buff) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_buff_size <= my_buff) { 0 599 599
2190 0 my_buff_size += 1024;
2191 0 my = (struct mem_tag *)realloc(my, sizeof(struct mem_tag) * my_buff_size);
2192 0 my_r->my = my;
2193 }
2194
2195 599 my[my_buff].lparams_size = 256;
2196 599 my[my_buff].params = (struct mem_params *)malloc(sizeof(struct mem_params) * my[my_buff].lparams_size);
2197 }
2198
2199 838 my[my_buff].stop_otag = 0;
2200
2201 838 my[my_buff].qo = '\0';
2202 838 my[my_buff].qol = 0;
2203
2204 838 my[my_buff].lparams = -1;
2205
2206 838 next_tag = 0;
2207
2208 838 pos = 1;
2209 838 my[my_buff].start_otag = i;
2210
2211 838 spl_word = 0;
2212 }
2213 else {
2214 1924 ▶ if(text_position == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(text_position == -1) 378 1546 1924
2215 378 text_position = i - 1;
2216
2217 1924 ▶ if(nc != ' ' && (nc < '\x09' || nc > '\x0D') && (tree_curr->tree[ tree_curr->ltree ].tag_id != DEFAULT_TAG_ID ||
Branch: 4 branches
BranchTrueFalseTotal
if(nc != ' ' && (nc < '\x09' || nc > '\x0D') && (tree_curr->tree[ tree_curr->ltree ].tag_id != DEFAULT_TAG_ID || 1639 285 1924
if(nc != ' ' && (nc < '\x09' || nc > '\x0D') && (tree_curr->tree[ tree_curr->ltree ].tag_id != DEFAULT_TAG_ID || 1639 0 1639
if(nc != ' ' && (nc < '\x09' || nc > '\x0D') && (tree_curr->tree[ tree_curr->ltree ].tag_id != DEFAULT_TAG_ID || 1611 28 1639
if(nc != ' ' && (nc < '\x09' || nc > '\x0D') && (tree_curr->tree[ tree_curr->ltree ].tag_id != DEFAULT_TAG_ID || 1270 341 1611
2218 1270 ▶ (tree_curr->tree[ tree_curr->ltree ].tag_id == DEFAULT_TAG_ID && tree_curr->tree[ tree_curr->ltree ].tag_body_stop != -1)
Branch: 2 branches
BranchTrueFalseTotal
(tree_curr->tree[ tree_curr->ltree ].tag_id == DEFAULT_TAG_ID && tree_curr->tree[ tree_curr->ltree ].tag_body_stop != -1) 1270 0 1270
(tree_curr->tree[ tree_curr->ltree ].tag_id == DEFAULT_TAG_ID && tree_curr->tree[ tree_curr->ltree ].tag_body_stop != -1) 5 1265 1270
2219 )) {
2220 346 int inc_offset = 0;
2221
2222 // если у нас текстовый элемент и он находится не в TD или TH то переносим его в родителя
2223 346 ▶ if(tree_curr->is_base == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 0) { 65 281 346
2224 65 ▶ if(tree_jail.family == FAMILY_TABLE) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail.family == FAMILY_TABLE) { 65 0 65
2225 65 if(
2226 65 ▶ tags->family[tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id] == FAMILY_TABLE &&
Branch: 1 branch
BranchTrueFalseTotal
tags->family[tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id] == FAMILY_TABLE && 63 2 65
2227 63 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td &&
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td && 29 34 63
2228 29 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th 5 24 29
2229 ){
2230 5 long next_element = tree_jail.curr_element;
2231
2232 5 tree_jail.curr_element = tree_curr->prev;
2233 5 tree_curr = &tree_jail.elements[tree_jail.curr_element];
2234 5 tree_curr->last_element_id = tree_curr->ltree + 1;
2235 5 tree_curr->next = next_element;
2236
2237 5 ▶ if(tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td &&
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_td && 4 1 5
2238 4 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th &&
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != tag_id_th && 4 0 4
2239 4 ▶ tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != -1
Branch: 1 branch
BranchTrueFalseTotal
tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id != -1 4 0 4
2240 ){
2241 // проверка будет ли входит в последний элемент родителя этот изолированный тег
2242 int ti;
2243 4 int tag_ool = tree_jail.elements[tree_jail.curr_element].lindex;
2244 7 ▶ for(ti = tag_ool; ti >= 1; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tag_ool; ti >= 1; ti--) { 7 0 7
2245 7 ▶ if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[ tree_curr->index[ti] ].tag_body_stop != -1){ 0 7 7
2246 0 continue;
2247 }
2248
2249 7 ▶ if(check_open_tag(my_r, tree_curr, ti, tag_id_table) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(check_open_tag(my_r, tree_curr, ti, tag_id_table) == 1) { 3 4 7
2250 3 continue;
2251 }
2252
2253 4 break;
2254 }
2255
2256 4 inc_offset = tree_jail.elements[tree_jail.curr_element].tree[ tree_jail.elements[tree_jail.curr_element].index[ti] ].inc + 1;
2257 }
2258 }
2259 }
2260 }
2261
2262 346 ▶ if(body_is_open == 0 && tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id == tag_id_head) {
Branch: 2 branches
BranchTrueFalseTotal
if(body_is_open == 0 && tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id == tag_id_head) { 0 346 346
if(body_is_open == 0 && tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].tag_id == tag_id_head) { 0 0 0
2263 0 close_all_element_by_tag_id(my, tree_curr, tags, tag_id_head, my_buff, i);
2264 0 add_to_tree(my_r, tree_curr, -1, 0, tag_id_body);
2265
2266 0 body_is_open = 1;
2267 }
2268
2269 346 tree_curr->ltree++;
2270
2271 346 ▶ if(tree_curr->ltree >= tree_curr->ltree_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->ltree >= tree_curr->ltree_size) { 0 346 346
2272 0 tree_curr->ltree_size += 1024;
2273 0 tree_curr->tree = (struct html_tree *)realloc(tree_curr->tree, sizeof(struct html_tree) * tree_curr->ltree_size);
2274
2275 0 ▶ if(tree_curr->is_base == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 1) 0 0 0
2276 0 my_r->list = tree_curr->tree;
2277 }
2278
2279 346 tree_curr->tree[tree_curr->ltree].id = tree_curr->ltree;
2280
2281 346 tree_curr->tree[tree_curr->ltree].tag_id = DEFAULT_TAG_ID;
2282 346 tree_curr->tree[tree_curr->ltree].my_id = -1;
2283
2284 346 tree_curr->tree[tree_curr->ltree].tag_body_start = text_position;
2285 346 tree_curr->tree[tree_curr->ltree].tag_body_stop = -1;
2286
2287 346 tree_curr->tree[tree_curr->ltree].tag_start = tree_curr->tree[ tree_curr->ltree ].tag_body_start;
2288 346 tree_curr->tree[tree_curr->ltree].tag_stop = -1;
2289
2290 346 tree_curr->tree[tree_curr->ltree].count_element = 0;
2291 346 tree_curr->tree[tree_curr->ltree].count_element_in = 0;
2292 346 tree_curr->tree[tree_curr->ltree].count_word = 0;
2293
2294 346 ▶ if(inc_offset == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(inc_offset == 0) { 342 4 346
2295 342 tree_curr->tree[ tree_curr->ltree ].inc = tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].inc + 1;
2296 }
2297 else {
2298 4 tree_curr->tree[ tree_curr->ltree ].inc = inc_offset;
2299 }
2300
2301 346 memset(tree_curr->tree[ tree_curr->ltree ].counts, 0, AI_BUFF);
2302 346 memset(tree_curr->tree[ tree_curr->ltree ].counts_in, 0, AI_BUFF);
2303 }
2304
2305 1924 ▶ if(spl_word == 0 && nc != ' ' && nc != '\n' && nc != '\t') {
Branch: 4 branches
BranchTrueFalseTotal
if(spl_word == 0 && nc != ' ' && nc != '\n' && nc != '\t') { 651 1273 1924
if(spl_word == 0 && nc != ' ' && nc != '\n' && nc != '\t') { 448 203 651
if(spl_word == 0 && nc != ' ' && nc != '\n' && nc != '\t') { 420 28 448
if(spl_word == 0 && nc != ' ' && nc != '\n' && nc != '\t') { 420 0 420
2306 420 tree_curr->tree[ tree_curr->index[tree_curr->lindex] ].count_word++;
2307 420 spl_word = 1;
2308 }
2309 1504 ▶ else if(nc == ' ' || nc == '\n' || nc == '\t'){
Branch: 3 branches
BranchTrueFalseTotal
else if(nc == ' ' || nc == '\n' || nc == '\t'){ 1219 285 1504
else if(nc == ' ' || nc == '\n' || nc == '\t'){ 1191 28 1219
else if(nc == ' ' || nc == '\n' || nc == '\t'){ 0 1191 1191
2310 313 spl_word = 0;
2311 }
2312 }
2313
2314 2762 break;
2315
2316 2427 case 1:
2317 2427 ▶ if(nc == ' ' || nc == '\t' || nc == '\n' || (my[my_buff].start_otag != i-1 && nc == '/')) {
Branch: 5 branches
BranchTrueFalseTotal
if(nc == ' ' || nc == '\t' || nc == '\n' || (my[my_buff].start_otag != i-1 && nc == '/')) { 2422 5 2427
if(nc == ' ' || nc == '\t' || nc == '\n' || (my[my_buff].start_otag != i-1 && nc == '/')) { 2422 0 2422
if(nc == ' ' || nc == '\t' || nc == '\n' || (my[my_buff].start_otag != i-1 && nc == '/')) { 2422 0 2422
if(nc == ' ' || nc == '\t' || nc == '\n' || (my[my_buff].start_otag != i-1 && nc == '/')) { 1584 838 2422
if(nc == ' ' || nc == '\t' || nc == '\n' || (my[my_buff].start_otag != i-1 && nc == '/')) { 0 1584 1584
2318 5 my[my_buff].stop_otag = i - 2;
2319
2320 // это закрывающий тег?
2321 5 ▶ if(html[ my[my_buff].start_otag ] == '/') {
Branch: 1 branch
BranchTrueFalseTotal
if(html[ my[my_buff].start_otag ] == '/') { 0 5 5
2322 0 pos = 6;
2323 0 break;
2324 }
2325
2326 5 pos = 2;
2327 }
2328
2329 2427 break;
2330
2331 24 case 2:
2332 24 ▶ if(nc == '/')
Branch: 1 branch
BranchTrueFalseTotal
if(nc == '/') 0 24 24
2333 0 break;
2334
2335 24 ▶ if( (nc != ' ' && nc != '\t' && nc != '\n' && nc != '=') || (nc == '=' && next_tag != my[my_buff].lparams) ) {
Branch: 6 branches
BranchTrueFalseTotal
if( (nc != ' ' && nc != '\t' && nc != '\n' && nc != '=') || (nc == '=' && next_tag != my[my_buff].lparams) ) { 24 0 24
if( (nc != ' ' && nc != '\t' && nc != '\n' && nc != '=') || (nc == '=' && next_tag != my[my_buff].lparams) ) { 24 0 24
if( (nc != ' ' && nc != '\t' && nc != '\n' && nc != '=') || (nc == '=' && next_tag != my[my_buff].lparams) ) { 24 0 24
if( (nc != ' ' && nc != '\t' && nc != '\n' && nc != '=') || (nc == '=' && next_tag != my[my_buff].lparams) ) { 5 19 24
if( (nc != ' ' && nc != '\t' && nc != '\n' && nc != '=') || (nc == '=' && next_tag != my[my_buff].lparams) ) { 5 0 5
if( (nc != ' ' && nc != '\t' && nc != '\n' && nc != '=') || (nc == '=' && next_tag != my[my_buff].lparams) ) { 0 5 5
2336 19 ▶ if(next_tag != my[my_buff].lparams) {
Branch: 1 branch
BranchTrueFalseTotal
if(next_tag != my[my_buff].lparams) { 5 14 19
2337 5 my[my_buff].lparams++;
2338
2339 5 ▶ if(my[my_buff].lparams >= my[my_buff].lparams_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(my[my_buff].lparams >= my[my_buff].lparams_size) { 0 5 5
2340 0 my[my_buff].lparams_size += 256;
2341 0 my[my_buff].params = (struct mem_params *)realloc(my[my_buff].params, sizeof(struct mem_params) * my[my_buff].lparams_size);
2342 }
2343
2344 5 my[my_buff].params[my[my_buff].lparams].lkey_size = 1024;
2345 5 my[my_buff].params[my[my_buff].lparams].lvalue_size = 1024;
2346 5 my[my_buff].params[my[my_buff].lparams].lkey = 0;
2347 5 my[my_buff].params[my[my_buff].lparams].lvalue = 0;
2348
2349 5 my[my_buff].params[my[my_buff].lparams].key = (char *)malloc(sizeof(char) * my[my_buff].params[my[my_buff].lparams].lkey_size);
2350 5 my[my_buff].params[my[my_buff].lparams].value = (char *)malloc(sizeof(char) * my[my_buff].params[my[my_buff].lparams].lvalue_size);
2351 }
2352
2353 19 ▶ if( my[my_buff].params[my[my_buff].lparams].lkey >= my[my_buff].params[my[my_buff].lparams].lkey_size ) {
Branch: 1 branch
BranchTrueFalseTotal
if( my[my_buff].params[my[my_buff].lparams].lkey >= my[my_buff].params[my[my_buff].lparams].lkey_size ) { 0 19 19
2354 0 my[my_buff].params[my[my_buff].lparams].lkey_size += 1024;
2355 0 my[my_buff].params[my[my_buff].lparams].key = (char *)realloc(my[my_buff].params[my[my_buff].lparams].key, my[my_buff].params[my[my_buff].lparams].lkey_size * sizeof(char));
2356 }
2357
2358 19 my[my_buff].params[my[my_buff].lparams].key[ my[my_buff].params[my[my_buff].lparams].lkey++ ] = tolower(nc);
2359 19 break;
2360 }
2361 5 ▶ else if(next_tag == my[my_buff].lparams && my[my_buff].params[my[my_buff].lparams].lkey != 0) {
Branch: 2 branches
BranchTrueFalseTotal
else if(next_tag == my[my_buff].lparams && my[my_buff].params[my[my_buff].lparams].lkey != 0) { 5 0 5
else if(next_tag == my[my_buff].lparams && my[my_buff].params[my[my_buff].lparams].lkey != 0) { 5 0 5
2362 5 ▶ if( my[my_buff].params[my[my_buff].lparams].lkey >= my[my_buff].params[my[my_buff].lparams].lkey_size ) {
Branch: 1 branch
BranchTrueFalseTotal
if( my[my_buff].params[my[my_buff].lparams].lkey >= my[my_buff].params[my[my_buff].lparams].lkey_size ) { 0 5 5
2363 0 my[my_buff].params[my[my_buff].lparams].lkey_size += 1024;
2364 0 my[my_buff].params[my[my_buff].lparams].key = (char *)realloc(my[my_buff].params[my[my_buff].lparams].key, my[my_buff].params[my[my_buff].lparams].lkey_size * sizeof(char));
2365 }
2366
2367 5 my[my_buff].params[my[my_buff].lparams].key[ my[my_buff].params[my[my_buff].lparams].lkey++ ] = '\0';
2368 5 pos = 3;
2369 }
2370
2371 case 3:
2372 5 ▶ if(nc == ' ' || nc == '\t' || nc == '\n' || nc == '/') {
Branch: 4 branches
BranchTrueFalseTotal
if(nc == ' ' || nc == '\t' || nc == '\n' || nc == '/') { 5 0 5
if(nc == ' ' || nc == '\t' || nc == '\n' || nc == '/') { 5 0 5
if(nc == ' ' || nc == '\t' || nc == '\n' || nc == '/') { 5 0 5
if(nc == ' ' || nc == '\t' || nc == '\n' || nc == '/') { 5 0 5
2373 break;
2374 }
2375 5 ▶ else if( nc == '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
else if( nc == '=' ) { 5 0 5
2376 5 pos = 4;
2377 } else {
2378 0 i--;
2379
2380 0 ▶ if(next_tag == my[my_buff].lparams){
Branch: 1 branch
BranchTrueFalseTotal
if(next_tag == my[my_buff].lparams){ 0 0 0
2381 0 my[my_buff].params[my[my_buff].lparams].value[0] = '\0';
2382 0 next_tag++;
2383 }
2384
2385 0 my[my_buff].qo = '\0';
2386 0 my[my_buff].qol = 0;
2387
2388 0 pos = 2;
2389 }
2390 5 break;
2391
2392 198 case 4:
2393 198 ▶ if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) {
Branch: 4 branches
BranchTrueFalseTotal
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 5 193 198
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 5 0 5
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 5 0 5
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 5 0 5
2394 break;
2395 }
2396 198 ▶ else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) {
Branch: 6 branches
BranchTrueFalseTotal
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 5 193 198
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 5 0 5
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 5 0 5
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 5 0 5
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 5 5
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 0 0
2397 0 my[my_buff].qo = ' ';
2398 }
2399
2400 // memset(buf, 0, sizeof(buf));
2401 198 ▶ if(my[my_buff].qo == '\0') {
Branch: 1 branch
BranchTrueFalseTotal
if(my[my_buff].qo == '\0') { 5 193 198
2402 5 ▶ if(nc == '"') {
Branch: 1 branch
BranchTrueFalseTotal
if(nc == '"') { 5 0 5
2403 5 my[my_buff].qo = '"';
2404 }
2405 0 ▶ else if(nc == '\'') {
Branch: 1 branch
BranchTrueFalseTotal
else if(nc == '\'') { 0 0 0
2406 0 my[my_buff].qo = '\'';
2407 }
2408 } else {
2409 193 ▶ if( my[my_buff].params[my[my_buff].lparams].lvalue >= my[my_buff].params[my[my_buff].lparams].lvalue_size ) {
Branch: 1 branch
BranchTrueFalseTotal
if( my[my_buff].params[my[my_buff].lparams].lvalue >= my[my_buff].params[my[my_buff].lparams].lvalue_size ) { 0 193 193
2410 0 my[my_buff].params[my[my_buff].lparams].lvalue_size += 1024;
2411 0 my[my_buff].params[my[my_buff].lparams].value = (char *)realloc(my[my_buff].params[my[my_buff].lparams].value, my[my_buff].params[my[my_buff].lparams].lvalue_size * sizeof(char));
2412 }
2413
2414 193 ▶ if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) {
Branch: 6 branches
BranchTrueFalseTotal
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 193 193
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 5 188 193
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 5 0 5
2415
2416 5 pos = 2;
2417 5 my[my_buff].params[my[my_buff].lparams].value[my[my_buff].params[my[my_buff].lparams].lvalue++] = '\0';
2418 5 my[my_buff].qo = '\0';
2419 5 my[my_buff].qol = 0;
2420
2421 5 next_tag++;
2422 5 break;
2423 } else {
2424 188 my[my_buff].params[my[my_buff].lparams].value[my[my_buff].params[my[my_buff].lparams].lvalue++] = nc;
2425 }
2426
2427 188 ▶ if(nc == '\\') {
Branch: 1 branch
BranchTrueFalseTotal
if(nc == '\\') { 0 188 188
2428 0 my[my_buff].qol++;
2429 } else {
2430 188 my[my_buff].qol = 0;
2431 }
2432 }
2433
2434 193 break;
2435
2436 0 case 5:
2437 0 ▶ if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) {
Branch: 4 branches
BranchTrueFalseTotal
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 0 0 0
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 0 0 0
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 0 0 0
if(my[my_buff].qo == '\0' && (nc == ' ' || nc == '\t' || nc == '\n')) { 0 0 0
2438 break;
2439 }
2440 0 ▶ else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) {
Branch: 6 branches
BranchTrueFalseTotal
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 0 0
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 0 0
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 0 0
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 0 0
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 0 0
else if(my[my_buff].qo == '\0' && (nc != ' ' && nc != '\t' && nc != '\n' && nc != '"' && nc != '\'')) { 0 0 0
2441 0 my[my_buff].qo = ' ';
2442 }
2443
2444 0 ▶ if(my[my_buff].qo == '\0') {
Branch: 1 branch
BranchTrueFalseTotal
if(my[my_buff].qo == '\0') { 0 0 0
2445 0 ▶ if(nc == '"') {
Branch: 1 branch
BranchTrueFalseTotal
if(nc == '"') { 0 0 0
2446 0 my[my_buff].qo = '"';
2447 }
2448 0 ▶ else if(nc == '\'') {
Branch: 1 branch
BranchTrueFalseTotal
else if(nc == '\'') { 0 0 0
2449 0 my[my_buff].qo = '\'';
2450 }
2451 } else {
2452 0 ▶ if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) {
Branch: 6 branches
BranchTrueFalseTotal
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
if((my[my_buff].qo == ' ' && (nc == ' ' || nc == '\t' || nc == '\n')) || (nc == my[my_buff].qo && (my[my_buff].qol % 2) == 0)) { 0 0 0
2453 0 my[my_buff].qo = '\0';
2454 0 my[my_buff].qol = 0;
2455 }
2456
2457 0 ▶ if(nc == '\\') {
Branch: 1 branch
BranchTrueFalseTotal
if(nc == '\\') { 0 0 0
2458 0 my[my_buff].qol++;
2459 } else {
2460 0 my[my_buff].qol = 0;
2461 }
2462 }
2463
2464 0 break;
2465 0 case 6:
2466 0 break;
2467 0 default:
2468 0 break;
2469 }
2470 }
2471
2472 while(1) {
2473 33 ▶ if(tree_curr->next != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->next != -1) { 0 33 33
2474 0 tree_jail.curr_element = tree_curr->next;
2475 0 tree_curr = &tree_jail.elements[tree_jail.curr_element];
2476 0 continue;
2477 }
2478
2479 33 break;
2480 }
2481
2482 33 ▶ if(tree_curr->is_base == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 0) { 0 33 33
2483 0 while(1){
2484 0 long ie = close_this_jail(my_r, &tree_jail, tree_curr, i);
2485
2486 0 tree_jail.curr_element = ie;
2487 0 tree_curr = &tree_jail.elements[ie];
2488
2489 0 ▶ if(tree_curr->is_base == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->is_base == 1) 0 0 0
2490 0 break;
2491 }
2492 }
2493
2494 33 int ti; long ni = i - 2;
2495 156 ▶ for(ti = tree_jail.elements[0].lindex; ti >= 0; ti--) {
Branch: 1 branch
BranchTrueFalseTotal
for(ti = tree_jail.elements[0].lindex; ti >= 0; ti--) { 123 33 156
2496 123 ▶ if(tree_jail.elements[0].tree[ tree_jail.elements[0].index[ti] ].tag_body_stop == -1){
Branch: 1 branch
BranchTrueFalseTotal
if(tree_jail.elements[0].tree[ tree_jail.elements[0].index[ti] ].tag_body_stop == -1){ 123 0 123
2497 123 tree_jail.elements[0].tree[ tree_jail.elements[0].index[ti] ].tag_body_stop = ni;
2498 123 tree_jail.elements[0].tree[ tree_jail.elements[0].index[ti] ].tag_stop = ni;
2499
2500 123 ▶ if(ti > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(ti > 0) { 90 33 123
2501 // сохраняем общее количество тегов
2502 90 tree_curr->tree[ tree_curr->index[ti - 1] ].count_element_in += tree_curr->tree[ tree_curr->index[ti] ].count_element_in;
2503
2504 int si;
2505 450 ▶ for(si = 0; si < AI_BUFF; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si < AI_BUFF; si++) { 360 90 450
2506 360 tree_curr->tree[ tree_curr->index[ti - 1] ].counts_in[ si ] += tree_curr->tree[ tree_curr->index[ti] ].counts_in[ si ];
2507 }
2508 }
2509 }
2510 }
2511
2512 long tl;
2513 41 ▶ for(tl = tree_curr->ltree; tl >= 0; tl--) {
Branch: 1 branch
BranchTrueFalseTotal
for(tl = tree_curr->ltree; tl >= 0; tl--) { 41 0 41
2514 41 ▶ if(tree_curr->tree[tl].tag_body_stop != -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tree_curr->tree[tl].tag_body_stop != -1) 33 8 41
2515 33 break;
2516
2517 8 tree_curr->tree[tl].tag_body_stop = ni;
2518 8 tree_curr->tree[tl].tag_stop = ni;
2519 }
2520
2521 33 my_r->count = tree_jail.elements[0].ltree;
2522 33 my_r->real_count = tree_jail.elements[0].ltree;
2523 33 my_r->my_count = my_buff;
2524 33 my_r->my_real_count = my_real_buff;
2525 33 my_r->cur_pos = 0;
2526 33 my_r->nco_pos = 0;
2527
2528 33 tree_curr = NULL;
2529
2530 33 free(tree_jail.elements[0].index);
2531
2532 51 ▶ for(tl = 1; tl <= tree_jail.lelements; tl++) {
Branch: 1 branch
BranchTrueFalseTotal
for(tl = 1; tl <= tree_jail.lelements; tl++) { 18 33 51
2533 18 free(tree_jail.elements[tl].tree);
2534 18 free(tree_jail.elements[tl].index);
2535 }
2536
2537 33 free(tree_jail.elements);
2538 33 }
2539  
2540 4290 int check_tags_alloc(struct tags *tags) {
2541 4290 ▶ if(tags->count >= tags->csize) {
Branch: 1 branch
BranchTrueFalseTotal
if(tags->count >= tags->csize) { 0 4290 4290
2542 0 tags->csize += 1024;
2543
2544 0 tags->name = (char **)realloc(tags->name, sizeof(char*) * tags->csize);
2545 0 tags->priority = (int *)realloc(tags->priority, sizeof(int) * tags->csize);
2546 0 tags->type = (int *)realloc(tags->type, sizeof(int) * tags->csize);
2547 0 tags->extra = (int *)realloc(tags->extra, sizeof(int) * tags->csize);
2548 0 tags->ai = (int *)realloc(tags->ai, sizeof(int) * tags->csize);
2549 0 tags->family = (int *)realloc(tags->family, sizeof(int) * tags->csize);
2550 0 tags->option = (int *)realloc(tags->option, sizeof(int) * tags->csize);
2551
2552 0 tags->index.tag_id = (long **)realloc(tags->index.tag_id, sizeof(long *) * tags->csize);
2553 0 tags->index.tag_count = (int *)realloc(tags->index.tag_count, tags->csize * sizeof(int));
2554 0 tags->index.tag_csize = (int *)realloc(tags->index.tag_csize, tags->csize * sizeof(int));
2555 }
2556
2557 4290 return tags->csize;
2558 }
2559  
2560 // +++++++++++
2561 // функции добавления тегов в список, присваивает им id
2562 // +++++++++++++++++++++++++++++++++
2563 0 int add_tag(struct tags *tags, char *html, struct mem_tag *my) {
2564 0 long pr = my->stop_otag - my->start_otag + 1;
2565
2566 0 ▶ if( pr <= 0 )
Branch: 1 branch
BranchTrueFalseTotal
if( pr <= 0 ) 0 0 0
2567 0 return -1;
2568
2569 0 tags->count++;
2570
2571 0 check_tags_alloc(tags);
2572
2573 0 tags->name[ tags->count ] = (char *)malloc(sizeof(char) * (pr + 1));
2574
2575 0 tags->index.tag_count[tags->count] = -1;
2576 0 tags->index.tag_csize[tags->count] = 256;
2577 0 tags->index.tag_id[tags->count] = (long *)malloc(sizeof(long) * tags->index.tag_csize[tags->count]);
2578
2579 0 long i, t = 0;
2580 0 ▶ for(i = my->start_otag; i <= my->stop_otag; i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my->start_otag; i <= my->stop_otag; i++ ) { 0 0 0
2581 0 tags->name[ tags->count ][t++] = tolower(html[i]);
2582 }
2583 0 tags->name[ tags->count ][t] = '\0';
2584
2585 0 tags->priority[ tags->count ] = 0;
2586 0 tags->type[ tags->count ] = TYPE_TAG_NORMAL;
2587 0 tags->extra[ tags->count ] = 0;
2588 0 tags->ai[ tags->count ] = AI_NULL;
2589 0 tags->family[ tags->count ] = 0;
2590 0 tags->option[ tags->count ] = OPTION_NULL;
2591
2592 0 return tags->count;
2593 }
2594  
2595 4290 int add_tag_R(struct tags *tags, char *tagname, size_t size, int priority, int family, int type, int extra, int option, int ai) {
2596 4290 tags->count++;
2597
2598 4290 check_tags_alloc(tags);
2599
2600 4290 tags->name[ tags->count ] = (char *)malloc(sizeof(char) * size + 1);
2601
2602 4290 tags->index.tag_count[tags->count] = -1;
2603 4290 tags->index.tag_csize[tags->count] = 256;
2604 4290 tags->index.tag_id[tags->count] = (long *)malloc(sizeof(long) * tags->index.tag_csize[tags->count]);
2605
2606 size_t i;
2607 27885 ▶ for(i = 0; i <= size; i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i <= size; i++ ) { 23595 4290 27885
2608 23595 tags->name[ tags->count ][i] = tolower(tagname[i]);
2609 }
2610
2611 4290 tags->priority[ tags->count ] = priority;
2612 4290 tags->type[ tags->count ] = type;
2613 4290 tags->extra[ tags->count ] = extra;
2614 4290 tags->ai[ tags->count ] = ai;
2615 4290 tags->family[ tags->count ] = family;
2616 4290 tags->option[ tags->count ] = option;
2617
2618 4290 return tags->count;
2619 }
2620  
2621 0 int set_tag_family(struct tags *tags, char *tagname, int value) {
2622 0 int tag_id = get_tag_id(tags, tagname);
2623 0 ▶ if(tag_id > -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id > -1) 0 0 0
2624 0 tags->family[tag_id] = value;
2625 0 return tag_id;
2626 }
2627  
2628 0 int set_tag_extra(struct tags *tags, char *tagname, int value) {
2629 0 int tag_id = get_tag_id(tags, tagname);
2630 0 ▶ if(tag_id > -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id > -1) 0 0 0
2631 0 tags->extra[tag_id] = value;
2632 0 return tag_id;
2633 }
2634  
2635 0 int set_tag_option(struct tags *tags, char *tagname, int value) {
2636 0 int tag_id = get_tag_id(tags, tagname);
2637 0 ▶ if(tag_id > -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id > -1) 0 0 0
2638 0 tags->option[tag_id] = value;
2639 0 return tag_id;
2640 }
2641  
2642 0 int set_tag_priority(struct tags *tags, char *tagname, int value) {
2643 0 int tag_id = get_tag_id(tags, tagname);
2644 0 ▶ if(tag_id > -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id > -1) 0 0 0
2645 0 tags->priority[tag_id] = value;
2646 0 return tag_id;
2647 }
2648  
2649 0 int set_tag_type(struct tags *tags, char *tagname, int value) {
2650 0 int tag_id = get_tag_id(tags, tagname);
2651 0 ▶ if(tag_id > -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id > -1) 0 0 0
2652 0 tags->type[tag_id] = value;
2653 0 return tag_id;
2654 }
2655  
2656 0 int set_tag_ai(struct tags *tags, char *tagname, int value) {
2657 0 int tag_id = get_tag_id(tags, tagname);
2658 0 ▶ if(tag_id > -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id > -1) 0 0 0
2659 0 tags->ai[tag_id] = value;
2660 0 return tag_id;
2661 }
2662  
2663 // +++++++++++
2664 // разнообразные функции сравнения тегов
2665 // +++++++++++++++++++++++++++++++++
2666 838 int cmp_tags(struct tags *tags, char *html, struct mem_tag *my, int offset) {
2667 int m1;
2668 838 int is_cg = -1;
2669
2670 63457 ▶ for(m1 = 0; m1 <= tags->count; m1++ ) {
Branch: 1 branch
BranchTrueFalseTotal
for(m1 = 0; m1 <= tags->count; m1++ ) { 63457 0 63457
2671 63457 int m2 = -1;// char m;
2672
2673 68614 ▶ while( tags->name[m1][++m2] ) {
Branch: 1 branch
BranchTrueFalseTotal
while( tags->name[m1][++m2] ) { 67668 946 68614
2674 67668 long p = my->start_otag + offset + m2;
2675
2676 67668 ▶ if(tolower(html[p]) != tags->name[m1][m2]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tolower(html[p]) != tags->name[m1][m2]) { 61673 5995 67668
2677 61673 break;
2678 }
2679 5995 ▶ else if(my->stop_otag == p && tags->name[m1][m2+1] == '\0') {
Branch: 2 branches
BranchTrueFalseTotal
else if(my->stop_otag == p && tags->name[m1][m2+1] == '\0') { 1013 4982 5995
else if(my->stop_otag == p && tags->name[m1][m2+1] == '\0') { 838 175 1013
2680 838 is_cg = m1;
2681 838 break;
2682 }
2683 }
2684
2685 63457 ▶ if(is_cg != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_cg != -1) { 838 62619 63457
2686 838 break;
2687 }
2688 }
2689
2690 838 ▶ if(is_cg == -1 && offset == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if(is_cg == -1 && offset == 0) { 0 838 838
if(is_cg == -1 && offset == 0) { 0 0 0
2691 0 is_cg = add_tag(tags, html, my);
2692 }
2693
2694 838 return is_cg;
2695 }
2696  
2697 // +++++++++++
2698 // вспомогательные функции
2699 // +++++++++++++++++++++++++++++++++
2700 2357 int get_tag_id(struct tags *tags, char *tagname) {
2701 int m1;
2702 2357 int is_cg = -1;
2703
2704 148289 ▶ for(m1 = 0; m1 <= tags->count; m1++ ) {
Branch: 1 branch
BranchTrueFalseTotal
for(m1 = 0; m1 <= tags->count; m1++ ) { 148246 43 148289
2705 148246 int m2 = -1;
2706
2707 166918 ▶ while( tags->name[m1][++m2] ) {
Branch: 1 branch
BranchTrueFalseTotal
while( tags->name[m1][++m2] ) { 164070 2848 166918
2708 164070 ▶ if(tolower(tagname[m2]) != tags->name[m1][m2]) {
Branch: 1 branch
BranchTrueFalseTotal
if(tolower(tagname[m2]) != tags->name[m1][m2]) { 143084 20986 164070
2709 143084 break;
2710 }
2711 20986 ▶ else if(tags->name[m1][m2+1] == '\0' && tagname[m2+1] == '\0') {
Branch: 2 branches
BranchTrueFalseTotal
else if(tags->name[m1][m2+1] == '\0' && tagname[m2+1] == '\0') { 2805 18181 20986
else if(tags->name[m1][m2+1] == '\0' && tagname[m2+1] == '\0') { 2314 491 2805
2712 2314 is_cg = m1;
2713 2314 break;
2714 }
2715 }
2716
2717 148246 ▶ if(is_cg != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_cg != -1) { 2314 145932 148246
2718 2314 break;
2719 }
2720 }
2721
2722 2357 return is_cg;
2723 }
2724  
2725 83 long set_position(struct tree_list *my_r, struct html_tree *element) {
2726 83 ▶ if(element == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(element == NULL) 0 83 83
2727 0 return -1;
2728
2729 83 my_r->nco_pos = element->id;
2730 83 my_r->cur_pos = element->id;
2731 83 return my_r->cur_pos;
2732 }
2733  
2734 0 long get_element_body_size(struct tree_list *my_r, struct html_tree *element) {
2735 0 ▶ if(element == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element == NULL) { 0 0 0
2736 0 return my_r->list[ my_r->cur_pos ].tag_body_stop - my_r->list[ my_r->cur_pos ].tag_body_start;
2737 }
2738
2739 0 return element->tag_body_stop - element->tag_body_start;
2740 }
2741  
2742 0 char * get_element_body(struct tree_list *my_r, struct html_tree *element) {
2743 0 ▶ if(element == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element == NULL) { 0 0 0
2744 0 return &my_r->html[ my_r->list[ my_r->cur_pos ].tag_body_start ];
2745 }
2746
2747 0 return &my_r->html[element->tag_body_start];
2748 }
2749  
2750 49 struct html_tree * get_curr_element(struct tree_list *my_r) {
2751 49 return &my_r->list[my_r->cur_pos];
2752 }
2753  
2754 0 struct html_tree * get_element_by_name(struct tree_list *my_r, char *tagname, long position) {
2755 0 int tag_id = get_tag_id(my_r->tags, tagname);
2756
2757 0 ▶ if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position)
Branch: 4 branches
BranchTrueFalseTotal
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
2758 0 return NULL;
2759
2760 0 return &my_r->list[ my_r->tags->index.tag_id[tag_id][position] ];
2761 }
2762  
2763 107 struct html_tree * get_element_by_tag_id(struct tree_list *my_r, int tag_id, long position) {
2764 107 ▶ if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position)
Branch: 4 branches
BranchTrueFalseTotal
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 107 0 107
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 41 66 107
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 41 0 41
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 41 41
2765 66 return NULL;
2766
2767 41 return &my_r->list[ my_r->tags->index.tag_id[tag_id][position] ];
2768 }
2769  
2770 0 struct html_tree * get_element_by_name_in_child(struct tree_list *my_r, char *tagname, long position) {
2771 0 int tag_id = get_tag_id(my_r->tags, tagname);
2772
2773 0 ▶ if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position)
Branch: 4 branches
BranchTrueFalseTotal
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
2774 0 return NULL;
2775
2776 0 long i; long cpos = -1; long il = 0;
2777 0 ▶ for(i = 0; i <= my_r->tags->index.tag_count[tag_id]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i <= my_r->tags->index.tag_count[tag_id]; i++) { 0 0 0
2778 0 ▶ if(my_r->cur_pos < my_r->tags->index.tag_id[tag_id][i]) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->cur_pos < my_r->tags->index.tag_id[tag_id][i]) { 0 0 0
2779 0 ▶ if(il == position) {
Branch: 1 branch
BranchTrueFalseTotal
if(il == position) { 0 0 0
2780 0 cpos = i;
2781 0 break;
2782 }
2783 0 il++;
2784 }
2785 }
2786
2787 0 ▶ if(cpos == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(cpos == -1) 0 0 0
2788 0 return NULL;
2789
2790 0 long level = -1;
2791 0 ▶ for(i = my_r->cur_pos + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->cur_pos + 1; i <= my_r->count; i++) { 0 0 0
2792 0 ▶ if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) { 0 0 0
2793 0 break;
2794 }
2795
2796 0 ▶ if(my_r->tags->index.tag_id[tag_id][cpos] == i) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags->index.tag_id[tag_id][cpos] == i) { 0 0 0
2797 0 level = i;
2798 0 break;
2799 }
2800 }
2801
2802 0 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 0 0
2803 0 return NULL;
2804 0 return &my_r->list[level];
2805 }
2806  
2807 0 struct html_tree * get_element_by_name_in_level(struct tree_list *my_r, char *tagname, long position) {
2808 0 int tag_id = get_tag_id(my_r->tags, tagname);
2809
2810 0 ▶ if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position)
Branch: 4 branches
BranchTrueFalseTotal
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
if(tag_id == -1 || my_r->tags->index.tag_count[tag_id] == -1 || position < 0 || my_r->tags->index.tag_count[tag_id] < position) 0 0 0
2811 0 return NULL;
2812
2813 0 struct html_tree * curr_element = get_curr_element(my_r);
2814
2815 0 long i; long cpos = -1; long il = 0;
2816 0 int i_level = my_r->list[ my_r->cur_pos ].inc + 1;
2817
2818 0 long max_id = -1;
2819 0 struct html_tree * max_element = get_next_element_skip_curr(my_r);
2820
2821 0 ▶ if(max_element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(max_element != NULL) { 0 0 0
2822 0 max_id = max_element->id;
2823 0 set_position(my_r, curr_element);
2824 }
2825
2826 0 ▶ for(i = 0; i <= my_r->tags->index.tag_count[tag_id]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i <= my_r->tags->index.tag_count[tag_id]; i++) { 0 0 0
2827 0 ▶ if(my_r->cur_pos < my_r->tags->index.tag_id[tag_id][i] &&
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->cur_pos < my_r->tags->index.tag_id[tag_id][i] && 0 0 0
2828 0 ▶ i_level == my_r->list[ my_r->tags->index.tag_id[tag_id][i] ].inc &&
Branch: 2 branches
BranchTrueFalseTotal
i_level == my_r->list[ my_r->tags->index.tag_id[tag_id][i] ].inc && 0 0 0
i_level == my_r->list[ my_r->tags->index.tag_id[tag_id][i] ].inc && 0 0 0
2829 0 ▶ (max_id == -1 || (max_id > my_r->tags->index.tag_id[tag_id][i]))
Branch: 1 branch
BranchTrueFalseTotal
(max_id == -1 || (max_id > my_r->tags->index.tag_id[tag_id][i])) 0 0 0
2830 ) {
2831 0 ▶ if(il == position) {
Branch: 1 branch
BranchTrueFalseTotal
if(il == position) { 0 0 0
2832 0 cpos = i;
2833 0 break;
2834 }
2835 0 il++;
2836 }
2837 }
2838
2839 0 ▶ if(cpos == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(cpos == -1) 0 0 0
2840 0 return NULL;
2841 0 return &my_r->list[ my_r->tags->index.tag_id[tag_id][cpos] ];
2842 }
2843  
2844 0 int get_count_element_by_name(struct tree_list *my_r, char *tagname) {
2845 0 int tag_id = get_tag_id(my_r->tags, tagname);
2846
2847 0 ▶ if(tag_id == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id == -1) 0 0 0
2848 0 return 0;
2849
2850 0 return my_r->tags->index.tag_count[tag_id] + 1;
2851 }
2852  
2853 0 int get_real_count_element_by_name(struct tree_list *my_r, char *tagname) {
2854 0 int tag_id = get_tag_id(my_r->tags, tagname);
2855
2856 0 ▶ if(tag_id == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(tag_id == -1) 0 0 0
2857 0 return -1;
2858
2859 0 return my_r->tags->index.tag_count[tag_id];
2860 }
2861  
2862 35 struct html_tree * get_next_element_in_level(struct tree_list *my_r) {
2863 35 ▶ if(my_r->count > my_r->nco_pos && my_r->list[ my_r->nco_pos + 1 ].inc > my_r->list[ my_r->cur_pos ].inc) {
Branch: 2 branches
BranchTrueFalseTotal
if(my_r->count > my_r->nco_pos && my_r->list[ my_r->nco_pos + 1 ].inc > my_r->list[ my_r->cur_pos ].inc) { 30 5 35
if(my_r->count > my_r->nco_pos && my_r->list[ my_r->nco_pos + 1 ].inc > my_r->list[ my_r->cur_pos ].inc) { 28 2 30
2864 28 my_r->nco_pos++;
2865 28 return &my_r->list[my_r->nco_pos];
2866 }
2867
2868 7 return NULL;
2869 }
2870  
2871 1 struct html_tree * get_prev_element_in_level(struct tree_list *my_r) {
2872 1 ▶ if(my_r->nco_pos > 0 && my_r->list[ my_r->nco_pos - 1 ].inc > my_r->list[ my_r->cur_pos ].inc) {
Branch: 2 branches
BranchTrueFalseTotal
if(my_r->nco_pos > 0 && my_r->list[ my_r->nco_pos - 1 ].inc > my_r->list[ my_r->cur_pos ].inc) { 1 0 1
if(my_r->nco_pos > 0 && my_r->list[ my_r->nco_pos - 1 ].inc > my_r->list[ my_r->cur_pos ].inc) { 1 0 1
2873 1 my_r->nco_pos--;
2874 1 return &my_r->list[my_r->nco_pos];
2875 }
2876
2877 0 return NULL;
2878 }
2879  
2880 1 struct html_tree * get_next_element_in_level_skip_curr(struct tree_list *my_r) {
2881 1 long i; long level = -1;
2882 2 ▶ for(i = my_r->nco_pos + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->nco_pos + 1; i <= my_r->count; i++) { 2 0 2
2883 2 ▶ if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) { 0 2 2
2884 0 break;
2885 }
2886 2 ▶ else if(my_r->list[i].inc <= my_r->list[ my_r->nco_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
else if(my_r->list[i].inc <= my_r->list[ my_r->nco_pos ].inc) { 1 1 2
2887 1 level = i;
2888 1 break;
2889 }
2890 }
2891
2892 1 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 1 1
2893 0 return NULL;
2894
2895 1 my_r->nco_pos = level;
2896 1 return &my_r->list[level];
2897 }
2898  
2899 0 struct html_tree * get_parent_in_level(struct tree_list *my_r, int set_pos) {
2900
2901 0 long i; long level = -1;
2902 0 ▶ for(i = my_r->nco_pos - 1; i >= my_r->cur_pos; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->nco_pos - 1; i >= my_r->cur_pos; i--) { 0 0 0
2903 0 ▶ if(my_r->list[i].inc < my_r->list[ my_r->nco_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc < my_r->list[ my_r->nco_pos ].inc) { 0 0 0
2904 0 level = i;
2905 0 break;
2906 }
2907 }
2908
2909 0 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 0 0
2910 0 return NULL;
2911
2912 0 ▶ if(set_pos == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(set_pos == 1) 0 0 0
2913 0 my_r->nco_pos = level;
2914
2915 0 return &my_r->list[level];
2916 }
2917  
2918 0 struct html_tree * get_next_element(struct tree_list *my_r) {
2919 0 ▶ if(my_r->count > my_r->cur_pos) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->count > my_r->cur_pos) { 0 0 0
2920 0 my_r->cur_pos++;
2921 0 my_r->nco_pos = my_r->cur_pos;
2922 0 return &my_r->list[my_r->cur_pos];
2923 }
2924
2925 0 return NULL;
2926 }
2927  
2928 0 struct html_tree * get_prev_element(struct tree_list *my_r) {
2929 0 ▶ if(my_r->cur_pos > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->cur_pos > 0) { 0 0 0
2930 0 my_r->cur_pos--;
2931 0 my_r->nco_pos = my_r->cur_pos;
2932 0 return &my_r->list[my_r->cur_pos];
2933 }
2934
2935 0 return NULL;
2936 }
2937  
2938 0 struct html_tree * get_next_element_skip_curr(struct tree_list *my_r) {
2939 0 long i; long level = -1;
2940 0 ▶ for(i = my_r->cur_pos + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->cur_pos + 1; i <= my_r->count; i++) { 0 0 0
2941 0 ▶ if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) { 0 0 0
2942 0 level = i;
2943 0 break;
2944 }
2945 }
2946
2947 0 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 0 0
2948 0 return NULL;
2949
2950 0 my_r->nco_pos = level;
2951 0 my_r->cur_pos = level;
2952 0 return &my_r->list[level];
2953 }
2954  
2955 2 struct html_tree * get_next_element_curr_level(struct tree_list *my_r) {
2956 2 long i; long level = -1;
2957 9 ▶ for(i = my_r->cur_pos + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->cur_pos + 1; i <= my_r->count; i++) { 8 1 9
2958 8 ▶ if(my_r->list[i].inc == my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc == my_r->list[ my_r->cur_pos ].inc) { 1 7 8
2959 1 level = i;
2960 1 break;
2961 }
2962 7 ▶ else if(my_r->list[i].inc < my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
else if(my_r->list[i].inc < my_r->list[ my_r->cur_pos ].inc) { 0 7 7
2963 0 break;
2964 }
2965 }
2966
2967 2 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 1 1 2
2968 1 return NULL;
2969
2970 1 my_r->nco_pos = level;
2971 1 my_r->cur_pos = level;
2972 1 return &my_r->list[level];
2973 }
2974  
2975 1 struct html_tree * get_prev_element_curr_level(struct tree_list *my_r) {
2976
2977 1 long i; long level = -1;
2978 3 ▶ for(i = my_r->cur_pos - 1; i >= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->cur_pos - 1; i >= 0; i--) { 3 0 3
2979 3 ▶ if(my_r->list[i].inc == my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc == my_r->list[ my_r->cur_pos ].inc) { 1 2 3
2980 1 level = i;
2981 1 break;
2982 }
2983 2 ▶ else if(my_r->list[i].inc < my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
else if(my_r->list[i].inc < my_r->list[ my_r->cur_pos ].inc) { 0 2 2
2984 0 break;
2985 }
2986 }
2987
2988 1 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 1 1
2989 0 return NULL;
2990
2991 1 my_r->nco_pos = level;
2992 1 my_r->cur_pos = level;
2993 1 return &my_r->list[level];
2994 }
2995  
2996 0 struct html_tree * get_child(struct tree_list *my_r, long pos) {
2997
2998 0 long level = -1;
2999 0 int next_level = my_r->list[ my_r->cur_pos ].inc + 1;
3000
3001 long i;
3002 0 ▶ for(i = my_r->cur_pos + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->cur_pos + 1; i <= my_r->count; i++) { 0 0 0
3003 0 ▶ if(my_r->list[i].inc == next_level) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc == next_level) { 0 0 0
3004 0 pos--;
3005 0 ▶ if(pos == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(pos == -1) { 0 0 0
3006 0 level = i;
3007 0 break;
3008 }
3009 }
3010 0 ▶ else if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
else if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) { 0 0 0
3011 0 break;
3012 }
3013 }
3014
3015 0 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 0 0
3016 0 return NULL;
3017
3018 0 my_r->nco_pos = level;
3019 0 my_r->cur_pos = level;
3020 0 return &my_r->list[level];
3021 }
3022  
3023 174 struct html_tree * get_child_n(struct tree_list *my_r, long pos) {
3024
3025 174 long level = -1;
3026 174 int next_level = my_r->list[ my_r->cur_pos ].inc + 1;
3027
3028 long i;
3029 586 ▶ for(i = my_r->cur_pos + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->cur_pos + 1; i <= my_r->count; i++) { 546 40 586
3030 546 ▶ if(my_r->list[i].inc == next_level) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc == next_level) { 236 310 546
3031 236 pos--;
3032 236 ▶ if(pos == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(pos == -1) { 88 148 236
3033 88 level = i;
3034 88 break;
3035 }
3036 }
3037 310 ▶ else if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
else if(my_r->list[i].inc <= my_r->list[ my_r->cur_pos ].inc) { 46 264 310
3038 46 break;
3039 }
3040 }
3041
3042 174 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 86 88 174
3043 86 return NULL;
3044
3045 88 return &my_r->list[level];
3046 }
3047  
3048 0 struct html_tree * get_parent(struct tree_list *my_r) {
3049
3050 0 long i; long level = -1;
3051 0 ▶ for(i = my_r->cur_pos - 1; i >= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = my_r->cur_pos - 1; i >= 0; i--) { 0 0 0
3052 0 ▶ if(my_r->list[i].inc < my_r->list[ my_r->cur_pos ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc < my_r->list[ my_r->cur_pos ].inc) { 0 0 0
3053 0 level = i;
3054 0 break;
3055 }
3056 }
3057
3058 0 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 0 0
3059 0 return NULL;
3060
3061 0 my_r->nco_pos = level;
3062 0 my_r->cur_pos = level;
3063 0 return &my_r->list[level];
3064 }
3065  
3066 0 struct html_tree * get_child_by_tree(struct tree_list *my_r, struct html_tree *html_tree) {
3067
3068 0 long i; long level = -1;
3069 0 ▶ for(i = html_tree->id + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = html_tree->id + 1; i <= my_r->count; i++) { 0 0 0
3070 0 ▶ if(my_r->list[i].inc > html_tree->inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc > html_tree->inc) { 0 0 0
3071 0 level = i;
3072 0 break;
3073 }
3074 0 ▶ else if(my_r->list[i].inc <= html_tree->inc) {
Branch: 1 branch
BranchTrueFalseTotal
else if(my_r->list[i].inc <= html_tree->inc) { 0 0 0
3075 0 break;
3076 }
3077 }
3078
3079 0 ▶ if(level == -1)
Branch: 1 branch
BranchTrueFalseTotal
if(level == -1) 0 0 0
3080 0 return NULL;
3081 0 return &my_r->list[level];
3082 }
3083  
3084 0 int get_count_to_next_element_in_level(struct tree_list *my_r, struct html_tree *tag) {
3085 0 long i; int count = 0;
3086 0 ▶ for(i = tag->id + 1; i <= my_r->count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = tag->id + 1; i <= my_r->count; i++) { 0 0 0
3087 0 count++;
3088
3089 0 ▶ if(my_r->list[i].inc <= my_r->list[ tag->id ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[i].inc <= my_r->list[ tag->id ].inc) { 0 0 0
3090 0 break;
3091 }
3092 0 ▶ else if(my_r->list[i].inc <= my_r->list[ tag->id ].inc) {
Branch: 1 branch
BranchTrueFalseTotal
else if(my_r->list[i].inc <= my_r->list[ tag->id ].inc) { 0 0 0
3093 0 break;
3094 }
3095 }
3096
3097 0 return count;
3098 }
3099  
3100 /////////////
3101 // работа с элементами и их параметрами
3102 ///////////////////
3103 6 struct mem_params * find_param_by_key_in_element(struct mem_tag *my, char *key) {
3104 long p;
3105 6 struct mem_params *np = NULL;
3106
3107 6 ▶ if (my->params == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (my->params == NULL) 0 6 6
3108 0 return np;
3109
3110 12 ▶ for (p = 0; p <= my->lparams; p++) {
Branch: 1 branch
BranchTrueFalseTotal
for (p = 0; p <= my->lparams; p++) { 6 6 12
3111 long k;
3112 15 ▶ for (k = 0; k <= my->params[p].lkey; k++) {
Branch: 1 branch
BranchTrueFalseTotal
for (k = 0; k <= my->params[p].lkey; k++) { 15 0 15
3113 15 ▶ if(my->params[p].key[k] != key[k] || ((my->params[p].key[k] != '\0' && key[k] == '\0') || (my->params[p].key[k] == '\0' && key[k] != '\0'))) {
Branch: 5 branches
BranchTrueFalseTotal
if(my->params[p].key[k] != key[k] || ((my->params[p].key[k] != '\0' && key[k] == '\0') || (my->params[p].key[k] == '\0' && key[k] != '\0'))) { 12 3 15
if(my->params[p].key[k] != key[k] || ((my->params[p].key[k] != '\0' && key[k] == '\0') || (my->params[p].key[k] == '\0' && key[k] != '\0'))) { 9 3 12
if(my->params[p].key[k] != key[k] || ((my->params[p].key[k] != '\0' && key[k] == '\0') || (my->params[p].key[k] == '\0' && key[k] != '\0'))) { 9 0 9
if(my->params[p].key[k] != key[k] || ((my->params[p].key[k] != '\0' && key[k] == '\0') || (my->params[p].key[k] == '\0' && key[k] != '\0'))) { 3 9 12
if(my->params[p].key[k] != key[k] || ((my->params[p].key[k] != '\0' && key[k] == '\0') || (my->params[p].key[k] == '\0' && key[k] != '\0'))) { 3 0 3
3114 break;
3115 }
3116 12 ▶ else if(my->params[p].key[k] == '\0' && key[k] == '\0') {
Branch: 2 branches
BranchTrueFalseTotal
else if(my->params[p].key[k] == '\0' && key[k] == '\0') { 3 9 12
else if(my->params[p].key[k] == '\0' && key[k] == '\0') { 3 0 3
3117 3 np = &my->params[p];
3118 3 break;
3119 }
3120 }
3121 }
3122
3123 6 return np;
3124 }
3125  
3126 /////////////
3127 // функции зачисток
3128 ///////////////////
3129 44 void clean_tree(struct tree_list * my_r) {
3130 int di;
3131 643 ▶ for(di = 0; di <= my_r->my_real_count; di++) {
Branch: 1 branch
BranchTrueFalseTotal
for(di = 0; di <= my_r->my_real_count; di++) { 599 44 643
3132 int si;
3133
3134 604 ▶ for(si = 0; si <= my_r->my[di].lparams; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si <= my_r->my[di].lparams; si++) { 5 599 604
3135 5 free(my_r->my[di].params[si].key);
3136 5 free(my_r->my[di].params[si].value);
3137 }
3138
3139 599 free(my_r->my[di].params);
3140 }
3141
3142 44 my_r->my_count = -1;
3143 44 my_r->my_real_count = -1;
3144
3145 44 my_r->count = -1;
3146 44 my_r->real_count = -1;
3147
3148 44 my_r->cur_pos = 0;
3149 44 my_r->nco_pos = 0;
3150
3151 44 ▶ if(my_r->my != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->my != NULL) { 33 11 44
3152 33 free(my_r->my);
3153 33 my_r->my = NULL;
3154 }
3155
3156 44 ▶ if(my_r->tags != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags != NULL) { 33 11 44
3157 4323 ▶ for(di = 0; di <= my_r->tags->count; di++) {
Branch: 1 branch
BranchTrueFalseTotal
for(di = 0; di <= my_r->tags->count; di++) { 4290 33 4323
3158 4290 free(my_r->tags->index.tag_id[di]);
3159 4290 free(my_r->tags->name[di]);
3160 }
3161
3162 33 free(my_r->tags->index.tag_count);
3163 33 free(my_r->tags->index.tag_csize);
3164 33 free(my_r->tags->index.tag_id);
3165 33 free(my_r->tags->name);
3166 33 free(my_r->tags->priority);
3167 33 free(my_r->tags->type);
3168 33 free(my_r->tags->extra);
3169 33 free(my_r->tags->ai);
3170 33 free(my_r->tags->family);
3171 33 free(my_r->tags->option);
3172
3173 33 my_r->tags->name = NULL;
3174 33 my_r->tags->priority = NULL;
3175 33 my_r->tags->type = NULL;
3176 33 my_r->tags->extra = NULL;
3177 33 my_r->tags->ai = NULL;
3178 33 my_r->tags->family = NULL;
3179 33 my_r->tags->option = NULL;
3180 }
3181
3182 44 ▶ if(my_r->swords != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->swords != NULL) 0 44 44
3183 0 free(my_r->swords);
3184
3185 44 ▶ if(my_r->tags_family != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags_family != NULL) { 33 11 44
3186 long ld;
3187 3960 ▶ for(ld = 0; ld <= my_r->tags_family->irtags; ld++) {
Branch: 1 branch
BranchTrueFalseTotal
for(ld = 0; ld <= my_r->tags_family->irtags; ld++) { 3927 33 3960
3188 3927 ▶ if(my_r->tags_family->rtags[ld] == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags_family->rtags[ld] == 0) 3696 231 3927
3189 3696 continue;
3190
3191 231 free(my_r->tags_family->rtags[ld]);
3192 }
3193
3194 4092 ▶ for(ld = 0; ld <= my_r->tags_family->itags; ld++) {
Branch: 1 branch
BranchTrueFalseTotal
for(ld = 0; ld <= my_r->tags_family->itags; ld++) { 4059 33 4092
3195 4059 ▶ if(my_r->tags_family->tags[ld] == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags_family->tags[ld] == 0) 3531 528 4059
3196 3531 continue;
3197
3198 528 free(my_r->tags_family->tags[ld]);
3199 }
3200
3201 33 free(my_r->tags_family->rtags);
3202 33 free(my_r->tags_family->tags);
3203
3204 33 my_r->tags_family->rtags = NULL;
3205 33 my_r->tags_family->tags = NULL;
3206
3207 33 free(my_r->tags_family);
3208 33 my_r->tags_family = NULL;
3209 }
3210
3211 44 ▶ if(my_r->list != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list != NULL) { 33 11 44
3212 33 free(my_r->list);
3213 33 my_r->list = NULL;
3214 }
3215 44 }
3216  
3217 //////////////
3218 // HTML Entities
3219 /////////////////////
3220 11 struct tree_entity * create_entity_tree(void) {
3221 11 struct tree_entity *entities = (struct tree_entity *)malloc(sizeof(struct tree_entity) * 128);
3222
3223 int i;
3224 1419 ▶ for(i = 0; i < 128; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < 128; i++) { 1408 11 1419
3225 1408 entities[i].count = -1;
3226 1408 entities[i].next = NULL;
3227 1408 entities[i].value[0] = '\0';
3228 1408 entities[i].level = 0;
3229 }
3230
3231 11 add_entity(entities, "AElig", "Æ");
3232 11 add_entity(entities, "Aacute", "Á");
3233 11 add_entity(entities, "Acirc", "Â");
3234 11 add_entity(entities, "Agrave", "À");
3235 11 add_entity(entities, "Alpha", "Α");
3236 11 add_entity(entities, "Aring", "Å");
3237 11 add_entity(entities, "Atilde", "Ã");
3238 11 add_entity(entities, "Auml", "Ä");
3239 11 add_entity(entities, "Beta", "Β");
3240 11 add_entity(entities, "Ccedil", "Ç");
3241 11 add_entity(entities, "Chi", "Χ");
3242 11 add_entity(entities, "Dagger", "‡");
3243 11 add_entity(entities, "Delta", "Δ");
3244 11 add_entity(entities, "ETH", "Ð");
3245 11 add_entity(entities, "Eacute", "É");
3246 11 add_entity(entities, "Ecirc", "Ê");
3247 11 add_entity(entities, "Egrave", "È");
3248 11 add_entity(entities, "Epsilon", "Ε");
3249 11 add_entity(entities, "Eta", "Η");
3250 11 add_entity(entities, "Euml", "Ë");
3251 11 add_entity(entities, "Gamma", "Γ");
3252 11 add_entity(entities, "Iacute", "Í");
3253 11 add_entity(entities, "Icirc", "Î");
3254 11 add_entity(entities, "Igrave", "Ì");
3255 11 add_entity(entities, "Iota", "Ι");
3256 11 add_entity(entities, "Iuml", "Ï");
3257 11 add_entity(entities, "Kappa", "Κ");
3258 11 add_entity(entities, "Lambda", "Λ");
3259 11 add_entity(entities, "Mu", "Μ");
3260 11 add_entity(entities, "Ntilde", "Ñ");
3261 11 add_entity(entities, "Nu", "Ν");
3262 11 add_entity(entities, "OElig", "Œ");
3263 11 add_entity(entities, "Oacute", "Ó");
3264 11 add_entity(entities, "Ocirc", "Ô");
3265 11 add_entity(entities, "Ograve", "Ò");
3266 11 add_entity(entities, "Omega", "Ω");
3267 11 add_entity(entities, "Omicron", "Ο");
3268 11 add_entity(entities, "Oslash", "Ø");
3269 11 add_entity(entities, "Otilde", "Õ");
3270 11 add_entity(entities, "Ouml", "Ö");
3271 11 add_entity(entities, "Phi", "Φ");
3272 11 add_entity(entities, "Pi", "Π");
3273 11 add_entity(entities, "Prime", "″");
3274 11 add_entity(entities, "Psi", "Ψ");
3275 11 add_entity(entities, "Rho", "Ρ");
3276 11 add_entity(entities, "Scaron", "Š");
3277 11 add_entity(entities, "Sigma", "Σ");
3278 11 add_entity(entities, "THORN", "Þ");
3279 11 add_entity(entities, "Tau", "Τ");
3280 11 add_entity(entities, "Theta", "Θ");
3281 11 add_entity(entities, "Uacute", "Ú");
3282 11 add_entity(entities, "Ucirc", "Û");
3283 11 add_entity(entities, "Ugrave", "Ù");
3284 11 add_entity(entities, "Upsilon", "Υ");
3285 11 add_entity(entities, "Uuml", "Ü");
3286 11 add_entity(entities, "Xi", "Ξ");
3287 11 add_entity(entities, "Yacute", "Ý");
3288 11 add_entity(entities, "Yuml", "Ÿ");
3289 11 add_entity(entities, "Zeta", "Ζ");
3290 11 add_entity(entities, "aacute", "á");
3291 11 add_entity(entities, "acirc", "â");
3292 11 add_entity(entities, "acute", "´");
3293 11 add_entity(entities, "aelig", "æ");
3294 11 add_entity(entities, "agrave", "à");
3295 11 add_entity(entities, "alefsym", "ℵ");
3296 11 add_entity(entities, "alpha", "α");
3297 11 add_entity(entities, "amp", "&");
3298 11 add_entity(entities, "and", "∧");
3299 11 add_entity(entities, "ang", "∠");
3300 11 add_entity(entities, "apos", "'");
3301 11 add_entity(entities, "aring", "å");
3302 11 add_entity(entities, "asymp", "≈");
3303 11 add_entity(entities, "atilde", "ã");
3304 11 add_entity(entities, "auml", "ä");
3305 11 add_entity(entities, "bdquo", "„");
3306 11 add_entity(entities, "beta", "β");
3307 11 add_entity(entities, "brvbar", "¦");
3308 11 add_entity(entities, "bull", "•");
3309 11 add_entity(entities, "cap", "∩");
3310 11 add_entity(entities, "ccedil", "ç");
3311 11 add_entity(entities, "cedil", "¸");
3312 11 add_entity(entities, "cent", "¢");
3313 11 add_entity(entities, "chi", "χ");
3314 11 add_entity(entities, "circ", "ˆ");
3315 11 add_entity(entities, "clubs", "♣");
3316 11 add_entity(entities, "cong", "≅");
3317 11 add_entity(entities, "copy", "©");
3318 11 add_entity(entities, "crarr", "↵");
3319 11 add_entity(entities, "cup", "∪");
3320 11 add_entity(entities, "curren", "¤");
3321 11 add_entity(entities, "dArr", "⇓");
3322 11 add_entity(entities, "dagger", "†");
3323 11 add_entity(entities, "darr", "↓");
3324 11 add_entity(entities, "deg", "°");
3325 11 add_entity(entities, "delta", "δ");
3326 11 add_entity(entities, "diams", "♦");
3327 11 add_entity(entities, "divide", "÷");
3328 11 add_entity(entities, "eacute", "é");
3329 11 add_entity(entities, "ecirc", "ê");
3330 11 add_entity(entities, "egrave", "è");
3331 11 add_entity(entities, "empty", "∅");
3332 11 add_entity(entities, "emsp", " ");
3333 11 add_entity(entities, "ensp", " ");
3334 11 add_entity(entities, "epsilon", "ε");
3335 11 add_entity(entities, "equiv", "≡");
3336 11 add_entity(entities, "eta", "η");
3337 11 add_entity(entities, "eth", "ð");
3338 11 add_entity(entities, "euml", "ë");
3339 11 add_entity(entities, "euro", "€");
3340 11 add_entity(entities, "exist", "∃");
3341 11 add_entity(entities, "fnof", "ƒ");
3342 11 add_entity(entities, "forall", "∀");
3343 11 add_entity(entities, "frac12", "½");
3344 11 add_entity(entities, "frac14", "¼");
3345 11 add_entity(entities, "frac34", "¾");
3346 11 add_entity(entities, "frasl", "⁄");
3347 11 add_entity(entities, "gamma", "γ");
3348 11 add_entity(entities, "ge", "≥");
3349 11 add_entity(entities, "gt", ">");
3350 11 add_entity(entities, "hArr", "⇔");
3351 11 add_entity(entities, "harr", "↔");
3352 11 add_entity(entities, "hearts", "♥");
3353 11 add_entity(entities, "hellip", "…");
3354 11 add_entity(entities, "iacute", "í");
3355 11 add_entity(entities, "icirc", "î");
3356 11 add_entity(entities, "iexcl", "¡");
3357 11 add_entity(entities, "igrave", "ì");
3358 11 add_entity(entities, "image", "ℑ");
3359 11 add_entity(entities, "infin", "∞");
3360 11 add_entity(entities, "int", "∫");
3361 11 add_entity(entities, "iota", "ι");
3362 11 add_entity(entities, "iquest", "¿");
3363 11 add_entity(entities, "isin", "∈");
3364 11 add_entity(entities, "iuml", "ï");
3365 11 add_entity(entities, "kappa", "κ");
3366 11 add_entity(entities, "lArr", "⇐");
3367 11 add_entity(entities, "lambda", "λ");
3368 11 add_entity(entities, "lang", "〈");
3369 11 add_entity(entities, "laquo", "«");
3370 11 add_entity(entities, "larr", "←");
3371 11 add_entity(entities, "lceil", "⌈");
3372 11 add_entity(entities, "ldquo", "“");
3373 11 add_entity(entities, "le", "≤");
3374 11 add_entity(entities, "lfloor", "⌊");
3375 11 add_entity(entities, "lowast", "∗");
3376 11 add_entity(entities, "loz", "◊");
3377 11 add_entity(entities, "lrm", "\xE2\x80\x8E");
3378 11 add_entity(entities, "lsaquo", "‹");
3379 11 add_entity(entities, "lsquo", "‘");
3380 11 add_entity(entities, "lt", "<");
3381 11 add_entity(entities, "macr", "¯");
3382 11 add_entity(entities, "mdash", "—");
3383 11 add_entity(entities, "micro", "µ");
3384 11 add_entity(entities, "middot", "·");
3385 11 add_entity(entities, "minus", "−");
3386 11 add_entity(entities, "mu", "μ");
3387 11 add_entity(entities, "nabla", "∇");
3388 11 add_entity(entities, "nbsp", " ");
3389 11 add_entity(entities, "ndash", "–");
3390 11 add_entity(entities, "ne", "≠");
3391 11 add_entity(entities, "ni", "∋");
3392 11 add_entity(entities, "not", "¬");
3393 11 add_entity(entities, "notin", "∉");
3394 11 add_entity(entities, "nsub", "⊄");
3395 11 add_entity(entities, "ntilde", "ñ");
3396 11 add_entity(entities, "nu", "ν");
3397 11 add_entity(entities, "oacute", "ó");
3398 11 add_entity(entities, "ocirc", "ô");
3399 11 add_entity(entities, "oelig", "œ");
3400 11 add_entity(entities, "ograve", "ò");
3401 11 add_entity(entities, "oline", "‾");
3402 11 add_entity(entities, "omega", "ω");
3403 11 add_entity(entities, "omicron", "ο");
3404 11 add_entity(entities, "oplus", "⊕");
3405 11 add_entity(entities, "or", "∨");
3406 11 add_entity(entities, "ordf", "ª");
3407 11 add_entity(entities, "ordm", "º");
3408 11 add_entity(entities, "oslash", "ø");
3409 11 add_entity(entities, "otilde", "õ");
3410 11 add_entity(entities, "otimes", "⊗");
3411 11 add_entity(entities, "ouml", "ö");
3412 11 add_entity(entities, "para", "¶");
3413 11 add_entity(entities, "part", "∂");
3414 11 add_entity(entities, "permil", "‰");
3415 11 add_entity(entities, "perp", "⊥");
3416 11 add_entity(entities, "phi", "φ");
3417 11 add_entity(entities, "pi", "π");
3418 11 add_entity(entities, "piv", "ϖ");
3419 11 add_entity(entities, "plusmn", "±");
3420 11 add_entity(entities, "pound", "£");
3421 11 add_entity(entities, "prime", "′");
3422 11 add_entity(entities, "prod", "∏");
3423 11 add_entity(entities, "prop", "∝");
3424 11 add_entity(entities, "psi", "ψ");
3425 11 add_entity(entities, "quot", "\"");
3426 11 add_entity(entities, "rArr", "⇒");
3427 11 add_entity(entities, "radic", "√");
3428 11 add_entity(entities, "rang", "〉");
3429 11 add_entity(entities, "raquo", "»");
3430 11 add_entity(entities, "rarr", "→");
3431 11 add_entity(entities, "rceil", "⌉");
3432 11 add_entity(entities, "rdquo", "”");
3433 11 add_entity(entities, "real", "ℜ");
3434 11 add_entity(entities, "reg", "®");
3435 11 add_entity(entities, "rfloor", "⌋");
3436 11 add_entity(entities, "rho", "ρ");
3437 11 add_entity(entities, "rlm", "\xE2\x80\x8F");
3438 11 add_entity(entities, "rsaquo", "›");
3439 11 add_entity(entities, "rsquo", "’");
3440 11 add_entity(entities, "sbquo", "‚");
3441 11 add_entity(entities, "scaron", "š");
3442 11 add_entity(entities, "sdot", "⋅");
3443 11 add_entity(entities, "sect", "§");
3444 11 add_entity(entities, "shy", "\xC2\xAD");
3445 11 add_entity(entities, "sigma", "σ");
3446 11 add_entity(entities, "sigmaf", "ς");
3447 11 add_entity(entities, "sim", "∼");
3448 11 add_entity(entities, "spades", "♠");
3449 11 add_entity(entities, "sub", "⊂");
3450 11 add_entity(entities, "sube", "⊆");
3451 11 add_entity(entities, "sum", "∑");
3452 11 add_entity(entities, "sup", "⊃");
3453 11 add_entity(entities, "sup1", "¹");
3454 11 add_entity(entities, "sup2", "²");
3455 11 add_entity(entities, "sup3", "³");
3456 11 add_entity(entities, "supe", "⊇");
3457 11 add_entity(entities, "szlig", "ß");
3458 11 add_entity(entities, "tau", "τ");
3459 11 add_entity(entities, "there4", "∴");
3460 11 add_entity(entities, "theta", "θ");
3461 11 add_entity(entities, "thetasym", "ϑ");
3462 11 add_entity(entities, "thinsp", " ");
3463 11 add_entity(entities, "thorn", "þ");
3464 11 add_entity(entities, "tilde", "˜");
3465 11 add_entity(entities, "times", "×");
3466 11 add_entity(entities, "trade", "™");
3467 11 add_entity(entities, "uArr", "⇑");
3468 11 add_entity(entities, "uacute", "ú");
3469 11 add_entity(entities, "uarr", "↑");
3470 11 add_entity(entities, "ucirc", "û");
3471 11 add_entity(entities, "ugrave", "ù");
3472 11 add_entity(entities, "uml", "¨");
3473 11 add_entity(entities, "upsih", "ϒ");
3474 11 add_entity(entities, "upsilon", "υ");
3475 11 add_entity(entities, "uuml", "ü");
3476 11 add_entity(entities, "weierp", "℘");
3477 11 add_entity(entities, "xi", "ξ");
3478 11 add_entity(entities, "yacute", "ý");
3479 11 add_entity(entities, "yen", "¥");
3480 11 add_entity(entities, "yuml", "ÿ");
3481 11 add_entity(entities, "zeta", "ζ");
3482 11 add_entity(entities, "zwj", "\xE2\x80\x8D");
3483 11 add_entity(entities, "zwnj", "\xE2\x80\x8C");
3484
3485 11 return entities;
3486 }
3487  
3488 12848 void _add_entity(struct tree_entity *entities, unsigned char *key, char *value, int i) {
3489 12848 ▶ if(entities[key[i]].next == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(entities[key[i]].next == NULL) { 9636 3212 12848
3490 9636 entities[key[i]].next = (struct tree_entity *)malloc(sizeof(struct tree_entity) * 128);
3491
3492 int k;
3493 1243044 ▶ for(k = 0; k < 128; k++) {
Branch: 1 branch
BranchTrueFalseTotal
for(k = 0; k < 128; k++) { 1233408 9636 1243044
3494 1233408 entities[key[i]].next[k].count = -1;
3495 1233408 entities[key[i]].next[k].next = NULL;
3496 1233408 entities[key[i]].next[k].value[0] = '\0';
3497 1233408 entities[key[i]].next[k].level = 0;
3498 }
3499 }
3500
3501 12848 int next_i = i + 1;
3502 12848 ▶ if(key[next_i] == '\0') {
Branch: 1 branch
BranchTrueFalseTotal
if(key[next_i] == '\0') { 2783 10065 12848
3503 2783 int m = -1;
3504 9295 ▶ while (value[++m]) {
Branch: 1 branch
BranchTrueFalseTotal
while (value[++m]) { 6512 2783 9295
3505 6512 entities[ key[i] ].value[m] = value[m];
3506 }
3507
3508 2783 entities[ key[i] ].value[m] = '\0';
3509 2783 entities[ key[i] ].level = i;
3510 2783 entities[ key[i] ].count++;
3511 } else {
3512 10065 _add_entity(entities[ key[i] ].next, key, value, i + 1);
3513 }
3514 12848 }
3515  
3516 2783 void add_entity(struct tree_entity *entities, char *key, char *value) {
3517 2783 _add_entity(entities, (unsigned char*)key, value, 0);
3518 2783 }
3519  
3520 0 struct tree_entity * _check_entity(struct tree_entity *entities, unsigned char *name, int i) {
3521 0 ▶ if(name[i] == '\0' || name[i] > 127)
Branch: 2 branches
BranchTrueFalseTotal
if(name[i] == '\0' || name[i] > 127) 0 0 0
if(name[i] == '\0' || name[i] > 127) 0 0 0
3522 0 return NULL;
3523
3524 0 int next_i = i + 1;
3525 0 ▶ if(name[next_i] == '\0' || name[next_i] > 127) {
Branch: 2 branches
BranchTrueFalseTotal
if(name[next_i] == '\0' || name[next_i] > 127) { 0 0 0
if(name[next_i] == '\0' || name[next_i] > 127) { 0 0 0
3526 0 ▶ if(entities[name[i]].count != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(entities[name[i]].count != -1) { 0 0 0
3527 0 return &entities[name[i]];
3528 }
3529 0 return NULL;
3530 }
3531
3532 0 ▶ if(entities[name[i]].next == NULL || entities[name[i]].next[name[next_i]].next == NULL) {
Branch: 2 branches
BranchTrueFalseTotal
if(entities[name[i]].next == NULL || entities[name[i]].next[name[next_i]].next == NULL) { 0 0 0
if(entities[name[i]].next == NULL || entities[name[i]].next[name[next_i]].next == NULL) { 0 0 0
3533 0 ▶ if(entities[name[i]].count != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(entities[name[i]].count != -1) { 0 0 0
3534 0 return &entities[name[i]];
3535 }
3536 else {
3537 0 return NULL;
3538 }
3539 }
3540
3541 0 return _check_entity(entities[name[i]].next, name, i + 1);
3542 }
3543  
3544 0 struct tree_entity * check_entity(struct tree_entity *entities, char *name) {
3545 0 return _check_entity(entities, (unsigned char*)name, 0);
3546 }
3547  
3548 9647 void clean_tree_entity(struct tree_entity *entities) {
3549 int i;
3550 1244463 ▶ for(i = 0; i < 128; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < 128; i++) { 1234816 9647 1244463
3551 1234816 ▶ if(entities[i].next != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(entities[i].next != NULL) { 9636 1225180 1234816
3552 9636 clean_tree_entity(entities[i].next);
3553 9636 free(entities[i].next);
3554 }
3555 }
3556 9647 }
3557  
3558 0 struct mem_stop_words * add_stop_word_params(struct mem_stop_words *swords, char *key, size_t ksize, char *value, size_t vsize)
3559 {
3560 0 ▶ if(swords == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(swords == NULL) { 0 0 0
3561 0 swords = malloc(sizeof(struct mem_stop_words));
3562
3563 0 swords->params_size = sizeof(struct mem_params) * 1024;
3564 0 swords->lparams = -1;
3565 0 swords->mem_params = malloc(swords->params_size);
3566 }
3567
3568 0 swords->lparams++;
3569
3570 0 ▶ if(swords->lparams >= swords->params_size) {
Branch: 1 branch
BranchTrueFalseTotal
if(swords->lparams >= swords->params_size) { 0 0 0
3571 0 swords->params_size += sizeof(struct mem_params) * 1024;
3572 0 swords->mem_params = realloc(swords->mem_params, swords->params_size);
3573 }
3574
3575 0 swords->mem_params[swords->lparams].key = malloc(sizeof(char) * ksize + 1);
3576 0 swords->mem_params[swords->lparams].lkey = (int)ksize;
3577 0 swords->mem_params[swords->lparams].lkey_size = (int)ksize;
3578 0 strncpy(swords->mem_params[swords->lparams].key, key, ksize);
3579
3580 0 swords->mem_params[swords->lparams].value = malloc(sizeof(char) * vsize + 1);
3581 0 swords->mem_params[swords->lparams].lvalue = (int)vsize;
3582 0 swords->mem_params[swords->lparams].lvalue_size = (int)vsize;
3583 0 strncpy(swords->mem_params[swords->lparams].value, value, vsize);
3584
3585 0 return swords;
3586 }
3587  
3588 16 void * clean_stop_word_params(struct mem_stop_words *swords) {
3589 16 ▶ if (swords == NULL || swords->mem_params == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if (swords == NULL || swords->mem_params == NULL) 0 16 16
if (swords == NULL || swords->mem_params == NULL) 0 0 0
3590 16 return NULL;
3591
3592 int si;
3593
3594 0 ▶ for(si = 0; si <= swords->lparams; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si <= swords->lparams; si++) { 0 0 0
3595 0 free(swords->mem_params[si].key);
3596 0 free(swords->mem_params[si].value);
3597 }
3598
3599 0 free(swords->mem_params);
3600 0 swords->mem_params = NULL;
3601 0 swords->lparams = -1;
3602 0 swords->params_size = 0;
3603
3604 0 free(swords);
3605
3606 0 return NULL;
3607 }
3608  
3609 0 int compare_param_by_nt(struct mem_params *curp, char *value, size_t size_value)
3610 {
3611 0 ▶ if (curp == NULL
Branch: 1 branch
BranchTrueFalseTotal
if (curp == NULL 0 0 0
3612 0 ▶ || (value[0] == '^' && curp->lvalue < (size_value - 1))
Branch: 2 branches
BranchTrueFalseTotal
|| (value[0] == '^' && curp->lvalue < (size_value - 1)) 0 0 0
|| (value[0] == '^' && curp->lvalue < (size_value - 1)) 0 0 0
3613 0 ▶ || (value[0] != '^' && curp->lvalue < size_value))
Branch: 2 branches
BranchTrueFalseTotal
|| (value[0] != '^' && curp->lvalue < size_value)) 0 0 0
|| (value[0] != '^' && curp->lvalue < size_value)) 0 0 0
3614 0 return 0;
3615
3616 0 long i, t = 0;
3617
3618 0 ▶ if(value[0] == '^') {
Branch: 1 branch
BranchTrueFalseTotal
if(value[0] == '^') { 0 0 0
3619 0 t = 1;
3620 0 ▶ for(i = 1; i < size_value; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 1; i < size_value; i++) { 0 0 0
3621 0 ▶ if (value[i] != curp->value[i-1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (value[i] != curp->value[i-1]) { 0 0 0
3622 0 t = 0;
3623 0 break;
3624 }
3625 }
3626
3627 0 ▶ i = t == 0 ? -1 : size_value;
Branch: 1 branch
BranchTrueFalseTotal
i = t == 0 ? -1 : size_value; 0 0 0
3628 }
3629 else {
3630 0 ▶ for(i = 0; i < size_value; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < size_value; i++) { 0 0 0
3631 0 ▶ if (t > curp->lvalue) {
Branch: 1 branch
BranchTrueFalseTotal
if (t > curp->lvalue) { 0 0 0
3632 0 break;
3633 }
3634 0 ▶ else if (value[i] != curp->value[t]) {
Branch: 1 branch
BranchTrueFalseTotal
else if (value[i] != curp->value[t]) { 0 0 0
3635 0 i = -1;
3636 }
3637
3638 0 t++;
3639 }
3640 }
3641
3642 0 return i == size_value;
3643 }
3644  
3645 21 int find_stop_word_param(struct mem_stop_words *swords, struct mem_tag *mtag) {
3646 21 int cm = 0;
3647
3648 21 ▶ if (swords == NULL || mtag == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if (swords == NULL || mtag == NULL) 0 21 21
if (swords == NULL || mtag == NULL) 0 0 0
3649 21 return cm;
3650
3651 long cw;
3652 0 ▶ for (cw = 0; cw <= swords->lparams; cw++) {
Branch: 1 branch
BranchTrueFalseTotal
for (cw = 0; cw <= swords->lparams; cw++) { 0 0 0
3653 0 struct mem_params *curp = find_param_by_key_in_element(mtag, swords->mem_params[cw].key);
3654 0 int resc = compare_param_by_nt(curp, swords->mem_params[cw].value, swords->mem_params[cw].lvalue);
3655
3656 0 ▶ if(resc == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if(resc == 1) { 0 0 0
3657 0 cm = 1;
3658 0 break;
3659 }
3660 }
3661
3662 0 return cm;
3663 }
3664  
3665 1 void * clean_return_list(struct return_list *return_list) {
3666 1 ▶ if (return_list == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (return_list == NULL) 0 1 1
3667 0 return NULL;
3668
3669 1 free(return_list->list);
3670 1 return_list->list = NULL;
3671 1 free(return_list);
3672
3673 1 return NULL;
3674 }
3675  
3676  
3677  
3678  
3679  
3680  
3681 3 HV * get_element_property_by_my(htmltag_t *my_r, struct mem_tag *mem_tag, int is_utf8) {
3682 SV **ha;
3683 3 HV *hash = newHV();
3684
3685 3 HV *hash_prop = newHV();
3686 3 ▶ if(mem_tag != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(mem_tag != NULL) { 3 0 3
3687 long si;
3688 6 ▶ for(si = 0; si <= mem_tag->lparams; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si <= mem_tag->lparams; si++) { 3 3 6
3689 3 ▶ if(mem_tag->params[si].lvalue > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(mem_tag->params[si].lvalue > 0) { 3 0 3
3690 3 SV *nm = newSVpv(mem_tag->params[si].value, mem_tag->params[si].lvalue - 1);
3691
3692 3 ▶ if(is_utf8) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_utf8) { 3 0 3
3693 3 SvUTF8_on(nm);
3694 }
3695 3 ha = hv_store(hash_prop, mem_tag->params[si].key, mem_tag->params[si].lkey - 1, nm, 0);
3696 } else {
3697 0 ha = hv_store(hash_prop, mem_tag->params[si].key, mem_tag->params[si].lkey - 1, &PL_sv_undef, 0);
3698 }
3699 }
3700
3701 3 ha = hv_store(hash, "prop" , 4, newRV_noinc((SV*)hash_prop), 0);
3702 3 ha = hv_store(hash, "start" , 5, newSViv(mem_tag->start_otag), 0);
3703 3 ha = hv_store(hash, "stop" , 4, newSViv(mem_tag->stop_otag) , 0);
3704 }
3705
3706 3 return hash;
3707 }
3708  
3709 652 HV * get_element_property_by_id(htmltag_t *my_r, long id, int is_utf8) {
3710 652 long my_id = my_r->list[id].my_id;
3711
3712 SV **ha;
3713 652 HV *hash = newHV();
3714
3715 652 ha = hv_store(hash, "name", 4, newSVpv(my_r->tags->name[my_r->list[id].tag_id], 0), 0);
3716
3717 652 HV *hash_prop = newHV();
3718 652 ▶ if(my_id != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_id != -1) { 550 102 652
3719 long si;
3720 550 ▶ for(si = 0; si <= my_r->my[my_id].lparams; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for(si = 0; si <= my_r->my[my_id].lparams; si++) { 0 550 550
3721 0 ▶ if(my_r->my[my_id].params[si].lvalue > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->my[my_id].params[si].lvalue > 0) { 0 0 0
3722 0 SV *nm = newSVpv(my_r->my[my_id].params[si].value, my_r->my[my_id].params[si].lvalue - 1);
3723
3724 0 ▶ if(is_utf8) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_utf8) { 0 0 0
3725 0 SvUTF8_on(nm);
3726 }
3727 0 ha = hv_store(hash_prop, my_r->my[my_id].params[si].key, my_r->my[my_id].params[si].lkey - 1, nm, 0);
3728 } else {
3729 0 ha = hv_store(hash_prop, my_r->my[my_id].params[si].key, my_r->my[my_id].params[si].lkey - 1, &PL_sv_undef, 0);
3730 }
3731 }
3732 }
3733
3734 652 ha = hv_store(hash, "id" , 2, newSViv(my_r->list[id].id) , 0);
3735 652 ha = hv_store(hash, "tag_id", 6, newSViv(my_r->list[id].tag_id) , 0);
3736
3737 652 ha = hv_store(hash, "prop" , 4, newRV_noinc((SV*)hash_prop), 0);
3738 652 ha = hv_store(hash, "level" , 5, newSViv(my_r->list[id].inc), 0);
3739
3740 652 ha = hv_store(hash, "start" , 5, newSViv(my_r->list[id].tag_start), 0);
3741 652 ha = hv_store(hash, "stop" , 4, newSViv(my_r->list[id].tag_stop) , 0);
3742
3743 652 ha = hv_store(hash, "bstart", 6, newSViv(my_r->list[id].tag_body_start), 0);
3744 652 ha = hv_store(hash, "bstop" , 5, newSViv(my_r->list[id].tag_body_stop) , 0);
3745
3746 652 return hash;
3747 }
3748  
3749 328 HV * get_element_property_deftag_by_id(htmltag_t *my_r, long id, char *name) {
3750 328 long my_id = my_r->list[id].my_id;
3751
3752 SV **ha;
3753 328 HV *hash = newHV();
3754
3755 328 ha = hv_store(hash, "name", 4, newSVpv(name, 0), 0);
3756
3757 328 ha = hv_store(hash, "id" , 2, newSViv(my_r->list[id].id) , 0);
3758 328 ha = hv_store(hash, "tag_id", 6, newSViv(my_r->list[id].tag_id) , 0);
3759
3760 328 ha = hv_store(hash, "prop" , 4, &PL_sv_undef, 0);
3761 328 ha = hv_store(hash, "level" , 5, newSViv(my_r->list[id].inc), 0);
3762
3763 328 ha = hv_store(hash, "start" , 5, newSViv(my_r->list[id].tag_start), 0);
3764 328 ha = hv_store(hash, "stop" , 4, newSViv(my_r->list[id].tag_stop) , 0);
3765
3766 328 ha = hv_store(hash, "bstart", 6, newSViv(my_r->list[id].tag_body_start), 0);
3767 328 ha = hv_store(hash, "bstop" , 5, newSViv(my_r->list[id].tag_body_stop) , 0);
3768
3769 328 return hash;
3770 }
3771  
3772 MODULE = HTML::Content::Extractor PACKAGE = HTML::Content::Extractor
3773  
3774 PROTOTYPES: DISABLE
3775  
3776 HTML::Content::Extractor
3777 new(char * class, ...)
3778 CODE:
3779 11 htmltag_t *my_r = malloc(sizeof(htmltag_t));
3780
3781 11 my_r->entities = create_entity_tree();
3782 11 my_r->tags = NULL;
3783 11 my_r->list = NULL;
3784 11 my_r->my = NULL;
3785 11 my_r->swords = NULL;
3786 11 my_r->tags_family = NULL;
3787
3788 11 my_r->my_count = -1;
3789 11 my_r->my_real_count = -1;
3790
3791 11 RETVAL = my_r;
3792 OUTPUT:
3793 RETVAL
3794  
3795 void
3796 analyze(my_r, html, hashref = &PL_sv_undef)
3797 HTML::Content::Extractor my_r;
3798 char *html;
3799 SV *hashref;
3800
3801 CODE:
3802 //setbuf(stdout, NULL);
3803
3804 HV * myhash;
3805 HE * entry;
3806 STRLEN retlen;
3807 I32 len;
3808
3809 char * key;
3810 SV * hashval;
3811 char *value;
3812
3813 AV* arrayh;
3814 char **elements;
3815 4 int elem_size = -1;
3816
3817 4 my_r->swords = clean_stop_word_params(my_r->swords);
3818 4 clean_tree(my_r);
3819
3820 4 ▶ if(my_r->tags)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags) 0 4 4
3821 0 free(my_r->tags);
3822
3823 4 struct tags *tags = malloc(sizeof(struct tags));
3824 4 tags->count = -1;
3825 4 tags->csize = -1;
3826 4 my_r->tags = tags;
3827
3828 4 my_r->html = html;
3829 4 html_tree(my_r);
3830
3831 4 ▶ if(SvROK(hashref)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvROK(hashref)) { 0 4 4
3832 0 myhash = (HV *)SvRV(hashref);
3833 0 (void)hv_iterinit(myhash);
3834 0 ▶ while ((entry = hv_iternext(myhash))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((entry = hv_iternext(myhash))) { 0 0 0
3835 0 key = hv_iterkey(entry,&len);
3836 0 hashval = hv_iterval(myhash,entry);
3837
3838 0 ▶ if(SvROK(hashval) && SvTYPE(SvRV(hashval)) == SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
if(SvROK(hashval) && SvTYPE(SvRV(hashval)) == SVt_PVAV) { 0 0 0
if(SvROK(hashval) && SvTYPE(SvRV(hashval)) == SVt_PVAV) { 0 0 0
3839 0 arrayh = (AV*)SvRV(hashval);
3840
3841 0 elem_size = av_len(arrayh);
3842
3843 char *tmp;
3844 int i;
3845 STRLEN len_s;
3846 0 ▶ for (i = 0; i <= elem_size; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= elem_size; i++) { 0 0 0
3847 0 SV** elem = av_fetch(arrayh, i, 0);
3848 0 char *nml = (char *)SvPV(*elem, len_s);
3849 0 ▶ if(elem != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(elem != NULL) 0 0 0
3850 0 my_r->swords = add_stop_word_params(my_r->swords, key, (size_t)len, nml, (size_t)len_s);
3851 }
3852 }
3853 else {
3854 0 value = SvPV(hashval,retlen);
3855 0 my_r->swords = add_stop_word_params(my_r->swords, key, (size_t)len, value, (size_t)retlen);
3856 }
3857 }
3858 }
3859
3860 4 struct max_element my_max = {0, NULL};
3861 4 struct html_tree * max_element = check_html(my_r, &my_max);
3862 4 set_position(my_r, max_element);
3863  
3864 SV*
3865 get_main_text(my_r, is_utf8 = 1)
3866 HTML::Content::Extractor my_r;
3867 int is_utf8;
3868
3869 CODE:
3870 1 ▶ if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) {
Branch: 3 branches
BranchTrueFalseTotal
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 0 1 1
3871 0 RETVAL = newSVsv(&PL_sv_undef);
3872 }
3873 else {
3874 1 struct lbuffer main_buff = {-1, 1024 * 1024, NULL};
3875 1 get_text_without_element(my_r, &main_buff);
3876 1 clean_text(my_r->entities, &main_buff);
3877
3878 1 ▶ if(main_buff.i < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(main_buff.i < 0) { 0 1 1
3879 0 RETVAL = newSVsv(&PL_sv_undef);
3880 } else {
3881 1 ▶ if(is_utf8) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_utf8) { 1 0 1
3882 1 SV *nm = newSVpv(main_buff.buff, main_buff.i);
3883 1 SvUTF8_on(nm);
3884 1 RETVAL = nm;
3885 } else {
3886 0 RETVAL = newSVpv(main_buff.buff, main_buff.i);
3887 }
3888 }
3889
3890 1 free(main_buff.buff);
3891 }
3892 OUTPUT:
3893 RETVAL
3894  
3895 SV*
3896 get_main_text_with_elements(my_r, is_utf8 = 1, elements_ref = &PL_sv_undef)
3897 HTML::Content::Extractor my_r;
3898 int is_utf8;
3899 SV* elements_ref;
3900
3901 CODE:
3902 AV* array;
3903 char **elements;
3904 1 int elem_size = -1;
3905
3906 1 ▶ if(SvROK(elements_ref)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvROK(elements_ref)) { 1 0 1
3907 1 array = (AV*)SvRV(elements_ref);
3908
3909 1 elem_size = av_len(array);
3910 1 elements = (char **)malloc(sizeof(char *) * elem_size + 1);
3911
3912 char *tmp;
3913 int i;
3914 STRLEN len_s;
3915 2 ▶ for (i = 0; i <= elem_size; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= elem_size; i++) { 1 1 2
3916 //SV *elem = av_shift(array);
3917 1 SV** elem = av_fetch(array, i, 0);
3918 1 ▶ if(elem != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(elem != NULL) { 1 0 1
3919 2 elements[i] = (char *)SvPV(*elem, len_s);
3920 }
3921 }
3922 }
3923
3924 1 ▶ if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) {
Branch: 3 branches
BranchTrueFalseTotal
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 0 1 1
3925 0 RETVAL = newSVsv(&PL_sv_undef);
3926 }
3927 else {
3928 1 struct lbuffer main_buff = {-1, 1024 * 1024, NULL};
3929 1 get_text_with_element(my_r, &main_buff, elements, elem_size);
3930
3931 1 ▶ if(main_buff.i < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(main_buff.i < 0) { 0 1 1
3932 0 RETVAL = newSVsv(&PL_sv_undef);
3933 } else {
3934 1 ▶ if(is_utf8) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_utf8) { 0 1 1
3935 0 SV *nm = newSVpv(main_buff.buff, main_buff.i);
3936 0 SvUTF8_on(nm);
3937 0 RETVAL = nm;
3938 } else {
3939 1 RETVAL = newSVpv(main_buff.buff, main_buff.i);
3940 }
3941 }
3942
3943 1 free(main_buff.buff);
3944 1 ▶ if(elem_size > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(elem_size > -1) { 1 0 1
3945 1 free(elements);
3946 }
3947 }
3948 OUTPUT:
3949 RETVAL
3950  
3951 SV*
3952 get_raw_text(my_r, is_utf8 = 1)
3953 HTML::Content::Extractor my_r;
3954 int is_utf8;
3955
3956 CODE:
3957 1 ▶ if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) {
Branch: 3 branches
BranchTrueFalseTotal
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 0 1 1
3958 0 RETVAL = newSVsv(&PL_sv_undef);
3959 }
3960 else {
3961 1 struct lbuffer main_buff = {-1, 1024 * 1024, NULL};
3962 1 get_raw_text(my_r, &main_buff);
3963
3964 1 ▶ if(main_buff.i < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(main_buff.i < 0) { 0 1 1
3965 0 RETVAL = newSVsv(&PL_sv_undef);
3966 } else {
3967 1 ▶ if(is_utf8) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_utf8) { 1 0 1
3968 1 SV *nm = newSVpv(main_buff.buff, main_buff.i);
3969 1 SvUTF8_on(nm);
3970 1 RETVAL = nm;
3971 } else {
3972 0 RETVAL = newSVpv(main_buff.buff, main_buff.i);
3973 }
3974 }
3975
3976 1 free(main_buff.buff);
3977 }
3978 OUTPUT:
3979 RETVAL
3980  
3981 SV*
3982 get_main_images(my_r, is_utf8 = 1, hashref = &PL_sv_undef, min_width = 100)
3983 HTML::Content::Extractor my_r;
3984 int is_utf8;
3985 SV *hashref;
3986 int min_width;
3987
3988 CODE:
3989 //setbuf(stdout, NULL);
3990 1 AV* array = newAV();
3991
3992 HV * myhash;
3993 HE * entry;
3994 STRLEN retlen;
3995 I32 len;
3996
3997 char * key;
3998 SV * hashval;
3999 char *value;
4000
4001 AV* arrayh;
4002 char **elements;
4003 1 int elem_size = -1;
4004
4005 1 struct mem_stop_words *img_stop = NULL;
4006
4007 1 ▶ if(SvROK(hashref)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvROK(hashref)) { 0 1 1
4008 0 myhash = (HV *)SvRV(hashref);
4009 0 (void)hv_iterinit(myhash);
4010 0 ▶ while ((entry = hv_iternext(myhash))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((entry = hv_iternext(myhash))) { 0 0 0
4011 0 key = hv_iterkey(entry,&len);
4012 0 hashval = hv_iterval(myhash,entry);
4013
4014 0 ▶ if(SvROK(hashval) && SvTYPE(SvRV(hashval)) == SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
if(SvROK(hashval) && SvTYPE(SvRV(hashval)) == SVt_PVAV) { 0 0 0
if(SvROK(hashval) && SvTYPE(SvRV(hashval)) == SVt_PVAV) { 0 0 0
4015 0 arrayh = (AV*)SvRV(hashval);
4016
4017 0 elem_size = av_len(arrayh);
4018
4019 char *tmp;
4020 int i;
4021 STRLEN len_s;
4022 0 ▶ for (i = 0; i <= elem_size; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= elem_size; i++) { 0 0 0
4023 0 SV** elem = av_fetch(arrayh, i, 0);
4024 0 char *nml = (char *)SvPV(*elem, len_s);
4025 0 ▶ if(elem != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(elem != NULL) 0 0 0
4026 0 img_stop = add_stop_word_params(img_stop, key, (size_t)len, nml, (size_t)len_s);
4027 }
4028 }
4029 else {
4030 0 value = SvPV(hashval,retlen);
4031 0 img_stop = add_stop_word_params(img_stop, key, (size_t)len, value, (size_t)retlen);
4032 //printf("-gg------ %s(%ld), %s(%ld)\n", key, (size_t)len, value, (size_t)retlen);
4033 }
4034 }
4035 }
4036
4037 1 ▶ if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) {
Branch: 3 branches
BranchTrueFalseTotal
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 1 0 1
if(my_r->list == NULL || my_r->my == NULL || my_r->tags == NULL) { 0 1 1
4038 0 RETVAL = newRV_noinc((SV*)array);
4039 }
4040 else {
4041 1 struct return_list *return_list = NULL;
4042 1 return_list = get_text_images_href(my_r, return_list, 0, img_stop, min_width);
4043
4044 1 ▶ if(return_list->count < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(return_list->count < 0) { 0 1 1
4045 0 RETVAL = newRV_noinc((SV*)array);
4046 } else {
4047 1 ▶ if(is_utf8) {
Branch: 1 branch
BranchTrueFalseTotal
if(is_utf8) { 1 0 1
4048 long i;
4049 4 ▶ for (i = 0; i <= return_list->real_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= return_list->real_count; i++) { 3 1 4
4050 3 av_push(array, newRV_noinc((SV*)get_element_property_by_my(my_r, &return_list->list[i], 1)));
4051
4052 //for (p = 0; p <= return_list->list[i].lparams; p++) {
4053 // printf("%s=%s\n", return_list->list[i].params[p].key, return_list->list[i].params[p].value);
4054 //}
4055 }
4056
4057 1 RETVAL = newRV_noinc((SV*)array);
4058 } else {
4059 long i;
4060 0 ▶ for (i = 0; i <= return_list->real_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= return_list->real_count; i++) { 0 0 0
4061 0 av_push(array, newRV_noinc((SV*)get_element_property_by_my(my_r, &return_list->list[i], 0)));
4062 }
4063
4064 0 RETVAL = newRV_noinc((SV*)array);
4065 }
4066 }
4067
4068 1 img_stop = clean_stop_word_params(img_stop);
4069
4070 1 return_list = clean_return_list(return_list);
4071 }
4072 OUTPUT:
4073 RETVAL
4074  
4075 SV*
4076 build_tree(my_r, html)
4077 HTML::Content::Extractor my_r;
4078 char *html;
4079
4080 CODE:
4081 //setbuf(stdout, NULL);
4082
4083 29 clean_tree(my_r);
4084
4085 29 ▶ if(my_r->tags)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags) 23 6 29
4086 23 free(my_r->tags);
4087
4088 29 struct tags *tags = malloc(sizeof(struct tags));
4089 29 tags->count = -1;
4090 29 tags->csize = -1;
4091 29 my_r->tags = tags;
4092
4093 29 my_r->html = html;
4094 29 html_tree(my_r);
4095
4096 29 RETVAL = newSViv(1);
4097
4098 OUTPUT:
4099 RETVAL
4100  
4101 SV*
4102 get_tree(my_r, inc_words_tag = 1)
4103 HTML::Content::Extractor my_r;
4104 int inc_words_tag;
4105
4106 CODE:
4107 //setbuf(stdout, NULL);
4108 29 AV* array = newAV();
4109
4110 long mi;
4111 1009 ▶ for (mi = 1; mi <= my_r->count; ++mi) {
Branch: 1 branch
BranchTrueFalseTotal
for (mi = 1; mi <= my_r->count; ++mi) { 980 29 1009
4112 980 long my_id = my_r->list[mi].my_id;
4113
4114 980 ▶ if(my_r->list[mi].tag_id == DEFAULT_TAG_ID) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[mi].tag_id == DEFAULT_TAG_ID) { 328 652 980
4115 328 ▶ if( inc_words_tag > 0 )
Branch: 1 branch
BranchTrueFalseTotal
if( inc_words_tag > 0 ) 328 0 328
4116 328 av_push(array, newRV_noinc((SV*)get_element_property_deftag_by_id(my_r, mi, " ")));
4117
4118 328 continue;
4119 }
4120
4121 652 av_push(array, newRV_noinc((SV*)get_element_property_by_id(my_r, mi, inc_words_tag)));
4122 }
4123
4124 29 RETVAL = newRV_noinc((SV*)array);
4125
4126 OUTPUT:
4127 RETVAL
4128  
4129 SV*
4130 get_tree_by_element_id(my_r, id, inc_words_tag = 1)
4131 HTML::Content::Extractor my_r;
4132 long id;
4133 int inc_words_tag;
4134
4135 CODE:
4136 0 ▶ if(id > my_r->count || id < 0) {
Branch: 2 branches
BranchTrueFalseTotal
if(id > my_r->count || id < 0) { 0 0 0
if(id > my_r->count || id < 0) { 0 0 0
4137 0 RETVAL = &PL_sv_undef;
4138 }
4139 else {
4140 0 AV* array = newAV();
4141
4142 0 int level = my_r->list[id].inc;
4143
4144 long mi;
4145 0 ▶ for (mi = id + 1; mi <= my_r->count; ++mi) {
Branch: 1 branch
BranchTrueFalseTotal
for (mi = id + 1; mi <= my_r->count; ++mi) { 0 0 0
4146 0 ▶ if(my_r->list[mi].inc <= level)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[mi].inc <= level) 0 0 0
4147 0 break;
4148
4149 0 long my_id = my_r->list[mi].my_id;
4150
4151 0 ▶ if(my_r->list[mi].tag_id == DEFAULT_TAG_ID) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->list[mi].tag_id == DEFAULT_TAG_ID) { 0 0 0
4152 0 ▶ if( inc_words_tag > 0 )
Branch: 1 branch
BranchTrueFalseTotal
if( inc_words_tag > 0 ) 0 0 0
4153 0 av_push(array, newRV_noinc((SV*)get_element_property_deftag_by_id(my_r, mi, " ")));
4154
4155 0 continue;
4156 }
4157
4158 0 av_push(array, newRV_noinc((SV*)get_element_property_by_id(my_r, mi, 1)));
4159 }
4160
4161 0 RETVAL = newRV_noinc((SV*)array);
4162 }
4163
4164 OUTPUT:
4165 RETVAL
4166  
4167 SV*
4168 get_element_by_name_in_child(my_r, name, pos = 0)
4169 HTML::Content::Extractor my_r;
4170 char *name;
4171 long pos;
4172
4173 CODE:
4174 0 struct html_tree *element = get_element_by_name_in_child(my_r, name, pos);
4175 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4176 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4177 }
4178 else {
4179 0 RETVAL = &PL_sv_undef;
4180 }
4181
4182 OUTPUT:
4183 RETVAL
4184  
4185 SV*
4186 get_element_by_name_in_level(my_r, name, pos = 0)
4187 HTML::Content::Extractor my_r;
4188 char *name;
4189 long pos;
4190
4191 CODE:
4192 0 struct html_tree *element = get_element_by_name_in_level(my_r, name, pos);
4193 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4194 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4195 }
4196 else {
4197 0 RETVAL = &PL_sv_undef;
4198 }
4199
4200 OUTPUT:
4201 RETVAL
4202  
4203  
4204 SV*
4205 get_element_by_name(my_r, name, pos = 0)
4206 HTML::Content::Extractor my_r;
4207 char *name;
4208 long pos;
4209
4210 CODE:
4211 0 struct html_tree *element = get_element_by_name(my_r, name, pos);
4212 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4213 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4214 }
4215 else {
4216 0 RETVAL = &PL_sv_undef;
4217 }
4218
4219 OUTPUT:
4220 RETVAL
4221  
4222 SV*
4223 get_stat_by_element_id(my_r, id)
4224 HTML::Content::Extractor my_r;
4225 long id;
4226
4227 CODE:
4228 SV **ha;
4229 0 HV *hash = newHV();
4230
4231 0 ha = hv_store(hash, "count", 5, newSViv(my_r->list[id].count_element), 0);
4232 0 ha = hv_store(hash, "all", 3, newSViv(my_r->list[id].count_element_in), 0);
4233 0 ha = hv_store(hash, "words", 5, newSViv(my_r->list[id].count_word), 0);
4234
4235 0 ha = hv_store(hash, "AI_TEXT", 7, newSViv(my_r->list[id].counts[AI_TEXT]), 0);
4236 0 ha = hv_store(hash, "AI_LINK", 7, newSViv(my_r->list[id].counts[AI_LINK]), 0);
4237 0 ha = hv_store(hash, "AI_IMG" , 6, newSViv(my_r->list[id].counts[AI_IMG]) , 0);
4238
4239 0 ha = hv_store(hash, "all_AI_LINK", 11, newSViv(my_r->list[id].counts_in[AI_TEXT]), 0);
4240 0 ha = hv_store(hash, "all_AI_LINK", 11, newSViv(my_r->list[id].counts_in[AI_LINK]), 0);
4241 0 ha = hv_store(hash, "all_AI_IMG" , 10, newSViv(my_r->list[id].counts_in[AI_IMG]) , 0);
4242
4243 0 RETVAL = newRV_noinc((SV*)hash);
4244 OUTPUT:
4245 RETVAL
4246  
4247 SV*
4248 get_tag_info_by_name(my_r, tag_name)
4249 HTML::Content::Extractor my_r;
4250 char *tag_name;
4251
4252 CODE:
4253 SV **ha;
4254 0 HV *hash = newHV();
4255
4256 0 int tag_id = get_tag_id(my_r->tags, tag_name);
4257
4258 0 ha = hv_store(hash, "priority", 8, newSViv(my_r->tags->priority[tag_id]), 0);
4259 0 ha = hv_store(hash, "type", 4, newSViv(my_r->tags->type[tag_id]), 0);
4260 0 ha = hv_store(hash, "extra", 5, newSViv(my_r->tags->extra[tag_id]), 0);
4261 0 ha = hv_store(hash, "ai", 2, newSViv(my_r->tags->ai[tag_id]), 0);
4262 0 ha = hv_store(hash, "family", 6, newSViv(my_r->tags->family[tag_id]), 0);
4263 0 ha = hv_store(hash, "option" , 6, newSViv(my_r->tags->option[tag_id]) , 0);
4264
4265 0 RETVAL = newRV_noinc((SV*)hash);
4266 OUTPUT:
4267 RETVAL
4268  
4269  
4270 SV*
4271 get_child(my_r, pos)
4272 HTML::Content::Extractor my_r;
4273 long pos;
4274
4275 CODE:
4276 0 struct html_tree *element = get_child(my_r, pos);
4277 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4278 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4279 }
4280 else {
4281 0 RETVAL = &PL_sv_undef;
4282 }
4283
4284 OUTPUT:
4285 RETVAL
4286  
4287 SV*
4288 get_parent(my_r)
4289 HTML::Content::Extractor my_r;
4290
4291 CODE:
4292 0 struct html_tree *element = get_parent(my_r);
4293 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4294 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4295 }
4296 else {
4297 0 RETVAL = &PL_sv_undef;
4298 }
4299
4300 OUTPUT:
4301 RETVAL
4302  
4303 SV*
4304 get_curr_element(my_r)
4305 HTML::Content::Extractor my_r;
4306
4307 CODE:
4308 0 struct html_tree *element = get_curr_element(my_r);
4309 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4310 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4311 }
4312 else {
4313 0 RETVAL = &PL_sv_undef;
4314 }
4315
4316 OUTPUT:
4317 RETVAL
4318  
4319 SV*
4320 get_prev_element(my_r)
4321 HTML::Content::Extractor my_r;
4322
4323 CODE:
4324 0 struct html_tree *element = get_prev_element(my_r);
4325 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4326 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4327 }
4328 else {
4329 0 RETVAL = &PL_sv_undef;
4330 }
4331
4332 OUTPUT:
4333 RETVAL
4334  
4335 SV*
4336 get_next_element_curr_level(my_r)
4337 HTML::Content::Extractor my_r;
4338
4339 CODE:
4340 0 struct html_tree *element = get_next_element_curr_level(my_r);
4341 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4342 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4343 }
4344 else {
4345 0 RETVAL = &PL_sv_undef;
4346 }
4347
4348 OUTPUT:
4349 RETVAL
4350  
4351 SV*
4352 get_prev_element_curr_level(my_r)
4353 HTML::Content::Extractor my_r;
4354
4355 CODE:
4356 0 struct html_tree *element = get_prev_element_curr_level(my_r);
4357 0 ▶ if(element != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(element != NULL) { 0 0 0
4358 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, element->id, 1));
4359 }
4360 else {
4361 0 RETVAL = &PL_sv_undef;
4362 }
4363
4364 OUTPUT:
4365 RETVAL
4366  
4367 SV*
4368 set_position(my_r, hashref)
4369 HTML::Content::Extractor my_r;
4370 SV *hashref;
4371
4372 CODE:
4373 0 HV *myhash = (HV *)SvRV(hashref);
4374 0 SV **svp = hv_fetch(myhash, "id", 2, 0);
4375 0 int el_id = SvNV(*svp);
4376
4377 0 ▶ if(set_position(my_r, &my_r->list[el_id]) != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if(set_position(my_r, &my_r->list[el_id]) != -1) { 0 0 0
4378 0 RETVAL = newRV_noinc((SV*)get_element_property_by_id(my_r, el_id, 1));
4379 }
4380 else {
4381 0 RETVAL = &PL_sv_undef;
4382 }
4383
4384 OUTPUT:
4385 RETVAL
4386  
4387 SV*
4388 check_html_with_all_text(my_r)
4389 HTML::Content::Extractor my_r;
4390
4391 CODE:
4392 0 struct max_element_list max_list = {-1, 1024};
4393 0 max_list.elements = (struct max_element *)malloc(sizeof(struct max_element) * max_list.lelements_size);
4394
4395 0 check_html_with_all_text(my_r, &max_list);
4396
4397 0 AV* array = newAV();
4398 SV **ha;
4399
4400 long i;
4401 0 ▶ for (i = 0; i <= max_list.lelements; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= max_list.lelements; i++) { 0 0 0
4402 0 set_position(my_r, max_list.elements[i].element);
4403
4404 0 struct lbuffer main_buff = {-1, 1024 * 1024, NULL};
4405 0 get_text_without_element(my_r, &main_buff);
4406 0 clean_text(my_r->entities, &main_buff);
4407
4408 0 HV *hash = newHV();
4409
4410 0 ha = hv_store(hash, "text", 4, newSVpv(main_buff.buff, 0), 0);
4411 0 ha = hv_store(hash, "element", 7, newRV_noinc((SV*)get_element_property_by_id(my_r, max_list.elements[i].element->id, 1)), 0);
4412
4413 0 av_push(array, newRV_noinc((SV*)hash));
4414
4415 0 free(main_buff.buff);
4416 }
4417
4418 0 free(max_list.elements);
4419
4420 0 RETVAL = newRV_noinc((SV*)array);
4421
4422 OUTPUT:
4423 RETVAL
4424  
4425 SV*
4426 set_tag_ai(my_r, tagname, value)
4427 HTML::Content::Extractor my_r;
4428 char *tagname;
4429 int value;
4430
4431 CODE:
4432 0 RETVAL = newSViv( set_tag_ai(my_r->tags, tagname, value) );
4433 OUTPUT:
4434 RETVAL
4435  
4436 SV*
4437 set_tag_type(my_r, tagname, value)
4438 HTML::Content::Extractor my_r;
4439 char *tagname;
4440 int value;
4441
4442 CODE:
4443 0 RETVAL = newSViv( set_tag_type(my_r->tags, tagname, value) );
4444 OUTPUT:
4445 RETVAL
4446  
4447 SV*
4448 set_tag_extra(my_r, tagname, value)
4449 HTML::Content::Extractor my_r;
4450 char *tagname;
4451 int value;
4452
4453 CODE:
4454 0 RETVAL = newSViv( set_tag_extra(my_r->tags, tagname, value) );
4455 OUTPUT:
4456 RETVAL
4457  
4458 SV*
4459 set_tag_family(my_r, tagname, value)
4460 HTML::Content::Extractor my_r;
4461 char *tagname;
4462 int value;
4463
4464 CODE:
4465 0 RETVAL = newSViv( set_tag_family(my_r->tags, tagname, value) );
4466 OUTPUT:
4467 RETVAL
4468  
4469 SV*
4470 set_tag_option(my_r, tagname, value)
4471 HTML::Content::Extractor my_r;
4472 char *tagname;
4473 int value;
4474
4475 CODE:
4476 0 RETVAL = newSViv( set_tag_option(my_r->tags, tagname, value) );
4477 OUTPUT:
4478 RETVAL
4479  
4480 SV*
4481 set_tag_priority(my_r, tagname, value)
4482 HTML::Content::Extractor my_r;
4483 char *tagname;
4484 int value;
4485
4486 CODE:
4487 0 RETVAL = newSViv( set_tag_priority(my_r->tags, tagname, value) );
4488 OUTPUT:
4489 RETVAL
4490  
4491  
4492 SV*
4493 AI_NULL()
4494 CODE:
4495 0 RETVAL = newSViv(AI_NULL);
4496 OUTPUT:
4497 RETVAL
4498  
4499 SV*
4500 AI_TEXT()
4501 CODE:
4502 0 RETVAL = newSViv(AI_TEXT);
4503 OUTPUT:
4504 RETVAL
4505  
4506 SV*
4507 AI_LINK()
4508 CODE:
4509 0 RETVAL = newSViv(AI_LINK);
4510 OUTPUT:
4511 RETVAL
4512  
4513 SV*
4514 AI_IMG()
4515 CODE:
4516 0 RETVAL = newSViv(AI_IMG);
4517 OUTPUT:
4518 RETVAL
4519  
4520  
4521 SV*
4522 TYPE_TAG_NORMAL()
4523 CODE:
4524 0 RETVAL = newSViv(TYPE_TAG_NORMAL);
4525 OUTPUT:
4526 RETVAL
4527  
4528 SV*
4529 TYPE_TAG_BLOCK()
4530 CODE:
4531 0 RETVAL = newSViv(TYPE_TAG_BLOCK);
4532 OUTPUT:
4533 RETVAL
4534  
4535 SV*
4536 TYPE_TAG_INLINE()
4537 CODE:
4538 0 RETVAL = newSViv(TYPE_TAG_INLINE);
4539 OUTPUT:
4540 RETVAL
4541  
4542 SV*
4543 TYPE_TAG_SIMPLE()
4544 CODE:
4545 0 RETVAL = newSViv(TYPE_TAG_SIMPLE);
4546 OUTPUT:
4547 RETVAL
4548  
4549 SV*
4550 TYPE_TAG_SIMPLE_TREE()
4551 CODE:
4552 0 RETVAL = newSViv(TYPE_TAG_SIMPLE_TREE);
4553 OUTPUT:
4554 RETVAL
4555  
4556 SV*
4557 TYPE_TAG_ONE()
4558 CODE:
4559 0 RETVAL = newSViv(TYPE_TAG_ONE);
4560 OUTPUT:
4561 RETVAL
4562  
4563 SV*
4564 TYPE_TAG_TEXT()
4565 CODE:
4566 0 RETVAL = newSViv(TYPE_TAG_TEXT);
4567 OUTPUT:
4568 RETVAL
4569  
4570 SV*
4571 TYPE_TAG_SYS()
4572 CODE:
4573 0 RETVAL = newSViv(TYPE_TAG_SYS);
4574 OUTPUT:
4575 RETVAL
4576  
4577  
4578 SV*
4579 DEFAULT_TAG_ID()
4580 CODE:
4581 0 RETVAL = newSViv(DEFAULT_TAG_ID);
4582 OUTPUT:
4583 RETVAL
4584  
4585  
4586 SV*
4587 EXTRA_TAG_CLOSE_IF_BLOCK()
4588 CODE:
4589 0 RETVAL = newSViv(EXTRA_TAG_CLOSE_IF_BLOCK);
4590 OUTPUT:
4591 RETVAL
4592  
4593 SV*
4594 EXTRA_TAG_CLOSE_IF_SELF()
4595 CODE:
4596 0 RETVAL = newSViv(EXTRA_TAG_CLOSE_IF_SELF);
4597 OUTPUT:
4598 RETVAL
4599  
4600 SV*
4601 EXTRA_TAG_CLOSE_IF_SELF_FAMILY()
4602 CODE:
4603 0 RETVAL = newSViv(EXTRA_TAG_CLOSE_IF_SELF_FAMILY);
4604 OUTPUT:
4605 RETVAL
4606  
4607 SV*
4608 EXTRA_TAG_CLOSE_NOW()
4609 CODE:
4610 0 RETVAL = newSViv(EXTRA_TAG_CLOSE_NOW);
4611 OUTPUT:
4612 RETVAL
4613  
4614 SV*
4615 EXTRA_TAG_SIMPLE()
4616 CODE:
4617 0 RETVAL = newSViv(EXTRA_TAG_SIMPLE);
4618 OUTPUT:
4619 RETVAL
4620  
4621 SV*
4622 EXTRA_TAG_SIMPLE_TREE()
4623 CODE:
4624 0 RETVAL = newSViv(EXTRA_TAG_SIMPLE_TREE);
4625 OUTPUT:
4626 RETVAL
4627  
4628 SV*
4629 EXTRA_TAG_CLOSE_PRIORITY()
4630 CODE:
4631 0 RETVAL = newSViv(EXTRA_TAG_CLOSE_PRIORITY);
4632 OUTPUT:
4633 RETVAL
4634  
4635 SV*
4636 EXTRA_TAG_CLOSE_FAMILY_LIST()
4637 CODE:
4638 0 RETVAL = newSViv(EXTRA_TAG_CLOSE_FAMILY_LIST);
4639 OUTPUT:
4640 RETVAL
4641  
4642 SV*
4643 EXTRA_TAG_CLOSE_PRIORITY_FAMILY()
4644 CODE:
4645 0 RETVAL = newSViv(EXTRA_TAG_CLOSE_PRIORITY_FAMILY);
4646 OUTPUT:
4647 RETVAL
4648  
4649  
4650 SV*
4651 FAMILY_H()
4652 CODE:
4653 0 RETVAL = newSViv(FAMILY_H);
4654 OUTPUT:
4655 RETVAL
4656  
4657 SV*
4658 FAMILY_TABLE()
4659 CODE:
4660 0 RETVAL = newSViv(FAMILY_TABLE);
4661 OUTPUT:
4662 RETVAL
4663  
4664 SV*
4665 FAMILY_LIST()
4666 CODE:
4667 0 RETVAL = newSViv(FAMILY_LIST);
4668 OUTPUT:
4669 RETVAL
4670  
4671 SV*
4672 FAMILY_RUBY()
4673 CODE:
4674 0 RETVAL = newSViv(FAMILY_RUBY);
4675 OUTPUT:
4676 RETVAL
4677  
4678 SV*
4679 FAMILY_SELECT()
4680 CODE:
4681 0 RETVAL = newSViv(FAMILY_SELECT);
4682 OUTPUT:
4683 RETVAL
4684  
4685 SV*
4686 FAMILY_HTML()
4687 CODE:
4688 0 RETVAL = newSViv(FAMILY_HTML);
4689 OUTPUT:
4690 RETVAL
4691  
4692  
4693 SV*
4694 OPTION_NULL()
4695 CODE:
4696 0 RETVAL = newSViv(OPTION_NULL);
4697 OUTPUT:
4698 RETVAL
4699  
4700 SV*
4701 OPTION_CLEAN_TAGS()
4702 CODE:
4703 0 RETVAL = newSViv(OPTION_CLEAN_TAGS);
4704 OUTPUT:
4705 RETVAL
4706  
4707 SV*
4708 OPTION_CLEAN_TAGS_SAVE()
4709 CODE:
4710 0 RETVAL = newSViv(OPTION_CLEAN_TAGS_SAVE);
4711 OUTPUT:
4712 RETVAL
4713  
4714  
4715 void
4716 DESTROY(my_r)
4717 HTML::Content::Extractor my_r;
4718
4719 CODE:
4720 11 my_r->swords = clean_stop_word_params(my_r->swords);
4721
4722 11 clean_tree_entity(my_r->entities);
4723 11 ▶ if(my_r->entities)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->entities) 11 0 11
4724 11 free(my_r->entities);
4725
4726 11 ▶ if(my_r) {
Branch: 1 branch
BranchTrueFalseTotal
if(my_r) { 11 0 11
4727 11 clean_tree(my_r);
4728
4729 11 ▶ if(my_r->tags)
Branch: 1 branch
BranchTrueFalseTotal
if(my_r->tags) 10 1 11
4730 10 free(my_r->tags);
4731
4732 11 free(my_r);
4733 }
↑ Summary blib/lib/HTML/Content/Extractor.pm »