Hi all,
it's seems that function calls:
buffer = xmlEncodeEntitiesReentrant(doc, value)
list = xmlStringGetNodeList(doc, buffer);
can be exactly replaced by a simple:
list = xmlNewDocText(doc, value);
You will find theses calls in tree.c. More precisely in
xmlNewPropInternal() and in xmlSetNsProp(), both called by xmlSetProp().
In fact all that xmlEncodeEntitiesReentrant() does, is exactly
undone by xmlStringGetNodeList(). There is any
technical/practical/historical reasons to keep these calls in tree.c?
Below a patch that do this replacement on current trunk. [Just to
illustrate my concern]. Our application and libxml2's "make tests" are
happy with this change.
Thanks.
--
Julien
Index: tree.c
===================================================================
--- tree.c (revision 3680)
+++ tree.c (working copy)
@@ -1814,11 +1814,9 @@
cur->name = name;
if (value != NULL) {
- xmlChar *buffer;
xmlNodePtr tmp;
- buffer = xmlEncodeEntitiesReentrant(doc, value);
- cur->children = xmlStringGetNodeList(doc, buffer);
+ cur->children = xmlNewDocText(doc, value);
cur->last = NULL;
tmp = cur->children;
while (tmp != NULL) {
@@ -1827,7 +1825,6 @@
cur->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
/*
@@ -6466,11 +6463,9 @@
prop->last = NULL;
prop->ns = ns;
if (value != NULL) {
- xmlChar *buffer;
xmlNodePtr tmp;
- buffer = xmlEncodeEntitiesReentrant(node->doc, value);
- prop->children = xmlStringGetNodeList(node->doc, buffer);
+ prop->children = xmlNewDocText(node->doc, value);
prop->last = NULL;
tmp = prop->children;
while (tmp != NULL) {
@@ -6479,7 +6474,6 @@
prop->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
if (prop->atype == XML_ATTRIBUTE_ID)
xmlAddID(NULL, node->doc, value, prop);
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml