diff --git a/ChangeLog b/ChangeLog index 04d4bf10..0c2f2fe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Oct 5 15:49:14 CEST 2003 Daniel Veillard + + * HTMLparser.c Makefile.am legacy.c parser.c parserInternals.c + include/libxml/xmlerror.h: more code cleanup, especially around + error messages, the HTML parser has now been upgraded to the new + handling. + * result/HTML/*: a few changes in the resulting error messages + Sat Oct 4 23:06:41 CEST 2003 Daniel Veillard * parser.c include/libxml/xmlerror.h: more error/warning diff --git a/HTMLparser.c b/HTMLparser.c index d9ef259a..3ee37a48 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -57,6 +57,81 @@ xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len, xmlChar end, xmlChar end2, xmlChar end3); static void htmlParseComment(htmlParserCtxtPtr ctxt); +/************************************************************************ + * * + * Some factorized error routines * + * * + ************************************************************************/ + +/** + * xmlErrMemory: + * @ctxt: an HTML parser context + * @extra: extra informations + * + * Handle a redefinition of attribute error + */ +static void +htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra) +{ + if (ctxt != NULL) { + ctxt->errNo = XML_ERR_NO_MEMORY; + ctxt->instate = XML_PARSER_EOF; + ctxt->disableSAX = 1; + } + if (extra) + __xmlRaiseError(NULL, NULL, ctxt, NULL, XML_FROM_PARSER, + XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, + NULL, NULL, 0, 0, + "Memory allocation failed : %s\n", extra); + else + __xmlRaiseError(NULL, NULL, ctxt, NULL, XML_FROM_PARSER, + XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, + NULL, NULL, 0, 0, "Memory allocation failed\n"); +} + +/** + * htmlParseErr: + * @ctxt: an HTML parser context + * @error: the error number + * @msg: the error message + * @str1: string infor + * @str2: string infor + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void +htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const xmlChar *str1, const xmlChar *str2) +{ + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, ctxt, NULL, XML_FROM_HTML, error, + XML_ERR_ERROR, NULL, 0, + (const char *) str1, (const char *) str2, + NULL, 0, 0, + msg, str1, str2); + ctxt->wellFormed = 0; +} + +/** + * htmlParseErrInt: + * @ctxt: an HTML parser context + * @error: the error number + * @msg: the error message + * @val: integer info + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void +htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, int val) +{ + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, ctxt, NULL, XML_FROM_HTML, error, + XML_ERR_ERROR, NULL, 0, NULL, NULL, + NULL, val, 0, msg, val); + ctxt->wellFormed = 0; +} + /************************************************************************ * * * Parser stacks related functions and macros * @@ -82,7 +157,7 @@ htmlnamePush(htmlParserCtxtPtr ctxt, const xmlChar * value) ctxt->nameMax * sizeof(ctxt->nameTab[0])); if (ctxt->nameTab == NULL) { - xmlGenericError(xmlGenericErrorContext, "realloc failed !\n"); + htmlErrMemory(ctxt, NULL); return (0); } } @@ -272,13 +347,8 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) { val |= cur[1] & 0x3f; } if (!IS_CHAR(val)) { - ctxt->errNo = XML_ERR_INVALID_ENCODING; - if ((ctxt->sax != NULL) && - (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "Char 0x%X out of allowed range\n", val); - ctxt->wellFormed = 0; - if (ctxt->recovery == 0) ctxt->disableSAX = 1; + htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, + "Char 0x%X out of allowed range\n", val); } return(val); } else { @@ -311,10 +381,10 @@ encoding_error: * to ISO-Latin-1 (if you don't like this policy, just declare the * encoding !) */ - ctxt->errNo = XML_ERR_INVALID_ENCODING; + htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING, + "Input is not proper UTF-8, indicate encoding !\n", + NULL, NULL); if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) { - ctxt->sax->error(ctxt->userData, - "Input is not proper UTF-8, indicate encoding !\n"); ctxt->sax->error(ctxt->userData, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n", ctxt->input->cur[0], ctxt->input->cur[1], ctxt->input->cur[2], ctxt->input->cur[3]); @@ -1039,17 +1109,6 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) const htmlElemDesc *info; int i, priority; -#ifdef DEBUG - const xmlChar *oldname; - - xmlGenericError(xmlGenericErrorContext, - "Close of %s stack: %d elements\n", newtag, - ctxt->nameNr); - for (i = 0; i < ctxt->nameNr; i++) - xmlGenericError(xmlGenericErrorContext, "%d : %s\n", i, - ctxt->nameTab[i]); -#endif - priority = htmlGetEndPriority(newtag); for (i = (ctxt->nameNr - 1); i >= 0; i--) { @@ -1070,36 +1129,14 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) while (!xmlStrEqual(newtag, ctxt->name)) { info = htmlTagLookup(ctxt->name); - if ((info == NULL) || (info->endTag == 1)) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext, - "htmlAutoCloseOnClose: %s closes %s\n", newtag, - ctxt->name); -#endif - } else if (info->endTag == 3) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext, - "End of tag %s: expecting %s\n", newtag, - ctxt->name); - -#endif - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "Opening and ending tag mismatch: %s and %s\n", - newtag, ctxt->name); - ctxt->wellFormed = 0; + if ((info != NULL) && (info->endTag == 3)) { + htmlParseErr(ctxt, XML_ERR_TAG_NAME_MISMATCH, + "Opening and ending tag mismatch: %s and %s\n", + NULL, NULL); } if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) ctxt->sax->endElement(ctxt->userData, ctxt->name); -#ifdef DEBUG - oldname = htmlnamePop(ctxt); - if (oldname != NULL) { - xmlGenericError(xmlGenericErrorContext, - "htmlAutoCloseOnClose: popped %s\n", oldname); - } -#else htmlnamePop(ctxt); -#endif } } @@ -1113,31 +1150,13 @@ static void htmlAutoCloseOnEnd(htmlParserCtxtPtr ctxt) { int i; -#ifdef DEBUG - const xmlChar *oldname; - - xmlGenericError(xmlGenericErrorContext, - "Close of stack: %d elements\n", ctxt->nameNr); -#endif if (ctxt->nameNr == 0) return; for (i = (ctxt->nameNr - 1); i >= 0; i--) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext, "%d : %s\n", i, - ctxt->nameTab[i]); -#endif if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) ctxt->sax->endElement(ctxt->userData, ctxt->name); -#ifdef DEBUG - oldname = htmlnamePop(ctxt); - if (oldname != NULL) { - xmlGenericError(xmlGenericErrorContext, - "htmlAutoCloseOnEnd: popped %s\n", oldname); - } -#else htmlnamePop(ctxt); -#endif } } @@ -1156,28 +1175,11 @@ htmlAutoCloseOnEnd(htmlParserCtxtPtr ctxt) static void htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) { -#ifdef DEBUG - const xmlChar *oldname; -#endif - while ((newtag != NULL) && (ctxt->name != NULL) && (htmlCheckAutoClose(newtag, ctxt->name))) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext, - "htmlAutoClose: %s closes %s\n", newtag, - ctxt->name); -#endif if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) ctxt->sax->endElement(ctxt->userData, ctxt->name); -#ifdef DEBUG - oldname = htmlnamePop(ctxt); - if (oldname != NULL) { - xmlGenericError(xmlGenericErrorContext, - "htmlAutoClose: popped %s\n", oldname); - } -#else htmlnamePop(ctxt); -#endif } if (newtag == NULL) { htmlAutoCloseOnEnd(ctxt); @@ -1187,23 +1189,10 @@ htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) ((xmlStrEqual(ctxt->name, BAD_CAST "head")) || (xmlStrEqual(ctxt->name, BAD_CAST "body")) || (xmlStrEqual(ctxt->name, BAD_CAST "html")))) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext, - "htmlAutoClose: EOF closes %s\n", ctxt->name); -#endif if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) ctxt->sax->endElement(ctxt->userData, ctxt->name); -#ifdef DEBUG - oldname = htmlnamePop(ctxt); - if (oldname != NULL) { - xmlGenericError(xmlGenericErrorContext, - "htmlAutoClose: popped %s\n", oldname); - } -#else htmlnamePop(ctxt); -#endif } - } /** @@ -1274,9 +1263,6 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { if (xmlStrEqual(newtag, BAD_CAST"html")) return; if (ctxt->nameNr <= 0) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext,"Implied element html: pushed html\n"); -#endif htmlnamePush(ctxt, BAD_CAST"html"); if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) ctxt->sax->startElement(ctxt->userData, BAD_CAST"html", NULL); @@ -1294,9 +1280,6 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { * dropped OBJECT ... i you put it first BODY will be * assumed ! */ -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext,"Implied element head: pushed head\n"); -#endif htmlnamePush(ctxt, BAD_CAST"head"); if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL); @@ -1313,9 +1296,6 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { } } -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext,"Implied element body: pushed body\n"); -#endif htmlnamePush(ctxt, BAD_CAST"body"); if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) ctxt->sax->startElement(ctxt->userData, BAD_CAST"body", NULL); @@ -1353,9 +1333,6 @@ htmlCheckParagraph(htmlParserCtxtPtr ctxt) { return(0); for (i = 0; htmlNoContentElements[i] != NULL; i++) { if (xmlStrEqual(tag, BAD_CAST htmlNoContentElements[i])) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext,"Implied element paragraph\n"); -#endif htmlAutoClose(ctxt, BAD_CAST"p"); htmlCheckImplied(ctxt, BAD_CAST"p"); htmlnamePush(ctxt, BAD_CAST"p"); @@ -1698,7 +1675,7 @@ static const htmlEntityDesc html40EntitiesTable[] = { buffer##_size *= 2; \ buffer = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \ if (buffer == NULL) { \ - xmlGenericError(xmlGenericErrorContext, "realloc failed\n"); \ + htmlErrMemory(ctxt, "growing buffer\n"); \ return(NULL); \ } \ } @@ -1720,9 +1697,6 @@ htmlEntityLookup(const xmlChar *name) { for (i = 0;i < (sizeof(html40EntitiesTable)/ sizeof(html40EntitiesTable[0]));i++) { if (xmlStrEqual(name, BAD_CAST html40EntitiesTable[i].name)) { -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", name); -#endif return((htmlEntityDescPtr) &html40EntitiesTable[i]); } } @@ -1742,28 +1716,14 @@ htmlEntityLookup(const xmlChar *name) { const htmlEntityDesc * htmlEntityValueLookup(unsigned int value) { unsigned int i; -#ifdef DEBUG - unsigned int lv = 0; -#endif for (i = 0;i < (sizeof(html40EntitiesTable)/ sizeof(html40EntitiesTable[0]));i++) { if (html40EntitiesTable[i].value >= value) { if (html40EntitiesTable[i].value > value) break; -#ifdef DEBUG - xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name); -#endif return((htmlEntityDescPtr) &html40EntitiesTable[i]); } -#ifdef DEBUG - if (lv > html40EntitiesTable[i].value) { - xmlGenericError(xmlGenericErrorContext, - "html40EntitiesTable[] is not sorted (%d > %d)!\n", - lv, html40EntitiesTable[i].value); - } - lv = html40EntitiesTable[i].value; -#endif } return(NULL); } @@ -1963,33 +1923,6 @@ htmlEncodeEntities(unsigned char* out, int *outlen, return(0); } -/** - * htmlDecodeEntities: - * @ctxt: the parser context - * @len: the len to decode (in bytes !), -1 for no size limit - * @end: an end marker xmlChar, 0 if none - * @end2: an end marker xmlChar, 0 if none - * @end3: an end marker xmlChar, 0 if none - * - * Substitute the HTML entities by their value - * - * DEPRECATED !!!! - * - * Returns A newly allocated string with the substitution done. The caller - * must deallocate it ! - */ -xmlChar * -htmlDecodeEntities(htmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED, - xmlChar end ATTRIBUTE_UNUSED, xmlChar end2 ATTRIBUTE_UNUSED, xmlChar end3 ATTRIBUTE_UNUSED) { - static int deprecated = 0; - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "htmlDecodeEntities() deprecated function reached\n"); - deprecated = 1; - } - return(NULL); -} - /************************************************************************ * * * Commodity functions to handle streams * @@ -2009,10 +1942,7 @@ htmlNewInputStream(htmlParserCtxtPtr ctxt) { input = (xmlParserInputPtr) xmlMalloc(sizeof(htmlParserInput)); if (input == NULL) { - ctxt->errNo = XML_ERR_NO_MEMORY; - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "malloc: couldn't allocate a new input stream\n"); + htmlErrMemory(ctxt, "couldn't allocate a new input stream\n"); return(NULL); } memset(input, 0, sizeof(htmlParserInput)); @@ -2126,8 +2056,7 @@ htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) { */ cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc)); if (cur == NULL) { - xmlGenericError(xmlGenericErrorContext, - "htmlNewDocNoDtD : malloc failed\n"); + htmlErrMemory(NULL, "HTML document creation failed\n"); return(NULL); } memset(cur, 0, sizeof(xmlDoc)); @@ -2322,8 +2251,7 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) { buffer_size = HTML_PARSER_BUFFER_SIZE; buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar)); if (buffer == NULL) { - xmlGenericError(xmlGenericErrorContext, - "htmlParseHTMLAttribute: malloc failed\n"); + htmlErrMemory(ctxt, "buffer allocation failed\n"); return(NULL); } out = buffer; @@ -2458,9 +2386,8 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) { NEXT; name = htmlParseName(ctxt); if (name == NULL) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "htmlParseEntityRef: no name\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_NAME_REQUIRED, + "htmlParseEntityRef: no name\n", NULL, NULL); } else { GROW; if (CUR == ';') { @@ -2473,9 +2400,9 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) { if (ent != NULL) /* OK that's ugly !!! */ NEXT; } else { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "htmlParseEntityRef: expecting ';'\n"); + htmlParseErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, + "htmlParseEntityRef: expecting ';'\n", + NULL, NULL); *str = name; } } @@ -2503,18 +2430,16 @@ htmlParseAttValue(htmlParserCtxtPtr ctxt) { NEXT; ret = htmlParseHTMLAttribute(ctxt, '"'); if (CUR != '"') { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "AttValue: ' expected\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, + "AttValue: \" expected\n", NULL, NULL); } else NEXT; } else if (CUR == '\'') { NEXT; ret = htmlParseHTMLAttribute(ctxt, '\''); if (CUR != '\'') { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "AttValue: ' expected\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, + "AttValue: ' expected\n", NULL, NULL); } else NEXT; } else { @@ -2523,9 +2448,8 @@ htmlParseAttValue(htmlParserCtxtPtr ctxt) { */ ret = htmlParseHTMLAttribute(ctxt, 0); if (ret == NULL) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "AttValue: no value found\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE, + "AttValue: no value found\n", NULL, NULL); } } return(ret); @@ -2553,9 +2477,8 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) { while ((IS_CHAR((unsigned int) CUR)) && (CUR != '"')) NEXT; if (!IS_CHAR((unsigned int) CUR)) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "Unfinished SystemLiteral\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, + "Unfinished SystemLiteral\n", NULL, NULL); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; @@ -2566,18 +2489,15 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) { while ((IS_CHAR((unsigned int) CUR)) && (CUR != '\'')) NEXT; if (!IS_CHAR((unsigned int) CUR)) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "Unfinished SystemLiteral\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, + "Unfinished SystemLiteral\n", NULL, NULL); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; } } else { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "SystemLiteral \" or ' expected\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, + " or ' expected\n", NULL, NULL); } return(ret); @@ -2606,9 +2526,8 @@ htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) { q = CUR_PTR; while (IS_PUBIDCHAR(CUR)) NEXT; if (CUR != '"') { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "Unfinished PubidLiteral\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, + "Unfinished PubidLiteral\n", NULL, NULL); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; @@ -2619,17 +2538,15 @@ htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) { while ((IS_PUBIDCHAR(CUR)) && (CUR != '\'')) NEXT; if (CUR != '\'') { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "Unfinished PubidLiteral\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, + "Unfinished PubidLiteral\n", NULL, NULL); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; } } else { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, "SystemLiteral \" or ' expected\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, + "PubidLiteral \" or ' expected\n", NULL, NULL); } return(ret); @@ -2708,10 +2625,8 @@ htmlParseScript(htmlParserCtxtPtr ctxt) { cur = CUR; } if (!(IS_CHAR((unsigned int) cur))) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "Invalid char in CDATA 0x%X\n", cur); - ctxt->wellFormed = 0; + htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, + "Invalid char in CDATA 0x%X\n", cur); NEXT; } @@ -2824,36 +2739,29 @@ htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID) { (UPP(4) == 'E') && (UPP(5) == 'M')) { SKIP(6); if (!IS_BLANK(CUR)) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "Space required after 'SYSTEM'\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_SPACE_REQUIRED, + "Space required after 'SYSTEM'\n", NULL, NULL); } SKIP_BLANKS; URI = htmlParseSystemLiteral(ctxt); if (URI == NULL) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "htmlParseExternalID: SYSTEM, no URI\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_URI_REQUIRED, + "htmlParseExternalID: SYSTEM, no URI\n", NULL, NULL); } } else if ((UPPER == 'P') && (UPP(1) == 'U') && (UPP(2) == 'B') && (UPP(3) == 'L') && (UPP(4) == 'I') && (UPP(5) == 'C')) { SKIP(6); if (!IS_BLANK(CUR)) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "Space required after 'PUBLIC'\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_SPACE_REQUIRED, + "Space required after 'PUBLIC'\n", NULL, NULL); } SKIP_BLANKS; *publicID = htmlParsePubidLiteral(ctxt); if (*publicID == NULL) { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "htmlParseExternalID: PUBLIC, no Public Identifier\n"); - ctxt->wellFormed = 0; + htmlParseErr(ctxt, XML_ERR_PUBID_REQUIRED, + "htmlParseExternalID: PUBLIC, no Public Identifier\n", + NULL, NULL); } SKIP_BLANKS; if ((CUR == '"') || (CUR == '\'')) { @@ -2893,8 +2801,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { SKIP(4); buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); if (buf == NULL) { - xmlGenericError(xmlGenericErrorContext, - "malloc of %d byte failed\n", size); + htmlErrMemory(ctxt, "buffer allocation failed\n"); ctxt->instate = state; return; } @@ -2911,8 +2818,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { size *= 2; buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); if (buf == NULL) { - xmlGenericError(xmlGenericErrorContext, - "realloc of %d byte failed\n", size); + htmlErrMemory(ctxt, "growing buffer failed\n"); ctxt->instate = state; return; } @@ -2932,11 +2838,8 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { } buf[len] = 0; if (!IS_CHAR(cur)) { - ctxt->errNo = XML_ERR_COMMENT_NOT_FINISHED; - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "Comment not terminated \n

^ -./test/HTML/doc3.htm:236: error: Unexpected end tag : font +./test/HTML/doc3.htm:236: HTML parser error : Unexpected end tag : font Specials




^ -./test/HTML/doc3.htm:747: error: Unexpected end tag : font +./test/HTML/doc3.htm:747: HTML parser error : Unexpected end tag : font om/ad_static.asp?pid=2097&sid=1881&asid=7708"> ^ -./test/HTML/doc3.htm:747: error: Unexpected end tag : p +./test/HTML/doc3.htm:747: HTML parser error : Unexpected end tag : p =7708">

^ -./test/HTML/doc3.htm:772: error: Unexpected end tag : form +./test/HTML/doc3.htm:772: HTML parser error : Unexpected end tag : form archive
Code:BP6-hd

Code:BP6-hd

 

< ^ -./test/HTML/doc3.htm:840: error: Unexpected end tag : td +./test/HTML/doc3.htm:840: HTML parser error : Unexpected end tag : td
  ^ diff --git a/result/HTML/entities.html.err b/result/HTML/entities.html.err index e9bfcfa2..180fa9f9 100644 --- a/result/HTML/entities.html.err +++ b/result/HTML/entities.html.err @@ -1,12 +1,12 @@ -./test/HTML/entities.html:1: error: htmlParseEntityRef: expecting ';' +./test/HTML/entities.html:1: HTML parser error : htmlParseEntityRef: expecting ';'

^ -./test/HTML/entities.html:1: error: htmlParseEntityRef: no name +./test/HTML/entities.html:1: HTML parser error : htmlParseEntityRef: no name

^ -./test/HTML/entities.html:3: error: htmlParseEntityRef: expecting ';' +./test/HTML/entities.html:3: HTML parser error : htmlParseEntityRef: expecting ';' a&b ^ -./test/HTML/entities.html:4: error: htmlParseEntityRef: no name +./test/HTML/entities.html:4: HTML parser error : htmlParseEntityRef: no name a & b ^ diff --git a/result/HTML/fp40.htm.err b/result/HTML/fp40.htm.err index 0ddb59f2..6ab388f5 100644 --- a/result/HTML/fp40.htm.err +++ b/result/HTML/fp40.htm.err @@ -1,3 +1,3 @@ -./test/HTML/fp40.htm:153: error: htmlParseEntityRef: no name +./test/HTML/fp40.htm:153: HTML parser error : htmlParseEntityRef: no name technical articles from Microsoft's extensive Knowledge Base, FAQs, & troublesho ^ diff --git a/result/HTML/reg4.html.err b/result/HTML/reg4.html.err index 10db868a..6515f70d 100644 --- a/result/HTML/reg4.html.err +++ b/result/HTML/reg4.html.err @@ -1,3 +1,3 @@ -./test/HTML/reg4.html:10: error: Unexpected end tag : p +./test/HTML/reg4.html:10: HTML parser error : Unexpected end tag : p

^ diff --git a/result/HTML/test3.html.err b/result/HTML/test3.html.err index 3a7b7310..d967d1f4 100644 --- a/result/HTML/test3.html.err +++ b/result/HTML/test3.html.err @@ -1,12 +1,12 @@ -./test/HTML/test3.html:6: error: Unexpected end tag : p +./test/HTML/test3.html:6: HTML parser error : Unexpected end tag : p


^ -./test/HTML/test3.html:13: error: Unexpected end tag : p +./test/HTML/test3.html:13: HTML parser error : Unexpected end tag : p


^ -./test/HTML/test3.html:27: error: Opening and ending tag mismatch: h4 and b +./test/HTML/test3.html:27: HTML parser error : Opening and ending tag mismatch: (null) and (null)

Links

^ -./test/HTML/test3.html:27: error: Unexpected end tag : b +./test/HTML/test3.html:27: HTML parser error : Unexpected end tag : b

Links

^ diff --git a/result/HTML/wired.html.err b/result/HTML/wired.html.err index 0e96b39d..73779318 100644 --- a/result/HTML/wired.html.err +++ b/result/HTML/wired.html.err @@ -1,249 +1,249 @@ -./test/HTML/wired.html:6: error: htmlParseEntityRef: expecting ';' +./test/HTML/wired.html:6: HTML parser error : htmlParseEntityRef: expecting ';'
^ -./test/HTML/wired.html:346: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:346: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:374: error: htmlParseEntityRef: no name +./test/HTML/wired.html:374: HTML parser error : htmlParseEntityRef: no name a, sans-serif">
Rants & ^ -./test/HTML/wired.html:374: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:374: HTML parser error : Opening and ending tag mismatch: (null) and (null) Readers on Apple's G4 ... AOL's passwords ... MS vs. Linux.



Vignette
^ -./test/HTML/wired.html:407: error: htmlParseEntityRef: expecting ';' +./test/HTML/wired.html:407: HTML parser error : htmlParseEntityRef: expecting ';' ervlet/appservlet?from=/wired/sprint/&template=/security/security.html&SITE= ^ -./test/HTML/wired.html:407: error: htmlParseEntityRef: expecting ';' +./test/HTML/wired.html:407: HTML parser error : htmlParseEntityRef: expecting ';' ervlet/appservlet?from=/wired/sprint/&template=/security/security.html&SITE= ^ -./test/HTML/wired.html:408: error: htmlParseEntityRef: expecting ';' +./test/HTML/wired.html:408: HTML parser error : htmlParseEntityRef: expecting ';' wired.com&BANNER=Sprint" style="text-decoration:none">Spri ^ -./test/HTML/wired.html:408: error: Opening and ending tag mismatch: a and font +./test/HTML/wired.html:408: HTML parser error : Opening and ending tag mismatch: (null) and (null) com&BANNER=Sprint" style="text-decoration:none">Sprint ^ -./test/HTML/wired.html:408: error: End tag : expected '>' +./test/HTML/wired.html:408: HTML parser error : End tag : expected '>' =Sprint" style="text-decoration:none">Sprint ^ -./test/HTML/wired.html:414: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:414: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:414: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:414: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:414: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:414: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:414: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:414: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:414: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:414: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:414: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:414: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:414: error: Opening and ending tag mismatch: td and font +./test/HTML/wired.html:414: HTML parser error : Opening and ending tag mismatch: (null) and (null) ^ -./test/HTML/wired.html:432: error: htmlParseEntityRef: expecting ';' +./test/HTML/wired.html:432: HTML parser error : htmlParseEntityRef: expecting ';' href="http://www.lycos.com/news/flash/hitlerbunker.html?v=wn1015&lpv=1">Lycos