third_party/modest/source/mycss/values/consume.c

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 46 SCAR 0
CC
0
Cov
0%
CRAP 0
« third_party/modest/source/mycss/values/color_parser.c ↑ Summary third_party/modest/source/mycss/values/destroy.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/values/consume.h"
22  
23 0 bool mycss_values_consume_length(mycss_entry_t* entry, mycss_token_t* token)
24 {
25 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_DIMENSION || token->type == MyCSS_TOKEN_TYPE_NUMBER)
Branch: 2 branches
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION || token->type == MyCSS_TOKEN_TYPE_NUMBER) 0 0 0
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION || token->type == MyCSS_TOKEN_TYPE_NUMBER) 0 0 0
26 0 {
27 0 mycss_values_length_t *value = mycss_values_create(entry, sizeof(mycss_values_length_t));
28
29 mycore_string_t str;
30 0 mycss_token_data_to_string(entry, token, &str, true, false);
31
32 double return_num;
33 0 size_t consume_length = mycss_convert_data_to_double(str.data, str.length, &return_num, &value->is_float);
34
35 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_DIMENSION) {
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION) { 0 0 0
36 0 value->type = mycss_units_type_by_name(&str.data[consume_length], (str.length - consume_length));
37 0 mycore_string_destroy(&str, false);
38
39 0 ▶ if(value->type == MyCSS_UNIT_TYPE_UNDEF) {
Branch: 1 branch
BranchTrueFalseTotal
if(value->type == MyCSS_UNIT_TYPE_UNDEF) { 0 0 0
40 0 mycss_values_destroy(entry, value);
41 0 return false;
42 }
43 }
44 else {
45 0 value->type = MyCSS_UNIT_TYPE_UNDEF;
46 0 mycore_string_destroy(&str, false);
47 }
48
49 0 ▶ if(value->is_float)
Branch: 1 branch
BranchTrueFalseTotal
if(value->is_float) 0 0 0
50 0 value->value.f = (float)return_num;
51 else
52 0 value->value.i = (int)return_num;
53
54 0 *entry->values = value;
55 }
56 else
57 0 return false;
58
59 0 return true;
60 }
61  
62 0 bool mycss_values_consume_percentage(mycss_entry_t* entry, mycss_token_t* token)
63 {
64 0 ▶ if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE)
Branch: 1 branch
BranchTrueFalseTotal
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) 0 0 0
65 {
66 0 mycss_values_percentage_t *value = mycss_values_create(entry, sizeof(mycss_values_length_t));
67
68 mycore_string_t str;
69 0 mycss_token_data_to_string(entry, token, &str, true, false);
70
71 double return_num;
72 0 mycss_convert_data_to_double(str.data, str.length, &return_num, &value->is_float);
73
74 0 mycore_string_destroy(&str, false);
75
76 0 ▶ if(value->is_float)
Branch: 1 branch
BranchTrueFalseTotal
if(value->is_float) 0 0 0
77 0 value->value.f = (float)return_num;
78 else
79 0 value->value.i = (int)return_num;
80
81 0 *entry->values = value;
82
83 0 return true;
84 }
85
86 0 return false;
87 }
88  
89  
90  
« third_party/modest/source/mycss/values/color_parser.c ↑ Summary third_party/modest/source/mycss/values/destroy.c »