Diff for /XML/HTMLparser.c between versions 1.55 and 1.56

version 1.55, 2000/08/02 16:11:05 version 1.56, 2000/08/04 17:51:27
Line 2168  htmlParseExternalID(htmlParserCtxtPtr ct Line 2168  htmlParseExternalID(htmlParserCtxtPtr ct
 void  void
 htmlParseComment(htmlParserCtxtPtr ctxt) {  htmlParseComment(htmlParserCtxtPtr ctxt) {
     xmlChar *buf = NULL;      xmlChar *buf = NULL;
     int len = 0;      int len;
     int size = HTML_PARSER_BUFFER_SIZE;      int size = HTML_PARSER_BUFFER_SIZE;
     register xmlChar s, r, q;      int q, ql;
       int r, rl;
       int cur, l;
       xmlParserInputState state;
   
     /*      /*
      * Check that there is a comment right here.       * Check that there is a comment right here.
      */       */
     if ((CUR != '<') || (NXT(1) != '!') ||      if ((RAW != '<') || (NXT(1) != '!') ||
         (NXT(2) != '-') || (NXT(3) != '-')) return;          (NXT(2) != '-') || (NXT(3) != '-')) return;
   
       state = ctxt->instate;
       ctxt->instate = XML_PARSER_COMMENT;
       SHRINK;
       SKIP(4);
     buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));      buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
     if (buf == NULL) {      if (buf == NULL) {
         fprintf(stderr, "malloc of %d byte failed\n", size);          fprintf(stderr, "malloc of %d byte failed\n", size);
           ctxt->instate = state;
         return;          return;
     }      }
     q = r = '-'; /* 0 or '-' to cover our ass against <!--> and <!---> ? !!! */      q = CUR_CHAR(ql);
     SKIP(4);      NEXTL(ql);
     s = CUR;      r = CUR_CHAR(rl);
           NEXTL(rl);
     while (IS_CHAR(s) &&      cur = CUR_CHAR(l);
            ((s != '>') || (r != '-') || (q != '-'))) {      len = 0;
         if (len + 1 >= size) {      while (IS_CHAR(cur) &&
              ((cur != '>') ||
               (r != '-') || (q != '-'))) {
           if (len + 5 >= size) {
             size *= 2;              size *= 2;
             buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));              buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
             if (buf == NULL) {              if (buf == NULL) {
                 fprintf(stderr, "realloc of %d byte failed\n", size);                  fprintf(stderr, "realloc of %d byte failed\n", size);
                   ctxt->instate = state;
                 return;                  return;
             }              }
         }          }
         buf[len++] = s;          COPY_BUF(ql,buf,len,q);
         NEXT;  
         q = r;          q = r;
         r = s;          ql = rl;
         s = CUR;          r = cur;
           rl = l;
           NEXTL(l);
           cur = CUR_CHAR(l);
           if (cur == 0) {
               SHRINK;
               GROW;
               cur = CUR_CHAR(l);
           }
     }      }
     buf[len - 2] = 0;      buf[len] = 0;
     if (!IS_CHAR(s)) {      if (!IS_CHAR(cur)) {
         if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))          if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
             ctxt->sax->error(ctxt->userData, "Comment not terminated \n<!--%.50s\n", buf);              ctxt->sax->error(ctxt->userData,
                                "Comment not terminated \n<!--%.50s\n", buf);
           ctxt->errNo = XML_ERR_COMMENT_NOT_FINISHED;
         ctxt->wellFormed = 0;          ctxt->wellFormed = 0;
           xmlFree(buf);
     } else {      } else {
         NEXT;          NEXT;
         if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL)) {          if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
               (!ctxt->disableSAX))
             ctxt->sax->comment(ctxt->userData, buf);              ctxt->sax->comment(ctxt->userData, buf);
         }          xmlFree(buf);
     }      }
     xmlFree(buf);      ctxt->instate = state;
 }  }
   
 /**  /**
Line 2483  htmlCheckEncoding(htmlParserCtxtPtr ctxt Line 2506  htmlCheckEncoding(htmlParserCtxtPtr ctxt
             (ctxt->input->buf->raw != NULL) &&              (ctxt->input->buf->raw != NULL) &&
             (ctxt->input->buf->buffer != NULL)) {              (ctxt->input->buf->buffer != NULL)) {
             int nbchars;              int nbchars;
               int processed;
   
             /*              /*
              * convert as much as possible to the parser reading buffer.               * convert as much as possible to the parser reading buffer.
              */               */
               processed = ctxt->input->cur - ctxt->input->base;
               xmlBufferShrink(ctxt->input->buf->buffer, processed);
             nbchars = xmlCharEncInFunc(ctxt->input->buf->encoder,              nbchars = xmlCharEncInFunc(ctxt->input->buf->encoder,
                                        ctxt->input->buf->buffer,                                         ctxt->input->buf->buffer,
                                        ctxt->input->buf->raw);                                         ctxt->input->buf->raw);
Line 2496  htmlCheckEncoding(htmlParserCtxtPtr ctxt Line 2522  htmlCheckEncoding(htmlParserCtxtPtr ctxt
                      "htmlCheckEncoding: encoder error\n");                       "htmlCheckEncoding: encoder error\n");
                 ctxt->errNo = XML_ERR_INVALID_ENCODING;                  ctxt->errNo = XML_ERR_INVALID_ENCODING;
             }              }
               ctxt->input->base =
               ctxt->input->cur = ctxt->input->buf->buffer->content;
         }          }
     }      }
 }  }
Line 2977  htmlParseContent(htmlParserCtxtPtr ctxt) Line 3005  htmlParseContent(htmlParserCtxtPtr ctxt)
   
 void  void
 htmlParseElement(htmlParserCtxtPtr ctxt) {  htmlParseElement(htmlParserCtxtPtr ctxt) {
     const xmlChar *openTag = CUR_PTR;  
     xmlChar *name;      xmlChar *name;
     xmlChar *currentNode = NULL;      xmlChar *currentNode = NULL;
     htmlElemDescPtr info;      htmlElemDescPtr info;
Line 3051  htmlParseElement(htmlParserCtxtPtr ctxt) Line 3078  htmlParseElement(htmlParserCtxtPtr ctxt)
         NEXT;          NEXT;
     } else {      } else {
         if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))          if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
             ctxt->sax->error(ctxt->userData, "Couldn't find end of Start Tag\n%.30s\n",              ctxt->sax->error(ctxt->userData,
                              openTag);                               "Couldn't find end of Start Tag %s\n",
                                name);
         ctxt->wellFormed = 0;          ctxt->wellFormed = 0;
   
         /*          /*
Line 3810  htmlParseTryOrFinish(htmlParserCtxtPtr c Line 3838  htmlParseTryOrFinish(htmlParserCtxtPtr c
 #endif  #endif
                 break;                  break;
             }              }
             case XML_PARSER_CONTENT:              case XML_PARSER_CONTENT: {
                   long cons;
                 /*                  /*
                  * Handle preparsed entities and charRef                   * Handle preparsed entities and charRef
                  */                   */
Line 3847  htmlParseTryOrFinish(htmlParserCtxtPtr c Line 3876  htmlParseTryOrFinish(htmlParserCtxtPtr c
                     goto done;                      goto done;
                 cur = in->cur[0];                  cur = in->cur[0];
                 next = in->cur[1];                  next = in->cur[1];
                   cons = ctxt->nbChars;
                 if ((cur == '<') && (next == '!') &&                  if ((cur == '<') && (next == '!') &&
                     (in->cur[2] == '-') && (in->cur[3] == '-')) {                      (in->cur[2] == '-') && (in->cur[3] == '-')) {
                     if ((!terminate) &&                      if ((!terminate) &&
Line 3901  htmlParseTryOrFinish(htmlParserCtxtPtr c Line 3931  htmlParseTryOrFinish(htmlParserCtxtPtr c
 #endif  #endif
                     htmlParseCharData(ctxt, 0);                      htmlParseCharData(ctxt, 0);
                 }                  }
                   if (cons == ctxt->nbChars) {
                       if (ctxt->node != NULL) {
                           if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
                               ctxt->sax->error(ctxt->userData,
                                    "detected an error in element content\n");
                           ctxt->wellFormed = 0;
                           NEXT;
                       }
                       break;
                   }
   
                 break;                  break;
               }
             case XML_PARSER_END_TAG:              case XML_PARSER_END_TAG:
                 if (avail < 2)                  if (avail < 2)
                     goto done;                      goto done;

Removed from v.1.55  
changed lines
  Added in v.1.56


Webmaster