From ed7a292966eb3bc288512a4230ef829c27619f5c Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 18:42:54 +0100 Subject: [PATCH] Use struct dom_string for node->attribute.value --- src/document/dom/node.c | 4 ++-- src/document/dom/node.h | 6 ++---- src/document/dom/renderer.c | 6 +++--- src/document/dom/string.h | 2 ++ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 91d41e5fa..3ab91d553 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -422,8 +422,8 @@ get_dom_node_value(struct dom_node *node, int codepage) switch (node->type) { case DOM_NODE_ATTRIBUTE: - value = node->data.attribute.value; - valuelen = node->data.attribute.valuelen; + value = node->data.attribute.value.string; + valuelen = node->data.attribute.value.length; break; case DOM_NODE_PROCESSING_INSTRUCTION: diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 0d0d627de..688b6002e 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -107,8 +107,7 @@ struct dom_attribute_node { /* The string that hold the attribute value. The @string / @length * members of {struct dom_node} holds the name that identifies the node * in the map. */ - unsigned char *value; - uint16_t valuelen; + struct dom_string value; /* For xml:lang="en" attributes this holds the offset of 'lang' */ uint16_t namespace_offset; @@ -272,8 +271,7 @@ add_dom_attribute(struct dom_node *parent, unsigned char *string, int length, struct dom_node *node = add_dom_node(parent, DOM_NODE_ATTRIBUTE, string, length); if (node && value) { - node->data.attribute.value = value; - node->data.attribute.valuelen = valuelen; + set_dom_string(&node->data.attribute.value, value, valuelen); } return node; diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 1cd372f4e..05ccb0ae0 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -645,10 +645,10 @@ render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void #endif render_dom_node_text(renderer, template, node); - if (node->data.attribute.value) { + if (is_dom_string_set(&node->data.attribute.value)) { int quoted = node->data.attribute.quoted == 1; - unsigned char *value = node->data.attribute.value - quoted; - int valuelen = node->data.attribute.valuelen + quoted * 2; + unsigned char *value = node->data.attribute.value.string - quoted; + int valuelen = node->data.attribute.value.length + quoted * 2; if (check_dom_node_source(renderer, value, 0)) { render_dom_flush(renderer, value); diff --git a/src/document/dom/string.h b/src/document/dom/string.h index b93cf7c22..5956bea1d 100644 --- a/src/document/dom/string.h +++ b/src/document/dom/string.h @@ -16,6 +16,8 @@ set_dom_string(struct dom_string *string, unsigned char *value, uint16_t length) string->length = length; } +#define is_dom_string_set(str) ((str)->string && (str)->length) + #define done_dom_string(str) mem_free((str)->string); #endif