summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-07-12 01:25:14 +0530
committerRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-08-01 21:44:32 +0530
commitccd7ddbd18b16943e42e91aec3b7ea26a03cb3bc (patch)
tree7f6798e24985a11bc201aab90b2f6ecaa31fd930
parent4cc5b88048f984ffb8a403a23f0c78c236a5b533 (diff)
downloadlibhubbub-ccd7ddbd18b16943e42e91aec3b7ea26a03cb3bc.tar.gz
libhubbub-ccd7ddbd18b16943e42e91aec3b7ea26a03cb3bc.tar.bz2
appending to formatting list makes use of comparing the attributes. Since we now have the facility to retrive attributes, this has now been implemented with a not so optimised brute force search
-rw-r--r--src/treebuilder/treebuilder.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index d741b5c..a965c5a 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -1401,7 +1401,9 @@ hubbub_error formatting_list_append(hubbub_treebuilder *treebuilder,
formatting_list_entry *entry;
uint32_t n_elements = 0;
formatting_list_entry *remove_entry;
- size_t i;
+ size_t i, j;
+
+ bool *hash_table = malloc(n_attrs * sizeof(bool));
for (entry = treebuilder->context.formatting_list_end;
entry != NULL; entry = entry->prev) {
@@ -1409,8 +1411,35 @@ hubbub_error formatting_list_append(hubbub_treebuilder *treebuilder,
if (is_scoping_element(entry->details.type))
break;
+ bool attrs_equal = (
+ n_attrs == entry->details.n_attributes);
+ for(i = 0; i < entry->details.n_attributes && attrs_equal; i++) {
+ memset(hash_table, 0, n_attrs * sizeof(bool));
+ bool found = false;
+ for(j = 0; j < n_attrs; j++) {
+ if(hubbub_string_match_ci(attrs[j].name.ptr,
+ attrs[j].name.len,
+ entry->details.attributes[i].name.ptr,
+ entry->details.attributes[i].name.len) &&
+ hubbub_string_match_ci(attrs[j].value.ptr,
+ attrs[j].value.len,
+ entry->details.attributes[i].value.ptr,
+ entry->details.attributes[i].value.len) &&
+ attrs[j].ns == entry->details.attributes[i].ns &&
+ hash_table[j] == false) {
+ hash_table[j] = true;
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ attrs_equal = false;
+ }
+ }
+
if(entry->details.type == type &&
- entry->details.ns == ns)
+ entry->details.ns == ns &&
+ attrs_equal)
{
remove_entry = entry;
n_elements += 1;