diff options
author | Daniel Veillard <veillard@redhat.com> | 2012-07-16 18:03:01 +0800 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2012-07-23 14:24:27 +0800 |
commit | 00ac0d3b96459865684fc9378e420e93418f9ef9 (patch) | |
tree | 1047ae1acaf6c5326db65a0358383153ad883a39 /HTMLparser.c | |
parent | 61551a1eb75bacb32e5209635c0f3459595af54a (diff) | |
download | android_external_libxml2-00ac0d3b96459865684fc9378e420e93418f9ef9.tar.gz android_external_libxml2-00ac0d3b96459865684fc9378e420e93418f9ef9.tar.bz2 android_external_libxml2-00ac0d3b96459865684fc9378e420e93418f9ef9.zip |
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
Diffstat (limited to 'HTMLparser.c')
-rw-r--r-- | HTMLparser.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/HTMLparser.c b/HTMLparser.c index fdbef805..63befed9 100644 --- a/HTMLparser.c +++ b/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 |