]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Add m4_copy_force, m4_rename_force.
authorEric Blake <ebb9@byu.net>
Mon, 15 Jun 2009 12:49:58 +0000 (06:49 -0600)
committerEric Blake <ebb9@byu.net>
Mon, 15 Jun 2009 12:59:03 +0000 (06:59 -0600)
* lib/m4sugar/m4sugar.m4 (m4_copy_force, m4_rename_force): New
macros.
* tests/m4sugar.at (m4@&t@_defn): Test them.
* doc/autoconf.texi (Redefined M4 Macros) <m4_copy>: Document
them.
* NEWS: Likewise.
Suggested by Ralf Wildenhues.

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

index f1313f6c8d28a72edb3ccfdee2111b92efd6425c..4acbea59db9bba9800c0cbed9a09a5b859ea37b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2009-06-15  Eric Blake  <ebb9@byu.net>
 
+       Add m4_copy_force, m4_rename_force.
+       * lib/m4sugar/m4sugar.m4 (m4_copy_force, m4_rename_force): New
+       macros.
+       * tests/m4sugar.at (m4@&t@_defn): Test them.
+       * doc/autoconf.texi (Redefined M4 Macros) <m4_copy>: Document
+       them.
+       * NEWS: Likewise.
+       Suggested by Ralf Wildenhues.
+
        Reinstate _AC_CHECK_HEADER_OLD for gcc.
        * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_NEW)
        (_AC_CHECK_HEADER_OLD): Provide autoupdate versions, since gcc and
diff --git a/NEWS b/NEWS
index 82ba6351539705c0a98ac92158ca44bc5ae17493..93a09c9e0713f20d4464b67a01ecaa49d6fb6b0c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -26,8 +26,8 @@ GNU Autoconf NEWS - User visible changes.
    AT_CHECK_UNQUOTED
 
 ** The following documented m4sugar macros are new:
-   m4_argn  m4_default_nblank  m4_default_nblank_quoted  m4_ifblank
-   m4_ifnblank
+   m4_argn  m4_copy_force  m4_default_nblank  m4_default_nblank_quoted
+   m4_ifblank  m4_ifnblank  m4_rename_force
 
 * Major changes in Autoconf 2.63b (2009-03-31) [beta]
   Released by Eric Blake, based on git versions 2.63.*.
index 9e3327e7c4da3e7c9c90ab76e8558ee5c4c80bfa..4b08042a35569a5f54f9f943d71b3ba12b519c0a 100644 (file)
@@ -10642,16 +10642,23 @@ released and supports extended regular expression syntax.
 @end defmac
 
 @defmac m4_copy (@var{source}, @var{dest})
+@defmacx m4_copy_force (@var{source}, @var{dest})
 @defmacx m4_rename (@var{source}, @var{dest})
+@defmacx m4_rename_force (@var{source}, @var{dest})
 @msindex{copy}
+@msindex{copy_force}
 @msindex{rename}
+@msindex{rename_force}
 These macros aren't directly builtins, but are closely related to
-@code{m4_pushdef} and @code{m4_defn}.  They both ensure that @var{dest}
-is undefined, then proceed to copy the entire pushdef stack of
-definitions of @var{source}.  @code{m4_copy} preserves the source
-(including in the special case where @var{source} is undefined), while
-@code{m4_rename} undefines the original macro name (making it an error
-to rename an undefined @var{source}).
+@code{m4_pushdef} and @code{m4_defn}.  @code{m4_copy} and
+@code{m4_rename} ensure that @var{dest} is undefined, while
+@code{m4_copy_force} and @code{m4_rename_force} overwrite any existing
+definition.  All four macros then proceed to copy the entire pushdef
+stack of definitions of @var{source} over to @var{dest}.  @code{m4_copy}
+and @code{m4_copy_force} preserve the source (including in the special
+case where @var{source} is undefined), while @code{m4_rename} and
+@code{m4_rename_force} undefine the original macro name (making it an
+error to rename an undefined @var{source}).
 
 Note that attempting to invoke a renamed macro might not work, since the
 macro may have a dependence on helper macros accessed via composition of
index f5a1f1c1af07cc3afb6ba485ceea35052ef1bc1f..83f6dba5de424fe0e2ed6572c5d6a95ef7523cc1 100644 (file)
@@ -579,7 +579,8 @@ m4_define([_m4_bpatsubsts],
 # give an error if DST is already defined.  This is particularly nice
 # for copying self-modifying pushdef stacks, where the top definition
 # includes one-shot initialization that is later popped to the normal
-# definition.
+# definition.  This version intentionally does nothing if SRC is
+# undefined.
 #
 # Some macros simply can't be renamed with this method: namely, anything
 # involved in the implementation of m4_stack_foreach_sep.
@@ -589,6 +590,19 @@ m4_define([m4_copy],
 [m4_ifdef([m4_location($1)], [m4_define([m4_location($2)], m4_location)])])
 
 
+# m4_copy_force(SRC, DST)
+# m4_rename_force(SRC, DST)
+# -------------------------
+# Like m4_copy/m4_rename, except blindly overwrite any existing DST.
+# Note that m4_copy_force tolerates undefined SRC, while m4_rename_force
+# does not.
+m4_define([m4_copy_force],
+[m4_ifdef([$2], [_m4_undefine([$2])])m4_copy($@)])
+
+m4_define([m4_rename_force],
+[m4_ifdef([$2], [_m4_undefine([$2])])m4_rename($@)])
+
+
 # m4_define_default(MACRO, VALUE)
 # -------------------------------
 # If MACRO is undefined, set it to VALUE.
index 4bc7bd43cdf4a3cb8115e7c04f018339e1d424f7..04f06b9aa1fc0d66a7eca7e143f26bba08ee8aba 100644 (file)
@@ -104,7 +104,8 @@ AT_CLEANUP
 
 AT_SETUP([m4@&t@_defn])
 
-AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine m4@&t@_copy m4@&t@_rename])
+AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine m4@&t@_copy m4@&t@_rename
+m4@&t@_copy_force m4@&t@_rename_force])
 
 # Ensure that m4sugar dies when dereferencing undefined macros, whether
 # this is provided by m4 natively or faked by wrappers in m4sugar.
@@ -161,12 +162,21 @@ m4_popdef([b], [c])dnl
 a b c
 dnl m4_copy is intentionally a no-op on undefined source
 m4_copy([oops], [dummy])m4_ifdef([dummy], [[oops]])dnl
+dnl allow forceful overwrites
+m4_define([d], [4])m4_define([e], [5])m4_define([f], [6])dnl
+m4_copy_force([d], [e])dnl
+m4_rename_force([d], [f])dnl
+d e f
+m4_popdef([e], [f])dnl
+d e f
 ]], [[0 b c
 a 0 c
 a 0 0
 a 2 2
 a 1 1
 a b c
+d 4 4
+d e f
 ]])
 
 AT_CLEANUP