fixing a leak detected by testapi in xmlDOMWrapAdoptNode, and fixing

* testapi.c tree.c: fixing a leak detected by testapi in
  xmlDOMWrapAdoptNode, and fixing another side effect in testapi
  seems to pass tests fine now.
* include/libxml/parser.h parser.c: xmlStopParser() is no more limited
  to push mode
* error.c: remove a warning
* runtest.c xmllint.c: avoid compilation errors if only some parts
  of the library are compiled in.
Daniel
This commit is contained in:
Daniel Veillard 2005-07-03 22:48:50 +00:00
parent 7e33dbaa0e
commit 39e5c89016
9 changed files with 73 additions and 31 deletions

View File

@ -1,13 +1,18 @@
Mon Jul 4 00:39:35 CEST 2005 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: fix a problem with previous patch to
testapi.c
Sun Jul 3 23:42:31 CEST 2005 Daniel Veillard <daniel@veillard.com> Sun Jul 3 23:42:31 CEST 2005 Daniel Veillard <daniel@veillard.com>
* testapi.c tree.c: fixing a leak detected by testapi in * testapi.c tree.c: fixing a leak detected by testapi in
xmlDOMWrapAdoptNode, and fixing another side effect in testapi xmlDOMWrapAdoptNode, and fixing another side effect in testapi
seems to pass tests fine now. seems to pass tests fine now.
* include/libxml/parser.h parser.c: xmlStopParser() is no more limited
to push mode
* error.c: remove a warning
* runtest.c xmllint.c: avoid compilation errors if only some parts
of the library are compiled in.
Mon Jul 4 00:39:35 CEST 2005 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: fix a problem with previous patch to
testapi.c
Sun Jul 3 22:59:28 CEST 2005 Daniel Veillard <daniel@veillard.com> Sun Jul 3 22:59:28 CEST 2005 Daniel Veillard <daniel@veillard.com>

View File

@ -127,7 +127,7 @@ AC_ARG_WITH(run_debug,
AC_ARG_WITH(sax1, AC_ARG_WITH(sax1,
[ --with-sax1 add the older SAX1 interface (on)]) [ --with-sax1 add the older SAX1 interface (on)])
AC_ARG_WITH(schemas, AC_ARG_WITH(schemas,
[ --with-schemas add Relax-NG and experimental Schemas support (on)]) [ --with-schemas add Relax-NG and Schemas support (on)])
AC_ARG_WITH(threads, AC_ARG_WITH(threads,
[ --with-threads add multithread support(on)]) [ --with-threads add multithread support(on)])
AC_ARG_WITH(thread-alloc, AC_ARG_WITH(thread-alloc,
@ -155,6 +155,22 @@ AC_ARG_WITH(zlib,
fi fi
]) ])
dnl
dnl hard dependancies on options
dnl
if test "$with_schemas" = "yes"
then
with_pattern=yes
with_regexp=yes
fi
if test "$with_reader" = "yes"
then
with_push=yes
fi
if test "$with_xptr" = "yes"
then
with_xpath=yes
fi
dnl dnl
dnl option to build a minimal libxml2 library dnl option to build a minimal libxml2 library
dnl dnl

View File

@ -514,7 +514,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
if ((node->doc != NULL) && (node->doc->URL != NULL)) { if ((node->doc != NULL) && (node->doc->URL != NULL)) {
baseptr = node; baseptr = node;
file = node->doc->URL; file = (const char *) node->doc->URL;
} }
for (i = 0; for (i = 0;
((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE)); ((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE));

View File

@ -836,10 +836,8 @@ XMLPUBFUN int XMLCALL
xmlSubstituteEntitiesDefault(int val); xmlSubstituteEntitiesDefault(int val);
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlKeepBlanksDefault (int val); xmlKeepBlanksDefault (int val);
#ifdef LIBXML_PUSH_ENABLED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlStopParser (xmlParserCtxtPtr ctxt); xmlStopParser (xmlParserCtxtPtr ctxt);
#endif /* LIBXML_PUSH_ENABLED */
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlPedanticParserDefault(int val); xmlPedanticParserDefault(int val);
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL

View File

@ -10137,24 +10137,6 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
* * * *
************************************************************************/ ************************************************************************/
/**
* xmlStopParser:
* @ctxt: an XML parser context
*
* Blocks further parser processing
*/
void
xmlStopParser(xmlParserCtxtPtr ctxt) {
if (ctxt == NULL)
return;
ctxt->instate = XML_PARSER_EOF;
ctxt->disableSAX = 1;
if (ctxt->input != NULL) {
ctxt->input->cur = BAD_CAST"";
ctxt->input->base = ctxt->input->cur;
}
}
/** /**
* xmlCreatePushParserCtxt: * xmlCreatePushParserCtxt:
* @sax: a SAX handler * @sax: a SAX handler
@ -10287,6 +10269,24 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
} }
#endif /* LIBXML_PUSH_ENABLED */ #endif /* LIBXML_PUSH_ENABLED */
/**
* xmlStopParser:
* @ctxt: an XML parser context
*
* Blocks further parser processing
*/
void
xmlStopParser(xmlParserCtxtPtr ctxt) {
if (ctxt == NULL)
return;
ctxt->instate = XML_PARSER_EOF;
ctxt->disableSAX = 1;
if (ctxt->input != NULL) {
ctxt->input->cur = BAD_CAST"";
ctxt->input->base = ctxt->input->cur;
}
}
/** /**
* xmlCreateIOParserCtxt: * xmlCreateIOParserCtxt:
* @sax: a SAX handler * @sax: a SAX handler

View File

@ -2122,6 +2122,7 @@ streamMemParseTest(const char *filename, const char *result, const char *err,
#endif #endif
#ifdef LIBXML_XPATH_ENABLED #ifdef LIBXML_XPATH_ENABLED
#ifdef LIBXML_DEBUG_ENABLED
/************************************************************************ /************************************************************************
* * * *
* XPath and XPointer based tests * * XPath and XPointer based tests *
@ -2411,6 +2412,7 @@ xmlidDocTest(const char *filename,
return(res); return(res);
} }
#endif /* LIBXML_DEBUG_ENABLED */
#endif /* XPATH */ #endif /* XPATH */
/************************************************************************ /************************************************************************
* * * *
@ -2909,6 +2911,7 @@ rngTest(const char *filename,
return(res); return(res);
} }
#ifdef LIBXML_READER_ENABLED
/** /**
* rngStreamTest: * rngStreamTest:
* @filename: the schemas file * @filename: the schemas file
@ -2999,11 +3002,12 @@ rngStreamTest(const char *filename,
return(res); return(res);
} }
#endif /* READER */
#endif #endif
#ifdef LIBXML_PATTERN_ENABLED #ifdef LIBXML_PATTERN_ENABLED
#ifdef LIBXML_READER_ENABLED
/************************************************************************ /************************************************************************
* * * *
* Patterns tests * * Patterns tests *
@ -3212,7 +3216,8 @@ patternTest(const char *filename,
free(temp); free(temp);
return(ret); return(ret);
} }
#endif #endif /* READER */
#endif /* PATTERN */
#ifdef LIBXML_C14N_ENABLED #ifdef LIBXML_C14N_ENABLED
/************************************************************************ /************************************************************************
* * * *
@ -3890,6 +3895,7 @@ testDesc testDescriptions[] = {
NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE },
#endif #endif
#ifdef LIBXML_XPATH_ENABLED #ifdef LIBXML_XPATH_ENABLED
#ifdef LIBXML_DEBUG_ENABLED
{ "XPath expressions regression tests" , { "XPath expressions regression tests" ,
xpathExprTest, "./test/XPath/expr/*", "result/XPath/expr/", "", NULL, xpathExprTest, "./test/XPath/expr/*", "result/XPath/expr/", "", NULL,
0 }, 0 },
@ -3904,6 +3910,7 @@ testDesc testDescriptions[] = {
{ "xml:id regression tests" , { "xml:id regression tests" ,
xmlidDocTest, "./test/xmlid/*", "result/xmlid/", "", ".err", xmlidDocTest, "./test/xmlid/*", "result/xmlid/", "", ".err",
0 }, 0 },
#endif
#endif #endif
{ "URI parsing tests" , { "URI parsing tests" ,
uriParseTest, "./test/URI/*.uri", "result/URI/", "", NULL, uriParseTest, "./test/URI/*.uri", "result/URI/", "", NULL,
@ -3918,15 +3925,19 @@ testDesc testDescriptions[] = {
{ "Relax-NG regression tests" , { "Relax-NG regression tests" ,
rngTest, "./test/relaxng/*.rng", NULL, NULL, NULL, rngTest, "./test/relaxng/*.rng", NULL, NULL, NULL,
XML_PARSE_DTDATTR | XML_PARSE_NOENT }, XML_PARSE_DTDATTR | XML_PARSE_NOENT },
#ifdef LIBXML_READER_ENABLED
{ "Relax-NG streaming regression tests" , { "Relax-NG streaming regression tests" ,
rngStreamTest, "./test/relaxng/*.rng", NULL, NULL, NULL, rngStreamTest, "./test/relaxng/*.rng", NULL, NULL, NULL,
XML_PARSE_DTDATTR | XML_PARSE_NOENT }, XML_PARSE_DTDATTR | XML_PARSE_NOENT },
#endif #endif
#endif
#ifdef LIBXML_PATTERN_ENABLED #ifdef LIBXML_PATTERN_ENABLED
#ifdef LIBXML_READER_ENABLED
{ "Pattern regression tests" , { "Pattern regression tests" ,
patternTest, "./test/pattern/*.pat", "result/pattern/", NULL, NULL, patternTest, "./test/pattern/*.pat", "result/pattern/", NULL, NULL,
0 }, 0 },
#endif #endif
#endif
#ifdef LIBXML_C14N_ENABLED #ifdef LIBXML_C14N_ENABLED
{ "C14N with comments regression tests" , { "C14N with comments regression tests" ,
c14nWithCommentTest, "./test/c14n/with-comments/*.xml", NULL, NULL, NULL, c14nWithCommentTest, "./test/c14n/with-comments/*.xml", NULL, NULL, NULL,

2
tree.c
View File

@ -7445,7 +7445,7 @@ xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapItemPtr *map,
str = xmlDictLookup(destDoc->dict, str, -1); \ str = xmlDictLookup(destDoc->dict, str, -1); \
if ((sourceDoc == NULL) || (sourceDoc->dict == NULL) || \ if ((sourceDoc == NULL) || (sourceDoc->dict == NULL) || \
(!xmlDictOwns(sourceDoc->dict, old))) \ (!xmlDictOwns(sourceDoc->dict, old))) \
xmlFree(old); \ xmlFree((char *)old); \
} else if ((sourceDoc) && (sourceDoc->dict) && \ } else if ((sourceDoc) && (sourceDoc->dict) && \
xmlDictOwns(sourceDoc->dict, str)) { \ xmlDictOwns(sourceDoc->dict, str)) { \
str = BAD_CAST xmlStrdup(str); \ str = BAD_CAST xmlStrdup(str); \

View File

@ -2341,7 +2341,11 @@ main(int argc, char **argv) {
} }
#endif /* LIBXML_SCHEMAS_ENABLED */ #endif /* LIBXML_SCHEMAS_ENABLED */
#ifdef LIBXML_PATTERN_ENABLED #ifdef LIBXML_PATTERN_ENABLED
if ((pattern != NULL) && (walker == 0)) { if ((pattern != NULL)
#ifdef LIBXML_WALKER_ENABLED
&& (walker == 0)
#endif
) {
patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL); patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
if (patternc == NULL) { if (patternc == NULL) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,

View File

@ -664,7 +664,9 @@ struct _xmlSchemaValidCtxt {
xmlDictPtr dict; xmlDictPtr dict;
#ifdef LIBXML_READER_ENABLED
xmlTextReaderPtr reader; xmlTextReaderPtr reader;
#endif
xmlSchemaAttrInfoPtr *attrInfos; xmlSchemaAttrInfoPtr *attrInfos;
int nbAttrInfos; int nbAttrInfos;
@ -18330,6 +18332,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt,
} }
} }
return (NULL); return (NULL);
#ifdef LIBXML_WRITER_ENABLED
} else if (vctxt->reader != NULL) { } else if (vctxt->reader != NULL) {
xmlChar *nsName; xmlChar *nsName;
@ -18343,6 +18346,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt,
return (ret); return (ret);
} else } else
return (NULL); return (NULL);
#endif
} else { } else {
xmlNsPtr ns; xmlNsPtr ns;
@ -23411,7 +23415,9 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
vctxt->flags = 0; vctxt->flags = 0;
vctxt->validationRoot = NULL; vctxt->validationRoot = NULL;
vctxt->doc = NULL; vctxt->doc = NULL;
#ifdef LIBXML_READER_ENABLED
vctxt->reader = NULL; vctxt->reader = NULL;
#endif
if (vctxt->value != NULL) { if (vctxt->value != NULL) {
xmlSchemaFreeValue(vctxt->value); xmlSchemaFreeValue(vctxt->value);
vctxt->value = NULL; vctxt->value = NULL;
@ -23846,12 +23852,14 @@ xmlSchemaVStart(xmlSchemaValidCtxtPtr vctxt)
* Tree validation. * Tree validation.
*/ */
ret = xmlSchemaVDocWalk(vctxt); ret = xmlSchemaVDocWalk(vctxt);
#ifdef LIBXML_READER_ENABLED
} else if (vctxt->reader != NULL) { } else if (vctxt->reader != NULL) {
/* /*
* XML Reader validation. * XML Reader validation.
*/ */
#ifdef XML_SCHEMA_READER_ENABLED #ifdef XML_SCHEMA_READER_ENABLED
ret = xmlSchemaVReaderWalk(vctxt); ret = xmlSchemaVReaderWalk(vctxt);
#endif
#endif #endif
} else if ((vctxt->sax != NULL) && (vctxt->parserCtxt != NULL)) { } else if ((vctxt->sax != NULL) && (vctxt->parserCtxt != NULL)) {
/* /*