CVSROOT: /sources/m4 Module name: m4 Branch: branch-1_4 Changes by: Eric Blake <ericb> 07/02/02 02:55:11
Index: src/m4.c =================================================================== RCS file: /sources/m4/m4/src/Attic/m4.c,v retrieving revision 1.1.1.1.2.42 retrieving revision 1.1.1.1.2.43 diff -u -b -r1.1.1.1.2.42 -r1.1.1.1.2.43 --- src/m4.c 28 Jan 2007 01:54:44 -0000 1.1.1.1.2.42 +++ src/m4.c 2 Feb 2007 02:55:11 -0000 1.1.1.1.2.43 @@ -52,6 +52,9 @@ /* Suppress warnings about missing arguments. */ int suppress_warnings = 0; +/* If true, then warnings affect exit status. */ +static bool fatal_warnings = false; + /* If not zero, then value of exit status for warning diagnostics. */ int warning_status = 0; @@ -69,6 +72,10 @@ /* The name this program was run with. */ const char *program_name; +/* Global catchall for any errors that should affect final error status, but + where we try to continue execution in the meantime. */ +int retcode; + struct macro_definition { struct macro_definition *next; @@ -90,6 +97,8 @@ va_start (args, format); verror_at_line (status, errnum, current_line ? current_file : NULL, current_line, format, args); + if (fatal_warnings && ! retcode) + retcode = EXIT_FAILURE; } /*-------------------------------. @@ -103,6 +112,8 @@ va_list args; va_start (args, format); verror_at_line (status, errnum, line ? file : NULL, line, format, args); + if (fatal_warnings && ! retcode) + retcode = EXIT_FAILURE; } #ifdef USE_STACKOVF @@ -147,7 +158,8 @@ --version output version information and exit\n\ ", stdout); fputs ("\ - -E, --fatal-warnings stop execution after first warning\n\ + -E, --fatal-warnings once: warnings become errors, twice: stop\n\ + execution at first error\n\ -i, --interactive unbuffer output, ignore interrupts\n\ -P, --prefix-builtins force a `m4_' prefix to all builtins\n\ -Q, --quiet, --silent suppress some warnings for builtins\n\ @@ -265,10 +277,6 @@ { NULL, 0, NULL, 0 }, }; -/* Global catchall for any errors that should affect final error status, but - where we try to continue execution in the meantime. */ -int retcode; - /* Process a command line file NAME, and return true only if it was stdin. */ static bool @@ -388,6 +396,9 @@ break; case 'E': + if (! fatal_warnings) + fatal_warnings = true; + else warning_status = EXIT_FAILURE; break; @@ -543,8 +554,7 @@ break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad code in deferred arguments")); + M4ERROR ((0, 0, "INTERNAL ERROR: bad code in deferred arguments")); abort (); }