1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-26 10:03:34 +03:00

parser: Rename internal xmlNewInput functions

This commit is contained in:
Nick Wellnhofer 2024-07-06 22:04:06 +02:00
parent 4f329dc524
commit d74ca59491
4 changed files with 90 additions and 83 deletions

View File

@ -4996,9 +4996,6 @@ htmlFreeParserCtxt(htmlParserCtxtPtr ctxt)
*
* See xmlCtxtSetErrorHandler for advanced error handling.
*
* See xmlNewInputURL, xmlNewInputMemory, xmlNewInputIO and similar
* functions for advanced input control.
*
* See htmlNewSAXParserCtxt for custom SAX parsers.
*
* Returns the htmlParserCtxtPtr or NULL in case of allocation error
@ -5059,7 +5056,7 @@ htmlCreateMemoryParserCtxtInternal(const char *url,
if (ctxt == NULL)
return(NULL);
input = xmlNewInputMemory(ctxt, url, buffer, size, encoding, 0);
input = xmlCtxtNewInputFromMemory(ctxt, url, buffer, size, encoding, 0);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -5116,7 +5113,8 @@ htmlCreateDocParserCtxt(const xmlChar *str, const char *url,
if (ctxt == NULL)
return(NULL);
input = xmlNewInputString(ctxt, url, (const char *) str, encoding, 0);
input = xmlCtxtNewInputFromString(ctxt, url, (const char *) str,
encoding, 0);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -5960,7 +5958,7 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
return(NULL);
}
input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0);
input = xmlCtxtNewInputFromUrl(ctxt, filename, NULL, encoding, 0);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -6026,8 +6024,6 @@ htmlSAXParseFile(const char *filename, const char *encoding, htmlSAXHandlerPtr s
*
* Parse an HTML file and build a tree.
*
* See xmlNewInputURL for details.
*
* Returns the resulting document tree
*/
@ -6426,8 +6422,8 @@ htmlReadDoc(const xmlChar *str, const char *url, const char *encoding,
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputString(ctxt, url, (const char *) str, encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromString(ctxt, url, (const char *) str, encoding,
XML_INPUT_BUF_STATIC);
doc = htmlCtxtParseDocument(ctxt, input);
@ -6461,7 +6457,7 @@ htmlReadFile(const char *filename, const char *encoding, int options)
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0);
input = xmlCtxtNewInputFromUrl(ctxt, filename, NULL, encoding, 0);
doc = htmlCtxtParseDocument(ctxt, input);
@ -6501,8 +6497,8 @@ htmlReadMemory(const char *buffer, int size, const char *url,
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputMemory(ctxt, url, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromMemory(ctxt, url, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
doc = htmlCtxtParseDocument(ctxt, input);
@ -6540,7 +6536,7 @@ htmlReadFd(int fd, const char *url, const char *encoding, int options)
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputFd(ctxt, url, fd, encoding, 0);
input = xmlCtxtNewInputFromFd(ctxt, url, fd, encoding, 0);
doc = htmlCtxtParseDocument(ctxt, input);
@ -6578,7 +6574,8 @@ htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputIO(ctxt, url, ioread, ioclose, ioctx, encoding, 0);
input = xmlCtxtNewInputFromIO(ctxt, url, ioread, ioclose, ioctx,
encoding, 0);
doc = htmlCtxtParseDocument(ctxt, input);
@ -6612,7 +6609,8 @@ htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar *str,
htmlCtxtReset(ctxt);
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputString(ctxt, URL, (const char *) str, encoding, 0);
input = xmlCtxtNewInputFromString(ctxt, URL, (const char *) str,
encoding, 0);
return(htmlCtxtParseDocument(ctxt, input));
}
@ -6627,7 +6625,7 @@ htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar *str,
* Parse an HTML file from the filesystem, the network or a
* user-defined resource loader.
*
* See xmlNewInputURL and htmlCtxtUseOptions for details.
* See htmlCtxtUseOptions for details.
*
* Returns the resulting document tree
*/
@ -6643,7 +6641,7 @@ htmlCtxtReadFile(htmlParserCtxtPtr ctxt, const char *filename,
htmlCtxtReset(ctxt);
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0);
input = xmlCtxtNewInputFromUrl(ctxt, filename, NULL, encoding, 0);
return(htmlCtxtParseDocument(ctxt, input));
}
@ -6676,8 +6674,8 @@ htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
htmlCtxtReset(ctxt);
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputMemory(ctxt, URL, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromMemory(ctxt, URL, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
return(htmlCtxtParseDocument(ctxt, input));
}
@ -6711,7 +6709,7 @@ htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd,
htmlCtxtReset(ctxt);
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputFd(ctxt, URL, fd, encoding, 0);
input = xmlCtxtNewInputFromFd(ctxt, URL, fd, encoding, 0);
return(htmlCtxtParseDocument(ctxt, input));
}
@ -6728,7 +6726,7 @@ htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd,
*
* Parse an HTML document from I/O functions and source and build a tree.
*
* See xmlNewInputIO and htmlCtxtUseOptions for details.
* See htmlCtxtUseOptions for details.
*
* Returns the resulting document tree
*/
@ -6746,7 +6744,8 @@ htmlCtxtReadIO(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
htmlCtxtReset(ctxt);
htmlCtxtUseOptions(ctxt, options);
input = xmlNewInputIO(ctxt, URL, ioread, ioclose, ioctx, encoding, 0);
input = xmlCtxtNewInputFromIO(ctxt, URL, ioread, ioclose, ioctx,
encoding, 0);
return(htmlCtxtParseDocument(ctxt, input));
}

View File

@ -96,24 +96,24 @@ XML_HIDDEN xmlParserInputPtr
xmlLoadResource(xmlParserCtxtPtr ctxt, const char *url, const char *publicId,
xmlResourceType type);
XML_HIDDEN xmlParserInputPtr
xmlNewInputURL(xmlParserCtxtPtr ctxt, const char *url, const char *publicId,
const char *encoding, int flags);
xmlCtxtNewInputFromUrl(xmlParserCtxtPtr ctxt, const char *url,
const char *publicId, const char *encoding, int flags);
XML_HIDDEN xmlParserInputPtr
xmlNewInputMemory(xmlParserCtxtPtr ctxt, const char *url,
const void *mem, size_t size,
const char *encoding, int flags);
xmlCtxtNewInputFromMemory(xmlParserCtxtPtr ctxt, const char *url,
const void *mem, size_t size,
const char *encoding, int flags);
XML_HIDDEN xmlParserInputPtr
xmlNewInputString(xmlParserCtxtPtr ctxt, const char *url, const char *str,
const char *encoding, int flags);
xmlCtxtNewInputFromString(xmlParserCtxtPtr ctxt, const char *url,
const char *str, const char *encoding, int flags);
XML_HIDDEN xmlParserInputPtr
xmlNewInputFd(xmlParserCtxtPtr ctxt, const char *filename, int fd,
const char *encoding, int flags);
xmlCtxtNewInputFromFd(xmlParserCtxtPtr ctxt, const char *filename, int fd,
const char *encoding, int flags);
XML_HIDDEN xmlParserInputPtr
xmlNewInputIO(xmlParserCtxtPtr ctxt, const char *url,
xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose,
void *ioCtxt,
const char *encoding, int flags);
xmlCtxtNewInputFromIO(xmlParserCtxtPtr ctxt, const char *url,
xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose,
void *ioCtxt,
const char *encoding, int flags);
XML_HIDDEN xmlParserInputPtr
xmlInputCreatePush(const char *url, const char *chunk, int size);

View File

@ -11754,7 +11754,8 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
return(NULL);
encoding = xmlGetCharEncodingName(enc);
input = xmlNewInputIO(ctxt, NULL, ioread, ioclose, ioctx, encoding, 0);
input = xmlCtxtNewInputFromIO(ctxt, NULL, ioread, ioclose, ioctx,
encoding, 0);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return (NULL);
@ -12518,9 +12519,9 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
if (ctxt == NULL)
return(XML_ERR_NO_MEMORY);
input = xmlNewInputMemory(ctxt, NULL, data, datalen,
(const char *) doc->encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromMemory(ctxt, NULL, data, datalen,
(const char *) doc->encoding,
XML_INPUT_BUF_STATIC);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(XML_ERR_NO_MEMORY);
@ -12847,9 +12848,9 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
}
if ((filename != NULL) && (filename[0] == '-') && (filename[1] == 0))
input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, NULL, 0);
input = xmlCtxtNewInputFromFd(ctxt, filename, STDIN_FILENO, NULL, 0);
else
input = xmlNewInputURL(ctxt, filename, NULL, NULL, 0);
input = xmlCtxtNewInputFromUrl(ctxt, filename, NULL, NULL, 0);
ret = xmlCtxtParseDocument(ctxt, input);
@ -12959,7 +12960,8 @@ xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const xmlChar* buffer,
xmlClearParserCtxt(ctxt);
input = xmlNewInputString(ctxt, filename, (const char *) buffer, NULL, 0);
input = xmlCtxtNewInputFromString(ctxt, filename, (const char *) buffer,
NULL, 0);
if (input == NULL)
return;
if (inputPush(ctxt, input) < 0)
@ -13045,7 +13047,7 @@ xmlCreateMemoryParserCtxt(const char *buffer, int size) {
if (ctxt == NULL)
return(NULL);
input = xmlNewInputMemory(ctxt, NULL, buffer, size, NULL, 0);
input = xmlCtxtNewInputFromMemory(ctxt, NULL, buffer, size, NULL, 0);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -13103,8 +13105,8 @@ xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
ctxt->recovery = 1;
}
input = xmlNewInputMemory(ctxt, NULL, buffer, size, NULL,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromMemory(ctxt, NULL, buffer, size, NULL,
XML_INPUT_BUF_STATIC);
ret = xmlCtxtParseDocument(ctxt, input);
@ -13235,7 +13237,7 @@ xmlCreateDocParserCtxt(const xmlChar *str) {
if (ctxt == NULL)
return(NULL);
input = xmlNewInputString(ctxt, NULL, (const char *) str, NULL, 0);
input = xmlCtxtNewInputFromString(ctxt, NULL, (const char *) str, NULL, 0);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -13896,8 +13898,8 @@ xmlReadDoc(const xmlChar *cur, const char *URL, const char *encoding,
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputString(ctxt, URL, (const char *) cur, encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromString(ctxt, URL, (const char *) cur, encoding,
XML_INPUT_BUF_STATIC);
doc = xmlCtxtParseDocument(ctxt, input);
@ -13937,9 +13939,10 @@ xmlReadFile(const char *filename, const char *encoding, int options)
* should be removed at some point.
*/
if ((filename != NULL) && (filename[0] == '-') && (filename[1] == 0))
input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, encoding, 0);
input = xmlCtxtNewInputFromFd(ctxt, filename, STDIN_FILENO,
encoding, 0);
else
input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0);
input = xmlCtxtNewInputFromUrl(ctxt, filename, NULL, encoding, 0);
doc = xmlCtxtParseDocument(ctxt, input);
@ -13979,8 +13982,8 @@ xmlReadMemory(const char *buffer, int size, const char *url,
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputMemory(ctxt, url, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromMemory(ctxt, url, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
doc = xmlCtxtParseDocument(ctxt, input);
@ -14017,7 +14020,7 @@ xmlReadFd(int fd, const char *URL, const char *encoding, int options)
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputFd(ctxt, URL, fd, encoding, 0);
input = xmlCtxtNewInputFromFd(ctxt, URL, fd, encoding, 0);
doc = xmlCtxtParseDocument(ctxt, input);
@ -14054,7 +14057,8 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputIO(ctxt, URL, ioread, ioclose, ioctx, encoding, 0);
input = xmlCtxtNewInputFromIO(ctxt, URL, ioread, ioclose, ioctx,
encoding, 0);
doc = xmlCtxtParseDocument(ctxt, input);
@ -14091,8 +14095,8 @@ xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar *str,
xmlCtxtReset(ctxt);
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputString(ctxt, URL, (const char *) str, encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromString(ctxt, URL, (const char *) str, encoding,
XML_INPUT_BUF_STATIC);
return(xmlCtxtParseDocument(ctxt, input));
}
@ -14121,7 +14125,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename,
xmlCtxtReset(ctxt);
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0);
input = xmlCtxtNewInputFromUrl(ctxt, filename, NULL, encoding, 0);
return(xmlCtxtParseDocument(ctxt, input));
}
@ -14157,8 +14161,8 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
xmlCtxtReset(ctxt);
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputMemory(ctxt, URL, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromMemory(ctxt, URL, buffer, size, encoding,
XML_INPUT_BUF_STATIC);
return(xmlCtxtParseDocument(ctxt, input));
}
@ -14195,7 +14199,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
xmlCtxtReset(ctxt);
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputFd(ctxt, URL, fd, encoding, 0);
input = xmlCtxtNewInputFromFd(ctxt, URL, fd, encoding, 0);
return(xmlCtxtParseDocument(ctxt, input));
}
@ -14234,7 +14238,8 @@ xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
xmlCtxtReset(ctxt);
xmlCtxtUseOptions(ctxt, options);
input = xmlNewInputIO(ctxt, URL, ioread, ioclose, ioctx, encoding, 0);
input = xmlCtxtNewInputFromIO(ctxt, URL, ioread, ioclose, ioctx,
encoding, 0);
return(xmlCtxtParseDocument(ctxt, input));
}

View File

@ -1705,7 +1705,7 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
}
/**
* xmlNewInputURL:
* xmlCtxtNewInputFromUrl:
* @ctxt: parser context
* @url: filename or URL
* @publicId: publid ID from doctype (optional)
@ -1718,8 +1718,9 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
* Returns a new parser input.
*/
xmlParserInputPtr
xmlNewInputURL(xmlParserCtxtPtr ctxt, const char *url, const char *publicId,
const char *encoding, int flags ATTRIBUTE_UNUSED) {
xmlCtxtNewInputFromUrl(xmlParserCtxtPtr ctxt, const char *url,
const char *publicId, const char *encoding,
int flags ATTRIBUTE_UNUSED) {
xmlParserInputPtr input;
if ((ctxt == NULL) || (url == NULL))
@ -1811,7 +1812,7 @@ xmlInputCreateMemory(const char *url, const void *mem, size_t size,
}
/**
* xmlNewInputMemory:
* xmlCtxtNewInputFromMemory:
* @ctxt: parser context
* @url: base URL (optional)
* @mem: pointer to char array
@ -1822,9 +1823,9 @@ xmlInputCreateMemory(const char *url, const void *mem, size_t size,
* Returns a new parser input or NULL in case of error.
*/
xmlParserInputPtr
xmlNewInputMemory(xmlParserCtxtPtr ctxt, const char *url,
const void *mem, size_t size,
const char *encoding, int flags) {
xmlCtxtNewInputFromMemory(xmlParserCtxtPtr ctxt, const char *url,
const void *mem, size_t size,
const char *encoding, int flags) {
xmlParserInputPtr input;
if ((ctxt == NULL) || (mem == NULL))
@ -1876,7 +1877,7 @@ xmlInputCreateString(const char *url, const char *str, int flags) {
}
/**
* xmlNewInputString:
* xmlCtxtNewInputFromString:
* @ctxt: parser context
* @url: base URL (optional)
* @str: zero-terminated string
@ -1886,8 +1887,8 @@ xmlInputCreateString(const char *url, const char *str, int flags) {
* Returns a new parser input.
*/
xmlParserInputPtr
xmlNewInputString(xmlParserCtxtPtr ctxt, const char *url,
const char *str, const char *encoding, int flags) {
xmlCtxtNewInputFromString(xmlParserCtxtPtr ctxt, const char *url,
const char *str, const char *encoding, int flags) {
xmlParserInputPtr input;
if ((ctxt == NULL) || (str == NULL))
@ -1937,7 +1938,7 @@ xmlInputCreateFd(const char *url, int fd, int flags ATTRIBUTE_UNUSED) {
}
/**
* xmlNewInputFd:
* xmlCtxtNewInputFromFd:
* @ctxt: parser context
* @url: base URL (optional)
* @fd: file descriptor
@ -1947,8 +1948,8 @@ xmlInputCreateFd(const char *url, int fd, int flags ATTRIBUTE_UNUSED) {
* Returns a new parser input.
*/
xmlParserInputPtr
xmlNewInputFd(xmlParserCtxtPtr ctxt, const char *url,
int fd, const char *encoding, int flags) {
xmlCtxtNewInputFromFd(xmlParserCtxtPtr ctxt, const char *url,
int fd, const char *encoding, int flags) {
xmlParserInputPtr input;
if ((ctxt == NULL) || (fd < 0))
@ -2016,7 +2017,7 @@ xmlInputCreateIO(const char *url, xmlInputReadCallback ioRead,
}
/**
* xmlNewInputIO:
* xmlCtxtNewInputFromIO:
* @ctxt: parser context
* @url: base URL (optional)
* @ioRead: read callback
@ -2028,9 +2029,10 @@ xmlInputCreateIO(const char *url, xmlInputReadCallback ioRead,
* Returns a new parser input.
*/
xmlParserInputPtr
xmlNewInputIO(xmlParserCtxtPtr ctxt, const char *url,
xmlInputReadCallback ioRead, xmlInputCloseCallback ioClose,
void *ioCtxt, const char *encoding, int flags) {
xmlCtxtNewInputFromIO(xmlParserCtxtPtr ctxt, const char *url,
xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose,
void *ioCtxt, const char *encoding, int flags) {
xmlParserInputPtr input;
if ((ctxt == NULL) || (ioRead == NULL))
@ -2139,8 +2141,8 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {
return(NULL);
if (ent->content != NULL) {
input = xmlNewInputString(ctxt, NULL, (const char *) ent->content,
NULL, XML_INPUT_BUF_STATIC);
input = xmlCtxtNewInputFromString(ctxt, NULL,
(const char *) ent->content, NULL, XML_INPUT_BUF_STATIC);
} else if (ent->URI != NULL) {
xmlResourceType rtype;
@ -2176,7 +2178,8 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {
*/
xmlParserInputPtr
xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer) {
return(xmlNewInputString(ctxt, NULL, (const char *) buffer, NULL, 0));
return(xmlCtxtNewInputFromString(ctxt, NULL, (const char *) buffer,
NULL, 0));
}