From 685b65a74f45fab915d3b0138ea429e21ee6f25b Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 11 Jun 2009 06:43:39 -0600 Subject: [PATCH] Clarify m4_copy semantics. * doc/autoconf.texi (Redefined M4 Macros) : Update documentation. * tests/m4sugar.at (m4@&t@_defn): Enhance test. Signed-off-by: Eric Blake --- ChangeLog | 7 +++++++ doc/autoconf.texi | 8 +++++--- tests/m4sugar.at | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01fdd3d35..df57b305a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-06-11 Eric Blake + + Clarify m4_copy semantics. + * doc/autoconf.texi (Redefined M4 Macros) : Update + documentation. + * tests/m4sugar.at (m4@&t@_defn): Enhance test. + 2009-06-06 Eric Blake Improve documentation on trap pitfalls. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 81bce0716..9e3327e7c 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -10646,10 +10646,12 @@ released and supports extended regular expression syntax. @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 diff --git a/tests/m4sugar.at b/tests/m4sugar.at index bf56c4dba..4bc7bd43c 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -136,6 +136,14 @@ AT_CHECK_M4SUGAR([-o-], 1, [], [stderr]) 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 @@ -151,6 +159,8 @@ m4_popdef([b], [c])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 -- 2.47.3