diff options
Diffstat (limited to 'parserInternals.c')
-rw-r--r-- | parserInternals.c | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/parserInternals.c b/parserInternals.c index f3fcd6f..9e9e03f 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -1206,50 +1206,13 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, } return (0); - } else { - if ((input->length == 0) || (input->buf == NULL)) { - /* - * When parsing a static memory array one must know the - * size to be able to convert the buffer. - */ - xmlErrInternal(ctxt, "switching encoding : no input\n", NULL); - return (-1); - } else { - int processed; - - /* - * Shrink the current input buffer. - * Move it as the raw buffer and create a new input buffer - */ - processed = input->cur - input->base; - - input->buf->raw = xmlBufferCreate(); - xmlBufferAdd(input->buf->raw, input->cur, - input->length - processed); - input->buf->buffer = xmlBufferCreate(); - - /* - * convert as much as possible of the raw input - * to the parser reading buffer. - */ - nbchars = xmlCharEncInFunc(input->buf->encoder, - input->buf->buffer, - input->buf->raw); - if (nbchars < 0) { - xmlErrInternal(ctxt, - "switching encoding: encoder error\n", - NULL); - return (-1); - } - - /* - * Conversion succeeded, get rid of the old buffer - */ - if ((input->free != NULL) && (input->base != NULL)) - input->free((xmlChar *) input->base); - input->base = input->cur = input->buf->buffer->content; - input->end = &input->base[input->buf->buffer->use]; - } + } else if (input->length == 0) { + /* + * When parsing a static memory array one must know the + * size to be able to convert the buffer. + */ + xmlErrInternal(ctxt, "switching encoding : no input\n", NULL); + return (-1); } return (0); } @@ -1492,8 +1455,13 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { if (ctxt == NULL) return(NULL); buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE); if (buf == NULL) { - __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n", - (const char *) filename); + if (filename == NULL) + __xmlLoaderErr(ctxt, + "failed to load external entity: NULL filename \n", + NULL); + else + __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n", + (const char *) filename); return(NULL); } @@ -1912,7 +1880,7 @@ xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, int found = 0; if ((seq == NULL) || (node == NULL)) - return (-1); + return ((unsigned long) -1); /* Do a binary search for the key */ lower = 1; |