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
diff --git a/HTMLparser.c b/HTMLparser.c
index fdbef80..63befed 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -5975,8 +5975,8 @@
}
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 @@
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 @@
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