mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
More cleanups for input/buffers code
When calling xmlParserInputBufferPush, the buffer may be reallocated and at the input level the pointers for base, cur and end need to be reevaluated. * buf.c buf.h: add two new functions, one to get the base from the input of the buffer, and another one to reset the pointers based on the cur and base inded * HTMLparser.c parser.c: cleanup to use the new helper functions as well as making sure size_t is used for the indexes computations
This commit is contained in:
16
HTMLparser.c
16
HTMLparser.c
@@ -5975,8 +5975,8 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
|
||||
}
|
||||
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
|
||||
(ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) {
|
||||
int base = ctxt->input->base - xmlBufContent(ctxt->input->buf->buffer);
|
||||
int cur = ctxt->input->cur - ctxt->input->base;
|
||||
size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
|
||||
size_t cur = ctxt->input->cur - ctxt->input->base;
|
||||
int res;
|
||||
|
||||
res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
||||
@@ -5985,9 +5985,7 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
|
||||
ctxt->disableSAX = 1;
|
||||
return (XML_PARSER_EOF);
|
||||
}
|
||||
ctxt->input->base = xmlBufContent(ctxt->input->buf->buffer) + base;
|
||||
ctxt->input->cur = ctxt->input->base + cur;
|
||||
ctxt->input->end = xmlBufEnd(ctxt->input->buf->buffer);
|
||||
xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
|
||||
#ifdef DEBUG_PUSH
|
||||
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
||||
#endif
|
||||
@@ -6108,14 +6106,12 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
|
||||
|
||||
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
|
||||
(ctxt->input->buf != NULL)) {
|
||||
int base = ctxt->input->base - xmlBufContent(ctxt->input->buf->buffer);
|
||||
int cur = ctxt->input->cur - ctxt->input->base;
|
||||
size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
|
||||
size_t cur = ctxt->input->cur - ctxt->input->base;
|
||||
|
||||
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
||||
|
||||
ctxt->input->base = xmlBufContent(ctxt->input->buf->buffer) + base;
|
||||
ctxt->input->cur = ctxt->input->base + cur;
|
||||
ctxt->input->end = xmlBufEnd(ctxt->input->buf->buffer);
|
||||
xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
|
||||
#ifdef DEBUG_PUSH
|
||||
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user