Diff for /embedaddon/libxml2/parser.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:37:57 version 1.1.1.2, 2013/07/22 01:22:20
Line 79 Line 79
 #ifdef HAVE_ZLIB_H  #ifdef HAVE_ZLIB_H
 #include <zlib.h>  #include <zlib.h>
 #endif  #endif
   #ifdef HAVE_LZMA_H
   #include <lzma.h>
   #endif
   
 static void  static void
 xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);  xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);
Line 197  unsigned int xmlParserMaxDepth = 256; Line 200  unsigned int xmlParserMaxDepth = 256;
   
 static const char *xmlW3CPIs[] = {  static const char *xmlW3CPIs[] = {
     "xml-stylesheet",      "xml-stylesheet",
       "xml-model",
     NULL      NULL
 };  };
   
Line 731  xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, Line 735  xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
  * @info1:  extra information string   * @info1:  extra information string
  * @info2:  extra information string   * @info2:  extra information string
  *   *
 * Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a namespace warning error
  */   */
 static void  static void
 xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error,  xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error,
Line 954  xmlHasFeature(xmlFeature feature) Line 958  xmlHasFeature(xmlFeature feature)
 #else  #else
             return(0);              return(0);
 #endif  #endif
           case XML_WITH_LZMA:
   #ifdef LIBXML_LZMA_ENABLED
               return(1);
   #else
               return(0);
   #endif
         case XML_WITH_ICU:          case XML_WITH_ICU:
 #ifdef LIBXML_ICU_ENABLED  #ifdef LIBXML_ICU_ENABLED
             return(1);              return(1);
Line 1819  namePush(xmlParserCtxtPtr ctxt, const xmlChar * value) Line 1829  namePush(xmlParserCtxtPtr ctxt, const xmlChar * value)
   
     if (ctxt->nameNr >= ctxt->nameMax) {      if (ctxt->nameNr >= ctxt->nameMax) {
         const xmlChar * *tmp;          const xmlChar * *tmp;
         ctxt->nameMax *= 2;  
         tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,          tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
                                    ctxt->nameMax *                                    ctxt->nameMax * 2 *
                                     sizeof(ctxt->nameTab[0]));                                      sizeof(ctxt->nameTab[0]));
         if (tmp == NULL) {          if (tmp == NULL) {
             ctxt->nameMax /= 2;  
             goto mem_error;              goto mem_error;
         }          }
         ctxt->nameTab = tmp;          ctxt->nameTab = tmp;
           ctxt->nameMax *= 2;
     }      }
     ctxt->nameTab[ctxt->nameNr] = value;      ctxt->nameTab[ctxt->nameNr] = value;
     ctxt->name = value;      ctxt->name = value;
Line 2709  xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, cons Line 2718  xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, cons
   
                 buffer[nbchars++] = '&';                  buffer[nbchars++] = '&';
                 if (nbchars > buffer_size - i - XML_PARSER_BUFFER_SIZE) {                  if (nbchars > buffer_size - i - XML_PARSER_BUFFER_SIZE) {
                    growBuffer(buffer, XML_PARSER_BUFFER_SIZE);                    growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE);
                 }                  }
                 for (;i > 0;i--)                  for (;i > 0;i--)
                     buffer[nbchars++] = *cur++;                      buffer[nbchars++] = *cur++;
Line 4769  get_more: Line 4778  get_more:
                     ctxt->instate = state;                      ctxt->instate = state;
                     return;                      return;
                 }                  }
                if (buf != NULL)                if (buf != NULL) {
                    xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,                    xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
                                      "Comment not terminated \n<!--%.50s\n",                                      "Double hyphen within comment: "
                                       "<!--%.50s\n",
                                       buf);                                        buf);
                else                } else
                    xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,                    xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
                                      "Comment not terminated \n", NULL);                                      "Double hyphen within comment\n", NULL);
                 in++;                  in++;
                 ctxt->input->col++;                  ctxt->input->col++;
             }              }
Line 4949  xmlParsePI(xmlParserCtxtPtr ctxt) { Line 4959  xmlParsePI(xmlParserCtxtPtr ctxt) {
                     (ctxt->sax->processingInstruction != NULL))                      (ctxt->sax->processingInstruction != NULL))
                     ctxt->sax->processingInstruction(ctxt->userData,                      ctxt->sax->processingInstruction(ctxt->userData,
                                                      target, NULL);                                                       target, NULL);
                ctxt->instate = state;                if (ctxt->instate != XML_PARSER_EOF)
                     ctxt->instate = state;
                 return;                  return;
             }              }
             buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));              buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
Line 5029  xmlParsePI(xmlParserCtxtPtr ctxt) { Line 5040  xmlParsePI(xmlParserCtxtPtr ctxt) {
         } else {          } else {
             xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL);              xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL);
         }          }
        ctxt->instate = state;        if (ctxt->instate != XML_PARSER_EOF)
             ctxt->instate = state;
     }      }
 }  }
   
Line 6992  xmlParseReference(xmlParserCtxtPtr ctxt) { Line 7004  xmlParseReference(xmlParserCtxtPtr ctxt) {
                     ent->owner = 1;                      ent->owner = 1;
                     while (list != NULL) {                      while (list != NULL) {
                         list->parent = (xmlNodePtr) ent;                          list->parent = (xmlNodePtr) ent;
                           xmlSetTreeDoc(list, ent->doc);
                         if (list->next == NULL)                          if (list->next == NULL)
                             ent->last = list;                              ent->last = list;
                         list = list->next;                          list = list->next;
Line 9552  xmlParseElement(xmlParserCtxtPtr ctxt) { Line 9565  xmlParseElement(xmlParserCtxtPtr ctxt) {
     const xmlChar *prefix = NULL;      const xmlChar *prefix = NULL;
     const xmlChar *URI = NULL;      const xmlChar *URI = NULL;
     xmlParserNodeInfo node_info;      xmlParserNodeInfo node_info;
    int line, tlen;    int line, tlen = 0;
     xmlNodePtr ret;      xmlNodePtr ret;
     int nsNr = ctxt->nsNr;      int nsNr = ctxt->nsNr;
   
Line 9588  xmlParseElement(xmlParserCtxtPtr ctxt) { Line 9601  xmlParseElement(xmlParserCtxtPtr ctxt) {
     else      else
         name = xmlParseStartTag(ctxt);          name = xmlParseStartTag(ctxt);
 #endif /* LIBXML_SAX1_ENABLED */  #endif /* LIBXML_SAX1_ENABLED */
       if (ctxt->instate == XML_PARSER_EOF)
           return;
     if (name == NULL) {      if (name == NULL) {
         spacePop(ctxt);          spacePop(ctxt);
         return;          return;
Line 9921  xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) { Line 9936  xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
         } else {          } else {
             xmlFatalErr(ctxt, XML_ERR_STRING_NOT_STARTED, NULL);              xmlFatalErr(ctxt, XML_ERR_STRING_NOT_STARTED, NULL);
         }          }
   
           /*
            * Non standard parsing, allowing the user to ignore encoding
            */
           if (ctxt->options & XML_PARSE_IGNORE_ENC)
               return(encoding);
   
         /*          /*
          * UTF-16 encoding stwich has already taken place at this stage,           * UTF-16 encoding stwich has already taken place at this stage,
          * more over the little-endian/big-endian selection is already done           * more over the little-endian/big-endian selection is already done
Line 10967  xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int termina Line 10989  xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int termina
                 else                  else
                     name = xmlParseStartTag(ctxt);                      name = xmlParseStartTag(ctxt);
 #endif /* LIBXML_SAX1_ENABLED */  #endif /* LIBXML_SAX1_ENABLED */
                   if (ctxt->instate == XML_PARSER_EOF)
                       goto done;
                 if (name == NULL) {                  if (name == NULL) {
                     spacePop(ctxt);                      spacePop(ctxt);
                     ctxt->instate = XML_PARSER_EOF;                      ctxt->instate = XML_PARSER_EOF;
Line 11153  xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int termina Line 11177  xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int termina
                   else                    else
                     xmlParseEndTag1(ctxt, 0);                      xmlParseEndTag1(ctxt, 0);
 #endif /* LIBXML_SAX1_ENABLED */  #endif /* LIBXML_SAX1_ENABLED */
                if (ctxt->nameNr == 0) {                if (ctxt->instate == XML_PARSER_EOF) {
                     /* Nothing */
                 } else if (ctxt->nameNr == 0) {
                     ctxt->instate = XML_PARSER_EPILOG;                      ctxt->instate = XML_PARSER_EPILOG;
                 } else {                  } else {
                     ctxt->instate = XML_PARSER_CONTENT;                      ctxt->instate = XML_PARSER_CONTENT;
Line 11958  xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user Line 11984  xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user
     xmlParserCtxtPtr ctxt;      xmlParserCtxtPtr ctxt;
     xmlParserInputPtr inputStream;      xmlParserInputPtr inputStream;
     xmlParserInputBufferPtr buf;      xmlParserInputBufferPtr buf;
    
     if (ioread == NULL) return(NULL);      if (ioread == NULL) return(NULL);
   
     buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);      buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
    if (buf == NULL) return(NULL);    if (buf == NULL) {
         if (ioclose != NULL)
             ioclose(ioctx);
         return (NULL);
     }
   
     ctxt = xmlNewParserCtxt();      ctxt = xmlNewParserCtxt();
     if (ctxt == NULL) {      if (ctxt == NULL) {
Line 11987  xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user Line 12017  xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user
             memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));              memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
         if (user_data != NULL)          if (user_data != NULL)
             ctxt->userData = user_data;              ctxt->userData = user_data;
    }       }
   
     inputStream = xmlNewIOInputStream(ctxt, buf, enc);      inputStream = xmlNewIOInputStream(ctxt, buf, enc);
     if (inputStream == NULL) {      if (inputStream == NULL) {
Line 12404  xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const Line 12434  xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const
     }      }
   
     /*      /*
        * If the user provided its own SAX callbacks then reuse the
        * useData callback field, otherwise the expected setup in a
        * DOM builder is to have userData == ctxt
        */
       if (ctx->userData == ctx)
           ctxt->userData = ctxt;
       else
           ctxt->userData = ctx->userData;
   
       /*
      * Doing validity checking on chunk doesn't make sense       * Doing validity checking on chunk doesn't make sense
      */       */
     ctxt->instate = XML_PARSER_CONTENT;      ctxt->instate = XML_PARSER_CONTENT;
Line 14138  xmlInitParser(void) { Line 14178  xmlInitParser(void) {
             (xmlGenericError == NULL))              (xmlGenericError == NULL))
             initGenericErrorDefaultFunc(NULL);              initGenericErrorDefaultFunc(NULL);
         xmlInitMemory();          xmlInitMemory();
           xmlInitializeDict();
         xmlInitCharEncodingHandlers();          xmlInitCharEncodingHandlers();
         xmlDefaultSAXHandlerInit();          xmlDefaultSAXHandlerInit();
         xmlRegisterDefaultInputCallbacks();          xmlRegisterDefaultInputCallbacks();
Line 14560  xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int o Line 14601  xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int o
         ctxt->options |= XML_PARSE_OLDSAX;          ctxt->options |= XML_PARSE_OLDSAX;
         options -= XML_PARSE_OLDSAX;          options -= XML_PARSE_OLDSAX;
     }      }
       if (options & XML_PARSE_IGNORE_ENC) {
           ctxt->options |= XML_PARSE_IGNORE_ENC;
           options -= XML_PARSE_IGNORE_ENC;
       }
     ctxt->linenumbers = 1;      ctxt->linenumbers = 1;
     return (options);      return (options);
 }  }
Line 14747  xmlReadFd(int fd, const char *URL, const char *encodin Line 14792  xmlReadFd(int fd, const char *URL, const char *encodin
  * @options:  a combination of xmlParserOption   * @options:  a combination of xmlParserOption
  *   *
  * parse an XML document from I/O functions and source and build a tree.   * parse an XML document from I/O functions and source and build a tree.
 *  *
  * Returns the resulting document tree   * Returns the resulting document tree
  */   */
 xmlDocPtr  xmlDocPtr
Line 14763  xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCa Line 14808  xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCa
   
     input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,      input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
                                          XML_CHAR_ENCODING_NONE);                                           XML_CHAR_ENCODING_NONE);
    if (input == NULL)    if (input == NULL) {
         if (ioclose != NULL)
             ioclose(ioctx);
         return (NULL);          return (NULL);
       }
     ctxt = xmlNewParserCtxt();      ctxt = xmlNewParserCtxt();
     if (ctxt == NULL) {      if (ctxt == NULL) {
         xmlFreeParserInputBuffer(input);          xmlFreeParserInputBuffer(input);
Line 14790  xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCa Line 14838  xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCa
  *   *
  * parse an XML in-memory document and build a tree.   * parse an XML in-memory document and build a tree.
  * This reuses the existing @ctxt parser context   * This reuses the existing @ctxt parser context
 *  *
  * Returns the resulting document tree   * Returns the resulting document tree
  */   */
 xmlDocPtr  xmlDocPtr
Line 14945  xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, Line 14993  xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
  *   *
  * parse an XML document from I/O functions and source and build a tree.   * parse an XML document from I/O functions and source and build a tree.
  * This reuses the existing @ctxt parser context   * This reuses the existing @ctxt parser context
 *  *
  * Returns the resulting document tree   * Returns the resulting document tree
  */   */
 xmlDocPtr  xmlDocPtr
Line 14966  xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallb Line 15014  xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallb
   
     input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,      input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
                                          XML_CHAR_ENCODING_NONE);                                           XML_CHAR_ENCODING_NONE);
    if (input == NULL)    if (input == NULL) {
         if (ioclose != NULL)
             ioclose(ioctx);
         return (NULL);          return (NULL);
       }
     stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);      stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
     if (stream == NULL) {      if (stream == NULL) {
         xmlFreeParserInputBuffer(input);          xmlFreeParserInputBuffer(input);

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


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