summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-24 16:26:55 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-24 16:26:55 +0000
commita24e5d04f5e4fb51446c623d2352e1da5ea53a2b (patch)
treed0d6d0ba115d4b5f2687940f12a35a240f4d3d4a
parentc9b35216c9cb5f21905f11b890c32f4be7fec10d (diff)
downloadlibdom-a24e5d04f5e4fb51446c623d2352e1da5ea53a2b.tar.gz
libdom-a24e5d04f5e4fb51446c623d2352e1da5ea53a2b.tar.bz2
Fixup _dom_node_get_text_content
svn path=/trunk/libdom/; revision=13598
-rw-r--r--src/core/node.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/core/node.c b/src/core/node.c
index 606f2b1..0660c53 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -1429,6 +1429,8 @@ dom_exception _dom_node_compare_document_position(dom_node_internal *node,
* the responsibility of the caller to unref the string once it has
* finished with it.
*
+ * If there is no text content in the code, NULL will returned in \a result.
+ *
* DOM3Core states that this can raise DOMSTRING_SIZE_ERR. It will not in
* this implementation; dom_strings are unbounded.
*/
@@ -1436,17 +1438,22 @@ dom_exception _dom_node_get_text_content(dom_node_internal *node,
dom_string **result)
{
dom_node_internal *n;
- dom_string *str;
- dom_string *ret;
+ dom_string *str = NULL;
+ dom_string *ret = NULL;
assert(node->owner != NULL);
-
+
for (n = node->first_child; n != NULL; n = n->next) {
- dom_node_get_text_content(n, &ret);
- dom_string_concat(str, ret, &str);
+ dom_node_get_text_content(n, (str == NULL) ? &str : &ret);
+ if (ret != NULL) {
+ dom_string *new_str;
+ dom_string_concat(str, ret, &new_str);
+ dom_string_unref(str);
+ dom_string_unref(ret);
+ str = new_str;
+ }
}
-
- dom_string_ref(str);
+
*result = str;
return DOM_NO_ERR;