mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
patch from Julien Charbon to simplify the processing of xmlSetProp()
* include/libxml/xmlerror.h tree.c: patch from Julien Charbon to simplify the processing of xmlSetProp() Daniel svn path=/trunk/; revision=3694
This commit is contained in:
parent
8e1a46d526
commit
6f8611fdb4
@ -1,3 +1,8 @@
|
||||
Fri Feb 15 09:32:11 CET 2008 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* include/libxml/xmlerror.h tree.c: patch from Julien Charbon
|
||||
to simplify the processing of xmlSetProp()
|
||||
|
||||
Fri Feb 15 08:45:32 CET 2008 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* config.h.in configure.in encoding.c: patch from Roumen Petrov
|
||||
|
@ -398,6 +398,7 @@ typedef enum {
|
||||
XML_TREE_INVALID_HEX = 1300,
|
||||
XML_TREE_INVALID_DEC, /* 1301 */
|
||||
XML_TREE_UNTERMINATED_ENTITY, /* 1302 */
|
||||
XML_TREE_NOT_UTF8, /* 1303 */
|
||||
XML_SAVE_NOT_UTF8 = 1400,
|
||||
XML_SAVE_CHAR_INVALID, /* 1401 */
|
||||
XML_SAVE_NO_DOCTYPE, /* 1402 */
|
||||
|
25
tree.c
25
tree.c
@ -92,6 +92,9 @@ xmlTreeErr(int code, xmlNodePtr node, const char *extra)
|
||||
case XML_TREE_UNTERMINATED_ENTITY:
|
||||
msg = "unterminated entity reference %15s\n";
|
||||
break;
|
||||
case XML_TREE_NOT_UTF8:
|
||||
msg = "string is not in UTF-8\n";
|
||||
break;
|
||||
default:
|
||||
msg = "unexpected error number\n";
|
||||
}
|
||||
@ -1814,11 +1817,15 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
|
||||
cur->name = name;
|
||||
|
||||
if (value != NULL) {
|
||||
xmlChar *buffer;
|
||||
xmlNodePtr tmp;
|
||||
|
||||
buffer = xmlEncodeEntitiesReentrant(doc, value);
|
||||
cur->children = xmlStringGetNodeList(doc, buffer);
|
||||
if(!xmlCheckUTF8(value)) {
|
||||
xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) doc,
|
||||
NULL);
|
||||
if (doc != NULL)
|
||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||
}
|
||||
cur->children = xmlNewDocText(doc, value);
|
||||
cur->last = NULL;
|
||||
tmp = cur->children;
|
||||
while (tmp != NULL) {
|
||||
@ -1827,7 +1834,6 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
|
||||
cur->last = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
xmlFree(buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -6466,11 +6472,15 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
|
||||
prop->last = NULL;
|
||||
prop->ns = ns;
|
||||
if (value != NULL) {
|
||||
xmlChar *buffer;
|
||||
xmlNodePtr tmp;
|
||||
|
||||
buffer = xmlEncodeEntitiesReentrant(node->doc, value);
|
||||
prop->children = xmlStringGetNodeList(node->doc, buffer);
|
||||
if(!xmlCheckUTF8(value)) {
|
||||
xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) node->doc,
|
||||
NULL);
|
||||
if (node->doc != NULL)
|
||||
node->doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||
}
|
||||
prop->children = xmlNewDocText(node->doc, value);
|
||||
prop->last = NULL;
|
||||
tmp = prop->children;
|
||||
while (tmp != NULL) {
|
||||
@ -6479,7 +6489,6 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
|
||||
prop->last = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
xmlFree(buffer);
|
||||
}
|
||||
if (prop->atype == XML_ATTRIBUTE_ID)
|
||||
xmlAddID(NULL, node->doc, value, prop);
|
||||
|
Loading…
x
Reference in New Issue
Block a user