Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #921 - warning for unknown config, and others... #931

Open
wants to merge 5 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion console/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/***************************************************************************//**
Expand Down Expand Up @@ -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 */
Expand All @@ -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
Expand All @@ -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 */
Expand Down Expand Up @@ -2479,6 +2484,7 @@ int main( int argc, char** argv )

default:
unknownOption( tdoc, c );
errorCount++; /* Is. #921 - option error */
break;
}
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
5 changes: 4 additions & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down