From 39e5c89016db91821b11262b5d19d7d7926a89c6 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Sun, 3 Jul 2005 22:48:50 +0000 Subject: [PATCH] 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 --- ChangeLog | 15 ++++++++++----- configure.in | 18 +++++++++++++++++- error.c | 2 +- include/libxml/parser.h | 2 -- parser.c | 36 ++++++++++++++++++------------------ runtest.c | 15 +++++++++++++-- tree.c | 2 +- xmllint.c | 6 +++++- xmlschemas.c | 8 ++++++++ 9 files changed, 73 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index e31b0eaf..5d5ab9f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,18 @@ -Mon Jul 4 00:39:35 CEST 2005 Daniel Veillard - - * gentest.py testapi.c: fix a problem with previous patch to - testapi.c - Sun Jul 3 23:42:31 CEST 2005 Daniel Veillard * 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. + +Mon Jul 4 00:39:35 CEST 2005 Daniel Veillard + + * gentest.py testapi.c: fix a problem with previous patch to + testapi.c Sun Jul 3 22:59:28 CEST 2005 Daniel Veillard diff --git a/configure.in b/configure.in index 768912de..e5ca84f3 100644 --- a/configure.in +++ b/configure.in @@ -127,7 +127,7 @@ AC_ARG_WITH(run_debug, AC_ARG_WITH(sax1, [ --with-sax1 add the older SAX1 interface (on)]) 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, [ --with-threads add multithread support(on)]) AC_ARG_WITH(thread-alloc, @@ -155,6 +155,22 @@ AC_ARG_WITH(zlib, 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 option to build a minimal libxml2 library dnl diff --git a/error.c b/error.c index 1c2024be..17ced922 100644 --- a/error.c +++ b/error.c @@ -514,7 +514,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel, if ((node->doc != NULL) && (node->doc->URL != NULL)) { baseptr = node; - file = node->doc->URL; + file = (const char *) node->doc->URL; } for (i = 0; ((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE)); diff --git a/include/libxml/parser.h b/include/libxml/parser.h index e0de43fa..7203ca3c 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -836,10 +836,8 @@ XMLPUBFUN int XMLCALL xmlSubstituteEntitiesDefault(int val); XMLPUBFUN int XMLCALL xmlKeepBlanksDefault (int val); -#ifdef LIBXML_PUSH_ENABLED XMLPUBFUN void XMLCALL xmlStopParser (xmlParserCtxtPtr ctxt); -#endif /* LIBXML_PUSH_ENABLED */ XMLPUBFUN int XMLCALL xmlPedanticParserDefault(int val); XMLPUBFUN int XMLCALL diff --git a/parser.c b/parser.c index 352ffa37..ff863d9f 100644 --- a/parser.c +++ b/parser.c @@ -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: * @sax: a SAX handler @@ -10287,6 +10269,24 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data, } #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: * @sax: a SAX handler diff --git a/runtest.c b/runtest.c index 0854a07c..79473adf 100644 --- a/runtest.c +++ b/runtest.c @@ -2122,6 +2122,7 @@ streamMemParseTest(const char *filename, const char *result, const char *err, #endif #ifdef LIBXML_XPATH_ENABLED +#ifdef LIBXML_DEBUG_ENABLED /************************************************************************ * * * XPath and XPointer based tests * @@ -2411,6 +2412,7 @@ xmlidDocTest(const char *filename, return(res); } +#endif /* LIBXML_DEBUG_ENABLED */ #endif /* XPATH */ /************************************************************************ * * @@ -2909,6 +2911,7 @@ rngTest(const char *filename, return(res); } +#ifdef LIBXML_READER_ENABLED /** * rngStreamTest: * @filename: the schemas file @@ -2999,11 +3002,12 @@ rngStreamTest(const char *filename, return(res); } - +#endif /* READER */ #endif #ifdef LIBXML_PATTERN_ENABLED +#ifdef LIBXML_READER_ENABLED /************************************************************************ * * * Patterns tests * @@ -3212,7 +3216,8 @@ patternTest(const char *filename, free(temp); return(ret); } -#endif +#endif /* READER */ +#endif /* PATTERN */ #ifdef LIBXML_C14N_ENABLED /************************************************************************ * * @@ -3890,6 +3895,7 @@ testDesc testDescriptions[] = { NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, #endif #ifdef LIBXML_XPATH_ENABLED +#ifdef LIBXML_DEBUG_ENABLED { "XPath expressions regression tests" , xpathExprTest, "./test/XPath/expr/*", "result/XPath/expr/", "", NULL, 0 }, @@ -3904,6 +3910,7 @@ testDesc testDescriptions[] = { { "xml:id regression tests" , xmlidDocTest, "./test/xmlid/*", "result/xmlid/", "", ".err", 0 }, +#endif #endif { "URI parsing tests" , uriParseTest, "./test/URI/*.uri", "result/URI/", "", NULL, @@ -3918,15 +3925,19 @@ testDesc testDescriptions[] = { { "Relax-NG regression tests" , rngTest, "./test/relaxng/*.rng", NULL, NULL, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT }, +#ifdef LIBXML_READER_ENABLED { "Relax-NG streaming regression tests" , rngStreamTest, "./test/relaxng/*.rng", NULL, NULL, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT }, #endif +#endif #ifdef LIBXML_PATTERN_ENABLED +#ifdef LIBXML_READER_ENABLED { "Pattern regression tests" , patternTest, "./test/pattern/*.pat", "result/pattern/", NULL, NULL, 0 }, #endif +#endif #ifdef LIBXML_C14N_ENABLED { "C14N with comments regression tests" , c14nWithCommentTest, "./test/c14n/with-comments/*.xml", NULL, NULL, NULL, diff --git a/tree.c b/tree.c index d2590ed4..4d127462 100644 --- a/tree.c +++ b/tree.c @@ -7445,7 +7445,7 @@ xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapItemPtr *map, str = xmlDictLookup(destDoc->dict, str, -1); \ if ((sourceDoc == NULL) || (sourceDoc->dict == NULL) || \ (!xmlDictOwns(sourceDoc->dict, old))) \ - xmlFree(old); \ + xmlFree((char *)old); \ } else if ((sourceDoc) && (sourceDoc->dict) && \ xmlDictOwns(sourceDoc->dict, str)) { \ str = BAD_CAST xmlStrdup(str); \ diff --git a/xmllint.c b/xmllint.c index 5ffabf56..ab088809 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2341,7 +2341,11 @@ main(int argc, char **argv) { } #endif /* LIBXML_SCHEMAS_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); if (patternc == NULL) { xmlGenericError(xmlGenericErrorContext, diff --git a/xmlschemas.c b/xmlschemas.c index c124e065..355600f8 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -664,7 +664,9 @@ struct _xmlSchemaValidCtxt { xmlDictPtr dict; +#ifdef LIBXML_READER_ENABLED xmlTextReaderPtr reader; +#endif xmlSchemaAttrInfoPtr *attrInfos; int nbAttrInfos; @@ -18330,6 +18332,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt, } } return (NULL); +#ifdef LIBXML_WRITER_ENABLED } else if (vctxt->reader != NULL) { xmlChar *nsName; @@ -18343,6 +18346,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt, return (ret); } else return (NULL); +#endif } else { xmlNsPtr ns; @@ -23411,7 +23415,9 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt) vctxt->flags = 0; vctxt->validationRoot = NULL; vctxt->doc = NULL; +#ifdef LIBXML_READER_ENABLED vctxt->reader = NULL; +#endif if (vctxt->value != NULL) { xmlSchemaFreeValue(vctxt->value); vctxt->value = NULL; @@ -23846,12 +23852,14 @@ xmlSchemaVStart(xmlSchemaValidCtxtPtr vctxt) * Tree validation. */ ret = xmlSchemaVDocWalk(vctxt); +#ifdef LIBXML_READER_ENABLED } else if (vctxt->reader != NULL) { /* * XML Reader validation. */ #ifdef XML_SCHEMA_READER_ENABLED ret = xmlSchemaVReaderWalk(vctxt); +#endif #endif } else if ((vctxt->sax != NULL) && (vctxt->parserCtxt != NULL)) { /*