third_party/modest/source/mycss/property/parser_text_decoration.c

filter: Statementstmt 0.0% 0 / 203 Branchbran 0.0% 0 / 116 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 319 SCAR 0
CC
0
Cov
0%
CRAP 0
« third_party/modest/source/mycss/property/parser_image.c ↑ Summary third_party/modest/source/mycss/property/parser_url.c »
1 /*
2 Copyright (C) 2016-2017 Alexander Borisov
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18 Author: lex.borisov@gmail.com (Alexander Borisov)
19 */
20  
21 #include "mycss/property/parser.h"
22  
23 0 static void mycss_property_parser_text_decoration_parser_switch(mycss_entry_t* entry)
24 {
25 0 mycss_stack_entry_t *stack_entry = mycss_stack_pop(entry->declaration->stack);
26
27 0 ▶ if(stack_entry->value)
Branch: 1 branch
BranchTrueFalseTotal
if(stack_entry->value) 0 0 0
28 0 entry->declaration->entry_last = stack_entry->value;
29
30 0 entry->parser = stack_entry->parser;
31 0 }
32  
33 0 void * mycss_property_destroy_text_decoration(mycss_entry_t* entry, void* value)
34 {
35 0 ▶ if(value == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(value == NULL) 0 0 0
36 0 return NULL;
37
38 0 mycss_values_text_decoration_t *text_decoration = (mycss_values_text_decoration_t*)value;
39
40 0 ▶ if(text_decoration->color)
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration->color) 0 0 0
41 0 text_decoration->color = mycss_declaration_entry_destroy(entry->declaration, text_decoration->color, true);
42
43 0 ▶ if(text_decoration->line)
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration->line) 0 0 0
44 0 text_decoration->color = mycss_declaration_entry_destroy(entry->declaration, text_decoration->line, true);
45
46 0 ▶ if(text_decoration->style)
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration->style) 0 0 0
47 0 text_decoration->color = mycss_declaration_entry_destroy(entry->declaration, text_decoration->style, true);
48
49 0 return mycss_values_destroy(entry, text_decoration);
50 }
51  
52 0 bool mycss_property_parser_text_decoration(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
53 {
54 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
55 0 return true;
56
57 0 mycore_string_t str = {0};
58 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
59 mycss_values_text_decoration_t *text_decoration;
60
61 0 ▶ if(dec_entry->value == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if(dec_entry->value == NULL) { 0 0 0
62 0 text_decoration = (mycss_values_text_decoration_t*)mycss_values_create(entry, sizeof(mycss_values_text_decoration_t));
63 0 dec_entry->value = text_decoration;
64
65 0 ▶ if(text_decoration == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration == NULL) 0 0 0
66 0 return mycss_property_shared_switch_to_parse_error(entry);
67 }
68 else {
69 0 text_decoration = (mycss_values_text_decoration_t*)dec_entry->value;
70 }
71
72 0 ▶ if(mycss_property_shared_check_declaration_end(entry, token)) {
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_check_declaration_end(entry, token)) { 0 0 0
73 0 ▶ if(text_decoration &&
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration && 0 0 0
74 0 ▶ text_decoration->color == NULL &&
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->color == NULL && 0 0 0
75 0 ▶ text_decoration->style == NULL &&
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->style == NULL && 0 0 0
76 0 ▶ text_decoration->line == NULL)
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->line == NULL) 0 0 0
77 {
78 0 dec_entry->value = mycss_property_destroy_text_decoration(entry, text_decoration);
79 0 return mycss_property_shared_switch_to_parse_error(entry);
80 }
81
82 0 return true;
83 }
84
85 0 ▶ if(text_decoration == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration == NULL) 0 0 0
86 0 return mycss_property_shared_switch_to_parse_error(entry);
87
88 0 dec_entry->value = text_decoration;
89
90 0 void *value = NULL;
91 0 unsigned int line_value = 0;
92 0 unsigned int value_type = 0;
93 0 bool parser_changed = false;
94
95 0 ▶ if(mycss_property_shared_text_decoration_style(entry, token, &value_type, &str))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_text_decoration_style(entry, token, &value_type, &str)) 0 0 0
96 {
97 0 ▶ if(text_decoration->style) {
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration->style) { 0 0 0
98 0 mycss_property_destroy_text_decoration(entry, text_decoration);
99 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
100 }
101
102 0 text_decoration->style = mycss_declaration_entry_create(entry->declaration, NULL);
103
104 0 text_decoration->style->type = MyCSS_PROPERTY_TYPE_TEXT_DECORATION_STYLE;
105 0 text_decoration->style->value_type = value_type;
106
107 0 return mycss_property_parser_destroy_string(&str, true);
108 }
109 0 ▶ else if(mycss_property_shared_color(entry, token, &value, &value_type, &str, &parser_changed))
Branch: 1 branch
BranchTrueFalseTotal
else if(mycss_property_shared_color(entry, token, &value, &value_type, &str, &parser_changed)) 0 0 0
110 {
111 0 ▶ if(text_decoration->color) {
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration->color) { 0 0 0
112 0 mycss_property_destroy_text_decoration(entry, text_decoration);
113 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
114 }
115
116 0 text_decoration->color = mycss_declaration_entry_create(entry->declaration, NULL);
117
118 0 ▶ if(parser_changed) {
Branch: 1 branch
BranchTrueFalseTotal
if(parser_changed) { 0 0 0
119 0 mycss_stack_push(entry->declaration->stack, dec_entry->value, mycss_property_parser_text_decoration_after_color);
120 0 entry->declaration->entry_last->value = text_decoration->color->value;
121 }
122
123 0 text_decoration->color->value = value;
124 0 text_decoration->color->type = MyCSS_PROPERTY_TYPE_TEXT_DECORATION_COLOR;
125 0 text_decoration->color->value_type = value_type;
126
127 0 return mycss_property_parser_destroy_string(&str, true);
128 }
129 0 ▶ else if(mycss_property_shared_text_decoration_line(entry, token, &line_value, &value_type, &str, true))
Branch: 1 branch
BranchTrueFalseTotal
else if(mycss_property_shared_text_decoration_line(entry, token, &line_value, &value_type, &str, true)) 0 0 0
130 {
131 0 ▶ if(text_decoration->line) {
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration->line) { 0 0 0
132 0 mycss_property_destroy_text_decoration(entry, text_decoration);
133 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
134 }
135
136 0 text_decoration->line = mycss_declaration_entry_create(entry->declaration, NULL);
137 0 text_decoration->line->type = MyCSS_PROPERTY_TYPE_TEXT_DECORATION_LINE;
138
139 0 ▶ if(line_value) {
Branch: 1 branch
BranchTrueFalseTotal
if(line_value) { 0 0 0
140 0 unsigned int *new_value = mycss_values_create(entry, sizeof(unsigned int));
141 0 *new_value = line_value;
142
143 0 text_decoration->line->value = new_value;
144
145 0 mycss_stack_push(entry->declaration->stack, dec_entry, mycss_property_parser_text_decoration_after_line);
146 0 entry->declaration->entry_last = text_decoration->line;
147 }
148 else {
149 0 text_decoration->line->value_type = value_type;
150 }
151
152 0 return mycss_property_parser_destroy_string(&str, true);
153 }
154
155 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
156 }
157  
158 0 bool mycss_property_parser_text_decoration_after_color(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
159 {
160 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
161
162 0 ▶ if(mycss_property_shared_check_declaration_end(entry, token))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_check_declaration_end(entry, token)) 0 0 0
163 {
164 0 mycss_values_text_decoration_t *text_decoration = (mycss_values_text_decoration_t*)dec_entry->value;
165
166 0 ▶ if(text_decoration &&
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration && 0 0 0
167 0 ▶ text_decoration->color == NULL &&
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->color == NULL && 0 0 0
168 0 ▶ text_decoration->style == NULL &&
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->style == NULL && 0 0 0
169 0 ▶ text_decoration->line == NULL)
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->line == NULL) 0 0 0
170 {
171 0 dec_entry->value = mycss_property_destroy_text_decoration(entry, text_decoration);
172 0 return mycss_property_shared_switch_to_parse_error(entry);
173 }
174
175 0 return true;
176 }
177
178 0 entry->parser = mycss_property_parser_text_decoration;
179 0 return false;
180 }
181  
182 0 bool mycss_property_parser_text_decoration_after_line(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
183 {
184 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
185
186 0 ▶ if(mycss_property_shared_check_declaration_end(entry, token))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_check_declaration_end(entry, token)) 0 0 0
187 {
188 0 mycss_values_text_decoration_t *text_decoration = (mycss_values_text_decoration_t*)dec_entry->value;
189
190 0 ▶ if(text_decoration &&
Branch: 1 branch
BranchTrueFalseTotal
if(text_decoration && 0 0 0
191 0 ▶ text_decoration->color == NULL &&
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->color == NULL && 0 0 0
192 0 ▶ text_decoration->style == NULL &&
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->style == NULL && 0 0 0
193 0 ▶ text_decoration->line == NULL)
Branch: 1 branch
BranchTrueFalseTotal
text_decoration->line == NULL) 0 0 0
194 {
195 0 dec_entry->value = mycss_property_destroy_text_decoration(entry, text_decoration);
196 0 return mycss_property_shared_switch_to_parse_error(entry);
197 }
198
199 0 return true;
200 }
201
202 0 entry->parser = mycss_property_parser_text_decoration;
203 0 return false;
204 }
205  
206 0 bool mycss_property_parser_text_decoration_color(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
207 {
208 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
209 0 return true;
210
211 0 mycore_string_t str = {0};
212 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
213
214 0 bool parser_changed = false;
215
216 0 ▶ if(mycss_property_shared_color(entry, token, &dec_entry->value, &dec_entry->value_type, &str, &parser_changed))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_color(entry, token, &dec_entry->value, &dec_entry->value_type, &str, &parser_changed)) 0 0 0
217 {
218 0 ▶ if(parser_changed)
Branch: 1 branch
BranchTrueFalseTotal
if(parser_changed) 0 0 0
219 0 mycss_stack_push(entry->declaration->stack, NULL, mycss_property_parser_text_decoration_color_after);
220
221 0 return mycss_property_parser_destroy_string(&str, true);
222 }
223
224 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
225 }
226  
227 0 bool mycss_property_parser_text_decoration_color_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
228 {
229 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
230 0 return true;
231
232 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
233
234 0 ▶ if(mycss_property_shared_check_declaration_end(entry, token))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_check_declaration_end(entry, token)) 0 0 0
235 0 return true;
236
237 0 dec_entry->value = mycss_values_destroy(entry, dec_entry->value);
238
239 0 return mycss_property_shared_switch_to_parse_error(entry);
240 }
241  
242 0 bool mycss_property_parser_text_decoration_skip(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
243 {
244 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
245 0 return true;
246
247 0 ▶ if(token->type != MyCSS_TOKEN_TYPE_IDENT)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type != MyCSS_TOKEN_TYPE_IDENT) 0 0 0
248 0 return mycss_property_shared_switch_to_parse_error(entry);
249
250 0 mycore_string_t str = {0};
251 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
252
253 0 unsigned int value = 0;
254
255 0 ▶ if(mycss_property_shared_text_decoration_skip(entry, token, &value, &dec_entry->value_type, &str, true)) {
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_text_decoration_skip(entry, token, &value, &dec_entry->value_type, &str, true)) { 0 0 0
256 0 ▶ if(value) {
Branch: 1 branch
BranchTrueFalseTotal
if(value) { 0 0 0
257 0 unsigned int *new_value = mycss_values_create(entry, sizeof(unsigned int));
258 0 *new_value = value;
259
260 0 dec_entry->value = new_value;
261
262 0 mycss_stack_push(entry->declaration->stack, dec_entry, mycss_property_parser_text_decoration_skip_after);
263 }
264
265 0 return mycss_property_parser_destroy_string(&str, true);
266 }
267
268 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
269 }
270  
271 0 bool mycss_property_parser_text_decoration_skip_not_none(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
272 {
273 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
274 0 return true;
275
276 0 ▶ if(token->type != MyCSS_TOKEN_TYPE_IDENT) {
Branch: 1 branch
BranchTrueFalseTotal
if(token->type != MyCSS_TOKEN_TYPE_IDENT) { 0 0 0
277 0 mycss_property_parser_text_decoration_parser_switch(entry);
278 0 return false;
279 }
280
281 0 mycore_string_t str = {0};
282 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
283
284 0 ▶ if(mycss_property_shared_text_decoration_skip(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_text_decoration_skip(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false)) 0 0 0
285 0 return mycss_property_parser_destroy_string(&str, true);
286
287 0 mycss_property_parser_text_decoration_parser_switch(entry);
288 0 return mycss_property_parser_destroy_string(&str, false);
289 }
290  
291 0 bool mycss_property_parser_text_decoration_skip_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
292 {
293 0 ▶ if(mycss_property_shared_check_declaration_end(entry, token))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_check_declaration_end(entry, token)) 0 0 0
294 0 return true;
295
296 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
297
298 0 ▶ if(dec_entry->value)
Branch: 1 branch
BranchTrueFalseTotal
if(dec_entry->value) 0 0 0
299 0 dec_entry->value = mycss_values_destroy(entry, dec_entry->value);
300
301 0 return mycss_property_shared_switch_to_parse_error(entry);
302 }
303  
304 0 bool mycss_property_parser_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
305 {
306 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
307 0 return true;
308
309 0 ▶ if(token->type != MyCSS_TOKEN_TYPE_IDENT)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type != MyCSS_TOKEN_TYPE_IDENT) 0 0 0
310 0 return mycss_property_shared_switch_to_parse_error(entry);
311
312 0 mycore_string_t str = {0};
313 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
314
315 0 ▶ if(mycss_property_shared_text_decoration_style(entry, token, &dec_entry->value_type, &str))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_text_decoration_style(entry, token, &dec_entry->value_type, &str)) 0 0 0
316 0 mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_find_important(entry));
317
318 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
319 }
320  
321 0 bool mycss_property_parser_text_decoration_line(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
322 {
323 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
324 0 return true;
325
326 0 ▶ if(token->type != MyCSS_TOKEN_TYPE_IDENT)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type != MyCSS_TOKEN_TYPE_IDENT) 0 0 0
327 0 return mycss_property_shared_switch_to_parse_error(entry);
328
329 0 mycore_string_t str = {0};
330 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
331
332 0 unsigned int value = 0;
333
334 0 ▶ if(mycss_property_shared_text_decoration_line(entry, token, &value, &dec_entry->value_type, &str, true))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_text_decoration_line(entry, token, &value, &dec_entry->value_type, &str, true)) 0 0 0
335 {
336 0 ▶ if(value) {
Branch: 1 branch
BranchTrueFalseTotal
if(value) { 0 0 0
337 0 unsigned int *new_value = mycss_values_create(entry, sizeof(unsigned int));
338 0 *new_value = value;
339
340 0 dec_entry->value = new_value;
341
342 0 mycss_stack_push(entry->declaration->stack, dec_entry, mycss_property_parser_text_decoration_line_after);
343 }
344
345 0 return mycss_property_parser_destroy_string(&str, true);
346 }
347
348 0 return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
349 }
350  
351 0 bool mycss_property_parser_text_decoration_line_not_none(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
352 {
353 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) 0 0 0
354 0 return true;
355
356 0 ▶ if(token->type != MyCSS_TOKEN_TYPE_IDENT) {
Branch: 1 branch
BranchTrueFalseTotal
if(token->type != MyCSS_TOKEN_TYPE_IDENT) { 0 0 0
357 0 mycss_property_parser_text_decoration_parser_switch(entry);
358 0 return false;
359 }
360
361 0 mycore_string_t str = {0};
362 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
363
364 0 ▶ if(mycss_property_shared_text_decoration_line(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_text_decoration_line(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false)) 0 0 0
365 0 return mycss_property_parser_destroy_string(&str, true);
366
367 0 mycss_property_parser_text_decoration_parser_switch(entry);
368 0 return mycss_property_parser_destroy_string(&str, false);
369 }
370  
371 0 bool mycss_property_parser_text_decoration_line_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
372 {
373 0 ▶ if(mycss_property_shared_check_declaration_end(entry, token))
Branch: 1 branch
BranchTrueFalseTotal
if(mycss_property_shared_check_declaration_end(entry, token)) 0 0 0
374 0 return true;
375
376 0 mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
377
378 0 ▶ if(dec_entry->value)
Branch: 1 branch
BranchTrueFalseTotal
if(dec_entry->value) 0 0 0
379 0 dec_entry->value = mycss_values_destroy(entry, dec_entry->value);
380
381 0 return mycss_property_shared_switch_to_parse_error(entry);
382 }
383  
384  
« third_party/modest/source/mycss/property/parser_image.c ↑ Summary third_party/modest/source/mycss/property/parser_url.c »