From b5890cb425627c44615daca6d7be1f34c394ec95 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 10 Jun 2024 18:51:56 +0200 Subject: [PATCH] io: Remove xmlParserInputBufferCreateFilenameSafe --- include/private/io.h | 4 ++-- parserInternals.c | 15 +++++++++++---- xmlIO.c | 31 +++++-------------------------- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/include/private/io.h b/include/private/io.h index df10062b..40286993 100644 --- a/include/private/io.h +++ b/include/private/io.h @@ -12,8 +12,8 @@ XML_HIDDEN int xmlNoNetExists(const char *filename); XML_HIDDEN int -xmlParserInputBufferCreateFilenameSafe(const char *URI, xmlCharEncoding enc, - xmlParserInputBufferPtr *out); +xmlParserInputBufferCreateFilenameInt(const char *URI, xmlCharEncoding enc, + xmlParserInputBufferPtr *out); XML_HIDDEN xmlParserInputBufferPtr xmlNewInputBufferString(const char *str, int flags); diff --git a/parserInternals.c b/parserInternals.c index 5dafe283..b2580882 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -2039,14 +2039,21 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { xmlParserInputPtr inputStream; const xmlChar *URI; xmlChar *canonic; - int code; + int code = XML_ERR_OK; if ((ctxt == NULL) || (filename == NULL)) return(NULL); - code = xmlParserInputBufferCreateFilenameSafe(filename, - XML_CHAR_ENCODING_NONE, &buf); - if (buf == NULL) { + if (xmlParserInputBufferCreateFilenameValue != NULL) { + buf = xmlParserInputBufferCreateFilenameValue(filename, + XML_CHAR_ENCODING_NONE); + if (buf == NULL) + code = XML_IO_ENOENT; + } else { + code = xmlParserInputBufferCreateFilenameInt(filename, + XML_CHAR_ENCODING_NONE, &buf); + } + if (code != XML_ERR_OK) { xmlCtxtErrIO(ctxt, code, filename); return(NULL); } diff --git a/xmlIO.c b/xmlIO.c index 929d8689..3f41b2cb 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -1503,7 +1503,7 @@ xmlOutputBufferClose(xmlOutputBufferPtr out) * * Returns an xmlParserErrors code. */ -static int +int xmlParserInputBufferCreateFilenameInt(const char *URI, xmlCharEncoding enc, xmlParserInputBufferPtr *out) { xmlParserInputBufferPtr buf; @@ -1577,34 +1577,13 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { */ xmlParserInputBufferPtr xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { + xmlParserInputBufferPtr ret; + if (xmlParserInputBufferCreateFilenameValue != NULL) return(xmlParserInputBufferCreateFilenameValue(URI, enc)); - return(__xmlParserInputBufferCreateFilename(URI, enc)); -} - -/** - * xmlParserInputBufferCreateFilenameSafe: - * @URI: the filename or URI - * @enc: encoding enum (deprecated) - * @out: pointer to resulting input buffer - * - * Create an input buffer for a filename or URI. - * - * Returns an xmlParserErrors code. - */ -int -xmlParserInputBufferCreateFilenameSafe(const char *URI, xmlCharEncoding enc, - xmlParserInputBufferPtr *out) { - if (xmlParserInputBufferCreateFilenameValue != NULL) { - *out = xmlParserInputBufferCreateFilenameValue(URI, enc); - - if (*out == NULL) - return(XML_IO_ENOENT); - return(XML_ERR_OK); - } - - return(xmlParserInputBufferCreateFilenameInt(URI, enc, out)); + xmlParserInputBufferCreateFilenameInt(URI, enc, &ret); + return(ret); } #ifdef LIBXML_OUTPUT_ENABLED