Author: tlsa
Date: Thu Dec 22 05:59:57 2011
New Revision: 13326
URL:
http://source.netsurf-browser.org?rev=13326&view=rev
Log:
Fix length for dom_string creation. Dump id attribute too.
Modified:
trunk/libdom/examples/dom-structure-dump.c
Modified: trunk/libdom/examples/dom-structure-dump.c
URL:
http://source.netsurf-browser.org/trunk/libdom/examples/dom-structure-dum...
==============================================================================
--- trunk/libdom/examples/dom-structure-dump.c (original)
+++ trunk/libdom/examples/dom-structure-dump.c Thu Dec 22 05:59:57 2011
@@ -41,6 +41,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <dom/dom.h>
#include <dom/bindings/hubbub/parser.h>
@@ -153,7 +154,7 @@
assert(type == DOM_ELEMENT_NODE);
/* Create a dom_string containing required attribute name. */
- exc = dom_string_create((uint8_t *)attribute, 5, &attr);
+ exc = dom_string_create((uint8_t *)attribute, strlen(attribute), &attr);
if (exc != DOM_NO_ERR) {
printf(" Exception raised for dom_string_create\n");
return false;
@@ -238,8 +239,10 @@
/* Finished with the node_name dom_string */
dom_string_unref(node_name);
- /* Print the element's class, if it has one */
- if (dump_dom_element_attribute(node, "class") == false) {
+ /* Print the element's id & class, if it has them */
+ if (dump_dom_element_attribute(node, "id") == false ||
+ dump_dom_element_attribute(node, "class") == false) {
+ /* Error occured */
printf("\n");
return false;
}