1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

Cleanup function xmlBufResetInput() to set input from Buffer

This was scattered in a number of modules, xmlParserInputPtr
have usually their base, cur and end pointer set from an
xmlBuf used as input.
* buf.c buf.h: add a new function implementing this setup
* parser.c HTMLparser.c catalog.c parserInternals.c xmlreader.c
  use the new function instead of digging into the buffer in
  all those modules
This commit is contained in:
Daniel Veillard
2012-07-16 16:28:47 +08:00
parent 145477d8ab
commit 61551a1eb7
7 changed files with 31 additions and 34 deletions

View File

@@ -1218,9 +1218,7 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
return (-1);
}
input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
input->base = input->cur = xmlBufContent(input->buf->buffer);
input->end = xmlBufEnd(input->buf->buffer);
xmlBufResetInput(input->buf->buffer, input);
}
return (0);
} else if (input->length == 0) {
@@ -1387,9 +1385,8 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
}
inputStream->filename = NULL;
inputStream->buf = input;
inputStream->cur =
inputStream->base = xmlBufContent(inputStream->buf->buffer);
inputStream->end = xmlBufEnd(inputStream->buf->buffer);
xmlBufResetInput(inputStream->buf->buffer, inputStream);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
@@ -1542,9 +1539,7 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
if (URI != NULL) xmlFree((char *) URI);
inputStream->directory = directory;
inputStream->base =
inputStream->cur = xmlBufContent(inputStream->buf->buffer);
inputStream->end = xmlBufEnd(inputStream->buf->buffer);
xmlBufResetInput(inputStream->buf->buffer, inputStream);
if ((ctxt->directory == NULL) && (directory != NULL))
ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
return(inputStream);