[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08-builtins-in-m4.patch
From: |
Akim Demaille |
Subject: |
08-builtins-in-m4.patch |
Date: |
30 Oct 2000 10:21:00 +0100 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) |
Index: ChangeLog
from Akim Demaille <address@hidden>
In M4sugar, move `define', `undefine', and `defn' into the `m4_'
name space.
* m4sugar.m4 (m4_define, m4_defn, m4_undefine): New macros.
(define, defn, undefine): Undefine.
Adjust all uses.
* m4sh.m4: Adjust.
* autoconf.m4: Reenable these builtins.
* m4sugar.m4 (m4_expansion_stack_dump): Use m4_copy.
Index: autoconf.m4
--- autoconf.m4 Thu, 26 Oct 2000 21:03:04 +0200 akim (ace/28_autoconf.m 1.7 664)
+++ autoconf.m4 Fri, 27 Oct 2000 23:05:10 +0200 akim (ace/28_autoconf.m 1.7 664)
@@ -26,6 +26,13 @@
m4_include(m4sh.m4)
+# M4sugar and M4sh use exclusively the `m4_' prefix, but Autoconf,
+# for historical reasons, uses the old names.
+
+m4_copy([m4_define], [define])
+m4_copy([m4_defn], [defn])
+m4_copy([m4_undefine], [undefine])
+
m4_include(acversion.m4)
m4_include(acgeneral.m4)
m4_include(aclang.m4)
Index: m4sugar.m4
--- m4sugar.m4 Fri, 27 Oct 2000 21:16:43 +0200 akim (ace/b/27_libm4.m4 1.26 644)
+++ m4sugar.m4 Fri, 27 Oct 2000 23:09:55 +0200 akim (ace/b/27_libm4.m4 1.26 644)
@@ -62,16 +62,34 @@
m4exit(2)])
-## --------------------------------------------- ##
-## 1. Move some builtins to a safer name space. ##
-## --------------------------------------------- ##
+## ------------------------------- ##
+## 1. Simulate --prefix-builtins. ##
+## ------------------------------- ##
+
+# m4_define
+# m4_defn
+# m4_undefine
+define([m4_define], defn([define]))
+define([m4_defn], defn([defn]))
+define([m4_undefine], defn([undefine]))
+
+m4_undefine([define])
+m4_undefine([defn])
+m4_undefine([undefine])
+
+
+# m4_copy(SRC, DST)
+# -----------------
+# Define DST as the definition of SRC.
+m4_define([m4_copy],
+[m4_define([$2], m4_defn([$1]))])
+
# m4_rename(SRC, DST)
# -------------------
-#
# Rename the macro SRC as DST.
-define([m4_rename],
-[define([$2], defn([$1]))undefine([$1])])
+m4_define([m4_rename],
+[m4_copy([$1], [$2])m4_undefine([$1])])
# Some m4 internals have names colliding with tokens we might use.
# Rename them a` la `m4 --prefix-builtins'.
@@ -88,27 +106,27 @@ define([m4_rename],
# m4_location
# -----------
-define([m4_location], [__file__:__line__])
+m4_define([m4_location], [__file__:__line__])
# m4_errprint(MSG)
# ----------------
# Same as `errprint', but with the missing end of line.
-define([m4_errprint], [errprint([$1
+m4_define([m4_errprint], [errprint([$1
])])
# m4_warning(MSG)
# ---------------
# Warn the user.
-define([m4_warning],
+m4_define([m4_warning],
[m4_errprint(m4_location[: warning: $1])])
# m4_fatal(MSG, [EXIT-STATUS])
# ----------------------------
# Fatal the user. :)
-define([m4_fatal],
+m4_define([m4_fatal],
[m4_errprint(m4_location[: error: $1])dnl
m4_expansion_stack_dump()dnl
m4exit(ifelse([$2],, 1, [$2]))])
@@ -118,7 +136,7 @@ define([m4_fatal],
# -------------------------------------------
# This macro ensures that EXPRESSION evaluates to true, and exits if
# EXPRESSION evaluates to false.
-define([m4_assert],
+m4_define([m4_assert],
[ifelse(m4_eval([$1]), 0,
[m4_fatal([assert failed: $1], [$2])],
[])])
@@ -142,14 +160,14 @@ define([m4_assert],
# - if none or noCATEGORY is met, run IF-FALSE
# - if all or CATEGORY is met, run IF-TRUE
# - if there is nothing left, run IF-FALSE.
-define([m4_warning_ifelse],
+m4_define([m4_warning_ifelse],
[_m4_warning_ifelse([$1], [$2], [$3], m4_warnings)])
# _m4_warning_ifelse(CATEGORY, IF-TRUE, IF-FALSE, WARNING1, ...)
# --------------------------------------------------------------
# Implementation of the loop described above.
-define([_m4_warning_ifelse],
+m4_define([_m4_warning_ifelse],
[ifelse([$4], [$1], [$2],
[$4], [all], [$2],
[$4], [], [$3],
@@ -161,14 +179,14 @@ define([_m4_warning_ifelse],
# _m4_warning_error_ifelse(IF-TRUE, IF-FALSE)
# -------------------------------------------
# The same as m4_warning_ifelse, but scan for `error' only.
-define([_m4_warning_error_ifelse],
+m4_define([_m4_warning_error_ifelse],
[__m4_warning_error_ifelse([$1], [$2], m4_warnings)])
# __m4_warning_error_ifelse(IF-TRUE, IF-FALSE)
# --------------------------------------------
# The same as _m4_warning_ifelse, but scan for `error' only.
-define([__m4_warning_error_ifelse],
+m4_define([__m4_warning_error_ifelse],
[ifelse([$3], [error], [$1],
[$3], [], [$2],
[$3], [no-error], [$2],
@@ -180,7 +198,7 @@ define([__m4_warning_error_ifelse],
# -----------------
# Report MESSAGE as a warning, unless the user requested -W error,
# in which case report a fatal error.
-define([_m4_warn],
+m4_define([_m4_warn],
[_m4_warning_error_ifelse([m4_fatal([$1])],
[m4_warning([$1])])])
@@ -189,7 +207,7 @@ define([_m4_warn],
# --------------------------
# Report a MESSAGE to the autoconf user if the CATEGORY of warnings
# is requested (in fact, not disabled).
-define([m4_warn],
+m4_define([m4_warn],
[m4_warning_ifelse([$1], [_m4_warn([$2])])])
@@ -202,28 +220,28 @@ define([m4_warn],
# We also want to neutralize include (and sinclude for symmetry),
# but we want to extend them slightly: warn when a file is included
# several times. This is in general a dangerous operation because
-# quite nobody quotes the first argument of define.
+# quite nobody quotes the first argument of m4_define.
#
# For instance in the following case:
-# define(foo, [bar])
+# m4_define(foo, [bar])
# then a second reading will turn into
-# define(bar, [bar])
+# m4_define(bar, [bar])
# which is certainly not what was meant.
# m4_include_unique(FILE)
# -----------------------
# Declare that the FILE was loading; and warn if it has already
# been included.
-define([m4_include_unique],
+m4_define([m4_include_unique],
[ifdef([m4_include($1)],
[m4_warn([file `$1' included several times])])dnl
-define([m4_include($1)])])
+m4_define([m4_include($1)])])
# m4_include(FILE)
# ----------------
# As the builtin include, but warns against multiple inclusions.
-define([m4_include],
+m4_define([m4_include],
[m4_include_unique([$1])dnl
builtin([include], [$1])])
@@ -231,13 +249,13 @@ define([m4_include],
# m4_sinclude(FILE)
# -----------------
# As the builtin sinclude, but warns against multiple inclusions.
-define([m4_sinclude],
+m4_define([m4_sinclude],
[m4_include_unique([$1])dnl
builtin([sinclude], [$1])])
# Neutralize include and sinclude.
-undefine([include])
-undefine([sinclude])
+m4_undefine([include])
+m4_undefine([sinclude])
@@ -263,14 +281,14 @@ define([m4_sinclude],
# ----------------------------------
# If COND is not the empty string, expand IF-TRUE, otherwise IF-FALSE.
# Comparable to ifdef.
-define([ifval], [ifelse([$1], [], [$3], [$2])])
+m4_define([ifval], [ifelse([$1], [], [$3], [$2])])
# m4_ifvanl(COND, [IF-TRUE], [IF-FALSE])
# --------------------------------------
# Same as `ifval', but add an extra newline to IF-TRUE or IF-FALSE
# unless that argument is empty.
-define([m4_ifvanl], [ifelse([$1], [],
+m4_define([m4_ifvanl], [ifelse([$1], [],
[ifelse([$3], [], [], [$3
])],
[ifelse([$2], [], [], [$2
@@ -281,15 +299,15 @@ define([m4_ifvanl], [ifelse([$1], [],
# -----------------------------------
# If MACRO has no definition, or of its definition is the empty string,
# expand IF-FALSE, otherwise IF-TRUE.
-define([ifset],
+m4_define([ifset],
[ifdef([$1],
- [ifelse(defn([$1]), [], [$3], [$2])],
+ [ifelse(m4_defn([$1]), [], [$3], [$2])],
[$3])])
# ifndef(NAME, [IF-NOT-DEFINED], [IF-DEFINED])
# --------------------------------------------
-define([ifndef],
+m4_define([ifndef],
[ifdef([$1], [$3], [$2])])
@@ -311,7 +329,7 @@ define([ifndef],
# }.
# All the values are optional, and the macro is robust to active
# symbols properly quoted.
-define([m4_case],
+m4_define([m4_case],
[ifelse([$#], 0, [],
[$#], 1, [],
[$#], 2, [$2],
@@ -334,7 +352,7 @@ define([m4_case],
#
# All the values are optional, and the macro is robust to active symbols
# properly quoted.
-define([m4_match],
+m4_define([m4_match],
[ifelse([$#], 0, [],
[$#], 1, [],
[$#], 2, [$2],
@@ -352,7 +370,7 @@ define([m4_match],
# This macro invokes all its arguments (in sequence, of course). It is
# useful for making your macros more structured and readable by dropping
# unecessary dnl's and have the macros indented properly.
-define([m4_do],
+m4_define([m4_do],
[ifelse($#, 0, [],
$#, 1, [$1],
[$1[]m4_do(m4_shift($@))])])
@@ -361,17 +379,17 @@ define([m4_do],
# m4_default(EXP1, EXP2)
# ----------------------
# Returns EXP1 if non empty, otherwise EXP2.
-define([m4_default], [ifval([$1], [$1], [$2])])
+m4_define([m4_default], [ifval([$1], [$1], [$2])])
# m4_shiftn(N, ...)
# -----------------
# Returns ... shifted N times. Useful for recursive "varargs" constructs.
-define([m4_shiftn],
+m4_define([m4_shiftn],
[m4_assert(($1 >= 0) && ($# > $1))dnl
_m4_shiftn($@)])
-define([_m4_shiftn],
+m4_define([_m4_shiftn],
[ifelse([$1], 0,
[m4_shift($@)],
[_m4_shiftn(m4_eval([$1]-1), m4_shift(m4_shift($@)))])])
@@ -381,9 +399,9 @@ define([_m4_shiftn],
# _m4_dumpdefs_up(NAME)
# ---------------------
-define([_m4_dumpdefs_up],
+m4_define([_m4_dumpdefs_up],
[ifdef([$1],
- [pushdef([_m4_dumpdefs], defn([$1]))dnl
+ [pushdef([_m4_dumpdefs], m4_defn([$1]))dnl
dumpdef([$1])dnl
popdef([$1])dnl
_m4_dumpdefs_up([$1])])])
@@ -391,9 +409,9 @@ define([_m4_dumpdefs_up],
# _m4_dumpdefs_down(NAME)
# -----------------------
-define([_m4_dumpdefs_down],
+m4_define([_m4_dumpdefs_down],
[ifdef([_m4_dumpdefs],
- [pushdef([$1], defn([_m4_dumpdefs]))dnl
+ [pushdef([$1], m4_defn([_m4_dumpdefs]))dnl
popdef([_m4_dumpdefs])dnl
_m4_dumpdefs_down([$1])])])
@@ -402,7 +420,7 @@ define([_m4_dumpdefs_down],
# -----------------
# Similar to `dumpdef(NAME)', but if NAME was pushdef'ed, display its
# value stack (most recent displayed first).
-define([m4_dumpdefs],
+m4_define([m4_dumpdefs],
[_m4_dumpdefs_up([$1])dnl
_m4_dumpdefs_down([$1])])
@@ -415,7 +433,7 @@ define([m4_dumpdefs],
# `[exp]': in the first case you obtain the quoted *result* of the
# expansion of EXP, while in the latter you just obtain the string
# `exp'.
-define([m4_quote], [[$*]])
+m4_define([m4_quote], [[$*]])
# m4_noquote(STRING)
@@ -424,7 +442,7 @@ define([m4_quote], [[$*]])
# macros it contains. Amongst other things useful for enabling macro
# invocations inside strings with [] blocks (for instance regexps and
# help-strings).
-define([m4_noquote],
+m4_define([m4_noquote],
[changequote(-=<{,}>=-)$1-=<{}>=-changequote([,])])
@@ -438,7 +456,7 @@ define([m4_noquote],
# Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO.
# Both limits are included.
-define([m4_for],
+m4_define([m4_for],
[m4_case(m4_sign(m4_eval($3 - $2)),
1, [m4_assert(m4_sign(m4_default($4, 1)) == 1)],
-1, [m4_assert(m4_sign(m4_default($4, -1)) == -1)])dnl
@@ -448,10 +466,10 @@ define([m4_for],
[_m4_for([$1], [$3], m4_default([$4], -1), [$5])])dnl
popdef([$1])])
-define([_m4_for],
+m4_define([_m4_for],
[$4[]dnl
ifelse($1, [$2], [],
- [define([$1], m4_eval($1+[$3]))_m4_for([$1], [$2], [$3], [$4])])])
+ [m4_define([$1], m4_eval($1+[$3]))_m4_for([$1], [$2], [$3], [$4])])])
# Implementing `foreach' loops in m4 is much more tricky than it may
@@ -462,20 +480,20 @@ define([_m4_for],
# The example in the documentation is:
#
# | # foreach(VAR, (LIST), STMT)
-# | define([foreach],
+# | m4_define([foreach],
# | [pushdef([$1])_foreach([$1], [$2], [$3])popdef([$1])])
-# | define([_arg1], [$1])
-# | define([_foreach],
-# | [ifelse([$2], [()], ,
-# | [define([$1], _arg1$2)$3[]_foreach([$1],
-# | (shift$2),
-# | [$3])])])
+# | m4_define([_arg1], [$1])
+# | m4_define([_foreach],
+# | [ifelse([$2], [()], ,
+# | [m4_define([$1], _arg1$2)$3[]_foreach([$1],
+# | (shift$2),
+# | [$3])])])
#
# But then if you run
#
-# | define(a, 1)
-# | define(b, 2)
-# | define(c, 3)
+# | m4_define(a, 1)
+# | m4_define(b, 2)
+# | m4_define(c, 3)
# | foreach([f], [([a], [(b], [c)])], [echo f
# | ])
#
@@ -493,13 +511,13 @@ define([_m4_for],
# apply to the maintenance of m4sugar!).
#
# | # foreach(VAR, (LIST), STMT)
-# | define([foreach], [pushdef([$1])_foreach($@)popdef([$1])])
-# | define([_arg1], [[$1]])
-# | define([_foreach],
+# | m4_define([foreach], [pushdef([$1])_foreach($@)popdef([$1])])
+# | m4_define([_arg1], [[$1]])
+# | m4_define([_foreach],
# | [ifelse($2, [()], ,
-# | [define([$1], [_arg1$2])$3[]_foreach([$1],
-# | [(shift$2)],
-# | [$3])])])
+# | [m4_define([$1], [_arg1$2])$3[]_foreach([$1],
+# | [(shift$2)],
+# | [$3])])])
#
# which this time answers
#
@@ -518,13 +536,13 @@ define([_m4_for],
# simplifies the use:
#
# | # foreach(VAR, (LIST), STMT)
-# | define([foreach], [pushdef([$1])_foreach($@)popdef([$1])])
-# | define([_arg1], [$1])
-# | define([_foreach],
+# | m4_define([foreach], [pushdef([$1])_foreach($@)popdef([$1])])
+# | m4_define([_arg1], [$1])
+# | m4_define([_foreach],
# | [ifelse($2, [], ,
-# | [define([$1], [_arg1($2)])$3[]_foreach([$1],
-# | [shift($2)],
-# | [$3])])])
+# | [m4_define([$1], [_arg1($2)])$3[]_foreach([$1],
+# | [shift($2)],
+# | [$3])])])
#
#
# Now, just replace the `$2' with `m4_quote($2)' in the outer `ifelse'
@@ -541,7 +559,7 @@ define([_m4_for],
# to be expanded.
#
# This macro is robust to active symbols:
-# | define(active, [ACT, IVE])
+# | m4_define(active, [ACT, IVE])
# | m4_foreach(Var, [active, active], [-Var-])
# => -ACT--IVE--ACT--IVE-
#
@@ -550,16 +568,16 @@ define([_m4_for],
#
# | m4_foreach(Var, [[[active]], [[active]]], [-Var-])
# => -active--active-
-define([m4_foreach],
+m4_define([m4_foreach],
[pushdef([$1])_m4_foreach($@)popdef([$1])])
# Low level macros used to define m4_foreach.
-define([m4_car], [$1])
-define([_m4_foreach],
+m4_define([m4_car], [$1])
+m4_define([_m4_foreach],
[ifelse(m4_quote($2), [], [],
- [define([$1], [m4_car($2)])$3[]_m4_foreach([$1],
- [m4_shift($2)],
- [$3])])])
+ [m4_define([$1], [m4_car($2)])$3[]_m4_foreach([$1],
+ [m4_shift($2)],
+ [$3])])])
@@ -572,7 +590,7 @@ define([_m4_foreach],
# ------------------------------------
# If DIVERSION-NAME is the name of a diversion, return its number, otherwise
# return makeNUMBER.
-define([_m4_divert],
+m4_define([_m4_divert],
[ifdef([_m4_divert($1)],
[indir([_m4_divert($1)])],
[$1])])
@@ -581,7 +599,7 @@ define([_m4_divert],
# m4_divert_push(DIVERSION-NAME)
# ------------------------------
# Change the diversion stream to DIVERSION-NAME, while stacking old values.
-define([m4_divert_push],
+m4_define([m4_divert_push],
[pushdef([_m4_divert_diversion], _m4_divert([$1]))dnl
divert(_m4_divert_diversion)dnl
])
@@ -590,7 +608,7 @@ define([m4_divert_push],
# m4_divert_pop
# -------------
# Change the diversion stream to its previous value, unstacking it.
-define([m4_divert_pop],
+m4_define([m4_divert_pop],
[popdef([_m4_divert_diversion])dnl
ifndef([_m4_divert_diversion],
[m4_fatal([too many m4_divert_pop])])dnl
@@ -602,7 +620,7 @@ define([m4_divert_pop],
# ----------------------------------
# Output CONTENT into DIVERSION-NAME (which may be a number actually).
# An end of line is appended for free to CONTENT.
-define([m4_divert],
+m4_define([m4_divert],
[m4_divert_push([$1])dnl
$2
m4_divert_pop()dnl
@@ -613,7 +631,7 @@ define([m4_divert],
## 8. Defining macros with bells and whistles. ##
## -------------------------------------------- ##
-# `m4_defun' is basically `define' but it equips the macro with the
+# `m4_defun' is basically `m4_define' but it equips the macro with the
# needed machinery for `m4_require'. A macro must be m4_defun'd if
# either it is m4_require'd, or it m4_require's.
#
@@ -957,14 +975,14 @@ define([m4_divert],
# - GROW
# m4_defun'd macros are elaborated here.
-define([_m4_divert(GROW)], 10000)
+m4_define([_m4_divert(GROW)], 10000)
# m4_expansion_stack_dump
# ------------------------
# Dump the expansion stack.
-define([m4_expansion_stack_dump],
+m4_define([m4_expansion_stack_dump],
[ifdef([_m4_expansion_stack],
- [m4_errprint(defn([_m4_expansion_stack]))dnl
+ [m4_errprint(m4_defn([_m4_expansion_stack]))dnl
popdef([_m4_expansion_stack])dnl
m4_expansion_stack_dump()],
[m4_errprint(m4_location[: the top level])])])
@@ -973,13 +991,13 @@ define([m4_expansion_stack_dump],
# _m4_defun_pro(MACRO-NAME)
# -------------------------
# The prologue for Autoconf macros.
-define([_m4_defun_pro],
+m4_define([_m4_defun_pro],
[pushdef([_m4_expansion_stack],
- defn([m4_location($1)])[: $1 is expanded from...])dnl
+ m4_defn([m4_location($1)])[: $1 is expanded from...])dnl
pushdef([_m4_expanding($1)])dnl
ifdef([_m4_divert_dump],
- [m4_divert_push(defn([_m4_divert_diversion]))],
- [define([_m4_divert_dump], defn([_m4_divert_diversion]))dnl
+ [m4_divert_push(m4_defn([_m4_divert_diversion]))],
+ [m4_copy([_m4_divert_diversion], [_m4_divert_dump])dnl
m4_divert_push([GROW])])dnl
])
@@ -988,11 +1006,11 @@ define([_m4_defun_pro],
# -------------------------
# The Epilogue for Autoconf macros. MACRO-NAME only helps tracing
# the PRO/EPI pairs.
-define([_m4_defun_epi],
+m4_define([_m4_defun_epi],
[m4_divert_pop()dnl
ifelse(_m4_divert_dump, _m4_divert_diversion,
[undivert(_m4_divert([GROW]))dnl
-undefine([_m4_divert_dump])])dnl
+m4_undefine([_m4_divert_dump])])dnl
popdef([_m4_expansion_stack])dnl
popdef([_m4_expanding($1)])dnl
m4_provide([$1])dnl
@@ -1009,18 +1027,18 @@ define([_m4_defun_epi],
# macros. We don't use this macro to define some frequently called
# macros that are not involved in ordering constraints, to save m4
# processing.
-define([m4_defun],
-[define([m4_location($1)], m4_location)dnl
-define([$1],
- [_m4_defun_pro([$1])$2[]_m4_defun_epi([$1])])])
+m4_define([m4_defun],
+[m4_define([m4_location($1)], m4_location)dnl
+m4_define([$1],
+ [_m4_defun_pro([$1])$2[]_m4_defun_epi([$1])])])
# m4_defun_once(NAME, EXPANSION)
# ------------------------------
# As m4_defun, but issues the EXPANSION only once, and warns if used
# several times.
-define([m4_defun_once],
-[define([$1],
+m4_define([m4_defun_once],
+[m4_define([$1],
[m4_provide_ifelse([$1],
[ac_warn([syntax], [$1 invoked multiple times])],
[_m4_defun_pro([$1])$2[]_m4_defun_epi([$1])])])])
@@ -1033,7 +1051,7 @@ define([m4_defun_once],
# m4_before(THIS-MACRO-NAME, CALLED-MACRO-NAME)
# ---------------------------------------------
-define([m4_before],
+m4_define([m4_before],
[m4_provide_ifelse([$2],
[m4_warn([syntax], [$2 was called before $1])])])
@@ -1067,7 +1085,7 @@ define([m4_before],
# such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this
# `extension' prevents `AC_LANG_COMPILER' from having actual arguments that
# it passes to `AC_LANG_COMPILER(C)'.
-define([_m4_require],
+m4_define([_m4_require],
[pushdef([_m4_expansion_stack],
m4_location[: $1 is required by...])dnl
ifdef([_m4_expanding($1)],
@@ -1091,14 +1109,14 @@ define([_m4_require],
# m4_require(STRING)
# ------------------
# If STRING has never been m4_provide'd, then expand it.
-define([m4_require],
+m4_define([m4_require],
[_m4_require([$1], [$1])])
# m4_expand_once(TEXT)
# --------------------
# If TEXT has never been expanded, expand it *here*.
-define([m4_expand_once],
+m4_define([m4_expand_once],
[m4_provide_ifelse([$1],
[],
[m4_provide([$1])[]$1])])
@@ -1106,8 +1124,8 @@ define([m4_expand_once],
# m4_provide(MACRO-NAME)
# ----------------------
-define([m4_provide],
-[define([m4_provide($1)])])
+m4_define([m4_provide],
+[m4_define([m4_provide($1)])])
# m4_provide_ifelse(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
@@ -1116,7 +1134,7 @@ define([m4_provide],
# The purpose of this macro is to provide the user with a means to
# check macros which are provided without letting her know how the
# information is coded.
-define([m4_provide_ifelse],
+m4_define([m4_provide_ifelse],
[ifdef([m4_provide($1)],
[$2], [$3])])
@@ -1129,12 +1147,12 @@ define([m4_provide_ifelse],
# m4_toupper(STRING)
# ------------------
# These macros lowercase and uppercase strings.
-define([m4_tolower],
+m4_define([m4_tolower],
[translit([$1],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ],
[abcdefghijklmnopqrstuvwxyz])])
-define([m4_toupper],
+m4_define([m4_toupper],
[translit([$1],
[abcdefghijklmnopqrstuvwxyz],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ])])
@@ -1160,12 +1178,12 @@ define([m4_toupper],
# patsubst is ``STRING'' (i.e., with additional `` and '').
#
# This macro is safe on active symbols, i.e.:
-# define(active, ACTIVE)
+# m4_define(active, ACTIVE)
# m4_split([active active ])end
# => [active], [active], []end
changequote(<<, >>)
-define(<<m4_split>>,
+m4_define(<<m4_split>>,
<<changequote(``, '')dnl
[dnl Can't use m4_default here instead of ifelse, because m4_default uses
dnl [ and ] as quotes.
@@ -1182,12 +1200,12 @@ define(<<m4_split>>,
# If STRING contains end of lines, replace them with spaces. If there
# are backslashed end of lines, remove them. This macro is safe with
# active symbols.
-# define(active, ACTIVE)
+# m4_define(active, ACTIVE)
# m4_join([active
# act\
# ive])end
# => active activeend
-define([m4_join],
+m4_define([m4_join],
[translit(patsubst([[[$1]]], [\\
]), [
], [ ])])
@@ -1199,7 +1217,7 @@ define([m4_join],
# space, and removing leading and trailing spaces.
#
# This macro is robust to active symbols.
-# define(active, ACTIVE)
+# m4_define(active, ACTIVE)
# m4_strip([ active active ])end
# => active activeend
#
@@ -1214,7 +1232,7 @@ define([m4_join],
# less [[STRING]]. So if there is a leading space in STRING, then it is
# the *third* character, since there are two leading `['; Equally for
# the outer patsubst.
-define([m4_strip],
+m4_define([m4_strip],
[patsubst(patsubst(patsubst([[[[$1]]]],
[[ ]+], [ ]),
[^\(..\) ], [\1]),
@@ -1230,53 +1248,53 @@ define([m4_strip],
# This macro is robust to active symbols. It can be used to grow
# strings.
#
-# | define(active, ACTIVE)
+# | m4_define(active, ACTIVE)
# | m4_append([sentence], [This is an])
# | m4_append([sentence], [ active ])
# | m4_append([sentence], [symbol.])
# | sentence
-# | undefine([active])dnl
+# | m4_undefine([active])dnl
# | sentence
# => This is an ACTIVE symbol.
# => This is an active symbol.
#
# It can be used to define hooks.
#
-# | define(active, ACTIVE)
-# | m4_append([hooks], [define([act1], [act2])])
-# | m4_append([hooks], [define([act2], [active])])
-# | undefine([active])
+# | m4_define(active, ACTIVE)
+# | m4_append([hooks], [m4_define([act1], [act2])])
+# | m4_append([hooks], [m4_define([act2], [active])])
+# | m4_undefine([active])
# | act1
# | hooks
# | act1
# => act1
# =>
# => active
-define([m4_append],
-[define([$1],
-ifdef([$1], [defn([$1])])[$2])])
+m4_define([m4_append],
+[m4_define([$1],
+ifdef([$1], [m4_defn([$1])])[$2])])
# m4_list_append(MACRO-NAME, STRING)
# ----------------------------------
# Same as `m4_append', but each element is separated by `, '.
-define([m4_list_append],
-[define([$1],
-ifdef([$1], [defn([$1]), ])[$2])])
+m4_define([m4_list_append],
+[m4_define([$1],
+ifdef([$1], [m4_defn([$1]), ])[$2])])
# m4_foreach_quoted(VARIABLE, LIST, EXPRESSION)
# ---------------------------------------------
# FIXME: This macro should not exists. Currently it's used only in
# m4_wrap, which needs to be rewritten. But it's godam hard.
-define([m4_foreach_quoted],
+m4_define([m4_foreach_quoted],
[pushdef([$1], [])_m4_foreach_quoted($@)popdef([$1])])
# Low level macros used to define m4_foreach.
-define([m4_car_quoted], [[$1]])
-define([_m4_foreach_quoted],
+m4_define([m4_car_quoted], [[$1]])
+m4_define([_m4_foreach_quoted],
[ifelse($2, [()], ,
- [define([$1], [m4_car_quoted$2])$3[]_m4_foreach_quoted([$1],
+ [m4_define([$1], [m4_car_quoted$2])$3[]_m4_foreach_quoted([$1],
[(m4_shift$2)],
[$3])])])
@@ -1318,7 +1336,7 @@ define([_m4_foreach_quoted],
# what complicates it a bit. The algorithm is stupid simple: all the
# words are preceded by m4_Separator which is defined to empty for the
# first word, and then ` ' (single space) for all the others.
-define([m4_wrap],
+m4_define([m4_wrap],
[pushdef([m4_Prefix], m4_default([$2], []))dnl
pushdef([m4_Prefix1], m4_default([$3], [m4_Prefix]))dnl
pushdef([m4_Width], m4_default([$4], 79))dnl
@@ -1326,18 +1344,18 @@ define([m4_wrap],
pushdef([m4_Separator], [])dnl
m4_Prefix1[]dnl
ifelse(m4_eval(m4_Cursor > len(m4_Prefix)),
- 1, [define([m4_Cursor], len(m4_Prefix))
+ 1, [m4_define([m4_Cursor], len(m4_Prefix))
m4_Prefix])[]dnl
m4_foreach_quoted([m4_Word], (m4_split(m4_strip(m4_join([$1])))),
-[define([m4_Cursor], m4_eval(m4_Cursor + len(m4_Word) + 1))dnl
+[m4_define([m4_Cursor], m4_eval(m4_Cursor + len(m4_Word) + 1))dnl
dnl New line if too long, else insert a space unless it is the first
dnl of the words.
ifelse(m4_eval(m4_Cursor > m4_Width),
- 1, [define([m4_Cursor], m4_eval(len(m4_Prefix) + len(m4_Word) + 1))]
+ 1, [m4_define([m4_Cursor], m4_eval(len(m4_Prefix) + len(m4_Word) + 1))]
m4_Prefix,
[m4_Separator])[]dnl
m4_Word[]dnl
-define([m4_Separator], [ ])])dnl
+m4_define([m4_Separator], [ ])])dnl
popdef([m4_Separator])dnl
popdef([m4_Cursor])dnl
popdef([m4_Width])dnl
@@ -1355,7 +1373,7 @@ define([m4_Separator], [ ])])dnl
# ----------
#
# The sign of the integer A.
-define([m4_sign],
+m4_define([m4_sign],
[m4_match([$1],
[^-], -1,
[^0+], 0,
@@ -1368,7 +1386,7 @@ define([m4_sign],
# A < B -> -1
# A = B -> 0
# A > B -> 1
-define([m4_cmp],
+m4_define([m4_cmp],
[m4_sign(m4_eval([$1 - $2]))])
@@ -1383,7 +1401,7 @@ define([m4_cmp],
# m4_list_cmp((1, 2, -3), (1, 2)) -> -1
# m4_list_cmp((1, 0), (1, 2)) -> -1
# m4_list_cmp((1), (1, 2)) -> -1
-define([m4_list_cmp],
+m4_define([m4_list_cmp],
[ifelse([$1$2], [()()], 0,
[$1], [()], [m4_list_cmp((0), [$2])],
[$2], [()], [m4_list_cmp([$1], (0))],
@@ -1408,7 +1426,7 @@ define([m4_list_cmp],
#i.e., 2.14a -> 2.15.-1.1, 2.14b -> 2.15.-1.2, etc.
# This macro is absolutely not robust to active macro, it expects
# reasonable version numbers and is valid up to `z', no double letters.
-define([m4_version_unletter],
+m4_define([m4_version_unletter],
[translit(patsubst(patsubst(patsubst([$1],
[\([0-9]+\)\([abcdefghi]\)],
[m4_eval(\1 + 1).-1.\2]),
@@ -1426,6 +1444,6 @@ define([m4_version_unletter],
# -1 if VERSION-1 < VERSION-2
# 0 if =
# 1 if >
-define([m4_version_compare],
+m4_define([m4_version_compare],
[m4_list_cmp((m4_split(m4_version_unletter([$1]), [\.])),
(m4_split(m4_version_unletter([$2]), [\.])))])
Index: m4sh.m4
--- m4sh.m4 Thu, 26 Oct 2000 21:03:04 +0200 akim (ace/b/41_m4sh.m4 1.1 644)
+++ m4sh.m4 Fri, 27 Oct 2000 21:33:41 +0200 akim (ace/b/41_m4sh.m4 1.1 644)
@@ -49,19 +49,6 @@
# Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
# and many other people.
-# Set the quotes, whatever the current quoting system.
-changequote()
-changequote([, ])
-
-# Some old m4's don't support m4exit. But they provide
-# equivalent functionality by core dumping because of the
-# long macros we define.
-ifdef([__gnu__], ,
-[errprint(Autoconf requires GNU m4. Install it before installing Autoconf or
-set the M4 environment variable to its path name.)
-m4exit(2)])
-
-
## ----------------------------- ##
## 1. Wrappers around builtins. ##
@@ -78,7 +65,7 @@
# | IF-FALSE
# | fi
# with simplifications is IF-TRUE and/or IF-FALSE is empty.
-define([AS_IFELSE],
+m4_define([AS_IFELSE],
[ifval([$2$3],
[if $1; then
ifval([$2], [$2], :)
@@ -94,7 +81,7 @@ define([AS_IFELSE],
# --------------------------------------------------
# Try to unset the env VAR, otherwise set it to
# VALUE-IF-UNSET-NOT-SUPPORTED. `ac_unset' must have been computed.
-define([AS_UNSET],
+m4_define([AS_UNSET],
[$ac_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
@@ -110,7 +97,7 @@ define([AS_UNSET],
# AS_MKDIR_P(PATH)
# ----------------
# Emulate `mkdir -p' with plain `mkdir'.
-define([AS_MKDIR_P],
+m4_define([AS_MKDIR_P],
[{ case $1 in
[[\\/]]* | ?:[[\\/]]* ) ac_incr_dir=;;
*) ac_incr_dir=.;;
@@ -152,14 +139,14 @@ define([AS_MKDIR_P],
# a silly length limit that causes expr to fail if the matched
# substring is longer than 120 bytes. So fall back on echo|sed if
# expr fails.
-define([AS_DIRNAME_EXPR],
+m4_define([AS_DIRNAME_EXPR],
[expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
X[]$1 : 'X\(//\)[[^/]]' \| \
X[]$1 : 'X\(//\)$' \| \
X[]$1 : 'X\(/\)' \| \
. : '\(.\)'])
-define([AS_DIRNAME_SED],
+m4_define([AS_DIRNAME_SED],
[echo "X[]$1" |
sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
@@ -167,7 +154,7 @@ define([AS_DIRNAME_SED],
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q']])
-define([AS_DIRNAME],
+m4_define([AS_DIRNAME],
[AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
AS_DIRNAME_SED([$1])])
@@ -184,7 +171,7 @@ define([AS_DIRNAME],
# Create as safely as possible a temporary directory which name is
# inspired by PREFIX (should be 2-4 chars max), and set trap
# mechanisms to remove it.
-define([AS_TMPDIR],
+m4_define([AS_TMPDIR],
[# Create a temporary directory, and hook for its removal unless debugging.
$debug ||
{
- 08-builtins-in-m4.patch,
Akim Demaille <=