Migrated surrogate errors; removed break after return.

This commit is contained in:
Jim Derry 2017-09-04 16:38:07 -04:00
parent 5b6edb5813
commit bc4388e317
2 changed files with 39 additions and 38 deletions

View file

@ -264,9 +264,9 @@ static struct _dispatchTable {
{ BAD_ATTRIBUTE_VALUE, TidyWarning, formatAttributeReport }, { BAD_ATTRIBUTE_VALUE, TidyWarning, formatAttributeReport },
{ BAD_CDATA_CONTENT, TidyWarning, formatStandard }, { BAD_CDATA_CONTENT, TidyWarning, formatStandard },
{ BAD_SUMMARY_HTML5, TidyWarning, formatStandard }, { BAD_SUMMARY_HTML5, TidyWarning, formatStandard },
{ BAD_SURROGATE_LEAD, TidyWarning, NULL }, { BAD_SURROGATE_LEAD, TidyWarning, formatStandard },
{ BAD_SURROGATE_PAIR, TidyWarning, NULL }, { BAD_SURROGATE_PAIR, TidyWarning, formatStandard },
{ BAD_SURROGATE_TAIL, TidyWarning, NULL }, { BAD_SURROGATE_TAIL, TidyWarning, formatStandard },
{ CANT_BE_NESTED, TidyWarning, formatStandard }, { CANT_BE_NESTED, TidyWarning, formatStandard },
{ COERCE_TO_ENDTAG, TidyWarning, formatStandard }, { COERCE_TO_ENDTAG, TidyWarning, formatStandard },
{ CONTENT_AFTER_BODY, TidyWarning, formatStandard }, { CONTENT_AFTER_BODY, TidyWarning, formatStandard },
@ -329,6 +329,7 @@ static struct _dispatchTable {
{ REPLACING_UNEX_ELEMENT, TidyWarning, formatStandard }, { REPLACING_UNEX_ELEMENT, TidyWarning, formatStandard },
{ SPACE_PRECEDING_XMLDECL, TidyWarning, formatStandard }, { SPACE_PRECEDING_XMLDECL, TidyWarning, formatStandard },
{ STRING_MISSING_MALFORMED, TidyConfig, formatStandard }, { STRING_MISSING_MALFORMED, TidyConfig, formatStandard },
{ STRING_UNKNOWN_OPTION, TidyConfig, formatStandard },
{ SUSPECTED_MISSING_QUOTE, TidyError, formatStandard }, { SUSPECTED_MISSING_QUOTE, TidyError, formatStandard },
{ TAG_NOT_ALLOWED_IN, TidyWarning, formatStandard, PREVIOUS_LOCATION }, { TAG_NOT_ALLOWED_IN, TidyWarning, formatStandard, PREVIOUS_LOCATION },
{ TOO_MANY_ELEMENTS_IN, TidyWarning, formatStandard, PREVIOUS_LOCATION }, { TOO_MANY_ELEMENTS_IN, TidyWarning, formatStandard, PREVIOUS_LOCATION },
@ -536,7 +537,7 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
tagtype = tidyLocalizedString( TIDYCUSTOMPRE_STRING ); tagtype = tidyLocalizedString( TIDYCUSTOMPRE_STRING );
break; break;
} }
return TY_(tidyMessageCreateWithNode)(doc, element, code, TidyInfo, elemdesc, tagtype ); return TY_(tidyMessageCreateWithNode)(doc, element, code, level, elemdesc, tagtype );
} }
case FILE_CANT_OPEN: case FILE_CANT_OPEN:
@ -547,7 +548,8 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
ctmbstr str; ctmbstr str;
if ( (str = va_arg( args, ctmbstr)) ) if ( (str = va_arg( args, ctmbstr)) )
return TY_(tidyMessageCreate)( doc, code, level, str ); return TY_(tidyMessageCreate)( doc, code, level, str );
}
} break;
case APOS_UNDEFINED: case APOS_UNDEFINED:
case MISSING_SEMICOLON_NCR: case MISSING_SEMICOLON_NCR:
@ -560,7 +562,7 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
{ {
entityname = "NULL"; entityname = "NULL";
} }
return TY_(tidyMessageCreateWithLexer)(doc, code, TidyWarning, entityname); return TY_(tidyMessageCreateWithLexer)(doc, code, level, entityname);
} }
case MISSING_ATTRIBUTE: case MISSING_ATTRIBUTE:
@ -568,19 +570,33 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
ctmbstr name; ctmbstr name;
if ( (name = va_arg( args, ctmbstr)) ) if ( (name = va_arg( args, ctmbstr)) )
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, nodedesc, name ); return TY_(tidyMessageCreateWithNode)(doc, node, code, level, nodedesc, name );
} break;
case STRING_UNKNOWN_OPTION:
{
ctmbstr str;
if ( (str = va_arg( args, ctmbstr)) )
return TY_(tidyMessageCreateWithLexer)(doc, code, level, str);
} break;
case BAD_SURROGATE_LEAD:
case BAD_SURROGATE_PAIR:
case BAD_SURROGATE_TAIL:
{
uint c1 = va_arg( args, uint );
uint c2 = va_arg( args, uint );
return TY_(tidyMessageCreateWithLexer)(doc, code, level, c1, c2);
} }
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 );
break;
case CANT_BE_NESTED: case CANT_BE_NESTED:
case NOFRAMES_CONTENT: case NOFRAMES_CONTENT:
case USING_BR_INPLACE_OF: case USING_BR_INPLACE_OF:
/* Can we use `rpt` here? No; `element` has a value in every case. */ /* Can we use `rpt` here? No; `element` has a value in every case. */
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, nodedesc ); return TY_(tidyMessageCreateWithNode)(doc, node, code, level, nodedesc );
break;
case ELEMENT_VERS_MISMATCH_ERROR: case ELEMENT_VERS_MISMATCH_ERROR:
case ELEMENT_VERS_MISMATCH_WARN: case ELEMENT_VERS_MISMATCH_WARN:
@ -589,7 +605,6 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
case TAG_NOT_ALLOWED_IN: case TAG_NOT_ALLOWED_IN:
/* Can we use `rpt` here? No; `element` has a value in every case. */ /* Can we use `rpt` here? No; `element` has a value in every case. */
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, nodedesc, element->element ); return TY_(tidyMessageCreateWithNode)(doc, node, code, level, nodedesc, element->element );
break;
case INSERTING_TAG: case INSERTING_TAG:
case MISSING_STARTTAG: case MISSING_STARTTAG:
@ -598,12 +613,10 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
case UNEXPECTED_ENDTAG_ERR: /* generated by XML docs */ case UNEXPECTED_ENDTAG_ERR: /* generated by XML docs */
/* Can we use `rpt` here? No; `element` has a value in every case. */ /* Can we use `rpt` here? No; `element` has a value in every case. */
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, node->element ); return TY_(tidyMessageCreateWithNode)(doc, node, code, level, node->element );
break;
case UNEXPECTED_ENDTAG_IN: case UNEXPECTED_ENDTAG_IN:
/* Can we use `rpt` here? No; `element` has a value in every case. */ /* Can we use `rpt` here? No; `element` has a value in every case. */
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, node->element, element->element ); return TY_(tidyMessageCreateWithNode)(doc, node, code, level, node->element, element->element );
break;
case BAD_CDATA_CONTENT: case BAD_CDATA_CONTENT:
case CONTENT_AFTER_BODY: case CONTENT_AFTER_BODY:
@ -617,7 +630,6 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
case SUSPECTED_MISSING_QUOTE: case SUSPECTED_MISSING_QUOTE:
case XML_DECLARATION_DETECTED: case XML_DECLARATION_DETECTED:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level );
break;
case ELEMENT_NOT_EMPTY: case ELEMENT_NOT_EMPTY:
case FOUND_STYLE_IN_BODY: case FOUND_STYLE_IN_BODY:
@ -626,13 +638,11 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
case TRIM_EMPTY_ELEMENT: case TRIM_EMPTY_ELEMENT:
case UNEXPECTED_END_OF_FILE: case UNEXPECTED_END_OF_FILE:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, elemdesc ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, elemdesc );
break;
case OBSOLETE_ELEMENT: case OBSOLETE_ELEMENT:
case REPLACING_ELEMENT: case REPLACING_ELEMENT:
case REPLACING_UNEX_ELEMENT: case REPLACING_UNEX_ELEMENT:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, elemdesc, nodedesc ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, elemdesc, nodedesc );
break;
case ADDED_MISSING_CHARSET: case ADDED_MISSING_CHARSET:
case BAD_SUMMARY_HTML5: case BAD_SUMMARY_HTML5:
@ -642,22 +652,18 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
case UNKNOWN_ELEMENT: case UNKNOWN_ELEMENT:
case UNKNOWN_ELEMENT_LOOKS_CUSTOM: case UNKNOWN_ELEMENT_LOOKS_CUSTOM:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, nodedesc ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, nodedesc );
break;
case MISSING_ENDTAG_FOR: case MISSING_ENDTAG_FOR:
case PREVIOUS_LOCATION: case PREVIOUS_LOCATION:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, element->element ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, element->element );
break;
case MISSING_ENDTAG_BEFORE: case MISSING_ENDTAG_BEFORE:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, element->element, nodedesc ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, element->element, nodedesc );
break;
case COERCE_TO_ENDTAG: case COERCE_TO_ENDTAG:
case NON_MATCHING_ENDTAG: case NON_MATCHING_ENDTAG:
case TOO_MANY_ELEMENTS_IN: case TOO_MANY_ELEMENTS_IN:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, node->element, node->element ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level, node->element, node->element );
break;
} }
return NULL; return NULL;
@ -807,6 +813,19 @@ void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name )
} }
void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2)
{
TY_(Report)( doc, NULL, NULL, code, c1,c2 );
}
void TY_(ReportUnknownOption)( TidyDocImpl* doc, ctmbstr option )
{
/* lexer is not defined when this is called */
TY_(Report)( doc, NULL, NULL, STRING_UNKNOWN_OPTION, option );
}
/********************************************************************* /*********************************************************************
* Legacy High Level Message Writing Functions - Specific * Legacy High Level Message Writing Functions - Specific
* When adding new reports to LibTidy, preference should be given * When adding new reports to LibTidy, preference should be given
@ -855,24 +874,6 @@ void TY_(ReportMarkupVersion)( TidyDocImpl* doc )
} }
void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2)
{
TidyMessageImpl *message = NULL;
message = TY_(tidyMessageCreateWithLexer)(doc, code, TidyWarning, c1, c2);
messageOut(message);
}
/* lexer is not defined when this is called */
void TY_(ReportUnknownOption)( TidyDocImpl* doc, ctmbstr option )
{
TidyMessageImpl *message = NULL;
assert( option != NULL );
message = TY_(tidyMessageCreateWithLexer)(doc, STRING_UNKNOWN_OPTION, TidyConfig, option);
messageOut(message);
}
/********************************************************************* /*********************************************************************
* Output Dialogue Information * Output Dialogue Information
* In addition to reports that are added to the table, Tidy emits * In addition to reports that are added to the table, Tidy emits

View file

@ -62,6 +62,8 @@ 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_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding);
void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name ); void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name );
void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2);
void TY_(ReportUnknownOption)( TidyDocImpl* doc, ctmbstr option );
/** @} */ /** @} */
@ -70,8 +72,6 @@ void TY_(ReportMissingAttr)( TidyDocImpl* doc, Node* node, ctmbstr name );
void TY_(ReportMarkupVersion)( TidyDocImpl* doc ); void TY_(ReportMarkupVersion)( TidyDocImpl* doc );
void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2);
void TY_(ReportUnknownOption)( TidyDocImpl* doc, ctmbstr option );
#if SUPPORT_ACCESSIBILITY_CHECKS #if SUPPORT_ACCESSIBILITY_CHECKS