2008-10-16 Eric Blake <ebb9@byu.net>
+ Allow comments before functions emitted by m4sh.
+ * lib/m4sugar/m4sh.m4 (AS_REQUIRE_SHELL_FN): Add comment
+ argument. Supply closing comment, to ease readability.
+ (_AS_MKDIR_P_PREPARE): Adjust caller.
+ (_AS_UNSET_PREPARE): Add comment.
+
Add AS_FUNCTION_DESCRIBE.
* lib/m4sugar/m4sh.m4 (AS_FUNCTION_DESCRIBE): New macro.
* lib/autotest/general.m4 (AT_INIT): Use it.
# important not to forget some: config.status needs them.
m4_defun([_AS_PREPARE],
[m4_pushdef([AS_REQUIRE], [])dnl
+AS_FUNCTION_DESCRIBE([as_func_mkdir_p], [],
+[Create "$as_dir" as a directory, including parents if necessary.])
as_func_mkdir_p ()
{
_AS_MKDIR_P
[m4_divert_require([_m4_divert_desired], [$1], [$2])])])
-# AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, BODY-TO-EXPAND,
+# AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
# [DIVERSION = M4SH-INIT-FN])
-# --------------------------------------------------
+# -----------------------------------------------------------
# BODY-TO-EXPAND is the body of a shell function to be emitted in the
# given diversion when expanded (required or not). Unlike other
-# xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
-#
+# xx_REQUIRE macros, BODY-TO-EXPAND is mandatory. If COMMENT is
+# provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
+# newline before the function name.
m4_define([AS_REQUIRE_SHELL_FN],
-[AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1 ()
+[AS_REQUIRE([AS_SHELL_FN_$1],
+[m4_provide([AS_SHELL_FN_$1])m4_n([$2])$1 ()
{
-$2
-}], m4_default_quoted([$3], [M4SH-INIT-FN]))])
+$3
+} [#] $1
+], m4_default_quoted([$4], [M4SH-INIT-FN]))])
# _AS_RUN(TEST, [SHELL])
# Define $as_unset to execute AS_UNSET, for backwards compatibility
# with older versions of M4sh.
m4_defun([_AS_UNSET_PREPARE],
-[as_func_unset ()
+[AS_FUNCTION_DESCRIBE([as_func_unset], [VAR], [Portably unset VAR.])
+as_func_unset ()
{
AS_UNSET([$[1]])
}
# _AS_MKDIR_P_PREPARE
# -------------------
m4_defun([_AS_MKDIR_P_PREPARE],
-[AS_REQUIRE_SHELL_FN([as_func_mkdir_p], [
+[AS_REQUIRE_SHELL_FN([as_func_mkdir_p],
+ [AS_FUNCTION_DESCRIBE([as_func_mkdir_p], [],
+ [Create "$as_dir" as a directory, including parents if necessary.])],
+[
_AS_MKDIR_P
])
if mkdir -p . 2>/dev/null; then