| 1 |
|
| /* |
| 2 |
|
| Copyright 2015-2016 Alexander Borisov |
| 3 |
|
| |
| 4 |
|
| Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
|
| you may not use this file except in compliance with the License. |
| 6 |
|
| You may obtain a copy of the License at |
| 7 |
|
| |
| 8 |
|
| http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| |
| 10 |
|
| Unless required by applicable law or agreed to in writing, software |
| 11 |
|
| distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
|
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
|
| See the License for the specific language governing permissions and |
| 14 |
|
| limitations under the License. |
| 15 |
|
| |
| 16 |
|
| Author: lex.borisov@gmail.com (Alexander Borisov) |
| 17 |
|
| */ |
| 18 |
|
| |
| 19 |
|
| #include "myhtml/tokenizer.h" |
| 20 |
|
| |
| 21 |
|
| static const unsigned char myhtml_tokenizer_chars_map[] = { |
| 22 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 23 |
|
| 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, |
| 24 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 25 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 26 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 27 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 28 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 29 |
|
| 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| 30 |
|
| 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| 31 |
|
| 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| 32 |
|
| 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, |
| 33 |
|
| 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| 34 |
|
| 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| 35 |
|
| 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, |
| 36 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 37 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 38 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 39 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 40 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 41 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 42 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 43 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 44 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 45 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 46 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 47 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 48 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 49 |
|
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 50 |
|
| 0x00, 0x00, 0x00, 0x00 |
| 51 |
|
| }; |
| 52 |
|
| |
| 53 |
0 |
| void myhtml_tokenizer_set_first_settings(myhtml_tree_t* tree, const char* html, size_t html_length) |
| 54 |
|
| { |
| 55 |
0 |
| tree->current_qnode = mythread_queue_get_current_node(tree->queue); |
| 56 |
|
| |
| 57 |
0 |
| mythread_queue_node_clean(tree->current_qnode); |
| 58 |
|
| |
| 59 |
0 |
| tree->current_qnode->text = html; |
| 60 |
0 |
| tree->current_qnode->tree = tree; |
| 61 |
|
| |
| 62 |
0 |
| myhtml_token_node_malloc(tree->token, tree->current_qnode->token, tree->mcasync_token_id); |
| 63 |
|
| |
| 64 |
0 |
| tree->incoming_buf_first = tree->incoming_buf; |
| 65 |
0 |
| } |
| 66 |
|
| |
| 67 |
0 |
| void myhtml_tokenizer_begin(myhtml_tree_t* tree, const char* html, size_t html_length) |
| 68 |
|
| { |
| 69 |
0 |
| myhtml_tokenizer_chunk(tree, html, html_length); |
| 70 |
0 |
| } |
| 71 |
|
| |
| 72 |
0 |
| void myhtml_tokenizer_chunk_process(myhtml_tree_t* tree, const char* html, size_t html_length) |
| 73 |
|
| { |
| 74 |
0 |
| myhtml_t* myhtml = tree->myhtml; |
| 75 |
0 |
| myhtml_tokenizer_state_f* state_f = myhtml->parse_state_func; |
| 76 |
|
| |
| 77 |
|
| // add for a chunk |
| 78 |
0 |
| myhtml_incomming_buf_add(myhtml, tree, tree->incoming_buf, html, html_length); |
| 79 |
|
| |
| 80 |
|
| #ifndef MyHTML_BUILD_WITHOUT_THREADS |
| 81 |
|
| |
| 82 |
0 |
▶ | if(myhtml->opt & MyHTML_OPTIONS_PARSE_MODE_SINGLE) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml->opt & MyHTML_OPTIONS_PARSE_MODE_SINGLE) |
0 |
0 |
0 |
|
| 83 |
0 |
| tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE; |
| 84 |
|
| |
| 85 |
0 |
▶ | if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0) |
0 |
0 |
0 |
|
| 86 |
|
| { |
| 87 |
0 |
▶ | if(tree->queue_entry == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->queue_entry == NULL) { |
0 |
0 |
0 |
|
| 88 |
0 |
| myhtml_status_t status = MyHTML_STATUS_OK; |
| 89 |
0 |
| tree->queue_entry = mythread_queue_list_entry_push(myhtml->thread, tree->queue, &status); |
| 90 |
|
| |
| 91 |
0 |
▶ | if(status) |
Branch: 1 branch
| Branch | True | False | Total |
| if(status) |
0 |
0 |
0 |
|
| 92 |
0 |
| return; |
| 93 |
|
| } |
| 94 |
|
| |
| 95 |
0 |
| myhtml_tokenizer_post(tree); |
| 96 |
|
| } |
| 97 |
|
| |
| 98 |
|
| #else |
| 99 |
|
| |
| 100 |
|
| tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE; |
| 101 |
|
| |
| 102 |
|
| #endif |
| 103 |
|
| |
| 104 |
0 |
▶ | if(tree->current_qnode == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->current_qnode == NULL) { |
0 |
0 |
0 |
|
| 105 |
0 |
| myhtml_tokenizer_set_first_settings(tree, html, html_length); |
| 106 |
|
| } |
| 107 |
|
| |
| 108 |
0 |
| size_t offset = 0; |
| 109 |
|
| |
| 110 |
0 |
▶ | while (offset < html_length) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (offset < html_length) { |
0 |
0 |
0 |
|
| 111 |
0 |
| offset = state_f[tree->state](tree, tree->current_qnode, html, offset, html_length); |
| 112 |
|
| } |
| 113 |
|
| |
| 114 |
0 |
| tree->global_offset += html_length; |
| 115 |
|
| } |
| 116 |
|
| |
| 117 |
0 |
| void myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, size_t html_length) |
| 118 |
|
| { |
| 119 |
0 |
▶ | if(tree->encoding_usereq != MyHTML_ENCODING_UTF_16LE && |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->encoding_usereq != MyHTML_ENCODING_UTF_16LE && |
0 |
0 |
0 |
|
| 120 |
0 |
▶ | tree->encoding_usereq != MyHTML_ENCODING_UTF_16BE) { |
Branch: 1 branch
| Branch | True | False | Total |
| tree->encoding_usereq != MyHTML_ENCODING_UTF_16BE) { |
0 |
0 |
0 |
|
| 121 |
0 |
| myhtml_tokenizer_chunk_process(tree, html, html_length); |
| 122 |
|
| } |
| 123 |
|
| else |
| 124 |
|
| { |
| 125 |
0 |
| unsigned const char* u_html = (unsigned const char*)html; |
| 126 |
0 |
| myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(tree->encoding); |
| 127 |
|
| |
| 128 |
0 |
▶ | if(tree->temp_stream == NULL || tree->temp_stream->current == NULL) |
Branch: 2 branches
| Branch | True | False | Total |
| if(tree->temp_stream == NULL || tree->temp_stream->current == NULL) |
0 |
0 |
0 |
| if(tree->temp_stream == NULL || tree->temp_stream->current == NULL) |
0 |
0 |
0 |
|
| 129 |
0 |
| myhtml_tree_temp_stream_alloc(tree, (4096 * 2)); |
| 130 |
|
| |
| 131 |
0 |
| struct myhtml_tree_temp_tag_name *current_stream = tree->temp_stream->current; |
| 132 |
|
| |
| 133 |
0 |
| size_t current_pos = current_stream->length; |
| 134 |
|
| |
| 135 |
0 |
▶ | for (size_t i = 0; i < html_length; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (size_t i = 0; i < html_length; i++) |
0 |
0 |
0 |
|
| 136 |
|
| { |
| 137 |
0 |
▶ | if(func(u_html[i], &tree->temp_stream->res) == MyHTML_ENCODING_STATUS_OK) |
Branch: 1 branch
| Branch | True | False | Total |
| if(func(u_html[i], &tree->temp_stream->res) == MyHTML_ENCODING_STATUS_OK) |
0 |
0 |
0 |
|
| 138 |
|
| { |
| 139 |
0 |
▶ | if((current_stream->length + 4) >= current_stream->size) |
Branch: 1 branch
| Branch | True | False | Total |
| if((current_stream->length + 4) >= current_stream->size) |
0 |
0 |
0 |
|
| 140 |
|
| { |
| 141 |
0 |
| tree->encoding = MyHTML_ENCODING_UTF_8; |
| 142 |
0 |
| myhtml_tokenizer_chunk_process(tree, ¤t_stream->data[current_pos], current_stream->length); |
| 143 |
|
| |
| 144 |
0 |
| current_stream = myhtml_tree_temp_stream_alloc(tree, (4096 * 2)); |
| 145 |
|
| |
| 146 |
0 |
▶ | if(current_stream == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if(current_stream == NULL) |
0 |
0 |
0 |
|
| 147 |
0 |
| return; |
| 148 |
|
| |
| 149 |
0 |
| current_pos = current_stream->length; |
| 150 |
|
| } |
| 151 |
|
| |
| 152 |
0 |
| current_stream->length += myhtml_encoding_codepoint_to_ascii_utf_8(tree->temp_stream->res.result, ¤t_stream->data[current_stream->length]); |
| 153 |
|
| } |
| 154 |
|
| } |
| 155 |
|
| |
| 156 |
0 |
▶ | if((current_stream->length - current_pos)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if((current_stream->length - current_pos)) { |
0 |
0 |
0 |
|
| 157 |
0 |
| tree->encoding = MyHTML_ENCODING_UTF_8; |
| 158 |
0 |
| myhtml_tokenizer_chunk_process(tree, current_stream->data, current_stream->length); |
| 159 |
|
| } |
| 160 |
|
| } |
| 161 |
|
| } |
| 162 |
|
| |
| 163 |
0 |
| void myhtml_tokenizer_end(myhtml_tree_t* tree) |
| 164 |
|
| { |
| 165 |
0 |
▶ | if(tree->incoming_buf) |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->incoming_buf) |
0 |
0 |
0 |
|
| 166 |
|
| { |
| 167 |
0 |
| tree->global_offset -= tree->incoming_buf->size; |
| 168 |
|
| |
| 169 |
0 |
| tree->myhtml->parse_state_func[(tree->state + MyHTML_TOKENIZER_STATE_LAST_ENTRY)] |
| 170 |
0 |
| (tree, tree->current_qnode, tree->incoming_buf->data, tree->incoming_buf->size, tree->incoming_buf->size); |
| 171 |
|
| } |
| 172 |
|
| |
| 173 |
0 |
| tree->current_qnode->token->tag_ctx_idx = MyHTML_TAG__END_OF_FILE; |
| 174 |
|
| |
| 175 |
0 |
| myhtml_queue_add(tree, NULL, 0, NULL); |
| 176 |
|
| |
| 177 |
|
| #ifndef MyHTML_BUILD_WITHOUT_THREADS |
| 178 |
|
| |
| 179 |
0 |
▶ | if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0) |
0 |
0 |
0 |
|
| 180 |
|
| { |
| 181 |
0 |
| mythread_queue_list_entry_wait_for_done(tree->myhtml->thread, tree->queue_entry); |
| 182 |
0 |
| tree->queue_entry = mythread_queue_list_entry_delete(tree->myhtml->thread, tree->queue_entry, false); |
| 183 |
|
| |
| 184 |
0 |
▶ | if(tree->myhtml->thread->queue_list->count == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->myhtml->thread->queue_list->count == 0) { |
0 |
0 |
0 |
|
| 185 |
|
| //myhtml_tokenizer_wait(tree); |
| 186 |
0 |
| myhtml_tokenizer_pause(tree); |
| 187 |
|
| } |
| 188 |
|
| } |
| 189 |
|
| |
| 190 |
|
| #endif |
| 191 |
|
| |
| 192 |
0 |
| tree->flags |= MyHTML_TREE_FLAGS_PARSE_END; |
| 193 |
|
| |
| 194 |
0 |
| myhtml_tree_temp_stream_clean(tree); |
| 195 |
|
| |
| 196 |
|
| #ifdef DEBUG_MODE |
| 197 |
|
| if(tree->open_elements->length) { |
| 198 |
|
| MyHTML_DEBUG_ERROR("Tokenizer end; Open Elements is %zu", tree->open_elements->length); |
| 199 |
|
| } |
| 200 |
|
| if(tree->active_formatting->length) { |
| 201 |
|
| MyHTML_DEBUG_ERROR("Tokenizer end; Active Formatting Elements is %zu", tree->active_formatting->length); |
| 202 |
|
| } |
| 203 |
|
| #endif |
| 204 |
0 |
| } |
| 205 |
|
| |
| 206 |
0 |
| myhtml_tree_node_t * myhtml_tokenizer_fragment_init(myhtml_tree_t* tree, myhtml_tag_id_t tag_idx, enum myhtml_namespace my_namespace) |
| 207 |
|
| { |
| 208 |
|
| // step 3 |
| 209 |
0 |
| tree->fragment = myhtml_tree_node_create(tree); |
| 210 |
0 |
| tree->fragment->my_namespace = my_namespace; |
| 211 |
0 |
| tree->fragment->tag_idx = tag_idx; |
| 212 |
|
| |
| 213 |
|
| // step 4, is already done |
| 214 |
0 |
▶ | if(my_namespace == MyHTML_NAMESPACE_HTML) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(my_namespace == MyHTML_NAMESPACE_HTML) { |
0 |
0 |
0 |
|
| 215 |
0 |
▶ | if(tag_idx == MyHTML_TAG_NOSCRIPT) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tag_idx == MyHTML_TAG_NOSCRIPT) { |
0 |
0 |
0 |
|
| 216 |
0 |
▶ | if(tree->flags & MyHTML_TREE_FLAGS_SCRIPT) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->flags & MyHTML_TREE_FLAGS_SCRIPT) { |
0 |
0 |
0 |
|
| 217 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT; |
| 218 |
|
| } |
| 219 |
|
| else { |
| 220 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 221 |
|
| } |
| 222 |
|
| } |
| 223 |
|
| else { |
| 224 |
0 |
| const myhtml_tag_context_t *tag_ctx = myhtml_tag_get_by_id(tree->tags, tag_idx); |
| 225 |
0 |
| myhtml_tokenizer_state_set(tree) = tag_ctx->data_parser; |
| 226 |
|
| } |
| 227 |
|
| } |
| 228 |
|
| |
| 229 |
|
| mcobject_async_status_t mcstatus; |
| 230 |
0 |
| tree->fragment->token = (myhtml_token_node_t*)mcobject_async_malloc(tree->token->nodes_obj, tree->mcasync_token_id, &mcstatus); |
| 231 |
|
| |
| 232 |
0 |
▶ | if(mcstatus) |
Branch: 1 branch
| Branch | True | False | Total |
| if(mcstatus) |
0 |
0 |
0 |
|
| 233 |
0 |
| return NULL; |
| 234 |
|
| |
| 235 |
0 |
| myhtml_token_node_clean(tree->fragment->token); |
| 236 |
0 |
| myhtml_token_set_done(tree->fragment->token); |
| 237 |
|
| |
| 238 |
0 |
| tree->token_namespace = tree->fragment->token; |
| 239 |
|
| |
| 240 |
|
| // step 5-7 |
| 241 |
0 |
| myhtml_tree_node_t* root = myhtml_tree_node_insert_root(tree, NULL, MyHTML_NAMESPACE_HTML); |
| 242 |
|
| |
| 243 |
0 |
▶ | if(tag_idx == MyHTML_TAG_TEMPLATE) |
Branch: 1 branch
| Branch | True | False | Total |
| if(tag_idx == MyHTML_TAG_TEMPLATE) |
0 |
0 |
0 |
|
| 244 |
0 |
| myhtml_tree_template_insertion_append(tree, MyHTML_INSERTION_MODE_IN_TEMPLATE); |
| 245 |
|
| |
| 246 |
0 |
| myhtml_tree_reset_insertion_mode_appropriately(tree); |
| 247 |
|
| |
| 248 |
0 |
| return root; |
| 249 |
|
| } |
| 250 |
|
| |
| 251 |
0 |
| void myhtml_tokenizer_wait(myhtml_tree_t* tree) |
| 252 |
|
| { |
| 253 |
0 |
| mythread_wait_all_for_done(tree->myhtml->thread); |
| 254 |
0 |
| } |
| 255 |
|
| |
| 256 |
0 |
| void myhtml_tokenizer_post(myhtml_tree_t* tree) |
| 257 |
|
| { |
| 258 |
0 |
| mythread_resume_all(tree->myhtml->thread); |
| 259 |
0 |
| } |
| 260 |
|
| |
| 261 |
0 |
| void myhtml_tokenizer_pause(myhtml_tree_t* tree) |
| 262 |
|
| { |
| 263 |
0 |
| mythread_stop_all(tree->myhtml->thread); |
| 264 |
0 |
| } |
| 265 |
|
| |
| 266 |
0 |
| void myhtml_tokenizer_calc_current_namespace(myhtml_tree_t* tree, mythread_queue_node_t* qnode) |
| 267 |
|
| { |
| 268 |
0 |
▶ | if(tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) |
0 |
0 |
0 |
|
| 269 |
|
| { |
| 270 |
0 |
| myhtml_tokenizer_state_set(tree) = tree->state_of_builder; |
| 271 |
|
| } |
| 272 |
|
| else { |
| 273 |
0 |
▶ | if(qnode->token->tag_ctx_idx == MyHTML_TAG_MATH || |
Branch: 1 branch
| Branch | True | False | Total |
| if(qnode->token->tag_ctx_idx == MyHTML_TAG_MATH || |
0 |
0 |
0 |
|
| 274 |
0 |
▶ | qnode->token->tag_ctx_idx == MyHTML_TAG_SVG || |
Branch: 1 branch
| Branch | True | False | Total |
| qnode->token->tag_ctx_idx == MyHTML_TAG_SVG || |
0 |
0 |
0 |
|
| 275 |
0 |
▶ | qnode->token->tag_ctx_idx == MyHTML_TAG_FRAMESET) |
Branch: 1 branch
| Branch | True | False | Total |
| qnode->token->tag_ctx_idx == MyHTML_TAG_FRAMESET) |
0 |
0 |
0 |
|
| 276 |
|
| { |
| 277 |
0 |
| tree->token_namespace = qnode->token; |
| 278 |
|
| } |
| 279 |
0 |
▶ | else if(tree->token_namespace && (qnode->token->type & MyHTML_TOKEN_TYPE_CLOSE) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if(tree->token_namespace && (qnode->token->type & MyHTML_TOKEN_TYPE_CLOSE) == 0) { |
0 |
0 |
0 |
| else if(tree->token_namespace && (qnode->token->type & MyHTML_TOKEN_TYPE_CLOSE) == 0) { |
0 |
0 |
0 |
|
| 280 |
0 |
| const myhtml_tag_context_t *tag_ctx = myhtml_tag_get_by_id(tree->tags, qnode->token->tag_ctx_idx); |
| 281 |
|
| |
| 282 |
0 |
▶ | if(tag_ctx->data_parser != MyHTML_TOKENIZER_STATE_DATA) |
Branch: 1 branch
| Branch | True | False | Total |
| if(tag_ctx->data_parser != MyHTML_TOKENIZER_STATE_DATA) |
0 |
0 |
0 |
|
| 283 |
|
| { |
| 284 |
0 |
| myhtml_tree_wait_for_last_done_token(tree, qnode->token); |
| 285 |
0 |
| myhtml_tokenizer_state_set(tree) = tree->state_of_builder; |
| 286 |
|
| } |
| 287 |
|
| } |
| 288 |
|
| } |
| 289 |
0 |
| } |
| 290 |
|
| |
| 291 |
|
| //void myhtml_tokenizer_calc_current_namespace(myhtml_tree_t* tree, mythread_queue_node_t* qnode) |
| 292 |
|
| //{ |
| 293 |
|
| // if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0) |
| 294 |
|
| // { |
| 295 |
|
| // if(qnode->token->tag_ctx_idx == MyHTML_TAG_MATH || |
| 296 |
|
| // qnode->token->tag_ctx_idx == MyHTML_TAG_SVG || |
| 297 |
|
| // qnode->token->tag_ctx_idx == MyHTML_TAG_FRAMESET) |
| 298 |
|
| // { |
| 299 |
|
| // tree->token_namespace = qnode->token; |
| 300 |
|
| // |
| 301 |
|
| // myhtml_tokenizer_wait(tree); |
| 302 |
|
| // myhtml_tokenizer_pause(tree); |
| 303 |
|
| // |
| 304 |
|
| // tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE; |
| 305 |
|
| // } |
| 306 |
|
| // } |
| 307 |
|
| // else if(tree->token_namespace) |
| 308 |
|
| // { |
| 309 |
|
| // myhtml_tokenizer_state_set(tree) = tree->state_of_builder; |
| 310 |
|
| // } |
| 311 |
|
| //} |
| 312 |
|
| |
| 313 |
0 |
| void myhtml_check_tag_parser(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset) |
| 314 |
|
| { |
| 315 |
0 |
| myhtml_tag_t* tags = tree->tags; |
| 316 |
0 |
| const myhtml_tag_context_t *tag_ctx = NULL; |
| 317 |
|
| |
| 318 |
0 |
▶ | if(html_offset < qnode->length) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset < qnode->length) { |
0 |
0 |
0 |
|
| 319 |
0 |
| const char *tagname = myhtml_tree_incomming_buf_make_data(tree, qnode, qnode->length); |
| 320 |
0 |
| tag_ctx = myhtml_tag_get_by_name(tags, tagname, qnode->length); |
| 321 |
|
| } |
| 322 |
|
| else { |
| 323 |
0 |
| tag_ctx = myhtml_tag_get_by_name(tags, &html[ (qnode->begin - tree->global_offset) ], qnode->length); |
| 324 |
|
| } |
| 325 |
|
| |
| 326 |
0 |
▶ | if(tag_ctx) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tag_ctx) { |
0 |
0 |
0 |
|
| 327 |
0 |
| qnode->token->tag_ctx_idx = tag_ctx->id; |
| 328 |
|
| } |
| 329 |
|
| else { |
| 330 |
0 |
▶ | if(html_offset < qnode->length) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset < qnode->length) { |
0 |
0 |
0 |
|
| 331 |
0 |
| const char *tagname = myhtml_tree_incomming_buf_make_data(tree, qnode, qnode->length); |
| 332 |
0 |
| qnode->token->tag_ctx_idx = myhtml_tag_add(tags, tagname, qnode->length, MyHTML_TOKENIZER_STATE_DATA, true); |
| 333 |
|
| } |
| 334 |
|
| else { |
| 335 |
0 |
| qnode->token->tag_ctx_idx = myhtml_tag_add(tags, &html[ (qnode->begin - tree->global_offset) ], qnode->length, MyHTML_TOKENIZER_STATE_DATA, true); |
| 336 |
|
| } |
| 337 |
|
| |
| 338 |
0 |
| myhtml_tag_set_category(tags, qnode->token->tag_ctx_idx, MyHTML_NAMESPACE_HTML, MyHTML_TAG_CATEGORIES_ORDINARY); |
| 339 |
|
| } |
| 340 |
0 |
| } |
| 341 |
|
| |
| 342 |
|
| //// |
| 343 |
0 |
| mythread_queue_node_t * myhtml_tokenizer_queue_create_text_node_if_need(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t absolute_html_offset, enum myhtml_token_type type) |
| 344 |
|
| { |
| 345 |
0 |
▶ | if(qnode->token->tag_ctx_idx == MyHTML_TAG__UNDEF) |
Branch: 1 branch
| Branch | True | False | Total |
| if(qnode->token->tag_ctx_idx == MyHTML_TAG__UNDEF) |
0 |
0 |
0 |
|
| 346 |
|
| { |
| 347 |
0 |
▶ | if(absolute_html_offset > qnode->begin) |
Branch: 1 branch
| Branch | True | False | Total |
| if(absolute_html_offset > qnode->begin) |
0 |
0 |
0 |
|
| 348 |
|
| { |
| 349 |
0 |
| qnode->token->type |= type; |
| 350 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__TEXT; |
| 351 |
0 |
| qnode->length = absolute_html_offset - qnode->begin; |
| 352 |
|
| |
| 353 |
0 |
| myhtml_queue_add(tree, html, 0, qnode); |
| 354 |
|
| |
| 355 |
0 |
| return tree->current_qnode; |
| 356 |
|
| } |
| 357 |
|
| } |
| 358 |
|
| |
| 359 |
0 |
| return qnode; |
| 360 |
|
| } |
| 361 |
|
| |
| 362 |
0 |
| void myhtml_tokenizer_set_state(myhtml_tree_t* tree, mythread_queue_node_t* qnode) |
| 363 |
|
| { |
| 364 |
0 |
▶ | if((qnode->token->type & MyHTML_TOKEN_TYPE_CLOSE) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if((qnode->token->type & MyHTML_TOKEN_TYPE_CLOSE) == 0) |
0 |
0 |
0 |
|
| 365 |
|
| { |
| 366 |
0 |
▶ | if(qnode->token->tag_ctx_idx == MyHTML_TAG_NOSCRIPT && |
Branch: 1 branch
| Branch | True | False | Total |
| if(qnode->token->tag_ctx_idx == MyHTML_TAG_NOSCRIPT && |
0 |
0 |
0 |
|
| 367 |
0 |
▶ | (tree->flags & MyHTML_TREE_FLAGS_SCRIPT) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| (tree->flags & MyHTML_TREE_FLAGS_SCRIPT) == 0) |
0 |
0 |
0 |
|
| 368 |
|
| { |
| 369 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 370 |
|
| } |
| 371 |
|
| else { |
| 372 |
0 |
| const myhtml_tag_context_t *tag_ctx = myhtml_tag_get_by_id(tree->tags, qnode->token->tag_ctx_idx); |
| 373 |
0 |
| myhtml_tokenizer_state_set(tree) = tag_ctx->data_parser; |
| 374 |
|
| } |
| 375 |
|
| } |
| 376 |
|
| else { |
| 377 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 378 |
|
| } |
| 379 |
0 |
| } |
| 380 |
|
| |
| 381 |
|
| ///////////////////////////////////////////////////////// |
| 382 |
|
| //// RCDATA |
| 383 |
|
| //// |
| 384 |
|
| ///////////////////////////////////////////////////////// |
| 385 |
0 |
| size_t myhtml_tokenizer_state_rcdata(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 386 |
|
| { |
| 387 |
0 |
▶ | if(tree->tmp_tag_id == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->tmp_tag_id == 0) { |
0 |
0 |
0 |
|
| 388 |
0 |
| qnode->begin = (html_offset + tree->global_offset); |
| 389 |
|
| |
| 390 |
0 |
| mythread_queue_node_t* prev_qnode = mythread_queue_get_prev_node(qnode); |
| 391 |
|
| |
| 392 |
0 |
▶ | if(prev_qnode && prev_qnode->token) { |
Branch: 2 branches
| Branch | True | False | Total |
| if(prev_qnode && prev_qnode->token) { |
0 |
0 |
0 |
| if(prev_qnode && prev_qnode->token) { |
0 |
0 |
0 |
|
| 393 |
0 |
| tree->tmp_tag_id = prev_qnode->token->tag_ctx_idx; |
| 394 |
|
| } |
| 395 |
0 |
▶ | else if(tree->fragment) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(tree->fragment) { |
0 |
0 |
0 |
|
| 396 |
0 |
| tree->tmp_tag_id = tree->fragment->tag_idx; |
| 397 |
|
| } |
| 398 |
|
| } |
| 399 |
|
| |
| 400 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 401 |
|
| { |
| 402 |
0 |
▶ | if(html[html_offset] == '<') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '<') |
0 |
0 |
0 |
|
| 403 |
|
| { |
| 404 |
0 |
| html_offset++; |
| 405 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA_LESS_THAN_SIGN; |
| 406 |
|
| |
| 407 |
0 |
| break; |
| 408 |
|
| } |
| 409 |
|
| |
| 410 |
0 |
| html_offset++; |
| 411 |
|
| } |
| 412 |
|
| |
| 413 |
0 |
| return html_offset; |
| 414 |
|
| } |
| 415 |
|
| |
| 416 |
0 |
| size_t myhtml_tokenizer_state_rcdata_less_than_sign(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 417 |
|
| { |
| 418 |
0 |
▶ | if(html[html_offset] == '/') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '/') |
0 |
0 |
0 |
|
| 419 |
|
| { |
| 420 |
0 |
| html_offset++; |
| 421 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA_END_TAG_OPEN; |
| 422 |
|
| } |
| 423 |
|
| else { |
| 424 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA; |
| 425 |
|
| } |
| 426 |
|
| |
| 427 |
0 |
| return html_offset; |
| 428 |
|
| } |
| 429 |
|
| |
| 430 |
0 |
| size_t myhtml_tokenizer_state_rcdata_end_tag_open(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 431 |
|
| { |
| 432 |
0 |
▶ | if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
0 |
0 |
0 |
|
| 433 |
|
| { |
| 434 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA_END_TAG_NAME; |
| 435 |
|
| } |
| 436 |
|
| else { |
| 437 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA; |
| 438 |
|
| } |
| 439 |
|
| |
| 440 |
0 |
| return html_offset; |
| 441 |
|
| } |
| 442 |
|
| |
| 443 |
0 |
| bool _myhtml_tokenizer_state_andata_end_tag_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t *html_offset, size_t tmp_begin, enum myhtml_token_type type) |
| 444 |
|
| { |
| 445 |
0 |
| qnode->length = (*html_offset + tree->global_offset) - qnode->begin; |
| 446 |
0 |
| myhtml_check_tag_parser(tree, qnode, html, *html_offset); |
| 447 |
|
| |
| 448 |
0 |
▶ | if(qnode->token->tag_ctx_idx != tree->tmp_tag_id) |
Branch: 1 branch
| Branch | True | False | Total |
| if(qnode->token->tag_ctx_idx != tree->tmp_tag_id) |
0 |
0 |
0 |
|
| 449 |
|
| { |
| 450 |
0 |
| qnode->begin = tmp_begin; |
| 451 |
0 |
| qnode->length = 0; |
| 452 |
|
| |
| 453 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA; |
| 454 |
|
| |
| 455 |
0 |
| (*html_offset)++; |
| 456 |
0 |
| return false; |
| 457 |
|
| } |
| 458 |
|
| |
| 459 |
0 |
▶ | if((qnode->begin - 2) > tmp_begin) |
Branch: 1 branch
| Branch | True | False | Total |
| if((qnode->begin - 2) > tmp_begin) |
0 |
0 |
0 |
|
| 460 |
|
| { |
| 461 |
0 |
| qnode->length = (qnode->begin - 2) - tmp_begin; |
| 462 |
0 |
| qnode->begin = tmp_begin; |
| 463 |
0 |
| qnode->token->type |= type; |
| 464 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__TEXT; |
| 465 |
|
| |
| 466 |
0 |
| myhtml_queue_add(tree, html, *html_offset, qnode); |
| 467 |
0 |
| qnode = tree->current_qnode; |
| 468 |
|
| } |
| 469 |
|
| |
| 470 |
0 |
| qnode->token->tag_ctx_idx = tree->tmp_tag_id; |
| 471 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_CLOSE; |
| 472 |
|
| |
| 473 |
0 |
| return true; |
| 474 |
|
| } |
| 475 |
|
| |
| 476 |
0 |
| size_t myhtml_tokenizer_state_rcdata_end_tag_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 477 |
|
| { |
| 478 |
0 |
| size_t tmp_begin = qnode->begin; |
| 479 |
0 |
| qnode->begin = html_offset + tree->global_offset; |
| 480 |
|
| |
| 481 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 482 |
|
| { |
| 483 |
0 |
▶ | if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE) |
0 |
0 |
0 |
|
| 484 |
|
| { |
| 485 |
0 |
▶ | if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RCDATA)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RCDATA)) { |
0 |
0 |
0 |
|
| 486 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 487 |
|
| |
| 488 |
0 |
| tree->tmp_tag_id = 0; |
| 489 |
0 |
| html_offset++; |
| 490 |
|
| |
| 491 |
0 |
| return html_offset; |
| 492 |
|
| } |
| 493 |
|
| |
| 494 |
0 |
| break; |
| 495 |
|
| } |
| 496 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 497 |
|
| { |
| 498 |
0 |
▶ | if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RCDATA)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RCDATA)) { |
0 |
0 |
0 |
|
| 499 |
0 |
| html_offset++; |
| 500 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 501 |
|
| |
| 502 |
0 |
| tree->tmp_tag_id = 0; |
| 503 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 504 |
|
| |
| 505 |
0 |
| return html_offset; |
| 506 |
|
| } |
| 507 |
|
| |
| 508 |
0 |
| break; |
| 509 |
|
| } |
| 510 |
|
| // check end of tag |
| 511 |
0 |
▶ | else if(html[html_offset] == '/') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '/') |
0 |
0 |
0 |
|
| 512 |
|
| { |
| 513 |
0 |
▶ | if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RCDATA)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RCDATA)) { |
0 |
0 |
0 |
|
| 514 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 515 |
|
| |
| 516 |
0 |
| tree->tmp_tag_id = 0; |
| 517 |
0 |
| html_offset++; |
| 518 |
|
| |
| 519 |
0 |
| return html_offset; |
| 520 |
|
| } |
| 521 |
|
| |
| 522 |
0 |
| break; |
| 523 |
|
| } |
| 524 |
0 |
▶ | else if (myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_A_Z_a_z) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_A_Z_a_z) { |
0 |
0 |
0 |
|
| 525 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA; |
| 526 |
0 |
| break; |
| 527 |
|
| } |
| 528 |
|
| |
| 529 |
0 |
| html_offset++; |
| 530 |
|
| } |
| 531 |
|
| |
| 532 |
0 |
| qnode->begin = tmp_begin; |
| 533 |
0 |
| return html_offset; |
| 534 |
|
| } |
| 535 |
|
| |
| 536 |
|
| ///////////////////////////////////////////////////////// |
| 537 |
|
| //// RAWTEXT |
| 538 |
|
| //// |
| 539 |
|
| ///////////////////////////////////////////////////////// |
| 540 |
0 |
| size_t myhtml_tokenizer_state_rawtext(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 541 |
|
| { |
| 542 |
0 |
▶ | if(tree->tmp_tag_id == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->tmp_tag_id == 0) { |
0 |
0 |
0 |
|
| 543 |
0 |
| qnode->begin = (html_offset + tree->global_offset); |
| 544 |
|
| |
| 545 |
0 |
| mythread_queue_node_t* prev_qnode = mythread_queue_get_prev_node(qnode); |
| 546 |
|
| |
| 547 |
0 |
▶ | if(prev_qnode && prev_qnode->token) { |
Branch: 2 branches
| Branch | True | False | Total |
| if(prev_qnode && prev_qnode->token) { |
0 |
0 |
0 |
| if(prev_qnode && prev_qnode->token) { |
0 |
0 |
0 |
|
| 548 |
0 |
| tree->tmp_tag_id = prev_qnode->token->tag_ctx_idx; |
| 549 |
|
| } |
| 550 |
0 |
▶ | else if(tree->fragment) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(tree->fragment) { |
0 |
0 |
0 |
|
| 551 |
0 |
| tree->tmp_tag_id = tree->fragment->tag_idx; |
| 552 |
|
| } |
| 553 |
|
| } |
| 554 |
|
| |
| 555 |
|
| |
| 556 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 557 |
|
| { |
| 558 |
0 |
▶ | if(html[html_offset] == '<') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '<') |
0 |
0 |
0 |
|
| 559 |
|
| { |
| 560 |
0 |
| html_offset++; |
| 561 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT_LESS_THAN_SIGN; |
| 562 |
|
| |
| 563 |
0 |
| break; |
| 564 |
|
| } |
| 565 |
|
| |
| 566 |
0 |
| html_offset++; |
| 567 |
|
| } |
| 568 |
|
| |
| 569 |
0 |
| return html_offset; |
| 570 |
|
| } |
| 571 |
|
| |
| 572 |
0 |
| size_t myhtml_tokenizer_state_rawtext_less_than_sign(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 573 |
|
| { |
| 574 |
0 |
▶ | if(html[html_offset] == '/') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '/') |
0 |
0 |
0 |
|
| 575 |
|
| { |
| 576 |
0 |
| html_offset++; |
| 577 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT_END_TAG_OPEN; |
| 578 |
|
| } |
| 579 |
|
| else { |
| 580 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT; |
| 581 |
|
| } |
| 582 |
|
| |
| 583 |
0 |
| return html_offset; |
| 584 |
|
| } |
| 585 |
|
| |
| 586 |
0 |
| size_t myhtml_tokenizer_state_rawtext_end_tag_open(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 587 |
|
| { |
| 588 |
0 |
▶ | if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
0 |
0 |
0 |
|
| 589 |
|
| { |
| 590 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT_END_TAG_NAME; |
| 591 |
|
| } |
| 592 |
|
| else { |
| 593 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT; |
| 594 |
|
| } |
| 595 |
|
| |
| 596 |
0 |
| return html_offset; |
| 597 |
|
| } |
| 598 |
|
| |
| 599 |
0 |
| size_t myhtml_tokenizer_state_rawtext_end_tag_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 600 |
|
| { |
| 601 |
0 |
| size_t tmp_begin = qnode->begin; |
| 602 |
0 |
| qnode->begin = html_offset + tree->global_offset; |
| 603 |
|
| |
| 604 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 605 |
|
| { |
| 606 |
0 |
▶ | if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE) |
0 |
0 |
0 |
|
| 607 |
|
| { |
| 608 |
0 |
▶ | if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RAWTEXT)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RAWTEXT)) { |
0 |
0 |
0 |
|
| 609 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 610 |
|
| |
| 611 |
0 |
| tree->tmp_tag_id = 0; |
| 612 |
0 |
| html_offset++; |
| 613 |
|
| } |
| 614 |
|
| |
| 615 |
0 |
| return html_offset; |
| 616 |
|
| } |
| 617 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 618 |
|
| { |
| 619 |
0 |
▶ | if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RAWTEXT)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RAWTEXT)) { |
0 |
0 |
0 |
|
| 620 |
0 |
| html_offset++; |
| 621 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 622 |
|
| |
| 623 |
0 |
| tree->tmp_tag_id = 0; |
| 624 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 625 |
|
| } |
| 626 |
|
| |
| 627 |
0 |
| return html_offset; |
| 628 |
|
| } |
| 629 |
|
| // check end of tag |
| 630 |
0 |
▶ | else if(html[html_offset] == '/') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '/') |
0 |
0 |
0 |
|
| 631 |
|
| { |
| 632 |
0 |
▶ | if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RAWTEXT)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(_myhtml_tokenizer_state_andata_end_tag_name(tree, qnode, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RAWTEXT)) { |
0 |
0 |
0 |
|
| 633 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 634 |
|
| |
| 635 |
0 |
| tree->tmp_tag_id = 0; |
| 636 |
0 |
| html_offset++; |
| 637 |
|
| } |
| 638 |
|
| |
| 639 |
0 |
| return html_offset; |
| 640 |
|
| } |
| 641 |
0 |
▶ | else if (myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_A_Z_a_z) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_A_Z_a_z) { |
0 |
0 |
0 |
|
| 642 |
0 |
| qnode->begin = tmp_begin; |
| 643 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT; |
| 644 |
|
| |
| 645 |
0 |
| return html_offset; |
| 646 |
|
| } |
| 647 |
|
| |
| 648 |
0 |
| html_offset++; |
| 649 |
|
| } |
| 650 |
|
| |
| 651 |
0 |
| qnode->begin = tmp_begin; |
| 652 |
0 |
| return html_offset; |
| 653 |
|
| } |
| 654 |
|
| |
| 655 |
|
| ///////////////////////////////////////////////////////// |
| 656 |
|
| //// PLAINTEXT |
| 657 |
|
| //// |
| 658 |
|
| ///////////////////////////////////////////////////////// |
| 659 |
0 |
| size_t myhtml_tokenizer_state_plaintext(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 660 |
|
| { |
| 661 |
0 |
▶ | if((qnode->token->type & MyHTML_TOKEN_TYPE_PLAINTEXT) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if((qnode->token->type & MyHTML_TOKEN_TYPE_PLAINTEXT) == 0) |
0 |
0 |
0 |
|
| 662 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_PLAINTEXT; |
| 663 |
|
| |
| 664 |
0 |
| qnode->begin = (html_offset + tree->global_offset); |
| 665 |
0 |
| qnode->length = (html_size + tree->global_offset) - qnode->begin; |
| 666 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__TEXT; |
| 667 |
|
| |
| 668 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 669 |
0 |
| myhtml_queue_add(tree, html, html_size, qnode); |
| 670 |
|
| |
| 671 |
0 |
| return html_size; |
| 672 |
|
| } |
| 673 |
|
| |
| 674 |
|
| ///////////////////////////////////////////////////////// |
| 675 |
|
| //// CDATA |
| 676 |
|
| //// |
| 677 |
|
| ///////////////////////////////////////////////////////// |
| 678 |
0 |
| size_t myhtml_tokenizer_state_cdata_section(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 679 |
|
| { |
| 680 |
0 |
▶ | if((qnode->token->type & MyHTML_TOKEN_TYPE_CDATA) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if((qnode->token->type & MyHTML_TOKEN_TYPE_CDATA) == 0) |
0 |
0 |
0 |
|
| 681 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_CDATA; |
| 682 |
|
| |
| 683 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 684 |
|
| { |
| 685 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 686 |
|
| { |
| 687 |
|
| const char *tagname; |
| 688 |
0 |
▶ | if(html_offset < 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset < 2) |
0 |
0 |
0 |
|
| 689 |
0 |
| tagname = myhtml_tree_incomming_buf_get_last(tree, tree->incoming_buf, html_offset, 2); |
| 690 |
|
| else |
| 691 |
0 |
| tagname = &html[html_offset - 2]; |
| 692 |
|
| |
| 693 |
0 |
▶ | if(tagname[0] == ']' && tagname[1] == ']') |
Branch: 2 branches
| Branch | True | False | Total |
| if(tagname[0] == ']' && tagname[1] == ']') |
0 |
0 |
0 |
| if(tagname[0] == ']' && tagname[1] == ']') |
0 |
0 |
0 |
|
| 694 |
|
| { |
| 695 |
0 |
| qnode->length = (((html_offset + tree->global_offset) - 2) - qnode->begin); |
| 696 |
0 |
| html_offset++; |
| 697 |
|
| |
| 698 |
0 |
▶ | if(qnode->length) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(qnode->length) { |
0 |
0 |
0 |
|
| 699 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 700 |
|
| } |
| 701 |
|
| else { |
| 702 |
0 |
| qnode->begin = html_offset + tree->global_offset; |
| 703 |
|
| } |
| 704 |
|
| |
| 705 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 706 |
0 |
| break; |
| 707 |
|
| } |
| 708 |
|
| } |
| 709 |
|
| |
| 710 |
0 |
| html_offset++; |
| 711 |
|
| } |
| 712 |
|
| |
| 713 |
0 |
| return html_offset; |
| 714 |
|
| } |
| 715 |
|
| |
| 716 |
|
| ///////////////////////////////////////////////////////// |
| 717 |
|
| //// outside of tag |
| 718 |
|
| //// %HERE%<div>%HERE%</div>%HERE% |
| 719 |
|
| ///////////////////////////////////////////////////////// |
| 720 |
0 |
| size_t myhtml_tokenizer_state_data(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 721 |
|
| { |
| 722 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 723 |
|
| { |
| 724 |
0 |
▶ | if(html[html_offset] == '<') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '<') |
0 |
0 |
0 |
|
| 725 |
|
| { |
| 726 |
0 |
| html_offset++; |
| 727 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_TAG_OPEN; |
| 728 |
|
| |
| 729 |
0 |
| break; |
| 730 |
|
| } |
| 731 |
0 |
▶ | else if(html[html_offset] == '\0' && (qnode->token->type & MyHTML_TOKEN_TYPE_NULL) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if(html[html_offset] == '\0' && (qnode->token->type & MyHTML_TOKEN_TYPE_NULL) == 0) { |
0 |
0 |
0 |
| else if(html[html_offset] == '\0' && (qnode->token->type & MyHTML_TOKEN_TYPE_NULL) == 0) { |
0 |
0 |
0 |
|
| 732 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_NULL; |
| 733 |
|
| } |
| 734 |
0 |
▶ | else if(qnode->token->type & MyHTML_TOKEN_TYPE_WHITESPACE && |
Branch: 1 branch
| Branch | True | False | Total |
| else if(qnode->token->type & MyHTML_TOKEN_TYPE_WHITESPACE && |
0 |
0 |
0 |
|
| 735 |
0 |
▶ | myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_WHITESPACE) { |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_WHITESPACE) { |
0 |
0 |
0 |
|
| 736 |
0 |
| qnode->token->type ^= (qnode->token->type & MyHTML_TOKEN_TYPE_WHITESPACE); |
| 737 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_DATA; |
| 738 |
|
| } |
| 739 |
|
| |
| 740 |
0 |
| html_offset++; |
| 741 |
|
| } |
| 742 |
|
| |
| 743 |
0 |
| return html_offset; |
| 744 |
|
| } |
| 745 |
|
| |
| 746 |
|
| ///////////////////////////////////////////////////////// |
| 747 |
|
| //// inside of tag |
| 748 |
|
| //// <%HERE%div></div> |
| 749 |
|
| ///////////////////////////////////////////////////////// |
| 750 |
0 |
| size_t myhtml_tokenizer_state_tag_open(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 751 |
|
| { |
| 752 |
0 |
▶ | if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
0 |
0 |
0 |
|
| 753 |
|
| { |
| 754 |
0 |
| qnode = myhtml_tokenizer_queue_create_text_node_if_need(tree, qnode, html, ((tree->global_offset + html_offset) - 1), MyHTML_TOKEN_TYPE_DATA); |
| 755 |
|
| |
| 756 |
0 |
| qnode->begin = tree->global_offset + html_offset; |
| 757 |
|
| |
| 758 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_TAG_NAME; |
| 759 |
|
| } |
| 760 |
0 |
▶ | else if(html[html_offset] == '!') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '!') |
0 |
0 |
0 |
|
| 761 |
|
| { |
| 762 |
0 |
| qnode = myhtml_tokenizer_queue_create_text_node_if_need(tree, qnode, html, ((tree->global_offset + html_offset) - 1), MyHTML_TOKEN_TYPE_DATA); |
| 763 |
|
| |
| 764 |
0 |
| html_offset++; |
| 765 |
0 |
| qnode->begin = tree->global_offset + html_offset; |
| 766 |
|
| |
| 767 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_MARKUP_DECLARATION_OPEN; |
| 768 |
|
| } |
| 769 |
0 |
▶ | else if(html[html_offset] == '/') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '/') |
0 |
0 |
0 |
|
| 770 |
|
| { |
| 771 |
0 |
| html_offset++; |
| 772 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_END_TAG_OPEN; |
| 773 |
|
| } |
| 774 |
0 |
▶ | else if(html[html_offset] == '?') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '?') |
0 |
0 |
0 |
|
| 775 |
|
| { |
| 776 |
0 |
| qnode = myhtml_tokenizer_queue_create_text_node_if_need(tree, qnode, html, ((tree->global_offset + html_offset) - 1), MyHTML_TOKEN_TYPE_DATA); |
| 777 |
|
| |
| 778 |
0 |
| qnode->begin = tree->global_offset + html_offset; |
| 779 |
|
| |
| 780 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BOGUS_COMMENT; |
| 781 |
|
| } |
| 782 |
|
| else { |
| 783 |
0 |
| qnode->token->type ^= (qnode->token->type & MyHTML_TOKEN_TYPE_WHITESPACE); |
| 784 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 785 |
|
| } |
| 786 |
|
| |
| 787 |
0 |
| return html_offset; |
| 788 |
|
| } |
| 789 |
|
| |
| 790 |
|
| ///////////////////////////////////////////////////////// |
| 791 |
|
| //// inside of tag |
| 792 |
|
| //// </%HERE% |
| 793 |
|
| ///////////////////////////////////////////////////////// |
| 794 |
0 |
| size_t myhtml_tokenizer_state_end_tag_open(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 795 |
|
| { |
| 796 |
0 |
▶ | if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) |
0 |
0 |
0 |
|
| 797 |
|
| { |
| 798 |
0 |
| qnode = myhtml_tokenizer_queue_create_text_node_if_need(tree, qnode, html, ((tree->global_offset + html_offset) - 2), MyHTML_TOKEN_TYPE_DATA); |
| 799 |
|
| |
| 800 |
0 |
| qnode->begin = tree->global_offset + html_offset; |
| 801 |
0 |
| qnode->token->type = MyHTML_TOKEN_TYPE_CLOSE; |
| 802 |
|
| |
| 803 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_TAG_NAME; |
| 804 |
|
| } |
| 805 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 806 |
|
| { |
| 807 |
0 |
| html_offset++; |
| 808 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 809 |
|
| } |
| 810 |
|
| else { |
| 811 |
0 |
| qnode = myhtml_tokenizer_queue_create_text_node_if_need(tree, qnode, html, ((tree->global_offset + html_offset) - 2), MyHTML_TOKEN_TYPE_DATA); |
| 812 |
|
| |
| 813 |
0 |
| qnode->begin = tree->global_offset + html_offset; |
| 814 |
|
| |
| 815 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BOGUS_COMMENT; |
| 816 |
|
| } |
| 817 |
|
| |
| 818 |
0 |
| return html_offset; |
| 819 |
|
| } |
| 820 |
|
| |
| 821 |
|
| ///////////////////////////////////////////////////////// |
| 822 |
|
| //// inside of tag |
| 823 |
|
| //// <!%HERE% |
| 824 |
|
| ///////////////////////////////////////////////////////// |
| 825 |
0 |
| size_t myhtml_tokenizer_state_markup_declaration_open(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 826 |
|
| { |
| 827 |
0 |
▶ | if((qnode->begin + 2) > (html_size + tree->global_offset)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if((qnode->begin + 2) > (html_size + tree->global_offset)) { |
0 |
0 |
0 |
|
| 828 |
0 |
| tree->incoming_buf->length = html_offset; |
| 829 |
0 |
| return html_size; |
| 830 |
|
| } |
| 831 |
|
| |
| 832 |
0 |
| const char *tagname = myhtml_tree_incomming_buf_make_data(tree, qnode, 2); |
| 833 |
|
| |
| 834 |
|
| // for a comment |
| 835 |
0 |
▶ | if(tagname[0] == '-' && tagname[1] == '-') |
Branch: 2 branches
| Branch | True | False | Total |
| if(tagname[0] == '-' && tagname[1] == '-') |
0 |
0 |
0 |
| if(tagname[0] == '-' && tagname[1] == '-') |
0 |
0 |
0 |
|
| 836 |
|
| { |
| 837 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT_START; |
| 838 |
|
| |
| 839 |
0 |
| html_offset += 2; |
| 840 |
|
| |
| 841 |
0 |
| qnode->begin = html_offset + tree->global_offset; |
| 842 |
0 |
| qnode->length = 0; |
| 843 |
|
| |
| 844 |
0 |
| return html_offset; |
| 845 |
|
| } |
| 846 |
|
| |
| 847 |
0 |
▶ | if((qnode->begin + 7) > (html_size + tree->global_offset)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if((qnode->begin + 7) > (html_size + tree->global_offset)) { |
0 |
0 |
0 |
|
| 848 |
0 |
| tree->incoming_buf->length = html_offset; |
| 849 |
0 |
| return html_size; |
| 850 |
|
| } |
| 851 |
|
| |
| 852 |
0 |
| tagname = myhtml_tree_incomming_buf_make_data(tree, qnode, 7); |
| 853 |
|
| |
| 854 |
0 |
▶ | if(myhtml_strncasecmp(tagname, "DOCTYPE", 7) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_strncasecmp(tagname, "DOCTYPE", 7) == 0) |
0 |
0 |
0 |
|
| 855 |
|
| { |
| 856 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DOCTYPE; |
| 857 |
|
| |
| 858 |
0 |
| html_offset = (qnode->begin + 7) - tree->incoming_buf->offset; |
| 859 |
|
| |
| 860 |
0 |
| qnode->length = 7; |
| 861 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__DOCTYPE; |
| 862 |
|
| |
| 863 |
0 |
| return html_offset; |
| 864 |
|
| } |
| 865 |
|
| |
| 866 |
|
| // CDATA sections can only be used in foreign content (MathML or SVG) |
| 867 |
0 |
▶ | if(strncmp(tagname, "[CDATA[", 7) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if(strncmp(tagname, "[CDATA[", 7) == 0) |
0 |
0 |
0 |
|
| 868 |
|
| { |
| 869 |
0 |
▶ | if(qnode->prev && qnode->prev->token) { |
Branch: 2 branches
| Branch | True | False | Total |
| if(qnode->prev && qnode->prev->token) { |
0 |
0 |
0 |
| if(qnode->prev && qnode->prev->token) { |
0 |
0 |
0 |
|
| 870 |
0 |
| myhtml_tree_wait_for_last_done_token(tree, qnode->prev->token); |
| 871 |
0 |
| myhtml_tree_node_t *adjusted_current_node = myhtml_tree_adjusted_current_node(tree); |
| 872 |
|
| |
| 873 |
0 |
▶ | if(adjusted_current_node && |
Branch: 1 branch
| Branch | True | False | Total |
| if(adjusted_current_node && |
0 |
0 |
0 |
|
| 874 |
0 |
▶ | adjusted_current_node->my_namespace != MyHTML_NAMESPACE_HTML) |
Branch: 1 branch
| Branch | True | False | Total |
| adjusted_current_node->my_namespace != MyHTML_NAMESPACE_HTML) |
0 |
0 |
0 |
|
| 875 |
|
| { |
| 876 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_CDATA_SECTION; |
| 877 |
|
| |
| 878 |
0 |
| html_offset = (qnode->begin + 7) - tree->incoming_buf->offset; |
| 879 |
|
| |
| 880 |
0 |
| qnode->begin += 7; |
| 881 |
0 |
| qnode->length = 0; |
| 882 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__TEXT; |
| 883 |
|
| |
| 884 |
0 |
| return html_offset; |
| 885 |
|
| } |
| 886 |
|
| } |
| 887 |
|
| } |
| 888 |
|
| |
| 889 |
0 |
| qnode->length = 0; |
| 890 |
|
| |
| 891 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BOGUS_COMMENT; |
| 892 |
0 |
| return html_offset; |
| 893 |
|
| } |
| 894 |
|
| |
| 895 |
|
| ///////////////////////////////////////////////////////// |
| 896 |
|
| //// inside of tag |
| 897 |
|
| //// <%HERE% |
| 898 |
|
| ///////////////////////////////////////////////////////// |
| 899 |
0 |
| size_t myhtml_tokenizer_state_tag_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 900 |
|
| { |
| 901 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 902 |
|
| { |
| 903 |
0 |
▶ | if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE) |
0 |
0 |
0 |
|
| 904 |
|
| { |
| 905 |
0 |
| qnode->length = (tree->global_offset + html_offset) - qnode->begin; |
| 906 |
0 |
| myhtml_check_tag_parser(tree, qnode, html, html_offset); |
| 907 |
|
| |
| 908 |
0 |
| html_offset++; |
| 909 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 910 |
|
| |
| 911 |
0 |
| break; |
| 912 |
|
| } |
| 913 |
0 |
▶ | else if(html[html_offset] == '/') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '/') |
0 |
0 |
0 |
|
| 914 |
|
| { |
| 915 |
0 |
| qnode->length = (tree->global_offset + html_offset) - qnode->begin; |
| 916 |
0 |
| myhtml_check_tag_parser(tree, qnode, html, html_offset); |
| 917 |
|
| |
| 918 |
0 |
| html_offset++; |
| 919 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_SELF_CLOSING_START_TAG; |
| 920 |
|
| |
| 921 |
0 |
| break; |
| 922 |
|
| } |
| 923 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 924 |
|
| { |
| 925 |
0 |
| qnode->length = (tree->global_offset + html_offset) - qnode->begin; |
| 926 |
|
| |
| 927 |
0 |
| myhtml_check_tag_parser(tree, qnode, html, html_offset); |
| 928 |
0 |
| myhtml_tokenizer_set_state(tree, qnode); |
| 929 |
|
| |
| 930 |
0 |
| html_offset++; |
| 931 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 932 |
|
| |
| 933 |
0 |
| break; |
| 934 |
|
| } |
| 935 |
|
| |
| 936 |
0 |
| html_offset++; |
| 937 |
|
| } |
| 938 |
|
| |
| 939 |
0 |
| return html_offset; |
| 940 |
|
| } |
| 941 |
|
| |
| 942 |
|
| ///////////////////////////////////////////////////////// |
| 943 |
|
| //// inside of tag |
| 944 |
|
| //// <%HERE% |
| 945 |
|
| ///////////////////////////////////////////////////////// |
| 946 |
0 |
| size_t myhtml_tokenizer_state_self_closing_start_tag(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 947 |
|
| { |
| 948 |
0 |
▶ | if(html[html_offset] == '>') { |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') { |
0 |
0 |
0 |
|
| 949 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_CLOSE_SELF; |
| 950 |
0 |
| myhtml_tokenizer_set_state(tree, qnode); |
| 951 |
|
| |
| 952 |
0 |
| html_offset++; |
| 953 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 954 |
|
| } |
| 955 |
|
| else { |
| 956 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 957 |
|
| } |
| 958 |
|
| |
| 959 |
0 |
| return html_offset; |
| 960 |
|
| } |
| 961 |
|
| |
| 962 |
|
| ///////////////////////////////////////////////////////// |
| 963 |
|
| //// inside of tag, after tag name |
| 964 |
|
| //// <div%HERE% class="bla"></div> |
| 965 |
|
| ///////////////////////////////////////////////////////// |
| 966 |
0 |
| size_t myhtml_tokenizer_state_before_attribute_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 967 |
|
| { |
| 968 |
|
| // skip WS |
| 969 |
0 |
▶ | myhtml_parser_skip_whitespace() |
Branch: 11 branches
| Branch | True | False | Total |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
|
| 970 |
|
| |
| 971 |
0 |
▶ | if(html_offset >= html_size) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset >= html_size) { |
0 |
0 |
0 |
|
| 972 |
0 |
| return html_offset; |
| 973 |
|
| } |
| 974 |
|
| |
| 975 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 976 |
|
| { |
| 977 |
0 |
| myhtml_tokenizer_set_state(tree, qnode); |
| 978 |
|
| |
| 979 |
0 |
| html_offset++; |
| 980 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 981 |
|
| } |
| 982 |
0 |
▶ | else if(html[html_offset] == '/') { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '/') { |
0 |
0 |
0 |
|
| 983 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_CLOSE_SELF; |
| 984 |
|
| |
| 985 |
0 |
| html_offset++; |
| 986 |
|
| } |
| 987 |
|
| else { |
| 988 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode) |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode) |
0 |
0 |
0 |
|
| 989 |
|
| |
| 990 |
0 |
| tree->attr_current->name_begin = html_offset + tree->global_offset; |
| 991 |
0 |
| tree->attr_current->name_length = 0; |
| 992 |
0 |
| tree->attr_current->value_begin = 0; |
| 993 |
0 |
| tree->attr_current->value_length = 0; |
| 994 |
|
| |
| 995 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_ATTRIBUTE_NAME; |
| 996 |
|
| } |
| 997 |
|
| |
| 998 |
0 |
| return html_offset; |
| 999 |
|
| } |
| 1000 |
|
| |
| 1001 |
|
| ///////////////////////////////////////////////////////// |
| 1002 |
|
| //// inside of tag, inside of attr key |
| 1003 |
|
| //// <div cla%HERE%ss="bla"></div> |
| 1004 |
|
| ///////////////////////////////////////////////////////// |
| 1005 |
0 |
| size_t myhtml_tokenizer_state_attribute_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1006 |
|
| { |
| 1007 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1008 |
|
| { |
| 1009 |
0 |
▶ | if(myhtml_whithspace(html[html_offset], ==, ||)) |
Branch: 5 branches
| Branch | True | False | Total |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
|
| 1010 |
|
| { |
| 1011 |
0 |
| tree->attr_current->name_length = (tree->global_offset + html_offset) - tree->attr_current->name_begin; |
| 1012 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_AFTER_ATTRIBUTE_NAME; |
| 1013 |
|
| |
| 1014 |
0 |
| html_offset++; |
| 1015 |
0 |
| break; |
| 1016 |
|
| } |
| 1017 |
0 |
▶ | else if(html[html_offset] == '=') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '=') |
0 |
0 |
0 |
|
| 1018 |
|
| { |
| 1019 |
0 |
| tree->attr_current->name_length = (tree->global_offset + html_offset) - tree->attr_current->name_begin; |
| 1020 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_VALUE; |
| 1021 |
|
| |
| 1022 |
0 |
| html_offset++; |
| 1023 |
0 |
| break; |
| 1024 |
|
| } |
| 1025 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 1026 |
|
| { |
| 1027 |
0 |
| tree->attr_current->name_length = (tree->global_offset + html_offset) - tree->attr_current->name_begin; |
| 1028 |
0 |
| myhtml_tokenizer_set_state(tree, qnode); |
| 1029 |
|
| |
| 1030 |
0 |
| html_offset++; |
| 1031 |
|
| |
| 1032 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1033 |
|
| |
| 1034 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1035 |
|
| |
| 1036 |
0 |
| break; |
| 1037 |
|
| } |
| 1038 |
0 |
▶ | else if(html[html_offset] == '/') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '/') |
0 |
0 |
0 |
|
| 1039 |
|
| { |
| 1040 |
0 |
| tree->attr_current->name_length = (tree->global_offset + html_offset) - tree->attr_current->name_begin; |
| 1041 |
|
| |
| 1042 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_CLOSE_SELF; |
| 1043 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 1044 |
|
| |
| 1045 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1046 |
|
| |
| 1047 |
0 |
| html_offset++; |
| 1048 |
0 |
| break; |
| 1049 |
|
| } |
| 1050 |
|
| |
| 1051 |
0 |
| html_offset++; |
| 1052 |
|
| } |
| 1053 |
|
| |
| 1054 |
0 |
| return html_offset; |
| 1055 |
|
| } |
| 1056 |
|
| |
| 1057 |
|
| ///////////////////////////////////////////////////////// |
| 1058 |
|
| //// inside of tag, after attr key |
| 1059 |
|
| //// <div class%HERE%="bla"></div> |
| 1060 |
|
| ///////////////////////////////////////////////////////// |
| 1061 |
0 |
| size_t myhtml_tokenizer_state_after_attribute_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1062 |
|
| { |
| 1063 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1064 |
|
| { |
| 1065 |
0 |
▶ | if(html[html_offset] == '=') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '=') |
0 |
0 |
0 |
|
| 1066 |
|
| { |
| 1067 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_VALUE; |
| 1068 |
|
| |
| 1069 |
0 |
| html_offset++; |
| 1070 |
0 |
| break; |
| 1071 |
|
| } |
| 1072 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 1073 |
|
| { |
| 1074 |
0 |
| myhtml_tokenizer_set_state(tree, qnode); |
| 1075 |
|
| |
| 1076 |
0 |
| html_offset++; |
| 1077 |
|
| |
| 1078 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1079 |
|
| |
| 1080 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1081 |
|
| |
| 1082 |
0 |
| break; |
| 1083 |
|
| } |
| 1084 |
0 |
▶ | else if(html[html_offset] == '"' || html[html_offset] == '\'' || html[html_offset] == '<') |
Branch: 3 branches
| Branch | True | False | Total |
| else if(html[html_offset] == '"' || html[html_offset] == '\'' || html[html_offset] == '<') |
0 |
0 |
0 |
| else if(html[html_offset] == '"' || html[html_offset] == '\'' || html[html_offset] == '<') |
0 |
0 |
0 |
| else if(html[html_offset] == '"' || html[html_offset] == '\'' || html[html_offset] == '<') |
0 |
0 |
0 |
|
| 1085 |
|
| { |
| 1086 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1087 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode) |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode) |
0 |
0 |
0 |
|
| 1088 |
|
| |
| 1089 |
0 |
| tree->attr_current->name_begin = (tree->global_offset + html_offset); |
| 1090 |
0 |
| tree->attr_current->name_length = 0; |
| 1091 |
0 |
| tree->attr_current->value_begin = 0; |
| 1092 |
0 |
| tree->attr_current->value_length = 0; |
| 1093 |
|
| |
| 1094 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_ATTRIBUTE_NAME; |
| 1095 |
0 |
| break; |
| 1096 |
|
| } |
| 1097 |
0 |
▶ | else if(myhtml_whithspace(html[html_offset], !=, &&)) |
Branch: 5 branches
| Branch | True | False | Total |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
|
| 1098 |
|
| { |
| 1099 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1100 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode) |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode) |
0 |
0 |
0 |
|
| 1101 |
|
| |
| 1102 |
0 |
| tree->attr_current->name_begin = (html_offset + tree->global_offset); |
| 1103 |
0 |
| tree->attr_current->name_length = 0; |
| 1104 |
0 |
| tree->attr_current->value_begin = 0; |
| 1105 |
0 |
| tree->attr_current->value_length = 0; |
| 1106 |
|
| |
| 1107 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_ATTRIBUTE_NAME; |
| 1108 |
0 |
| break; |
| 1109 |
|
| } |
| 1110 |
|
| |
| 1111 |
0 |
| html_offset++; |
| 1112 |
|
| } |
| 1113 |
|
| |
| 1114 |
0 |
| return html_offset; |
| 1115 |
|
| } |
| 1116 |
|
| |
| 1117 |
|
| ///////////////////////////////////////////////////////// |
| 1118 |
|
| //// inside of tag, after attr key |
| 1119 |
|
| //// <div class=%HERE%"bla"></div> |
| 1120 |
|
| ///////////////////////////////////////////////////////// |
| 1121 |
0 |
| size_t myhtml_tokenizer_state_before_attribute_value(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1122 |
|
| { |
| 1123 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1124 |
|
| { |
| 1125 |
0 |
▶ | if(html[html_offset] == '>') { |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') { |
0 |
0 |
0 |
|
| 1126 |
0 |
| myhtml_tokenizer_set_state(tree, qnode); |
| 1127 |
|
| |
| 1128 |
0 |
| html_offset++; |
| 1129 |
|
| |
| 1130 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1131 |
|
| |
| 1132 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1133 |
|
| |
| 1134 |
0 |
| break; |
| 1135 |
|
| } |
| 1136 |
0 |
▶ | else if(myhtml_whithspace(html[html_offset], !=, &&)) |
Branch: 5 branches
| Branch | True | False | Total |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], !=, &&)) |
0 |
0 |
0 |
|
| 1137 |
|
| { |
| 1138 |
0 |
▶ | if(html[html_offset] == '"') { |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '"') { |
0 |
0 |
0 |
|
| 1139 |
0 |
| html_offset++; |
| 1140 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_DOUBLE_QUOTED; |
| 1141 |
|
| } |
| 1142 |
0 |
▶ | else if(html[html_offset] == '\'') { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '\'') { |
0 |
0 |
0 |
|
| 1143 |
0 |
| html_offset++; |
| 1144 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_SINGLE_QUOTED; |
| 1145 |
|
| } |
| 1146 |
|
| else { |
| 1147 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_UNQUOTED; |
| 1148 |
|
| } |
| 1149 |
|
| |
| 1150 |
0 |
| tree->attr_current->value_begin = (tree->global_offset + html_offset); |
| 1151 |
|
| |
| 1152 |
0 |
| break; |
| 1153 |
|
| } |
| 1154 |
|
| |
| 1155 |
0 |
| html_offset++; |
| 1156 |
|
| } |
| 1157 |
|
| |
| 1158 |
0 |
| return html_offset; |
| 1159 |
|
| } |
| 1160 |
|
| |
| 1161 |
|
| ///////////////////////////////////////////////////////// |
| 1162 |
|
| //// inside of tag, inside of attr value |
| 1163 |
|
| //// <div class="bla%HERE%"></div> |
| 1164 |
|
| ///////////////////////////////////////////////////////// |
| 1165 |
0 |
| size_t myhtml_tokenizer_state_attribute_value_double_quoted(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1166 |
|
| { |
| 1167 |
|
| //myhtml_t* myhtml = tree->myhtml; |
| 1168 |
|
| |
| 1169 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1170 |
|
| { |
| 1171 |
0 |
▶ | if(html[html_offset] == '"') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '"') |
0 |
0 |
0 |
|
| 1172 |
|
| { |
| 1173 |
0 |
| tree->attr_current->value_length = (tree->global_offset + html_offset) - tree->attr_current->value_begin; |
| 1174 |
|
| |
| 1175 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1176 |
|
| |
| 1177 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 1178 |
|
| |
| 1179 |
0 |
| html_offset++; |
| 1180 |
0 |
| break; |
| 1181 |
|
| } |
| 1182 |
|
| |
| 1183 |
0 |
| html_offset++; |
| 1184 |
|
| } |
| 1185 |
|
| |
| 1186 |
0 |
| return html_offset; |
| 1187 |
|
| } |
| 1188 |
|
| |
| 1189 |
|
| ///////////////////////////////////////////////////////// |
| 1190 |
|
| //// inside of tag, inside of attr value |
| 1191 |
|
| //// <div class="bla%HERE%"></div> |
| 1192 |
|
| ///////////////////////////////////////////////////////// |
| 1193 |
0 |
| size_t myhtml_tokenizer_state_attribute_value_single_quoted(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1194 |
|
| { |
| 1195 |
|
| //myhtml_t* myhtml = tree->myhtml; |
| 1196 |
|
| |
| 1197 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1198 |
|
| { |
| 1199 |
0 |
▶ | if(html[html_offset] == '\'') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '\'') |
0 |
0 |
0 |
|
| 1200 |
|
| { |
| 1201 |
0 |
| tree->attr_current->value_length = (tree->global_offset + html_offset) - tree->attr_current->value_begin; |
| 1202 |
|
| |
| 1203 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1204 |
|
| |
| 1205 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 1206 |
|
| |
| 1207 |
0 |
| html_offset++; |
| 1208 |
0 |
| break; |
| 1209 |
|
| } |
| 1210 |
|
| |
| 1211 |
0 |
| html_offset++; |
| 1212 |
|
| } |
| 1213 |
|
| |
| 1214 |
0 |
| return html_offset; |
| 1215 |
|
| } |
| 1216 |
|
| |
| 1217 |
|
| ///////////////////////////////////////////////////////// |
| 1218 |
|
| //// inside of tag, inside of attr value |
| 1219 |
|
| //// <div class="bla%HERE%"></div> |
| 1220 |
|
| ///////////////////////////////////////////////////////// |
| 1221 |
0 |
| size_t myhtml_tokenizer_state_attribute_value_unquoted(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1222 |
|
| { |
| 1223 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1224 |
|
| { |
| 1225 |
0 |
▶ | if(myhtml_whithspace(html[html_offset], ==, ||)) |
Branch: 5 branches
| Branch | True | False | Total |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
|
| 1226 |
|
| { |
| 1227 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME; |
| 1228 |
|
| |
| 1229 |
0 |
| tree->attr_current->value_length = (tree->global_offset + html_offset) - tree->attr_current->value_begin; |
| 1230 |
|
| |
| 1231 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1232 |
|
| |
| 1233 |
0 |
| html_offset++; |
| 1234 |
0 |
| break; |
| 1235 |
|
| } |
| 1236 |
0 |
▶ | else if(html[html_offset] == '>') { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') { |
0 |
0 |
0 |
|
| 1237 |
0 |
| tree->attr_current->value_length = (tree->global_offset + html_offset) - tree->attr_current->value_begin; |
| 1238 |
|
| |
| 1239 |
0 |
| myhtml_tokenizer_set_state(tree, qnode); |
| 1240 |
|
| |
| 1241 |
0 |
| html_offset++; |
| 1242 |
|
| |
| 1243 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1244 |
|
| |
| 1245 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 1246 |
|
| |
| 1247 |
0 |
| break; |
| 1248 |
|
| } |
| 1249 |
|
| |
| 1250 |
0 |
| html_offset++; |
| 1251 |
|
| } |
| 1252 |
|
| |
| 1253 |
0 |
| return html_offset; |
| 1254 |
|
| } |
| 1255 |
|
| |
| 1256 |
|
| ///////////////////////////////////////////////////////// |
| 1257 |
|
| //// COMMENT |
| 1258 |
|
| //// <!--%HERE% |
| 1259 |
|
| ///////////////////////////////////////////////////////// |
| 1260 |
0 |
| size_t myhtml_tokenizer_state_comment_start(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1261 |
|
| { |
| 1262 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__COMMENT; |
| 1263 |
|
| |
| 1264 |
0 |
▶ | if(html[html_offset] == '-') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '-') |
0 |
0 |
0 |
|
| 1265 |
|
| { |
| 1266 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT_START_DASH; |
| 1267 |
|
| } |
| 1268 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 1269 |
|
| { |
| 1270 |
0 |
| html_offset++; |
| 1271 |
|
| |
| 1272 |
0 |
| qnode->length = 0; |
| 1273 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1274 |
|
| |
| 1275 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 1276 |
|
| |
| 1277 |
0 |
| return html_offset; |
| 1278 |
|
| } |
| 1279 |
|
| else { |
| 1280 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT; |
| 1281 |
|
| } |
| 1282 |
|
| |
| 1283 |
0 |
| html_offset++; |
| 1284 |
|
| |
| 1285 |
0 |
| return html_offset; |
| 1286 |
|
| } |
| 1287 |
|
| |
| 1288 |
0 |
| size_t myhtml_tokenizer_state_comment_start_dash(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1289 |
|
| { |
| 1290 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__COMMENT; |
| 1291 |
|
| |
| 1292 |
0 |
▶ | if(html[html_offset] == '-') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '-') |
0 |
0 |
0 |
|
| 1293 |
|
| { |
| 1294 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT_END; |
| 1295 |
|
| } |
| 1296 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 1297 |
|
| { |
| 1298 |
0 |
| html_offset++; |
| 1299 |
|
| |
| 1300 |
0 |
| qnode->length = 0; |
| 1301 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1302 |
|
| |
| 1303 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 1304 |
|
| |
| 1305 |
0 |
| return html_offset; |
| 1306 |
|
| } |
| 1307 |
|
| else { |
| 1308 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT; |
| 1309 |
|
| } |
| 1310 |
|
| |
| 1311 |
0 |
| html_offset++; |
| 1312 |
|
| |
| 1313 |
0 |
| return html_offset; |
| 1314 |
|
| } |
| 1315 |
|
| |
| 1316 |
0 |
| size_t myhtml_tokenizer_state_comment(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1317 |
|
| { |
| 1318 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__COMMENT; |
| 1319 |
|
| |
| 1320 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1321 |
|
| { |
| 1322 |
0 |
▶ | if(html[html_offset] == '-') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '-') |
0 |
0 |
0 |
|
| 1323 |
|
| { |
| 1324 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT_END_DASH; |
| 1325 |
0 |
| html_offset++; |
| 1326 |
0 |
| break; |
| 1327 |
|
| } |
| 1328 |
|
| |
| 1329 |
0 |
| html_offset++; |
| 1330 |
|
| } |
| 1331 |
|
| |
| 1332 |
0 |
| return html_offset; |
| 1333 |
|
| } |
| 1334 |
|
| |
| 1335 |
0 |
| size_t myhtml_tokenizer_state_comment_end_dash(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1336 |
|
| { |
| 1337 |
0 |
▶ | if(html[html_offset] == '-') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '-') |
0 |
0 |
0 |
|
| 1338 |
|
| { |
| 1339 |
0 |
| html_offset++; |
| 1340 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT_END; |
| 1341 |
|
| } |
| 1342 |
|
| else { |
| 1343 |
0 |
| html_offset++; |
| 1344 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT; |
| 1345 |
|
| } |
| 1346 |
|
| |
| 1347 |
0 |
| return html_offset; |
| 1348 |
|
| } |
| 1349 |
|
| |
| 1350 |
0 |
| size_t myhtml_tokenizer_state_comment_end(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1351 |
|
| { |
| 1352 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 1353 |
|
| { |
| 1354 |
0 |
| qnode->length = ((tree->global_offset + html_offset) - qnode->begin); |
| 1355 |
|
| |
| 1356 |
0 |
▶ | if(qnode->length >= 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if(qnode->length >= 2) |
0 |
0 |
0 |
|
| 1357 |
0 |
| qnode->length -= 2; |
| 1358 |
|
| else |
| 1359 |
0 |
| qnode->length = 0; |
| 1360 |
|
| |
| 1361 |
0 |
| html_offset++; |
| 1362 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1363 |
|
| |
| 1364 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 1365 |
|
| } |
| 1366 |
0 |
▶ | else if(html[html_offset] == '!') { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '!') { |
0 |
0 |
0 |
|
| 1367 |
0 |
| html_offset++; |
| 1368 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT_END_BANG; |
| 1369 |
|
| } |
| 1370 |
0 |
▶ | else if(html[html_offset] == '-') { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '-') { |
0 |
0 |
0 |
|
| 1371 |
0 |
| html_offset++; |
| 1372 |
|
| } |
| 1373 |
|
| else { |
| 1374 |
0 |
| html_offset++; |
| 1375 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT; |
| 1376 |
|
| } |
| 1377 |
|
| |
| 1378 |
0 |
| return html_offset; |
| 1379 |
|
| } |
| 1380 |
|
| |
| 1381 |
0 |
| size_t myhtml_tokenizer_state_comment_end_bang(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1382 |
|
| { |
| 1383 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 1384 |
|
| { |
| 1385 |
0 |
▶ | if(((tree->global_offset + html_offset) - 3) >= qnode->begin) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(((tree->global_offset + html_offset) - 3) >= qnode->begin) { |
0 |
0 |
0 |
|
| 1386 |
0 |
| qnode->length = ((tree->global_offset + html_offset) - qnode->begin) - 3; |
| 1387 |
|
| |
| 1388 |
0 |
| html_offset++; |
| 1389 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1390 |
|
| } |
| 1391 |
|
| else { |
| 1392 |
0 |
| html_offset++; |
| 1393 |
0 |
| qnode->length = 0; |
| 1394 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1395 |
|
| } |
| 1396 |
|
| |
| 1397 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 1398 |
|
| } |
| 1399 |
0 |
▶ | else if(html[html_offset] == '-') { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '-') { |
0 |
0 |
0 |
|
| 1400 |
0 |
| html_offset++; |
| 1401 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT_END_DASH; |
| 1402 |
|
| } |
| 1403 |
|
| else { |
| 1404 |
0 |
| html_offset++; |
| 1405 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_COMMENT; |
| 1406 |
|
| } |
| 1407 |
|
| |
| 1408 |
0 |
| return html_offset; |
| 1409 |
|
| } |
| 1410 |
|
| |
| 1411 |
|
| ///////////////////////////////////////////////////////// |
| 1412 |
|
| //// BOGUS COMMENT |
| 1413 |
|
| //// find > |
| 1414 |
|
| ///////////////////////////////////////////////////////// |
| 1415 |
0 |
| size_t myhtml_tokenizer_state_bogus_comment(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 1416 |
|
| { |
| 1417 |
0 |
| qnode->token->tag_ctx_idx = MyHTML_TAG__COMMENT; |
| 1418 |
0 |
| qnode->token->type |= MyHTML_TOKEN_TYPE_COMMENT; |
| 1419 |
|
| |
| 1420 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 1421 |
|
| { |
| 1422 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 1423 |
|
| { |
| 1424 |
0 |
| qnode->length = ((tree->global_offset + html_offset) - qnode->begin); |
| 1425 |
|
| |
| 1426 |
0 |
| html_offset++; |
| 1427 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 1428 |
|
| |
| 1429 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 1430 |
0 |
| break; |
| 1431 |
|
| } |
| 1432 |
|
| |
| 1433 |
0 |
| html_offset++; |
| 1434 |
|
| } |
| 1435 |
|
| |
| 1436 |
0 |
| return html_offset; |
| 1437 |
|
| } |
| 1438 |
|
| |
| 1439 |
1 |
| myhtml_status_t myhtml_tokenizer_state_init(myhtml_t* myhtml) |
| 1440 |
|
| { |
| 1441 |
1 |
| myhtml->parse_state_func = (myhtml_tokenizer_state_f*)mymalloc(sizeof(myhtml_tokenizer_state_f) * |
| 1442 |
|
| ((MyHTML_TOKENIZER_STATE_LAST_ENTRY * |
| 1443 |
|
| MyHTML_TOKENIZER_STATE_LAST_ENTRY) + 1)); |
| 1444 |
|
| |
| 1445 |
1 |
▶ | if(myhtml->parse_state_func == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml->parse_state_func == NULL) |
0 |
1 |
1 |
|
| 1446 |
0 |
| return MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION; |
| 1447 |
|
| |
| 1448 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_DATA] = myhtml_tokenizer_state_data; |
| 1449 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_TAG_OPEN] = myhtml_tokenizer_state_tag_open; |
| 1450 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_TAG_NAME] = myhtml_tokenizer_state_tag_name; |
| 1451 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_END_TAG_OPEN] = myhtml_tokenizer_state_end_tag_open; |
| 1452 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SELF_CLOSING_START_TAG] = myhtml_tokenizer_state_self_closing_start_tag; |
| 1453 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_MARKUP_DECLARATION_OPEN] = myhtml_tokenizer_state_markup_declaration_open; |
| 1454 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME] = myhtml_tokenizer_state_before_attribute_name; |
| 1455 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_ATTRIBUTE_NAME] = myhtml_tokenizer_state_attribute_name; |
| 1456 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_AFTER_ATTRIBUTE_NAME] = myhtml_tokenizer_state_after_attribute_name; |
| 1457 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_VALUE] = myhtml_tokenizer_state_before_attribute_value; |
| 1458 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_DOUBLE_QUOTED] = myhtml_tokenizer_state_attribute_value_double_quoted; |
| 1459 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_SINGLE_QUOTED] = myhtml_tokenizer_state_attribute_value_single_quoted; |
| 1460 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_UNQUOTED] = myhtml_tokenizer_state_attribute_value_unquoted; |
| 1461 |
|
| |
| 1462 |
|
| // comments |
| 1463 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_COMMENT_START] = myhtml_tokenizer_state_comment_start; |
| 1464 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_COMMENT_START_DASH] = myhtml_tokenizer_state_comment_start_dash; |
| 1465 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_COMMENT] = myhtml_tokenizer_state_comment; |
| 1466 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_COMMENT] = myhtml_tokenizer_state_comment; |
| 1467 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_COMMENT_END] = myhtml_tokenizer_state_comment_end; |
| 1468 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_COMMENT_END_DASH] = myhtml_tokenizer_state_comment_end_dash; |
| 1469 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_COMMENT_END_BANG] = myhtml_tokenizer_state_comment_end_bang; |
| 1470 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_BOGUS_COMMENT] = myhtml_tokenizer_state_bogus_comment; |
| 1471 |
|
| |
| 1472 |
|
| // cdata |
| 1473 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_CDATA_SECTION] = myhtml_tokenizer_state_cdata_section; |
| 1474 |
|
| |
| 1475 |
|
| // rcdata |
| 1476 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RCDATA] = myhtml_tokenizer_state_rcdata; |
| 1477 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RCDATA_LESS_THAN_SIGN] = myhtml_tokenizer_state_rcdata_less_than_sign; |
| 1478 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RCDATA_END_TAG_OPEN] = myhtml_tokenizer_state_rcdata_end_tag_open; |
| 1479 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RCDATA_END_TAG_NAME] = myhtml_tokenizer_state_rcdata_end_tag_name; |
| 1480 |
|
| |
| 1481 |
|
| // rawtext |
| 1482 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RAWTEXT] = myhtml_tokenizer_state_rawtext; |
| 1483 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RAWTEXT_LESS_THAN_SIGN] = myhtml_tokenizer_state_rawtext_less_than_sign; |
| 1484 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RAWTEXT_END_TAG_OPEN] = myhtml_tokenizer_state_rawtext_end_tag_open; |
| 1485 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_RAWTEXT_END_TAG_NAME] = myhtml_tokenizer_state_rawtext_end_tag_name; |
| 1486 |
|
| |
| 1487 |
|
| // plaintext |
| 1488 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_PLAINTEXT] = myhtml_tokenizer_state_plaintext; |
| 1489 |
|
| |
| 1490 |
|
| // doctype |
| 1491 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_DOCTYPE] = myhtml_tokenizer_state_doctype; |
| 1492 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_BEFORE_DOCTYPE_NAME] = myhtml_tokenizer_state_before_doctype_name; |
| 1493 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_DOCTYPE_NAME] = myhtml_tokenizer_state_doctype_name; |
| 1494 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_NAME] = myhtml_tokenizer_state_after_doctype_name; |
| 1495 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_CUSTOM_AFTER_DOCTYPE_NAME_A_Z] = myhtml_tokenizer_state_custom_after_doctype_name_a_z; |
| 1496 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER] = myhtml_tokenizer_state_before_doctype_public_identifier; |
| 1497 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED] = myhtml_tokenizer_state_doctype_public_identifier_double_quoted; |
| 1498 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED] = myhtml_tokenizer_state_doctype_public_identifier_single_quoted; |
| 1499 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_PUBLIC_IDENTIFIER] = myhtml_tokenizer_state_after_doctype_public_identifier; |
| 1500 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED] = myhtml_tokenizer_state_doctype_system_identifier_double_quoted; |
| 1501 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED] = myhtml_tokenizer_state_doctype_system_identifier_single_quoted; |
| 1502 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_SYSTEM_IDENTIFIER] = myhtml_tokenizer_state_after_doctype_system_identifier; |
| 1503 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_BOGUS_DOCTYPE] = myhtml_tokenizer_state_bogus_doctype; |
| 1504 |
|
| |
| 1505 |
|
| // script |
| 1506 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA] = myhtml_tokenizer_state_script_data; |
| 1507 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_LESS_THAN_SIGN] = myhtml_tokenizer_state_script_data_less_than_sign; |
| 1508 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_END_TAG_OPEN] = myhtml_tokenizer_state_script_data_end_tag_open; |
| 1509 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_END_TAG_NAME] = myhtml_tokenizer_state_script_data_end_tag_name; |
| 1510 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPE_START] = myhtml_tokenizer_state_script_data_escape_start; |
| 1511 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPE_START_DASH] = myhtml_tokenizer_state_script_data_escape_start_dash; |
| 1512 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED] = myhtml_tokenizer_state_script_data_escaped; |
| 1513 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_DASH] = myhtml_tokenizer_state_script_data_escaped_dash; |
| 1514 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_DASH_DASH] = myhtml_tokenizer_state_script_data_escaped_dash_dash; |
| 1515 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN] = myhtml_tokenizer_state_script_data_escaped_less_than_sign; |
| 1516 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_END_TAG_OPEN] = myhtml_tokenizer_state_script_data_escaped_end_tag_open; |
| 1517 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_END_TAG_NAME] = myhtml_tokenizer_state_script_data_escaped_end_tag_name; |
| 1518 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPE_START] = myhtml_tokenizer_state_script_data_double_escape_start; |
| 1519 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED] = myhtml_tokenizer_state_script_data_double_escaped; |
| 1520 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED_DASH] = myhtml_tokenizer_state_script_data_double_escaped_dash; |
| 1521 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH] = myhtml_tokenizer_state_script_data_double_escaped_dash_dash; |
| 1522 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN] = myhtml_tokenizer_state_script_data_double_escaped_less_than_sign; |
| 1523 |
1 |
| myhtml->parse_state_func[MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPE_END] = myhtml_tokenizer_state_script_data_double_escape_end; |
| 1524 |
|
| |
| 1525 |
|
| // *********** |
| 1526 |
|
| // for ends |
| 1527 |
|
| // ********* |
| 1528 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1529 |
1 |
| + MyHTML_TOKENIZER_STATE_DATA)] = myhtml_tokenizer_end_state_data; |
| 1530 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1531 |
1 |
| + MyHTML_TOKENIZER_STATE_TAG_OPEN)] = myhtml_tokenizer_end_state_tag_open; |
| 1532 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1533 |
1 |
| + MyHTML_TOKENIZER_STATE_TAG_NAME)] = myhtml_tokenizer_end_state_tag_name; |
| 1534 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1535 |
1 |
| + MyHTML_TOKENIZER_STATE_END_TAG_OPEN)] = myhtml_tokenizer_end_state_end_tag_open; |
| 1536 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1537 |
1 |
| + MyHTML_TOKENIZER_STATE_SELF_CLOSING_START_TAG)] = myhtml_tokenizer_end_state_self_closing_start_tag; |
| 1538 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1539 |
1 |
| + MyHTML_TOKENIZER_STATE_MARKUP_DECLARATION_OPEN)] = myhtml_tokenizer_end_state_markup_declaration_open; |
| 1540 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1541 |
1 |
| + MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME)] = myhtml_tokenizer_end_state_before_attribute_name; |
| 1542 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1543 |
1 |
| + MyHTML_TOKENIZER_STATE_ATTRIBUTE_NAME)] = myhtml_tokenizer_end_state_attribute_name; |
| 1544 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1545 |
1 |
| + MyHTML_TOKENIZER_STATE_AFTER_ATTRIBUTE_NAME)] = myhtml_tokenizer_end_state_after_attribute_name; |
| 1546 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1547 |
1 |
| + MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_VALUE)] = myhtml_tokenizer_end_state_before_attribute_value; |
| 1548 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1549 |
1 |
| + MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_DOUBLE_QUOTED)] = myhtml_tokenizer_end_state_attribute_value_double_quoted; |
| 1550 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1551 |
1 |
| + MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_SINGLE_QUOTED)] = myhtml_tokenizer_end_state_attribute_value_single_quoted; |
| 1552 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1553 |
1 |
| + MyHTML_TOKENIZER_STATE_ATTRIBUTE_VALUE_UNQUOTED)] = myhtml_tokenizer_end_state_attribute_value_unquoted; |
| 1554 |
|
| |
| 1555 |
|
| // for ends comments |
| 1556 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1557 |
1 |
| + MyHTML_TOKENIZER_STATE_COMMENT_START)] = myhtml_tokenizer_end_state_comment_start; |
| 1558 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1559 |
1 |
| + MyHTML_TOKENIZER_STATE_COMMENT_START_DASH)] = myhtml_tokenizer_end_state_comment_start_dash; |
| 1560 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1561 |
1 |
| + MyHTML_TOKENIZER_STATE_COMMENT)] = myhtml_tokenizer_end_state_comment; |
| 1562 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1563 |
1 |
| + MyHTML_TOKENIZER_STATE_COMMENT_END)] = myhtml_tokenizer_end_state_comment_end; |
| 1564 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1565 |
1 |
| + MyHTML_TOKENIZER_STATE_COMMENT_END_DASH)] = myhtml_tokenizer_end_state_comment_end_dash; |
| 1566 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1567 |
1 |
| + MyHTML_TOKENIZER_STATE_COMMENT_END_BANG)] = myhtml_tokenizer_end_state_comment_end_bang; |
| 1568 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1569 |
1 |
| + MyHTML_TOKENIZER_STATE_BOGUS_COMMENT)] = myhtml_tokenizer_end_state_bogus_comment; |
| 1570 |
|
| |
| 1571 |
|
| // for ends cdata |
| 1572 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1573 |
1 |
| + MyHTML_TOKENIZER_STATE_CDATA_SECTION)] = myhtml_tokenizer_end_state_cdata_section; |
| 1574 |
|
| |
| 1575 |
|
| // rcdata |
| 1576 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1577 |
1 |
| + MyHTML_TOKENIZER_STATE_RCDATA)] = myhtml_tokenizer_end_state_rcdata; |
| 1578 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1579 |
1 |
| + MyHTML_TOKENIZER_STATE_RCDATA_LESS_THAN_SIGN)] = myhtml_tokenizer_end_state_rcdata_less_than_sign; |
| 1580 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1581 |
1 |
| + MyHTML_TOKENIZER_STATE_RCDATA_END_TAG_OPEN)] = myhtml_tokenizer_end_state_rcdata_end_tag_open; |
| 1582 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1583 |
1 |
| + MyHTML_TOKENIZER_STATE_RCDATA_END_TAG_NAME)] = myhtml_tokenizer_end_state_rcdata_end_tag_name; |
| 1584 |
|
| |
| 1585 |
|
| // rawtext |
| 1586 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1587 |
1 |
| + MyHTML_TOKENIZER_STATE_RAWTEXT)] = myhtml_tokenizer_end_state_rawtext; |
| 1588 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1589 |
1 |
| + MyHTML_TOKENIZER_STATE_RAWTEXT_LESS_THAN_SIGN)] = myhtml_tokenizer_end_state_rawtext_less_than_sign; |
| 1590 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1591 |
1 |
| + MyHTML_TOKENIZER_STATE_RAWTEXT_END_TAG_OPEN)] = myhtml_tokenizer_end_state_rawtext_end_tag_open; |
| 1592 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1593 |
1 |
| + MyHTML_TOKENIZER_STATE_RAWTEXT_END_TAG_NAME)] = myhtml_tokenizer_end_state_rawtext_end_tag_name; |
| 1594 |
|
| |
| 1595 |
|
| // for ends plaintext |
| 1596 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1597 |
1 |
| + MyHTML_TOKENIZER_STATE_PLAINTEXT)] = myhtml_tokenizer_end_state_plaintext; |
| 1598 |
|
| |
| 1599 |
|
| // for ends doctype |
| 1600 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1601 |
1 |
| + MyHTML_TOKENIZER_STATE_DOCTYPE)] = myhtml_tokenizer_end_state_doctype; |
| 1602 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1603 |
1 |
| + MyHTML_TOKENIZER_STATE_BEFORE_DOCTYPE_NAME)] = myhtml_tokenizer_end_state_before_doctype_name; |
| 1604 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1605 |
1 |
| + MyHTML_TOKENIZER_STATE_DOCTYPE_NAME)] = myhtml_tokenizer_end_state_doctype_name; |
| 1606 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1607 |
1 |
| + MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_NAME)] = myhtml_tokenizer_end_state_after_doctype_name; |
| 1608 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1609 |
1 |
| + MyHTML_TOKENIZER_STATE_CUSTOM_AFTER_DOCTYPE_NAME_A_Z)] = myhtml_tokenizer_end_state_custom_after_doctype_name_a_z; |
| 1610 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1611 |
1 |
| + MyHTML_TOKENIZER_STATE_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER)] = myhtml_tokenizer_end_state_before_doctype_public_identifier; |
| 1612 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1613 |
1 |
| + MyHTML_TOKENIZER_STATE_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED)] = myhtml_tokenizer_end_state_doctype_public_identifier_double_quoted; |
| 1614 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1615 |
1 |
| + MyHTML_TOKENIZER_STATE_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED)] = myhtml_tokenizer_end_state_doctype_public_identifier_single_quoted; |
| 1616 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1617 |
1 |
| + MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_PUBLIC_IDENTIFIER)] = myhtml_tokenizer_end_state_after_doctype_public_identifier; |
| 1618 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1619 |
1 |
| + MyHTML_TOKENIZER_STATE_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED)] = myhtml_tokenizer_end_state_doctype_system_identifier_double_quoted; |
| 1620 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1621 |
1 |
| + MyHTML_TOKENIZER_STATE_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED)] = myhtml_tokenizer_end_state_doctype_system_identifier_single_quoted; |
| 1622 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1623 |
1 |
| + MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_SYSTEM_IDENTIFIER)] = myhtml_tokenizer_end_state_after_doctype_system_identifier; |
| 1624 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1625 |
1 |
| + MyHTML_TOKENIZER_STATE_BOGUS_DOCTYPE)] = myhtml_tokenizer_end_state_bogus_doctype; |
| 1626 |
|
| |
| 1627 |
|
| // for ends script |
| 1628 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1629 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA)] = myhtml_tokenizer_end_state_script_data; |
| 1630 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1631 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_LESS_THAN_SIGN)] = myhtml_tokenizer_end_state_script_data_less_than_sign; |
| 1632 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1633 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_END_TAG_OPEN)] = myhtml_tokenizer_end_state_script_data_end_tag_open; |
| 1634 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1635 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_END_TAG_NAME)] = myhtml_tokenizer_end_state_script_data_end_tag_name; |
| 1636 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1637 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPE_START)] = myhtml_tokenizer_end_state_script_data_escape_start; |
| 1638 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1639 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPE_START_DASH)] = myhtml_tokenizer_end_state_script_data_escape_start_dash; |
| 1640 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1641 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED)] = myhtml_tokenizer_end_state_script_data_escaped; |
| 1642 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1643 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_DASH)] = myhtml_tokenizer_end_state_script_data_escaped_dash; |
| 1644 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1645 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_DASH_DASH)] = myhtml_tokenizer_end_state_script_data_escaped_dash_dash; |
| 1646 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1647 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN)] = myhtml_tokenizer_end_state_script_data_escaped_less_than_sign; |
| 1648 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1649 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_END_TAG_OPEN)] = myhtml_tokenizer_end_state_script_data_escaped_end_tag_open; |
| 1650 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1651 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED_END_TAG_NAME)] = myhtml_tokenizer_end_state_script_data_escaped_end_tag_name; |
| 1652 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1653 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPE_START)] = myhtml_tokenizer_end_state_script_data_double_escape_start; |
| 1654 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1655 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED)] = myhtml_tokenizer_end_state_script_data_double_escaped; |
| 1656 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1657 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED_DASH)] = myhtml_tokenizer_end_state_script_data_double_escaped_dash; |
| 1658 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1659 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH)] = myhtml_tokenizer_end_state_script_data_double_escaped_dash_dash; |
| 1660 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1661 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN)] = myhtml_tokenizer_end_state_script_data_double_escaped_less_than_sign; |
| 1662 |
1 |
| myhtml->parse_state_func[(MyHTML_TOKENIZER_STATE_LAST_ENTRY |
| 1663 |
1 |
| + MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPE_END)] = myhtml_tokenizer_end_state_script_data_double_escape_end; |
| 1664 |
|
| |
| 1665 |
1 |
| return MyHTML_STATUS_OK; |
| 1666 |
|
| } |
| 1667 |
|
| |
| 1668 |
1 |
| void myhtml_tokenizer_state_destroy(myhtml_t* myhtml) |
| 1669 |
|
| { |
| 1670 |
1 |
▶ | if(myhtml->parse_state_func) |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml->parse_state_func) |
1 |
0 |
1 |
|
| 1671 |
1 |
| free(myhtml->parse_state_func); |
| 1672 |
1 |
| } |
| 1673 |
|
| |
| 1674 |
|
| |
| 1675 |
|
| |