fixed the streaming property of the reader, it was generating tree faster
* xmlreader.c: fixed the streaming property of the reader,
it was generating tree faster than consuming it. Pointed out
by Nate Myers
* tree.c: fixed a bug in xmlSaveFormatFileEnc if passed a NULL doc
Daniel
diff --git a/ChangeLog b/ChangeLog
index a3edd8d..e710c46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Jan 14 01:15:04 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * xmlreader.c: fixed the streaming property of the reader,
+ it was generating tree faster than consuming it. Pointed out
+ by Nate Myers
+ * tree.c: fixed a bug in xmlSaveFormatFileEnc if passed a NULL doc
+
Sun Jan 12 22:18:02 CET 2003 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
* win32/libxml2.def.src: added more xmlreader and other exports
diff --git a/tree.c b/tree.c
index bae197a..4e3f749 100644
--- a/tree.c
+++ b/tree.c
@@ -7582,6 +7582,9 @@
xmlCharEncoding enc;
int ret;
+ if (cur == NULL)
+ return(-1);
+
if (encoding == NULL)
encoding = (const char *) cur->encoding;
diff --git a/xmlreader.c b/xmlreader.c
index 316ff15..7203217 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -606,8 +606,13 @@
while (((oldstate == XML_TEXTREADER_BACKTRACK) ||
(reader->node->children == NULL) ||
(reader->node->type == XML_ENTITY_REF_NODE) ||
- (reader->node->type == XML_DTD_NODE)) &&
+ (reader->node->type == XML_DTD_NODE) ||
+ (reader->node->type == XML_DOCUMENT_NODE) ||
+ (reader->node->type == XML_HTML_DOCUMENT_NODE)) &&
(reader->node->next == NULL) &&
+ ((reader->ctxt->node == NULL) ||
+ (reader->ctxt->node == reader->node) ||
+ (reader->ctxt->node == reader->node->parent)) &&
(reader->ctxt->nodeNr == olddepth) &&
(reader->ctxt->instate != XML_PARSER_EOF)) {
val = xmlTextReaderPushData(reader);
@@ -643,9 +648,11 @@
/*
* Cleanup of the old node
*/
- if (oldnode->type != XML_DTD_NODE) {
- xmlUnlinkNode(oldnode);
- xmlFreeNode(oldnode);
+ if ((reader->node->prev != NULL) &&
+ (reader->node->prev->type != XML_DTD_NODE)) {
+ xmlNodePtr tmp = reader->node->prev;
+ xmlUnlinkNode(tmp);
+ xmlFreeNode(tmp);
}
goto node_found;