Added TidyReportFilter2

This commit is contained in:
Jim Derry 2014-11-22 15:43:11 +08:00
parent 6aaf826476
commit e279302eaf
4 changed files with 25 additions and 0 deletions

View file

@ -619,10 +619,16 @@ TIDY_EXPORT void TIDY_CALL tidyPutByte( TidyOutputSink* sink, uint byteValue );
typedef Bool (TIDY_CALL *TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl, typedef Bool (TIDY_CALL *TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl,
uint line, uint col, ctmbstr mssg ); uint line, uint col, ctmbstr mssg );
typedef Bool (TIDY_CALL *TidyReportFilter2)( TidyDoc tdoc, TidyReportLevel lvl,
uint line, uint col, ctmbstr mssg, va_list args );
/** Give Tidy a filter callback to use */ /** Give Tidy a filter callback to use */
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc, TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc,
TidyReportFilter filtCallback ); TidyReportFilter filtCallback );
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc,
TidyReportFilter2 filtCallback );
/** Set error sink to named file */ /** Set error sink to named file */
TIDY_EXPORT FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam ); TIDY_EXPORT FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam );
/** Set error sink to given buffer */ /** Set error sink to given buffer */

View file

@ -1035,12 +1035,19 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level,
if ( go ) if ( go )
{ {
va_list args_copy;
va_copy(args_copy, args);
TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args); TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args);
if ( doc->mssgFilt ) if ( doc->mssgFilt )
{ {
TidyDoc tdoc = tidyImplToDoc( doc ); TidyDoc tdoc = tidyImplToDoc( doc );
go = doc->mssgFilt( tdoc, level, line, col, messageBuf ); go = doc->mssgFilt( tdoc, level, line, col, messageBuf );
} }
if ( doc->mssgFilt2 )
{
TidyDoc tdoc = tidyImplToDoc( doc );
go = go | doc->mssgFilt2( tdoc, level, line, col, msg, args_copy );
}
} }
if ( go ) if ( go )

View file

@ -48,6 +48,7 @@ struct _TidyDocImpl
StreamOut* docOut; StreamOut* docOut;
StreamOut* errout; StreamOut* errout;
TidyReportFilter mssgFilt; TidyReportFilter mssgFilt;
TidyReportFilter2 mssgFilt2;
TidyOptCallback pOptCallback; TidyOptCallback pOptCallback;
/* Parse + Repair Results */ /* Parse + Repair Results */

View file

@ -650,6 +650,17 @@ Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc, TidyReportFilter filt )
return no; return no;
} }
Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc, TidyReportFilter2 filt )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
if ( impl )
{
impl->mssgFilt2 = filt;
return yes;
}
return no;
}
#if 0 /* Not yet */ #if 0 /* Not yet */
int tidySetContentOutputSink( TidyDoc tdoc, TidyOutputSink* outp ) int tidySetContentOutputSink( TidyDoc tdoc, TidyOutputSink* outp )
{ {