diff options
author | lexborisov <lex.borisov@gmail.com> | 2016-11-15 08:07:19 +0300 |
---|---|---|
committer | lexborisov <lex.borisov@gmail.com> | 2016-11-15 08:07:19 +0300 |
commit | 1cf5d4c0e869d4cd5c45fd2f1f757db67218f33c (patch) | |
tree | d656737aaab33225bca71f0d79131148f630eb18 /source/myhtml | |
parent | 10435746a3d0842a4a8b4ee48e38755341d9ef6f (diff) |
Sync with myhtml
Diffstat (limited to 'source/myhtml')
-rw-r--r-- | source/myhtml/incoming.c | 23 | ||||
-rw-r--r-- | source/myhtml/incoming.h | 5 | ||||
-rw-r--r-- | source/myhtml/serialization.c | 6 | ||||
-rw-r--r-- | source/myhtml/tokenizer.c | 2 |
4 files changed, 28 insertions, 8 deletions
diff --git a/source/myhtml/incoming.c b/source/myhtml/incoming.c index 124b379..fc0bd99 100644 --- a/source/myhtml/incoming.c +++ b/source/myhtml/incoming.c @@ -21,7 +21,7 @@ #include "myhtml/incoming.h" #include "myhtml/utils/resources.h" -myhtml_incoming_buffer_t * myhtml_incomming_buffer_add(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, +myhtml_incoming_buffer_t * myhtml_incoming_buffer_add(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, const char *html, size_t html_size) { myhtml_incoming_buffer_t *inc_buf = mcobject_malloc(mcobject, NULL); @@ -44,11 +44,30 @@ myhtml_incoming_buffer_t * myhtml_incomming_buffer_add(myhtml_incoming_buffer_t return inc_buf; } -void myhtml_incomming_buffer_clean(myhtml_incoming_buffer_t *current) +void myhtml_incoming_buffer_clean(myhtml_incoming_buffer_t *current) { memset(current, 0, sizeof(myhtml_incoming_buffer_t)); } +myhtml_incoming_buffer_t * myhtml_incoming_buffer_split(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos) +{ + size_t relative_pos = global_pos - current->offset; + myhtml_incoming_buffer_t *inc_buf = mcobject_malloc(mcobject, NULL); + + inc_buf->size = current->size - relative_pos; + inc_buf->length = inc_buf->size; + inc_buf->data = ¤t->data[relative_pos]; + inc_buf->offset = current->offset + relative_pos; + inc_buf->next = NULL; + inc_buf->prev = current; + + current->next = inc_buf; + current->size = relative_pos; + current->length = relative_pos; + + return inc_buf; +} + myhtml_incoming_buffer_t * myhtml_incoming_buffer_find_by_position(myhtml_incoming_buffer_t *inc_buf, size_t begin) { if(inc_buf->offset < begin) { diff --git a/source/myhtml/incoming.h b/source/myhtml/incoming.h index 5c70209..6e35389 100644 --- a/source/myhtml/incoming.h +++ b/source/myhtml/incoming.h @@ -42,8 +42,9 @@ struct myhtml_incoming_buffer { // incoming buffer -myhtml_incoming_buffer_t * myhtml_incomming_buffer_add(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, const char *html, size_t html_size); -void myhtml_incomming_buffer_clean(myhtml_incoming_buffer_t *current); +myhtml_incoming_buffer_t * myhtml_incoming_buffer_add(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, const char *html, size_t html_size); +void myhtml_incoming_buffer_clean(myhtml_incoming_buffer_t *current); +myhtml_incoming_buffer_t * myhtml_incoming_buffer_split(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos); myhtml_incoming_buffer_t * myhtml_incoming_buffer_find_by_position(myhtml_incoming_buffer_t *inc_buf, size_t begin); diff --git a/source/myhtml/serialization.c b/source/myhtml/serialization.c index 2cbea0a..ef76b94 100644 --- a/source/myhtml/serialization.c +++ b/source/myhtml/serialization.c @@ -160,13 +160,13 @@ void myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* at The attribute's serialized name is the string "xmlns:" followed by the attribute's local name. */ if(attr->key.data && attr->key.length == 5 && myhtml_strcmp(attr->key.data, "xmlns")) { - callback("xmlns:", 6, callback); + callback("xmlns:", 6, ptr); } break; } case MyHTML_NAMESPACE_XLINK: { - callback("xlink:", 6, callback); + callback("xlink:", 6, ptr); break; } @@ -309,7 +309,7 @@ void myhtml_serialization_append_attr(const char* data, size_t size, myhtml_call break; case 0xA0: if (notwritten) callback(data + i - notwritten, notwritten, ptr); - callback(" ", 6, NULL); + callback(" ", 6, ptr); notwritten = 0; break; default: diff --git a/source/myhtml/tokenizer.c b/source/myhtml/tokenizer.c index aa03639..d9e904b 100644 --- a/source/myhtml/tokenizer.c +++ b/source/myhtml/tokenizer.c @@ -46,7 +46,7 @@ myhtml_status_t myhtml_tokenizer_chunk_process(myhtml_tree_t* tree, const char* myhtml_tokenizer_state_f* state_f = myhtml->parse_state_func; // add for a chunk - tree->incoming_buf = myhtml_incomming_buffer_add(tree->incoming_buf, tree->mcobject_incoming_buf, html, html_length); + tree->incoming_buf = myhtml_incoming_buffer_add(tree->incoming_buf, tree->mcobject_incoming_buf, html, html_length); #ifndef MyHTML_BUILD_WITHOUT_THREADS |