mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
make the push interfaces synchronous added a specific test added the new
* parser.c: make the push interfaces synchronous * python/tests/sync.py: added a specific test * python/tests/Makefile.am doc/examples/Makefile.am doc/examples/index.py: added the new test, cleaning up "make tests" output Daniel
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
Mon Jul 5 18:43:47 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* parser.c: make the push interfaces synchronous
|
||||||
|
* python/tests/sync.py: added a specific test
|
||||||
|
* python/tests/Makefile.am doc/examples/Makefile.am
|
||||||
|
doc/examples/index.py: added the new test, cleaning up
|
||||||
|
"make tests" output
|
||||||
|
|
||||||
Mon Jul 5 15:09:17 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
Mon Jul 5 15:09:17 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xmlschemas.c: applied patch from Kasimier to fix some Relax-NG
|
* xmlschemas.c: applied patch from Kasimier to fix some Relax-NG
|
||||||
|
@ -93,6 +93,7 @@ valgrind:
|
|||||||
$(MAKE) CHECKER='valgrind -q' tests
|
$(MAKE) CHECKER='valgrind -q' tests
|
||||||
|
|
||||||
tests: $(noinst_PROGRAMS)
|
tests: $(noinst_PROGRAMS)
|
||||||
|
@(echo '## examples regression tests')
|
||||||
@(echo > .memdump)
|
@(echo > .memdump)
|
||||||
@($(CHECKER) ././xpath1 test3.xml '//child2' > xpath1.tmp ; diff xpath1.tmp xpath1.res ; rm xpath1.tmp)
|
@($(CHECKER) ././xpath1 test3.xml '//child2' > xpath1.tmp ; diff xpath1.tmp xpath1.res ; rm xpath1.tmp)
|
||||||
@(grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
|
@(grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
|
||||||
|
File diff suppressed because one or more lines are too long
@ -251,6 +251,7 @@ install-data-local:
|
|||||||
example, example)
|
example, example)
|
||||||
Makefile = Makefile + "valgrind: \n\t$(MAKE) CHECKER='valgrind -q' tests\n\n"
|
Makefile = Makefile + "valgrind: \n\t$(MAKE) CHECKER='valgrind -q' tests\n\n"
|
||||||
Makefile = Makefile + "tests: $(noinst_PROGRAMS)\n"
|
Makefile = Makefile + "tests: $(noinst_PROGRAMS)\n"
|
||||||
|
Makefile = Makefile + "\t@(echo '## examples regression tests')\n"
|
||||||
Makefile = Makefile + "\t@(echo > .memdump)\n"
|
Makefile = Makefile + "\t@(echo > .memdump)\n"
|
||||||
for test in tests:
|
for test in tests:
|
||||||
Makefile = Makefile + "\t@($(CHECKER) %s)\n" % (test)
|
Makefile = Makefile + "\t@($(CHECKER) %s)\n" % (test)
|
||||||
|
49
parser.c
49
parser.c
@ -8818,29 +8818,37 @@ xmlParseGetLasts(xmlParserCtxtPtr ctxt, const xmlChar **lastlt,
|
|||||||
if ((ctxt->progressive != 0) && (ctxt->inputNr == 1)) {
|
if ((ctxt->progressive != 0) && (ctxt->inputNr == 1)) {
|
||||||
tmp = ctxt->input->end;
|
tmp = ctxt->input->end;
|
||||||
tmp--;
|
tmp--;
|
||||||
while ((tmp >= ctxt->input->base) && (*tmp != '<') &&
|
while ((tmp >= ctxt->input->base) && (*tmp != '<')) tmp--;
|
||||||
(*tmp != '>')) tmp--;
|
|
||||||
if (tmp < ctxt->input->base) {
|
if (tmp < ctxt->input->base) {
|
||||||
*lastlt = NULL;
|
*lastlt = NULL;
|
||||||
*lastgt = NULL;
|
*lastgt = NULL;
|
||||||
} else if (*tmp == '<') {
|
|
||||||
*lastlt = tmp;
|
|
||||||
tmp--;
|
|
||||||
while ((tmp >= ctxt->input->base) && (*tmp != '>')) tmp--;
|
|
||||||
if (tmp < ctxt->input->base)
|
|
||||||
*lastgt = NULL;
|
|
||||||
else
|
|
||||||
*lastgt = tmp;
|
|
||||||
} else {
|
} else {
|
||||||
*lastgt = tmp;
|
*lastlt = tmp;
|
||||||
tmp--;
|
tmp++;
|
||||||
while ((tmp >= ctxt->input->base) && (*tmp != '<')) tmp--;
|
while ((tmp < ctxt->input->end) && (*tmp != '>')) {
|
||||||
if (tmp < ctxt->input->base)
|
if (*tmp == '\'') {
|
||||||
*lastlt = NULL;
|
tmp++;
|
||||||
else
|
while ((tmp < ctxt->input->end) && (*tmp != '\'')) tmp++;
|
||||||
*lastlt = tmp;
|
if (tmp < ctxt->input->end) tmp++;
|
||||||
|
} else if (*tmp == '"') {
|
||||||
|
tmp++;
|
||||||
|
while ((tmp < ctxt->input->end) && (*tmp != '"')) tmp++;
|
||||||
|
if (tmp < ctxt->input->end) tmp++;
|
||||||
|
} else
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
if (tmp < ctxt->input->end)
|
||||||
|
*lastgt = tmp;
|
||||||
|
else {
|
||||||
|
tmp = *lastlt;
|
||||||
|
tmp--;
|
||||||
|
while ((tmp >= ctxt->input->base) && (*tmp != '>')) tmp--;
|
||||||
|
if (tmp >= ctxt->input->base)
|
||||||
|
*lastgt = tmp;
|
||||||
|
else
|
||||||
|
*lastgt = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*lastlt = NULL;
|
*lastlt = NULL;
|
||||||
*lastgt = NULL;
|
*lastgt = NULL;
|
||||||
@ -9096,7 +9104,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
if (!terminate) {
|
if (!terminate) {
|
||||||
if (ctxt->progressive) {
|
if (ctxt->progressive) {
|
||||||
/* > can be found unescaped in attribute values */
|
/* > can be found unescaped in attribute values */
|
||||||
if ((lastlt == NULL) || (ctxt->input->cur >= lastlt))
|
if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
|
||||||
goto done;
|
goto done;
|
||||||
} else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
|
} else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
|
||||||
goto done;
|
goto done;
|
||||||
@ -9274,7 +9282,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
goto done;
|
goto done;
|
||||||
if (!terminate) {
|
if (!terminate) {
|
||||||
if (ctxt->progressive) {
|
if (ctxt->progressive) {
|
||||||
if ((lastgt == NULL) || (ctxt->input->cur > lastgt))
|
/* > can be found unescaped in attribute values */
|
||||||
|
if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
|
||||||
goto done;
|
goto done;
|
||||||
} else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
|
} else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -33,6 +33,7 @@ PYTESTS= \
|
|||||||
readererr.py\
|
readererr.py\
|
||||||
relaxng.py \
|
relaxng.py \
|
||||||
thread2.py \
|
thread2.py \
|
||||||
|
sync.py \
|
||||||
tstLastError.py \
|
tstLastError.py \
|
||||||
indexes.py
|
indexes.py
|
||||||
|
|
||||||
@ -45,8 +46,13 @@ EXTRA_DIST = $(PYTESTS) $(XMLS)
|
|||||||
|
|
||||||
if WITH_PYTHON
|
if WITH_PYTHON
|
||||||
tests: $(PYTESTS)
|
tests: $(PYTESTS)
|
||||||
-@(PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; export PYTHONPATH; \
|
echo "## running Python regression tests"
|
||||||
for test in $(PYTESTS) ; do echo "-- $$test" ; $(PYTHON) $(srcdir)/$$test ; done)
|
-@(PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; \
|
||||||
|
export PYTHONPATH; \
|
||||||
|
for test in $(PYTESTS) ; \
|
||||||
|
do log=`$(PYTHON) $(srcdir)/$$test` ; \
|
||||||
|
if [ "`echo $$log | grep OK`" = "" ] ; then \
|
||||||
|
echo "-- $$test" ; echo "$$log" ; fi ; done)
|
||||||
else
|
else
|
||||||
tests:
|
tests:
|
||||||
endif
|
endif
|
||||||
|
135
python/tests/sync.py
Executable file
135
python/tests/sync.py
Executable file
@ -0,0 +1,135 @@
|
|||||||
|
#!/usr/bin/python -u
|
||||||
|
import sys
|
||||||
|
import libxml2
|
||||||
|
|
||||||
|
# Memory debug specific
|
||||||
|
libxml2.debugMemory(1)
|
||||||
|
|
||||||
|
log = ""
|
||||||
|
|
||||||
|
class callback:
|
||||||
|
def startDocument(self):
|
||||||
|
global log
|
||||||
|
log = log + "startDocument:"
|
||||||
|
|
||||||
|
def endDocument(self):
|
||||||
|
global log
|
||||||
|
log = log + "endDocument:"
|
||||||
|
|
||||||
|
def startElement(self, tag, attrs):
|
||||||
|
global log
|
||||||
|
log = log + "startElement %s %s:" % (tag, attrs)
|
||||||
|
|
||||||
|
def endElement(self, tag):
|
||||||
|
global log
|
||||||
|
log = log + "endElement %s:" % (tag)
|
||||||
|
|
||||||
|
def characters(self, data):
|
||||||
|
global log
|
||||||
|
log = log + "characters: %s:" % (data)
|
||||||
|
|
||||||
|
def warning(self, msg):
|
||||||
|
global log
|
||||||
|
log = log + "warning: %s:" % (msg)
|
||||||
|
|
||||||
|
def error(self, msg):
|
||||||
|
global log
|
||||||
|
log = log + "error: %s:" % (msg)
|
||||||
|
|
||||||
|
def fatalError(self, msg):
|
||||||
|
global log
|
||||||
|
log = log + "fatalError: %s:" % (msg)
|
||||||
|
|
||||||
|
handler = callback()
|
||||||
|
|
||||||
|
log=""
|
||||||
|
chunk="""<foo><bar2/>"""
|
||||||
|
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
|
||||||
|
ctxt.parseChunk(chunk, len(chunk), 0)
|
||||||
|
ctxt=None
|
||||||
|
|
||||||
|
reference = "startDocument:startElement foo None:startElement bar2 None:endElement bar2:"
|
||||||
|
if log != reference:
|
||||||
|
print "Error got: %s" % log
|
||||||
|
print "Exprected: %s" % reference
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
log=""
|
||||||
|
chunk="""<foo><bar2></bar2>"""
|
||||||
|
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
|
||||||
|
ctxt.parseChunk(chunk, len(chunk), 0)
|
||||||
|
ctxt=None
|
||||||
|
|
||||||
|
reference = "startDocument:startElement foo None:startElement bar2 None:endElement bar2:"
|
||||||
|
if log != reference:
|
||||||
|
print "Error got: %s" % log
|
||||||
|
print "Exprected: %s" % reference
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
log=""
|
||||||
|
chunk="""<foo><bar2>"""
|
||||||
|
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
|
||||||
|
ctxt.parseChunk(chunk, len(chunk), 0)
|
||||||
|
ctxt=None
|
||||||
|
|
||||||
|
reference = "startDocument:startElement foo None:startElement bar2 None:"
|
||||||
|
if log != reference:
|
||||||
|
print "Error got: %s" % log
|
||||||
|
print "Exprected: %s" % reference
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
log=""
|
||||||
|
chunk="""<foo><bar2 a="1" b='2' />"""
|
||||||
|
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
|
||||||
|
ctxt.parseChunk(chunk, len(chunk), 0)
|
||||||
|
ctxt=None
|
||||||
|
|
||||||
|
reference = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:endElement bar2:"
|
||||||
|
if log != reference:
|
||||||
|
print "Error got: %s" % log
|
||||||
|
print "Exprected: %s" % reference
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
log=""
|
||||||
|
chunk="""<foo><bar2 a="1" b='2' >"""
|
||||||
|
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
|
||||||
|
ctxt.parseChunk(chunk, len(chunk), 0)
|
||||||
|
ctxt=None
|
||||||
|
|
||||||
|
reference = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:"
|
||||||
|
if log != reference:
|
||||||
|
print "Error got: %s" % log
|
||||||
|
print "Exprected: %s" % reference
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
log=""
|
||||||
|
chunk="""<foo><bar2 a="1" b='2' ></bar2>"""
|
||||||
|
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
|
||||||
|
ctxt.parseChunk(chunk, len(chunk), 0)
|
||||||
|
ctxt=None
|
||||||
|
|
||||||
|
reference = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:endElement bar2:"
|
||||||
|
if log != reference:
|
||||||
|
print "Error got: %s" % log
|
||||||
|
print "Exprected: %s" % reference
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
log=""
|
||||||
|
chunk="""<foo><bar2 a="b='1' />"""
|
||||||
|
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
|
||||||
|
ctxt.parseChunk(chunk, len(chunk), 0)
|
||||||
|
ctxt=None
|
||||||
|
|
||||||
|
reference = "startDocument:startElement foo None:"
|
||||||
|
if log != reference:
|
||||||
|
print "Error got: %s" % log
|
||||||
|
print "Exprected: %s" % reference
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Memory debug specific
|
||||||
|
libxml2.cleanupParser()
|
||||||
|
if libxml2.debugMemory(1) == 0:
|
||||||
|
print "OK"
|
||||||
|
else:
|
||||||
|
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
|
||||||
|
libxml2.dumpMemory()
|
Reference in New Issue
Block a user