]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
add a separate diversion for shell functions
authorPaolo Bonzini <bonzini@gnu.org>
Thu, 18 Sep 2008 12:12:46 +0000 (14:12 +0200)
committerEric Blake <ebb9@byu.net>
Tue, 7 Oct 2008 03:35:11 +0000 (21:35 -0600)
* lib/m4sugar/m4sh.m4 (M4SH-INIT-FN): New diversion.
(AS_REQUIRE): Accept diversion parameter.
(AS_REQUIRE_SHELL_FN): Use it.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/m4sugar/m4sh.m4

index f7833faee74b40e37743f54d6b8735447d9ab237..7e73e221bce1b01b3ab591a7e101cc0b297b901b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-09-18  Paolo Bonzini  <bonzini@gnu.org>
+       and Eric Blake  <ebb9@byu.net>
+
+       Add a separate diversion for shell functions.
+       * lib/m4sugar/m4sh.m4 (M4SH-INIT-FN): New diversion.
+       (AS_REQUIRE): Accept diversion parameter.
+       (AS_REQUIRE_SHELL_FN): Use it.
+
 2008-10-06  Eric Blake  <ebb9@byu.net>
 
        Add m4_default_quoted.
index 5aab9c7940b25a53a71b1f073f432c8761bc510b..5fa2ef78b6cc0e6e13371660f25c94446714afd6 100644 (file)
 #   Copyright notice(s)
 # - M4SH-SANITIZE
 #   M4sh's shell setup
+# - M4SH-INIT-FN
+#   M4sh initialization (shell functions)
 # - M4SH-INIT
-#   M4sh initialization
+#   M4sh initialization (detection code)
 # - BODY
 #   The body of the script.
 
@@ -85,7 +87,8 @@ m4_define([_m4_divert(HEADER-REVISION)],   1)
 m4_define([_m4_divert(HEADER-COMMENT)],    2)
 m4_define([_m4_divert(HEADER-COPYRIGHT)],  3)
 m4_define([_m4_divert(M4SH-SANITIZE)],     4)
-m4_define([_m4_divert(M4SH-INIT)],         5)
+m4_define([_m4_divert(M4SH-INIT-FN)],      5)
+m4_define([_m4_divert(M4SH-INIT)],         6)
 m4_define([_m4_divert(BODY)],           1000)
 
 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
@@ -100,10 +103,11 @@ m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
 ## ------------------------- ##
 
 
-# AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK])
+# AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
+#            [DIVERSION = M4SH-INIT])
 # -----------------------------------------------------------
 # BODY-TO-EXPAND is some initialization which must be expanded in the
-# M4SH-INIT section when expanded (required or not).  This is very
+# given diversion when expanded (required or not).  This is very
 # different from m4_require.  For instance:
 #
 #      m4_defun([_FOO_PREPARE], [foo=foo])
@@ -140,21 +144,22 @@ m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
 #
 m4_define([AS_REQUIRE],
 [m4_provide_if([$1], [],
-              [m4_divert_text([M4SH-INIT], [m4_default([$2], [$1])])])])
+              [m4_divert_text(m4_default_quoted([$3], [M4SH-INIT]),
+                              [m4_default([$2], [$1])])])])
 
 
-# AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, BODY-TO-EXPAND)
+# AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, BODY-TO-EXPAND,
+#                     [DIVERSION = M4SH-INIT-FN])
 # --------------------------------------------------
 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
-# M4SH-INIT section when expanded (required or not).  Unlike other
+# given diversion when expanded (required or not).  Unlike other
 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
 #
 m4_define([AS_REQUIRE_SHELL_FN],
 [_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
-m4_provide_if([AS_SHELL_FN_$1], [],
-              [m4_provide([AS_SHELL_FN_$1])m4_divert_text([M4SH-INIT], [$1() {
+AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1() {
 $2
-}])])])
+}], [m4_default_quoted([$3], [M4SH-INIT-FN])])])
 
 
 # AS_BOURNE_COMPATIBLE