]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Make sure that nested AS_REQUIRE do not lose the desired diversion.
authorPaolo Bonzini <bonzini@gnu.org>
Sat, 18 Oct 2008 13:08:17 +0000 (15:08 +0200)
committerPaolo Bonzini <bonzini@gnu.org>
Sat, 18 Oct 2008 22:01:16 +0000 (00:01 +0200)
* lib/m4sugar/m4sh.m4 (AS_REQUIRE): Expand _m4_divert_desired before
passing it to m4_divert_require, so that its content is not used
anymore.
* tests/m4sh.at (Nested AS_REQUIRE): New testcase.

ChangeLog
lib/m4sugar/m4sh.m4
tests/m4sh.at

index 25c8826adaecd872a97f9abbf764ae3439f74bc2..5380a507c703f5987353417957c1d98c4d60ac58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-18  Paolo Bonzini  <bonzini@gnu.org>
+
+       Make sure that nested AS_REQUIRE do not lose the desired diversion.
+       * lib/m4sugar/m4sh.m4 (AS_REQUIRE): Expand _m4_divert_desired before
+       passing it to m4_divert_require, so that its content is not used
+       anymore.
+       * tests/m4sh.at (Nested AS_REQUIRE): New testcase.
+
 2008-10-18  Eric Blake  <ebb9@byu.net>
 
        Document bugs in { } handling.
index 75b8d8477a5d5d97ffa85379f05c3bc6058ca132..fbce0269d8dadf3207ffd988ef737857c85b4d6e 100644 (file)
@@ -314,11 +314,14 @@ m4_divert_pop[]dnl
 # given diversion when expanded (required or not).  The expansion
 # goes in the named diversion or an earlier one.
 #
+# Note: we expand _m4_divert_desired before passing it to m4_divert_require,
+# otherwise we would need to use m4_pushdef and m4_popdef instead of
+# simply m4_define.
 m4_defun([AS_REQUIRE],
 [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])dnl
 m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)), 1,
       [m4_require([$1], [$2])],
-      [m4_divert_require([_m4_divert_desired], [$1], [$2])])])
+      [m4_divert_require(_m4_divert(_m4_divert_desired), [$1], [$2])])])
 
 
 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
index c39c8c1d1067453d7cdcfbe5e34cd88b400ee7e1..75da8a4db5077e2441db0c2c9655fd82039edd7f 100644 (file)
@@ -536,6 +536,44 @@ AT_CHECK([./script])
 AT_CLEANUP
 
 
+## ------------------- ##
+## Nested AS_REQUIRE.  ##
+## ------------------- ##
+
+# Hypothesis: M4sh expands the requirements of AS_REQUIRE in the
+# requested diversion, even if other AS_REQUIREs are interleaved.
+
+AT_SETUP([Nested AS@&t@_REQUIRE])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+
+m4_defun([in_fn_diversion], still_in_m4sh_init_fn=yes)
+m4_defun([not_in_fn_diversion], still_in_m4sh_init_fn=no)
+
+m4_defun([NESTED], [nested_require_in_fn_diversion=$still_in_m4sh_init_fn])
+
+m4_defun([OUTER], [AS_REQUIRE([NESTED])dnl
+outer_require_in_fn_diversion=$still_in_m4sh_init_fn])
+
+m4_defun([test_init], [
+AS_REQUIRE([in_fn_diversion], , [M4SH-INIT-FN])
+AS_REQUIRE([OUTER], , [M4SH-INIT-FN])
+AS_REQUIRE([not_in_fn_diversion], , [M4SH-INIT-FN])
+])
+
+test_init
+if test $outer_require_in_fn_diversion != yes; then AS_EXIT([1]); fi
+if test $nested_require_in_fn_diversion != no; then AS_EXIT([1]); fi
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([./script])
+
+AT_CLEANUP
+
+
 ## ------------------------------------ ##
 ## AS_REQUIRE_SHELL_FN and m4_require.  ##
 ## ------------------------------------ ##