diff --git a/ChangeLog b/ChangeLog index 22043aa7b4ece7770edfa73fdbad75d75490b8c2..727b1806b596d056679132f0ef3118b78b52bbe4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Jul 29 01:48:02 CEST 2005 Daniel Veillard + + * HTMLparser.c SAX2.c encoding.c globals.c parser.c relaxng.c + runsuite.c runtest.c schematron.c testHTML.c testReader.c + testRegexp.c testSAX.c testThreads.c valid.c xinclude.c xmlIO.c + xmllint.c xmlmodule.c xmlschemas.c xpath.c xpointer.c: a lot of + small cleanups based on Linus' sparse check output. + Thu Jul 28 21:28:33 CEST 2005 Daniel Veillard * include/libxml/Makefile.am: added schematron.h, oops ... diff --git a/HTMLparser.c b/HTMLparser.c index a54fc8da6c74223ed9e82c37abd38f392a3efb8d..f4e27aa78a9d649d5f126d45709ca2d00503b361 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -192,16 +192,16 @@ htmlnamePop(htmlParserCtxtPtr ctxt) const xmlChar *ret; if (ctxt->nameNr <= 0) - return (0); + return (NULL); ctxt->nameNr--; if (ctxt->nameNr < 0) - return (0); + return (NULL); if (ctxt->nameNr > 0) ctxt->name = ctxt->nameTab[ctxt->nameNr - 1]; else ctxt->name = NULL; ret = ctxt->nameTab[ctxt->nameNr]; - ctxt->nameTab[ctxt->nameNr] = 0; + ctxt->nameTab[ctxt->nameNr] = NULL; return (ret); } diff --git a/SAX2.c b/SAX2.c index 16e361f9137f891cbd974505597867a4ddedb7a8..c8b6244bcd431c67aa9a44fd423f44263a812d16 100644 --- a/SAX2.c +++ b/SAX2.c @@ -227,7 +227,7 @@ const xmlChar * xmlSAX2GetSystemId(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; - if ((ctx == NULL) || (ctxt->input == NULL)) return(0); + if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL); return((const xmlChar *) ctxt->input->filename); } diff --git a/encoding.c b/encoding.c index 66e63b518aa9add3cbeb22a2e057abcd4b7e1575..3f5d8b494915b2a35b03fedc97266fde784c4fb2 100644 --- a/encoding.c +++ b/encoding.c @@ -1239,7 +1239,7 @@ xmlNewCharEncodingHandler(const char *name, const char *alias; char upper[500]; int i; - char *up = 0; + char *up = NULL; /* * Do the alias resolution diff --git a/globals.c b/globals.c index bee542c31a34a7fc83018edfe5f4908b6063e928..fcace756c0e6dcf43cdd0cd415761f395aa3a614 100644 --- a/globals.c +++ b/globals.c @@ -344,7 +344,7 @@ static const char *xmlTreeIndentStringThrDef = " "; * Disabled by default */ int xmlSaveNoEmptyTags = 0; -int xmlSaveNoEmptyTagsThrDef = 0; +static int xmlSaveNoEmptyTagsThrDef = 0; #ifdef LIBXML_SAX1_ENABLED /** diff --git a/parser.c b/parser.c index 13d19a050f8e79ba640f3f505bc4b63bb104f6d9..e5f3e0c02d7e8f987b7af3b944af8b6b5c844c18 100644 --- a/parser.c +++ b/parser.c @@ -984,14 +984,14 @@ inputPop(xmlParserCtxtPtr ctxt) if (ctxt == NULL) return(NULL); if (ctxt->inputNr <= 0) - return (0); + return (NULL); ctxt->inputNr--; if (ctxt->inputNr > 0) ctxt->input = ctxt->inputTab[ctxt->inputNr - 1]; else ctxt->input = NULL; ret = ctxt->inputTab[ctxt->inputNr]; - ctxt->inputTab[ctxt->inputNr] = 0; + ctxt->inputTab[ctxt->inputNr] = NULL; return (ret); } /** @@ -1053,7 +1053,7 @@ nodePop(xmlParserCtxtPtr ctxt) else ctxt->node = NULL; ret = ctxt->nodeTab[ctxt->nodeNr]; - ctxt->nodeTab[ctxt->nodeNr] = 0; + ctxt->nodeTab[ctxt->nodeNr] = NULL; return (ret); } @@ -1118,7 +1118,7 @@ nameNsPop(xmlParserCtxtPtr ctxt) const xmlChar *ret; if (ctxt->nameNr <= 0) - return (0); + return (NULL); ctxt->nameNr--; if (ctxt->nameNr > 0) ctxt->name = ctxt->nameTab[ctxt->nameNr - 1]; @@ -1184,7 +1184,7 @@ namePop(xmlParserCtxtPtr ctxt) else ctxt->name = NULL; ret = ctxt->nameTab[ctxt->nameNr]; - ctxt->nameTab[ctxt->nameNr] = 0; + ctxt->nameTab[ctxt->nameNr] = NULL; return (ret); } diff --git a/relaxng.c b/relaxng.c index 61daa0d1ec717b48e356e0f77f4e89c43addb1db..41398e1085ba46c3db3a96580ba72420704c0878 100644 --- a/relaxng.c +++ b/relaxng.c @@ -1477,14 +1477,14 @@ xmlRelaxNGIncludePop(xmlRelaxNGParserCtxtPtr ctxt) xmlRelaxNGIncludePtr ret; if (ctxt->incNr <= 0) - return (0); + return (NULL); ctxt->incNr--; if (ctxt->incNr > 0) ctxt->inc = ctxt->incTab[ctxt->incNr - 1]; else ctxt->inc = NULL; ret = ctxt->incTab[ctxt->incNr]; - ctxt->incTab[ctxt->incNr] = 0; + ctxt->incTab[ctxt->incNr] = NULL; return (ret); } @@ -1889,14 +1889,14 @@ xmlRelaxNGDocumentPop(xmlRelaxNGParserCtxtPtr ctxt) xmlRelaxNGDocumentPtr ret; if (ctxt->docNr <= 0) - return (0); + return (NULL); ctxt->docNr--; if (ctxt->docNr > 0) ctxt->doc = ctxt->docTab[ctxt->docNr - 1]; else ctxt->doc = NULL; ret = ctxt->docTab[ctxt->docNr]; - ctxt->docTab[ctxt->docNr] = 0; + ctxt->docTab[ctxt->docNr] = NULL; return (ret); } diff --git a/runsuite.c b/runsuite.c index b78831349db9695b476f60eaf79c72a8e4aae520..aecd6ae71c90ef733a78add385e2277103895f51 100644 --- a/runsuite.c +++ b/runsuite.c @@ -30,8 +30,8 @@ #include #define LOGFILE "runsuite.log" -FILE *logfile = NULL; -int verbose = 0; +static FILE *logfile = NULL; +static int verbose = 0; #if defined(_WIN32) && !defined(__CYGWIN__) #define vsnprintf _vsnprintf @@ -96,9 +96,9 @@ fatalError(void) { * that's needed to implement */ #define MAX_ENTITIES 20 -char *testEntitiesName[MAX_ENTITIES]; -char *testEntitiesValue[MAX_ENTITIES]; -int nb_entities = 0; +static char *testEntitiesName[MAX_ENTITIES]; +static char *testEntitiesValue[MAX_ENTITIES]; +static int nb_entities = 0; static void resetEntities(void) { int i; @@ -205,7 +205,7 @@ testErrorHandler(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { testErrors[testErrorsSize] = 0; } -xmlXPathContextPtr ctxtXPath; +static xmlXPathContextPtr ctxtXPath; static void initializeLibxml2(void) { diff --git a/runtest.c b/runtest.c index 3ec48cb2ae4558a5a93bc2147ad814f85ce59645..ac2d95523333cd5b9f3f3a84a286a81704bb0546 100644 --- a/runtest.c +++ b/runtest.c @@ -714,12 +714,12 @@ static int unloadMem(const char *mem) { * * ************************************************************************/ -FILE *SAXdebug = NULL; +static FILE *SAXdebug = NULL; /* * empty SAX block */ -xmlSAXHandler emptySAXHandlerStruct = { +static xmlSAXHandler emptySAXHandlerStruct = { NULL, /* internalSubset */ NULL, /* isStandalone */ NULL, /* hasInternalSubset */ @@ -755,8 +755,8 @@ xmlSAXHandler emptySAXHandlerStruct = { }; static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; -int callbacks = 0; -int quiet = 0; +static int callbacks = 0; +static int quiet = 0; /** * isStandaloneDebug: @@ -1347,7 +1347,7 @@ fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) va_end(args); } -xmlSAXHandler debugSAXHandlerStruct = { +static xmlSAXHandler debugSAXHandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, @@ -1382,7 +1382,7 @@ xmlSAXHandler debugSAXHandlerStruct = { NULL }; -xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct; +static xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct; /* * SAX2 specific callbacks @@ -1471,7 +1471,7 @@ endElementNsDebug(void *ctx ATTRIBUTE_UNUSED, fprintf(SAXdebug, ", '%s')\n", (char *) URI); } -xmlSAXHandler debugSAX2HandlerStruct = { +static xmlSAXHandler debugSAX2HandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, @@ -1506,7 +1506,7 @@ xmlSAXHandler debugSAX2HandlerStruct = { NULL }; -xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct; +static xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct; #ifdef LIBXML_HTML_ENABLED /** @@ -1586,7 +1586,7 @@ htmlcdataDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) fprintf(SAXdebug, "SAX.cdata(%s, %d)\n", output, len); } -xmlSAXHandler debugHTMLSAXHandlerStruct = { +static xmlSAXHandler debugHTMLSAXHandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, @@ -1621,7 +1621,7 @@ xmlSAXHandler debugHTMLSAXHandlerStruct = { NULL }; -xmlSAXHandlerPtr debugHTMLSAXHandler = &debugHTMLSAXHandlerStruct; +static xmlSAXHandlerPtr debugHTMLSAXHandler = &debugHTMLSAXHandlerStruct; #endif /* LIBXML_HTML_ENABLED */ #ifdef LIBXML_SAX1_ENABLED @@ -2247,8 +2247,8 @@ streamMemParseTest(const char *filename, const char *result, const char *err, * * ************************************************************************/ -FILE *xpathOutput; -xmlDocPtr xpathDocument; +static FILE *xpathOutput; +static xmlDocPtr xpathDocument; static void testXPath(const char *str, int xptr, int expr) { @@ -3667,8 +3667,8 @@ static const char *testfiles[] = { "test/threads/invalid.xml", }; -const char *Okay = "OK"; -const char *Failed = "Failed"; +static const char *Okay = "OK"; +static const char *Failed = "Failed"; #ifndef xmlDoValidityCheckingDefaultValue #error xmlDoValidityCheckingDefaultValue is not a macro diff --git a/schematron.c b/schematron.c index dbf45439be903b7dfe78ca2b8c6f42724c42a8d2..dfc9a6591f66a69782218d58b733037effc23dad 100644 --- a/schematron.c +++ b/schematron.c @@ -470,7 +470,7 @@ xmlSchematronNewParserCtxt(const char *URL) ret->type = XML_STRON_CTXT_PARSER; ret->dict = xmlDictCreate(); ret->URL = xmlDictLookup(ret->dict, (const xmlChar *) URL, -1); - ret->includes = 0; + ret->includes = NULL; ret->xctxt = xmlXPathNewContext(NULL); if (ret->xctxt == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context", diff --git a/testHTML.c b/testHTML.c index 205bdf23656747a33bc71e34665bc8dfd2ab4357..f350342d0268b75de3f355d30f5ed044cee253e6 100644 --- a/testHTML.c +++ b/testHTML.c @@ -50,7 +50,7 @@ static int push = 0; static char *encoding = NULL; static int options = 0; -xmlSAXHandler emptySAXHandlerStruct = { +static xmlSAXHandler emptySAXHandlerStruct = { NULL, /* internalSubset */ NULL, /* isStandalone */ NULL, /* hasInternalSubset */ @@ -85,7 +85,7 @@ xmlSAXHandler emptySAXHandlerStruct = { NULL /* xmlStructuredErrorFunc */ }; -xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; +static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; extern xmlSAXHandlerPtr debugSAXHandler; /************************************************************************ @@ -574,7 +574,7 @@ fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) va_end(args); } -xmlSAXHandler debugSAXHandlerStruct = { +static xmlSAXHandler debugSAXHandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, diff --git a/testReader.c b/testReader.c index 4d5711bcd236501c6c618d1de572143d8979a6cb..8f8e26d5b74adb912e4f32b7e2ce013e58c9148c 100644 --- a/testReader.c +++ b/testReader.c @@ -34,12 +34,12 @@ #include -int debug = 0; -int dump = 0; -int noent = 0; -int count = 0; -int valid = 0; -int consumed = 0; +static int debug = 0; +static int dump = 0; +static int noent = 0; +static int count = 0; +static int valid = 0; +static int consumed = 0; static void usage(const char *progname) { printf("Usage : %s [options] XMLfiles ...\n", progname); diff --git a/testRegexp.c b/testRegexp.c index 4f79481e97b7ab3fb150d2f76e762ca90a011c16..1e9f35b5cb116db19b0bed652420d14ced5ed63a 100644 --- a/testRegexp.c +++ b/testRegexp.c @@ -12,8 +12,8 @@ #include #include -int repeat = 0; -int debug = 0; +static int repeat = 0; +static int debug = 0; static void testRegexp(xmlRegexpPtr comp, const char *value) { int ret; diff --git a/testSAX.c b/testSAX.c index 2f2921ee2859f7a2a1ece2a6fa5f4b628eb2ae53..cd16268fd0195355ef8418c5d6eae19d7398cf0a 100644 --- a/testSAX.c +++ b/testSAX.c @@ -200,7 +200,7 @@ endTimer(char *format, ...) /* * empty SAX block */ -xmlSAXHandler emptySAXHandlerStruct = { +static xmlSAXHandler emptySAXHandlerStruct = { NULL, /* internalSubset */ NULL, /* isStandalone */ NULL, /* hasInternalSubset */ @@ -235,7 +235,7 @@ xmlSAXHandler emptySAXHandlerStruct = { NULL /* xmlStructuredErrorFunc */ }; -xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; +static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; extern xmlSAXHandlerPtr debugSAXHandler; /************************************************************************ @@ -833,7 +833,7 @@ fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) va_end(args); } -xmlSAXHandler debugSAXHandlerStruct = { +static xmlSAXHandler debugSAXHandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, @@ -957,7 +957,7 @@ endElementNsDebug(void *ctx ATTRIBUTE_UNUSED, fprintf(stdout, ", '%s')\n", (char *) URI); } -xmlSAXHandler debugSAX2HandlerStruct = { +static xmlSAXHandler debugSAX2HandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, @@ -992,7 +992,7 @@ xmlSAXHandler debugSAX2HandlerStruct = { NULL }; -xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct; +static xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct; /************************************************************************ * * diff --git a/testThreads.c b/testThreads.c index 714718268969a21359dbe3f0af5f619b4121b21b..6405a77fc54478f5610772c42fc791f9332ebdf6 100644 --- a/testThreads.c +++ b/testThreads.c @@ -36,8 +36,8 @@ static const char *testfiles[] = { "test/threads/invalid.xml", }; -const char *Okay = "OK"; -const char *Failed = "Failed"; +static const char *Okay = "OK"; +static const char *Failed = "Failed"; #ifndef xmlDoValidityCheckingDefaultValue #error xmlDoValidityCheckingDefaultValue is not a macro @@ -110,7 +110,7 @@ main(void) } for (i = 0; i < num_threads; i++) { - ret = pthread_create(&tid[i], 0, thread_specific_data, + ret = pthread_create(&tid[i], NULL, thread_specific_data, (void *) testfiles[i]); if (ret != 0) { perror("pthread_create"); diff --git a/valid.c b/valid.c index f4e05f66a0423a7bef4052c47c562c6389d890de..32132fa3ce31627a1698eefc45d3e3168d1ef943 100644 --- a/valid.c +++ b/valid.c @@ -453,14 +453,14 @@ nodeVPop(xmlValidCtxtPtr ctxt) xmlNodePtr ret; if (ctxt->nodeNr <= 0) - return (0); + return (NULL); ctxt->nodeNr--; if (ctxt->nodeNr > 0) ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1]; else ctxt->node = NULL; ret = ctxt->nodeTab[ctxt->nodeNr]; - ctxt->nodeTab[ctxt->nodeNr] = 0; + ctxt->nodeTab[ctxt->nodeNr] = NULL; return (ret); } @@ -3866,7 +3866,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc, fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); if (fullname == NULL) - return(0); + return(NULL); attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name); if ((attrDecl == NULL) && (doc->extSubset != NULL)) { attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name); @@ -3951,7 +3951,7 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem, fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); if (fullname == NULL) - return(0); + return(NULL); attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name); if ((attrDecl == NULL) && (doc->extSubset != NULL)) attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name); diff --git a/xinclude.c b/xinclude.c index ab6409688d0ad9a00b7244c6469f8beff8754870..b6ec35348b638bd0f1f9963e7d5e5149ec6c2895 100644 --- a/xinclude.c +++ b/xinclude.c @@ -237,7 +237,7 @@ xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI, ret->URI = xmlStrdup(URI); ret->fragment = NULL; ret->ref = ref; - ret->doc = 0; + ret->doc = NULL; ret->count = 0; ret->xml = 0; ret->inc = NULL; @@ -360,7 +360,7 @@ xmlXIncludeURLPop(xmlXIncludeCtxtPtr ctxt) else ctxt->url = NULL; ret = ctxt->urlTab[ctxt->urlNr]; - ctxt->urlTab[ctxt->urlNr] = 0; + ctxt->urlTab[ctxt->urlNr] = NULL; if (ret != NULL) xmlFree(ret); } @@ -1952,7 +1952,7 @@ xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) { static xmlNodePtr xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { xmlXIncludeAddNode(ctxt, node); - return(0); + return(NULL); } /** diff --git a/xmlIO.c b/xmlIO.c index a000e8c9b420e96a2b1b4ec7cbc5355366e8fc11..0902a2fcfd4ea04dc33673ac40950064945da926 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -1206,7 +1206,7 @@ xmlCreateZMemBuff( int compression ) { } /* Set the header data. The CRC will be needed for the trailer */ - buff->crc = crc32( 0L, Z_NULL, 0 ); + buff->crc = crc32( 0L, NULL, 0 ); hdr_lgth = snprintf( (char *)buff->zbuff, buff->size, "%c%c%c%c%c%c%c%c%c%c", GZ_MAGIC1, GZ_MAGIC2, Z_DEFLATED, diff --git a/xmllint.c b/xmllint.c index f33053909626b0733f02b8e3cd9de8a6502f4362..686b652cec11147ff79beda0e3c0abcf170262f7 100644 --- a/xmllint.c +++ b/xmllint.c @@ -235,7 +235,7 @@ void parsePath(const xmlChar *path) { } } -xmlExternalEntityLoader defaultEntityLoader = NULL; +static xmlExternalEntityLoader defaultEntityLoader = NULL; static xmlParserInputPtr xmllintExternalEntityLoader(const char *URL, const char *ID, @@ -508,7 +508,7 @@ endTimer(char *format, ...) * HTML ouput * * * ************************************************************************/ -char buffer[50000]; +static char buffer[50000]; static void xmlHTMLEncodeSend(void) { @@ -817,7 +817,7 @@ static void myClose(FILE *f) { /* * empty SAX block */ -xmlSAXHandler emptySAXHandlerStruct = { +static xmlSAXHandler emptySAXHandlerStruct = { NULL, /* internalSubset */ NULL, /* isStandalone */ NULL, /* hasInternalSubset */ @@ -852,7 +852,7 @@ xmlSAXHandler emptySAXHandlerStruct = { NULL /* xmlStructuredErrorFunc */ }; -xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; +static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; extern xmlSAXHandlerPtr debugSAXHandler; static int callbacks; @@ -1440,7 +1440,7 @@ fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) va_end(args); } -xmlSAXHandler debugSAXHandlerStruct = { +static xmlSAXHandler debugSAXHandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, @@ -1564,7 +1564,7 @@ endElementNsDebug(void *ctx ATTRIBUTE_UNUSED, fprintf(stdout, ", '%s')\n", (char *) URI); } -xmlSAXHandler debugSAX2HandlerStruct = { +static xmlSAXHandler debugSAX2HandlerStruct = { internalSubsetDebug, isStandaloneDebug, hasInternalSubsetDebug, @@ -1599,7 +1599,7 @@ xmlSAXHandler debugSAX2HandlerStruct = { NULL }; -xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct; +static xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct; static void testSAX(const char *filename) { diff --git a/xmlmodule.c b/xmlmodule.c index 8b0fab97931c27b6c0b9799945f23e1b00161071..6cc86ee620b51f6f3c0d8cf649ab43fed04b53e4 100644 --- a/xmlmodule.c +++ b/xmlmodule.c @@ -85,7 +85,7 @@ xmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED) __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0, name, NULL, 0, 0, "failed to open %s\n", name); - return 0; + return(NULL); } module->name = xmlStrdup((const xmlChar *) name); @@ -179,7 +179,7 @@ xmlModuleFree(xmlModulePtr module) { if (NULL == module) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, - XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, 0, + XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "null module pointer\n"); return -1; } diff --git a/xmlschemas.c b/xmlschemas.c index 7e668cf4deac95be47d7021cfb708c970de32daa..db30dc9ffbe3d5fcecf9b4225ee7ca09e1002dea 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -5023,7 +5023,7 @@ xmlSchemaPValAttrNodeQNameValue(xmlSchemaParserCtxtPtr ctxt, return (-1); if (!strchr((char *) value, ':')) { - ns = xmlSearchNs(attr->doc, attr->parent, 0); + ns = xmlSearchNs(attr->doc, attr->parent, NULL); if (ns) *uri = xmlDictLookup(ctxt->dict, ns->href, -1); else if (schema->flags & XML_SCHEMAS_INCLUDING_CONVERT_NS) { @@ -12827,7 +12827,7 @@ xmlSchemaBuildAttributeValidation(xmlSchemaParserCtxtPtr pctxt, * declaration}'s {value constraint} . */ xmlSchemaGetEffectiveValueConstraint(base->attr, - &effFixed, &bEffValue, 0); + &effFixed, &bEffValue, NULL); /* * 2.1.3 ... one of the following must be true * @@ -12839,7 +12839,7 @@ xmlSchemaBuildAttributeValidation(xmlSchemaParserCtxtPtr pctxt, const xmlChar *rEffValue = NULL; xmlSchemaGetEffectiveValueConstraint(base->attr, - &effFixed, &rEffValue, 0); + &effFixed, &rEffValue, NULL); /* * 2.1.3.2 R's ·effective value constraint· is * fixed with the same string as B's. diff --git a/xpath.c b/xpath.c index f6e982623de3cbeeccc4a2bef2224f7d74bf695b..f0cb291c530952e8be32672c581ec65056345d29 100644 --- a/xpath.c +++ b/xpath.c @@ -89,7 +89,7 @@ double xmlXPathNAN = 0; double xmlXPathPINF = 1; double xmlXPathNINF = -1; -double xmlXPathNZERO = 0; +static double xmlXPathNZERO = 0; /* not exported from headers */ static int xmlXPathInitialized = 0; /** @@ -189,6 +189,15 @@ static int xmlXPathDisableOptimizer = 0; * * ************************************************************************/ +/** + * XP_ERRORNULL: + * @X: the error code + * + * Macro to raise an XPath error and return NULL. + */ +#define XP_ERRORNULL(X) \ + { xmlXPathErr(ctxt, X); return(NULL); } + /* * The array xmlXPathErrorMessages corresponds to the enum xmlXPathError */ @@ -1116,20 +1125,20 @@ xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp, * * Returns the XPath object just removed */ -extern xmlXPathObjectPtr +xmlXPathObjectPtr valuePop(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr ret; if ((ctxt == NULL) || (ctxt->valueNr <= 0)) - return (0); + return (NULL); ctxt->valueNr--; if (ctxt->valueNr > 0) ctxt->value = ctxt->valueTab[ctxt->valueNr - 1]; else ctxt->value = NULL; ret = ctxt->valueTab[ctxt->valueNr]; - ctxt->valueTab[ctxt->valueNr] = 0; + ctxt->valueTab[ctxt->valueNr] = NULL; return (ret); } /** @@ -1141,7 +1150,7 @@ valuePop(xmlXPathParserContextPtr ctxt) * * returns the number of items on the value stack */ -extern int +int valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value) { if ((ctxt == NULL) || (value == NULL)) return(-1); @@ -7574,7 +7583,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); if (buffer == NULL) { - XP_ERROR0(XPATH_MEMORY_ERROR); + XP_ERRORNULL(XPATH_MEMORY_ERROR); } memcpy(buffer, buf, len); while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigname.xml */ @@ -7587,7 +7596,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { buffer = (xmlChar *) xmlRealloc(buffer, max * sizeof(xmlChar)); if (buffer == NULL) { - XP_ERROR0(XPATH_MEMORY_ERROR); + XP_ERRORNULL(XPATH_MEMORY_ERROR); } } COPY_BUF(l,buffer,len,c); @@ -7823,7 +7832,7 @@ xmlXPathParseLiteral(xmlXPathParserContextPtr ctxt) { while ((IS_CHAR_CH(CUR)) && (CUR != '"')) NEXT; if (!IS_CHAR_CH(CUR)) { - XP_ERROR0(XPATH_UNFINISHED_LITERAL_ERROR); + XP_ERRORNULL(XPATH_UNFINISHED_LITERAL_ERROR); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; @@ -7834,13 +7843,13 @@ xmlXPathParseLiteral(xmlXPathParserContextPtr ctxt) { while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) NEXT; if (!IS_CHAR_CH(CUR)) { - XP_ERROR0(XPATH_UNFINISHED_LITERAL_ERROR); + XP_ERRORNULL(XPATH_UNFINISHED_LITERAL_ERROR); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; } } else { - XP_ERROR0(XPATH_START_LITERAL_ERROR); + XP_ERRORNULL(XPATH_START_LITERAL_ERROR); } return(ret); } @@ -8650,7 +8659,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, if (name == NULL) name = xmlXPathParseNCName(ctxt); if (name == NULL) { - XP_ERROR0(XPATH_EXPR_ERROR); + XP_ERRORNULL(XPATH_EXPR_ERROR); } blanks = IS_BLANK_CH(CUR); @@ -8671,7 +8680,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, else { if (name != NULL) xmlFree(name); - XP_ERROR0(XPATH_EXPR_ERROR); + XP_ERRORNULL(XPATH_EXPR_ERROR); } *test = NODE_TEST_TYPE; @@ -8686,7 +8695,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, name = NULL; if (CUR != ')') { name = xmlXPathParseLiteral(ctxt); - CHECK_ERROR 0; + CHECK_ERROR NULL; *test = NODE_TEST_PI; SKIP_BLANKS; } @@ -8694,7 +8703,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, if (CUR != ')') { if (name != NULL) xmlFree(name); - XP_ERROR0(XPATH_UNCLOSED_ERROR); + XP_ERRORNULL(XPATH_UNCLOSED_ERROR); } NEXT; return(name); @@ -8732,7 +8741,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, name = xmlXPathParseNCName(ctxt); if (name == NULL) { - XP_ERROR0(XPATH_EXPR_ERROR); + XP_ERRORNULL(XPATH_EXPR_ERROR); } } return(name); @@ -11390,7 +11399,7 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) { if( pctxt->error != XPATH_EXPRESSION_OK ) { xmlXPathFreeParserContext(pctxt); - return (0); + return(NULL); } if (*pctxt->cur != 0) { diff --git a/xpointer.c b/xpointer.c index 84c80c3a60b310b324983bc02c7840b1ece0e9c9..943cf21b466d3e4023a8759281ceca668cad8a56 100644 --- a/xpointer.c +++ b/xpointer.c @@ -2412,7 +2412,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) { if (pos + bytes >= len) { bytes -= (len - pos); cur = xmlXPtrAdvanceNode(cur, NULL); - cur = 0; + pos = 0; } else if (pos + bytes < len) { pos += bytes; *node = cur;