1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Use struct dom_string for node->attribute.value

This commit is contained in:
Jonas Fonseca 2005-12-10 18:42:54 +01:00 committed by Jonas Fonseca
parent ce3778c3c0
commit ed7a292966
4 changed files with 9 additions and 9 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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);

View File

@ -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