fixed another couple of xmlreader bugs reported by Stéphane Bidoul and
* xmlreader.c python/tests/reader.py: fixed another couple of
xmlreader bugs reported by Stéphane Bidoul and added tests.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 4de7607..1fb78f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jan 1 16:09:57 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * xmlreader.c python/tests/reader.py: fixed another couple of
+ xmlreader bugs reported by Stéphane Bidoul and added tests.
+
Wed Jan 1 15:42:54 CET 2003 Daniel Veillard <daniel@veillard.com>
* xmlreader.c python/tests/reader2.py: fixed another validity
diff --git a/python/tests/reader.py b/python/tests/reader.py
index 69724bd..83fa0e4 100755
--- a/python/tests/reader.py
+++ b/python/tests/reader.py
@@ -305,15 +305,15 @@
reader.Depth())
if reader.NodeType() == 1: # Element
while reader.MoveToNextAttribute():
- res = res + "-- %s (%s) [%s] %d\n" % (reader.NodeType(),
- reader.Name(),reader.Value(),
- reader.Depth())
+ res = res + "-- %s (%s) [%s] %d %d\n" % (reader.NodeType(),
+ reader.Name(),reader.Value(),
+ reader.IsEmptyElement(), reader.Depth())
return res
doc="""<a><b b1="b1"/><c>content of c</c></a>"""
expect="""1 (a) [None] 0 0
1 (b) [None] 1 1
--- 2 (b1) [b1] 2
+-- 2 (b1) [b1] 0 2
1 (c) [None] 0 1
3 (#text) [content of c] 0 2
15 (c) [None] 0 1
@@ -353,6 +353,30 @@
print res
sys.exit(1)
+doc="""<test a="a"/>"""
+expect="""1 (test) [None] 1 0
+-- 2 (a) [a] 0 1
+"""
+res = tst_reader(doc)
+if res != expect:
+ print "test11 failed"
+ print res
+ sys.exit(1)
+
+doc="""<test><a>aaa</a><b/></test>"""
+expect="""1 (test) [None] 0 0
+1 (a) [None] 0 1
+3 (#text) [aaa] 0 2
+15 (a) [None] 0 1
+1 (b) [None] 1 1
+15 (test) [None] 0 0
+"""
+res = tst_reader(doc)
+if res != expect:
+ print "test12 failed"
+ print res
+ sys.exit(1)
+
#
# cleanup for memory allocation counting
#
diff --git a/xmlreader.c b/xmlreader.c
index fea78cb..1d65df6 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -395,8 +395,9 @@
oldstate = reader->state;
olddepth = reader->ctxt->nodeNr;
oldnode = reader->node;
- wasempty = ((reader->wasempty == 1) && (reader->ctxt->node != NULL) &&
- (reader->ctxt->node->last == reader->node));
+ wasempty = (((reader->wasempty == 1) && (reader->ctxt->node != NULL) &&
+ (reader->ctxt->node->last == reader->node)) ||
+ (reader->node != reader->ctxt->node));
/*
* If we are not backtracking on ancestors or examined nodes,
@@ -1443,6 +1444,8 @@
return(-1);
if (reader->node->type != XML_ELEMENT_NODE)
return(0);
+ if (reader->curnode != NULL)
+ return(0);
if (reader->node->children != NULL)
return(0);
if (reader->node != reader->ctxt->node)