From 8cb41987247decc674cc7136c15daac9206feb00 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Mon, 4 Sep 2017 15:28:08 -0400 Subject: [PATCH] Entity errors migrated. --- src/message.c | 50 ++++++++++++++++++++++++++++++-------------------- src/message.h | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/message.c b/src/message.c index bb8af9a..36fcf5c 100755 --- a/src/message.c +++ b/src/message.c @@ -254,7 +254,7 @@ static struct _dispatchTable { } dispatchTable[] = { { ADDED_MISSING_CHARSET, TidyInfo, formatStandard }, { ANCHOR_NOT_UNIQUE, TidyWarning, formatAttributeReport }, - { APOS_UNDEFINED, TidyWarning, NULL }, + { APOS_UNDEFINED, TidyWarning, formatStandard }, { ATTR_VALUE_NOT_LCASE, TidyWarning, formatAttributeReport }, { ATTRIBUTE_VALUE_REPLACED, TidyInfo, formatAttributeReport }, { ATTRIBUTE_IS_NOT_ALLOWED, TidyWarning, formatAttributeReport }, @@ -307,8 +307,8 @@ static struct _dispatchTable { { MISSING_ENDTAG_FOR, TidyWarning, formatStandard }, { MISSING_IMAGEMAP, TidyWarning, formatAttributeReport }, { MISSING_QUOTEMARK, TidyWarning, formatAttributeReport }, - { MISSING_SEMICOLON_NCR, TidyWarning, NULL }, - { MISSING_SEMICOLON, TidyWarning, NULL }, + { MISSING_SEMICOLON_NCR, TidyWarning, formatStandard }, + { MISSING_SEMICOLON, TidyWarning, formatStandard }, { MISSING_STARTTAG, TidyWarning, formatStandard }, { MISSING_TITLE_ELEMENT, TidyWarning, formatStandard }, { MOVED_STYLE_TO_HEAD, TidyWarning, formatStandard }, @@ -333,7 +333,7 @@ static struct _dispatchTable { { TOO_MANY_ELEMENTS_IN, TidyWarning, formatStandard, PREVIOUS_LOCATION }, { TOO_MANY_ELEMENTS, TidyWarning, formatStandard }, { TRIM_EMPTY_ELEMENT, TidyWarning, formatStandard }, - { UNESCAPED_AMPERSAND, TidyWarning, NULL }, + { UNESCAPED_AMPERSAND, TidyWarning, formatStandard }, { UNEXPECTED_END_OF_FILE_ATTR, TidyWarning, formatAttributeReport }, { UNEXPECTED_END_OF_FILE, TidyWarning, formatStandard }, { UNEXPECTED_ENDTAG_IN, TidyError, formatStandard }, @@ -344,7 +344,7 @@ static struct _dispatchTable { { UNEXPECTED_QUOTEMARK, TidyWarning, formatAttributeReport }, { UNKNOWN_ELEMENT_LOOKS_CUSTOM, TidyError, formatStandard }, { UNKNOWN_ELEMENT, TidyError, formatStandard }, - { UNKNOWN_ENTITY, TidyWarning, NULL }, + { UNKNOWN_ENTITY, TidyWarning, formatStandard }, { USING_BR_INPLACE_OF, TidyWarning, formatStandard }, { VENDOR_SPECIFIC_CHARS, TidyWarning, NULL }, { WHITE_IN_URI, TidyWarning, formatAttributeReport }, @@ -491,6 +491,20 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin return TY_(tidyMessageCreate)( doc, code, level, str ); } + case APOS_UNDEFINED: + case MISSING_SEMICOLON_NCR: + case MISSING_SEMICOLON: + case UNESCAPED_AMPERSAND: + case UNKNOWN_ENTITY: + { + ctmbstr entityname; + if ( !(entityname = va_arg( args, ctmbstr)) ) + { + entityname = "NULL"; + } + return TY_(tidyMessageCreateWithLexer)(doc, code, TidyWarning, entityname); + } + case SPACE_PRECEDING_XMLDECL: /* @TODO: Should this be a TidyInfo "silent" fix? */ return TY_(tidyMessageCreateWithNode)(doc, node, code, level ); @@ -697,6 +711,13 @@ void TY_(ReportBadArgument)( TidyDocImpl* doc, ctmbstr option ) } +void TY_(ReportEntityError)( TidyDocImpl* doc, uint code, ctmbstr entity, int ARG_UNUSED(c) ) +{ + /* Note that the report formatter currently doesn't use argument c */ + TY_(Report)( doc, NULL, NULL, code, entity, c ); +} + + void TY_(ReportFileError)( TidyDocImpl* doc, ctmbstr file, uint code ) { TY_(Report)(doc, NULL, NULL, code, file); @@ -721,9 +742,9 @@ void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarde /* An encoding mismatch is currently treated as a non-fatal error */ switch (code) { - case VENDOR_SPECIFIC_CHARS: + case INVALID_NCR: NtoS(c, buf); - doc->badChars |= BC_VENDOR_SPECIFIC_CHARS; + doc->badChars |= BC_INVALID_NCR; break; case INVALID_SGML_CHARS: @@ -743,9 +764,9 @@ void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarde break; #endif - case INVALID_NCR: + case VENDOR_SPECIFIC_CHARS: NtoS(c, buf); - doc->badChars |= BC_INVALID_NCR; + doc->badChars |= BC_VENDOR_SPECIFIC_CHARS; break; } @@ -773,17 +794,6 @@ void TY_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding) } -void TY_(ReportEntityError)( TidyDocImpl* doc, uint code, ctmbstr entity, - int ARG_UNUSED(c) ) -{ - TidyMessageImpl *message = NULL; - ctmbstr entityname = ( entity ? entity : "NULL" ); - - message = TY_(tidyMessageCreateWithLexer)(doc, code, TidyWarning, entityname); - messageOut( message ); -} - - void TY_(ReportMarkupVersion)( TidyDocImpl* doc ) { TidyMessageImpl *message = NULL; diff --git a/src/message.h b/src/message.h index e3ec9b5..c2b6184 100644 --- a/src/message.h +++ b/src/message.h @@ -57,6 +57,7 @@ void TY_(Report)(TidyDocImpl* doc, Node *element, Node *node, uint code, ...); void TY_(ReportAttrError)(TidyDocImpl* doc, Node *node, AttVal *av, uint code); void TY_(ReportBadArgument)( TidyDocImpl* doc, ctmbstr option ); +void TY_(ReportEntityError)( TidyDocImpl* doc, uint code, ctmbstr entity, int c ); void TY_(ReportFileError)( TidyDocImpl* doc, ctmbstr file, uint code ); @@ -67,7 +68,6 @@ void TY_(ReportFileError)( TidyDocImpl* doc, ctmbstr file, uint code ); void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarded); void TY_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding); -void TY_(ReportEntityError)( TidyDocImpl* doc, uint code, ctmbstr entity, int c ); void TY_(ReportMarkupVersion)( TidyDocImpl* doc ); void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name ); void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2);