From e279302eafe48e6327424d7996bff54831b5f59b Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Sat, 22 Nov 2014 15:43:11 +0800 Subject: [PATCH] Added TidyReportFilter2 --- include/tidy.h | 6 ++++++ src/localize.c | 7 +++++++ src/tidy-int.h | 1 + src/tidylib.c | 11 +++++++++++ 4 files changed, 25 insertions(+) diff --git a/include/tidy.h b/include/tidy.h index d6c68a7..0a7e678 100755 --- a/include/tidy.h +++ b/include/tidy.h @@ -619,10 +619,16 @@ TIDY_EXPORT void TIDY_CALL tidyPutByte( TidyOutputSink* sink, uint byteValue ); typedef Bool (TIDY_CALL *TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl, 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 */ TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc, TidyReportFilter filtCallback ); +TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc, + TidyReportFilter2 filtCallback ); + /** Set error sink to named file */ TIDY_EXPORT FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam ); /** Set error sink to given buffer */ diff --git a/src/localize.c b/src/localize.c index eb393be..f0133ed 100755 --- a/src/localize.c +++ b/src/localize.c @@ -1035,12 +1035,19 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level, if ( go ) { + va_list args_copy; + va_copy(args_copy, args); TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args); if ( doc->mssgFilt ) { TidyDoc tdoc = tidyImplToDoc( doc ); 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 ) diff --git a/src/tidy-int.h b/src/tidy-int.h index a9bdf9a..6bc2a6f 100755 --- a/src/tidy-int.h +++ b/src/tidy-int.h @@ -48,6 +48,7 @@ struct _TidyDocImpl StreamOut* docOut; StreamOut* errout; TidyReportFilter mssgFilt; + TidyReportFilter2 mssgFilt2; TidyOptCallback pOptCallback; /* Parse + Repair Results */ diff --git a/src/tidylib.c b/src/tidylib.c index e3d9f23..07378b3 100755 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -650,6 +650,17 @@ Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc, TidyReportFilter filt ) 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 */ int tidySetContentOutputSink( TidyDoc tdoc, TidyOutputSink* outp ) {