mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
parser: Move progressive flag into input struct
This commit is contained in:
parent
4f14fe9cf7
commit
6a9a88a17f
18
HTMLparser.c
18
HTMLparser.c
@ -255,13 +255,16 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
|
||||
#define CUR_PTR ctxt->input->cur
|
||||
#define BASE_PTR ctxt->input->base
|
||||
|
||||
#define SHRINK if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
|
||||
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
|
||||
xmlParserShrink(ctxt)
|
||||
#define SHRINK \
|
||||
if ((!PARSER_PROGRESSIVE(ctxt)) && \
|
||||
(ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
|
||||
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
|
||||
xmlParserShrink(ctxt);
|
||||
|
||||
#define GROW if ((ctxt->progressive == 0) && \
|
||||
(ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \
|
||||
xmlParserGrow(ctxt)
|
||||
#define GROW \
|
||||
if ((!PARSER_PROGRESSIVE(ctxt)) && \
|
||||
(ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \
|
||||
xmlParserGrow(ctxt);
|
||||
|
||||
#define SKIP_BLANKS htmlSkipBlankChars(ctxt)
|
||||
|
||||
@ -5867,6 +5870,8 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
inputStream->flags |= XML_INPUT_PROGRESSIVE;
|
||||
|
||||
if (filename == NULL)
|
||||
inputStream->filename = NULL;
|
||||
else
|
||||
@ -5890,7 +5895,6 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
|
||||
xmlHaltParser(ctxt);
|
||||
}
|
||||
}
|
||||
ctxt->progressive = 1;
|
||||
|
||||
if (enc != XML_CHAR_ENCODING_NONE)
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
|
5
SAX2.c
5
SAX2.c
@ -286,7 +286,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
||||
xmlParserInputPtr *oldinputTab;
|
||||
xmlParserInputPtr input = NULL;
|
||||
const xmlChar *oldencoding;
|
||||
int oldprogressive;
|
||||
unsigned long consumed;
|
||||
size_t buffered;
|
||||
|
||||
@ -314,9 +313,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
||||
oldinputMax = ctxt->inputMax;
|
||||
oldinputTab = ctxt->inputTab;
|
||||
oldencoding = ctxt->encoding;
|
||||
oldprogressive = ctxt->progressive;
|
||||
ctxt->encoding = NULL;
|
||||
ctxt->progressive = 0;
|
||||
|
||||
ctxt->inputTab = (xmlParserInputPtr *)
|
||||
xmlMalloc(5 * sizeof(xmlParserInputPtr));
|
||||
@ -328,7 +325,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
||||
ctxt->inputMax = oldinputMax;
|
||||
ctxt->inputTab = oldinputTab;
|
||||
ctxt->encoding = oldencoding;
|
||||
ctxt->progressive = oldprogressive;
|
||||
return;
|
||||
}
|
||||
ctxt->inputNr = 0;
|
||||
@ -382,7 +378,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
||||
(!xmlDictOwns(ctxt->dict, ctxt->encoding))))
|
||||
xmlFree((xmlChar *) ctxt->encoding);
|
||||
ctxt->encoding = oldencoding;
|
||||
ctxt->progressive = oldprogressive;
|
||||
/* ctxt->wellFormed = oldwellFormed; */
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ struct _xmlParserCtxt {
|
||||
int linenumbers; /* set line number in element content */
|
||||
void *catalogs; /* document's own catalog */
|
||||
int recovery; /* run in recovery mode */
|
||||
int progressive; /* is this a progressive parsing */
|
||||
int progressive; /* unused */
|
||||
xmlDictPtr dict; /* dictionary for the parser */
|
||||
const xmlChar * *atts; /* array for the attributes callbacks */
|
||||
int maxatts; /* the size of the array */
|
||||
|
@ -25,9 +25,13 @@
|
||||
#define XML_INPUT_AUTO_OTHER (4u << 1)
|
||||
#define XML_INPUT_USES_ENC_DECL (1u << 4)
|
||||
#define XML_INPUT_ENCODING_ERROR (1u << 5)
|
||||
#define XML_INPUT_PROGRESSIVE (1u << 6)
|
||||
|
||||
#define PARSER_STOPPED(ctxt) ((ctxt)->disableSAX > 1)
|
||||
|
||||
#define PARSER_PROGRESSIVE(ctxt) \
|
||||
((ctxt)->input->flags & XML_INPUT_PROGRESSIVE)
|
||||
|
||||
#define PARSER_IN_PE(ctxt) \
|
||||
(((ctxt)->input->entity != NULL) && \
|
||||
(((ctxt)->input->entity->etype == XML_INTERNAL_PARAMETER_ENTITY) || \
|
||||
|
21
parser.c
21
parser.c
@ -2143,13 +2143,15 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
|
||||
xmlParserGrow(ctxt); \
|
||||
} while (0)
|
||||
|
||||
/* Don't shrink push parser buffer. */
|
||||
#define SHRINK \
|
||||
if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
|
||||
if ((!PARSER_PROGRESSIVE(ctxt)) && \
|
||||
(ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
|
||||
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
|
||||
xmlParserShrink(ctxt);
|
||||
|
||||
#define GROW if (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK) \
|
||||
#define GROW \
|
||||
if ((!PARSER_PROGRESSIVE(ctxt)) && \
|
||||
(ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \
|
||||
xmlParserGrow(ctxt);
|
||||
|
||||
#define SKIP_BLANKS xmlSkipBlankChars(ctxt)
|
||||
@ -7926,7 +7928,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
const xmlChar *oldencoding;
|
||||
xmlChar *content = NULL;
|
||||
size_t length, i;
|
||||
int oldinputNr, oldinputMax, oldprogressive;
|
||||
int oldinputNr, oldinputMax;
|
||||
int ret = -1;
|
||||
int res;
|
||||
|
||||
@ -7952,13 +7954,11 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
oldinputMax = ctxt->inputMax;
|
||||
oldinputTab = ctxt->inputTab;
|
||||
oldencoding = ctxt->encoding;
|
||||
oldprogressive = ctxt->progressive;
|
||||
|
||||
ctxt->input = NULL;
|
||||
ctxt->inputNr = 0;
|
||||
ctxt->inputMax = 1;
|
||||
ctxt->encoding = NULL;
|
||||
ctxt->progressive = 0;
|
||||
ctxt->inputTab = xmlMalloc(sizeof(xmlParserInputPtr));
|
||||
if (ctxt->inputTab == NULL) {
|
||||
xmlErrMemory(ctxt);
|
||||
@ -8039,7 +8039,6 @@ error:
|
||||
ctxt->inputMax = oldinputMax;
|
||||
ctxt->inputTab = oldinputTab;
|
||||
ctxt->encoding = oldencoding;
|
||||
ctxt->progressive = oldprogressive;
|
||||
|
||||
xmlFree(content);
|
||||
|
||||
@ -11784,7 +11783,7 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
|
||||
if (ctxt->input == NULL)
|
||||
return(-1);
|
||||
|
||||
ctxt->progressive = 1;
|
||||
ctxt->input->flags |= XML_INPUT_PROGRESSIVE;
|
||||
if (ctxt->instate == XML_PARSER_START)
|
||||
xmlDetectSAX2(ctxt);
|
||||
if ((size > 0) && (chunk != NULL) && (!terminate) &&
|
||||
@ -11917,6 +11916,8 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
inputStream->flags |= XML_INPUT_PROGRESSIVE;
|
||||
|
||||
if (filename == NULL)
|
||||
inputStream->filename = NULL;
|
||||
else {
|
||||
@ -12258,7 +12259,6 @@ xmlCtxtParseContent(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||
xmlNodePtr oldNode, root = NULL;
|
||||
int oldNameNr, oldSpaceNr, oldNodeNr;
|
||||
int oldWellFormed;
|
||||
int oldProgressive;
|
||||
int oldNodeLen, oldNodeMem;
|
||||
xmlParserNsData *nsdb, *oldNsdb;
|
||||
int ret;
|
||||
@ -12293,7 +12293,6 @@ xmlCtxtParseContent(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||
oldNode = ctxt->node;
|
||||
oldInput = ctxt->input;
|
||||
oldWellFormed = ctxt->wellFormed;
|
||||
oldProgressive = ctxt->progressive;
|
||||
oldNodeLen = ctxt->nodelen;
|
||||
oldNodeMem = ctxt->nodemem;
|
||||
oldNsdb = ctxt->nsdb;
|
||||
@ -12308,7 +12307,6 @@ xmlCtxtParseContent(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||
* ctxt->inputNr > 1 means that we're inside a parameter entity.
|
||||
*/
|
||||
ctxt->input = input;
|
||||
ctxt->progressive = 0;
|
||||
ctxt->nodelen = 0;
|
||||
ctxt->nodemem = 0;
|
||||
ctxt->nsdb = nsdb;
|
||||
@ -12396,7 +12394,6 @@ xmlCtxtParseContent(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||
ctxt->node = oldNode;
|
||||
ctxt->input = oldInput;
|
||||
ctxt->wellFormed = oldWellFormed && ctxt->wellFormed;
|
||||
ctxt->progressive = oldProgressive;
|
||||
ctxt->nodelen = oldNodeLen;
|
||||
ctxt->nodemem = oldNodeMem;
|
||||
ctxt->nsdb = oldNsdb;
|
||||
|
@ -437,7 +437,7 @@ xmlParserGrow(xmlParserCtxtPtr ctxt) {
|
||||
if (buf == NULL)
|
||||
return(0);
|
||||
/* Don't grow push parser buffer. */
|
||||
if ((ctxt->progressive) && (!PARSER_IN_PE(ctxt)))
|
||||
if (PARSER_PROGRESSIVE(ctxt))
|
||||
return(0);
|
||||
/* Don't grow memory buffers. */
|
||||
if ((buf->encoder == NULL) && (buf->readcallback == NULL))
|
||||
@ -529,7 +529,7 @@ xmlParserShrink(xmlParserCtxtPtr ctxt) {
|
||||
if (buf == NULL)
|
||||
return;
|
||||
/* Don't shrink pull parser memory buffers. */
|
||||
if ((ctxt->progressive == 0) &&
|
||||
if ((!PARSER_PROGRESSIVE(ctxt)) &&
|
||||
(buf->encoder == NULL) &&
|
||||
(buf->readcallback == NULL))
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user