diff options
author | Eric Blake <ebb9@byu.net> | 2008-12-23 07:32:28 -0700 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2008-12-23 08:27:55 -0700 |
commit | 180376508cd4345812278d896024a3f3cd5746d1 (patch) | |
tree | 896111c4446586b8daf1273b693b5a66e7c9649a | |
parent | c8b753e292542bcda27b335a6b4d2e7f4eb85c9e (diff) | |
download | m4-180376508cd4345812278d896024a3f3cd5746d1.tar.gz |
Make --debugfile argument optional.
* src/main.c (long_options): Make the argument optional, to allow
setting debug file back to stderr.
(main): Make --debugfile order-dependent.
(usage): Document this.
* doc/m4.texinfo (Debugging options): Likewise.
* NEWS: Likewise.
* tests/options.at (--debugfile): Enhance test.
(--safer): Adjust to new semantics.
Signed-off-by: Eric Blake <ebb9@byu.net>
(cherry picked from commit c59c67993219ec04965b1347b44a7e3d09ff425c)
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | NEWS | 31 | ||||
-rw-r--r-- | doc/m4.texinfo | 15 | ||||
-rw-r--r-- | src/main.c | 31 | ||||
-rw-r--r-- | tests/options.at | 16 |
5 files changed, 77 insertions, 28 deletions
@@ -1,3 +1,15 @@ +2008-12-23 Eric Blake <ebb9@byu.net> + + Make --debugfile argument optional. + * src/main.c (long_options): Make the argument optional, to allow + setting debug file back to stderr. + (main): Make --debugfile order-dependent. + (usage): Document this. + * doc/m4.texinfo (Debugging options): Likewise. + * NEWS: Likewise. + * tests/options.at (--debugfile): Enhance test. + (--safer): Adjust to new semantics. + 2008-12-22 Eric Blake <ebb9@byu.net> Use @var correctly. @@ -251,24 +251,12 @@ promoted to 2.0. `-d-V' to disable prior debug settings from the command line, similar to using the builtin `debugmode' without arguments. The option `--debugmode' is added as an alias for `-d'. The new flag `d' is added - to control whether dereferncing an undefined macro causes a warning; + to control whether dereferencing an undefined macro causes a warning; this flag is enabled by default if neither `-d' nor `-E' are specified. When given the empty string, the mode is treated as `+adeq' instead of `aeq'. Also, the position of `-d' with respect to files on the command line is now significant. -** New `-g'/`--gnu' command-line option overrides `-G'/`--traditional'. - For now, the environment variable POSIXLY_CORRECT has no effect on M4 - behavior; but a future release of M4 will behave as though --traditional - is implied if POSIXLY_CORRECT is set (this future change is necessary, - because in the current release, there is no way to disable GNU - extensions that conflict with POSIX without the use of a non-POSIX - command-line argument). Clients of M4 that want to use GNU extensions, - even when POSIXLY_CORRECT is set, should start using the -g command-line - argument, even though it is currently a no-op if -G did not appear - earlier in the command line, so that the client will not break in the - face of an upgraded m4 and a POSIXLY_CORRECT execution environment. - ** A new predefined text macro, `__m4_version__', expands to the unquoted version number of M4, if GNU extensions are enabled. While you should generally favor feature tests over version number checks, this macro can @@ -334,6 +322,23 @@ contains the following beta features that were deemed worth deferring until ** A number of portability improvements inherited from gnulib. +* Noteworthy changes in Version 1.4.13 (2008-12-??) [stable] + Released by Eric Blake, based on git version 1.4.12.* + +** The manual is now distributed under the terms of FDL 1.3. + +** The `divert' and `undivert' builtins have been made more efficient + when using temporary files for large diversions. + +** The command line option `--debugfile', introduced in 1.4.7, now + treats its argument as optional, in order to allow setting the debug + output back to stderr when used without an argument; and order is now + significant with respect to command line files. You must therefore use + `m4 --debugfile=trace file', not `m4 file --debugfile trace'. This + change does not affect the deprecated `-o'/`--error-output' option. + +** A number of portability improvements inherited from gnulib. + * Noteworthy changes in Version 1.4.12 (2008-10-10) [stable] Released by Eric Blake, based on git version 1.4.11.* diff --git a/doc/m4.texinfo b/doc/m4.texinfo index a2eda21a..121300f6 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -856,7 +856,7 @@ redefining the same @var{name} adds another definition to its stack. Short for @option{--syncoutput=1}, turning on synchronization lines (sometimes called @dfn{synclines}). -@item --syncoutput@r{[}=STATE@r{]} +@item --syncoutput@r{[}=@var{state}@r{]} @cindex synchronization lines @cindex location, input @cindex input location @@ -1024,15 +1024,18 @@ len(`123') @result{}3 @end example -@item --debugfile=@var{file} +@item --debugfile@r{[}=@var{file}@r{]} @itemx -o @var{file} @itemx --error-output=@var{file} Redirect debug and trace output to the named @var{file}. Warnings, error messages, and the output of @code{errprint} and @code{dumpdef}, -are still printed to standard error. If this option is not given, debug -output goes to standard error; if @var{file} is the empty string, debug -output is discarded. @xref{Debugfile}, for more details. The -spellings @option{-o} and @option{--error-output} are misleading and +are still printed to standard error. If these options are not used, or +if @var{file} is unspecified (only possible for @option{--debugfile}), +debug output goes to standard error; if @var{file} is the empty string, +debug output is discarded. @xref{Debugfile}, for more details. The +option @option{--debugfile} may be given more than once, and order is +significant with respect to file names. The spellings @option{-o} and +@option{--error-output} are misleading and inconsistent with other @acronym{GNU} tools; using those spellings will evoke a warning, and they may be withdrawn or change semantics in a future release. @@ -94,7 +94,7 @@ Operation modes:\n\ -b, --batch buffer output, process interrupts\n\ -c, --discard-comments do not copy comments to the output\n\ -E, --fatal-warnings once: warnings become errors, twice: stop\n\ - execution at first error\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\ @@ -112,10 +112,10 @@ SPEC is any one of:\n\ xprintf (_("\ Dynamic loading features:\n\ -M, --module-directory=DIR add DIR to module search path before\n\ - `%s'\n\ + %s\n\ -m, --load-module=MODULE load dynamic MODULE\n\ --unload-module=MODULE unload dynamic MODULE\n\ -"), PKGLIBEXECDIR); +"), quotearg_style (locale_quoting_style, PKGLIBEXECDIR)); puts (""); fputs (_("\ Preprocessor features:\n\ @@ -129,7 +129,7 @@ Preprocessor features:\n\ -p, --pushdef=NAME[=VALUE] pushdef NAME as having VALUE, or empty\n\ -s, --synclines short for --syncoutput=1\n\ --syncoutput[=STATE] set generation of `#line NUM \"FILE\"' lines\n\ - to STATE (0=off, 1=on, default 0 if omitted)\n\ + to STATE (0=off, 1=on, default 0)\n\ -U, --undefine=NAME undefine NAME\n\ "), stdout); puts (""); @@ -150,7 +150,8 @@ Frozen state files:\n\ Debugging:\n\ -d, --debug[=[-|+]FLAGS], --debugmode[=[-|+]FLAGS]\n\ set debug level (no FLAGS implies `+adeq')\n\ - --debugfile=FILE redirect debug and trace output\n\ + --debugfile[=FILE] redirect debug and trace output to FILE\n\ + (default stderr, discard if empty string)\n\ -l, --debuglen=NUM restrict macro tracing size\n\ -t, --trace=NAME, --traceon=NAME\n\ trace NAME when it is defined\n\ @@ -253,7 +254,7 @@ static const struct option long_options[] = {"warnings", no_argument, NULL, 'W'}, {"arglength", required_argument, NULL, ARGLENGTH_OPTION}, - {"debugfile", required_argument, NULL, DEBUGFILE_OPTION}, + {"debugfile", optional_argument, NULL, DEBUGFILE_OPTION}, {"hashsize", required_argument, NULL, HASHSIZE_OPTION}, {"error-output", required_argument, NULL, ERROR_OUTPUT_OPTION}, {"import-environment", no_argument, NULL, IMPORT_ENVIRONMENT_OPTION}, @@ -564,6 +565,15 @@ main (int argc, char *const *argv, char *const *envp) m4_set_max_debug_arg_length_opt (context, size); break; + case DEBUGFILE_OPTION: + /* Staggered handling of '--debugfile', since it is useful + prior to first file and prior to reloading, but other + uses must also have effect between files. */ + if (seen_file || frozen_file_to_read) + goto defer; + debugfile = optarg; + break; + case 'o': case ERROR_OUTPUT_OPTION: /* FIXME: -o is inconsistent with other tools' use of @@ -573,8 +583,6 @@ main (int argc, char *const *argv, char *const *envp) after 2.1. */ error (0, 0, _("Warning: `%s' is deprecated, use `%s' instead"), optchar == 'o' ? "-o" : "--error-output", "--debugfile"); - /* fall through */ - case DEBUGFILE_OPTION: /* Don't call m4_debug_set_output here, as it has side effects. */ debugfile = optarg; break; @@ -710,6 +718,13 @@ main (int argc, char *const *argv, char *const *envp) process_file (context, arg); break; + case DEBUGFILE_OPTION: + if (!m4_debug_set_output (context, NULL, arg)) + m4_error (context, 0, errno, NULL, _("cannot set debug file %s"), + quotearg_style (locale_quoting_style, + arg ? arg : _("stderr"))); + break; + case POPDEF_OPTION: { size_t len = strlen (arg); diff --git a/tests/options.at b/tests/options.at index dce43f87..48e5b036 100644 --- a/tests/options.at +++ b/tests/options.at @@ -312,6 +312,20 @@ AT_CHECK_M4([--debugfile=trace4 -dV in], [0], [[foo ]]) AT_CHECK([cat trace4], [0], [expout]) +dnl check that order matters +AT_DATA([in1], [[bar +]]) +AT_DATA([in2], [[errprint(`hi +')dnl +bar +]]) +AT_CHECK_M4([-Dbar=hello -tbar --debugfile= in1 --debugfile in2], [0], +[[hello +hello +]], [[hi +m4trace: -1- bar -> `hello' +]]) + AT_CLEANUP @@ -746,7 +760,7 @@ debugfile(`trace2') define(`foo', `2')foo ]]) -AT_CHECK_M4([--safer --debugfile trace1 -t foo in], [1], +AT_CHECK_M4([--safer --debugfile=trace1 -t foo in], [1], [[1 2 |