Skip to content

Commit

Permalink
Zero return status code when all errors & warnings have been muted - c…
Browse files Browse the repository at this point in the history
…lose #933
  • Loading branch information
Lucas-C committed Mar 31, 2021
1 parent 8e70d4d commit 6e8ec58
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions console/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2544,8 +2544,8 @@ int main( int argc, char** argv )
}
}

contentErrors += tidyErrorCount( tdoc );
contentWarnings += tidyWarningCount( tdoc );
contentErrors += tidyErrorCount( tdoc ) - tidyMutedErrorCount( tdoc );
contentWarnings += tidyWarningCount( tdoc ) - tidyMutedWarningCount( tdoc );
accessWarnings += tidyAccessWarningCount( tdoc );

--argc;
Expand Down
12 changes: 12 additions & 0 deletions include/tidy.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,24 @@ TIDY_EXPORT Bool TIDY_CALL tidyDetectedGenericXml( TidyDoc tdoc );
*/
TIDY_EXPORT uint TIDY_CALL tidyErrorCount( TidyDoc tdoc );

/** Indicates the number of error messages muted, that won't be output.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of muted error messages.
*/
TIDY_EXPORT uint TIDY_CALL tidyMutedErrorCount( TidyDoc tdoc );

/** Indicates the number of TidyWarning messages that were generated.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of TidyWarning messages that were generated.
*/
TIDY_EXPORT uint TIDY_CALL tidyWarningCount( TidyDoc tdoc );

/** Indicates the number of warning messages muted, that won't be output.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of muted warning messages.
*/
TIDY_EXPORT uint TIDY_CALL tidyMutedWarningCount( TidyDoc tdoc );

/** Indicates the number of TidyAccess messages that were generated.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of TidyAccess messages that were generated.
Expand Down
4 changes: 4 additions & 0 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ static void messageOut( TidyMessageImpl *message )
break;
case TidyWarning:
doc->warnings++;
if ( message->muted )
doc->mutedWarningCount++;
break;
case TidyConfig:
doc->optionErrors++;
Expand All @@ -142,6 +144,8 @@ static void messageOut( TidyMessageImpl *message )
break;
case TidyError:
doc->errors++;
if ( message->muted )
doc->mutedErrorCount++;
break;
case TidyBadDocument:
doc->docErrors++;
Expand Down
2 changes: 2 additions & 0 deletions src/tidy-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ struct _TidyDocImpl
/* Parse + Repair Results */
uint optionErrors;
uint errors;
uint mutedErrorCount;
uint warnings;
uint mutedWarningCount;
uint accessErrors;
uint infoMessages;
uint docErrors;
Expand Down
16 changes: 16 additions & 0 deletions src/tidylib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,14 @@ uint TIDY_CALL tidyErrorCount( TidyDoc tdoc )
count = impl->errors;
return count;
}
uint TIDY_CALL tidyMutedErrorCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
uint count = 0xFFFFFFFF;
if ( impl )
count = impl->mutedErrorCount;
return count;
}
uint TIDY_CALL tidyWarningCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
Expand All @@ -1052,6 +1060,14 @@ uint TIDY_CALL tidyWarningCount( TidyDoc tdoc )
count = impl->warnings;
return count;
}
uint TIDY_CALL tidyMutedWarningCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
uint count = 0xFFFFFFFF;
if ( impl )
count = impl->mutedWarningCount;
return count;
}
uint TIDY_CALL tidyAccessWarningCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
Expand Down

0 comments on commit 6e8ec58

Please sign in to comment.