third_party/modest/source/modest/finder/match.c

filter: Statementstmt 0.0% 0 / 121 Branchbran 0.0% 0 / 188 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 309 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« third_party/modest/source/modest/finder/finder.c ↑ Summary third_party/modest/source/modest/finder/pseudo_class.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 "modest/finder/match.h"
22  
23 0 bool modest_finder_match_attribute_only_key(myhtml_token_attr_t* attr, const char* key, size_t key_len)
24 {
25 0 ▶ if(key == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(key == NULL) 0 0 0
26 0 return false;
27
28 0 ▶ while (attr)
Branch: 1 branch
BranchTrueFalseTotal
while (attr) 0 0 0
29 {
30 0 ▶ if(attr->key.length == key_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->key.length == key_len) { 0 0 0
31 0 ▶ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(key, attr->key.data, key_len) == 0) 0 0 0
32 0 return true;
33 }
34
35 0 attr = attr->next;
36 }
37
38 0 return false;
39 }
40  
41 0 bool modest_finder_match_attribute_eq(myhtml_token_attr_t* attr, const char* key, size_t key_len, const char* value, size_t value_len, bool case_sensitive)
42 {
43 0 ▶ if(key == NULL || value == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if(key == NULL || value == NULL) 0 0 0
if(key == NULL || value == NULL) 0 0 0
44 0 return false;
45
46 0 ▶ while (attr)
Branch: 1 branch
BranchTrueFalseTotal
while (attr) 0 0 0
47 {
48 0 ▶ if(attr->key.length == key_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->key.length == key_len) { 0 0 0
49 0 ▶ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(key, attr->key.data, key_len) == 0) 0 0 0
50 {
51 0 ▶ if(attr->value.length == value_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.length == value_len) { 0 0 0
52 0 ▶ if(case_sensitive) {
Branch: 1 branch
BranchTrueFalseTotal
if(case_sensitive) { 0 0 0
53 0 ▶ if(strncmp(value, attr->value.data, value_len) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(strncmp(value, attr->value.data, value_len) == 0) { 0 0 0
54 0 return true;
55 }
56 }
57 else {
58 0 ▶ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) { 0 0 0
59 0 return true;
60 }
61 }
62 }
63
64 0 break;
65 }
66 }
67
68 0 attr = attr->next;
69 }
70
71 0 return false;
72 }
73  
74 0 bool modest_finder_match_attribute_ws(myhtml_token_attr_t* attr, const char* key, size_t key_len, const char* value, size_t value_len, bool case_sensitive)
75 {
76 0 ▶ if(key == NULL || value == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if(key == NULL || value == NULL) 0 0 0
if(key == NULL || value == NULL) 0 0 0
77 0 return false;
78
79 0 ▶ while (attr)
Branch: 1 branch
BranchTrueFalseTotal
while (attr) 0 0 0
80 {
81 0 ▶ if(attr->key.length == key_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->key.length == key_len) { 0 0 0
82 0 ▶ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(key, attr->key.data, key_len) == 0) 0 0 0
83 {
84 0 size_t i = 0;
85 size_t begin;
86
87 0 ▶ if(attr->value.length >= value_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.length >= value_len) { 0 0 0
88 0 ▶ if(case_sensitive)
Branch: 1 branch
BranchTrueFalseTotal
if(case_sensitive) 0 0 0
89 {
90 0 ▶ while(i < attr->value.length)
Branch: 1 branch
BranchTrueFalseTotal
while(i < attr->value.length) 0 0 0
91 {
92 0 begin = i;
93 0 ▶ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;}
Branch: 6 branches
BranchTrueFalseTotal
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
94
95 0 ▶ if((i - begin) == value_len && (mycore_strncmp(value, &attr->value.data[begin], value_len) == 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if((i - begin) == value_len && (mycore_strncmp(value, &attr->value.data[begin], value_len) == 0)) { 0 0 0
if((i - begin) == value_len && (mycore_strncmp(value, &attr->value.data[begin], value_len) == 0)) { 0 0 0
96 0 return true;
97 }
98 /* skip all ws */
99 0 ▶ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;}
Branch: 6 branches
BranchTrueFalseTotal
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
100 }
101 }
102 else {
103 0 ▶ while(i < attr->value.length)
Branch: 1 branch
BranchTrueFalseTotal
while(i < attr->value.length) 0 0 0
104 {
105 0 begin = i;
106 0 ▶ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;}
Branch: 6 branches
BranchTrueFalseTotal
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;} 0 0 0
107
108 0 ▶ if((i - begin) == value_len && (mycore_strncasecmp(value, &attr->value.data[begin], value_len) == 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if((i - begin) == value_len && (mycore_strncasecmp(value, &attr->value.data[begin], value_len) == 0)) { 0 0 0
if((i - begin) == value_len && (mycore_strncasecmp(value, &attr->value.data[begin], value_len) == 0)) { 0 0 0
109 0 return true;
110 }
111 /* skip all ws */
112 0 ▶ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;}
Branch: 6 branches
BranchTrueFalseTotal
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;} 0 0 0
113 }
114 }
115 }
116
117 0 break;
118 }
119 }
120
121 0 attr = attr->next;
122 }
123
124 0 return false;
125 }
126  
127 0 bool modest_finder_match_attribute_begin(myhtml_token_attr_t* attr, const char* key, size_t key_len, const char* value, size_t value_len, bool case_sensitive)
128 {
129 0 ▶ if(key == NULL || value == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if(key == NULL || value == NULL) 0 0 0
if(key == NULL || value == NULL) 0 0 0
130 0 return false;
131
132 0 ▶ while (attr)
Branch: 1 branch
BranchTrueFalseTotal
while (attr) 0 0 0
133 {
134 0 ▶ if(attr->key.length == key_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->key.length == key_len) { 0 0 0
135 0 ▶ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(key, attr->key.data, key_len) == 0) 0 0 0
136 {
137 0 ▶ if(attr->value.length >= value_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.length >= value_len) { 0 0 0
138 0 ▶ if(case_sensitive) {
Branch: 1 branch
BranchTrueFalseTotal
if(case_sensitive) { 0 0 0
139 0 ▶ if(mycore_strncmp(value, attr->value.data, value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncmp(value, attr->value.data, value_len) == 0) 0 0 0
140 0 return true;
141 }
142 else {
143 0 ▶ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) 0 0 0
144 0 return true;
145 }
146 }
147
148 0 break;
149 }
150 }
151
152 0 attr = attr->next;
153 }
154
155 0 return false;
156 }
157  
158 0 bool modest_finder_match_attribute_end(myhtml_token_attr_t* attr, const char* key, size_t key_len, const char* value, size_t value_len, bool case_sensitive)
159 {
160 0 ▶ if(key == NULL || value == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if(key == NULL || value == NULL) 0 0 0
if(key == NULL || value == NULL) 0 0 0
161 0 return false;
162
163 0 ▶ while (attr)
Branch: 1 branch
BranchTrueFalseTotal
while (attr) 0 0 0
164 {
165 0 ▶ if(attr->key.length == key_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->key.length == key_len) { 0 0 0
166 0 ▶ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(key, attr->key.data, key_len) == 0) 0 0 0
167 {
168 0 ▶ if(attr->value.length >= value_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.length >= value_len) { 0 0 0
169 0 ▶ if(case_sensitive) {
Branch: 1 branch
BranchTrueFalseTotal
if(case_sensitive) { 0 0 0
170 0 ▶ if(mycore_strncmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0) 0 0 0
171 0 return true;
172 }
173 else {
174 0 ▶ if(mycore_strncasecmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0) 0 0 0
175 0 return true;
176 }
177 }
178
179 0 break;
180 }
181 }
182
183 0 attr = attr->next;
184 }
185
186 0 return false;
187 }
188  
189 0 bool modest_finder_match_attribute_sub(myhtml_token_attr_t* attr, const char* key, size_t key_len, const char* value, size_t value_len, bool case_sensitive)
190 {
191 0 ▶ if(key == NULL || value == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if(key == NULL || value == NULL) 0 0 0
if(key == NULL || value == NULL) 0 0 0
192 0 return false;
193
194 0 ▶ while (attr)
Branch: 1 branch
BranchTrueFalseTotal
while (attr) 0 0 0
195 {
196 0 ▶ if(attr->key.length == key_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->key.length == key_len) { 0 0 0
197 0 ▶ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(key, attr->key.data, key_len) == 0) 0 0 0
198 {
199 0 ▶ if(attr->value.length >= value_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.length >= value_len) { 0 0 0
200 0 size_t i = 0;
201
202 0 ▶ if(case_sensitive)
Branch: 1 branch
BranchTrueFalseTotal
if(case_sensitive) 0 0 0
203 {
204 0 ▶ while ((i + value_len) <= attr->value.length)
Branch: 1 branch
BranchTrueFalseTotal
while ((i + value_len) <= attr->value.length) 0 0 0
205 {
206 0 ▶ if(mycore_strncmp(value, &attr->value.data[i], value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncmp(value, &attr->value.data[i], value_len) == 0) 0 0 0
207 0 return true;
208
209 0 i++;
210 }
211 }
212 else {
213 0 ▶ while ((i + value_len) <= attr->value.length)
Branch: 1 branch
BranchTrueFalseTotal
while ((i + value_len) <= attr->value.length) 0 0 0
214 {
215 0 ▶ if(mycore_strncasecmp(value, &attr->value.data[i], value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(value, &attr->value.data[i], value_len) == 0) 0 0 0
216 0 return true;
217
218 0 i++;
219 }
220 }
221 }
222
223 0 break;
224 }
225 }
226
227 0 attr = attr->next;
228 }
229
230 0 return false;
231 }
232  
233 0 bool modest_finder_match_attribute_hsp(myhtml_token_attr_t* attr, const char* key, size_t key_len, const char* value, size_t value_len, bool case_sensitive)
234 {
235 0 ▶ if(key == NULL || value == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if(key == NULL || value == NULL) 0 0 0
if(key == NULL || value == NULL) 0 0 0
236 0 return false;
237
238 0 ▶ while (attr)
Branch: 1 branch
BranchTrueFalseTotal
while (attr) 0 0 0
239 {
240 0 ▶ if(attr->key.length == key_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->key.length == key_len) { 0 0 0
241 0 ▶ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(key, attr->key.data, key_len) == 0) 0 0 0
242 {
243 0 ▶ if(attr->value.length == value_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.length == value_len) { 0 0 0
244 0 ▶ if(case_sensitive) {
Branch: 1 branch
BranchTrueFalseTotal
if(case_sensitive) { 0 0 0
245 0 ▶ if(mycore_strncmp(value, attr->value.data, value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncmp(value, attr->value.data, value_len) == 0) 0 0 0
246 0 return true;
247 }
248 else {
249 0 ▶ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) 0 0 0
250 0 return true;
251 }
252 }
253 0 ▶ else if(attr->value.length > value_len) {
Branch: 1 branch
BranchTrueFalseTotal
else if(attr->value.length > value_len) { 0 0 0
254 0 ▶ if(case_sensitive) {
Branch: 1 branch
BranchTrueFalseTotal
if(case_sensitive) { 0 0 0
255 0 ▶ if(mycore_strncmp(value, attr->value.data, value_len) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncmp(value, attr->value.data, value_len) == 0) { 0 0 0
256 0 ▶ if(attr->value.data[value_len] == '-')
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.data[value_len] == '-') 0 0 0
257 0 return true;
258 }
259 }
260 else {
261 0 ▶ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) { 0 0 0
262 0 ▶ if(attr->value.data[value_len] == '-')
Branch: 1 branch
BranchTrueFalseTotal
if(attr->value.data[value_len] == '-') 0 0 0
263 0 return true;
264 }
265 }
266 }
267
268 0 break;
269 }
270 }
271
272 0 attr = attr->next;
273 }
274
275 0 return false;
276 }
277  
278  
« third_party/modest/source/modest/finder/finder.c ↑ Summary third_party/modest/source/modest/finder/pseudo_class.c »