Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lexborisov/Modest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlexborisov <lex.borisov@gmail.com>2017-03-21 09:56:42 +0300
committerlexborisov <lex.borisov@gmail.com>2017-03-21 09:56:42 +0300
commit7024458c55c0baedfb29c2f9db213d3b0474c851 (patch)
tree7ec10676fc5a24bffed67d9f6f89ba14130ea781 /source/modest/finder
parent0708dba577f51a9cb504db1feeb094aa9badd795 (diff)
Merge branch 'master' into coverity_scancoverity_scan
Diffstat (limited to 'source/modest/finder')
-rw-r--r--source/modest/finder/finder.c16
-rw-r--r--source/modest/finder/finder.h6
-rw-r--r--source/modest/finder/match.c69
-rw-r--r--source/modest/finder/match.h2
-rw-r--r--source/modest/finder/myosi.h2
-rw-r--r--source/modest/finder/pseudo_class.c16
-rw-r--r--source/modest/finder/pseudo_class.h2
-rw-r--r--source/modest/finder/resource.h2
-rw-r--r--source/modest/finder/thread.c157
-rw-r--r--source/modest/finder/thread.h13
-rw-r--r--source/modest/finder/type.c4
-rw-r--r--source/modest/finder/type.h4
12 files changed, 183 insertions, 110 deletions
diff --git a/source/modest/finder/finder.c b/source/modest/finder/finder.c
index 57b7e7b..bf52435 100644
--- a/source/modest/finder/finder.c
+++ b/source/modest/finder/finder.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -23,10 +23,10 @@
modest_finder_t * modest_finder_create(void)
{
- return (modest_finder_t*)myhtml_calloc(1, sizeof(modest_finder_t));
+ return (modest_finder_t*)mycore_calloc(1, sizeof(modest_finder_t));
}
-modest_status_t modest_finder_init(modest_finder_t* finder)
+mystatus_t modest_finder_init(modest_finder_t* finder)
{
return MODEST_STATUS_OK;
}
@@ -42,7 +42,7 @@ modest_finder_t * modest_finder_destroy(modest_finder_t* finder, bool self_destr
return NULL;
if(self_destroy) {
- myhtml_free(finder);
+ mycore_free(finder);
return NULL;
}
@@ -114,7 +114,7 @@ modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, my
if(finder == NULL)
return NULL;
- modest_status_t status = modest_finder_init(finder);
+ mystatus_t status = modest_finder_init(finder);
if(status != MODEST_STATUS_OK) {
modest_finder_destroy(finder, true);
@@ -122,7 +122,7 @@ modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, my
}
if(*collection == NULL) {
- myhtml_status_t status;
+ mystatus_t status;
*collection = myhtml_collection_create(4096, &status);
if(status) {
@@ -148,14 +148,14 @@ modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, my
return finder;
}
-modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
+mystatus_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
mycss_selectors_list_t* selector_list, myhtml_collection_t** collection)
{
if(finder == NULL || selector_list == NULL || scope_node == NULL || collection == NULL)
return MODEST_STATUS_ERROR;
if(*collection == NULL) {
- myhtml_status_t status;
+ mystatus_t status;
*collection = myhtml_collection_create(4096, &status);
if(status)
diff --git a/source/modest/finder/finder.h b/source/modest/finder/finder.h
index dd29d87..d3cdeff 100644
--- a/source/modest/finder/finder.h
+++ b/source/modest/finder/finder.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -38,7 +38,7 @@ typedef myhtml_tree_node_t * (*modest_finder_selector_combinator_f)(modest_finde
/* init */
modest_finder_t * modest_finder_create(void);
-modest_status_t modest_finder_init(modest_finder_t* finder);
+mystatus_t modest_finder_init(modest_finder_t* finder);
void modest_finder_clean(modest_finder_t* finder);
modest_finder_t * modest_finder_destroy(modest_finder_t* finder, bool self_destroy);
@@ -59,7 +59,7 @@ void modest_finder_specificity_inc(mycss_selectors_entry_t* selector, mycss_sele
/* base api */
modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, myhtml_collection_t** collection, myhtml_tree_node_t* base_node);
-modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
+mystatus_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
mycss_selectors_list_t* selector_list, myhtml_collection_t** collection);
/* process */
diff --git a/source/modest/finder/match.c b/source/modest/finder/match.c
index 97d5f9d..e75c524 100644
--- a/source/modest/finder/match.c
+++ b/source/modest/finder/match.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,7 @@ bool modest_finder_match_attribute_only_key(myhtml_token_attr_t* attr, const cha
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
return true;
}
@@ -46,7 +46,7 @@ bool modest_finder_match_attribute_eq(myhtml_token_attr_t* attr, const char* key
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length == value_len) {
if(case_sensitive) {
@@ -55,7 +55,7 @@ bool modest_finder_match_attribute_eq(myhtml_token_attr_t* attr, const char* key
}
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0) {
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) {
return true;
}
}
@@ -79,46 +79,37 @@ bool modest_finder_match_attribute_ws(myhtml_token_attr_t* attr, const char* key
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
size_t i = 0;
+ size_t begin;
if(attr->value.length >= value_len) {
if(case_sensitive)
{
while(i < attr->value.length)
{
- size_t end = i + value_len;
+ begin = i;
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;}
- if(end > attr->value.length)
- return false;
-
- if(
- (myhtml_strncmp(value, &attr->value.data[i], value_len) == 0) &&
- (myhtml_utils_whithspace(attr->value.data[end], ==, ||) || end == attr->value.length))
- {
+ if((i - begin) == value_len && (mycore_strncmp(value, &attr->value.data[begin], value_len) == 0)) {
return true;
}
-
- i++;
+ /* skip all ws */
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;}
}
}
else {
while(i < attr->value.length)
{
- size_t end = i + value_len;
+ begin = i;
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;}
- if(end > attr->value.length)
- return false;
-
- if(
- (myhtml_strncasecmp(value, &attr->value.data[i], value_len) == 0) &&
- (myhtml_utils_whithspace(attr->value.data[end], ==, ||) || end == attr->value.length))
- {
+ if((i - begin) == value_len && (mycore_strncasecmp(value, &attr->value.data[begin], value_len) == 0)) {
return true;
}
-
- i++;
+ /* skip all ws */
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;}
}
}
}
@@ -141,15 +132,15 @@ bool modest_finder_match_attribute_begin(myhtml_token_attr_t* attr, const char*
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length >= value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncmp(value, attr->value.data, value_len) == 0)
return true;
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0)
return true;
}
}
@@ -172,15 +163,15 @@ bool modest_finder_match_attribute_end(myhtml_token_attr_t* attr, const char* ke
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length >= value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
+ if(mycore_strncmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
return true;
}
else {
- if(myhtml_strncasecmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
+ if(mycore_strncasecmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
return true;
}
}
@@ -203,7 +194,7 @@ bool modest_finder_match_attribute_sub(myhtml_token_attr_t* attr, const char* ke
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length >= value_len) {
size_t i = 0;
@@ -212,7 +203,7 @@ bool modest_finder_match_attribute_sub(myhtml_token_attr_t* attr, const char* ke
{
while ((i + value_len) <= attr->value.length)
{
- if(myhtml_strncmp(value, &attr->value.data[i], value_len) == 0)
+ if(mycore_strncmp(value, &attr->value.data[i], value_len) == 0)
return true;
i++;
@@ -221,7 +212,7 @@ bool modest_finder_match_attribute_sub(myhtml_token_attr_t* attr, const char* ke
else {
while ((i + value_len) <= attr->value.length)
{
- if(myhtml_strncasecmp(value, &attr->value.data[i], value_len) == 0)
+ if(mycore_strncasecmp(value, &attr->value.data[i], value_len) == 0)
return true;
i++;
@@ -247,27 +238,27 @@ bool modest_finder_match_attribute_hsp(myhtml_token_attr_t* attr, const char* ke
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length == value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncmp(value, attr->value.data, value_len) == 0)
return true;
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0)
return true;
}
}
else if(attr->value.length > value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, attr->value.data, value_len) == 0) {
+ if(mycore_strncmp(value, attr->value.data, value_len) == 0) {
if(attr->value.data[value_len] == '-')
return true;
}
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0) {
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) {
if(attr->value.data[value_len] == '-')
return true;
}
diff --git a/source/modest/finder/match.h b/source/modest/finder/match.h
index adcf493..df76258 100644
--- a/source/modest/finder/match.h
+++ b/source/modest/finder/match.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/source/modest/finder/myosi.h b/source/modest/finder/myosi.h
index eaf769d..97232da 100644
--- a/source/modest/finder/myosi.h
+++ b/source/modest/finder/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/source/modest/finder/pseudo_class.c b/source/modest/finder/pseudo_class.c
index 807996e..f26ac69 100644
--- a/source/modest/finder/pseudo_class.c
+++ b/source/modest/finder/pseudo_class.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -159,7 +159,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_child_check_selec
bool modest_finder_selector_sub_type_pseudo_class_function_nth_child(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -226,7 +226,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_column(modest_fin
bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_child(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -290,7 +290,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_column(modes
bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_of_type(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -322,7 +322,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_of_type(mode
bool modest_finder_selector_sub_type_pseudo_class_function_nth_of_type(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -420,15 +420,15 @@ bool modest_finder_selector_sub_type_pseudo_class_checked(modest_finder_t* finde
while (attr)
{
if(attr->key.length == 4) {
- if(myhtml_strncasecmp("type", attr->key.data, 4) == 0)
+ if(mycore_strncasecmp("type", attr->key.data, 4) == 0)
{
if(attr->value.length == 8) {
- if(myhtml_strncasecmp("checkbox", attr->value.data, 8) == 0) {
+ if(mycore_strncasecmp("checkbox", attr->value.data, 8) == 0) {
return modest_finder_match_attribute_only_key(base_node->token->attr_first, "checked", 7);
}
}
else if(attr->value.length == 5) {
- if(myhtml_strncasecmp("radio", attr->value.data, 5) == 0) {
+ if(mycore_strncasecmp("radio", attr->value.data, 5) == 0) {
return modest_finder_match_attribute_only_key(base_node->token->attr_first, "checked", 7);
}
}
diff --git a/source/modest/finder/pseudo_class.h b/source/modest/finder/pseudo_class.h
index 17c682a..c9c1c07 100644
--- a/source/modest/finder/pseudo_class.h
+++ b/source/modest/finder/pseudo_class.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/source/modest/finder/resource.h b/source/modest/finder/resource.h
index 839914a..0d312ba 100644
--- a/source/modest/finder/resource.h
+++ b/source/modest/finder/resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/source/modest/finder/thread.c b/source/modest/finder/thread.c
index 1d03b09..a6f5d86 100644
--- a/source/modest/finder/thread.c
+++ b/source/modest/finder/thread.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -21,7 +21,12 @@
#include "modest/finder/thread.h"
/* private functions */
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
static void modest_finder_thread_stream(mythread_id_t thread_id, void* arg);
+#else
+static void modest_finder_thread_stream_single(modest_finder_thread_t* finder_thread, mycss_selectors_list_t* selector_list);
+#endif
+
static modest_finder_thread_context_t * modest_finder_thread_create_context(modest_finder_thread_t* finder_thread, size_t count);
//static void modest_finder_thread_callback_found(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_list_t* selector_list,
// mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec, void* ctx);
@@ -29,11 +34,15 @@ static modest_finder_thread_context_t * modest_finder_thread_create_context(mode
/* basic functions */
modest_finder_thread_t * modest_finder_thread_create(void)
{
- return (modest_finder_thread_t*)myhtml_calloc(1, sizeof(modest_finder_thread_t));
+ return (modest_finder_thread_t*)mycore_calloc(1, sizeof(modest_finder_thread_t));
}
-modest_status_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count)
+mystatus_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count)
{
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+ thread_count = 1;
+#endif
+
finder_thread->finder = finder;
/* objects for nodes */
@@ -59,23 +68,27 @@ modest_status_t modest_finder_thread_init(modest_finder_t* finder, modest_finder
return MODEST_STATUS_OK;
/* create and init threads */
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+ finder_thread->thread = NULL;
+#else
finder_thread->thread = mythread_create();
if(finder_thread->thread == NULL)
return MODEST_STATUS_OK;
- myhtml_status_t status = mythread_init(finder_thread->thread, "lastmac", thread_count);
+ mystatus_t status = mythread_init(finder_thread->thread, MyTHREAD_TYPE_STREAM, thread_count, 0);
if(status) {
- mythread_destroy(finder_thread->thread, NULL, true);
+ mythread_destroy(finder_thread->thread, NULL, NULL, true);
return MODEST_STATUS_OK;
}
finder_thread->thread->context = finder_thread;
/* create threads */
- for(size_t i = finder_thread->thread->pth_list_root; i < finder_thread->thread->pth_list_size; i++) {
- myhread_create_stream(finder_thread->thread, mythread_function, modest_finder_thread_stream, MyTHREAD_OPT_UNDEF, &status);
+ for(size_t i = 0; i < finder_thread->thread->entries_size; i++) {
+ myhread_entry_create(finder_thread->thread, mythread_function, modest_finder_thread_stream, MyTHREAD_OPT_STOP);
}
+#endif
return MODEST_STATUS_OK;
}
@@ -93,28 +106,24 @@ modest_finder_thread_t * modest_finder_thread_destroy(modest_finder_thread_t* fi
if(finder_thread == NULL)
return NULL;
- finder_thread->entry_obj = mcobject_async_destroy(finder_thread->entry_obj, true);
- finder_thread->declaration_obj = mcobject_async_destroy(finder_thread->declaration_obj, true);
-
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
if(finder_thread->thread) {
- finder_thread->thread->stream_opt = MyTHREAD_OPT_QUIT;
-
- for(size_t i = finder_thread->thread->pth_list_root; i < finder_thread->thread->pth_list_size; i++) {
- finder_thread->thread->pth_list[i].data.opt = MyTHREAD_OPT_QUIT;
- }
-
- finder_thread->thread = mythread_destroy(finder_thread->thread, NULL, true);
+ finder_thread->thread = mythread_destroy(finder_thread->thread, mythread_callback_quit, NULL, true);
}
+#endif
+
+ finder_thread->entry_obj = mcobject_async_destroy(finder_thread->entry_obj, true);
+ finder_thread->declaration_obj = mcobject_async_destroy(finder_thread->declaration_obj, true);
if(finder_thread->context_list) {
- myhtml_free(finder_thread->context_list);
+ mycore_free(finder_thread->context_list);
finder_thread->context_list = NULL;
finder_thread->context_list_size = 0;
}
if(self_destroy) {
- myhtml_free(finder_thread);
+ mycore_free(finder_thread);
return NULL;
}
@@ -133,8 +142,64 @@ void modest_finder_thread_collate_node(modest_t* modest, myhtml_tree_node_t* nod
}
}
-modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread,
- myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list)
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+mystatus_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread,
+ myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list)
+{
+ finder_thread->base_node = scope_node;
+ finder_thread->selector_list = selector_list;
+
+ if(finder_thread->finder == NULL)
+ return MODEST_STATUS_ERROR;
+
+ modest_finder_thread_stream_single(finder_thread, selector_list);
+
+ /* calc result */
+ modest_finder_thread_context_t* context = finder_thread->context_list;
+ myhtml_tree_node_t* node = scope_node;
+
+ /* compare results */
+ while(node) {
+ modest_finder_thread_entry_t* entry = context->entry;
+
+ while(entry) {
+ if(entry->node == node)
+ {
+ if(entry->next)
+ entry->next->prev = entry->prev;
+ else
+ context->entry_last = entry->prev;
+
+ if(entry->prev)
+ entry->prev->next = entry->next;
+ else
+ context->entry = entry->next;
+
+ modest_finder_thread_collate_node(modest, node, entry);
+ }
+
+ entry = entry->next;
+ }
+
+ if(node->child)
+ node = node->child;
+ else {
+ while(node != scope_node && node->next == NULL)
+ node = node->parent;
+
+ if(node == scope_node)
+ break;
+
+ node = node->next;
+ }
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+#else /* end def MyCORE_BUILD_WITHOUT_THREADS */
+mystatus_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread,
+ myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list)
{
finder_thread->base_node = scope_node;
finder_thread->selector_list = selector_list;
@@ -142,7 +207,7 @@ modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thr
if(finder_thread->finder == NULL)
return MODEST_STATUS_ERROR;
- mythread_resume_all(finder_thread->thread);
+ mythread_resume(finder_thread->thread, MyTHREAD_OPT_UNDEF);
modest_finder_thread_wait_for_all_done(finder_thread);
/* calc result */
@@ -151,7 +216,7 @@ modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thr
/* compare results */
while(node) {
- for(size_t i = finder_thread->thread->pth_list_root; i < finder_thread->thread->pth_list_size; i++)
+ for(size_t i = 0; i < finder_thread->thread->entries_length; i++)
{
modest_finder_thread_context_t* context = &context_list[i];
modest_finder_thread_entry_t* entry = context->entry;
@@ -194,29 +259,26 @@ modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thr
void modest_finder_thread_wait_for_all_done(modest_finder_thread_t* finder_thread)
{
- const struct timespec tomeout = {0, 0};
-
- for (size_t idx = finder_thread->thread->pth_list_root; idx < finder_thread->thread->pth_list_size; idx++) {
- while((finder_thread->thread->pth_list[idx].data.opt & MyTHREAD_OPT_DONE) == 0) {
- myhtml_thread_nanosleep(&tomeout);
+ for (size_t idx = 0; idx < finder_thread->thread->entries_length; idx++) {
+ while((finder_thread->thread->entries[idx].context.opt & MyTHREAD_OPT_DONE) == 0) {
+ mythread_nanosleep_sleep(finder_thread->thread->timespec);
}
}
}
+#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */
modest_finder_thread_context_t * modest_finder_thread_create_context(modest_finder_thread_t* finder_thread, size_t count)
{
- /* +1 because threads ids begin 1 */
- count++;
finder_thread->context_list_size = count;
- modest_finder_thread_context_t *ctx = myhtml_calloc(count, sizeof(modest_finder_thread_context_t));
+ modest_finder_thread_context_t *ctx = mycore_calloc(count, sizeof(modest_finder_thread_context_t));
if(ctx == NULL)
return NULL;
mcobject_async_status_t mcstatus;
- for(size_t i = 1; i < count; i++) {
+ for(size_t i = 0; i < count; i++) {
ctx[i].entry_node_id = mcobject_async_node_add(finder_thread->entry_obj, &mcstatus);
if(mcstatus) {
@@ -225,12 +287,12 @@ modest_finder_thread_context_t * modest_finder_thread_create_context(modest_find
mcobject_async_node_delete(finder_thread->entry_obj, ctx[i].entry_node_id);
}
- myhtml_free(ctx);
+ mycore_free(ctx);
return NULL;
}
}
- for(size_t i = 1; i < count; i++) {
+ for(size_t i = 0; i < count; i++) {
ctx[i].declaration_node_id = mcobject_async_node_add(finder_thread->declaration_obj, &mcstatus);
if(mcstatus) {
@@ -245,7 +307,7 @@ modest_finder_thread_context_t * modest_finder_thread_create_context(modest_find
mcobject_async_node_delete(finder_thread->declaration_obj, ctx[i].declaration_node_id);
}
- myhtml_free(ctx);
+ mycore_free(ctx);
return NULL;
}
}
@@ -371,6 +433,25 @@ void modest_finder_thread_callback_found(modest_finder_t* finder, myhtml_tree_no
}
}
+void modest_finder_thread_stream_single(modest_finder_thread_t* finder_thread, mycss_selectors_list_t* selector_list)
+{
+ modest_finder_thread_found_context_t found_ctx = {finder_thread, finder_thread->context_list};
+
+ while(selector_list)
+ {
+ for(size_t i = 0; i < selector_list->entries_list_length; i++) {
+ mycss_selectors_entries_list_t *entries = &selector_list->entries_list[i];
+ mycss_selectors_specificity_t spec = entries->specificity;
+
+ modest_finder_node_combinator_begin(finder_thread->finder, finder_thread->base_node, selector_list,
+ entries->entry, &spec, modest_finder_thread_callback_found, &found_ctx);
+ }
+
+ selector_list = selector_list->next;
+ }
+}
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
void modest_finder_thread_stream(mythread_id_t thread_id, void* arg)
{
mythread_context_t* ctx = (mythread_context_t*)arg;
@@ -380,7 +461,7 @@ void modest_finder_thread_stream(mythread_id_t thread_id, void* arg)
modest_finder_thread_found_context_t found_ctx = {finder_thread, &finder_thread->context_list[ctx->id]};
size_t count = 0, counnt_done = ctx->id - 1;
- size_t offset = (ctx->mythread->pth_list_size - 1);
+ size_t offset = (ctx->mythread->entries_size - 1);
while(selector_list) {
for(size_t i = 0; i < selector_list->entries_list_length; i++) {
@@ -400,8 +481,6 @@ void modest_finder_thread_stream(mythread_id_t thread_id, void* arg)
selector_list = selector_list->next;
}
-
- ctx->opt = MyTHREAD_OPT_STOP|MyTHREAD_OPT_DONE;
}
-
+#endif
diff --git a/source/modest/finder/thread.h b/source/modest/finder/thread.h
index 7db18fb..7bb6959 100644
--- a/source/modest/finder/thread.h
+++ b/source/modest/finder/thread.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -29,8 +29,8 @@
#include "modest/finder/myosi.h"
#include "modest/finder/finder.h"
-#include "myhtml/thread.h"
-#include "myhtml/utils/mcobject_async.h"
+#include "mycore/mythread.h"
+#include "mycore/utils/mcobject_async.h"
#include "mycss/declaration/myosi.h"
@@ -85,13 +85,16 @@ struct modest_finder_thread_found_context {
modest_finder_thread_t * modest_finder_thread_create(void);
-modest_status_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count);
+mystatus_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count);
void modest_finder_thread_clean(modest_finder_thread_t* finder_thread, bool self_destroy);
modest_finder_thread_t * modest_finder_thread_destroy(modest_finder_thread_t* finder_thread, bool self_destroy);
-modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread, myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list);
+mystatus_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread, myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
void modest_finder_thread_wait_for_all_done(modest_finder_thread_t* finder_thread);
+#endif
+
bool modest_finder_thread_spec_is_up(modest_style_raw_specificity_t* spec_f, modest_style_raw_specificity_t* spec_t);
#ifdef __cplusplus
diff --git a/source/modest/finder/type.c b/source/modest/finder/type.c
index 0de5ad5..6db405e 100644
--- a/source/modest/finder/type.c
+++ b/source/modest/finder/type.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -35,7 +35,7 @@ bool modest_finder_selector_type_element(modest_finder_t* finder, myhtml_tree_no
}
/* tag match */
- myhtml_string_t *str = selector->key;
+ mycore_string_t *str = selector->key;
if(str->length == 1 && *str->data == '*')
return true;
diff --git a/source/modest/finder/type.h b/source/modest/finder/type.h
index 9156b47..a62a460 100644
--- a/source/modest/finder/type.h
+++ b/source/modest/finder/type.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ Copyright (C) 2016-2017 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,7 @@
#include "modest/finder/pseudo_class.h"
#include "modest/finder/match.h"
#include "myhtml/tree.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#include "mycss/selectors/value.h"
#ifdef __cplusplus