summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2007-02-02 02:55:11 +0000
committerEric Blake <ebb9@byu.net>2007-09-21 15:39:25 -0600
commit2227ee0fe9ad8b259d22fe438ca0de477b3f540a (patch)
tree604896d7ae9c086cd4b4507f6ef088b012240ad0
parent659c6ff0940188a56bd5cc23a30977f52313fd50 (diff)
downloadm4-2227ee0fe9ad8b259d22fe438ca0de477b3f540a.tar.gz
* src/m4.c (fatal_warnings): New variable.
(usage): Document new -E behavior. (main): Make -E an additive option. (m4_error, m4_error_at_line): Change exit status when required. * NEWS: Document this change. * doc/m4.texinfo (Operation modes): Likewise. Reported by Ralf Wildenhues.
-rw-r--r--ChangeLog10
-rw-r--r--NEWS5
-rw-r--r--doc/m4.texinfo10
-rw-r--r--src/m4.c26
4 files changed, 41 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a9d2a393..1f2dece9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-02-01 Eric Blake <ebb9@byu.net>
+
+ * src/m4.c (fatal_warnings): New variable.
+ (usage): Document new -E behavior.
+ (main): Make -E an additive option.
+ (m4_error, m4_error_at_line): Change exit status when required.
+ * NEWS: Document this change.
+ * doc/m4.texinfo (Operation modes): Likewise.
+ Reported by Ralf Wildenhues.
+
2007-01-27 Eric Blake <ebb9@byu.net>
* src/m4.h (warn_syntax): Declare.
diff --git a/NEWS b/NEWS
index 17cd0e34..427fad18 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,11 @@ Version 1.4.9 - ?? ??? 2007, by ???? (CVS version 1.4.8a)
of variable assignment as an extension.
* The `include' builtin now affects exit status on failure, as required by
POSIX. Use `sinclude' if you need a successful exit status.
+* The `-E'/`--fatal-warnings' command-line option now has two levels. When
+ specified only once, warnings affect exit status, but execution
+ continues, so that you can see all warnings instead of fixing them one
+ at a time. To acheive 1.4.8 behavior, where the first warning
+ immediately exits, specify -E twice on the command line.
* A new `--warn-syntax' command-line option allows detection of
non-portable syntax that might be broken when upgrading to M4 2.0. For
example, POSIX requires a macro definition containing `$11' to expand to
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 3c3a08bf..5460be26 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -551,8 +551,14 @@ performing any other actions.
@item -E
@itemx --fatal-warnings
-Stop execution and exit @code{m4} once the first warning or error has
-been issued, considering all of them to be fatal.
+Controls the effect of warnings. If unspecified, then execution
+continues and exit status is unaffected when a warning is printed. If
+specified exactly once, warnings become fatal; when one is issued,
+execution continues, but the exit status will be non-zero. If specified
+multiple times, then execution halts with non-zero status the first time
+a warning is issued. The introduction of behavior levels is new to M4
+1.4.9; for behavior consistent with earlier versions, you should specify
+@option{-E} twice.
@item -i
@itemx --interactive
diff --git a/src/m4.c b/src/m4.c
index 3067dcac..ad1de1dc 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -52,6 +52,9 @@ int max_debug_argument_length = 0;
/* 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 @@ const char *user_word_regexp = "";
/* 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 @@ m4_error (int status, int errnum, const char *format, ...)
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 @@ m4_error_at_line (int status, int errnum, const char *file, int line,
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 @@ Operation modes:\n\
--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 @@ static const struct option long_options[] =
{ 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,7 +396,10 @@ main (int argc, char *const *argv, char *const *envp)
break;
case 'E':
- warning_status = EXIT_FAILURE;
+ if (! fatal_warnings)
+ fatal_warnings = true;
+ else
+ warning_status = EXIT_FAILURE;
break;
case 'F':
@@ -543,8 +554,7 @@ main (int argc, char *const *argv, char *const *envp)
break;
default:
- M4ERROR ((warning_status, 0,
- "INTERNAL ERROR: bad code in deferred arguments"));
+ M4ERROR ((0, 0, "INTERNAL ERROR: bad code in deferred arguments"));
abort ();
}