m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU M4 source repository branch, master, updated. cvs-readonly-180


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, master, updated. cvs-readonly-180-g268aa74
Date: Wed, 24 Dec 2008 03:27:04 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU M4 source repository".

http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=268aa74a4cd66160d4c589572294e50f455c2069

The branch, master has been updated
       via  268aa74a4cd66160d4c589572294e50f455c2069 (commit)
       via  180376508cd4345812278d896024a3f3cd5746d1 (commit)
      from  c8b753e292542bcda27b335a6b4d2e7f4eb85c9e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 268aa74a4cd66160d4c589572294e50f455c2069
Author: Eric Blake <address@hidden>
Date:   Tue Dec 23 14:40:57 2008 -0700

    Add debugmode(o) to control dumpdef output location.
    
    * m4/m4module.h (M4_DEBUG_TRACE_OUTPUT_DUMPDEF): New enumerator.
    (M4_DEBUG_TRACE_VERBOSE): Update.
    * m4/debug.c (m4_debug_decode): Support new debug option.
    * src/freeze.c (produce_debugmode_state): Likewise.
    * modules/m4.c (dumpdef): When set, force dumpdef to stderr rather
    than the debug file.
    * src/main.c (usage): Document it.
    * doc/m4.texinfo (Debugmode, Dumpdef, Debugging options)
    (Debugfile): Likewise.
    * NEWS: Likewise.
    Based on an autoconf bug report by Paolo Bonzini.
    
    Signed-off-by: Eric Blake <address@hidden>
    (cherry picked from commit df6bfeeaac6bdc1ef8e5406c6ac051af2c10d0d8)

commit 180376508cd4345812278d896024a3f3cd5746d1
Author: Eric Blake <address@hidden>
Date:   Tue Dec 23 07:32:28 2008 -0700

    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 <address@hidden>
    (cherry picked from commit c59c67993219ec04965b1347b44a7e3d09ff425c)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog        |   25 ++++++++++++++++
 NEWS             |   43 ++++++++++++++------------
 doc/m4.texinfo   |   85 ++++++++++++++++++++++++++++++++++++++++-------------
 m4/debug.c       |    4 ++
 m4/m4module.h    |    4 ++-
 modules/m4.c     |    6 +++-
 src/freeze.c     |    4 ++-
 src/main.c       |   32 +++++++++++++++-----
 tests/options.at |   16 +++++++++-
 9 files changed, 166 insertions(+), 53 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 11e31b2..4321384 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2008-12-23  Eric Blake  <address@hidden>
+
+       Add debugmode(o) to control dumpdef output location.
+       * m4/m4module.h (M4_DEBUG_TRACE_OUTPUT_DUMPDEF): New enumerator.
+       (M4_DEBUG_TRACE_VERBOSE): Update.
+       * m4/debug.c (m4_debug_decode): Support new debug option.
+       * src/freeze.c (produce_debugmode_state): Likewise.
+       * modules/m4.c (dumpdef): When set, force dumpdef to stderr rather
+       than the debug file.
+       * src/main.c (usage): Document it.
+       * doc/m4.texinfo (Debugmode, Dumpdef, Debugging options)
+       (Debugfile): Likewise.
+       * NEWS: Likewise.
+       Based on an autoconf bug report by Paolo Bonzini.
+
+       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  <address@hidden>
 
        Use @var correctly.
diff --git a/NEWS b/NEWS
index 618a8f2..4180190 100644
--- a/NEWS
+++ b/NEWS
@@ -157,10 +157,6 @@ promoted to 2.0.
     `dumpdef'.  The `c' flag has been updated to add information to the
     first line to show the definition of the macro being expanded.
 
-*** The `dumpdef' builtin now always outputs to standard error, rather than
-    the debug file specified by the `--debugfile' option or `debugfile'
-    macro.
-
 *** The `eval' and `mpeval' builtins now support the following new
     operators: `>>>', `\', `?:', and  `,'.
 
@@ -251,23 +247,13 @@ 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.
+   The new flag `o' is added to control whether `dumpdef' outputs to stderr
+   or the current `debugfile' location.  When the command line option is
+   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.
 
 ** A new predefined text macro, `__m4_version__', expands to the unquoted
    version number of M4, if GNU extensions are enabled.  While you should
@@ -334,6 +320,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 a2eda21..3d039f6 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}).
 
address@hidden address@hidden@r{]}
address@hidden address@hidden@address@hidden
 @cindex synchronization lines
 @cindex location, input
 @cindex input location
@@ -1024,15 +1024,20 @@ len(`123')
 @result{}3
 @end example
 
address@hidden address@hidden
address@hidden address@hidden@address@hidden
 @itemx -o @var{file}
 @itemx address@hidden
-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
+Redirect debug messages and trace output to the
+named @var{file}.  Warnings, error messages, and @code{errprint} output
+are still printed to standard error.  Output from @code{dumpdef} goes to
+this file when the debug level @code{o} is not set (@pxref{Debugmode}).
+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
address@hidden 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.
@@ -4071,14 +4076,13 @@ If you want to see what a name expands into, you can 
use the builtin
 @code{dumpdef}:
 
 @deffn {Builtin (m4)} dumpdef (@address@hidden)
-Accepts any number of arguments.  If called without any arguments,
-it displays the definitions of all known names, otherwise it displays
-the definitions of each @var{name} given.  The output is printed
-directly to standard error, independently of the @option{--debugfile}
-option (@pxref{Debugging options, , Invoking m4}), or @code{debugfile} macro.
-The output is sorted by name.  If a @var{name} is undefined, the
address@hidden debug level controls whether a warning is issued
-(@pxref{Debugmode}).
+Accepts any number of arguments.  If called without any arguments, it
+displays the definitions of all known names, otherwise it displays the
+definitions of each @var{name} given, sorted by name.  If a @var{name}
+is undefined, the @samp{d} debug level controls whether a warning is
+issued (@pxref{Debugmode}).  Likewise, the @samp{o} debug level controls
+whether the output is issued to standard error or the current debug
+file (@pxref{Debugfile}).
 
 The expansion of @code{dumpdef} is void.
 @end deffn
@@ -4488,6 +4492,11 @@ In debug output, print a message each time a module is 
manipulated
 and in dumpdef output, follow builtin macros with their module name,
 surrounded by braces (@address@hidden@}}).
 
address@hidden o
+Output @code{dumpdef} data to standard error instead of the current
+debug file.  This can be useful when post-processing trace output, where
+interleaving dumpdef and trace output can cause ambiguities.
+
 @item p
 In debug output, print a message when a named file is found through the
 path search mechanism (@pxref{Search Path}), giving the actual file name
@@ -4688,11 +4697,13 @@ Invoking m4}), or with the builtin macro 
@code{debugfile}:
 @deffn {Builtin (gnu)} debugfile (@ovar{file})
 Send all further debug and trace output to @var{file}, opened in append
 mode.  If @var{file} is the empty string, debug and trace output are
-discarded.  If @code{debugfile} is called without any arguments,
-debug and trace output are sent to standard error.  This does not
-affect warnings, error messages, or @code{errprint} and @code{dumpdef}
-output, which are always sent to standard error.  If @var{file} cannot
-be opened, the current debug file is unchanged, and an error is issued.
+discarded.  If @code{debugfile} is called without any arguments, debug
+and trace output are sent to standard error.  Output from @code{dumpdef}
+is sent to this file if the debug level @code{o} is not set
+(@pxref{Debugmode}).  This does not affect
+warnings, error messages, or @code{errprint} output, which are
+always sent to standard error.  If @var{file} cannot be opened, the
+current debug file is unchanged, and an error is issued.
 
 When the @option{--safer} option (@pxref{Operation modes, , Invoking
 m4}) is in effect, @var{file} must be empty or omitted, since otherwise
@@ -4750,6 +4761,38 @@ undivert(`trace')dnl
 @result{}m4trace:3: -1- foo -> `bar'
 @end example
 
+Sometimes it is useful to post-process trace output, even though there
+is no standardized format for trace output.  In this situation, forcing
address@hidden to output to standard error instead of the default of the
+current debug file will avoid any ambiguities between the two types of
+output; it also allows debugging via @code{dumpdef} when debug output is
+discarded.
+
address@hidden
+$ @kbd{m4 -d}
+traceon(`divnum')
address@hidden
+divnum
address@hidden: -1- divnum -> `0'
address@hidden
+dumpdef(`divnum')
address@hidden:@tabchar{}<divnum>
address@hidden
+debugfile(`')
address@hidden
+divnum
address@hidden
+dumpdef(`divnum')
address@hidden
+debugmode(`+o')
address@hidden
+divnum
address@hidden
+dumpdef(`divnum')
address@hidden:@tabchar{}<divnum>
address@hidden
address@hidden example
+
 @node Input Control
 @chapter Input control
 
diff --git a/m4/debug.c b/m4/debug.c
index f4005eb..f5cb4e2 100644
--- a/m4/debug.c
+++ b/m4/debug.c
@@ -101,6 +101,10 @@ m4_debug_decode (m4 *context, const char *opts)
              level |= M4_DEBUG_TRACE_DEREF;
              break;
 
+            case 'o':
+               level |= M4_DEBUG_TRACE_OUTPUT_DUMPDEF;
+               break;
+
            case 'V':
              level |= M4_DEBUG_TRACE_VERBOSE;
              break;
diff --git a/m4/m4module.h b/m4/m4module.h
index 1f3b7bc..d5ad513 100644
--- a/m4/m4module.h
+++ b/m4/m4module.h
@@ -404,9 +404,11 @@ enum {
   M4_DEBUG_TRACE_STACK         = (1 << 11),
   /* d: warn if dereferencing undefined macro */
   M4_DEBUG_TRACE_DEREF         = (1 << 12),
+  /* o: output dumpdef to stderr, not debug file */
+  M4_DEBUG_TRACE_OUTPUT_DUMPDEF        = (1 << 13),
 
   /* V: very verbose --  print everything */
-  M4_DEBUG_TRACE_VERBOSE       = ((1 << 13) - 1)
+  M4_DEBUG_TRACE_VERBOSE       = ((1 << 14) - 1)
 };
 
 /* initial flags, used if no -d or -E -- equiv: d */
diff --git a/modules/m4.c b/modules/m4.c
index f78a177..f578261 100644
--- a/modules/m4.c
+++ b/modules/m4.c
@@ -341,7 +341,11 @@ M4BUILTIN_HANDLER (dumpdef)
   bool stack = m4_is_debug_bit (context, M4_DEBUG_TRACE_STACK);
   size_t arg_length = m4_get_max_debug_arg_length_opt (context);
   bool module = m4_is_debug_bit (context, M4_DEBUG_TRACE_MODULE);
+  FILE *output = (m4_is_debug_bit (context, M4_DEBUG_TRACE_OUTPUT_DUMPDEF)
+                 ? stderr : m4_get_debug_file (context));
 
+  if (!output)
+    return;
   if (m4_is_debug_bit (context, M4_DEBUG_TRACE_QUOTE))
     quotes = m4_get_syntax_quotes (M4SYNTAX);
   data.obs = m4_arg_scratch (context);
@@ -365,7 +369,7 @@ M4BUILTIN_HANDLER (dumpdef)
       obstack_1grow (obs, '\n');
       len = obstack_object_size (obs);
       value = (char *) obstack_finish (obs);
-      fwrite (value, 1, len, stderr);
+      fwrite (value, 1, len, output);
       obstack_free (obs, value);
     }
 }
diff --git a/src/freeze.c b/src/freeze.c
index 3008f27..0394d4c 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -111,7 +111,7 @@ static void
 produce_debugmode_state (FILE *file, int flags)
 {
   /* This code tracks the number of bits in M4_DEBUG_TRACE_VERBOSE.  */
-  char str[14];
+  char str[15];
   int offset = 0;
   verify ((1 << (sizeof str - 1)) - 1 == M4_DEBUG_TRACE_VERBOSE);
   if (flags & M4_DEBUG_TRACE_ARGS)
@@ -140,6 +140,8 @@ produce_debugmode_state (FILE *file, int flags)
     str[offset++] = 's';
   if (flags & M4_DEBUG_TRACE_DEREF)
     str[offset++] = 'd';
+  if (flags & M4_DEBUG_TRACE_OUTPUT_DUMPDEF)
+    str[offset++] = 'o';
   str[offset] = '\0';
   if (offset)
     xfprintf (file, "d%d\n%s\n", offset, str);
diff --git a/src/main.c b/src/main.c
index b890041..c04c549 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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\
@@ -169,6 +170,7 @@ FLAGS is any of:\n\
 "), stdout);
       fputs (_("\
   m   show module information in trace, debug, and dumpdef\n\
+  o   output dumpdef to stderr rather than debug file\n\
   p   show results of path searches in debug\n\
   q   quote values in dumpdef and trace, useful with a or e\n\
   s   show full stack of pushdef values in dumpdef\n\
@@ -253,7 +255,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 +566,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 +584,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 +719,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 dce43f8..48e5b03 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


hooks/post-receive
--
GNU M4 source repository




reply via email to

[Prev in Thread] Current Thread [Next in Thread]