From b349225952c4fc95fe35018a1b5468f6a4b4c98d Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 14 Mar 2025 00:01:11 +0100 Subject: [PATCH] include: Change some return types from int to enum This also affects some new functions from 2.13. --- HTMLtree.c | 2 +- buf.c | 4 +- doc/libxml2-api.xml | 24 ++++----- encoding.c | 102 +++++++++++++++++++------------------- example/icu.c | 8 +-- fuzz/fuzz.c | 2 +- fuzz/fuzz.h | 2 +- fuzz/genSeed.c | 2 +- include/libxml/encoding.h | 15 +++--- include/libxml/parser.h | 8 +-- include/libxml/xmlsave.h | 2 +- include/private/enc.h | 4 +- include/private/io.h | 4 +- parserInternals.c | 70 +++++++++++++------------- runsuite.c | 2 +- testapi.c | 12 ++--- testparser.c | 4 +- xinclude.c | 14 +++--- xmlIO.c | 40 ++++++++------- xmllint.c | 4 +- xmlsave.c | 12 ++--- 21 files changed, 172 insertions(+), 165 deletions(-) diff --git a/HTMLtree.c b/HTMLtree.c index 6e0d8d20..4173a363 100644 --- a/HTMLtree.c +++ b/HTMLtree.c @@ -337,7 +337,7 @@ htmlIsBooleanAttr(const xmlChar *name) * * ************************************************************************/ -static int +static xmlParserErrors htmlFindOutputEncoder(const char *encoding, xmlCharEncodingHandler **out) { /* * Fallback to HTML if the encoding is unspecified diff --git a/buf.c b/buf.c index 5205171b..f24a8192 100644 --- a/buf.c +++ b/buf.c @@ -1092,7 +1092,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size) * Add a string range to an XML buffer. if len == -1, the length of * str is recomputed. * - * Returns a xmlParserError code. + * Returns a xmlParserErrors code. */ int xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) { @@ -1124,7 +1124,7 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) { * Add a string range to the beginning of an XML buffer. * if len == -1, the length of @str is recomputed. * - * Returns a xmlParserError code. + * Returns a xmlParserErrors code. */ int xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) { diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml index 6759f01a..cd6294cd 100644 --- a/doc/libxml2-api.xml +++ b/doc/libxml2-api.xml @@ -7764,14 +7764,14 @@ crash if you try to modify the tree)'/> Add a string range to an XML buffer. if len == -1, the length of str is recomputed. - + Add a string range to the beginning of an XML buffer. if len == -1, the length of @str is recomputed. - + @@ -8110,7 +8110,7 @@ crash if you try to modify the tree)'/> Convert between character encodings. The value of @inlen after return is the number of bytes consumed and @outlen is the number of bytes produced. If the converter can consume partial multi-byte sequences, the @flush flag can be used to detect truncated sequences at EOF. Otherwise, the flag can be ignored. - + @@ -8120,7 +8120,7 @@ crash if you try to modify the tree)'/> If this function returns XML_ERR_OK, it must fill the @out pointer with an encoding handler. The handler can be obtained from xmlCharEncNewCustomHandler. @flags can contain XML_ENC_INPUT, XML_ENC_OUTPUT or both. - + @@ -8142,7 +8142,7 @@ crash if you try to modify the tree)'/> Create a custom xmlCharEncodingHandler. - + @@ -8371,7 +8371,7 @@ crash if you try to modify the tree)'/> Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - Custom implementation if provided - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. @flags can contain XML_ENC_INPUT, XML_ENC_OUTPUT or both. Available since 2.14.0. - + @@ -9865,7 +9865,7 @@ crash if you try to modify the tree)'/> Use encoding handler to decode input data. Closes the handler on error. - + @@ -10168,7 +10168,7 @@ crash if you try to modify the tree)'/> Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. Available since 2.13.0. - + @@ -10619,7 +10619,7 @@ crash if you try to modify the tree)'/> Create a new input stream based on a file or a URL. The flag XML_INPUT_UNZIP allows decompression. The flag XML_INPUT_NETWORK allows network access. The following resource loaders will be called if they were registered (in order of precedence): - the per-thread xmlParserInputBufferCreateFilenameFunc set with xmlParserInputBufferCreateFilenameDefault (deprecated) - the default loader which will return - the result from a matching global input callback set with xmlRegisterInputCallbacks (deprecated) - a HTTP resource if support is compiled in. - a file opened from the filesystem, with automatic detection of compressed files if support is compiled in. Available since 2.14.0. - + @@ -10947,7 +10947,7 @@ crash if you try to modify the tree)'/> Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. Available since 2.13.0. - + @@ -12275,7 +12275,7 @@ crash if you try to modify the tree)'/> Callback for custom resource loaders. @flags can contain XML_INPUT_UNZIP and XML_INPUT_NETWORK. On success, @out should be set to a new parser input object and XML_ERR_OK should be returned. - + @@ -12628,7 +12628,7 @@ crash if you try to modify the tree)'/> defined(LIBXML_OUTPUT_ENABLED) Close a document saving context, i.e. make sure that all bytes have been output and free the associated data. Available since 2.13.0. - + diff --git a/encoding.c b/encoding.c index be9ce664..a90694f5 100644 --- a/encoding.c +++ b/encoding.c @@ -112,34 +112,34 @@ static const xmlEncTableEntry xmlEncTable[] = { { "UTF8", XML_CHAR_ENCODING_UTF8 } }; -static int +static xmlCharEncError asciiToAscii(void *vctxt, unsigned char* out, int *outlen, const unsigned char* in, int *inlen, int flush); -static int +static xmlCharEncError UTF8ToUTF8(void *vctxt, unsigned char* out, int *outlen, const unsigned char* inb, int *inlenb, int flush); -static int +static xmlCharEncError latin1ToUTF8(void *vctxt, unsigned char* out, int *outlen, const unsigned char* in, int *inlen, int flush); -static int +static xmlCharEncError UTF16LEToUTF8(void *vctxt, unsigned char* out, int *outlen, const unsigned char* inb, int *inlenb, int flush); -static int +static xmlCharEncError UTF16BEToUTF8(void *vctxt, unsigned char* out, int *outlen, const unsigned char* inb, int *inlenb, int flush); #ifdef LIBXML_OUTPUT_ENABLED -static int +static xmlCharEncError UTF8ToLatin1(void *vctxt, unsigned char* outb, int *outlen, const unsigned char* in, int *inlen, int flush); -static int +static xmlCharEncError UTF8ToUTF16(void *vctxt, unsigned char* outb, int *outlen, const unsigned char* in, int *inlen, int flush); -static int +static xmlCharEncError UTF8ToUTF16LE(void *vctxt, unsigned char* outb, int *outlen, const unsigned char* in, int *inlen, int flush); -static int +static xmlCharEncError UTF8ToUTF16BE(void *vctxt, unsigned char* outb, int *outlen, const unsigned char* in, int *inlen, int flush); @@ -153,7 +153,7 @@ UTF8ToUTF16BE(void *vctxt, unsigned char* outb, int *outlen, #endif /* LIBXML_OUTPUT_ENABLED */ #if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTML_ENABLED) -static int +static xmlCharEncError UTF8ToHtmlWrapper(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush); #else @@ -165,10 +165,10 @@ UTF8ToHtmlWrapper(void *vctxt, unsigned char *out, int *outlen, #include "iso8859x.inc" -static int +static xmlCharEncError ISO8859xToUTF8(void *vctxt, unsigned char* out, int *outlen, const unsigned char* in, int *inlen, int flush); -static int +static xmlCharEncError UTF8ToISO8859x(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush); @@ -238,13 +238,13 @@ static xmlCharEncodingHandlerPtr *globalHandlers = NULL; static int nbCharEncodingHandler = 0; #ifdef LIBXML_ICONV_ENABLED -static int +static xmlParserErrors xmlCharEncIconv(const char *name, xmlCharEncFlags flags, xmlCharEncodingHandler **out); #endif #ifdef LIBXML_ICU_ENABLED -static int +static xmlParserErrors xmlCharEncUconv(const char *name, xmlCharEncFlags flags, xmlCharEncodingHandler **out); #endif @@ -655,9 +655,9 @@ xmlNewCharEncodingHandler(const char *name, * * Create a custom xmlCharEncodingHandler. * - * Returns an xmlParserError code. + * Returns an xmlParserErrors code. */ -int +xmlParserErrors xmlCharEncNewCustomHandler(const char *name, xmlCharEncConvFunc input, xmlCharEncConvFunc output, xmlCharEncConvCtxtDtor ctxtDtor, @@ -805,7 +805,7 @@ free_handler: * * Returns an xmlParserErrors error code. */ -static int +static xmlParserErrors xmlFindExtraHandler(const char *norig, const char *name, xmlCharEncFlags flags, xmlCharEncConvImpl impl, void *implCtxt, xmlCharEncodingHandler **out) { @@ -886,7 +886,7 @@ xmlFindExtraHandler(const char *norig, const char *name, xmlCharEncFlags flags, * Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another * xmlParserErrors error code. */ -int +xmlParserErrors xmlLookupCharEncodingHandler(xmlCharEncoding enc, xmlCharEncodingHandler **out) { const xmlCharEncodingHandler *handler; @@ -969,7 +969,7 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) { * Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another * xmlParserErrors error code. */ -int +xmlParserErrors xmlCreateCharEncodingHandler(const char *name, xmlCharEncFlags flags, xmlCharEncConvImpl impl, void *implCtxt, xmlCharEncodingHandler **out) { @@ -1031,7 +1031,7 @@ xmlCreateCharEncodingHandler(const char *name, xmlCharEncFlags flags, * Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another * xmlParserErrors error code. */ -int +xmlParserErrors xmlOpenCharEncodingHandler(const char *name, int output, xmlCharEncodingHandler **out) { xmlCharEncFlags flags = output ? XML_ENC_OUTPUT : XML_ENC_INPUT; @@ -1094,13 +1094,13 @@ typedef struct { * @inlen: the length of @in * @flush: end of input * - * Returns an XML_ENC_ERR code. - * * The value of @inlen after return is the number of octets consumed * as the return value is positive, else unpredictable. * The value of @outlen after return is the number of octets produced. + * + * Returns an XML_ENC_ERR code. */ -static int +static xmlCharEncError xmlIconvConvert(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush ATTRIBUTE_UNUSED) { @@ -1185,14 +1185,14 @@ xmlEncodingMatch(const char *name1, const char *name2) { } #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ -static int +static xmlParserErrors xmlCharEncIconv(const char *name, xmlCharEncFlags flags, xmlCharEncodingHandler **out) { xmlCharEncConvFunc inFunc = NULL, outFunc = NULL; xmlIconvCtxt *inputCtxt = NULL, *outputCtxt = NULL; iconv_t icv_in; iconv_t icv_out; - int ret; + xmlParserErrors ret; /* * POSIX allows "indicator suffixes" like "//IGNORE" to be @@ -1334,7 +1334,7 @@ struct _uconv_t { * as the return value is positive, else unpredictable. * The value of @outlen after return is the number of octets produced. */ -static int +static xmlCharEncError xmlUconvConvert(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush) { xmlUconvCtxt *cd = vctxt; @@ -1406,7 +1406,7 @@ xmlUconvConvert(void *vctxt, unsigned char *out, int *outlen, return(ret); } -static int +static xmlParserErrors openIcuConverter(const char* name, int isInput, xmlUconvCtxt **out) { UErrorCode status; @@ -1445,7 +1445,7 @@ openIcuConverter(const char* name, int isInput, xmlUconvCtxt **out) goto error; *out = conv; - return(0); + return(XML_ERR_OK); error: if (conv->uconv) @@ -1474,7 +1474,7 @@ xmlUconvFree(void *vctxt) { closeIcuConverter(vctxt); } -static int +static xmlParserErrors xmlCharEncUconv(const char *name, xmlCharEncFlags flags, xmlCharEncodingHandler **out) { xmlCharEncConvFunc inFunc = NULL, outFunc = NULL; @@ -1520,9 +1520,9 @@ error: * * Convert XML_ENC_ERR to libxml2 error codes. */ -static int -xmlEncConvertError(int code) { - int ret; +static xmlParserErrors +xmlEncConvertError(xmlCharEncError code) { + xmlParserErrors ret; switch (code) { case XML_ENC_ERR_SUCCESS: @@ -1557,11 +1557,11 @@ xmlEncConvertError(int code) { * * Returns an XML_ENC_ERR code. */ -int +xmlCharEncError xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush) { - int ret; + xmlCharEncError ret; if (handler->flags & XML_HANDLER_LEGACY) { xmlCharEncodingInputFunc func = handler->input.legacyFunc; @@ -1613,10 +1613,10 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, * as the return value is 0, else unpredictable. * The value of @outlen after return is the number of octets produced. */ -static int +static xmlCharEncError xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen) { - int ret; + xmlCharEncError ret; if (handler->flags & XML_HANDLER_LEGACY) { xmlCharEncodingOutputFunc func = handler->output.legacyFunc; @@ -1675,7 +1675,7 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out, * * Returns an XML_ENC_ERR code. */ -int +xmlCharEncError xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush) { xmlBufPtr out, in; @@ -1683,7 +1683,7 @@ xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush) size_t availIn; size_t maxOut; size_t totalIn, totalOut; - int ret; + xmlCharEncError ret; out = input->buffer; in = input->raw; @@ -1763,7 +1763,7 @@ xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush) input->rawconsumed += totalIn; *sizeOut = totalOut; - return(XML_ERR_OK); + return(XML_ENC_ERR_SUCCESS); } /** @@ -2126,7 +2126,7 @@ xmlByteConsumed(xmlParserCtxtPtr ctxt) { * * ************************************************************************/ -static int +static xmlCharEncError asciiToAscii(void *vctxt ATTRIBUTE_UNUSED, unsigned char* out, int *poutlen, const unsigned char* in, int *pinlen, @@ -2171,7 +2171,7 @@ asciiToAscii(void *vctxt ATTRIBUTE_UNUSED, return(ret); } -static int +static xmlCharEncError latin1ToUTF8(void *vctxt ATTRIBUTE_UNUSED, unsigned char* out, int *outlen, const unsigned char* in, int *inlen, @@ -2236,7 +2236,7 @@ xmlIsolat1ToUTF8(unsigned char* out, int *outlen, /* flush */ 0)); } -static int +static xmlCharEncError UTF8ToUTF8(void *vctxt ATTRIBUTE_UNUSED, unsigned char* out, int *outlen, const unsigned char* in, int *inlen, @@ -2267,7 +2267,7 @@ UTF8ToUTF8(void *vctxt ATTRIBUTE_UNUSED, #ifdef LIBXML_OUTPUT_ENABLED -static int +static xmlCharEncError UTF8ToLatin1(void *vctxt ATTRIBUTE_UNUSED, unsigned char* out, int *outlen, const unsigned char* in, int *inlen, @@ -2346,7 +2346,7 @@ xmlUTF8ToIsolat1(unsigned char* out, int *outlen, } #endif /* LIBXML_OUTPUT_ENABLED */ -static int +static xmlCharEncError UTF16LEToUTF8(void *vctxt ATTRIBUTE_UNUSED, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, @@ -2416,7 +2416,7 @@ done: } #ifdef LIBXML_OUTPUT_ENABLED -static int +static xmlCharEncError UTF8ToUTF16LE(void *vctxt ATTRIBUTE_UNUSED, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, @@ -2519,7 +2519,7 @@ done: return(ret); } -static int +static xmlCharEncError UTF8ToUTF16(void *vctxt, unsigned char* outb, int *outlen, const unsigned char* in, int *inlen, @@ -2543,7 +2543,7 @@ UTF8ToUTF16(void *vctxt, } #endif /* LIBXML_OUTPUT_ENABLED */ -static int +static xmlCharEncError UTF16BEToUTF8(void *vctxt ATTRIBUTE_UNUSED, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, @@ -2613,7 +2613,7 @@ done: } #ifdef LIBXML_OUTPUT_ENABLED -static int +static xmlCharEncError UTF8ToUTF16BE(void *vctxt ATTRIBUTE_UNUSED, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, @@ -2717,7 +2717,7 @@ done: #endif /* LIBXML_OUTPUT_ENABLED */ #if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTML_ENABLED) -static int +static xmlCharEncError UTF8ToHtmlWrapper(void *vctxt ATTRIBUTE_UNUSED, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, @@ -2729,7 +2729,7 @@ UTF8ToHtmlWrapper(void *vctxt ATTRIBUTE_UNUSED, #if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED) && \ defined(LIBXML_ISO8859X_ENABLED) -static int +static xmlCharEncError UTF8ToISO8859x(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, @@ -2811,7 +2811,7 @@ done: return(ret); } -static int +static xmlCharEncError ISO8859xToUTF8(void *vctxt, unsigned char* out, int *outlen, const unsigned char* in, int *inlen, diff --git a/example/icu.c b/example/icu.c index 6f6f340e..05622498 100644 --- a/example/icu.c +++ b/example/icu.c @@ -30,7 +30,7 @@ typedef struct { UChar pivot_buf[ICU_PIVOT_BUF_SIZE]; } myConvCtxt; -static int +static xmlCharEncError icuConvert(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush) { myConvCtxt *cd = vctxt; @@ -102,7 +102,7 @@ icuConvert(void *vctxt, unsigned char *out, int *outlen, return ret; } -static int +static xmlParserErrors icuOpen(const char* name, int isInput, myConvCtxt **out) { UErrorCode status; @@ -170,13 +170,13 @@ icuConvCtxtDtor(void *vctxt) { icuClose(vctxt); } -static int +static xmlParserErrors icuConvImpl(void *vctxt, const char *name, xmlCharEncFlags flags, xmlCharEncodingHandler **result) { xmlCharEncConvFunc inFunc = NULL, outFunc = NULL; myConvCtxt *inputCtxt = NULL; myConvCtxt *outputCtxt = NULL; - int ret; + xmlParserErrors ret; if (flags & XML_ENC_INPUT) { ret = icuOpen(name, 1, &inputCtxt); diff --git a/fuzz/fuzz.c b/fuzz/fuzz.c index 816f5d3b..5bcd40de 100644 --- a/fuzz/fuzz.c +++ b/fuzz/fuzz.c @@ -457,7 +457,7 @@ xmlFuzzSecondaryEntity(size_t *size) { * * The resource loader for fuzz data. */ -int +xmlParserErrors xmlFuzzResourceLoader(void *data ATTRIBUTE_UNUSED, const char *URL, const char *ID ATTRIBUTE_UNUSED, xmlResourceType type ATTRIBUTE_UNUSED, diff --git a/fuzz/fuzz.h b/fuzz/fuzz.h index adf52092..48e83c17 100644 --- a/fuzz/fuzz.h +++ b/fuzz/fuzz.h @@ -135,7 +135,7 @@ xmlFuzzSecondaryUrl(void); const char * xmlFuzzSecondaryEntity(size_t *size); -int +xmlParserErrors xmlFuzzResourceLoader(void *data, const char *URL, const char *ID, xmlResourceType type, xmlParserInputFlags flags, xmlParserInputPtr *out); diff --git a/fuzz/genSeed.c b/fuzz/genSeed.c index fa2d3a73..6a98dc74 100644 --- a/fuzz/genSeed.c +++ b/fuzz/genSeed.c @@ -54,7 +54,7 @@ static struct { * A custom resource loader that writes all external DTDs or entities to a * single file in the format expected by xmlFuzzResourceLoader. */ -static int +static xmlParserErrors fuzzResourceRecorder(void *data ATTRIBUTE_UNUSED, const char *URL, const char *ID ATTRIBUTE_UNUSED, xmlResourceType type ATTRIBUTE_UNUSED, diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h index 7b862602..9a358dbb 100644 --- a/include/libxml/encoding.h +++ b/include/libxml/encoding.h @@ -23,6 +23,7 @@ #define __XML_CHAR_ENCODING_H__ #include +#include #ifdef __cplusplus extern "C" { @@ -142,9 +143,9 @@ typedef int (*xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, * @flush flag can be used to detect truncated sequences at EOF. * Otherwise, the flag can be ignored. * - * Returns a non-negative number on success or an XML_ENC_ERR code. + * Returns an XML_ENC_ERR code. */ -typedef int +typedef xmlCharEncError (*xmlCharEncConvFunc)(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush); @@ -195,7 +196,7 @@ struct _xmlCharEncodingHandler { * * Returns an xmlParserErrors code. */ -typedef int +typedef xmlParserErrors (*xmlCharEncConvImpl)(void *vctxt, const char *name, xmlCharEncFlags flags, xmlCharEncodingHandler **out); @@ -210,14 +211,14 @@ XMLPUBFUN void xmlCleanupCharEncodingHandlers (void); XMLPUBFUN void xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); -XMLPUBFUN int +XMLPUBFUN xmlParserErrors xmlLookupCharEncodingHandler (xmlCharEncoding enc, xmlCharEncodingHandlerPtr *out); -XMLPUBFUN int +XMLPUBFUN xmlParserErrors xmlOpenCharEncodingHandler (const char *name, int output, xmlCharEncodingHandlerPtr *out); -XMLPUBFUN int +XMLPUBFUN xmlParserErrors xmlCreateCharEncodingHandler (const char *name, xmlCharEncFlags flags, xmlCharEncConvImpl impl, @@ -231,7 +232,7 @@ XMLPUBFUN xmlCharEncodingHandlerPtr xmlNewCharEncodingHandler (const char *name, xmlCharEncodingInputFunc input, xmlCharEncodingOutputFunc output); -XMLPUBFUN int +XMLPUBFUN xmlParserErrors xmlCharEncNewCustomHandler (const char *name, xmlCharEncConvFunc input, xmlCharEncConvFunc output, diff --git a/include/libxml/parser.h b/include/libxml/parser.h index 1518ac8f..e2247526 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -218,9 +218,9 @@ typedef struct _xmlAttrHashBucket xmlAttrHashBucket; * On success, @out should be set to a new parser input object and * XML_ERR_OK should be returned. * - * Returns an xmlParserError code. + * Returns an xmlParserErrors code. */ -typedef int +typedef xmlParserErrors (*xmlResourceLoader)(void *ctxt, const char *url, const char *publicId, xmlResourceType type, xmlParserInputFlags flags, xmlParserInputPtr *out); @@ -1555,7 +1555,7 @@ XMLPUBFUN xmlDocPtr * New input API */ -XMLPUBFUN int +XMLPUBFUN xmlParserErrors xmlNewInputFromUrl(const char *url, xmlParserInputFlags flags, xmlParserInputPtr *out); XMLPUBFUN xmlParserInputPtr @@ -1570,7 +1570,7 @@ XMLPUBFUN xmlParserInputPtr xmlNewInputFromIO(const char *url, xmlInputReadCallback ioRead, xmlInputCloseCallback ioClose, void *ioCtxt, xmlParserInputFlags flags); -XMLPUBFUN int +XMLPUBFUN xmlParserErrors xmlInputSetEncodingHandler(xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler); diff --git a/include/libxml/xmlsave.h b/include/libxml/xmlsave.h index 176b1c7a..91d6ef9f 100644 --- a/include/libxml/xmlsave.h +++ b/include/libxml/xmlsave.h @@ -77,7 +77,7 @@ XMLPUBFUN int xmlSaveFlush (xmlSaveCtxtPtr ctxt); XMLPUBFUN int xmlSaveClose (xmlSaveCtxtPtr ctxt); -XMLPUBFUN int +XMLPUBFUN xmlParserErrors xmlSaveFinish (xmlSaveCtxtPtr ctxt); XMLPUBFUN int xmlSaveSetIndentString (xmlSaveCtxtPtr ctxt, diff --git a/include/private/enc.h b/include/private/enc.h index de575582..ef8ce5ae 100644 --- a/include/private/enc.h +++ b/include/private/enc.h @@ -7,11 +7,11 @@ XML_HIDDEN void xmlInitEncodingInternal(void); -XML_HIDDEN int +XML_HIDDEN xmlCharEncError xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush); -XML_HIDDEN int +XML_HIDDEN xmlCharEncError xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush); XML_HIDDEN int xmlCharEncOutput(xmlOutputBufferPtr output, int init); diff --git a/include/private/io.h b/include/private/io.h index be44809b..d6af99f1 100644 --- a/include/private/io.h +++ b/include/private/io.h @@ -21,7 +21,7 @@ xmlInitIOCallbacks(void); XML_HIDDEN int xmlNoNetExists(const char *filename); -XML_HIDDEN int +XML_HIDDEN xmlParserErrors xmlParserInputBufferCreateUrl(const char *URI, xmlCharEncoding enc, xmlParserInputFlags flags, xmlParserInputBufferPtr *out); @@ -32,7 +32,7 @@ XML_HIDDEN xmlParserInputBufferPtr xmlNewInputBufferMemory(const void *mem, size_t size, xmlParserInputFlags flags, xmlCharEncoding enc); -XML_HIDDEN int +XML_HIDDEN xmlParserErrors xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, xmlParserInputFlags flags); #ifdef LIBXML_OUTPUT_ENABLED diff --git a/parserInternals.c b/parserInternals.c index 34417cb0..af2dfd93 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -621,14 +621,14 @@ xmlParserCheckEOF(xmlParserCtxtPtr ctxt, xmlParserErrors code) { if ((buf != NULL) && (buf->encoder != NULL)) { size_t curBase = in->cur - in->base; size_t sizeOut = 64; - int ret; + xmlCharEncError ret; /* * Check for truncated multi-byte sequence */ ret = xmlCharEncInput(buf, &sizeOut, /* flush */ 1); xmlBufUpdateInput(buf->buffer, in, curBase); - if (ret < 0) { + if (ret != XML_ENC_ERR_SUCCESS) { xmlCtxtErrIO(ctxt, buf->error, NULL); return; } @@ -1129,12 +1129,14 @@ xmlCtxtSetCharEncConvImpl(xmlParserCtxtPtr ctxt, xmlCharEncConvImpl impl, ctxt->convCtxt = vctxt; } -static int +static xmlParserErrors xmlDetectEBCDIC(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr *hout) { xmlChar out[200]; xmlParserInputPtr input = ctxt->input; xmlCharEncodingHandlerPtr handler; - int inlen, outlen, res, i; + int inlen, outlen, i; + xmlParserErrors code; + xmlCharEncError res; *hout = NULL; @@ -1142,10 +1144,10 @@ xmlDetectEBCDIC(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr *hout) { * To detect the EBCDIC code page, we convert the first 200 bytes * to IBM037 (EBCDIC-US) and try to find the encoding declaration. */ - res = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT, + code = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT, ctxt->convImpl, ctxt->convCtxt, &handler); - if (res != 0) - return(res); + if (code != XML_ERR_OK) + return(code); outlen = sizeof(out) - 1; inlen = input->end - input->cur; res = xmlEncInputChunk(handler, out, &outlen, input->cur, &inlen, @@ -1187,13 +1189,13 @@ xmlDetectEBCDIC(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr *hout) { break; out[i] = 0; xmlCharEncCloseFunc(handler); - res = xmlCreateCharEncodingHandler((char *) out + start, + code = xmlCreateCharEncodingHandler((char *) out + start, XML_ENC_INPUT, ctxt->convImpl, ctxt->convCtxt, &handler); - if (res != 0) - return(res); + if (code != XML_ERR_OK) + return(code); *hout = handler; - return(0); + return(XML_ERR_OK); } } @@ -1202,12 +1204,12 @@ done: * Encoding handlers are stateful, so we have to recreate them. */ xmlCharEncCloseFunc(handler); - res = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT, + code = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT, ctxt->convImpl, ctxt->convCtxt, &handler); - if (res != 0) - return(res); + if (code != XML_ERR_OK) + return(code); *hout = handler; - return(0); + return(XML_ERR_OK); } /** @@ -1228,14 +1230,14 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) { xmlCharEncodingHandlerPtr handler = NULL; int ret; - int res; + xmlParserErrors code; if ((ctxt == NULL) || (ctxt->input == NULL)) return(-1); - res = xmlLookupCharEncodingHandler(enc, &handler); - if (res != 0) { - xmlFatalErr(ctxt, res, NULL); + code = xmlLookupCharEncodingHandler(enc, &handler); + if (code != 0) { + xmlFatalErr(ctxt, code, NULL); return(-1); } @@ -1260,7 +1262,7 @@ static int xmlSwitchInputEncodingName(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, const char *encoding) { xmlCharEncodingHandlerPtr handler; - int res; + xmlParserErrors res; if (encoding == NULL) return(-1); @@ -1319,12 +1321,12 @@ xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding) { * * Returns an xmlParserErrors code. */ -int +xmlParserErrors xmlInputSetEncodingHandler(xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler) { xmlParserInputBufferPtr in; xmlBufPtr buf; - int code = XML_ERR_OK; + xmlParserErrors code = XML_ERR_OK; if ((input == NULL) || (input->buf == NULL)) { xmlCharEncCloseFunc(handler); @@ -1377,7 +1379,7 @@ xmlInputSetEncodingHandler(xmlParserInputPtr input, if (input->end > input->base) { size_t processed; size_t nbchars; - int res; + xmlCharEncError res; /* * Shrink the current input buffer. @@ -1399,7 +1401,7 @@ xmlInputSetEncodingHandler(xmlParserInputPtr input, else nbchars = 4000 /* MINLEN */; res = xmlCharEncInput(in, &nbchars, /* flush */ 0); - if (res < 0) + if (res != XML_ENC_ERR_SUCCESS) code = in->error; } @@ -1423,7 +1425,7 @@ xmlInputSetEncodingHandler(xmlParserInputPtr input, int xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler) { - int code = xmlInputSetEncodingHandler(input, handler); + xmlParserErrors code = xmlInputSetEncodingHandler(input, handler); if (code != XML_ERR_OK) { xmlCtxtErrIO(ctxt, code, NULL); @@ -1448,7 +1450,7 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, int xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler) { - int code; + xmlParserErrors code; if (ctxt == NULL) return(-1); @@ -1579,7 +1581,7 @@ xmlDetectEncoding(xmlParserCtxtPtr ctxt) { if (enc == XML_CHAR_ENCODING_EBCDIC) { xmlCharEncodingHandlerPtr handler; - int res; + xmlParserErrors res; res = xmlDetectEBCDIC(ctxt, &handler); if (res != XML_ERR_OK) { @@ -1610,7 +1612,7 @@ xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding) { if (((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) && ((ctxt->options & XML_PARSE_IGNORE_ENC) == 0)) { xmlCharEncodingHandlerPtr handler; - int res; + xmlParserErrors res; /* * xmlSwitchEncodingName treats unsupported encodings as @@ -2018,7 +2020,7 @@ xmlNewInputFromFd(const char *url, int fd, xmlParserInputFlags flags) { if (buf == NULL) return(NULL); - if (xmlInputFromFd(buf, fd, flags) < 0) { + if (xmlInputFromFd(buf, fd, flags) != XML_ERR_OK) { xmlFreeParserInputBuffer(buf); return(NULL); } @@ -2367,7 +2369,7 @@ xmlResolveResourceFromCatalog(const char *URL, const char *ID, #endif #ifdef LIBXML_HTTP_ENABLED -static int +static xmlParserErrors xmlCheckHTTPInputInternal(xmlParserInputPtr input) { const char *encoding; const char *redir; @@ -2391,7 +2393,7 @@ xmlCheckHTTPInputInternal(xmlParserInputPtr input) { encoding = xmlNanoHTTPEncoding(input->buf->context); if (encoding != NULL) { xmlCharEncodingHandlerPtr handler; - int res; + xmlParserErrors res; res = xmlOpenCharEncodingHandler(encoding, /* output */ 0, &handler); @@ -2478,12 +2480,12 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) { * * Returns an xmlParserErrors code. */ -int +xmlParserErrors xmlNewInputFromUrl(const char *filename, xmlParserInputFlags flags, xmlParserInputPtr *out) { xmlParserInputBufferPtr buf; xmlParserInputPtr input; - int code = XML_ERR_OK; + xmlParserErrors code = XML_ERR_OK; if (out == NULL) return(XML_ERR_ARGUMENT); @@ -2534,7 +2536,7 @@ xmlParserInputPtr xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { xmlParserInputPtr input; xmlParserInputFlags flags = 0; - int code; + xmlParserErrors code; if ((ctxt == NULL) || (filename == NULL)) return(NULL); diff --git a/runsuite.c b/runsuite.c index 37315891..52fc6a1a 100644 --- a/runsuite.c +++ b/runsuite.c @@ -241,7 +241,7 @@ static int addEntity(char *name, char *content) { return(0); } -static int +static xmlParserErrors testResourceLoader(void *vctxt ATTRIBUTE_UNUSED, const char *URL, const char *ID ATTRIBUTE_UNUSED, xmlResourceType type ATTRIBUTE_UNUSED, diff --git a/testapi.c b/testapi.c index f14b8f58..5e3e6fb9 100644 --- a/testapi.c +++ b/testapi.c @@ -13222,7 +13222,7 @@ test_xmlInputSetEncodingHandler(void) { int test_ret = 0; int mem_base; - int ret_val; + xmlParserErrors ret_val; xmlParserInputPtr input; /* the input stream */ int n_input; xmlCharEncodingHandlerPtr handler; /* the encoding handler */ @@ -13235,7 +13235,7 @@ test_xmlInputSetEncodingHandler(void) { handler = gen_xmlCharEncodingHandlerPtr(n_handler, 1); ret_val = xmlInputSetEncodingHandler(input, handler); - desret_int(ret_val); + desret_xmlParserErrors(ret_val); call_tests++; des_xmlParserInputPtr(n_input, input, 0); des_xmlCharEncodingHandlerPtr(n_handler, handler, 1); @@ -13534,7 +13534,7 @@ test_xmlNewInputFromUrl(void) { int test_ret = 0; int mem_base; - int ret_val; + xmlParserErrors ret_val; const char * filename; /* the filename to use as entity */ int n_filename; xmlParserInputFlags flags; /* XML_INPUT flags */ @@ -13551,7 +13551,7 @@ test_xmlNewInputFromUrl(void) { out = gen_xmlParserInputPtr_ptr(n_out, 2); ret_val = xmlNewInputFromUrl(filename, flags, out); - desret_int(ret_val); + desret_xmlParserErrors(ret_val); call_tests++; des_filepath(n_filename, filename, 0); des_xmlParserInputFlags(n_flags, flags, 1); @@ -33991,7 +33991,7 @@ test_xmlSaveFinish(void) { #if defined(LIBXML_OUTPUT_ENABLED) int mem_base; - int ret_val; + xmlParserErrors ret_val; xmlSaveCtxtPtr ctxt; /* a document saving context */ int n_ctxt; @@ -34000,7 +34000,7 @@ test_xmlSaveFinish(void) { ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); ret_val = xmlSaveFinish(ctxt); - desret_int(ret_val); + desret_xmlParserErrors(ret_val); call_tests++; des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); xmlResetLastError(); diff --git a/testparser.c b/testparser.c index 012c9fd3..5cca7b67 100644 --- a/testparser.c +++ b/testparser.c @@ -1030,7 +1030,7 @@ testTruncatedMultiByte(void) { static int charEncConvImplError; -static int +static xmlCharEncError rot13Convert(void *vctxt, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush ATTRIBUTE_UNUSED) { @@ -1063,7 +1063,7 @@ rot13ConvCtxtDtor(void *vctxt) { xmlFree(vctxt); } -static int +static xmlParserErrors rot13ConvImpl(void *vctxt ATTRIBUTE_UNUSED, const char *name, xmlCharEncFlags flags, xmlCharEncodingHandler **out) { int *inputCtxt; diff --git a/xinclude.c b/xinclude.c index 0e9edd4a..15089180 100644 --- a/xinclude.c +++ b/xinclude.c @@ -1398,18 +1398,20 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) { encoding = xmlXIncludeGetProp(ctxt, ref->elem, XINCLUDE_PARSE_ENCODING); } if (encoding != NULL) { - res = xmlOpenCharEncodingHandler((const char *) encoding, - /* output */ 0, &handler); + xmlParserErrors code; - if (res != 0) { - if (res == XML_ERR_NO_MEMORY) { + code = xmlOpenCharEncodingHandler((const char *) encoding, + /* output */ 0, &handler); + + if (code != XML_ERR_OK) { + if (code == XML_ERR_NO_MEMORY) { xmlXIncludeErrMemory(ctxt); - } else if (res == XML_ERR_UNSUPPORTED_ENCODING) { + } else if (code == XML_ERR_UNSUPPORTED_ENCODING) { xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_UNKNOWN_ENCODING, "encoding %s not supported\n", encoding); goto error; } else { - xmlXIncludeErr(ctxt, ref->elem, res, + xmlXIncludeErr(ctxt, ref->elem, code, "unexpected error from iconv or ICU\n", NULL); goto error; } diff --git a/xmlIO.c b/xmlIO.c index e2e2a7d0..206efa79 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -122,10 +122,10 @@ static int xmlOutputCallbackNr; * * Returns an xmlParserErrors code. */ -static int +static xmlParserErrors xmlIOErr(int err) { - int code; + xmlParserErrors code; if (err == 0) code = XML_IO_UNKNOWN; #ifdef EACCES @@ -449,12 +449,12 @@ typedef struct { * * Returns an xmlParserErrors code */ -static int +static xmlParserErrors xmlFdOpen(const char *filename, int write, int *out) { char *fromUri = NULL; int flags; int fd; - int ret; + xmlParserErrors ret; *out = -1; if (filename == NULL) @@ -628,13 +628,13 @@ xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) { * * input from FILE * * - * Returns an I/O context or NULL in case of error + * Returns an xmlParserErrors code */ -static int +static xmlParserErrors xmlFileOpenSafe(const char *filename, int write, void **out) { char *fromUri = NULL; FILE *fd; - int ret = XML_ERR_OK; + xmlParserErrors ret = XML_ERR_OK; *out = NULL; if (filename == NULL) @@ -1046,9 +1046,9 @@ xmlIODefaultMatch(const char *filename ATTRIBUTE_UNUSED) { * Update the buffer to read from @fd. Supports the XML_INPUT_UNZIP * flag. * - * Returns an xmlParserError code. + * Returns an xmlParserErrors code. */ -int +xmlParserErrors xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, xmlParserInputFlags flags) { xmlFdIOCtxt *fdctxt; @@ -1160,10 +1160,10 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, * * Returns an xmlParserErrors code. */ -static int +static xmlParserErrors xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename, xmlParserInputFlags flags) { - int ret; + xmlParserErrors ret; int fd; #ifdef LIBXML_HTTP_ENABLED @@ -1205,7 +1205,7 @@ xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename, * * Returns an xmlParserErrors code. */ -static int +static xmlParserErrors xmlOutputDefaultOpen(xmlOutputBufferPtr buf, const char *filename, int compression) { xmlFdIOCtxt *fdctxt; @@ -1290,7 +1290,7 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) { return(NULL); } if (enc != XML_CHAR_ENCODING_NONE) { - if (xmlLookupCharEncodingHandler(enc, &ret->encoder) != 0) { + if (xmlLookupCharEncodingHandler(enc, &ret->encoder) != XML_ERR_OK) { /* We can't handle errors properly here. */ xmlFreeParserInputBuffer(ret); return(NULL); @@ -1454,12 +1454,12 @@ xmlOutputBufferClose(xmlOutputBufferPtr out) * * Returns an xmlParserErrors code. */ -int +xmlParserErrors xmlParserInputBufferCreateUrl(const char *URI, xmlCharEncoding enc, xmlParserInputFlags flags, xmlParserInputBufferPtr *out) { xmlParserInputBufferPtr buf; - int ret; + xmlParserErrors ret; int i; xmlInitParser(); @@ -1534,7 +1534,7 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { xmlParserInputBufferPtr xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { xmlParserInputBufferPtr ret; - int code; + xmlParserErrors code; if (xmlParserInputBufferCreateFilenameValue != NULL) return(xmlParserInputBufferCreateFilenameValue(URI, enc)); @@ -1601,7 +1601,7 @@ __xmlOutputBufferCreateFilename(const char *URI, */ for (i = xmlOutputCallbackNr - 1; i >= 0; i--) { xmlOutputCallback *cb = &xmlOutputCallbackTable[i]; - int code; + xmlParserErrors code; if (cb->matchcallback == xmlIODefaultMatch) { code = xmlOutputDefaultOpen(ret, URI, compression); @@ -2203,7 +2203,8 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in, * convert as much as possible to the parser reading buffer. */ nbchars = SIZE_MAX; - if (xmlCharEncInput(in, &nbchars, /* flush */ 0) < 0) + if (xmlCharEncInput(in, &nbchars, /* flush */ 0) != + XML_ENC_ERR_SUCCESS) return(-1); if (nbchars > INT_MAX) nbchars = INT_MAX; @@ -2314,7 +2315,8 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) { else sizeOut = SIZE_MAX; - if (xmlCharEncInput(in, &sizeOut, /* flush */ 0) < 0) + if (xmlCharEncInput(in, &sizeOut, /* flush */ 0) != + XML_ENC_ERR_SUCCESS) return(-1); res = sizeOut; } diff --git a/xmllint.c b/xmllint.c index 8967c887..19f31168 100644 --- a/xmllint.c +++ b/xmllint.c @@ -253,12 +253,12 @@ parsePath(xmllintState *lint, const xmlChar *path) { } } -static int +static xmlParserErrors xmllintResourceLoader(void *ctxt, const char *URL, const char *ID, xmlResourceType type, xmlParserInputFlags flags, xmlParserInputPtr *out) { xmllintState *lint = ctxt; - int code; + xmlParserErrors code; int i; const char *lastsegment = URL; const char *iter = URL; diff --git a/xmlsave.c b/xmlsave.c index 1e7b19d4..38ccdbfd 100644 --- a/xmlsave.c +++ b/xmlsave.c @@ -319,7 +319,7 @@ xmlNewSaveCtxt(const char *encoding, int options) memset(ret, 0, sizeof(xmlSaveCtxt)); if (encoding != NULL) { - int res; + xmlParserErrors res; res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &ret->handler); @@ -771,7 +771,7 @@ static int xmlSaveSwitchEncoding(xmlSaveCtxtPtr ctxt, const char *encoding) { if ((encoding != NULL) && (buf->encoder == NULL) && (buf->conv == NULL)) { xmlCharEncodingHandler *handler; - int res; + xmlParserErrors res; res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler); if (res != XML_ERR_OK) { @@ -2196,7 +2196,7 @@ xmlSaveClose(xmlSaveCtxtPtr ctxt) * * Returns an xmlParserErrors code. */ -int +xmlParserErrors xmlSaveFinish(xmlSaveCtxtPtr ctxt) { int ret; @@ -2549,7 +2549,7 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr, if (txt_encoding == NULL) txt_encoding = (const char *) out_doc->encoding; if (txt_encoding != NULL) { - int res; + xmlParserErrors res; res = xmlOpenCharEncodingHandler(txt_encoding, /* output */ 1, &conv_hdlr); @@ -2671,7 +2671,7 @@ xmlDocFormatDump(FILE *f, xmlDocPtr cur, int format) { encoding = (const char *) cur->encoding; if (encoding != NULL) { - int res; + xmlParserErrors res; res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler); if (res != XML_ERR_OK) { @@ -2817,7 +2817,7 @@ xmlSaveFormatFileEnc( const char * filename, xmlDocPtr cur, encoding = (const char *) cur->encoding; if (encoding != NULL) { - int res; + xmlParserErrors res; res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler); if (res != XML_ERR_OK)