[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] add a separate diversion for shell functions
From: |
Paolo Bonzini |
Subject: |
[PATCH 1/5] add a separate diversion for shell functions |
Date: |
Thu, 18 Sep 2008 16:12:46 +0200 |
This patch is the first in a set to use shell functions for m4sh
macros AS_BASENAME, AS_DIRNAME, AS_MKDIR_P. However, most of these
patches are applicable anyway.
This patch adds a separate diversion for shell functions, which are
output after sanitization but before other initialization. This
makes sure that _AS_*_PREPARE macros can use the shell functions
they set.
The argument to AS_REQUIRE is used also later in the series,
which is why I have not inlined it in AS_REQUIRE_SHELL_FN.
2008-09-18 Paolo Bonzini <address@hidden>
* lib/m4sugar/m4sh.m4 (M4SH-INIT-FN): New diversion.
(AS_REQUIRE): Accept diversion parameter.
(AS_REQUIRE_SHELL_FN): Use it.
---
lib/m4sugar/m4sh.m4 | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 5aab9c7..7ebb1a3 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -68,8 +68,10 @@
# 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 direction section when expanded (required or not). This is very
# different from m4_require. For instance:
#
# m4_defun([_FOO_PREPARE], [foo=foo])
@@ -140,7 +144,8 @@ 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([$3], [M4SH-INIT]),
+ [m4_default([$2], [$1])])])])
# AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, BODY-TO-EXPAND)
@@ -151,10 +156,9 @@ m4_define([AS_REQUIRE],
#
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
-}])])])
+}], [M4SH-INIT-FN])])
# AS_BOURNE_COMPATIBLE
--
1.5.5
- [PATCH 1/5] add a separate diversion for shell functions,
Paolo Bonzini <=