+2002-03-19 Akim Demaille <akim@epita.fr>
+
+ * lib/m4sugar/m4sugar.m4 (m4_define_default, m4_fst, m4_map): New.
+
2002-03-18 Paul Eggert <eggert@twinsun.com>
* doc/autoconf.texi (Programming in M4sh): Add AS_MKDIR_P.
# This file is part of Autoconf.
# Base M4 layer.
# Requires GNU M4.
-# Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
[$3])])
+# m4_map(MACRO, LIST)
+# -------------------
+# Invoke MACRO($1), MACRO($2) etc. where $1, $2... are the elements
+# of LIST (which can be lists themselves, for multiple arguments MACROs).
+m4_define([m4_fst], [$1])
+m4_define([m4_map],
+[m4_if([$2], [[]], [],
+ [$1(m4_fst($2))[]dnl
+m4_map([$1], m4_cdr($2))])])
+
## ---------------------------------------- ##
## 6. Enhanced version of some primitives. ##
[$1[]m4_do(m4_shift($@))])])
+# m4_define_default(MACRO, VALUE)
+# -------------------------------
+# If MACRO is undefined, set it to VALUE.
+m4_define([m4_define_default],
+[m4_ifndef([$1], [m4_define($@)])])
+
+
# m4_default(EXP1, EXP2)
# ----------------------
# Returns EXP1 if non empty, otherwise EXP2.
m4_define([m4_quote], [[$*]])
m4_define([m4_dquote], [[$@]])
+
# m4_noquote(STRING)
# ------------------
# Return the result of ignoring all quotes in STRING and invoking the