fixed another couple of xmlreader bugs reported by Stphane Bidoul and

* xmlreader.c python/tests/reader.py: fixed another couple of
  xmlreader bugs reported by Stphane Bidoul and added tests.
Daniel
This commit is contained in:
Daniel Veillard 2003-01-01 15:11:05 +00:00
parent 9e395c289f
commit e3c036eedd
3 changed files with 38 additions and 6 deletions

View File

@ -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

View File

@ -305,15 +305,15 @@ def tst_reader(s):
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 @@ if res != expect:
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
#

View File

@ -395,8 +395,9 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
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 @@ xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader) {
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)