diff options
author | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2012-03-24 16:26:55 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2012-03-24 16:26:55 +0000 |
commit | 9b13de6db599b3307422ab0b6ce87221f2058a4d (patch) | |
tree | d0d6d0ba115d4b5f2687940f12a35a240f4d3d4a | |
parent | e27244ca65a05375eec18e686c576a8febdf587e (diff) | |
download | libdom-9b13de6db599b3307422ab0b6ce87221f2058a4d.tar.gz libdom-9b13de6db599b3307422ab0b6ce87221f2058a4d.tar.bz2 |
Fixup _dom_node_get_text_content
svn path=/trunk/libdom/; revision=13598
-rw-r--r-- | src/core/node.c | 21 |
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; |