diff --git a/console/tidy.c b/console/tidy.c index 3a3d9ad8..45d51439 100644 --- a/console/tidy.c +++ b/console/tidy.c @@ -49,6 +49,8 @@ static FILE* errout = NULL; ** @{ */ +/** Fatal error count - like bad option, no files, etc - Exit -1 */ +static uint errorCount = 0; /* Is. #921 */ /* MARK: - Miscellaneous Utilities */ /***************************************************************************//** @@ -2123,6 +2125,7 @@ int main( int argc, char** argv ) if ( status != 0 ) { fprintf(errout, tidyLocalizedString( TC_MAIN_ERROR_LOAD_CONFIG ), TIDY_CONFIG_FILE, status); fprintf(errout, "\n"); + errorCount++; /* Is. #921 - config file failed */ } } #endif /* TIDY_CONFIG_FILE */ @@ -2133,6 +2136,7 @@ int main( int argc, char** argv ) if ( status != 0 ) { fprintf(errout, tidyLocalizedString( TC_MAIN_ERROR_LOAD_CONFIG ), cfgfil, status); fprintf(errout, "\n"); + errorCount++; /* Is. #921 - config file failed */ } } #ifdef TIDY_USER_CONFIG_FILE @@ -2142,6 +2146,7 @@ int main( int argc, char** argv ) if ( status != 0 ) { fprintf(errout, tidyLocalizedString( TC_MAIN_ERROR_LOAD_CONFIG ), TIDY_USER_CONFIG_FILE, status); fprintf(errout, "\n"); + errorCount++; /* Is. #921 - config file failed */ } } #endif /* TIDY_USER_CONFIG_FILE */ @@ -2479,6 +2484,7 @@ int main( int argc, char** argv ) default: unknownOption( tdoc, c ); + errorCount++; /* Is. #921 - option error */ break; } } @@ -2506,6 +2512,8 @@ int main( int argc, char** argv ) if ( tidyOptGetBool(tdoc, TidyEmacs) || tidyOptGetBool(tdoc, TidyShowFilename)) tidySetEmacsFile( tdoc, htmlfil ); status = tidyParseFile( tdoc, htmlfil ); + if (status < 0) /* Is. #921 - input file failed */ + errorCount++; } else { @@ -2547,6 +2555,7 @@ int main( int argc, char** argv ) contentErrors += tidyErrorCount( tdoc ); contentWarnings += tidyWarningCount( tdoc ); accessWarnings += tidyAccessWarningCount( tdoc ); + errorCount += tidyConfigErrorCount( tdoc); /* Is. #921 - config error are fatal */ --argc; ++argv; @@ -2568,8 +2577,16 @@ int main( int argc, char** argv ) /* called to free hash tables etc. */ tidyRelease( tdoc ); - + /* return status can be used by scripts */ + + /* Is. #921 - one, or more fatal errors */ + /* this can be many forms, from file does not exit, to an unknown option, + * or malformed option, etc ... + */ + if (errorCount > 0) + return 3; /* Is. #921 */ + if ( contentErrors > 0 ) return 2; diff --git a/src/config.c b/src/config.c index bae56b8f..3dd22a00 100644 --- a/src/config.c +++ b/src/config.c @@ -1581,7 +1581,10 @@ Bool ParsePickList( TidyDocImpl* doc, const TidyOptionImpl* entry ) return yes; } - TY_(ReportBadArgument)( doc, entry->name ); + /* Is. #921 - this service calls 'GetParsePickListValue', which already emits + * 'ReportBadArgument' if it fails, so eliminate this duplicate call + * TY_(ReportBadArgument)( doc, entry->name ); + */ return no; } diff --git a/src/message.c b/src/message.c index 8f6b1fb2..c14dbba0 100644 --- a/src/message.c +++ b/src/message.c @@ -169,7 +169,7 @@ static void messageOut( TidyMessageImpl *message ) go = go && message->code != STRING_CONTENT_LOOKS; go = go && message->code != STRING_NO_SYSID; go = go && message->level != TidyDialogueInfo; - go = go && message->level != TidyConfig; + /* go = go && message->level != TidyConfig; Is. #921 - these are errors, not informational! */ go = go && message->level != TidyInfo; go = go && !(message->level >= TidyDialogueSummary && message->code != STRING_NEEDS_INTERVENTION);