third_party/modest/source/myhtml/charef.c

filter: Statementstmt 32.8% 22 / 67 Branchbran 27.2% 12 / 44 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 30.6% 34 / 111 SCAR 0
CC
0
Cov
0%
CRAP 0
« third_party/modest/source/myhtml/data_process.c ↑ Summary third_party/modest/source/modest/finder/type.c »
1 /*
2 Copyright (C) 2015-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 "myhtml/charef.h"
22 #include "myhtml/charef_resource.h"
23  
24 0 const charef_entry_t * myhtml_charef_find(const char *begin, size_t *offset, size_t size, size_t *data_size)
25 {
26 0 unsigned const char* u_begin = (unsigned const char*)begin;
27 0 size_t pos = (size_t)(*u_begin);
28
29 0 ▶ while (named_character_references[pos].ch)
Branch: 1 branch
BranchTrueFalseTotal
while (named_character_references[pos].ch) 0 0 0
30 {
31 0 ▶ if(named_character_references[pos].ch == u_begin[*offset])
Branch: 1 branch
BranchTrueFalseTotal
if(named_character_references[pos].ch == u_begin[*offset]) 0 0 0
32 {
33 0 (*offset)++;
34
35 0 ▶ if(named_character_references[pos].next == 0 || *offset >= size) {
Branch: 2 branches
BranchTrueFalseTotal
if(named_character_references[pos].next == 0 || *offset >= size) { 0 0 0
if(named_character_references[pos].next == 0 || *offset >= size) { 0 0 0
36 0 ▶ if(data_size)
Branch: 1 branch
BranchTrueFalseTotal
if(data_size) 0 0 0
37 0 *data_size = named_character_references[pos].codepoints_len;
38
39 0 return &named_character_references[pos];
40 }
41
42 0 pos = named_character_references[pos].next;
43 }
44 0 ▶ else if(u_begin[*offset] > named_character_references[pos].ch) {
Branch: 1 branch
BranchTrueFalseTotal
else if(u_begin[*offset] > named_character_references[pos].ch) { 0 0 0
45 0 pos++;
46 }
47 else {
48 0 break;
49 }
50 }
51
52 0 ▶ if(data_size)
Branch: 1 branch
BranchTrueFalseTotal
if(data_size) 0 0 0
53 0 *data_size = named_character_references[pos].codepoints_len;
54
55 0 return &named_character_references[pos];
56 }
57  
58 128 const charef_entry_t * myhtml_charef_get_first_position(const char begin)
59 {
60 128 return &named_character_references[ (unsigned const char)begin ];
61 }
62  
63 128 const charef_entry_t * myhtml_charef_find_by_pos(size_t pos, const char *begin, size_t *offset, size_t size, charef_entry_result_t *result)
64 {
65 128 unsigned const char* u_begin = (unsigned const char*)begin;
66
67 128 ▶ if(u_begin[*offset] == '&') {
Branch: 1 branch
BranchTrueFalseTotal
if(u_begin[*offset] == '&') { 0 128 128
68 0 result->is_done = 1;
69
70 0 ▶ if(result->curr_entry->codepoints_len)
Branch: 1 branch
BranchTrueFalseTotal
if(result->curr_entry->codepoints_len) 0 0 0
71 0 return result->curr_entry;
72 0 ▶ else if(result->last_entry) {
Branch: 1 branch
BranchTrueFalseTotal
else if(result->last_entry) { 0 0 0
73 0 *offset = result->last_offset;
74 0 return result->last_entry;
75 }
76
77 0 return &named_character_references[0];
78 }
79
80 128 result->is_done = 0;
81
82 1888 ▶ while (named_character_references[pos].ch)
Branch: 1 branch
BranchTrueFalseTotal
while (named_character_references[pos].ch) 1888 0 1888
83 {
84 1888 ▶ if(named_character_references[pos].ch == u_begin[*offset])
Branch: 1 branch
BranchTrueFalseTotal
if(named_character_references[pos].ch == u_begin[*offset]) 384 1504 1888
85 {
86 384 ▶ if(u_begin[*offset] == ';') {
Branch: 1 branch
BranchTrueFalseTotal
if(u_begin[*offset] == ';') { 128 256 384
87 128 result->is_done = 1;
88
89 128 result->curr_entry = &named_character_references[pos];
90 128 return result->curr_entry;
91 }
92
93 256 (*offset)++;
94
95 256 ▶ if(named_character_references[pos].next == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(named_character_references[pos].next == 0) { 0 256 256
96 0 result->is_done = 1;
97 0 return &named_character_references[pos];
98 }
99
100 256 ▶ if(*offset >= size)
Branch: 1 branch
BranchTrueFalseTotal
if(*offset >= size) 0 256 256
101 {
102 0 result->curr_entry = &named_character_references[pos];
103
104 0 ▶ if(named_character_references[pos].codepoints_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(named_character_references[pos].codepoints_len) { 0 0 0
105 0 result->last_offset = *offset;
106 0 result->last_entry = &named_character_references[pos];
107 }
108
109 0 return result->curr_entry;
110 }
111
112 256 ▶ if(u_begin[*offset] == '&') {
Branch: 1 branch
BranchTrueFalseTotal
if(u_begin[*offset] == '&') { 0 256 256
113 0 result->is_done = 1;
114 0 result->curr_entry = &named_character_references[pos];
115
116 0 ▶ if(result->curr_entry->codepoints_len)
Branch: 1 branch
BranchTrueFalseTotal
if(result->curr_entry->codepoints_len) 0 0 0
117 0 return result->curr_entry;
118 0 ▶ else if(result->last_entry) {
Branch: 1 branch
BranchTrueFalseTotal
else if(result->last_entry) { 0 0 0
119 0 *offset = result->last_offset;
120 0 return result->last_entry;
121 }
122
123 0 return &named_character_references[0];
124 }
125
126 256 ▶ if(named_character_references[pos].codepoints_len) {
Branch: 1 branch
BranchTrueFalseTotal
if(named_character_references[pos].codepoints_len) { 128 128 256
127 128 result->last_offset = *offset;
128 128 result->last_entry = &named_character_references[pos];
129 }
130
131 256 pos = named_character_references[pos].next;
132 }
133 1504 ▶ else if(u_begin[*offset] > named_character_references[pos].ch) {
Branch: 1 branch
BranchTrueFalseTotal
else if(u_begin[*offset] > named_character_references[pos].ch) { 1504 0 1504
134 1504 pos++;
135 }
136 else {
137 0 break;
138 }
139 }
140
141 0 result->is_done = 1;
142
143 0 ▶ if(result->last_entry) {
Branch: 1 branch
BranchTrueFalseTotal
if(result->last_entry) { 0 0 0
144 0 *offset = result->last_offset;
145 0 return result->last_entry;
146 }
147
148 0 return &named_character_references[0];
149 }
150  
151  
« third_party/modest/source/myhtml/data_process.c ↑ Summary third_party/modest/source/modest/finder/type.c »