EncodingWarning and MissingAttr migrated.

This commit is contained in:
Jim Derry 2017-09-04 16:12:01 -04:00
parent f49c419908
commit 5b6edb5813
2 changed files with 37 additions and 39 deletions

View file

@ -277,7 +277,7 @@ static struct _dispatchTable {
{ ELEMENT_NOT_EMPTY, TidyWarning, formatStandard }, { ELEMENT_NOT_EMPTY, TidyWarning, formatStandard },
{ ELEMENT_VERS_MISMATCH_ERROR, TidyError, formatStandard }, { ELEMENT_VERS_MISMATCH_ERROR, TidyError, formatStandard },
{ ELEMENT_VERS_MISMATCH_WARN, TidyWarning, formatStandard }, { ELEMENT_VERS_MISMATCH_WARN, TidyWarning, formatStandard },
{ ENCODING_MISMATCH, TidyWarning, NULL }, { ENCODING_MISMATCH, TidyWarning, formatEncodingReport },
{ ESCAPED_ILLEGAL_URI, TidyWarning, formatAttributeReport }, { ESCAPED_ILLEGAL_URI, TidyWarning, formatAttributeReport },
{ FILE_CANT_OPEN, TidyBadDocument, formatStandard }, { FILE_CANT_OPEN, TidyBadDocument, formatStandard },
{ FILE_CANT_OPEN_CFG, TidyBadDocument, formatStandard }, { FILE_CANT_OPEN_CFG, TidyBadDocument, formatStandard },
@ -302,7 +302,7 @@ static struct _dispatchTable {
{ MISMATCHED_ATTRIBUTE_ERROR, TidyError, formatAttributeReport }, { MISMATCHED_ATTRIBUTE_ERROR, TidyError, formatAttributeReport },
{ MISMATCHED_ATTRIBUTE_WARN, TidyWarning, formatAttributeReport }, { MISMATCHED_ATTRIBUTE_WARN, TidyWarning, formatAttributeReport },
{ MISSING_ATTR_VALUE, TidyWarning, formatAttributeReport }, { MISSING_ATTR_VALUE, TidyWarning, formatAttributeReport },
{ MISSING_ATTRIBUTE, TidyWarning, NULL }, { MISSING_ATTRIBUTE, TidyWarning, formatStandard },
{ MISSING_DOCTYPE, TidyWarning, formatStandard }, { MISSING_DOCTYPE, TidyWarning, formatStandard },
{ MISSING_ENDTAG_BEFORE, TidyWarning, formatStandard }, { MISSING_ENDTAG_BEFORE, TidyWarning, formatStandard },
{ MISSING_ENDTAG_FOR, TidyWarning, formatStandard }, { MISSING_ENDTAG_FOR, TidyWarning, formatStandard },
@ -483,6 +483,15 @@ TidyMessageImpl *formatEncodingReport(TidyDocImpl* doc, Node *element, Node *nod
NtoS(c, buf); NtoS(c, buf);
doc->badChars |= BC_VENDOR_SPECIFIC_CHARS; doc->badChars |= BC_VENDOR_SPECIFIC_CHARS;
break; break;
case ENCODING_MISMATCH:
doc->badChars |= BC_ENCODING_MISMATCH;
return TY_(tidyMessageCreateWithLexer)(doc,
code,
level,
TY_(CharEncodingName)(doc->docIn->encoding),
TY_(CharEncodingName)(c));
break;
} }
return TY_(tidyMessageCreateWithLexer)(doc, code, level, action, buf ); return TY_(tidyMessageCreateWithLexer)(doc, code, level, action, buf );
@ -554,6 +563,13 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
return TY_(tidyMessageCreateWithLexer)(doc, code, TidyWarning, entityname); return TY_(tidyMessageCreateWithLexer)(doc, code, TidyWarning, entityname);
} }
case MISSING_ATTRIBUTE:
{
ctmbstr name;
if ( (name = va_arg( args, ctmbstr)) )
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, nodedesc, name );
}
case SPACE_PRECEDING_XMLDECL: case SPACE_PRECEDING_XMLDECL:
/* @TODO: Should this be a TidyInfo "silent" fix? */ /* @TODO: Should this be a TidyInfo "silent" fix? */
return TY_(tidyMessageCreateWithNode)(doc, node, code, level ); return TY_(tidyMessageCreateWithNode)(doc, node, code, level );
@ -778,6 +794,18 @@ void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarde
TY_(Report)( doc, NULL, NULL, code, c, discarded ); TY_(Report)( doc, NULL, NULL, code, c, discarded );
} }
void TY_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding)
{
/* va_list in formatter expects trailing `no` argument */
TY_(Report)( doc, NULL, NULL, code, encoding, no );
}
void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name )
{
TY_(Report)( doc, NULL, node, MISSING_ATTRIBUTE, name );
}
/********************************************************************* /*********************************************************************
* Legacy High Level Message Writing Functions - Specific * Legacy High Level Message Writing Functions - Specific
@ -788,25 +816,6 @@ void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarde
*********************************************************************/ *********************************************************************/
void TY_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding)
{
TidyMessageImpl *message = NULL;
switch(code)
{
case ENCODING_MISMATCH:
message = TY_(tidyMessageCreateWithLexer)(doc,
code,
TidyWarning,
TY_(CharEncodingName)(doc->docIn->encoding),
TY_(CharEncodingName)(encoding));
doc->badChars |= BC_ENCODING_MISMATCH; /* @todo: why not in calling function? */
break;
}
messageOut( message );
}
void TY_(ReportMarkupVersion)( TidyDocImpl* doc ) void TY_(ReportMarkupVersion)( TidyDocImpl* doc )
{ {
TidyMessageImpl *message = NULL; TidyMessageImpl *message = NULL;
@ -846,17 +855,6 @@ void TY_(ReportMarkupVersion)( TidyDocImpl* doc )
} }
void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name )
{
TidyMessageImpl *message = NULL;
char tagdesc[ 64 ];
TagToString(node, tagdesc, sizeof(tagdesc));
message = TY_(tidyMessageCreateWithNode)(doc, node, MISSING_ATTRIBUTE, TidyWarning, tagdesc, name );
messageOut(message);
}
void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2) void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2)
{ {
TidyMessageImpl *message = NULL; TidyMessageImpl *message = NULL;

View file

@ -60,6 +60,8 @@ void TY_(ReportBadArgument)( TidyDocImpl* doc, ctmbstr option );
void TY_(ReportEntityError)( TidyDocImpl* doc, uint code, ctmbstr entity, int c ); void TY_(ReportEntityError)( TidyDocImpl* doc, uint code, ctmbstr entity, int c );
void TY_(ReportFileError)( TidyDocImpl* doc, ctmbstr file, uint code ); void TY_(ReportFileError)( TidyDocImpl* doc, ctmbstr file, uint code );
void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarded); void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarded);
void TY_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding);
void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name );
/** @} */ /** @} */
@ -67,9 +69,7 @@ void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarde
/** @{ */ /** @{ */
void TY_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding);
void TY_(ReportMarkupVersion)( TidyDocImpl* doc ); 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); void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2);
void TY_(ReportUnknownOption)( TidyDocImpl* doc, ctmbstr option ); void TY_(ReportUnknownOption)( TidyDocImpl* doc, ctmbstr option );