1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-25 10:50:08 +03:00

parser: Rename inputPush to xmlCtxtPushInput

This commit is contained in:
Nick Wellnhofer 2024-11-17 20:13:14 +01:00
parent e2ad249c23
commit 0f4f89005d
9 changed files with 80 additions and 45 deletions

View File

@ -4293,7 +4293,7 @@ htmlCtxtParseContentInternal(htmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
htmlnamePop(ctxt);
/* xmlPopInput would free the stream */
inputPop(ctxt);
xmlCtxtPopInput(ctxt);
xmlFreeNode(root);
return(list);
@ -4606,7 +4606,7 @@ htmlCreateMemoryParserCtxtInternal(const char *url,
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -4664,7 +4664,7 @@ htmlCreateDocParserCtxt(const xmlChar *str, const char *url,
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -5301,7 +5301,7 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -5411,7 +5411,7 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
xmlFreeParserCtxt(ctxt);
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -5596,7 +5596,7 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
dict = ctxt->dict;
while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
while ((input = xmlCtxtPopInput(ctxt)) != NULL) { /* Non consuming */
xmlFreeInputStream(input);
}
ctxt->inputNr = 0;
@ -5892,9 +5892,9 @@ htmlCtxtParseDocument(htmlParserCtxtPtr ctxt, xmlParserInputPtr input)
/* assert(ctxt->inputNr == 0); */
while (ctxt->inputNr > 0)
xmlFreeInputStream(inputPop(ctxt));
xmlFreeInputStream(xmlCtxtPopInput(ctxt));
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
return(NULL);
}
@ -5912,7 +5912,7 @@ htmlCtxtParseDocument(htmlParserCtxtPtr ctxt, xmlParserInputPtr input)
/* assert(ctxt->inputNr == 1); */
while (ctxt->inputNr > 0)
xmlFreeInputStream(inputPop(ctxt));
xmlFreeInputStream(xmlCtxtPopInput(ctxt));
return(ret);
}

View File

@ -897,7 +897,7 @@ xmlParseCatalogFile(const char *filename) {
inputStream->buf = buf;
xmlBufResetInput(buf->buffer, inputStream);
if (inputPush(ctxt, inputStream) < 0) {
if (xmlCtxtPushInput(ctxt, inputStream) < 0) {
xmlFreeInputStream(inputStream);
xmlFreeParserCtxt(ctxt);
return(NULL);

View File

@ -343,6 +343,11 @@ XML_DEPRECATED
XMLPUBFUN xmlParserInputPtr
xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
xmlEntityPtr entity);
XMLPUBFUN int
xmlCtxtPushInput (xmlParserCtxtPtr ctxt,
xmlParserInputPtr input);
XMLPUBFUN xmlParserInputPtr
xmlCtxtPopInput (xmlParserCtxtPtr ctxt);
XML_DEPRECATED
XMLPUBFUN int
xmlPushInput (xmlParserCtxtPtr ctxt,

View File

@ -1931,7 +1931,7 @@ mem_error:
}
/**
* inputPush:
* xmlCtxtPushInput:
* @ctxt: an XML parser context
* @value: the parser input
*
@ -1940,13 +1940,22 @@ mem_error:
* Returns -1 in case of error, the index in the stack otherwise
*/
int
inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
xmlCtxtPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
{
char *directory = NULL;
int maxDepth;
if ((ctxt == NULL) || (value == NULL))
return(-1);
maxDepth = (ctxt->options & XML_PARSE_HUGE) ? 40 : 20;
if (ctxt->inputNr > maxDepth) {
xmlFatalErrMsg(ctxt, XML_ERR_RESOURCE_LIMIT,
"Maximum entity nesting depth exceeded");
xmlHaltParser(ctxt);
return(-1);
}
if (ctxt->inputNr >= ctxt->inputMax) {
size_t newSize = ctxt->inputMax * 2;
xmlParserInputPtr *tmp;
@ -1991,8 +2000,9 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
return(ctxt->inputNr++);
}
/**
* inputPop:
* xmlCtxtPopInput:
* @ctxt: an XML parser context
*
* Pops the top parser input from the input stack
@ -2000,7 +2010,7 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
* Returns the input just removed
*/
xmlParserInputPtr
inputPop(xmlParserCtxtPtr ctxt)
xmlCtxtPopInput(xmlParserCtxtPtr ctxt)
{
xmlParserInputPtr ret;
@ -2017,6 +2027,34 @@ inputPop(xmlParserCtxtPtr ctxt)
ctxt->inputTab[ctxt->inputNr] = NULL;
return (ret);
}
/**
* inputPush:
* @ctxt: an XML parser context
* @value: the parser input
*
* Pushes a new parser input on top of the input stack
*
* Returns -1 in case of error, the index in the stack otherwise
*/
int
inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
{
return(xmlCtxtPushInput(ctxt, value));
}
/**
* inputPop:
* @ctxt: an XML parser context
*
* Pops the top parser input from the input stack
*
* Returns the input just removed
*/
xmlParserInputPtr
inputPop(xmlParserCtxtPtr ctxt)
{
return(xmlCtxtPopInput(ctxt));
}
/**
* nodePush:
* @ctxt: an XML parser context
@ -2561,7 +2599,7 @@ xmlPopInput(xmlParserCtxtPtr ctxt) {
xmlParserInputPtr input;
if ((ctxt == NULL) || (ctxt->inputNr <= 1)) return(0);
input = inputPop(ctxt);
input = xmlCtxtPopInput(ctxt);
xmlFreeInputStream(input);
if (*ctxt->input->cur == 0)
xmlParserGrow(ctxt);
@ -2581,20 +2619,12 @@ xmlPopInput(xmlParserCtxtPtr ctxt) {
*/
int
xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
int maxDepth;
int ret;
if ((ctxt == NULL) || (input == NULL))
return(-1);
maxDepth = (ctxt->options & XML_PARSE_HUGE) ? 40 : 20;
if (ctxt->inputNr > maxDepth) {
xmlFatalErrMsg(ctxt, XML_ERR_RESOURCE_LIMIT,
"Maximum entity nesting depth exceeded");
xmlHaltParser(ctxt);
return(-1);
}
ret = inputPush(ctxt, input);
ret = xmlCtxtPushInput(ctxt, input);
if (ret >= 0)
GROW;
return(ret);
@ -7984,7 +8014,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
xmlBufResetInput(input->buf->buffer, input);
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
goto error;
}
@ -8053,7 +8083,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
error:
while (ctxt->inputNr > 0)
xmlFreeInputStream(inputPop(ctxt));
xmlFreeInputStream(xmlCtxtPopInput(ctxt));
xmlFree(ctxt->inputTab);
xmlFree((xmlChar *) ctxt->encoding);
@ -11650,7 +11680,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
xmlFreeParserCtxt(ctxt);
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -11709,7 +11739,7 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
xmlFreeParserCtxt(ctxt);
return (NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -12019,7 +12049,7 @@ xmlCtxtParseContentInternal(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
spacePop(ctxt);
/* xmlPopInput would free the stream */
inputPop(ctxt);
xmlCtxtPopInput(ctxt);
error:
xmlFreeNode(root);
@ -12672,7 +12702,7 @@ xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID,
if (input == NULL)
goto error;
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
goto error;
}
@ -12723,7 +12753,7 @@ xmlCreateURLParserCtxt(const char *filename, int options)
xmlFreeParserCtxt(ctxt);
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -12908,7 +12938,7 @@ xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const xmlChar* buffer,
NULL, 0);
if (input == NULL)
return;
if (inputPush(ctxt, input) < 0)
if (xmlCtxtPushInput(ctxt, input) < 0)
xmlFreeInputStream(input);
}
@ -12996,7 +13026,7 @@ xmlCreateMemoryParserCtxt(const char *buffer, int size) {
xmlFreeParserCtxt(ctxt);
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -13186,7 +13216,7 @@ xmlCreateDocParserCtxt(const xmlChar *str) {
xmlFreeParserCtxt(ctxt);
return(NULL);
}
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -13295,7 +13325,7 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
dict = ctxt->dict;
while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
while ((input = xmlCtxtPopInput(ctxt)) != NULL) { /* Non consuming */
xmlFreeInputStream(input);
}
ctxt->inputNr = 0;
@ -13404,7 +13434,7 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
if (input == NULL)
return(1);
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
return(1);
}
@ -13796,9 +13826,9 @@ xmlCtxtParseDocument(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
/* assert(ctxt->inputNr == 0); */
while (ctxt->inputNr > 0)
xmlFreeInputStream(inputPop(ctxt));
xmlFreeInputStream(xmlCtxtPopInput(ctxt));
if (inputPush(ctxt, input) < 0) {
if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
return(NULL);
}
@ -13819,7 +13849,7 @@ xmlCtxtParseDocument(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
/* assert(ctxt->inputNr == 1); */
while (ctxt->inputNr > 0)
xmlFreeInputStream(inputPop(ctxt));
xmlFreeInputStream(xmlCtxtPopInput(ctxt));
return(ret);
}

View File

@ -2755,7 +2755,7 @@ xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, const xmlSAXHandler *sax,
}
if (ctxt->inputTab == NULL)
return(-1);
while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
while ((input = xmlCtxtPopInput(ctxt)) != NULL) { /* Non consuming */
xmlFreeInputStream(input);
}
ctxt->inputNr = 0;
@ -2896,7 +2896,7 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if (ctxt == NULL) return;
while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
while ((input = xmlCtxtPopInput(ctxt)) != NULL) { /* Non consuming */
xmlFreeInputStream(input);
}
if (ctxt->spaceTab != NULL) xmlFree(ctxt->spaceTab);

View File

@ -667,7 +667,7 @@ static int testCharRanges(void) {
input->cur =
input->base = xmlBufContent(input->buf->buffer);
input->end = input->base + 4;
inputPush(ctxt, input);
xmlCtxtPushInput(ctxt, input);
printf("testing char range: 1");
fflush(stdout);

View File

@ -351,7 +351,7 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
if (inputStream == NULL)
goto error;
if (inputPush(pctxt, inputStream) < 0) {
if (xmlCtxtPushInput(pctxt, inputStream) < 0) {
xmlFreeInputStream(inputStream);
goto error;
}

View File

@ -4919,7 +4919,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
inputStream->buf = buf;
xmlBufResetInput(buf->buffer, inputStream);
if (inputPush(reader->ctxt, inputStream) < 0) {
if (xmlCtxtPushInput(reader->ctxt, inputStream) < 0) {
xmlFreeInputStream(inputStream);
return(-1);
}

View File

@ -28806,7 +28806,7 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
ret = -1;
goto done;
}
if (inputPush(pctxt, inputStream) < 0) {
if (xmlCtxtPushInput(pctxt, inputStream) < 0) {
xmlFreeInputStream(inputStream);
ret = -1;
goto done;