1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

parser: Simplify xmlNewInputFromFile

This commit is contained in:
Nick Wellnhofer 2024-06-11 00:52:04 +02:00
parent 0b58838764
commit a3b2baeb67

View File

@ -2036,9 +2036,7 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
xmlParserInputPtr
xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
xmlParserInputBufferPtr buf;
xmlParserInputPtr inputStream;
const xmlChar *URI;
xmlChar *canonic;
xmlParserInputPtr input;
int code = XML_ERR_OK;
if ((ctxt == NULL) || (filename == NULL))
@ -2062,34 +2060,13 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
return(NULL);
}
inputStream = xmlNewInputStream(ctxt);
if (inputStream == NULL) {
xmlFreeParserInputBuffer(buf);
input = xmlNewInputInternal(ctxt, buf, filename, NULL);
if (input == NULL)
return(NULL);
}
inputStream->buf = buf;
inputStream = xmlCheckHTTPInput(ctxt, inputStream);
if (inputStream == NULL)
return(NULL);
input = xmlCheckHTTPInput(ctxt, input);
if (inputStream->filename == NULL)
URI = (xmlChar *) filename;
else
URI = (xmlChar *) inputStream->filename;
canonic = xmlCanonicPath(URI);
if (canonic == NULL) {
xmlCtxtErrMemory(ctxt);
xmlFreeInputStream(inputStream);
return(NULL);
}
if (inputStream->filename != NULL)
xmlFree((char *) inputStream->filename);
inputStream->filename = (char *) canonic;
xmlBufResetInput(inputStream->buf->buffer, inputStream);
return(inputStream);
return(input);
}
/**