Implement TidyReportFilter2 using raw strings to support library localization.

This commit is contained in:
Jim Derry 2014-04-27 16:07:20 +08:00
parent 0cf6d99843
commit 5786a5afb5
4 changed files with 27 additions and 3 deletions

6
include/tidy.h Normal file → Executable file
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,
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 */

5
src/localize.c Normal file → Executable file
View file

@ -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 )

1
src/tidy-int.h Normal file → Executable file
View file

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

12
src/tidylib.c Normal file → Executable file
View file

@ -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 )
{