--debugmode

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On head, I added --debugmode as an alias to --debug, to match the builtin
macro name.  For backwards compatibility, --debug remains unambiguous and
documented, without issuing any warnings.

2006-10-11  Eric Blake  <[email protected]>

	* src/main.c (usage, long_options): Add --debugmode as an alias
	for --debug, to match macro name.
	* tests/options.at (--debugmode): Rename from --debug, and test
	for new alias.
	(--discard-comments): Augment test.
	* doc/m4.texinfo (Invoking m4, Debugmode): Document this.
	* NEWS: Likewise.

- --
Life is short - so eat dessert first!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFLaum84KuGfSFAYARAo6xAKCjkK8tOqSSWyy9C0ivW0cAyskAqwCePpXI
cAcWyMGh7MeuIINJa9/qpM0=
=EMQ0
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch181 (text/plain, 8.1 KB)
Index: src/main.c
===================================================================
RCS file: /sources/m4/m4/src/main.c,v
retrieving revision 1.95
diff -u -p -r1.95 main.c
--- src/main.c	10 Oct 2006 12:47:23 -0000	1.95
+++ src/main.c	12 Oct 2006 02:40:10 -0000
@@ -130,7 +130,8 @@ Frozen state files:\n\
       fputs (_("\
 \n\
 Debugging:\n\
-  -d, --debug[=FLAGS]          set debug level (no FLAGS implies `aeq')\n\
+  -d, --debug[=FLAGS], --debugmode[=FLAGS]\n\
+                               set debug level (no FLAGS implies `aeq')\n\
       --debugfile=FILE         redirect debug and trace output\n\
   -l, --debuglen=NUM           restrict macro tracing size\n\
   -t, --trace=NAME             trace NAME when it is defined\n\
@@ -194,6 +195,7 @@ static const struct option long_options[
   {"batch", no_argument, NULL, 'b'},
   {"debug", optional_argument, NULL, 'd'},
   {"debuglen", required_argument, NULL, 'l'},
+  {"debugmode", optional_argument, NULL, 'd'},
   {"define", required_argument, NULL, 'D'},
   {"discard-comments", no_argument, NULL, 'c'},
   {"fatal-warnings", no_argument, NULL, 'E'},
@@ -471,7 +473,7 @@ main (int argc, char *const *argv, char 
 	       optchar == 'o' ? "-o" : "--error-output", "--debugfile");
 	/* fall through */
       case DEBUGFILE_OPTION:
-	/* Don't call m4_debug_set_output here, as it has side effects.	 */
+	/* Don't call m4_debug_set_output here, as it has side effects.  */
 	debugfile = optarg;
 	break;
 
Index: NEWS
===================================================================
RCS file: /sources/m4/m4/NEWS,v
retrieving revision 1.26
diff -u -p -r1.26 NEWS
--- NEWS	10 Oct 2006 12:47:23 -0000	1.26
+++ NEWS	12 Oct 2006 02:40:10 -0000
@@ -67,6 +67,7 @@ promoted to 2.0.
   the definition of the macro being expanded.  The 'e' flag has been
   updated to output non-text expansions.  Also, the `--debug' option now
   understands `-' and `+' modifiers, the way `debugmode' has always done.
+  The option `--debugmode' is added as an alias for `-d'.
 
 * The semantics of `traceon' and `traceoff' now match traditional
   implementations: when called without arguments, they affect global state
Index: tests/options.at
===================================================================
RCS file: /sources/m4/m4/tests/options.at,v
retrieving revision 1.18
diff -u -p -r1.18 options.at
--- tests/options.at	10 Oct 2006 12:47:23 -0000	1.18
+++ tests/options.at	12 Oct 2006 02:40:10 -0000
@@ -138,58 +138,6 @@ m@&t@4_dnl()
 AT_CLEANUP
 
 
-## ----------- ##
-## debug flags ##
-## ----------- ##
-
-AT_SETUP([--debug])
-
-AT_DATA([[in]],
-[[divnum
-len(`abc')
-]])
-
-dnl AT_CHECK_M4 starts life with -d.  Make sure it looks like -daeq.
-AT_CHECK_M4([-tlen in], [0], [[0
-3
-]], [[m4trace: -1- len(`abc') -> `3'
-]])
-
-dnl Test all flags.
-AT_CHECK_M4([-dV in], [0], [[0
-3
-]], [[m4debug: module m4: opening file
-m4debug: module m4: init hook called
-m4debug: module m4: opened
-m4debug: module m4: builtins loaded
-m4debug: module gnu: opening file
-m4debug: module gnu: opened
-m4debug: module gnu: builtins loaded
-m4debug: module gnu: macros loaded
-m4debug: path search for `in' found `in'
-m4debug: input read from in
-m4trace:in:1: -1- id 1: divnum ... = <divnum>{m4}
-m4trace:in:1: -1- id 1: divnum -> `0'
-m4trace:in:2: -1- id 2: len ... = <len>{m4}
-m4trace:in:2: -1- id 2: len(`abc') -> `3'
-m4debug:in:3: input exhausted
-m4debug: module gnu: symbols unloaded
-m4debug: module gnu: finish hook called
-m4debug: module gnu: closed
-m4debug: module m4: symbols unloaded
-m4debug: module m4: resident module not closed
-]])
-
-dnl Test addition and subtraction of flags.
-AT_CHECK_M4([-d-e -d+xt in], [0], [[0
-3
-]], [[m4trace: -1- id 1: divnum
-m4trace: -1- id 2: len(`abc')
-]])
-
-AT_CLEANUP
-
-
 ## --------- ##
 ## debugfile ##
 ## --------- ##
@@ -288,6 +236,64 @@ AT_CHECK_M4([--debuglen=3 -l0 in], [0], 
 AT_CLEANUP
 
 
+## --------- ##
+## debugmode ##
+## --------- ##
+
+AT_SETUP([--debugmode])
+
+AT_DATA([[in]],
+[[divnum
+len(`abc')
+]])
+
+dnl AT_CHECK_M4 starts life with -d.  Make sure it looks like -daeq.
+AT_CHECK_M4([-tlen in], [0], [[0
+3
+]], [[m4trace: -1- len(`abc') -> `3'
+]])
+
+dnl Test all flags.
+AT_CHECK_M4([-dV in], [0], [[0
+3
+]], [[m4debug: module m4: opening file
+m4debug: module m4: init hook called
+m4debug: module m4: opened
+m4debug: module m4: builtins loaded
+m4debug: module gnu: opening file
+m4debug: module gnu: opened
+m4debug: module gnu: builtins loaded
+m4debug: module gnu: macros loaded
+m4debug: path search for `in' found `in'
+m4debug: input read from in
+m4trace:in:1: -1- id 1: divnum ... = <divnum>{m4}
+m4trace:in:1: -1- id 1: divnum -> `0'
+m4trace:in:2: -1- id 2: len ... = <len>{m4}
+m4trace:in:2: -1- id 2: len(`abc') -> `3'
+m4debug:in:3: input exhausted
+m4debug: module gnu: symbols unloaded
+m4debug: module gnu: finish hook called
+m4debug: module gnu: closed
+m4debug: module m4: symbols unloaded
+m4debug: module m4: resident module not closed
+]])
+
+dnl Test addition and subtraction of flags.
+AT_CHECK_M4([--debug=-e --debugmode=+xt in], [0], [[0
+3
+]], [[m4trace: -1- id 1: divnum
+m4trace: -1- id 2: len(`abc')
+]])
+
+dnl Test that shorter prefix is ambiguous.
+AT_CHECK_M4([--debu], [1], [],
+[[m4: option `--debu' is ambiguous
+Try `m4 --help' for more information.
+]])
+
+AT_CLEANUP
+
+
 ## ---------------- ##
 ## discard comments ##
 ## ---------------- ##
@@ -296,7 +302,7 @@ AT_SETUP([--discard-comments])
 
 AT_DATA([[in]],
 [[This is not a comment # but this is.
-# This line should dissappear completely.
+# This line should disappear completely.
 This should not disappear.
 changecom(`<!--', `-->')
 html <!--
@@ -310,6 +316,14 @@ AT_CHECK_M4([-c in], [0],
 html  ends.
 ]])
 
+dnl check that even when discarding, a comment must be terminated by EOF
+AT_DATA([in], [[changecom(`/*', `*/')dnl
+/* unterminated comment
+]])
+AT_CHECK_M4([--discard-comments in], [1], [],
+[[m4:in:2: end of file in comment
+]])
+
 AT_CLEANUP
 
 
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.61
diff -u -p -r1.61 m4.texinfo
--- doc/m4.texinfo	10 Oct 2006 12:47:23 -0000	1.61
+++ doc/m4.texinfo	12 Oct 2006 02:40:12 -0000
@@ -678,13 +678,18 @@ scripts.
 @table @code
 @item -d@r{[}@var{FLAGS}@r{]}
 @itemx --debug@r{[}=@var{FLAGS}@r{]}
+@itemx --debugmode@r{[}=@var{FLAGS}@r{]}
 Set the debug-level according to the flags @var{FLAGS}.  The debug-level
 controls the format and amount of information presented by the debugging
 functions.  @xref{Debugmode}, for more details on the format and
 meaning of @var{FLAGS}.  If omitted, @var{FLAGS} defaults to
 @samp{aeq}.  When the option is presented multiple times, if later
 @var{FLAGS} starts with @samp{-} or @samp{+}, they are cumulative,
-otherwise the later flags override all earlier occurrences.
+otherwise the later flags override all earlier occurrences.  The
+spelling @option{--debug} is recognized as an unambiguous option for
+compatibility with earlier versions of @acronym{GNU} M4, but for
+consistency with the builtin name, you can also use the spelling
+@option{--debugmode}.
 
 @item --debugfile=@var{FILE}
 @itemx -o @var{FILE}
@@ -1316,6 +1321,8 @@ It is an error if the end of file occurs
 
 @comment status: 1
 @example
+hello world
+@result{}hello world
 define(
 ^D
 @error{}m4:stdin:1: end of file in argument list
@@ -2893,7 +2900,8 @@ display.
 
 @cindex controlling debugging output
 @cindex debugging output, controlling
-The @option{--debug} option to @code{m4} (or @option{-d},
+The @option{--debug} option to @code{m4} (also spelled
+@option{--debugmode} or @option{-d},
 @pxref{Invoking m4}) controls the amount of details presented in three
 categories of output.  Trace output is requested by @code{traceon}
 (@pxref{Trace}), and each line is prefixed by @samp{m4trace:} in
@@ -3212,7 +3220,7 @@ next newline, on whatever line containin
 @example
 dnl(`args are ignored, but side effects occur',
 define(`foo', `like this')) while this text is ignored: undefine(`foo')
-@error{}m4:stdin:2: Warning: dnl: extra arguments ignored: 2 > 0
+@error{}m4:stdin:1: Warning: dnl: extra arguments ignored: 2 > 0
 See how `foo' was defined, foo?
 @result{}See how foo was defined, like this?
 @end example
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.