From 5786a5afb5d448cf2ee05b51f67240fedf072108 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Sun, 27 Apr 2014 16:07:20 +0800 Subject: [PATCH] Implement TidyReportFilter2 using raw strings to support library localization. --- include/tidy.h | 12 +++++++++--- src/localize.c | 5 +++++ src/tidy-int.h | 1 + src/tidylib.c | 12 ++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) mode change 100644 => 100755 include/tidy.h mode change 100644 => 100755 src/localize.c mode change 100644 => 100755 src/tidy-int.h mode change 100644 => 100755 src/tidylib.c diff --git a/include/tidy.h b/include/tidy.h old mode 100644 new mode 100755 index 8d72a07..c1adbce --- 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 */ @@ -852,7 +858,7 @@ TIDY_EXPORT uint TIDY_CALL tidyNodeColumn( TidyNode tnod ); /** @defgroup NodeIsElementName Deprecated node interrogation per TagId ** -** @deprecated The functions tidyNodeIs{ElementName} are deprecated and +** @deprecated The functions tidyNodeIs{ElementName} are deprecated and ** should be replaced by tidyNodeGetId. ** @{ */ @@ -954,7 +960,7 @@ TIDY_EXPORT Bool TIDY_CALL tidyAttrIsProp( TidyAttr tattr ); /** @defgroup AttrIsAttributeName Deprecated attribute interrogation per AttrId ** -** @deprecated The functions tidyAttrIs{AttributeName} are deprecated and +** @deprecated The functions tidyAttrIs{AttributeName} are deprecated and ** should be replaced by tidyAttrGetId. ** @{ */ @@ -1019,7 +1025,7 @@ TIDY_EXPORT TidyAttr TIDY_CALL tidyAttrGetById( TidyNode tnod, TidyAttrId attId /** @defgroup AttrGetAttributeName Deprecated attribute retrieval per AttrId ** -** @deprecated The functions tidyAttrGet{AttributeName} are deprecated and +** @deprecated The functions tidyAttrGet{AttributeName} are deprecated and ** should be replaced by tidyAttrGetById. ** For instance, tidyAttrGetID( TidyNode tnod ) can be replaced by ** tidyAttrGetById( TidyNode tnod, TidyAttr_ID ). This avoids a potential diff --git a/src/localize.c b/src/localize.c old mode 100644 new mode 100755 index 9fbf034..ab2b416 --- a/src/localize.c +++ b/src/localize.c @@ -1034,6 +1034,11 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level, TidyDoc tdoc = tidyImplToDoc( doc ); go = doc->mssgFilt( tdoc, level, line, col, messageBuf ); } + if ( doc->mssgFilt2 ) + { + TidyDoc tdoc = tidyImplToDoc( doc ); + go = doc->mssgFilt2( tdoc, level, line, col, msg, args ); + } } if ( go ) diff --git a/src/tidy-int.h b/src/tidy-int.h old mode 100644 new mode 100755 index a9bdf9a..6bc2a6f --- 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 old mode 100644 new mode 100755 index bb3b344..e3dbc31 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -649,6 +649,18 @@ 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 ) {