Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6e8ec58

Browse files
committedMar 31, 2021
Zero return status code when all errors & warnings have been muted - close #933
1 parent 8e70d4d commit 6e8ec58

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed
 

‎console/tidy.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2544,8 +2544,8 @@ int main( int argc, char** argv )
25442544
}
25452545
}
25462546

2547-
contentErrors += tidyErrorCount( tdoc );
2548-
contentWarnings += tidyWarningCount( tdoc );
2547+
contentErrors += tidyErrorCount( tdoc ) - tidyMutedErrorCount( tdoc );
2548+
contentWarnings += tidyWarningCount( tdoc ) - tidyMutedWarningCount( tdoc );
25492549
accessWarnings += tidyAccessWarningCount( tdoc );
25502550

25512551
--argc;

‎include/tidy.h

+12
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,24 @@ TIDY_EXPORT Bool TIDY_CALL tidyDetectedGenericXml( TidyDoc tdoc );
444444
*/
445445
TIDY_EXPORT uint TIDY_CALL tidyErrorCount( TidyDoc tdoc );
446446

447+
/** Indicates the number of error messages muted, that won't be output.
448+
** @param tdoc An instance of a TidyDoc to query.
449+
** @result Returns the number of muted error messages.
450+
*/
451+
TIDY_EXPORT uint TIDY_CALL tidyMutedErrorCount( TidyDoc tdoc );
452+
447453
/** Indicates the number of TidyWarning messages that were generated.
448454
** @param tdoc An instance of a TidyDoc to query.
449455
** @result Returns the number of TidyWarning messages that were generated.
450456
*/
451457
TIDY_EXPORT uint TIDY_CALL tidyWarningCount( TidyDoc tdoc );
452458

459+
/** Indicates the number of warning messages muted, that won't be output.
460+
** @param tdoc An instance of a TidyDoc to query.
461+
** @result Returns the number of muted warning messages.
462+
*/
463+
TIDY_EXPORT uint TIDY_CALL tidyMutedWarningCount( TidyDoc tdoc );
464+
453465
/** Indicates the number of TidyAccess messages that were generated.
454466
** @param tdoc An instance of a TidyDoc to query.
455467
** @result Returns the number of TidyAccess messages that were generated.

‎src/message.c

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ static void messageOut( TidyMessageImpl *message )
133133
break;
134134
case TidyWarning:
135135
doc->warnings++;
136+
if ( message->muted )
137+
doc->mutedWarningCount++;
136138
break;
137139
case TidyConfig:
138140
doc->optionErrors++;
@@ -142,6 +144,8 @@ static void messageOut( TidyMessageImpl *message )
142144
break;
143145
case TidyError:
144146
doc->errors++;
147+
if ( message->muted )
148+
doc->mutedErrorCount++;
145149
break;
146150
case TidyBadDocument:
147151
doc->docErrors++;

‎src/tidy-int.h

+2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ struct _TidyDocImpl
6565
/* Parse + Repair Results */
6666
uint optionErrors;
6767
uint errors;
68+
uint mutedErrorCount;
6869
uint warnings;
70+
uint mutedWarningCount;
6971
uint accessErrors;
7072
uint infoMessages;
7173
uint docErrors;

‎src/tidylib.c

+16
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,14 @@ uint TIDY_CALL tidyErrorCount( TidyDoc tdoc )
10441044
count = impl->errors;
10451045
return count;
10461046
}
1047+
uint TIDY_CALL tidyMutedErrorCount( TidyDoc tdoc )
1048+
{
1049+
TidyDocImpl* impl = tidyDocToImpl( tdoc );
1050+
uint count = 0xFFFFFFFF;
1051+
if ( impl )
1052+
count = impl->mutedErrorCount;
1053+
return count;
1054+
}
10471055
uint TIDY_CALL tidyWarningCount( TidyDoc tdoc )
10481056
{
10491057
TidyDocImpl* impl = tidyDocToImpl( tdoc );
@@ -1052,6 +1060,14 @@ uint TIDY_CALL tidyWarningCount( TidyDoc tdoc )
10521060
count = impl->warnings;
10531061
return count;
10541062
}
1063+
uint TIDY_CALL tidyMutedWarningCount( TidyDoc tdoc )
1064+
{
1065+
TidyDocImpl* impl = tidyDocToImpl( tdoc );
1066+
uint count = 0xFFFFFFFF;
1067+
if ( impl )
1068+
count = impl->mutedWarningCount;
1069+
return count;
1070+
}
10551071
uint TIDY_CALL tidyAccessWarningCount( TidyDoc tdoc )
10561072
{
10571073
TidyDocImpl* impl = tidyDocToImpl( tdoc );

0 commit comments

Comments
 (0)
Please sign in to comment.