Diff for /embedaddon/libxml2/parserInternals.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2013/07/22 01:22:19 version 1.1.1.3, 2014/06/15 19:53:29
Line 55 Line 55
 #include <libxml/globals.h>  #include <libxml/globals.h>
 #include <libxml/chvalid.h>  #include <libxml/chvalid.h>
   
   #include "buf.h"
   #include "enc.h"
   
 /*  /*
  * Various global defaults for parsing   * Various global defaults for parsing
  */   */
Line 73  xmlCheckVersion(int version) { Line 76  xmlCheckVersion(int version) {
     xmlInitParser();      xmlInitParser();
   
     if ((myversion / 10000) != (version / 10000)) {      if ((myversion / 10000) != (version / 10000)) {
        xmlGenericError(xmlGenericErrorContext,         xmlGenericError(xmlGenericErrorContext,
                 "Fatal: program compiled against libxml %d using libxml %d\n",                  "Fatal: program compiled against libxml %d using libxml %d\n",
                 (version / 10000), (myversion / 10000));                  (version / 10000), (myversion / 10000));
        fprintf(stderr,         fprintf(stderr,
                 "Fatal: program compiled against libxml %d using libxml %d\n",                  "Fatal: program compiled against libxml %d using libxml %d\n",
                 (version / 10000), (myversion / 10000));                  (version / 10000), (myversion / 10000));
     }      }
     if ((myversion / 100) < (version / 100)) {      if ((myversion / 100) < (version / 100)) {
        xmlGenericError(xmlGenericErrorContext,         xmlGenericError(xmlGenericErrorContext,
                 "Warning: program compiled against libxml %d using older %d\n",                  "Warning: program compiled against libxml %d using older %d\n",
                 (version / 100), (myversion / 100));                  (version / 100), (myversion / 100));
     }      }
Line 90  xmlCheckVersion(int version) { Line 93  xmlCheckVersion(int version) {
   
 /************************************************************************  /************************************************************************
  *                                                                      *   *                                                                      *
 *              Some factorized error routines                          * *                Some factorized error routines                          *
  *                                                                      *   *                                                                      *
  ************************************************************************/   ************************************************************************/
   
Line 225  xmlIsLetter(int c) { Line 228  xmlIsLetter(int c) {
   
 /************************************************************************  /************************************************************************
  *                                                                      *   *                                                                      *
 *              Input handling functions for progressive parsing        * *                Input handling functions for progressive parsing        *
  *                                                                      *   *                                                                      *
  ************************************************************************/   ************************************************************************/
   
Line 242  xmlIsLetter(int c) { Line 245  xmlIsLetter(int c) {
   
 static  static
 void check_buffer(xmlParserInputPtr in) {  void check_buffer(xmlParserInputPtr in) {
    if (in->base != in->buf->buffer->content) {    if (in->base != xmlBufContent(in->buf->buffer)) {
         xmlGenericError(xmlGenericErrorContext,          xmlGenericError(xmlGenericErrorContext,
                 "xmlParserInput: base mismatch problem\n");                  "xmlParserInput: base mismatch problem\n");
     }      }
Line 250  void check_buffer(xmlParserInputPtr in) { Line 253  void check_buffer(xmlParserInputPtr in) {
         xmlGenericError(xmlGenericErrorContext,          xmlGenericError(xmlGenericErrorContext,
                 "xmlParserInput: cur < base problem\n");                  "xmlParserInput: cur < base problem\n");
     }      }
    if (in->cur > in->base + in->buf->buffer->use) {    if (in->cur > in->base + xmlBufUse(in->buf->buffer)) {
         xmlGenericError(xmlGenericErrorContext,          xmlGenericError(xmlGenericErrorContext,
                 "xmlParserInput: cur > base + use problem\n");                  "xmlParserInput: cur > base + use problem\n");
     }      }
    xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d, size %d\n",    xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d\n",
            (int) in, (int) in->buf->buffer->content, in->cur - in->base,            (int) in, (int) xmlBufContent(in->buf->buffer), in->cur - in->base,
            in->buf->buffer->use, in->buf->buffer->size);            xmlBufUse(in->buf->buffer));
 }  }
   
 #else  #else
#define CHECK_BUFFER(in) #define CHECK_BUFFER(in)
 #endif  #endif
   
   
Line 269  void check_buffer(xmlParserInputPtr in) { Line 272  void check_buffer(xmlParserInputPtr in) {
  * @in:  an XML parser input   * @in:  an XML parser input
  * @len:  an indicative size for the lookahead   * @len:  an indicative size for the lookahead
  *   *
 * This function refresh the input for the parser. It doesn't try to * This function was internal and is deprecated.
 * preserve pointers to the input buffer, and discard already read data 
  *   *
 * Returns the number of xmlChars read, or -1 in case of error, 0 indicate the * Returns -1 as this is an error to use it.
 * end of this entity 
  */   */
 int  int
xmlParserInputRead(xmlParserInputPtr in, int len) {xmlParserInputRead(xmlParserInputPtr in ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED) {
    int ret;    return(-1);
    int used; 
    int indx; 
 
    if (in == NULL) return(-1); 
#ifdef DEBUG_INPUT 
    xmlGenericError(xmlGenericErrorContext, "Read\n"); 
#endif 
    if (in->buf == NULL) return(-1); 
    if (in->base == NULL) return(-1); 
    if (in->cur == NULL) return(-1); 
    if (in->buf->buffer == NULL) return(-1); 
    if (in->buf->readcallback == NULL) return(-1); 
 
    CHECK_BUFFER(in); 
 
    used = in->cur - in->buf->buffer->content; 
    ret = xmlBufferShrink(in->buf->buffer, used); 
    if (ret > 0) { 
        in->cur -= ret; 
        in->consumed += ret; 
    } 
    ret = xmlParserInputBufferRead(in->buf, len); 
    if (in->base != in->buf->buffer->content) { 
        /* 
         * the buffer has been reallocated 
         */ 
        indx = in->cur - in->base; 
        in->base = in->buf->buffer->content; 
        in->cur = &in->buf->buffer->content[indx]; 
    } 
    in->end = &in->buf->buffer->content[in->buf->buffer->use]; 
 
    CHECK_BUFFER(in); 
 
    return(ret); 
 }  }
   
 /**  /**
Line 323  xmlParserInputRead(xmlParserInputPtr in, int len) { Line 289  xmlParserInputRead(xmlParserInputPtr in, int len) {
  * This function increase the input for the parser. It tries to   * This function increase the input for the parser. It tries to
  * preserve pointers to the input buffer, and keep already read data   * preserve pointers to the input buffer, and keep already read data
  *   *
 * Returns the number of xmlChars read, or -1 in case of error, 0 indicate the * Returns the amount of char read, or -1 in case of error, 0 indicate the
  * end of this entity   * end of this entity
  */   */
 int  int
 xmlParserInputGrow(xmlParserInputPtr in, int len) {  xmlParserInputGrow(xmlParserInputPtr in, int len) {
    int ret;    size_t ret;
    int indx;    size_t indx;
     const xmlChar *content;
   
    if (in == NULL) return(-1);    if ((in == NULL) || (len < 0)) return(-1);
 #ifdef DEBUG_INPUT  #ifdef DEBUG_INPUT
     xmlGenericError(xmlGenericErrorContext, "Grow\n");      xmlGenericError(xmlGenericErrorContext, "Grow\n");
 #endif  #endif
Line 343  xmlParserInputGrow(xmlParserInputPtr in, int len) { Line 310  xmlParserInputGrow(xmlParserInputPtr in, int len) {
     CHECK_BUFFER(in);      CHECK_BUFFER(in);
   
     indx = in->cur - in->base;      indx = in->cur - in->base;
    if (in->buf->buffer->use > (unsigned int) indx + INPUT_CHUNK) {    if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
   
         CHECK_BUFFER(in);          CHECK_BUFFER(in);
   
         return(0);          return(0);
     }      }
    if (in->buf->readcallback != NULL)    if (in->buf->readcallback != NULL) {
         ret = xmlParserInputBufferGrow(in->buf, len);          ret = xmlParserInputBufferGrow(in->buf, len);
    else            } else
         return(0);          return(0);
   
     /*      /*
Line 360  xmlParserInputGrow(xmlParserInputPtr in, int len) { Line 327  xmlParserInputGrow(xmlParserInputPtr in, int len) {
      *        pointer arithmetic. Insure will raise it as a bug but in       *        pointer arithmetic. Insure will raise it as a bug but in
      *        that specific case, that's not !       *        that specific case, that's not !
      */       */
    if (in->base != in->buf->buffer->content) {
     content = xmlBufContent(in->buf->buffer);
     if (in->base != content) {
         /*          /*
          * the buffer has been reallocated           * the buffer has been reallocated
          */           */
         indx = in->cur - in->base;          indx = in->cur - in->base;
        in->base = in->buf->buffer->content;        in->base = content;
        in->cur = &in->buf->buffer->content[indx];        in->cur = &content[indx];
     }      }
    in->end = &in->buf->buffer->content[in->buf->buffer->use];    in->end = xmlBufEnd(in->buf->buffer);
   
     CHECK_BUFFER(in);      CHECK_BUFFER(in);
   
Line 383  xmlParserInputGrow(xmlParserInputPtr in, int len) { Line 352  xmlParserInputGrow(xmlParserInputPtr in, int len) {
  */   */
 void  void
 xmlParserInputShrink(xmlParserInputPtr in) {  xmlParserInputShrink(xmlParserInputPtr in) {
    int used;    size_t used;
    int ret;    size_t ret;
    int indx;    size_t indx;
     const xmlChar *content;
   
 #ifdef DEBUG_INPUT  #ifdef DEBUG_INPUT
     xmlGenericError(xmlGenericErrorContext, "Shrink\n");      xmlGenericError(xmlGenericErrorContext, "Shrink\n");
Line 398  xmlParserInputShrink(xmlParserInputPtr in) { Line 368  xmlParserInputShrink(xmlParserInputPtr in) {
   
     CHECK_BUFFER(in);      CHECK_BUFFER(in);
   
    used = in->cur - in->buf->buffer->content;    used = in->cur - xmlBufContent(in->buf->buffer);
     /*      /*
      * Do not shrink on large buffers whose only a tiny fraction       * Do not shrink on large buffers whose only a tiny fraction
      * was consumed       * was consumed
      */       */
     if (used > INPUT_CHUNK) {      if (used > INPUT_CHUNK) {
        ret = xmlBufferShrink(in->buf->buffer, used - LINE_LEN);        ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
         if (ret > 0) {          if (ret > 0) {
             in->cur -= ret;              in->cur -= ret;
             in->consumed += ret;              in->consumed += ret;
         }          }
        in->end = &in->buf->buffer->content[in->buf->buffer->use];        in->end = xmlBufEnd(in->buf->buffer);
     }      }
   
     CHECK_BUFFER(in);      CHECK_BUFFER(in);
   
    if (in->buf->buffer->use > INPUT_CHUNK) {    if (xmlBufUse(in->buf->buffer) > INPUT_CHUNK) {
         return;          return;
     }      }
     xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);      xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
    if (in->base != in->buf->buffer->content) {    content = xmlBufContent(in->buf->buffer);
     if (in->base != content) {
         /*          /*
          * the buffer has been reallocated           * the buffer has been reallocated
          */           */
         indx = in->cur - in->base;          indx = in->cur - in->base;
        in->base = in->buf->buffer->content;        in->base = content;
        in->cur = &in->buf->buffer->content[indx];        in->cur = &content[indx];
     }      }
    in->end = &in->buf->buffer->content[in->buf->buffer->use];    in->end = xmlBufEnd(in->buf->buffer);
   
     CHECK_BUFFER(in);      CHECK_BUFFER(in);
 }  }
   
 /************************************************************************  /************************************************************************
  *                                                                      *   *                                                                      *
 *              UTF8 character input and related functions              * *                UTF8 character input and related functions              *
  *                                                                      *   *                                                                      *
  ************************************************************************/   ************************************************************************/
   
Line 484  xmlNextChar(xmlParserCtxtPtr ctxt) Line 455  xmlNextChar(xmlParserCtxtPtr ctxt)
              * UCS-4 range (hex.)           UTF-8 octet sequence (binary)               * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
              * 0000 0000-0000 007F   0xxxxxxx               * 0000 0000-0000 007F   0xxxxxxx
              * 0000 0080-0000 07FF   110xxxxx 10xxxxxx               * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
             * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx              * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
              *               *
              * Check for the 0x110000 limit too               * Check for the 0x110000 limit too
              */               */
Line 634  xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) { Line 605  xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
          * UCS-4 range (hex.)           UTF-8 octet sequence (binary)           * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
          * 0000 0000-0000 007F   0xxxxxxx           * 0000 0000-0000 007F   0xxxxxxx
          * 0000 0080-0000 07FF   110xxxxx 10xxxxxx           * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
         * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx          * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
          *           *
          * Check for the 0x110000 limit too           * Check for the 0x110000 limit too
          */           */
Line 695  xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) { Line 666  xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
             if (!IS_CHAR(val)) {              if (!IS_CHAR(val)) {
                 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,                  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
                                   "Char 0x%X out of allowed range\n", val);                                    "Char 0x%X out of allowed range\n", val);
            }                }
             return(val);              return(val);
         } else {          } else {
             /* 1-byte code */              /* 1-byte code */
Line 759  encoding_error: Line 730  encoding_error:
                      "Input is not proper UTF-8, indicate encoding !\n%s",                       "Input is not proper UTF-8, indicate encoding !\n%s",
                      BAD_CAST buffer, NULL);                       BAD_CAST buffer, NULL);
     }      }
    ctxt->charset = XML_CHAR_ENCODING_8859_1;     ctxt->charset = XML_CHAR_ENCODING_8859_1;
     *len = 1;      *len = 1;
     return((int) *ctxt->input->cur);      return((int) *ctxt->input->cur);
 }  }
Line 788  xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlC Line 759  xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlC
          * UCS-4 range (hex.)           UTF-8 octet sequence (binary)           * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
          * 0000 0000-0000 007F   0xxxxxxx           * 0000 0000-0000 007F   0xxxxxxx
          * 0000 0080-0000 07FF   110xxxxx 10xxxxxx           * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
         * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx          * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
          *           *
          * Check for the 0x110000 limit too           * Check for the 0x110000 limit too
          */           */
Line 881  encoding_error: Line 852  encoding_error:
  * @out:  pointer to an array of xmlChar   * @out:  pointer to an array of xmlChar
  * @val:  the char value   * @val:  the char value
  *   *
 * append the char value in the array  * append the char value in the array
  *   *
  * Returns the number of xmlChar written   * Returns the number of xmlChar written
  */   */
Line 895  xmlCopyCharMultiByte(xmlChar *out, int val) { Line 866  xmlCopyCharMultiByte(xmlChar *out, int val) {
      * UCS-4 range (hex.)           UTF-8 octet sequence (binary)       * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
      * 0000 0000-0000 007F   0xxxxxxx       * 0000 0000-0000 007F   0xxxxxxx
      * 0000 0080-0000 07FF   110xxxxx 10xxxxxx       * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
     * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx      * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
      */       */
     if  (val >= 0x80) {      if  (val >= 0x80) {
         xmlChar *savedout = out;          xmlChar *savedout = out;
Line 923  xmlCopyCharMultiByte(xmlChar *out, int val) { Line 894  xmlCopyCharMultiByte(xmlChar *out, int val) {
  * @out:  pointer to an array of xmlChar   * @out:  pointer to an array of xmlChar
  * @val:  the char value   * @val:  the char value
  *   *
 * append the char value in the array  * append the char value in the array
  *   *
  * Returns the number of xmlChar written   * Returns the number of xmlChar written
  */   */
Line 945  xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, in Line 916  xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, in
  *                                                                      *   *                                                                      *
  ************************************************************************/   ************************************************************************/
   
 /* defined in encoding.c, not public */  
 int  
 xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,  
                        xmlBufferPtr in, int len);  
   
 static int  static int
 xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,  xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
                        xmlCharEncodingHandlerPtr handler, int len);                         xmlCharEncodingHandlerPtr handler, int len);
Line 1189  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa Line 1155  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa
         /*          /*
          * Is there already some content down the pipe to convert ?           * Is there already some content down the pipe to convert ?
          */           */
        if ((input->buf->buffer != NULL) && (input->buf->buffer->use > 0)) {        if (xmlBufIsEmpty(input->buf->buffer) == 0) {
             int processed;              int processed;
             unsigned int use;              unsigned int use;
   
             /*              /*
             * Specific handling of the Byte Order Mark for              * Specific handling of the Byte Order Mark for
              * UTF-16               * UTF-16
              */               */
             if ((handler->name != NULL) &&              if ((handler->name != NULL) &&
Line 1225  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa Line 1191  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa
              * Move it as the raw buffer and create a new input buffer               * Move it as the raw buffer and create a new input buffer
              */               */
             processed = input->cur - input->base;              processed = input->cur - input->base;
            xmlBufferShrink(input->buf->buffer, processed);            xmlBufShrink(input->buf->buffer, processed);
             input->buf->raw = input->buf->buffer;              input->buf->raw = input->buf->buffer;
            input->buf->buffer = xmlBufferCreate();            input->buf->buffer = xmlBufCreate();
             input->buf->rawconsumed = processed;              input->buf->rawconsumed = processed;
            use = input->buf->raw->use;            use = xmlBufUse(input->buf->raw);
   
             if (ctxt->html) {              if (ctxt->html) {
                 /*                  /*
                  * convert as much as possible of the buffer                   * convert as much as possible of the buffer
                  */                   */
                nbchars = xmlCharEncInFunc(input->buf->encoder,                nbchars = xmlCharEncInput(input->buf, 1);
                                           input->buf->buffer, 
                                           input->buf->raw); 
             } else {              } else {
                 /*                  /*
                  * convert just enough to get                   * convert just enough to get
Line 1245  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa Line 1209  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa
                  * parsed with the autodetected encoding                   * parsed with the autodetected encoding
                  * into the parser reading buffer.                   * into the parser reading buffer.
                  */                   */
                nbchars = xmlCharEncFirstLineInt(input->buf->encoder,                nbchars = xmlCharEncFirstLineInput(input->buf, len);
                                                 input->buf->buffer, 
                                                 input->buf->raw, 
                                                 len); 
             }              }
             if (nbchars < 0) {              if (nbchars < 0) {
                 xmlErrInternal(ctxt,                  xmlErrInternal(ctxt,
Line 1256  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa Line 1217  xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlPa
                                NULL);                                 NULL);
                 return (-1);                  return (-1);
             }              }
            input->buf->rawconsumed += use - input->buf->raw->use;            input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
            input->base = input->cur = input->buf->buffer->content;            xmlBufResetInput(input->buf->buffer, input);
            input->end = &input->base[input->buf->buffer->use]; 
 
         }          }
         return (0);          return (0);
     } else if (input->length == 0) {      } else if (input->length == 0) {
Line 1294  xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParse Line 1253  xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParse
  * xmlSwitchToEncodingInt:   * xmlSwitchToEncodingInt:
  * @ctxt:  the parser context   * @ctxt:  the parser context
  * @handler:  the encoding handler   * @handler:  the encoding handler
 * @len: the lenght to convert or -1 * @len: the length to convert or -1
  *   *
  * change the input functions when discovering the character encoding   * change the input functions when discovering the character encoding
  * of a given entity, and convert only @len bytes of the output, this   * of a given entity, and convert only @len bytes of the output, this
Line 1336  xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt, Line 1295  xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
  * Returns 0 in case of success, -1 otherwise   * Returns 0 in case of success, -1 otherwise
  */   */
 int  int
xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler) xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
 {  {
     return (xmlSwitchToEncodingInt(ctxt, handler, -1));      return (xmlSwitchToEncodingInt(ctxt, handler, -1));
 }  }
Line 1363  xmlFreeInputStream(xmlParserInputPtr input) { Line 1322  xmlFreeInputStream(xmlParserInputPtr input) {
     if (input->version != NULL) xmlFree((char *) input->version);      if (input->version != NULL) xmlFree((char *) input->version);
     if ((input->free != NULL) && (input->base != NULL))      if ((input->free != NULL) && (input->base != NULL))
         input->free((xmlChar *) input->base);          input->free((xmlChar *) input->base);
    if (input->buf != NULL)     if (input->buf != NULL)
         xmlFreeParserInputBuffer(input->buf);          xmlFreeParserInputBuffer(input->buf);
     xmlFree(input);      xmlFree(input);
 }  }
Line 1426  xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserIn Line 1385  xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserIn
     }      }
     inputStream->filename = NULL;      inputStream->filename = NULL;
     inputStream->buf = input;      inputStream->buf = input;
    inputStream->base = inputStream->buf->buffer->content;    xmlBufResetInput(inputStream->buf->buffer, inputStream);
    inputStream->cur = inputStream->buf->buffer->content;
    inputStream->end = &inputStream->base[inputStream->buf->buffer->use]; 
     if (enc != XML_CHAR_ENCODING_NONE) {      if (enc != XML_CHAR_ENCODING_NONE) {
         xmlSwitchEncoding(ctxt, enc);          xmlSwitchEncoding(ctxt, enc);
     }      }
Line 1570  xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char  Line 1528  xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char 
     inputStream = xmlCheckHTTPInput(ctxt, inputStream);      inputStream = xmlCheckHTTPInput(ctxt, inputStream);
     if (inputStream == NULL)      if (inputStream == NULL)
         return(NULL);          return(NULL);
    
     if (inputStream->filename == NULL)      if (inputStream->filename == NULL)
         URI = xmlStrdup((xmlChar *) filename);          URI = xmlStrdup((xmlChar *) filename);
     else      else
Line 1581  xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char  Line 1539  xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char 
     if (URI != NULL) xmlFree((char *) URI);      if (URI != NULL) xmlFree((char *) URI);
     inputStream->directory = directory;      inputStream->directory = directory;
   
    inputStream->base = inputStream->buf->buffer->content;    xmlBufResetInput(inputStream->buf->buffer, inputStream);
    inputStream->cur = inputStream->buf->buffer->content; 
    inputStream->end = &inputStream->base[inputStream->buf->buffer->use]; 
     if ((ctxt->directory == NULL) && (directory != NULL))      if ((ctxt->directory == NULL) && (directory != NULL))
         ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);          ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
     return(inputStream);      return(inputStream);
Line 1622  xmlInitParserCtxt(xmlParserCtxtPtr ctxt) Line 1578  xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
         xmlErrMemory(NULL, "cannot initialize parser context\n");          xmlErrMemory(NULL, "cannot initialize parser context\n");
         return(-1);          return(-1);
     }      }
       xmlDictSetLimit(ctxt->dict, XML_MAX_DICTIONARY_LIMIT);
   
     if (ctxt->sax == NULL)      if (ctxt->sax == NULL)
         ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));          ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
     if (ctxt->sax == NULL) {      if (ctxt->sax == NULL) {
Line 1761  xmlInitParserCtxt(xmlParserCtxtPtr ctxt) Line 1719  xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
     ctxt->charset = XML_CHAR_ENCODING_UTF8;      ctxt->charset = XML_CHAR_ENCODING_UTF8;
     ctxt->catalogs = NULL;      ctxt->catalogs = NULL;
     ctxt->nbentities = 0;      ctxt->nbentities = 0;
       ctxt->sizeentities = 0;
       ctxt->sizeentcopy = 0;
     ctxt->input_id = 1;      ctxt->input_id = 1;
     xmlInitNodeInfoSeq(&ctxt->node_seq);      xmlInitNodeInfoSeq(&ctxt->node_seq);
     return(0);      return(0);
Line 1807  xmlFreeParserCtxt(xmlParserCtxtPtr ctxt) Line 1767  xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
     if (ctxt->nsTab != NULL) xmlFree((char *) ctxt->nsTab);      if (ctxt->nsTab != NULL) xmlFree((char *) ctxt->nsTab);
     if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);      if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);
     if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);      if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);
    if (ctxt->attsDefault != NULL)     if (ctxt->attsDefault != NULL)
         xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree);          xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree);
     if (ctxt->attsSpecial != NULL)      if (ctxt->attsSpecial != NULL)
         xmlHashFree(ctxt->attsSpecial, NULL);          xmlHashFree(ctxt->attsSpecial, NULL);
Line 1907  xmlClearParserCtxt(xmlParserCtxtPtr ctxt) Line 1867  xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
  * @node:  an XML node within the tree   * @node:  an XML node within the tree
  *   *
  * Find the parser node info struct for a given node   * Find the parser node info struct for a given node
 *  *
  * Returns an xmlParserNodeInfo block pointer or NULL   * Returns an xmlParserNodeInfo block pointer or NULL
  */   */
 const xmlParserNodeInfo *  const xmlParserNodeInfo *
Line 1965  xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq) Line 1925  xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
  * @seq:  a node info sequence pointer   * @seq:  a node info sequence pointer
  * @node:  an XML node pointer   * @node:  an XML node pointer
  *   *
 *  *
  * xmlParserFindNodeInfoIndex : Find the index that the info record for   * xmlParserFindNodeInfoIndex : Find the index that the info record for
  *   the given node is or should be at in a sorted sequence   *   the given node is or should be at in a sorted sequence
  *   *
Line 2022  xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt, Line 1982  xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
     pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr)      pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr)
                                      info->node);                                       info->node);
   
    if ((pos < ctxt->node_seq.length) &&     if ((pos < ctxt->node_seq.length) &&
         (ctxt->node_seq.buffer != NULL) &&          (ctxt->node_seq.buffer != NULL) &&
         (ctxt->node_seq.buffer[pos].node == info->node)) {          (ctxt->node_seq.buffer[pos].node == info->node)) {
         ctxt->node_seq.buffer[pos] = *info;          ctxt->node_seq.buffer[pos] = *info;
Line 2075  xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt, Line 2035  xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
  ************************************************************************/   ************************************************************************/
 /**  /**
  * xmlPedanticParserDefault:   * xmlPedanticParserDefault:
 * @val:  int 0 or 1  * @val:  int 0 or 1
  *   *
  * Set and return the previous value for enabling pedantic warnings.   * Set and return the previous value for enabling pedantic warnings.
  *   *
Line 2092  xmlPedanticParserDefault(int val) { Line 2052  xmlPedanticParserDefault(int val) {
   
 /**  /**
  * xmlLineNumbersDefault:   * xmlLineNumbersDefault:
 * @val:  int 0 or 1  * @val:  int 0 or 1
  *   *
  * Set and return the previous value for enabling line numbers in elements   * Set and return the previous value for enabling line numbers in elements
  * contents. This may break on old application and is turned off by default.   * contents. This may break on old application and is turned off by default.
Line 2110  xmlLineNumbersDefault(int val) { Line 2070  xmlLineNumbersDefault(int val) {
   
 /**  /**
  * xmlSubstituteEntitiesDefault:   * xmlSubstituteEntitiesDefault:
 * @val:  int 0 or 1  * @val:  int 0 or 1
  *   *
  * Set and return the previous value for default entity support.   * Set and return the previous value for default entity support.
  * Initially the parser always keep entity references instead of substituting   * Initially the parser always keep entity references instead of substituting
Line 2132  xmlSubstituteEntitiesDefault(int val) { Line 2092  xmlSubstituteEntitiesDefault(int val) {
   
 /**  /**
  * xmlKeepBlanksDefault:   * xmlKeepBlanksDefault:
 * @val:  int 0 or 1  * @val:  int 0 or 1
  *   *
  * Set and return the previous value for default blanks text nodes support.   * Set and return the previous value for default blanks text nodes support.
  * The 1.x version of the parser used an heuristic to try to detect   * The 1.x version of the parser used an heuristic to try to detect
Line 2143  xmlSubstituteEntitiesDefault(int val) { Line 2103  xmlSubstituteEntitiesDefault(int val) {
  * ignorableWhitespace() are only generated when running the parser in   * ignorableWhitespace() are only generated when running the parser in
  * validating mode and when the current element doesn't allow CDATA or   * validating mode and when the current element doesn't allow CDATA or
  * mixed content.   * mixed content.
 * This function is provided as a way to force the standard behavior  * This function is provided as a way to force the standard behavior
  * on 1.X libs and to switch back to the old mode for compatibility when   * on 1.X libs and to switch back to the old mode for compatibility when
  * running 1.X client code on 2.X . Upgrade of 1.X code should be done   * running 1.X client code on 2.X . Upgrade of 1.X code should be done
  * by using xmlIsBlankNode() commodity function to detect the "empty"   * by using xmlIsBlankNode() commodity function to detect the "empty"

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>