third_party/modest/source/mycss/selectors/pseudo.c

filter: Statementstmt 72.0% 18 / 25 Branchbran 50.0% 7 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 64.1% 25 / 39 SCAR 0
CC
0
Cov
0%
CRAP 0
« third_party/modest/source/myencoding/detect.c ↑ Summary third_party/modest/source/mycore/utils/mcsimple.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/selectors/pseudo.h"
22 #include "mycss/selectors/pseudo_resource.h"
23 #include "mycore/utils/resources.h"
24  
25 /////////////////////////////////////////////////////////
26 //// Functions for a find Begin Function
27 ////
28 /////////////////////////////////////////////////////////
29 7 const mycss_selectots_pseudo_begin_entry_t * mycss_pseudo_begin_entry_by_name(const char* name, size_t length, size_t static_size, const mycss_selectots_pseudo_begin_entry_t* pseudo)
30 {
31 7 size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
32 7 mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
33 length)
34 7 % static_size) + 1;
35
36 7 ▶ while (pseudo[idx].name)
Branch: 1 branch
BranchTrueFalseTotal
while (pseudo[idx].name) 5 2 7
37 {
38 5 ▶ if(pseudo[idx].length == length) {
Branch: 1 branch
BranchTrueFalseTotal
if(pseudo[idx].length == length) { 5 0 5
39 5 ▶ if(mycore_strncasecmp(pseudo[idx].name, name, length) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if(mycore_strncasecmp(pseudo[idx].name, name, length) == 0) 5 0 5
40 5 return &pseudo[idx];
41
42 0 ▶ if(pseudo[idx].next)
Branch: 1 branch
BranchTrueFalseTotal
if(pseudo[idx].next) 0 0 0
43 0 idx = pseudo[idx].next;
44 else
45 0 return NULL;
46 }
47 0 ▶ else if(pseudo[idx].length > length) {
Branch: 1 branch
BranchTrueFalseTotal
else if(pseudo[idx].length > length) { 0 0 0
48 0 return NULL;
49 }
50 else {
51 0 idx = pseudo[idx].next;
52 }
53 }
54
55 2 return NULL;
56 }
57  
58 4 mycss_selectors_sub_type_pseudo_class_t mycss_pseudo_class_by_name(const char *name, size_t length)
59 {
60 4 const mycss_selectots_pseudo_begin_entry_t *entry = mycss_pseudo_begin_entry_by_name(name, length, MyCSS_SELECTORS_PSEUDO_CLASS_NAME_STATIC_SIZE, mycss_selectors_pseudo_class_begin_map_index);
61
62 4 ▶ if(entry)
Branch: 1 branch
BranchTrueFalseTotal
if(entry) 2 2 4
63 2 return entry->sub_type;
64
65 2 return MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_UNKNOWN;
66 }
67  
68 3 mycss_selectors_sub_type_pseudo_element_t mycss_pseudo_element_by_name(const char *name, size_t length)
69 {
70 3 const mycss_selectots_pseudo_begin_entry_t *entry = mycss_pseudo_begin_entry_by_name(name, length, MyCSS_SELECTORS_PSEUDO_ELEMENT_NAME_STATIC_SIZE, mycss_selectors_pseudo_element_begin_map_index);
71
72 3 ▶ if(entry)
Branch: 1 branch
BranchTrueFalseTotal
if(entry) 3 0 3
73 3 return entry->sub_type;
74
75 0 return MyCSS_SELECTORS_SUB_TYPE_PSEUDO_ELEMENT_UNKNOWN;
76 }
77  
78  
« third_party/modest/source/myencoding/detect.c ↑ Summary third_party/modest/source/mycore/utils/mcsimple.c »