]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Support multiple arguments to m4_defn, m4_popdef, and m4_undefine.
authorEric Blake <ebb9@byu.net>
Fri, 18 Jul 2008 20:26:41 +0000 (14:26 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 19 Jul 2008 19:11:45 +0000 (13:11 -0600)
* lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Loop
through all variables, per POSIX and newer m4.
(_m4_text_wrap): Exploit the looping capabilities.
* tests/m4sugar.at (m4@&t@_defn): Test this.
* NEWS: Document it.
* doc/autoconf.texi (Redefined M4 Macros) <m4_defn, m4_popdef>
<m4_undefine>: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
NEWS
doc/autoconf.texi
lib/m4sugar/m4sugar.m4
tests/m4sugar.at

index 974c025eccb5cc1272debfc4e561afee110b76c7..47c73b7f2b1cf8a13f4631dee2df76558f969dca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-07-19  Eric Blake  <ebb9@byu.net>
 
+       Support multiple arguments to m4_defn, m4_popdef, and m4_undefine.
+       * lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Loop
+       through all variables, per POSIX and newer m4.
+       (_m4_text_wrap): Exploit the looping capabilities.
+       * tests/m4sugar.at (m4@&t@_defn): Test this.
+       * NEWS: Document it.
+       * doc/autoconf.texi (Redefined M4 Macros) <m4_defn, m4_popdef>
+       <m4_undefine>: Likewise.
+
        Reduce overhead of m4_builtin([defn]).
        * lib/m4sugar/m4sugar.m4 (_m4_defn, _m4_popdef, _m4_undefine): New
        internal macros, which are slightly more efficient than
diff --git a/NEWS b/NEWS
index d3fb23b9cb69041467177f5826202fe8a86c3d4d..232ec8616bfe76617771b2176041a965ce5a77ec 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,10 @@ GNU Autoconf NEWS - User visible changes.
 ** The following m4sugar macros are new:
    m4_joinall
 
+** The following m4sugar macros now accept multiple arguments, as is the
+   case with underlying m4:
+   m4_defn  m4_popdef  m4_undefine
+
 ** AT_KEYWORDS once again performs expansion on its argument, such that
    AT_KEYWORDS([m4_if([$1], [], [default])]) no longer complains about
    the possibly unexpanded m4_if [regression introduced in 2.62].
index 4e8638d34c4b419382d09ed701f3a343266bf816..efb6540431211bd7d7ddcfc12e980637cd6d5732 100644 (file)
@@ -10323,12 +10323,14 @@ is kept for future versions of M4sugar, once @acronym{GNU} M4 2.0 is
 released and supports extended regular expression syntax.
 @end defmac
 
-@defmac m4_defn (@var{macro})
+@defmac m4_defn (@var{macro}@dots{})
 @msindex{defn}
-Unlike the M4 builtin, this macro fails if @var{macro} is not
-defined.  Also, while newer M4 can concatenate multiple definitions,
-this version currently only supports a single @var{macro}.  See
-@code{m4_undefine}.
+This macro fails if @var{macro} is not defined, even when using older
+versions of M4 that did not warn.  See @code{m4_undefine}.
+Unfortunately, in order to support these older versions of M4, there are
+some situations involving unbalanced quotes where concatenating multiple
+macros together will work in newer M4 but not in m4sugar; use
+quadrigraphs to work around this.
 @end defmac
 
 @defmac m4_divert (@var{diversion})
@@ -10380,26 +10382,23 @@ and both have the secure semantics regardless of which macro the
 underlying M4 provides.
 @end defmac
 
-@defmac m4_popdef (@var{macro})
+@defmac m4_popdef (@var{macro}@dots{})
 @msindex{popdef}
-Unlike the M4 builtin, this macro fails if @var{macro} is not
-defined.  Also, while newer M4 can pop multiple definitions at once,
-this version currently only supports a single @var{macro}.  See
-@code{m4_undefine}.
+This macro fails if @var{macro} is not defined, even when using older
+versions of M4 that did not warn.  See @code{m4_undefine}.
 @end defmac
 
-@defmac m4_undefine (@var{macro})
+@defmac m4_undefine (@var{macro}@dots{})
 @msindex{undefine}
-Unlike the M4 builtin, this macro fails if @var{macro} is not
-defined.  Also, while newer M4 can undefine multiple definitions at
-once, this version currently only supports a single @var{macro}.  Use
+This macro fails if @var{macro} is not defined, even when using older
+versions of M4 that did not warn.  Use
 
 @example
 m4_ifdef([@var{macro}], [m4_undefine([@var{macro}])])
 @end example
 
 @noindent
-to recover the behavior of the builtin.
+if you are not sure whether @var{macro} is defined.
 @end defmac
 
 @defmac m4_undivert (@var{diversion})
index 347c123c52a7c22aa1d3dcfb14c76b27c4af2e07..5ef78366d79d5bf3116e2100687f12de10f7ce8e 100644 (file)
@@ -506,7 +506,11 @@ m4_define([m4_default],
 # m4_defn(NAME)
 # -------------
 # Like the original, except guarantee a warning when using something which is
-# undefined (unlike M4 1.4.x), and only support one argument.
+# undefined (unlike M4 1.4.x).  This replacement is not a full-featured
+# replacement: if any of the defined macros contain unbalanced quoting, but
+# when pasted together result in a well-quoted string, then only native m4
+# support is able to get it correct.  But that's where quadrigraphs come in
+# handy, if you really need unbalanced quotes inside your macros.
 #
 # This macro is called frequently, so minimize the amount of additional
 # expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
@@ -521,7 +525,7 @@ m4_ifdef([__m4_version__], [],
 [m4_define([m4_defn],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[_m4_defn([$1])])])
+[_m4_defn([$1])m4_if([$#], [1], [], [$0(m4_shift($@))])])])
 
 
 # _m4_dumpdefs_up(NAME)
@@ -555,7 +559,7 @@ _m4_dumpdefs_down([$1])])
 # m4_popdef(NAME)
 # ---------------
 # Like the original, except guarantee a warning when using something which is
-# undefined (unlike M4 1.4.x), and only support one argument.
+# undefined (unlike M4 1.4.x).
 #
 # This macro is called frequently, so minimize the amount of additional
 # expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
@@ -569,7 +573,7 @@ m4_ifdef([__m4_version__], [],
 [m4_define([m4_popdef],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[_m4_popdef([$1])])])
+[_m4_popdef([$1])m4_if([$#], [1], [], [$0(m4_shift($@))])])])
 
 
 # m4_shiftn(N, ...)
@@ -619,7 +623,7 @@ m4_define([_m4_shift3],
 # m4_undefine(NAME)
 # -----------------
 # Like the original, except guarantee a warning when using something which is
-# undefined (unlike M4 1.4.x), and only support one argument.
+# undefined (unlike M4 1.4.x).
 #
 # This macro is called frequently, so minimize the amount of additional
 # expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
@@ -633,7 +637,7 @@ m4_ifdef([__m4_version__], [],
 [m4_define([m4_undefine],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[_m4_undefine([$1])])])
+[_m4_undefine([$1])m4_if([$#], [1], [], [$0(m4_shift($@))])])])
 
 # _m4_wrap(PRE, POST)
 # -------------------
@@ -2067,9 +2071,7 @@ dnl either way, insert the word
 [$2]],
       [m4_Separator[]])_m4_defn([m4_Word])])]],
 dnl finally, clean up the local variabls
-[[_m4_popdef([m4_Separator])]],
-[[_m4_popdef([m4_Cursor])]],
-[[_m4_popdef([m4_Indent])]]))
+[[_m4_popdef([m4_Separator], [m4_Cursor], [m4_Indent])]]))
 
 
 # m4_text_box(MESSAGE, [FRAME-CHARACTER = `-'])
index 650f5dcf01f2fd8f0fddab7f69c550b5b177a6a7..9dd953a9868e6b8fc6f1badbe1f69489e1105535 100644 (file)
@@ -64,24 +64,30 @@ AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine])
 # this is provided by m4 natively or faked by wrappers in m4sugar.
 
 AT_DATA_M4SUGAR([script.4s],
-[[m4_defn([oops])
+[[m4_define([good])
+m4_defn([good], [oops])
 ]])
 
 AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
 AT_CHECK([grep 'm4@&t@_defn: undefined.*oops' stderr], [0], [ignore])
 
 AT_DATA_M4SUGAR([script.4s],
-[[m4_popdef([oops])
+[[m4_define([good])
+m4_popdef([good], [oops])
 ]])
 
 AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
 AT_CHECK([grep 'm4@&t@_popdef: undefined.*oops' stderr], [0], [ignore])
 
 AT_DATA_M4SUGAR([script.4s],
-[[m4_undefine([oops])
+[[m4_define([good])
+m4_undefine([good], [oops])
 ]])
 
 AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
 AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
 
 AT_CLEANUP