+2009-06-11 Eric Blake <ebb9@byu.net>
+
+ Clarify m4_copy semantics.
+ * doc/autoconf.texi (Redefined M4 Macros) <m4_copy>: Update
+ documentation.
+ * tests/m4sugar.at (m4@&t@_defn): Enhance test.
+
2009-06-06 Eric Blake <ebb9@byu.net>
Improve documentation on trap pitfalls.
@msindex{copy}
@msindex{rename}
These macros aren't directly builtins, but are closely related to
-@code{m4_pushdef} and @code{m4_defn}. They both ensures that @var{dest}
+@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, while
-@code{m4_rename} undefines the original macro name.
+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}).
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
AT_CHECK([grep good stderr], [1])
AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
+# Cannot rename an undefined macro.
+AT_DATA_M4SUGAR([script.4s],
+[[m4_rename([oops], [good])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
+
# Check that pushdef stacks can be renamed.
AT_CHECK_M4SUGAR_TEXT([[m4_pushdef([a], [1])dnl
m4_pushdef([a], [2])dnl
a b c
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
]], [[0 b c
a 0 c
a 0 0