From 38d452ac1c98b64eb0723175a67c2f59adc35d5a Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Tue, 22 May 2007 16:00:06 +0000 Subject: [PATCH] Fixed typo in xmlCharEncFirstLine pointed out by Mark Rowe (bug #440159) * encoding.c: Fixed typo in xmlCharEncFirstLine pointed out by Mark Rowe (bug #440159) * include/libxml/xmlversion.h.in: Added check for definition of _POSIX_C_SOURCE to avoid warnings on Apple OS/X (patch from Wendy Doyle and Mark Rowe, bug #346675) * schematron.c, testapi.c, tree.c, xmlIO.c, xmlsave.c: minor changes to fix compilation warnings - no change to logic. svn path=/trunk/; revision=3618 --- ChangeLog | 10 ++++++++++ encoding.c | 13 +++++++------ include/libxml/xmlversion.h.in | 3 ++- schematron.c | 4 ++++ testapi.c | 2 +- tree.c | 2 +- xmlIO.c | 2 +- xmlsave.c | 1 - 8 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f8e95d1..0c7a0d7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue May 22 08:59:48 PDT 2007 William Brack + + * encoding.c: Fixed typo in xmlCharEncFirstLine pointed out + by Mark Rowe (bug #440159) + * include/libxml/xmlversion.h.in: Added check for definition of + _POSIX_C_SOURCE to avoid warnings on Apple OS/X (patch from + Wendy Doyle and Mark Rowe, bug #346675) + * schematron.c, testapi.c, tree.c, xmlIO.c, xmlsave.c: minor + changes to fix compilation warnings - no change to logic. + Tue May 15 22:18:08 PDT 2007 William Brack * nanohttp.c: small enhancement to last fix, pointed out diff --git a/encoding.c b/encoding.c index ee33df1a..002eeba2 100644 --- a/encoding.c +++ b/encoding.c @@ -1761,19 +1761,20 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out, if (out == NULL) return(-1); if (in == NULL) return(-1); + /* calculate space available */ written = out->size - out->use; toconv = in->use; - if (toconv * 2 >= written) { - xmlBufferGrow(out, toconv); - written = out->size - out->use - 1; - } - /* * echo '' | wc -c => 38 * 45 chars should be sufficient to reach the end of the encoding * declaration without going too far inside the document content. */ - written = 45; + if (toconv > 45) + toconv = 45; + if (toconv * 2 >= written) { + xmlBufferGrow(out, toconv); + written = out->size - out->use - 1; + } if (handler->input != NULL) { ret = handler->input(&out->content[out->use], &written, diff --git a/include/libxml/xmlversion.h.in b/include/libxml/xmlversion.h.in index 09679137..29cef749 100644 --- a/include/libxml/xmlversion.h.in +++ b/include/libxml/xmlversion.h.in @@ -91,7 +91,8 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * Whether the thread support is configured in */ #if @WITH_THREADS@ -#if defined(_REENTRANT) || defined(__MT__) || (_POSIX_C_SOURCE - 0 >= 199506L) +#if defined(_REENTRANT) || defined(__MT__) || \ + (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L)) #define LIBXML_THREAD_ENABLED #endif #endif diff --git a/schematron.c b/schematron.c index 0a90ff80..a2eabcc2 100644 --- a/schematron.c +++ b/schematron.c @@ -714,6 +714,7 @@ xmlSchematronFreeParserCtxt(xmlSchematronParserCtxtPtr ctxt) xmlFree(ctxt); } +#if 0 /** * xmlSchematronPushInclude: * @ctxt: the schema parser context @@ -782,6 +783,7 @@ xmlSchematronPopInclude(xmlSchematronParserCtxtPtr ctxt) return(xmlSchematronPopInclude(ctxt)); return(ret); } +#endif /** * xmlSchematronAddNamespace: @@ -987,6 +989,7 @@ xmlSchematronParsePattern(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr pat) } } +#if 0 /** * xmlSchematronLoadInclude: * @ctxt: a schema validation context @@ -1051,6 +1054,7 @@ done: xmlFree(URI); return(ret); } +#endif /** * xmlSchematronParse: diff --git a/testapi.c b/testapi.c index 969fdd3c..af71ac22 100644 --- a/testapi.c +++ b/testapi.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) { int blocks, mem; /* access to the proxy can slow up regression tests a lot */ - putenv("http_proxy="); + putenv((char *) "http_proxy="); memset(chartab, 0, sizeof(chartab)); strncpy((char *) chartab, " chartab\n", 20); diff --git a/tree.c b/tree.c index fe579219..432007e1 100644 --- a/tree.c +++ b/tree.c @@ -4848,7 +4848,7 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) { fixed = xmlPathToURI(uri); if (fixed != NULL) { xmlSetNsProp(cur, ns, BAD_CAST "base", fixed); - xmlFree(fixed); + xmlFree((xmlChar *)fixed); } else { xmlSetNsProp(cur, ns, BAD_CAST "base", uri); } diff --git a/xmlIO.c b/xmlIO.c index f576d76a..154fcf86 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -3638,7 +3638,7 @@ static int xmlNoNetExists(const char *URL) { * * Returns a new allocated URL, or NULL. */ -xmlChar * +static xmlChar * xmlResolveResourceFromCatalog(const char *URL, const char *ID, xmlParserCtxtPtr ctxt) { xmlChar *resource = NULL; diff --git a/xmlsave.c b/xmlsave.c index 231ee7b9..b97327ec 100644 --- a/xmlsave.c +++ b/xmlsave.c @@ -834,7 +834,6 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) { xmlCharEncodingOutputFunc oldescape = ctxt->escape; xmlCharEncodingOutputFunc oldescapeAttr = ctxt->escapeAttr; xmlOutputBufferPtr buf = ctxt->buf; - xmlCharEncodingHandlerPtr handler = NULL; xmlCharEncoding enc; xmlInitParser();