| 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/data_process.h" |
| 22 |
|
| #include "mycore/utils/resources.h" |
| 23 |
|
| |
| 24 |
|
| #define MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() \ |
| 25 |
|
| tmp_offset += myhtml_string_before_append_any_preprocessing(str, &data[tmp_offset], (offset - tmp_offset), \ |
| 26 |
|
| proc_entry->tmp_str_pos_proc); \ |
| 27 |
|
| if(offset != tmp_offset) { \ |
| 28 |
|
| if(proc_entry->encoding == MyENCODING_UTF_8) \ |
| 29 |
|
| proc_entry->tmp_str_pos_proc = myhtml_string_append_with_preprocessing(str, &data[tmp_offset], (offset - tmp_offset), \ |
| 30 |
|
| proc_entry->emit_null_char); \ |
| 31 |
|
| else { \ |
| 32 |
|
| proc_entry->tmp_str_pos_proc = \ |
| 33 |
|
| myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res, \ |
| 34 |
|
| &data[tmp_offset], (offset - tmp_offset), \ |
| 35 |
|
| proc_entry->encoding, proc_entry->emit_null_char); \ |
| 36 |
|
| } \ |
| 37 |
|
| } |
| 38 |
|
| |
| 39 |
0 |
| void myhtml_data_process_entry_clean(myhtml_data_process_entry_t* proc_entry) |
| 40 |
|
| { |
| 41 |
0 |
| memset(proc_entry, 0, sizeof(myhtml_data_process_entry_t)); |
| 42 |
0 |
| proc_entry->state = myhtml_data_process_state_data; |
| 43 |
0 |
| } |
| 44 |
|
| |
| 45 |
0 |
| void myhtml_data_process_string_append_char(mycore_string_t* str, const char sm) |
| 46 |
|
| { |
| 47 |
0 |
▶ | MyCORE_STRING_REALLOC_IF_NEED(str, 2, 0); |
Branch: 1 branch
| Branch | True | False | Total |
| MyCORE_STRING_REALLOC_IF_NEED(str, 2, 0); |
0 |
0 |
0 |
|
| 48 |
|
| |
| 49 |
0 |
| str->data[str->length] = sm; |
| 50 |
0 |
| str->length++; |
| 51 |
|
| |
| 52 |
0 |
| str->data[str->length] = '\0'; |
| 53 |
0 |
| } |
| 54 |
|
| |
| 55 |
0 |
| size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size) |
| 56 |
|
| { |
| 57 |
0 |
| size_t tmp_offset = offset; |
| 58 |
|
| |
| 59 |
0 |
▶ | while(offset < size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(offset < size) |
0 |
0 |
0 |
|
| 60 |
|
| { |
| 61 |
0 |
▶ | if(data[offset] == '&') |
Branch: 1 branch
| Branch | True | False | Total |
| if(data[offset] == '&') |
0 |
0 |
0 |
|
| 62 |
|
| { |
| 63 |
0 |
| tmp_offset += myhtml_string_before_append_any_preprocessing(str, &data[tmp_offset], (offset - tmp_offset), |
| 64 |
|
| proc_entry->tmp_str_pos_proc); |
| 65 |
0 |
▶ | if(offset != tmp_offset) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(offset != tmp_offset) { |
0 |
0 |
0 |
|
| 66 |
0 |
▶ | if(proc_entry->encoding == MyENCODING_UTF_8) |
Branch: 1 branch
| Branch | True | False | Total |
| if(proc_entry->encoding == MyENCODING_UTF_8) |
0 |
0 |
0 |
|
| 67 |
0 |
| proc_entry->tmp_str_pos_proc = myhtml_string_append_with_preprocessing(str, &data[tmp_offset], |
| 68 |
|
| (offset - tmp_offset), |
| 69 |
0 |
| proc_entry->emit_null_char); |
| 70 |
|
| else { |
| 71 |
0 |
| proc_entry->tmp_str_pos_proc = |
| 72 |
0 |
| myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res, |
| 73 |
|
| &data[tmp_offset], (offset - tmp_offset), |
| 74 |
0 |
| proc_entry->encoding, proc_entry->emit_null_char); |
| 75 |
0 |
| myencoding_result_clean(&proc_entry->res); |
| 76 |
|
| } |
| 77 |
|
| } |
| 78 |
|
| |
| 79 |
0 |
| proc_entry->tmp_str_pos = str->length; |
| 80 |
0 |
| proc_entry->state = myhtml_data_process_state_ampersand; |
| 81 |
|
| |
| 82 |
0 |
| myhtml_data_process_string_append_char(str, data[offset]); |
| 83 |
|
| |
| 84 |
0 |
| offset++; |
| 85 |
0 |
| return offset; |
| 86 |
|
| } |
| 87 |
|
| |
| 88 |
0 |
| offset++; |
| 89 |
|
| } |
| 90 |
|
| |
| 91 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 92 |
|
| |
| 93 |
0 |
| return offset; |
| 94 |
|
| } |
| 95 |
|
| |
| 96 |
0 |
| size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size) |
| 97 |
|
| { |
| 98 |
0 |
▶ | if(data[offset] == '#') |
Branch: 1 branch
| Branch | True | False | Total |
| if(data[offset] == '#') |
0 |
0 |
0 |
|
| 99 |
|
| { |
| 100 |
0 |
| myhtml_data_process_string_append_char(str, data[offset]); |
| 101 |
0 |
| offset++; |
| 102 |
|
| |
| 103 |
0 |
| proc_entry->tmp_num = 0; |
| 104 |
|
| |
| 105 |
0 |
▶ | if(offset >= size) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(offset >= size) { |
0 |
0 |
0 |
|
| 106 |
0 |
| proc_entry->state = myhtml_data_process_state_ampersand_hash; |
| 107 |
0 |
| return offset; |
| 108 |
|
| } |
| 109 |
|
| |
| 110 |
0 |
▶ | if(data[offset] == 'x' || data[offset] == 'X') { |
Branch: 2 branches
| Branch | True | False | Total |
| if(data[offset] == 'x' || data[offset] == 'X') { |
0 |
0 |
0 |
| if(data[offset] == 'x' || data[offset] == 'X') { |
0 |
0 |
0 |
|
| 111 |
0 |
| myhtml_data_process_string_append_char(str, data[offset]); |
| 112 |
0 |
| offset++; |
| 113 |
|
| |
| 114 |
0 |
| proc_entry->state = myhtml_data_process_state_ampersand_hash_x_data; |
| 115 |
|
| } |
| 116 |
|
| else |
| 117 |
0 |
| proc_entry->state = myhtml_data_process_state_ampersand_hash_data; |
| 118 |
|
| } |
| 119 |
|
| else { |
| 120 |
0 |
| proc_entry->charef_res.last_entry = NULL; |
| 121 |
0 |
| proc_entry->charef_res.curr_entry = myhtml_charef_get_first_position(data[offset]); |
| 122 |
|
| |
| 123 |
0 |
▶ | if(proc_entry->charef_res.curr_entry->ch == '\0') |
Branch: 1 branch
| Branch | True | False | Total |
| if(proc_entry->charef_res.curr_entry->ch == '\0') |
0 |
0 |
0 |
|
| 124 |
0 |
| proc_entry->state = myhtml_data_process_state_data; |
| 125 |
|
| else { |
| 126 |
0 |
| proc_entry->state = myhtml_data_process_state_ampersand_data; |
| 127 |
|
| |
| 128 |
0 |
| myhtml_data_process_string_append_char(str, data[offset]); |
| 129 |
0 |
| offset++; |
| 130 |
|
| } |
| 131 |
|
| } |
| 132 |
|
| |
| 133 |
0 |
| return offset; |
| 134 |
|
| } |
| 135 |
|
| |
| 136 |
0 |
| size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size) |
| 137 |
|
| { |
| 138 |
0 |
| size_t tmp_offset = offset; |
| 139 |
|
| |
| 140 |
0 |
| const charef_entry_t *current_entry = myhtml_charef_find_by_pos(proc_entry->charef_res.curr_entry->next, data, &offset, size, &proc_entry->charef_res); |
| 141 |
|
| |
| 142 |
0 |
▶ | if(proc_entry->charef_res.is_done) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(proc_entry->charef_res.is_done) { |
0 |
0 |
0 |
|
| 143 |
0 |
| proc_entry->state = myhtml_data_process_state_data; |
| 144 |
|
| |
| 145 |
0 |
▶ | if(data[offset] == ';') |
Branch: 1 branch
| Branch | True | False | Total |
| if(data[offset] == ';') |
0 |
0 |
0 |
|
| 146 |
0 |
| offset++; |
| 147 |
|
| else { |
| 148 |
|
| /* if current charef is atrribute */ |
| 149 |
0 |
▶ | if(proc_entry->is_attributes && |
Branch: 1 branch
| Branch | True | False | Total |
| if(proc_entry->is_attributes && |
0 |
0 |
0 |
|
| 150 |
0 |
▶ | (data[offset] == '=' || mycore_string_alphanumeric_character[ (unsigned char)data[offset] ] != 0xff)) |
Branch: 2 branches
| Branch | True | False | Total |
| (data[offset] == '=' || mycore_string_alphanumeric_character[ (unsigned char)data[offset] ] != 0xff)) |
0 |
0 |
0 |
| (data[offset] == '=' || mycore_string_alphanumeric_character[ (unsigned char)data[offset] ] != 0xff)) |
0 |
0 |
0 |
|
| 151 |
|
| { |
| 152 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 153 |
|
| |
| 154 |
0 |
| return offset; |
| 155 |
|
| } |
| 156 |
|
| } |
| 157 |
|
| |
| 158 |
0 |
▶ | if(current_entry->codepoints_len) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(current_entry->codepoints_len) { |
0 |
0 |
0 |
|
| 159 |
0 |
▶ | for (size_t i = 0; i < current_entry->codepoints_len; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (size_t i = 0; i < current_entry->codepoints_len; i++) { |
0 |
0 |
0 |
|
| 160 |
0 |
▶ | MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0); |
Branch: 1 branch
| Branch | True | False | Total |
| MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0); |
0 |
0 |
0 |
|
| 161 |
|
| |
| 162 |
0 |
| proc_entry->tmp_str_pos += myencoding_codepoint_to_ascii_utf_8(current_entry->codepoints[i], &str->data[proc_entry->tmp_str_pos]); |
| 163 |
|
| } |
| 164 |
|
| |
| 165 |
0 |
| str->length = proc_entry->tmp_str_pos; |
| 166 |
0 |
| str->data[str->length] = '\0'; |
| 167 |
|
| } |
| 168 |
|
| else { |
| 169 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 170 |
|
| } |
| 171 |
|
| |
| 172 |
0 |
| proc_entry->charef_res.last_entry = NULL; |
| 173 |
|
| } |
| 174 |
|
| else { |
| 175 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 176 |
|
| } |
| 177 |
|
| |
| 178 |
0 |
| return offset; |
| 179 |
|
| } |
| 180 |
|
| |
| 181 |
0 |
| size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size) |
| 182 |
|
| { |
| 183 |
0 |
▶ | if(data[offset] == 'x' || data[offset] == 'X') { |
Branch: 2 branches
| Branch | True | False | Total |
| if(data[offset] == 'x' || data[offset] == 'X') { |
0 |
0 |
0 |
| if(data[offset] == 'x' || data[offset] == 'X') { |
0 |
0 |
0 |
|
| 184 |
0 |
| myhtml_data_process_string_append_char(str, data[offset]); |
| 185 |
0 |
| offset++; |
| 186 |
|
| |
| 187 |
0 |
| proc_entry->state = myhtml_data_process_state_ampersand_hash_x_data; |
| 188 |
|
| } |
| 189 |
|
| else |
| 190 |
0 |
| proc_entry->state = myhtml_data_process_state_ampersand_hash_data; |
| 191 |
|
| |
| 192 |
0 |
| return offset; |
| 193 |
|
| } |
| 194 |
|
| |
| 195 |
0 |
| size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size) |
| 196 |
|
| { |
| 197 |
0 |
| const unsigned char *u_data = (const unsigned char*)data; |
| 198 |
0 |
| size_t tmp_offset = offset; |
| 199 |
|
| |
| 200 |
0 |
▶ | while(offset < size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(offset < size) |
0 |
0 |
0 |
|
| 201 |
|
| { |
| 202 |
0 |
▶ | if(mycore_string_chars_num_map[ u_data[offset] ] == 0xff) |
Branch: 1 branch
| Branch | True | False | Total |
| if(mycore_string_chars_num_map[ u_data[offset] ] == 0xff) |
0 |
0 |
0 |
|
| 203 |
|
| { |
| 204 |
0 |
| proc_entry->state = myhtml_data_process_state_data; |
| 205 |
|
| |
| 206 |
0 |
▶ | if((offset - tmp_offset) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if((offset - tmp_offset) == 0) { |
0 |
0 |
0 |
|
| 207 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 208 |
|
| |
| 209 |
0 |
| return offset; |
| 210 |
|
| } |
| 211 |
|
| |
| 212 |
0 |
▶ | if(data[offset] == ';') |
Branch: 1 branch
| Branch | True | False | Total |
| if(data[offset] == ';') |
0 |
0 |
0 |
|
| 213 |
0 |
| offset++; |
| 214 |
|
| |
| 215 |
0 |
| myhtml_data_process_state_end(proc_entry, str); |
| 216 |
0 |
| return offset; |
| 217 |
|
| } |
| 218 |
|
| |
| 219 |
0 |
▶ | if(proc_entry->tmp_num <= 0x10FFFF) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(proc_entry->tmp_num <= 0x10FFFF) { |
0 |
0 |
0 |
|
| 220 |
0 |
| proc_entry->tmp_num = mycore_string_chars_num_map[ u_data[offset] ] + proc_entry->tmp_num * 10; |
| 221 |
|
| } |
| 222 |
|
| |
| 223 |
0 |
| offset++; |
| 224 |
|
| } |
| 225 |
|
| |
| 226 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 227 |
|
| |
| 228 |
0 |
| return offset; |
| 229 |
|
| } |
| 230 |
|
| |
| 231 |
0 |
| size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size) |
| 232 |
|
| { |
| 233 |
0 |
| unsigned const char *u_data = (unsigned const char*)data; |
| 234 |
0 |
| size_t tmp_offset = offset; |
| 235 |
|
| |
| 236 |
0 |
▶ | while(offset < size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(offset < size) |
0 |
0 |
0 |
|
| 237 |
|
| { |
| 238 |
0 |
▶ | if(mycore_string_chars_hex_map[ u_data[offset] ] == 0xff) |
Branch: 1 branch
| Branch | True | False | Total |
| if(mycore_string_chars_hex_map[ u_data[offset] ] == 0xff) |
0 |
0 |
0 |
|
| 239 |
|
| { |
| 240 |
0 |
| proc_entry->state = myhtml_data_process_state_data; |
| 241 |
|
| |
| 242 |
0 |
▶ | if((offset - tmp_offset) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if((offset - tmp_offset) == 0) { |
0 |
0 |
0 |
|
| 243 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 244 |
|
| |
| 245 |
0 |
| return offset; |
| 246 |
|
| } |
| 247 |
|
| |
| 248 |
0 |
▶ | if(data[offset] == ';') |
Branch: 1 branch
| Branch | True | False | Total |
| if(data[offset] == ';') |
0 |
0 |
0 |
|
| 249 |
0 |
| offset++; |
| 250 |
|
| |
| 251 |
0 |
| myhtml_data_process_state_end(proc_entry, str); |
| 252 |
0 |
| return offset; |
| 253 |
|
| } |
| 254 |
|
| |
| 255 |
0 |
▶ | if(proc_entry->tmp_num <= 0x10FFFF) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(proc_entry->tmp_num <= 0x10FFFF) { |
0 |
0 |
0 |
|
| 256 |
0 |
| proc_entry->tmp_num <<= 4; |
| 257 |
0 |
| proc_entry->tmp_num |= mycore_string_chars_hex_map[ u_data[offset] ]; |
| 258 |
|
| } |
| 259 |
|
| |
| 260 |
0 |
| offset++; |
| 261 |
|
| } |
| 262 |
|
| |
| 263 |
0 |
▶ | MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
Branch: 2 branches
| Branch | True | False | Total |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
| MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() |
0 |
0 |
0 |
|
| 264 |
|
| |
| 265 |
0 |
| return offset; |
| 266 |
|
| } |
| 267 |
|
| |
| 268 |
0 |
| void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str) |
| 269 |
|
| { |
| 270 |
|
| /* 4 is max utf8 byte + \0 */ |
| 271 |
0 |
▶ | MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0); |
Branch: 1 branch
| Branch | True | False | Total |
| MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0); |
0 |
0 |
0 |
|
| 272 |
|
| |
| 273 |
0 |
▶ | if(proc_entry->tmp_num <= 0x9F) |
Branch: 1 branch
| Branch | True | False | Total |
| if(proc_entry->tmp_num <= 0x9F) |
0 |
0 |
0 |
|
| 274 |
0 |
| proc_entry->tmp_num = replacement_character[proc_entry->tmp_num]; |
| 275 |
0 |
▶ | else if(proc_entry->tmp_num >= 0xD800 && proc_entry->tmp_num <= 0xDFFF) |
Branch: 2 branches
| Branch | True | False | Total |
| else if(proc_entry->tmp_num >= 0xD800 && proc_entry->tmp_num <= 0xDFFF) |
0 |
0 |
0 |
| else if(proc_entry->tmp_num >= 0xD800 && proc_entry->tmp_num <= 0xDFFF) |
0 |
0 |
0 |
|
| 276 |
0 |
| proc_entry->tmp_num = replacement_character[0]; |
| 277 |
0 |
▶ | else if(proc_entry->tmp_num > 0x10FFFF) |
Branch: 1 branch
| Branch | True | False | Total |
| else if(proc_entry->tmp_num > 0x10FFFF) |
0 |
0 |
0 |
|
| 278 |
0 |
| proc_entry->tmp_num = replacement_character[0]; |
| 279 |
|
| |
| 280 |
0 |
| str->length = proc_entry->tmp_str_pos + |
| 281 |
0 |
| myencoding_codepoint_to_ascii_utf_8(proc_entry->tmp_num, &str->data[proc_entry->tmp_str_pos]); |
| 282 |
|
| |
| 283 |
0 |
| str->data[str->length] = '\0'; |
| 284 |
0 |
| } |
| 285 |
|
| |
| 286 |
0 |
| void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t size) |
| 287 |
|
| { |
| 288 |
0 |
| size_t offset = 0; |
| 289 |
|
| |
| 290 |
0 |
▶ | while (offset < size) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (offset < size) { |
0 |
0 |
0 |
|
| 291 |
0 |
| offset = proc_entry->state(proc_entry, str, data, offset, size); |
| 292 |
|
| } |
| 293 |
0 |
| } |
| 294 |
|
| |
| 295 |
0 |
| void myhtml_data_process_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str) |
| 296 |
|
| { |
| 297 |
0 |
▶ | if(proc_entry->state == myhtml_data_process_state_ampersand_data && proc_entry->charef_res.last_entry) |
Branch: 2 branches
| Branch | True | False | Total |
| if(proc_entry->state == myhtml_data_process_state_ampersand_data && proc_entry->charef_res.last_entry) |
0 |
0 |
0 |
| if(proc_entry->state == myhtml_data_process_state_ampersand_data && proc_entry->charef_res.last_entry) |
0 |
0 |
0 |
|
| 298 |
0 |
| { |
| 299 |
0 |
| const charef_entry_t *entry = proc_entry->charef_res.last_entry; |
| 300 |
|
| |
| 301 |
0 |
▶ | for (size_t i = 0; i < entry->codepoints_len; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (size_t i = 0; i < entry->codepoints_len; i++) { |
0 |
0 |
0 |
|
| 302 |
0 |
▶ | MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0); |
Branch: 1 branch
| Branch | True | False | Total |
| MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0); |
0 |
0 |
0 |
|
| 303 |
|
| |
| 304 |
0 |
| proc_entry->tmp_str_pos += myencoding_codepoint_to_ascii_utf_8(entry->codepoints[i], &str->data[proc_entry->tmp_str_pos]); |
| 305 |
|
| } |
| 306 |
|
| |
| 307 |
0 |
| str->length = proc_entry->tmp_str_pos; |
| 308 |
0 |
| str->data[str->length] = '\0'; |
| 309 |
|
| } |
| 310 |
0 |
▶ | else if(proc_entry->state == myhtml_data_process_state_ampersand_hash_data) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(proc_entry->state == myhtml_data_process_state_ampersand_hash_data) { |
0 |
0 |
0 |
|
| 311 |
0 |
▶ | if((str->length - (proc_entry->tmp_str_pos + 2))) |
Branch: 1 branch
| Branch | True | False | Total |
| if((str->length - (proc_entry->tmp_str_pos + 2))) |
0 |
0 |
0 |
|
| 312 |
0 |
| myhtml_data_process_state_end(proc_entry, str); |
| 313 |
|
| } |
| 314 |
0 |
▶ | else if(proc_entry->state == myhtml_data_process_state_ampersand_hash_x_data) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(proc_entry->state == myhtml_data_process_state_ampersand_hash_x_data) { |
0 |
0 |
0 |
|
| 315 |
0 |
▶ | if((str->length - (proc_entry->tmp_str_pos + 3))) |
Branch: 1 branch
| Branch | True | False | Total |
| if((str->length - (proc_entry->tmp_str_pos + 3))) |
0 |
0 |
0 |
|
| 316 |
0 |
| myhtml_data_process_state_end(proc_entry, str); |
| 317 |
|
| } |
| 318 |
0 |
| } |
| 319 |
|
| |
| 320 |
|
| |