fixed some wording make sure doc/examples is packaged fixed the really
* Copyright: fixed some wording
* libxml.spec.in: make sure doc/examples is packaged
* include/libxml/tree.h valid.c xmlreader.c: fixed the really
annoying problem about xmlRemoveID and xmlReader streaming.
Thing looks fixed now, add to add a doc reference to the
xmlID structure though...
Daniel
diff --git a/valid.c b/valid.c
index 9599cd1..9fb9b69 100644
--- a/valid.c
+++ b/valid.c
@@ -2359,6 +2359,18 @@
* *
************************************************************************/
/**
+ * DICT_FREE:
+ * @str: a string
+ *
+ * Free a string if it is not owned by the "dict" dictionnary in the
+ * current scope
+ */
+#define DICT_FREE(str) \
+ if ((str) && ((!dict) || \
+ (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
+ xmlFree((char *)(str));
+
+/**
* xmlCreateIDTable:
*
* create and initialize an empty id hash table.
@@ -2379,14 +2391,21 @@
*/
static void
xmlFreeID(xmlIDPtr id) {
+ xmlDictPtr dict = NULL;
+
if (id == NULL) return;
+
+ if (id->doc != NULL)
+ dict = id->doc->dict;
+
if (id->value != NULL)
- xmlFree((xmlChar *) id->value);
+ DICT_FREE(id->value)
if (id->name != NULL)
- xmlFree((xmlChar *) id->name);
+ DICT_FREE(id->name)
xmlFree(id);
}
+
/**
* xmlAddID:
* @ctxt: the validation context
@@ -2436,11 +2455,15 @@
* fill the structure.
*/
ret->value = xmlStrdup(value);
+ ret->doc = doc;
if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
/*
* Operating in streaming mode, attr is gonna disapear
*/
- ret->name = xmlStrdup(attr->name);
+ if (doc->dict != NULL)
+ ret->name = xmlDictLookup(doc->dict, attr->name, -1);
+ else
+ ret->name = xmlStrdup(attr->name);
ret->attr = NULL;
} else {
ret->attr = attr;
@@ -2546,8 +2569,8 @@
*/
int
xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
- xmlAttrPtr cur;
xmlIDTablePtr table;
+ xmlIDPtr id;
xmlChar *ID;
if (doc == NULL) return(-1);
@@ -2561,8 +2584,8 @@
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
return(-1);
- cur = xmlHashLookup(table, ID);
- if (cur != attr) {
+ id = xmlHashLookup(table, ID);
+ if (id == NULL || id->attr != attr) {
xmlFree(ID);
return(-1);
}