* tests/base.at, tests/compile.at, tests/foreign.at,
* tests/m4sh.at, tests/m4sugar.at, tests/mktests.sh,
* tests/semantics.at, tests/suite.at, tests/tools.at,
* tests/torture.at: Ask Autotest mode, not Autoconf mode.
2001-08-20 22:44:38 +08:00
|
|
|
# -*- Autotest -*-
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
2000-11-29 18:12:05 +08:00
|
|
|
AT_BANNER([M4sugar.])
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
2008-03-22 01:07:08 +08:00
|
|
|
# Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007, 2008 Free Software
|
|
|
|
# Foundation, Inc.
|
* AUTHORS, BUGS, ChangeLog, ChangeLog.0, ChangeLog.1,
ChangeLog.2, GNUmakefile, Makefile.maint, NEWS, README,
README-alpha, TODO, configure.ac, lib/autoconf/Makefile.am,
m4/atconfig.m4, m4/init.m4, m4/m4.m4, m4/missing.m4,
m4/sanity.m4, tests/README, tests/aclocal.m4,
tests/atspecific.m4, tests/base.at, tests/compile.at,
tests/foreign.at, tests/m4sh.at, tests/m4sugar.at,
tests/semantics.at, tests/suite.at, tests/tools.at,
tests/torture.at: Add copyright notice.
* tests/mktests.sh: Update year in copyright notice.
2001-08-12 21:05:11 +08:00
|
|
|
#
|
2007-07-21 07:11:49 +08:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
* AUTHORS, BUGS, ChangeLog, ChangeLog.0, ChangeLog.1,
ChangeLog.2, GNUmakefile, Makefile.maint, NEWS, README,
README-alpha, TODO, configure.ac, lib/autoconf/Makefile.am,
m4/atconfig.m4, m4/init.m4, m4/m4.m4, m4/missing.m4,
m4/sanity.m4, tests/README, tests/aclocal.m4,
tests/atspecific.m4, tests/base.at, tests/compile.at,
tests/foreign.at, tests/m4sh.at, tests/m4sugar.at,
tests/semantics.at, tests/suite.at, tests/tools.at,
tests/torture.at: Add copyright notice.
* tests/mktests.sh: Update year in copyright notice.
2001-08-12 21:05:11 +08:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2008-04-04 23:09:47 +08:00
|
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
# any later version.
|
* AUTHORS, BUGS, ChangeLog, ChangeLog.0, ChangeLog.1,
ChangeLog.2, GNUmakefile, Makefile.maint, NEWS, README,
README-alpha, TODO, configure.ac, lib/autoconf/Makefile.am,
m4/atconfig.m4, m4/init.m4, m4/m4.m4, m4/missing.m4,
m4/sanity.m4, tests/README, tests/aclocal.m4,
tests/atspecific.m4, tests/base.at, tests/compile.at,
tests/foreign.at, tests/m4sh.at, tests/m4sugar.at,
tests/semantics.at, tests/suite.at, tests/tools.at,
tests/torture.at: Add copyright notice.
* tests/mktests.sh: Update year in copyright notice.
2001-08-12 21:05:11 +08:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2008-04-04 23:09:47 +08:00
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
# 02110-1301, USA.
|
* AUTHORS, BUGS, ChangeLog, ChangeLog.0, ChangeLog.1,
ChangeLog.2, GNUmakefile, Makefile.maint, NEWS, README,
README-alpha, TODO, configure.ac, lib/autoconf/Makefile.am,
m4/atconfig.m4, m4/init.m4, m4/m4.m4, m4/missing.m4,
m4/sanity.m4, tests/README, tests/aclocal.m4,
tests/atspecific.m4, tests/base.at, tests/compile.at,
tests/foreign.at, tests/m4sh.at, tests/m4sugar.at,
tests/semantics.at, tests/suite.at, tests/tools.at,
tests/torture.at: Add copyright notice.
* tests/mktests.sh: Update year in copyright notice.
2001-08-12 21:05:11 +08:00
|
|
|
|
2001-01-17 23:26:42 +08:00
|
|
|
|
2006-02-21 05:43:05 +08:00
|
|
|
# AT_CHECK_M4SUGAR_TEXT(CODE, STDOUT, STDERR)
|
|
|
|
# -------------------------------------------
|
2005-02-05 12:55:08 +08:00
|
|
|
# Check that m4sugar CODE expands to STDOUT and emits STDERR.
|
|
|
|
m4_define([AT_CHECK_M4SUGAR_TEXT],
|
|
|
|
[
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_init
|
|
|
|
m4_divert_push(0)[]dnl
|
|
|
|
]$1[[]dnl
|
|
|
|
m4_divert_pop(0)
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-],, [$2], [$3])
|
|
|
|
])# AT_CHECK_M4SUGAR_TEXT
|
|
|
|
|
|
|
|
|
2008-10-28 18:27:31 +08:00
|
|
|
## ------------------ ##
|
|
|
|
## m4_stack_foreach. ##
|
|
|
|
## ------------------ ##
|
|
|
|
|
2008-10-29 05:11:16 +08:00
|
|
|
AT_SETUP([m4@&t@_stack])
|
2008-10-28 18:27:31 +08:00
|
|
|
|
2008-10-29 05:11:16 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_stack_foreach m4@&t@_stack_foreach_lifo])
|
|
|
|
AT_KEYWORDS([m4@&t@_stack_foreach_sep m4@&t@_stack_foreach_sep_lifo])
|
|
|
|
AT_KEYWORDS([m4@&t@_copy m4@&t@_n])
|
2008-10-28 18:27:31 +08:00
|
|
|
|
|
|
|
# Test the semantics of macros to walk stacked macro definitions.
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[dnl
|
|
|
|
m4_pushdef([abc], [def])dnl
|
|
|
|
m4_pushdef([abc], [ghi])dnl
|
|
|
|
m4_pushdef([abc], [jkl])dnl
|
|
|
|
m4_stack_foreach([abc], [m4_n])
|
|
|
|
abc
|
|
|
|
m4_stack_foreach_lifo([abc], [m4_n])
|
|
|
|
m4_stack_foreach([abc], [m4_n])
|
|
|
|
m4_copy([abc], [foo])dnl
|
|
|
|
m4_stack_foreach([foo], [m4_n])
|
|
|
|
m4_stack_foreach_lifo([foo], [m4_n])
|
2008-10-29 05:11:16 +08:00
|
|
|
m4_stack_foreach_sep([abc], [ m4_index([abcdefghijkl],], [)])
|
|
|
|
m4_stack_foreach_sep_lifo([abc], [<], [>], [:])
|
2008-10-28 18:27:31 +08:00
|
|
|
m4_pushdef([xyz], [123])dnl
|
|
|
|
m4_pushdef([xyz], [456])dnl
|
2008-10-29 05:11:16 +08:00
|
|
|
m4_define([doit], [[$1](m4_stack_foreach_sep([xyz], [m4_dquote(], [)], [,]))
|
2008-10-28 18:27:31 +08:00
|
|
|
])dnl
|
|
|
|
m4_stack_foreach([abc], [doit])]],
|
|
|
|
[[def
|
|
|
|
ghi
|
|
|
|
jkl
|
|
|
|
|
|
|
|
jkl
|
|
|
|
jkl
|
|
|
|
ghi
|
|
|
|
def
|
|
|
|
|
|
|
|
def
|
|
|
|
ghi
|
|
|
|
jkl
|
|
|
|
|
|
|
|
def
|
|
|
|
ghi
|
|
|
|
jkl
|
|
|
|
|
|
|
|
jkl
|
|
|
|
ghi
|
|
|
|
def
|
|
|
|
|
2008-10-29 05:11:16 +08:00
|
|
|
3 6 9
|
|
|
|
<jkl>:<ghi>:<def>
|
|
|
|
def([123],[456])
|
|
|
|
ghi([123],[456])
|
|
|
|
jkl([123],[456])
|
2008-10-28 18:27:31 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-07-19 02:05:43 +08:00
|
|
|
## --------- ##
|
|
|
|
## m4_defn. ##
|
|
|
|
## --------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_defn])
|
|
|
|
|
2008-10-24 11:17:25 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine m4@&t@_copy m4@&t@_rename])
|
2008-07-19 02:05:43 +08:00
|
|
|
|
|
|
|
# Ensure that m4sugar dies when dereferencing undefined macros, whether
|
|
|
|
# this is provided by m4 natively or faked by wrappers in m4sugar.
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
2008-07-19 04:26:41 +08:00
|
|
|
[[m4_define([good])
|
|
|
|
m4_defn([good], [oops])
|
2008-07-19 02:05:43 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
|
2008-07-19 04:26:41 +08:00
|
|
|
AT_CHECK([grep good stderr], [1])
|
2008-07-19 02:05:43 +08:00
|
|
|
AT_CHECK([grep 'm4@&t@_defn: undefined.*oops' stderr], [0], [ignore])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
2008-07-19 04:26:41 +08:00
|
|
|
[[m4_define([good])
|
|
|
|
m4_popdef([good], [oops])
|
2008-07-19 02:05:43 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
|
2008-07-19 04:26:41 +08:00
|
|
|
AT_CHECK([grep good stderr], [1])
|
2008-07-19 02:05:43 +08:00
|
|
|
AT_CHECK([grep 'm4@&t@_popdef: undefined.*oops' stderr], [0], [ignore])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
2008-07-19 04:26:41 +08:00
|
|
|
[[m4_define([good])
|
|
|
|
m4_undefine([good], [oops])
|
2008-07-19 02:05:43 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
|
2008-07-19 04:26:41 +08:00
|
|
|
AT_CHECK([grep good stderr], [1])
|
2008-07-19 02:05:43 +08:00
|
|
|
AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
|
|
|
|
|
2008-10-24 11:17:25 +08:00
|
|
|
# Check that pushdef stacks can be renamed.
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[m4_pushdef([a], [1])dnl
|
|
|
|
m4_pushdef([a], [2])dnl
|
|
|
|
a b c
|
|
|
|
m4_rename([a], [b])dnl
|
|
|
|
a b c
|
|
|
|
m4_copy([b], [c])dnl
|
|
|
|
a b c
|
|
|
|
m4_popdef([b], [c])dnl
|
|
|
|
a b c
|
|
|
|
m4_popdef([b], [c])dnl
|
|
|
|
a b c
|
|
|
|
]], [[2 b c
|
|
|
|
a 2 c
|
|
|
|
a 2 2
|
|
|
|
a 1 1
|
|
|
|
a b c
|
|
|
|
]])
|
|
|
|
|
2008-07-19 02:05:43 +08:00
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-10-29 02:14:06 +08:00
|
|
|
## ------------ ##
|
|
|
|
## m4_dumpdef. ##
|
|
|
|
## ------------ ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_dumpdef])
|
|
|
|
|
|
|
|
AT_KEYWORDS([m4@&t@_dumpdefs])
|
|
|
|
|
|
|
|
# Ensure that m4sugar dies when dereferencing undefined macros.
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_define([good], [yep])
|
|
|
|
m4_dumpdef([good], [oops])
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
|
|
|
|
AT_CHECK([grep '^good: \[[yep\]]$' stderr], [0], [ignore])
|
|
|
|
AT_CHECK([grep 'm4@&t@_dumpdef: undefined.*oops' stderr], [0], [ignore])
|
|
|
|
|
|
|
|
# Check that pushdef stacks can be dumped.
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[m4_divert_push([KILL])
|
|
|
|
m4_pushdef([a], [1])
|
|
|
|
m4_pushdef([a], [2])
|
|
|
|
m4_dumpdef([a])
|
2008-10-31 05:51:26 +08:00
|
|
|
m4_dumpdefs([oops], [a])
|
2008-10-29 02:14:06 +08:00
|
|
|
m4_divert_pop([KILL])dnl
|
|
|
|
]], [],
|
|
|
|
[[a: [2]
|
|
|
|
a: [2]
|
|
|
|
a: [1]
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2001-01-17 23:26:42 +08:00
|
|
|
## --------- ##
|
|
|
|
## m4_warn. ##
|
|
|
|
## --------- ##
|
|
|
|
|
2005-02-05 12:55:08 +08:00
|
|
|
AT_SETUP([m4@&t@_warn])
|
2001-01-17 23:26:42 +08:00
|
|
|
|
|
|
|
# m4_text_wrap is used to display the help strings. Also, check that
|
|
|
|
# commas are not swallowed. This can easily happen because of
|
|
|
|
# m4-listification.
|
|
|
|
|
2001-08-15 15:49:59 +08:00
|
|
|
# FIXME: For the time being we use -f to make sure we do issue the
|
|
|
|
# warnings. But maybe autom4te should handle that by itself?
|
|
|
|
|
2001-10-08 16:21:54 +08:00
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
2003-08-22 21:38:33 +08:00
|
|
|
[[m4_init
|
2006-10-26 22:41:44 +08:00
|
|
|
m4_defun([cross_warning], [m4_warn([cross], [cross])])
|
2003-08-22 21:38:33 +08:00
|
|
|
|
2006-06-20 13:35:38 +08:00
|
|
|
m4_divert([0])dnl
|
2003-08-27 23:14:03 +08:00
|
|
|
m4_warn([obsolete], [obsolete])dnl
|
|
|
|
cross_warning[]dnl
|
|
|
|
m4_warn([syntax], [syntax])dnl
|
2001-01-17 23:26:42 +08:00
|
|
|
]])
|
|
|
|
|
The use of `dumpstat' revealed that `len' was used although it
should not. m4_text_wrap was using it, but in the Autoconf world
where it is legal. Hence (i) test M4sh in its own world, not
Autoconf's, and (ii), ahem, fix the bug :)
* lib/autotest/general.m4: Be sure the set good quotes, as tracing
does not like `' instead of [].
(AT_INIT): Forbid `^_?AT_'.
And don't output such tokens.
* tests/Makefile.am (CLEANFILES): Add `script', `script.s4g',
`script.as', and `autom4te.cache'.
Remove `empty' and `macro' which are no longer used.
* tests/atspecific.m4 (AT_CHECK_M4SUGAR, AT_CHECK_M4SH): New.
* tests/m4sugar.at: Use it.
* lib/m4sugar/m4sugar.m4: Use `m4_len' not `len'.
2001-08-07 15:56:40 +08:00
|
|
|
AT_CHECK_M4SUGAR([-o-], 0, [],
|
2006-10-26 22:41:44 +08:00
|
|
|
[script.4s:7: warning: syntax
|
2001-01-17 23:26:42 +08:00
|
|
|
])
|
|
|
|
|
2001-08-15 15:49:59 +08:00
|
|
|
AT_CHECK_M4SUGAR([-o- -Wall -f], 0, [],
|
2006-10-26 22:41:44 +08:00
|
|
|
[script.4s:5: warning: obsolete
|
|
|
|
script.4s:6: warning: cross
|
|
|
|
script.4s:2: cross_warning is expanded from...
|
|
|
|
script.4s:6: the top level
|
|
|
|
script.4s:7: warning: syntax
|
2001-01-17 23:26:42 +08:00
|
|
|
])
|
|
|
|
|
First stab at preserving warnings between calls to autom4te,
including when the cache is used.
There are still several issues: (i) there are too many runs of m4
(one for include, one for warnings, and some more), (ii) warnings
spreading on several lines are not handled gracefully, (iii) the
code meant to have the call stack display for errors does not work
(its handling should move from m4 to autom4te).
* bin/autom4te.in Autom4te::Channels, Autom4te::ChannelDefs):
Use them.
(@preselect): Add m4_warn.
($exit_status): Remove, use $exit_code.
($help): Use Autom4te::ChannelDefs::usage.
(&handle_m4): No longer define the m4_warnings.
At each run, extract and report the warnings.
Always cache the result, including if the exit status is on
failure, since if nothing changes, we should result in the same
failure, hence we can use the cache.
* lib/m4sugar/m4sugar.m4 (m4_warning_ifelse, _m4_warning_ifelse)
(_m4_warning_error_ifelse, __m4_warning_error_ifelse, _m4_warn):
Remove.
(m4_warn): Redefine as a do-nothing: it is its invocation that
matters, as warnings are now reported via traces.
* lib/autoconf/general.m4 (AC_DIAGNOSE): Don't make it a copy of
the contents of m4_warn: make it _call_ m4_warn, so that tracing
the latter reveals calls to the former.
Adjust the tests.
* tests/m4sugar.at (m4@&t@_warn): Use existing warning categories.
2003-08-22 01:25:28 +08:00
|
|
|
AT_CHECK_M4SUGAR([-o- -Wnone,cross -f], 0, [],
|
2006-10-26 22:41:44 +08:00
|
|
|
[script.4s:6: warning: cross
|
|
|
|
script.4s:2: cross_warning is expanded from...
|
|
|
|
script.4s:6: the top level
|
2001-01-17 23:26:42 +08:00
|
|
|
])
|
|
|
|
|
First stab at preserving warnings between calls to autom4te,
including when the cache is used.
There are still several issues: (i) there are too many runs of m4
(one for include, one for warnings, and some more), (ii) warnings
spreading on several lines are not handled gracefully, (iii) the
code meant to have the call stack display for errors does not work
(its handling should move from m4 to autom4te).
* bin/autom4te.in Autom4te::Channels, Autom4te::ChannelDefs):
Use them.
(@preselect): Add m4_warn.
($exit_status): Remove, use $exit_code.
($help): Use Autom4te::ChannelDefs::usage.
(&handle_m4): No longer define the m4_warnings.
At each run, extract and report the warnings.
Always cache the result, including if the exit status is on
failure, since if nothing changes, we should result in the same
failure, hence we can use the cache.
* lib/m4sugar/m4sugar.m4 (m4_warning_ifelse, _m4_warning_ifelse)
(_m4_warning_error_ifelse, __m4_warning_error_ifelse, _m4_warn):
Remove.
(m4_warn): Redefine as a do-nothing: it is its invocation that
matters, as warnings are now reported via traces.
* lib/autoconf/general.m4 (AC_DIAGNOSE): Don't make it a copy of
the contents of m4_warn: make it _call_ m4_warn, so that tracing
the latter reveals calls to the former.
Adjust the tests.
* tests/m4sugar.at (m4@&t@_warn): Use existing warning categories.
2003-08-22 01:25:28 +08:00
|
|
|
AT_CHECK_M4SUGAR([-o- -Wnone,cross,error -f], 1, [],
|
2006-10-26 22:41:44 +08:00
|
|
|
[[script.4s:6: warning: cross
|
|
|
|
script.4s:2: cross_warning is expanded from...
|
|
|
|
script.4s:6: the top level
|
2002-08-29 16:03:10 +08:00
|
|
|
]])
|
2001-01-17 23:26:42 +08:00
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-10-31 05:32:56 +08:00
|
|
|
## ----------------- ##
|
|
|
|
## m4_divert_stack. ##
|
|
|
|
## ----------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_divert_stack])
|
2008-10-31 05:51:26 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_divert m4@&t@_divert_push m4@&t@_divert_pop
|
|
|
|
m4@&t@_undivert])
|
2008-10-31 05:32:56 +08:00
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[1.m4_divert_stack
|
|
|
|
m4_divert_push([10])2.m4_divert_stack
|
|
|
|
m4_divert_text([20], [3.m4_divert_stack])dnl
|
|
|
|
m4_divert([30])4.m4_divert_stack
|
|
|
|
m4_divert_pop([30])dnl
|
2008-10-31 05:51:26 +08:00
|
|
|
5.m4_undivert([20], [30])
|
2008-10-31 05:32:56 +08:00
|
|
|
m4_pattern_allow([^m4_divert])dnl
|
|
|
|
]], [[1.script.4s:2: m4@&t@_divert_push: 0
|
|
|
|
script.4s:1: m4@&t@_divert: KILL
|
|
|
|
5.3.script.4s:5: m4@&t@_divert_push: 20
|
|
|
|
script.4s:4: m4@&t@_divert_push: 10
|
|
|
|
script.4s:2: m4@&t@_divert_push: 0
|
|
|
|
script.4s:1: m4@&t@_divert: KILL
|
2008-10-31 05:51:26 +08:00
|
|
|
4.script.4s:6: m4@&t@_divert: 30
|
2008-10-31 05:32:56 +08:00
|
|
|
script.4s:2: m4@&t@_divert_push: 0
|
|
|
|
script.4s:1: m4@&t@_divert: KILL
|
|
|
|
|
|
|
|
2.script.4s:4: m4@&t@_divert_push: 10
|
|
|
|
script.4s:2: m4@&t@_divert_push: 0
|
|
|
|
script.4s:1: m4@&t@_divert: KILL
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_divert_pop
|
|
|
|
]])
|
|
|
|
AT_CHECK_M4SUGAR([-o-], [1], [],
|
|
|
|
[[script.4s:1: error: too many m4@&t@_divert_pop
|
|
|
|
script.4s:1: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_init
|
|
|
|
m4_divert_push([1])
|
|
|
|
m4_divert_pop([2])
|
|
|
|
]])
|
|
|
|
AT_CHECK_M4SUGAR([-o-], [1], [],
|
|
|
|
[[script.4s:3: error: m4@&t@_divert_pop(2): diversion mismatch:
|
|
|
|
script.4s:2: m4@&t@_divert_push: 1
|
|
|
|
script.4s:1: m4@&t@_divert: KILL
|
|
|
|
script.4s:3: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_divert([1])
|
|
|
|
m4_init
|
|
|
|
m4_divert_push([2])
|
|
|
|
]])
|
|
|
|
AT_CHECK_M4SUGAR([-o-], [1], [],
|
|
|
|
[[script.4s:2: error: m4@&t@_init: unbalanced m4@&t@_divert_push:
|
|
|
|
script.4s:3: m4@&t@_divert_push: 2
|
|
|
|
script.4s:2: m4@&t@_divert: KILL
|
|
|
|
script.4s:2: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-10-31 02:16:15 +08:00
|
|
|
## -------------------- ##
|
|
|
|
## m4_expansion_stack. ##
|
|
|
|
## -------------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_expansion_stack])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[1.m4_expansion_stack
|
|
|
|
m4_defun([a], [b])dnl
|
|
|
|
m4_define([c], [d])dnl
|
|
|
|
m4_defun([d], [2.m4_expansion_stack])dnl
|
|
|
|
m4_defun([b], [c])dnl
|
|
|
|
a
|
|
|
|
3.m4_ifdef([_m4_expansion_stack], [m4_expansion_stack])
|
|
|
|
]], [[1.script.4s:3: the top level
|
|
|
|
2.script.4s:6: d is expanded from...
|
|
|
|
script.4s:7: b is expanded from...
|
|
|
|
script.4s:4: a is expanded from...
|
|
|
|
script.4s:8: the top level
|
|
|
|
3.
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2006-06-05 16:18:33 +08:00
|
|
|
## --------------------------- ##
|
|
|
|
## m4_require: error message. ##
|
|
|
|
## --------------------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_require: error message])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_defun([foo], [FOO])
|
|
|
|
m4_require([foo])
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
|
|
|
[[script.4s:2: error: m4@&t@_require(foo): cannot be used outside of an m4_defun'd macro
|
|
|
|
script.4s:2: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2001-01-17 23:26:42 +08:00
|
|
|
## ----------------------------------- ##
|
|
|
|
## m4_require: circular dependencies. ##
|
|
|
|
## ----------------------------------- ##
|
|
|
|
|
2005-02-05 12:55:08 +08:00
|
|
|
AT_SETUP([m4@&t@_require: circular dependencies])
|
2001-01-17 23:26:42 +08:00
|
|
|
|
2001-10-08 16:21:54 +08:00
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
2006-10-26 22:41:44 +08:00
|
|
|
[[m4_defun([foo], [m4_require([bar])])
|
2001-01-17 23:26:42 +08:00
|
|
|
|
2006-10-26 22:41:44 +08:00
|
|
|
m4_defun([bar], [m4_require([foo])])
|
2001-01-17 23:26:42 +08:00
|
|
|
|
2006-10-26 22:41:44 +08:00
|
|
|
m4_defun([baz], [m4_require([foo])])
|
2001-01-17 23:26:42 +08:00
|
|
|
|
2001-01-18 17:16:08 +08:00
|
|
|
m4_init
|
2006-06-20 13:35:38 +08:00
|
|
|
m4_divert([0])dnl
|
2001-01-17 23:26:42 +08:00
|
|
|
baz
|
|
|
|
]])
|
|
|
|
|
2002-10-18 23:20:46 +08:00
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
2006-10-26 22:41:44 +08:00
|
|
|
[[script.4s:9: error: m4@&t@_require: circular dependency of foo
|
|
|
|
script.4s:3: bar is expanded from...
|
|
|
|
script.4s:1: foo is expanded from...
|
|
|
|
script.4s:5: baz is expanded from...
|
|
|
|
script.4s:9: the top level
|
2002-08-29 16:03:10 +08:00
|
|
|
autom4te: m4 failed with exit status: 1
|
2001-01-17 23:26:42 +08:00
|
|
|
]])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
Optimize clients of AS_REQUIRE.
* lib/m4sugar/m4sugar.m4 (m4_defun): Add undocumented third
argument.
(m4_defun_init): New undocumented macro.
* lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG, AS_MESSAGE, AS_BASENAME)
(_AS_DIRNAME_EXPR, AS_DIRNAME, AS_ECHO, AS_ECHO_N, AS_TEST_X)
(AS_LN_S, AS_MKDIR_P, _AS_PATH_WALK, AS_VERSION_COMPARE)
(AS_TR_SH, AS_TR_CPP, AS_VAR_APPEND, AS_VAR_PUSHDEF): Use it to
simplify these macros once the one-shot initialization is
complete.
* tests/m4sugar.at (m4@&t@_require: one-shot initialization): New
test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-24 05:08:45 +08:00
|
|
|
## ---------------------- ##
|
|
|
|
## m4_require: one-shot. ##
|
|
|
|
## ---------------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_require: one-shot initialization])
|
2008-10-25 01:24:32 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_defun_init m4@&t@_copy])
|
Optimize clients of AS_REQUIRE.
* lib/m4sugar/m4sugar.m4 (m4_defun): Add undocumented third
argument.
(m4_defun_init): New undocumented macro.
* lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG, AS_MESSAGE, AS_BASENAME)
(_AS_DIRNAME_EXPR, AS_DIRNAME, AS_ECHO, AS_ECHO_N, AS_TEST_X)
(AS_LN_S, AS_MKDIR_P, _AS_PATH_WALK, AS_VERSION_COMPARE)
(AS_TR_SH, AS_TR_CPP, AS_VAR_APPEND, AS_VAR_PUSHDEF): Use it to
simplify these macros once the one-shot initialization is
complete.
* tests/m4sugar.at (m4@&t@_require: one-shot initialization): New
test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-24 05:08:45 +08:00
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[
|
|
|
|
m4_defun_init([a], [[init a
|
|
|
|
]], [[common a]])dnl
|
|
|
|
m4_defun([b], [[b]m4_require([a])])dnl
|
|
|
|
m4_defun([c], [[c]m4_require([a])])dnl
|
|
|
|
b
|
|
|
|
c
|
|
|
|
a
|
2008-10-25 01:24:32 +08:00
|
|
|
m4_defun_init([-], [hello, ], [m4_if([$#], [0], [world], [[$1]])])dnl
|
|
|
|
m4_copy([-], [.])dnl
|
|
|
|
m4_indir([.])
|
|
|
|
m4_indir([.], [goodbye])
|
|
|
|
m4_indir([-], [again])
|
Optimize clients of AS_REQUIRE.
* lib/m4sugar/m4sugar.m4 (m4_defun): Add undocumented third
argument.
(m4_defun_init): New undocumented macro.
* lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG, AS_MESSAGE, AS_BASENAME)
(_AS_DIRNAME_EXPR, AS_DIRNAME, AS_ECHO, AS_ECHO_N, AS_TEST_X)
(AS_LN_S, AS_MKDIR_P, _AS_PATH_WALK, AS_VERSION_COMPARE)
(AS_TR_SH, AS_TR_CPP, AS_VAR_APPEND, AS_VAR_PUSHDEF): Use it to
simplify these macros once the one-shot initialization is
complete.
* tests/m4sugar.at (m4@&t@_require: one-shot initialization): New
test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-24 05:08:45 +08:00
|
|
|
]], [[
|
|
|
|
init a
|
|
|
|
common a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
common a
|
2008-10-25 01:24:32 +08:00
|
|
|
hello, world
|
|
|
|
goodbye
|
|
|
|
hello, again
|
Optimize clients of AS_REQUIRE.
* lib/m4sugar/m4sugar.m4 (m4_defun): Add undocumented third
argument.
(m4_defun_init): New undocumented macro.
* lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG, AS_MESSAGE, AS_BASENAME)
(_AS_DIRNAME_EXPR, AS_DIRNAME, AS_ECHO, AS_ECHO_N, AS_TEST_X)
(AS_LN_S, AS_MKDIR_P, _AS_PATH_WALK, AS_VERSION_COMPARE)
(AS_TR_SH, AS_TR_CPP, AS_VAR_APPEND, AS_VAR_PUSHDEF): Use it to
simplify these macros once the one-shot initialization is
complete.
* tests/m4sugar.at (m4@&t@_require: one-shot initialization): New
test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-24 05:08:45 +08:00
|
|
|
]])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-08-12 20:32:23 +08:00
|
|
|
## --------- ##
|
|
|
|
## m4_cond. ##
|
|
|
|
## --------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_cond])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[m4_define([side], [m4_errprintn([$1])$1])
|
|
|
|
m4_cond([side(1)], [1], [a],
|
|
|
|
[side(1)], [1], [b],
|
|
|
|
[side(1)], [2], [c])
|
|
|
|
m4_cond([side(2)], [1], [a],
|
|
|
|
[side(2)], [1], [b],
|
|
|
|
[side(2)], [2], [c],
|
|
|
|
[side(2)])
|
|
|
|
m4_cond([side(3)], [1], [a],
|
|
|
|
[side(3)], [1], [b],
|
|
|
|
[side(3)], [2], [c],
|
|
|
|
[side(3)])
|
|
|
|
m4_cond([a,a], [a,a], [yes], [no])
|
|
|
|
m4_cond([[a,a]], [a,a], [yes])
|
|
|
|
m4_cond([a,a], [a,b], [yes], [no])
|
|
|
|
m4_cond([a,a], [a,b], [yes])
|
|
|
|
m4_cond([m4_eval([0xa])])
|
2008-08-12 23:18:53 +08:00
|
|
|
m4_define([ab], [AB])dnl
|
|
|
|
m4_cond([a])b
|
|
|
|
m4_cond([1], [1], [a])b
|
|
|
|
m4_cond([1], [2], [3], [a])b
|
2008-08-12 20:32:23 +08:00
|
|
|
]], [[
|
|
|
|
a
|
|
|
|
c
|
|
|
|
3
|
|
|
|
yes
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
|
|
|
|
10
|
2008-08-12 23:18:53 +08:00
|
|
|
AB
|
|
|
|
AB
|
|
|
|
AB
|
2008-08-12 20:32:23 +08:00
|
|
|
]], [[1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
2
|
|
|
|
3
|
|
|
|
3
|
|
|
|
3
|
|
|
|
3
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2007-10-04 23:43:59 +08:00
|
|
|
## ---------- ##
|
|
|
|
## m4_split. ##
|
|
|
|
## ---------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_split])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_define([active], [ACT, IVE])m4_define([bd], [oops])
|
|
|
|
m4_split
|
|
|
|
m4_split([[]])
|
|
|
|
m4_split([ ])
|
|
|
|
m4_split([active])
|
|
|
|
m4_split([ active active ])end
|
|
|
|
m4_split([ ], [ ])
|
|
|
|
m4_split([active], [ ])
|
|
|
|
m4_split([ active active ], [ ])end
|
|
|
|
m4_split([abcde], [bd])
|
|
|
|
m4_split([abcde], [[bd]])
|
|
|
|
m4_split([foo=`` bar=''])
|
|
|
|
m4_split([foo='' bar=``])
|
2008-04-24 23:31:16 +08:00
|
|
|
dnl these next two are from the manual; keep this in sync if the internal
|
|
|
|
dnl quoting strings in m4_split are changed
|
|
|
|
m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])dnl
|
|
|
|
m4_split([a )}>=- b -=<{( c])
|
|
|
|
m4_split([a )}@&t@>=- b -=<@&t@{( c])
|
2007-10-04 23:43:59 +08:00
|
|
|
]],
|
|
|
|
[[
|
|
|
|
|
|
|
|
[[]]
|
|
|
|
[], []
|
|
|
|
[active]
|
|
|
|
[], [active], [active], []end
|
|
|
|
[], []
|
|
|
|
[active]
|
|
|
|
[], [active active], []end
|
|
|
|
[abcde]
|
|
|
|
[a], [c], [e]
|
|
|
|
[foo=``], [bar='']
|
|
|
|
[foo=''], [bar=``]
|
2008-04-24 23:31:16 +08:00
|
|
|
[a], [], [B], [], [c]
|
|
|
|
[a], [)}>=-], [b], [-=<{(], [c]
|
2007-10-04 23:43:59 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-07-30 04:17:03 +08:00
|
|
|
## ------- ##
|
|
|
|
## m4_do. ##
|
|
|
|
## ------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_do])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_define([ab], [1])m4_define([bc], [2])m4_define([abc], [3])dnl
|
|
|
|
m4_define([AB], [4])m4_define([BC], [5])m4_define([ABC], [6])dnl
|
|
|
|
m4_do
|
|
|
|
m4_do([a])
|
|
|
|
m4_do([a], [b])c
|
|
|
|
m4_unquote(m4_join([], [a], [b]))c
|
|
|
|
m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])dnl
|
|
|
|
m4_do([a], [b])c
|
|
|
|
m4_unquote(m4_join([], [a], [b]))c
|
|
|
|
]],
|
|
|
|
[[
|
|
|
|
a
|
|
|
|
abc
|
|
|
|
3
|
|
|
|
ABC
|
|
|
|
3
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2007-10-12 04:46:40 +08:00
|
|
|
## ----------- ##
|
|
|
|
## m4_append. ##
|
|
|
|
## ----------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_append])
|
2008-11-06 08:11:15 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_append_uniq m4@&t@_append_uniq_w])
|
2007-10-12 04:46:40 +08:00
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_define([active], [ACTIVE])dnl
|
|
|
|
m4_append([sentence], [This is an])dnl
|
|
|
|
m4_append([sentence], [ active ])dnl
|
|
|
|
m4_append([sentence], [symbol.])dnl
|
|
|
|
sentence
|
|
|
|
m4_undefine([active])dnl
|
|
|
|
sentence
|
|
|
|
m4_define([active], [ACTIVE])dnl
|
|
|
|
m4_append([hooks], [m4_define([act1], [act2])])dnl
|
|
|
|
m4_append([hooks], [m4_define([act2], [active])])dnl
|
|
|
|
m4_undefine([active])dnl
|
|
|
|
act1
|
|
|
|
hooks
|
|
|
|
act1
|
|
|
|
dnl Test for bug fixed in 2.62 when separator is active.
|
|
|
|
m4_define([a], [A])dnl
|
|
|
|
m4_append_uniq([foo], [-], [a])dnl
|
|
|
|
m4_append_uniq([foo], [-], [a])dnl
|
|
|
|
m4_append_uniq([bar], [-], [a])dnl
|
|
|
|
m4_append_uniq([bar], [~], [a])dnl
|
|
|
|
m4_append_uniq([bar], [-], [a])dnl
|
|
|
|
m4_defn([foo])
|
|
|
|
m4_defn([bar])
|
|
|
|
foo
|
|
|
|
bar
|
|
|
|
m4_append_uniq([blah], [one], [, ], [new], [existing])
|
|
|
|
m4_append_uniq([blah], [two], [, ], [new], [existing])
|
|
|
|
m4_append_uniq([blah], [two], [, ], [new], [existing])
|
|
|
|
m4_append_uniq([blah], [three], [, ], [new], [existing])
|
|
|
|
m4_append([blah], [two], [, ])dnl
|
|
|
|
blah
|
|
|
|
m4_dquote(blah)
|
|
|
|
m4_append([list], [one], [[, ]])dnl
|
|
|
|
m4_append([list], [two], [[, ]])dnl
|
|
|
|
m4_append([list], [three], [[, ]])dnl
|
|
|
|
list
|
|
|
|
m4_dquote(list)
|
2007-10-18 23:05:09 +08:00
|
|
|
m4_append_uniq_w([numbers], [1 1 2])dnl
|
|
|
|
m4_append_uniq_w([numbers], [ 2 3 ])dnl
|
|
|
|
numbers
|
2007-10-12 04:46:40 +08:00
|
|
|
]],
|
|
|
|
[[This is an ACTIVE symbol.
|
|
|
|
This is an active symbol.
|
|
|
|
act1
|
|
|
|
|
|
|
|
active
|
|
|
|
-
|
|
|
|
-a~
|
|
|
|
-
|
|
|
|
-A~
|
|
|
|
new
|
|
|
|
new
|
|
|
|
existing
|
|
|
|
new
|
|
|
|
one, two, three, two
|
|
|
|
[one],[two],[three],[two]
|
|
|
|
one, two, three
|
|
|
|
[one, two, three]
|
2007-10-18 23:05:09 +08:00
|
|
|
1 2 3
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
2008-10-28 19:18:55 +08:00
|
|
|
[[m4_init[]dnl
|
|
|
|
m4_append_uniq([str], [a], [ ])
|
2007-10-18 23:05:09 +08:00
|
|
|
m4_append_uniq([str], [a b], [ ])
|
|
|
|
m4_divert([0])dnl
|
|
|
|
str
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], 0, [[a a b
|
2008-10-28 19:18:55 +08:00
|
|
|
]], [[script.4s:3: warning: m4@&t@_append_uniq: `a b' contains ` '
|
2007-10-12 04:46:40 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2007-10-14 01:11:44 +08:00
|
|
|
## --------- ##
|
|
|
|
## m4_join. ##
|
|
|
|
## --------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_join])
|
|
|
|
|
2008-07-18 22:30:07 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_joinall])
|
|
|
|
|
2007-10-14 01:11:44 +08:00
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_define([active], [ACTIVE])
|
|
|
|
m4_join
|
|
|
|
m4_join([|])
|
|
|
|
m4_join([, ], [one], [two])
|
|
|
|
m4_dquote(m4_join([, ], [one], [two]))
|
|
|
|
m4_join([|], [active], [active])
|
|
|
|
m4_join([|], ,,,[one])
|
|
|
|
m4_join([|], [one],,,)
|
|
|
|
m4_join([], ,,,[two])
|
|
|
|
m4_join([], [two],,,)
|
|
|
|
m4_join([ active ], [one], , [two])
|
|
|
|
m4_join([], [one], [two])
|
2008-07-18 22:30:07 +08:00
|
|
|
m4_joinall([-], [one], [], [two])
|
|
|
|
m4_joinall([-], [], [], [three], [], [])
|
|
|
|
m4_joinall([], [one], [], [two])
|
|
|
|
m4_joinall
|
|
|
|
m4_joinall([-])
|
|
|
|
m4_joinall([-], [one])
|
2007-10-14 01:11:44 +08:00
|
|
|
]],
|
|
|
|
[[
|
|
|
|
|
|
|
|
|
|
|
|
one, two
|
|
|
|
[one, two]
|
|
|
|
active|active
|
|
|
|
one
|
|
|
|
one
|
|
|
|
two
|
|
|
|
two
|
|
|
|
one active two
|
|
|
|
onetwo
|
2008-07-18 22:30:07 +08:00
|
|
|
one--two
|
|
|
|
--three--
|
|
|
|
onetwo
|
|
|
|
|
|
|
|
|
|
|
|
one
|
2007-10-14 01:11:44 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-11-20 00:00:55 +08:00
|
|
|
## ----------- ##
|
|
|
|
## m4_expand. ##
|
|
|
|
## ----------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_expand])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_define([active], [ACTIVE])dnl
|
|
|
|
m4_expand([#active
|
|
|
|
active])
|
|
|
|
m4_expand([[active]])
|
|
|
|
dnl properly quoted case statements
|
|
|
|
m4_expand([case a in @%:@(
|
|
|
|
*) echo active, ;;
|
|
|
|
esac
|
|
|
|
case b in
|
|
|
|
*[)] echo active, ;;
|
|
|
|
esac])
|
|
|
|
dnl unbalanced underquoted `)', but we manage anyway (gasp!)
|
|
|
|
m4_expand([case c in #(
|
|
|
|
*) echo active, ;;
|
|
|
|
esac
|
|
|
|
case d in
|
|
|
|
*) echo active, ;;
|
|
|
|
esac])
|
|
|
|
]],
|
|
|
|
[[#active
|
|
|
|
ACTIVE
|
|
|
|
active
|
|
|
|
case a in #(
|
|
|
|
*) echo ACTIVE, ;;
|
|
|
|
esac
|
|
|
|
case b in
|
|
|
|
*) echo ACTIVE, ;;
|
|
|
|
esac
|
|
|
|
case c in #(
|
|
|
|
*) echo ACTIVE, ;;
|
|
|
|
esac
|
|
|
|
case d in
|
|
|
|
*) echo ACTIVE, ;;
|
|
|
|
esac
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
## -------------- ##
|
|
|
|
## m4_text_wrap. ##
|
|
|
|
## -------------- ##
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
2005-02-05 12:55:08 +08:00
|
|
|
AT_SETUP([m4@&t@_text_wrap])
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
# m4_text_wrap is used to display the help strings. Also, check that
|
2008-03-22 01:07:08 +08:00
|
|
|
# commas and $ are not swallowed. This can easily happen because of
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
# m4-listification.
|
|
|
|
|
2001-10-08 16:21:54 +08:00
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
2008-10-28 19:18:55 +08:00
|
|
|
[[m4_init[]m4_divert([0])dnl
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
m4_text_wrap([Short string */], [ ], [/* ], 20)
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
m4_text_wrap([Much longer string */], [ ], [/* ], 20)
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
m4_text_wrap([Short doc.], [ ], [ --short ], 30)
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
m4_text_wrap([Short doc.], [ ], [ --too-wide], 30)
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
m4_text_wrap([Super long documentation.], [ ], [ --too-wide], 30)
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
* m4sugar.m4 (m4_rename_m4, m4_copy_unm4): New macros.
Use them.
(debugfile, debugmode, m4exit, m4wrap, maketemp, patsubst, regexp)
(substr, translit, m4_wrap): Rename as...
(m4_debugfile, m4_debugmode, m4_exit, m4_wrap, m4_maketemp)
(m4_patsubst, m4_regexp, m4_substr, m4_translit, m4_text_wrap): these.
Adjust all dependencies.
* acgeneral.m4: Adjust.
* tests/m4sugar.at: Adjust.
* autoconf.m4 (m4exit, patsubst, regexp, substr, translit):
Reestablish them.
2000-11-03 16:53:26 +08:00
|
|
|
m4_text_wrap([First, second , third, [,quoted]])
|
2008-03-22 01:07:08 +08:00
|
|
|
m4_define([xfff], [oops])
|
|
|
|
m4_text_wrap([Some $1 $2 $3 $4 embedded dollars.], [ $* ], [ $@ ], [0xfff & 20])
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
]])
|
|
|
|
|
2001-08-20 22:45:09 +08:00
|
|
|
AT_DATA([expout],
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
[[/* Short string */
|
|
|
|
|
|
|
|
/* Much longer
|
|
|
|
string */
|
|
|
|
|
|
|
|
--short Short doc.
|
|
|
|
|
|
|
|
--too-wide
|
|
|
|
Short doc.
|
|
|
|
|
|
|
|
--too-wide
|
|
|
|
Super long
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
First, second , third, [,quoted]
|
2008-03-22 01:07:08 +08:00
|
|
|
|
|
|
|
$@ Some $1 $2 $3
|
|
|
|
$* $4 embedded
|
|
|
|
$* dollars.
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
]])
|
|
|
|
|
The use of `dumpstat' revealed that `len' was used although it
should not. m4_text_wrap was using it, but in the Autoconf world
where it is legal. Hence (i) test M4sh in its own world, not
Autoconf's, and (ii), ahem, fix the bug :)
* lib/autotest/general.m4: Be sure the set good quotes, as tracing
does not like `' instead of [].
(AT_INIT): Forbid `^_?AT_'.
And don't output such tokens.
* tests/Makefile.am (CLEANFILES): Add `script', `script.s4g',
`script.as', and `autom4te.cache'.
Remove `empty' and `macro' which are no longer used.
* tests/atspecific.m4 (AT_CHECK_M4SUGAR, AT_CHECK_M4SH): New.
* tests/m4sugar.at: Use it.
* lib/m4sugar/m4sugar.m4: Use `m4_len' not `len'.
2001-08-07 15:56:40 +08:00
|
|
|
AT_CHECK_M4SUGAR([-o-], 0, [expout])
|
Move the Autoconf independent shell macros into the file
`shell.m4' and the name space `AS_*'.
* acgeneral.m4 (AC_SHELL_IFELSE, _AC_SHELL_TMPDIR, AC_SHELL_UNSET)
(AC_SHELL_MKDIR_P, AC_SHELL_DIRNAME): Rename and move to...
* shell.m4 (AS_IFELSE, AS_TMPDIR, AS_UNSET, AS_MKDIR_P)
(AS_DIRNAME): here, a new file.
Adjust all dependencies.
* tests/base.m4 (m4_wrap): Eve out into...
* tests/shell.m4: here, new file.
* tests/base.m4 (AC_SHELL_MKDIR_P)
(AC_SHELL_DIRNAME & AC_SHELL_DIRNAME_SED): Eve out into...
* tests/m4sugar.m4 (AS_MKDIR_P, AS_DIRNAME & AS_DIRNAME_SED):
here, new file.
Adjust the test suite.
2000-10-26 01:51:10 +08:00
|
|
|
|
2000-12-19 16:15:48 +08:00
|
|
|
AT_CLEANUP
|
2005-02-05 12:55:08 +08:00
|
|
|
|
2007-09-13 11:21:18 +08:00
|
|
|
## -------------------- ##
|
|
|
|
## m4_version_compare. ##
|
|
|
|
## -------------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_version_compare])
|
|
|
|
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_list_cmp])
|
|
|
|
|
2007-09-13 11:21:18 +08:00
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_version_compare([1.1], [2.0])
|
|
|
|
m4_version_compare([2.0b], [2.0a])
|
|
|
|
m4_version_compare([2.0z], [2.0y])
|
|
|
|
m4_version_compare([1.1.1], [1.1.1a])
|
|
|
|
m4_version_compare([1.2], [1.1.1a])
|
|
|
|
m4_version_compare([1.0], [1])
|
|
|
|
m4_version_compare([1.0a], [1.0a])
|
|
|
|
m4_version_compare([1.1a], [1.1a.1])
|
Make AC_PREREQ faster and more robust.
* lib/m4sugar/m4sugar.m4 (m4_ignore, m4_unquote): New macros.
(m4_version_prereq): Inline constant expansions.
(m4_list_cmp): Reduce number of expansions, by avoiding m4_case.
Rewrite in terms of [] list, not () list.
(_m4_list_cmp, _m4_version_unletter): New helper macros.
(m4_version_unletter): Write wrapper around new implementation to
preserve old semantics.
(m4_version_compare): Pass correct type of list, and avoid
overhead of flattening expressions too early.
(m4_do): Move to be near other quoting macros.
(m4_max, m4_min): Always result in decimal output.
* doc/autoconf.texi (Looping constructs): Add m4_car, m4_cdr.
Move m4_do...
(Evaluation Macros): ...here. Add m4_ignore, m4_unquote.
(Text processing Macros): Move m4_version_compare...
(Number processing Macros): ...to this new node; document m4_cmp,
m4_list_cmp, m4_sign, m4_max, m4_min.
* tests/m4sugar.at (m4@&t@_version_compare): Enhance test, to pick
up on bugs fixed by this patch.
* NEWS: Document new macros.
Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-13 21:47:46 +08:00
|
|
|
m4_version_compare([1.10], [1.1a])
|
2007-11-03 21:20:47 +08:00
|
|
|
m4_version_compare([1-1a], [1,1A])
|
Make AC_PREREQ faster and more robust.
* lib/m4sugar/m4sugar.m4 (m4_ignore, m4_unquote): New macros.
(m4_version_prereq): Inline constant expansions.
(m4_list_cmp): Reduce number of expansions, by avoiding m4_case.
Rewrite in terms of [] list, not () list.
(_m4_list_cmp, _m4_version_unletter): New helper macros.
(m4_version_unletter): Write wrapper around new implementation to
preserve old semantics.
(m4_version_compare): Pass correct type of list, and avoid
overhead of flattening expressions too early.
(m4_do): Move to be near other quoting macros.
(m4_max, m4_min): Always result in decimal output.
* doc/autoconf.texi (Looping constructs): Add m4_car, m4_cdr.
Move m4_do...
(Evaluation Macros): ...here. Add m4_ignore, m4_unquote.
(Text processing Macros): Move m4_version_compare...
(Number processing Macros): ...to this new node; document m4_cmp,
m4_list_cmp, m4_sign, m4_max, m4_min.
* tests/m4sugar.at (m4@&t@_version_compare): Enhance test, to pick
up on bugs fixed by this patch.
* NEWS: Document new macros.
Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-13 21:47:46 +08:00
|
|
|
m4_define([a], [oops])dnl
|
|
|
|
m4_version_compare([1.1a], [1.1A])
|
|
|
|
m4_version_compare([1z], [1aa])
|
2007-11-03 21:20:47 +08:00
|
|
|
m4_version_compare([2.61a], [2.61a-248-dc51])
|
|
|
|
m4_version_compare([2.61b], [2.61a-248-dc51])
|
2008-08-22 12:17:33 +08:00
|
|
|
dnl Test that side effects to m4_list_cmp occur exactly once
|
|
|
|
m4_list_cmp([[0], [0], [0]m4_errprintn([hi])],
|
|
|
|
[[0], [0], [0]m4_errprintn([hi])])
|
|
|
|
m4_list_cmp([[0], [0], [0]m4_errprintn([hi])],
|
|
|
|
[[0], [0], [0]m4_errprintn([bye])])
|
2007-09-13 11:21:18 +08:00
|
|
|
]],
|
|
|
|
[[-1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
-1
|
|
|
|
1
|
|
|
|
0
|
|
|
|
0
|
|
|
|
-1
|
Make AC_PREREQ faster and more robust.
* lib/m4sugar/m4sugar.m4 (m4_ignore, m4_unquote): New macros.
(m4_version_prereq): Inline constant expansions.
(m4_list_cmp): Reduce number of expansions, by avoiding m4_case.
Rewrite in terms of [] list, not () list.
(_m4_list_cmp, _m4_version_unletter): New helper macros.
(m4_version_unletter): Write wrapper around new implementation to
preserve old semantics.
(m4_version_compare): Pass correct type of list, and avoid
overhead of flattening expressions too early.
(m4_do): Move to be near other quoting macros.
(m4_max, m4_min): Always result in decimal output.
* doc/autoconf.texi (Looping constructs): Add m4_car, m4_cdr.
Move m4_do...
(Evaluation Macros): ...here. Add m4_ignore, m4_unquote.
(Text processing Macros): Move m4_version_compare...
(Number processing Macros): ...to this new node; document m4_cmp,
m4_list_cmp, m4_sign, m4_max, m4_min.
* tests/m4sugar.at (m4@&t@_version_compare): Enhance test, to pick
up on bugs fixed by this patch.
* NEWS: Document new macros.
Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-13 21:47:46 +08:00
|
|
|
1
|
|
|
|
0
|
|
|
|
0
|
|
|
|
-1
|
2007-11-03 21:20:47 +08:00
|
|
|
-1
|
|
|
|
1
|
2008-08-22 12:17:33 +08:00
|
|
|
0
|
|
|
|
0
|
|
|
|
]], [[hi
|
|
|
|
hi
|
|
|
|
hi
|
|
|
|
bye
|
2007-09-13 11:21:18 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
2005-02-05 12:55:08 +08:00
|
|
|
## ------------------------------ ##
|
|
|
|
## Standard regular expressions. ##
|
|
|
|
## ------------------------------ ##
|
|
|
|
|
|
|
|
AT_SETUP([Standard regular expressions])
|
|
|
|
|
|
|
|
# AT_CHECK_M4RE(RE-NAME, TEXT, INTENT = `ok' | `')
|
|
|
|
# ------------------------------------------------
|
|
|
|
# Check whether RE-NAME (a macro whose definition is a regular expression)
|
|
|
|
# matches TEXT. INTENT = `ok' if the match should succeed or else empty.
|
|
|
|
m4_define([AT_CHECK_M4RE],
|
|
|
|
[AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_bregexp([$2], ^m4_defn([$1])$, [ok])
|
|
|
|
]], [$3
|
|
|
|
])])
|
|
|
|
|
|
|
|
AT_CHECK_M4RE([m4_re_word], [ab9_c], [ok])
|
|
|
|
AT_CHECK_M4RE([m4_re_word], [_9abc], [ok])
|
|
|
|
AT_CHECK_M4RE([m4_re_word], [9ab_c])
|
|
|
|
|
|
|
|
AT_CHECK_M4RE([m4_re_string], [ab9_c], [ok])
|
|
|
|
AT_CHECK_M4RE([m4_re_string], [_9abc], [ok])
|
|
|
|
AT_CHECK_M4RE([m4_re_string], [9ab_c], [ok])
|
|
|
|
AT_CHECK_M4RE([m4_re_string], [9a@_c])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
2006-02-21 05:43:05 +08:00
|
|
|
|
2008-08-13 05:23:56 +08:00
|
|
|
## ----------- ##
|
|
|
|
## m4_bmatch. ##
|
|
|
|
## ----------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_bmatch])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_bmatch([abc], [default\])
|
|
|
|
m4_bmatch([abc], [^a], [yes])
|
|
|
|
m4_bmatch([abc], [^a], [yes], [no])
|
|
|
|
m4_bmatch([abc], [^.a], [yes])
|
|
|
|
m4_bmatch([abc], [^.a], [yes], [no\])
|
|
|
|
m4_bmatch([abc], [a], [1], [b], [2])
|
|
|
|
m4_bmatch([abc], [A], [1], [b], [2])
|
|
|
|
m4_define([ab], [AB])dnl
|
|
|
|
m4_bmatch([$*], [a])b
|
|
|
|
m4_bmatch([$*], [\*], [a])b
|
|
|
|
m4_bmatch([$*], [1], [2], [a])b
|
|
|
|
]], [[default\
|
|
|
|
yes
|
|
|
|
yes
|
|
|
|
|
|
|
|
no\
|
|
|
|
1
|
|
|
|
2
|
|
|
|
AB
|
|
|
|
AB
|
|
|
|
AB
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
2008-07-30 10:34:06 +08:00
|
|
|
## --------------- ##
|
|
|
|
## m4_bpatsubsts. ##
|
|
|
|
## --------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_bpatsubsts])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_bpatsubsts([11], [^..$])
|
|
|
|
m4_bpatsubsts([11], [\(.\)1], [\12])
|
|
|
|
m4_bpatsubsts([11], [^..$], [], [1], [2])
|
|
|
|
m4_bpatsubsts([11], [\(.\)1], [\12], [1], [3])
|
2008-07-30 23:45:21 +08:00
|
|
|
m4_define([a], [oops])m4_define([c], [oops])dnl
|
|
|
|
m4_define([AB], [good])m4_define([bc], [good])dnl
|
2008-07-30 10:34:06 +08:00
|
|
|
m4_bpatsubsts([abc], [a], [A], [b], [B], [c])
|
2008-07-30 23:45:21 +08:00
|
|
|
m4_bpatsubsts([ab], [a])c
|
|
|
|
m4_bpatsubsts([ab], [c], [C], [a])c
|
2008-07-30 10:34:06 +08:00
|
|
|
m4_bpatsubsts([$1$*$@], [\$\*], [$#])
|
|
|
|
]], [[11
|
|
|
|
21
|
|
|
|
22
|
|
|
|
23
|
|
|
|
good
|
2008-07-30 23:45:21 +08:00
|
|
|
good
|
|
|
|
good
|
2008-07-30 10:34:06 +08:00
|
|
|
$1$#$@
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
2008-11-13 12:45:42 +08:00
|
|
|
## -------------- ##
|
|
|
|
## m4_esyscmd_s. ##
|
|
|
|
## -------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_esyscmd_s])
|
|
|
|
AT_KEYWORDS([m4@&t@_chomp m4@&t@_chomp_all])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_define([world], [WORLD])dnl
|
|
|
|
m4_chomp([abc])
|
|
|
|
m4_chomp([world
|
|
|
|
|
|
|
|
])
|
|
|
|
m4_esyscmd_s([echo hello world])
|
|
|
|
m4_esyscmd_s([echo '[goodbye,
|
|
|
|
cruel world
|
|
|
|
|
|
|
|
]'])
|
|
|
|
]], [[abc
|
|
|
|
world
|
|
|
|
|
|
|
|
hello WORLD
|
|
|
|
goodbye,
|
|
|
|
cruel world
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
2006-02-21 05:43:05 +08:00
|
|
|
## ---------- ##
|
|
|
|
## M4 Loops. ##
|
|
|
|
## ---------- ##
|
|
|
|
|
|
|
|
AT_SETUP([M4 loops])
|
|
|
|
|
2008-11-06 08:11:15 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_for m4@&t@_foreach m4@&t@_foreach_w m4@&t@_map_args_w])
|
2008-08-22 12:17:33 +08:00
|
|
|
|
2006-02-21 05:43:05 +08:00
|
|
|
AT_CHECK_M4SUGAR_TEXT([[dnl
|
|
|
|
m4_define([myvar], [outer value])dnl
|
|
|
|
m4_for([myvar], 1, 3, 1, [ myvar])
|
|
|
|
m4_for([myvar], 1, 3, , [ myvar])
|
|
|
|
m4_for([myvar], 3, 1,-1, [ myvar])
|
|
|
|
m4_for([myvar], 3, 1, , [ myvar])
|
|
|
|
m4_for([myvar], 1, 3, 2, [ myvar])
|
|
|
|
m4_for([myvar], 3, 1,-2, [ myvar])
|
|
|
|
m4_for([myvar],-1,-3,-2, [ myvar])
|
|
|
|
m4_for([myvar],-3,-1, 2, [ myvar])
|
|
|
|
dnl Make sure we recalculate the bounds correctly:
|
|
|
|
m4_for([myvar], 1, 3, 3, [ myvar])
|
|
|
|
m4_for([myvar], 1, 6, 3, [ myvar])
|
|
|
|
m4_for([myvar],22,-7,-5, [ myvar])
|
|
|
|
m4_for([myvar],-2,-7,-4, [ myvar])
|
|
|
|
m4_for([myvar],-7,-2, 4, [ myvar])
|
|
|
|
dnl Make sure we are not exposed to division truncation:
|
|
|
|
m4_for([myvar], 2, 5, 2, [ myvar])
|
|
|
|
m4_for([myvar],-5,-2, 2, [ myvar])
|
|
|
|
m4_for([myvar], 5, 2,-2, [ myvar])
|
|
|
|
m4_for([myvar],-2,-5,-2, [ myvar])
|
|
|
|
dnl Make sure we do not divide by zero:
|
|
|
|
m4_for([myvar], 1, 1, , [ myvar])
|
|
|
|
m4_for([myvar], 1, 1,+2, [ myvar])
|
|
|
|
m4_for([myvar], 1, 1,-2, [ myvar])
|
|
|
|
dnl Make sure we do not loop endlessly
|
|
|
|
m4_for([myval], 1, 1, 0, [ myval])
|
|
|
|
dnl Make sure to properly parenthesize
|
|
|
|
m4_for([myvar], 3-5, -2+8, , [ myvar])
|
|
|
|
m4_for([myvar], -2+8, 3-5, , [ myvar])
|
|
|
|
m4_for([myvar], 8, 16, 3 * 2, [ myvar])
|
|
|
|
m4_for([myvar], 8, 16, -3 * -2, [ myvar])
|
|
|
|
m4_for([myvar], [2<<2], [2<<3], [-3 * (-2)], [ myvar])
|
2008-07-30 02:21:25 +08:00
|
|
|
dnl Modifying var does not affect the number of iterations
|
|
|
|
m4_for([myvar], 1, 5, , [ myvar[]m4_define([myvar], 5)])
|
2007-09-30 20:27:46 +08:00
|
|
|
dnl Make sure we can do nameless iteration
|
|
|
|
m4_for(, 1, 10, , -)
|
|
|
|
dnl foreach tests
|
2006-02-21 05:43:05 +08:00
|
|
|
m4_foreach([myvar], [[a], [b, c], [d], [e
|
|
|
|
],[f]], [ myvar|])
|
|
|
|
m4_foreach_w([myvar], [a b c, d,e f
|
|
|
|
g], [ myvar|])
|
|
|
|
myvar
|
2008-11-06 08:11:15 +08:00
|
|
|
m4_map_args_w([a b c, d,e f
|
|
|
|
g], [ ], [|])
|
|
|
|
m4_map_args_w([a b], [\1], [/])
|
|
|
|
m4_map_args_w([a b], [/], [\1])
|
2008-08-22 12:17:33 +08:00
|
|
|
dnl only one side effect expansion, prior to visiting list elements
|
|
|
|
m4_foreach([i], [[1], [2], [3]m4_errprintn([hi])], [m4_errprintn(i)])dnl
|
2008-08-28 10:30:25 +08:00
|
|
|
dnl shifting forms an important part of loops
|
|
|
|
m4_shift3:m4_shift3(1,2,3):m4_shift3(1,2,3,4)
|
|
|
|
m4_shiftn(3,1,2,3):m4_shiftn(3,1,2,3,4)
|
2006-02-21 05:43:05 +08:00
|
|
|
]],
|
|
|
|
[[ 1 2 3
|
|
|
|
1 2 3
|
|
|
|
3 2 1
|
|
|
|
3 2 1
|
|
|
|
1 3
|
|
|
|
3 1
|
|
|
|
-1 -3
|
|
|
|
-3 -1
|
|
|
|
1
|
|
|
|
1 4
|
|
|
|
22 17 12 7 2 -3
|
|
|
|
-2 -6
|
|
|
|
-7 -3
|
|
|
|
2 4
|
|
|
|
-5 -3
|
|
|
|
5 3
|
|
|
|
-2 -4
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
-2 -1 0 1 2 3 4 5 6
|
|
|
|
6 5 4 3 2 1 0 -1 -2
|
|
|
|
8 14
|
|
|
|
8 14
|
|
|
|
8 14
|
2008-07-30 02:21:25 +08:00
|
|
|
1 2 3 4 5
|
2007-09-30 20:27:46 +08:00
|
|
|
----------
|
2006-02-21 05:43:05 +08:00
|
|
|
a| b, c| d| e
|
|
|
|
| f|
|
|
|
|
a| b| c,| d,e| f| g|
|
|
|
|
outer value
|
2008-11-06 08:11:15 +08:00
|
|
|
a| b| c,| d,e| f| g|
|
|
|
|
\1a/\1b/
|
|
|
|
/a\1/b\1
|
2008-08-28 10:30:25 +08:00
|
|
|
::4
|
|
|
|
:4
|
2008-08-22 12:17:33 +08:00
|
|
|
]], [[hi
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
]])
|
2006-02-21 05:43:05 +08:00
|
|
|
|
2008-08-28 10:30:25 +08:00
|
|
|
dnl bounds checking in m4_for
|
2006-02-21 05:43:05 +08:00
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_init
|
2006-06-20 13:35:38 +08:00
|
|
|
m4_divert([0])dnl
|
2006-02-21 05:43:05 +08:00
|
|
|
m4_for([myvar], 1, 3,-1, [ myvar])
|
|
|
|
]])
|
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
|
|
|
[[script.4s:3: error: assert failed: -1 > 0
|
|
|
|
script.4s:3: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_init
|
2006-06-20 13:35:38 +08:00
|
|
|
m4_divert([0])dnl
|
2006-02-21 05:43:05 +08:00
|
|
|
m4_for([myvar], 1, 2, 0, [ myvar])
|
|
|
|
]])
|
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
|
|
|
[[script.4s:3: error: assert failed: 0 > 0
|
|
|
|
script.4s:3: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_init
|
2006-06-20 13:35:38 +08:00
|
|
|
m4_divert([0])dnl
|
2006-02-21 05:43:05 +08:00
|
|
|
m4_for([myvar], 2, 1, 0, [ myvar])
|
|
|
|
]])
|
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
|
|
|
[[script.4s:3: error: assert failed: 0 < 0
|
|
|
|
script.4s:3: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
|
2008-08-28 10:30:25 +08:00
|
|
|
dnl m4_shiftn also does bounds checking
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_init
|
|
|
|
m4_divert([0])dnl
|
|
|
|
m4_shiftn(3,1,2)
|
|
|
|
]])
|
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
|
|
|
[[script.4s:3: error: assert failed: 0 < 3 && 3 < 3
|
|
|
|
script.4s:3: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
2006-02-21 05:43:05 +08:00
|
|
|
AT_CLEANUP
|
2007-10-18 03:51:26 +08:00
|
|
|
|
|
|
|
|
2008-08-15 21:06:39 +08:00
|
|
|
## --------------------- ##
|
|
|
|
## m4_map{,all}{,_sep}. ##
|
|
|
|
## --------------------- ##
|
2007-10-18 03:51:26 +08:00
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_map])
|
2008-08-15 21:06:39 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_apply m4@&t@_map_sep m4@&t@_mapall m4@&t@_mapall_sep])
|
2007-10-18 03:51:26 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_count])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[dnl
|
|
|
|
m4_map([m4_count], [])
|
|
|
|
m4_map([ m4_count], [[],
|
|
|
|
[[1]],
|
|
|
|
[[1], [2]]])
|
2008-08-15 21:06:39 +08:00
|
|
|
m4_mapall([ m4_count], [[],
|
|
|
|
[[1]],
|
|
|
|
[[1], [2]]])
|
2007-10-18 03:51:26 +08:00
|
|
|
m4_map_sep([m4_eval], [,], [[[1+2]],
|
|
|
|
[[10], [16]]])
|
2008-08-15 21:06:39 +08:00
|
|
|
m4_count(m4_map_sep([m4_echo], [,], [[], [[1]], [[2]]]))
|
|
|
|
m4_count(m4_mapall_sep([m4_echo], [,], [[], [[1]], [[2]]]))
|
|
|
|
m4_map_sep([m4_eval], [[,]], [[[1+2]],
|
|
|
|
[[10], [16]]])
|
|
|
|
m4_count(m4_map_sep([m4_echo], [[,]], [[], [[1]], [[2]]]))
|
|
|
|
m4_count(m4_mapall_sep([m4_echo], [[,]], [[], [[1]], [[2]]]))
|
|
|
|
m4_map([-], [[]])
|
|
|
|
m4_mapall([-], [[]])
|
|
|
|
m4_map_sep([-], [:], [[]])
|
|
|
|
m4_mapall_sep([-], [:], [[]])
|
2007-10-18 03:51:26 +08:00
|
|
|
m4_define([a], [m4_if([$#], [0], [oops], [$1], [a], [pass], [oops])])dnl
|
|
|
|
m4_define([a1], [oops])dnl
|
|
|
|
m4_define([pass1], [oops])dnl
|
|
|
|
m4_map([a], [[[a]]])1
|
|
|
|
m4_map([m4_unquote([a])], [m4_dquote([a])])
|
2008-08-22 12:17:33 +08:00
|
|
|
dnl only one side effect expansion, prior to visiting list elements
|
|
|
|
m4_map([m4_errprintn], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
|
|
|
|
m4_map_sep([m4_errprintn], [], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
|
|
|
|
m4_mapall([m4_errprintn], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
|
|
|
|
m4_mapall_sep([m4_errprintn], [], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
|
2007-10-18 03:51:26 +08:00
|
|
|
]],
|
|
|
|
[[
|
2008-08-15 21:06:39 +08:00
|
|
|
1 2
|
2007-10-18 03:51:26 +08:00
|
|
|
0 1 2
|
|
|
|
3,a
|
2008-08-15 21:06:39 +08:00
|
|
|
2
|
|
|
|
3
|
|
|
|
3,a
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-
|
2007-10-18 03:51:26 +08:00
|
|
|
pass1
|
|
|
|
pass
|
2008-08-22 12:17:33 +08:00
|
|
|
]], [[hi
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
hi
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
hi
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
hi
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
]])
|
2007-10-18 03:51:26 +08:00
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2008-11-04 08:17:38 +08:00
|
|
|
## --------------------------------------- ##
|
|
|
|
## m4_map_args{,_sep,_pair} and m4_curry. ##
|
|
|
|
## --------------------------------------- ##
|
2008-10-14 00:46:40 +08:00
|
|
|
|
2008-10-16 01:55:45 +08:00
|
|
|
AT_SETUP([m4@&t@_map_args and m4@&t@_curry])
|
2008-11-04 08:17:38 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_map_args_sep m4@&t@_map_args_pair m4@&t@_reverse
|
|
|
|
m4@&t@_map])
|
2008-10-14 00:46:40 +08:00
|
|
|
|
2008-10-16 01:55:45 +08:00
|
|
|
dnl First, make sure we can curry in isolation.
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_curry([m4_echo])([1])
|
|
|
|
m4_curry([m4_curry], [m4_reverse], [1])([2])([3])
|
|
|
|
m4_define([add], [m4_eval(([$1]) + ([$2]))])dnl
|
|
|
|
m4_define([add_one], [m4_curry([add], [1])])dnl
|
|
|
|
add_one()([4])
|
|
|
|
]],
|
|
|
|
[[1
|
|
|
|
3, 2, 1
|
|
|
|
5
|
|
|
|
]])
|
|
|
|
|
|
|
|
dnl Now, check that we can map a list of arguments.
|
2008-10-14 00:46:40 +08:00
|
|
|
AT_CHECK_M4SUGAR_TEXT([[m4_define([active], [ACTIVE])dnl
|
|
|
|
m4_map_args([ m4_echo])
|
|
|
|
m4_map_args([ m4_echo], [plain], [active])
|
|
|
|
m4_map_args([m4_unquote], [plain], [active])
|
|
|
|
m4_map_args_pair([, m4_reverse], [])
|
|
|
|
m4_map_args_pair([, m4_reverse], [], [1])
|
|
|
|
m4_map_args_pair([, m4_reverse], [], [1], [2])
|
|
|
|
m4_map_args_pair([, m4_reverse], [], [1], [2], [3])
|
|
|
|
m4_map_args_pair([, m4_reverse], [], [1], [2], [3], [4])
|
|
|
|
m4_map_args_pair([, m4_reverse], [, m4_dquote], [1])
|
|
|
|
m4_map_args_pair([, m4_reverse], [, m4_dquote], [1], [2])
|
|
|
|
m4_map_args_pair([, m4_reverse], [, m4_dquote], [1], [2], [3])
|
|
|
|
m4_map_args_pair([, m4_reverse], [, m4_dquote], [1], [2], [3], [4])
|
2008-11-04 08:17:38 +08:00
|
|
|
m4_map_args_sep([<], [>], [:], [1], [2], [3])
|
|
|
|
m4_map_args_sep([m4_echo(], [)], [ ], [plain], [active])
|
2008-10-14 00:46:40 +08:00
|
|
|
]],
|
|
|
|
[[
|
|
|
|
plain active
|
|
|
|
plainACTIVE
|
|
|
|
|
|
|
|
, 1
|
|
|
|
, 2, 1
|
|
|
|
, 2, 1, 3
|
|
|
|
, 2, 1, 4, 3
|
|
|
|
, [1]
|
|
|
|
, 2, 1
|
|
|
|
, 2, 1, [3]
|
|
|
|
, 2, 1, 4, 3
|
2008-11-04 08:17:38 +08:00
|
|
|
<1>:<2>:<3>
|
|
|
|
plain active
|
2008-10-14 00:46:40 +08:00
|
|
|
]])
|
|
|
|
|
2008-10-16 01:55:45 +08:00
|
|
|
dnl Finally, put the two concepts together, to show the real power of the API.
|
|
|
|
AT_CHECK_M4SUGAR_TEXT(
|
|
|
|
[[m4_define([add], [m4_eval(([$1]) + ([$2]))])dnl
|
|
|
|
m4_define([list], [[-1], [0], [1]])dnl
|
|
|
|
dnl list_add_n(value, arg...)
|
|
|
|
dnl add VALUE to each ARG and output the resulting list
|
|
|
|
m4_define([list_add_n],
|
|
|
|
[m4_shift(m4_map_args([,m4_curry([add], [$1])], m4_shift($@)))])
|
|
|
|
list_add_n([1], list)
|
|
|
|
list_add_n([2], list)
|
|
|
|
]], [[
|
|
|
|
0,1,2
|
|
|
|
1,2,3
|
|
|
|
]])
|
|
|
|
|
2008-10-14 00:46:40 +08:00
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
2007-10-18 03:51:26 +08:00
|
|
|
## ------------ ##
|
|
|
|
## m4_combine. ##
|
|
|
|
## ------------ ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_combine])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
|
|
|
|
m4_combine([, ], [[a], [b], [c]], [-], [1], [2], [3])
|
|
|
|
m4_combine([, ], [[a], [b]], [-])
|
|
|
|
m4_combine([, ], [[a], [b]], [-], [])
|
|
|
|
m4_combine([, ], [], [-], [a], [b])
|
|
|
|
m4_combine([, ], [[]], [-], [a], [b])
|
|
|
|
m4_combine([ a ], [[-], [+]], [a], [-], [+])
|
2008-03-22 01:07:08 +08:00
|
|
|
m4_combine([$* ], [[$1], [$2]], [$#], [$@])
|
2007-10-18 03:51:26 +08:00
|
|
|
]],
|
|
|
|
[[a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3
|
|
|
|
|
|
|
|
a-, b-
|
|
|
|
|
|
|
|
-a, -b
|
|
|
|
-a- a -a+ a +a- a +a+
|
2008-03-22 01:07:08 +08:00
|
|
|
$1$#$@$* $2$#$@
|
2007-10-18 03:51:26 +08:00
|
|
|
]], [])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
## -------------- ##
|
|
|
|
## m4_{max,min}. ##
|
|
|
|
## -------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_max and m4@&t@_min])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_max
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
|
|
|
[[script.4s:1: error: too few arguments to m4@&t@_max
|
|
|
|
script.4s:1: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_min
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([], 1, [],
|
|
|
|
[[script.4s:1: error: too few arguments to m4@&t@_min
|
|
|
|
script.4s:1: the top level
|
|
|
|
autom4te: m4 failed with exit status: 1
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[dnl
|
|
|
|
m4_min(0)
|
|
|
|
m4_min(0xa)
|
|
|
|
m4_min(0, 0)
|
|
|
|
m4_min(0, 1)
|
|
|
|
m4_min(1, 0)
|
|
|
|
m4_min(0+1, 1+1)
|
|
|
|
m4_min(0+1, 1+0)
|
|
|
|
m4_min(0, 1, 2)
|
|
|
|
m4_min(2, 1, 0)
|
|
|
|
m4_min(1m4_for([i], 2, 100, , [,i]))
|
|
|
|
m4_min(m4_for([i], 100, 2, , [i,])1)
|
|
|
|
----
|
|
|
|
m4_max(0)
|
|
|
|
m4_max(0xa)
|
|
|
|
m4_max(0, 0)
|
|
|
|
m4_max(0, 1)
|
|
|
|
m4_max(1, 0)
|
|
|
|
m4_max(1+0, 1+1)
|
|
|
|
m4_max(1+0, 1+0)
|
|
|
|
m4_max(0, 1, 2)
|
|
|
|
m4_max(2, 1, 0)
|
|
|
|
m4_max(1m4_for([i], 2, 100, , [,i]))
|
|
|
|
m4_max(m4_for([i], 100, 2, , [i,])1)
|
|
|
|
]],
|
|
|
|
[[0
|
|
|
|
10
|
|
|
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
1
|
|
|
|
1
|
|
|
|
0
|
|
|
|
0
|
|
|
|
1
|
|
|
|
1
|
|
|
|
----
|
|
|
|
0
|
|
|
|
10
|
|
|
|
0
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
100
|
|
|
|
100
|
|
|
|
]], [])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
## ----------- ##
|
|
|
|
## Recursion. ##
|
|
|
|
## ----------- ##
|
|
|
|
|
|
|
|
AT_SETUP([recursion])
|
|
|
|
|
2008-07-31 06:44:03 +08:00
|
|
|
AT_KEYWORDS([m4@&t@_foreach m4@&t@_foreach_w m4@&t@_case m4@&t@_cond
|
|
|
|
m4@&t@_bpatsubsts m4@&t@_shiftn m4@&t@_do m4@&t@_dquote_elt m4@&t@_reverse
|
2008-08-13 05:23:56 +08:00
|
|
|
m4@&t@_map m4@&t@_join m4@&t@_joinall m4@&t@_list_cmp m4@&t@_max m4@&t@_min
|
2008-10-14 00:46:40 +08:00
|
|
|
m4@&t@_bmatch m4@&t@_map_args m4@&t@_map_args_pair])
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
|
|
|
|
dnl This test completes in a reasonable time if m4_foreach is linear,
|
|
|
|
dnl but thrashes if it is quadratic. If we are testing with m4 1.4.x,
|
|
|
|
dnl only the slower foreach.m4 implementation will work. But if we
|
|
|
|
dnl are testing with m4 1.6, we can rerun the test with __m4_version__
|
|
|
|
dnl undefined to exercise the alternate code path.
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_init
|
|
|
|
m4_divert_push(0)[]dnl
|
|
|
|
m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
|
|
|
|
m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
|
|
|
|
m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
|
|
|
|
m4_len(m4_joinall([--], m4_map([, m4_echo],
|
|
|
|
m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
|
|
|
|
m4_max(m4_min([1]m4_for([i], [2], [10000], [],
|
|
|
|
[,i]))m4_for([i], [2], [10000], [], [,i]))
|
|
|
|
m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
|
|
|
|
m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
|
2008-07-29 21:12:26 +08:00
|
|
|
m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
|
2008-07-29 22:28:01 +08:00
|
|
|
m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
|
|
|
|
m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
m4_for([i], [1], [10000], [], [m4_define(i)])dnl
|
|
|
|
m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
|
2008-07-30 10:34:06 +08:00
|
|
|
m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
|
2008-08-13 05:23:56 +08:00
|
|
|
m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
|
2008-07-31 06:44:03 +08:00
|
|
|
m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
|
|
|
|
m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops]) j
|
2008-10-14 00:46:40 +08:00
|
|
|
m4_count(m4_map_args_pair([,m4_quote], []m4_map_args([,m4_echo]m4_for([i],
|
2008-08-19 12:20:37 +08:00
|
|
|
[1], [10000], [], [,i]))))
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
m4_divert_pop(0)
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], [0], [[48894
|
|
|
|
9999,10000
|
|
|
|
78896
|
|
|
|
58894
|
|
|
|
10000
|
|
|
|
end
|
|
|
|
0
|
2008-07-29 22:28:01 +08:00
|
|
|
0
|
|
|
|
0
|
2008-07-30 10:34:06 +08:00
|
|
|
A
|
2008-08-13 05:23:56 +08:00
|
|
|
^9998$
|
2008-07-31 06:44:03 +08:00
|
|
|
9990 9990
|
2008-08-19 12:20:37 +08:00
|
|
|
5001
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA_M4SUGAR([script.4s],
|
|
|
|
[[m4_ifdef([__m4_version__],
|
|
|
|
[m4_undefine([__m4_version__])],
|
|
|
|
[m4_divert_push(0)48894
|
|
|
|
9999,10000
|
|
|
|
78896
|
|
|
|
58894
|
|
|
|
10000
|
|
|
|
end
|
|
|
|
0
|
2008-07-29 22:28:01 +08:00
|
|
|
0
|
|
|
|
0
|
2008-07-30 10:34:06 +08:00
|
|
|
A
|
2008-08-13 05:23:56 +08:00
|
|
|
^9998$
|
2008-07-31 06:44:03 +08:00
|
|
|
9990 9990
|
2008-08-19 12:20:37 +08:00
|
|
|
5001
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
m4_exit([0])])
|
|
|
|
m4_init
|
|
|
|
m4_divert_push(0)[]dnl
|
|
|
|
m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
|
|
|
|
m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
|
|
|
|
m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
|
|
|
|
m4_len(m4_joinall([--], m4_map([, m4_echo],
|
|
|
|
m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
|
|
|
|
m4_max(m4_min([1]m4_for([i], [2], [10000], [],
|
|
|
|
[,i]))m4_for([i], [2], [10000], [], [,i]))
|
|
|
|
m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
|
|
|
|
m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
|
2008-07-29 21:12:26 +08:00
|
|
|
m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
|
2008-07-29 22:28:01 +08:00
|
|
|
m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
|
|
|
|
m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
m4_for([i], [1], [10000], [], [m4_define(i)])dnl
|
|
|
|
m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
|
2008-07-30 10:34:06 +08:00
|
|
|
m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
|
2008-08-13 05:23:56 +08:00
|
|
|
m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
|
2008-07-31 06:44:03 +08:00
|
|
|
m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
|
2008-08-22 12:17:33 +08:00
|
|
|
m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops]) j
|
2008-10-14 00:46:40 +08:00
|
|
|
m4_count(m4_map_args_pair([,m4_quote], []m4_map_args([,m4_echo]m4_for([i],
|
2008-08-19 12:20:37 +08:00
|
|
|
[1], [10000], [], [,i]))))
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
m4_divert_pop(0)
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], [0], [[48894
|
|
|
|
9999,10000
|
|
|
|
78896
|
|
|
|
58894
|
|
|
|
10000
|
|
|
|
end
|
|
|
|
0
|
2008-07-29 22:28:01 +08:00
|
|
|
0
|
|
|
|
0
|
2008-07-30 10:34:06 +08:00
|
|
|
A
|
2008-08-13 05:23:56 +08:00
|
|
|
^9998$
|
2008-07-31 06:44:03 +08:00
|
|
|
9990 9990
|
2008-08-19 12:20:37 +08:00
|
|
|
5001
|
Provide O(n) replacement macros for M4 1.4.x.
* lib/m4sugar/foreach.m4: New file.
(m4_foreach, m4_case, _m4_shiftn, m4_do, m4_dquote_elt, _m4_map)
(m4_join, m4_joinall, m4_list_cmp, _m4_minmax): Replace m4sugar
macros based on $@ recursion [fast on M4 1.6, but quadratic on M4
1.4.x] with versions based on m4_for/m4_foreach [slow on 1.6, but
linear on 1.4.x].
* lib/m4sugar/m4sugar.m4 (m4_init): Dynamically load new file if
older M4 is assumed.
(m4_map_sep): Optimize.
(m4_max, m4_min): Refactor, by adding...
(_m4_max, _m4_min, _m4_minmax): ...more efficient helpers.
(m4_defn, m4_popdef, m4_undefine): Use foreach recursion.
* lib/m4sugar/Makefile.am (dist_m4sugarlib_DATA): Distribute new
file.
* tests/m4sugar.at (M4 loops): Add a stress test that takes
forever if m4_foreach and friends are quadratic.
* NEWS: Mention this.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-26 05:17:38 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
Implement O(n) unique element set creation.
* lib/m4sugar/m4sugar.m4 (m4_set_add, m4_set_add_all)
(m4_set_contains, m4_set_contents, m4_set_delete)
(m4_set_difference, m4_set_dump, m4_set_empty, m4_set_foreach)
(m4_set_intersection, m4_set_list, m4_set_listc, m4_set_remove)
(m4_set_size, m4_set_union): New macros.
* lib/m4sugar/foreach.m4 (m4_set_add_all): Add O(n) fallback for
m4 1.4.x.
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS, AC_SUBST): Use
new m4_set API for the set most likely to be large.
* doc/autoconf.texi (Set manipulation Macros): New node.
* NEWS: Mention new macros.
* tests/m4sugar.at (m4@&t@_set): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-28 20:35:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
## ---------- ##
|
|
|
|
## m4_set_*. ##
|
|
|
|
## ---------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_set])
|
|
|
|
|
|
|
|
AT_KEYWORDS([m4@&t@_set_add m4@&t@_set_add_all m4@&t@_set_contains
|
|
|
|
m4@&t@_set_contents m4@&t@_set_delete m4@&t@_set_difference m4@&t@_set_dump
|
|
|
|
m4@&t@_set_empty m4@&t@_set_foreach m4@&t@_set_intersection m4@&t@_set_list
|
2008-10-14 05:37:31 +08:00
|
|
|
m4@&t@_set_listc m4@&t@_set_map m4@&t@_set_remove m4@&t@_set_size
|
|
|
|
m4@&t@_set_union])
|
Implement O(n) unique element set creation.
* lib/m4sugar/m4sugar.m4 (m4_set_add, m4_set_add_all)
(m4_set_contains, m4_set_contents, m4_set_delete)
(m4_set_difference, m4_set_dump, m4_set_empty, m4_set_foreach)
(m4_set_intersection, m4_set_list, m4_set_listc, m4_set_remove)
(m4_set_size, m4_set_union): New macros.
* lib/m4sugar/foreach.m4 (m4_set_add_all): Add O(n) fallback for
m4 1.4.x.
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS, AC_SUBST): Use
new m4_set API for the set most likely to be large.
* doc/autoconf.texi (Set manipulation Macros): New node.
* NEWS: Mention new macros.
* tests/m4sugar.at (m4@&t@_set): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-28 20:35:34 +08:00
|
|
|
|
|
|
|
# Simple tests
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[m4_set_contains([a], [1], [yes], [no])
|
|
|
|
m4_set_add([a], [1], [added], [dup])
|
|
|
|
m4_set_contains([a], [1], [yes], [no])
|
|
|
|
m4_set_add([a], [1], [added], [dup])
|
|
|
|
m4_set_contents([a])
|
|
|
|
m4_set_remove([a], [1], [removed], [missing])
|
|
|
|
m4_set_contains([a], [1], [yes], [no])
|
|
|
|
m4_set_remove([a], [1], [removed], [missing])
|
|
|
|
m4_set_add([a], [2], [added], [dup])
|
|
|
|
m4_set_empty([a], [yes], [no])
|
|
|
|
m4_set_delete([a])
|
|
|
|
m4_set_empty([a], [yes], [no])
|
|
|
|
m4_set_add_all([c], [1], [2], [3])
|
|
|
|
m4_set_add_all([a]m4_set_listc([c]))
|
|
|
|
m4_set_contents([c], [-])
|
|
|
|
m4_set_dump([a], [-])
|
|
|
|
m4_set_contents([a])
|
|
|
|
m4_set_add_all([a], [1], [2], [3])m4_set_add_all([b], [3], [], [4])
|
|
|
|
m4_set_difference([a], [b])
|
|
|
|
m4_set_difference([b], [a])
|
|
|
|
m4_set_intersection([a], [b])
|
|
|
|
m4_set_union([a], [b])
|
2008-10-14 05:37:31 +08:00
|
|
|
m4_define([printodd], [m4_if(m4_eval([$1 & 1]), [1], [:$1])])dnl
|
|
|
|
m4_set_map([a], [printodd])
|
Implement O(n) unique element set creation.
* lib/m4sugar/m4sugar.m4 (m4_set_add, m4_set_add_all)
(m4_set_contains, m4_set_contents, m4_set_delete)
(m4_set_difference, m4_set_dump, m4_set_empty, m4_set_foreach)
(m4_set_intersection, m4_set_list, m4_set_listc, m4_set_remove)
(m4_set_size, m4_set_union): New macros.
* lib/m4sugar/foreach.m4 (m4_set_add_all): Add O(n) fallback for
m4 1.4.x.
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS, AC_SUBST): Use
new m4_set API for the set most likely to be large.
* doc/autoconf.texi (Set manipulation Macros): New node.
* NEWS: Mention new macros.
* tests/m4sugar.at (m4@&t@_set): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-28 20:35:34 +08:00
|
|
|
m4_set_foreach([a], [i], [m4_if(m4_eval(i & 1), [1], [m4_set_remove([a], i)])])
|
|
|
|
m4_set_list([a])
|
|
|
|
m4_set_add([a], [])
|
|
|
|
m4_set_list([a])
|
|
|
|
m4_set_remove([a], [2])
|
|
|
|
m4_dquote(m4_set_list([a]))
|
|
|
|
m4_set_listc([a])
|
|
|
|
m4_set_size([a])
|
|
|
|
m4_set_delete([a])
|
|
|
|
m4_dquote(m4_set_list([a]))
|
|
|
|
m4_indir([m4_dquote]m4_set_listc([a]))
|
|
|
|
m4_set_listc([a])
|
|
|
|
m4_set_size([a])
|
|
|
|
]], [[no
|
|
|
|
added
|
|
|
|
yes
|
|
|
|
dup
|
|
|
|
1
|
|
|
|
removed
|
|
|
|
no
|
|
|
|
missing
|
|
|
|
added
|
|
|
|
no
|
|
|
|
|
|
|
|
yes
|
|
|
|
|
|
|
|
|
|
|
|
1-2-3
|
|
|
|
3-2-1
|
|
|
|
|
|
|
|
|
|
|
|
,1,2
|
|
|
|
,,4
|
|
|
|
,3
|
|
|
|
,1,2,3,,4
|
2008-10-14 05:37:31 +08:00
|
|
|
:1:3
|
Implement O(n) unique element set creation.
* lib/m4sugar/m4sugar.m4 (m4_set_add, m4_set_add_all)
(m4_set_contains, m4_set_contents, m4_set_delete)
(m4_set_difference, m4_set_dump, m4_set_empty, m4_set_foreach)
(m4_set_intersection, m4_set_list, m4_set_listc, m4_set_remove)
(m4_set_size, m4_set_union): New macros.
* lib/m4sugar/foreach.m4 (m4_set_add_all): Add O(n) fallback for
m4 1.4.x.
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS, AC_SUBST): Use
new m4_set API for the set most likely to be large.
* doc/autoconf.texi (Set manipulation Macros): New node.
* NEWS: Mention new macros.
* tests/m4sugar.at (m4@&t@_set): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-28 20:35:34 +08:00
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
2,
|
|
|
|
|
|
|
|
[]
|
|
|
|
,
|
|
|
|
1
|
|
|
|
|
|
|
|
[]
|
|
|
|
|
|
|
|
|
|
|
|
0
|
|
|
|
]])
|
|
|
|
|
|
|
|
# Stress tests - check for unusual names/values
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
|
|
|
|
m4_set_add([a], [a])dnl
|
|
|
|
m4_set_remove([a], [oops], [yes], [no])
|
|
|
|
m4_set_add([a,b], [c])dnl
|
|
|
|
m4_set_add([a,b], [$*[]])dnl
|
|
|
|
m4_set_add_all([a], [b,c])dnl
|
|
|
|
m4_set_size([a])
|
|
|
|
m4_count(m4_set_contents([a], [,]))
|
|
|
|
m4_count(m4_set_list([a], [,]))
|
|
|
|
m4_set_dump([a], [,])
|
|
|
|
m4_set_contents([a,b], [,])
|
|
|
|
m4_set_list([a,b])
|
|
|
|
m4_set_foreach([$*[]], [$*[]], [oops])
|
|
|
|
m4_set_add([$*[]], [])dnl
|
|
|
|
m4_set_remove([$*[]], [a], [yes], [no])
|
|
|
|
m4_set_add([$*[]], [a])dnl
|
|
|
|
m4_set_foreach([$*[]], [$*[]], [-m4_defn([$*[]])m4_indir([$*[]])-])
|
|
|
|
m4_set_remove([$*[]], [], [yes], [no])
|
|
|
|
m4_set_add([c], [,])dnl
|
|
|
|
m4_set_foreach([a,b], [set], [:m4_set_listc(_m4_defn([set])):])
|
|
|
|
]],[[no
|
|
|
|
2
|
|
|
|
1
|
|
|
|
2
|
|
|
|
b,c,a
|
|
|
|
c,$*[]
|
|
|
|
c,$*[]
|
|
|
|
|
|
|
|
no
|
|
|
|
---aoops-
|
|
|
|
yes
|
|
|
|
:,,::,a:
|
|
|
|
]])
|
|
|
|
|
|
|
|
# Stress tests - check for linear scaling (won't necessarily fail if
|
|
|
|
# quadratic, but hopefully users will complain if it appears to hang)
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[dnl
|
|
|
|
m4_for([i], [1], [10000], [], [m4_set_add([a], i)])dnl
|
|
|
|
m4_set_add_all([b]m4_for([i], [1], [10000], [], [,i]))dnl
|
|
|
|
m4_set_remove([a], [1])dnl
|
|
|
|
m4_set_remove([b], [10000])dnl
|
|
|
|
m4_set_add_all([a]m4_for([i], [1], [10000], [], [,i]))dnl
|
|
|
|
m4_for([i], [1], [10000], [], [m4_set_add([b], i)])dnl
|
|
|
|
m4_len(m4_set_contents([a]))
|
|
|
|
m4_len(m4_set_foreach([b], [b], [m4_if(m4_eval(b & 1), [1],
|
|
|
|
[m4_set_remove([b], b, [-])])]))
|
|
|
|
m4_set_size([b])
|
2008-10-14 05:37:31 +08:00
|
|
|
m4_define([prune3x], [m4_if(m4_eval([$1 % 3]), [0],
|
|
|
|
[m4_set_remove([a], [$1], [-])])])dnl
|
|
|
|
m4_len(m4_set_map([a], [prune3x]))
|
Implement O(n) unique element set creation.
* lib/m4sugar/m4sugar.m4 (m4_set_add, m4_set_add_all)
(m4_set_contains, m4_set_contents, m4_set_delete)
(m4_set_difference, m4_set_dump, m4_set_empty, m4_set_foreach)
(m4_set_intersection, m4_set_list, m4_set_listc, m4_set_remove)
(m4_set_size, m4_set_union): New macros.
* lib/m4sugar/foreach.m4 (m4_set_add_all): Add O(n) fallback for
m4 1.4.x.
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS, AC_SUBST): Use
new m4_set API for the set most likely to be large.
* doc/autoconf.texi (Set manipulation Macros): New node.
* NEWS: Mention new macros.
* tests/m4sugar.at (m4@&t@_set): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-28 20:35:34 +08:00
|
|
|
m4_count(m4_shift(m4_set_intersection([a], [b])))
|
|
|
|
]], [[38894
|
|
|
|
5000
|
|
|
|
5000
|
2008-10-14 05:37:31 +08:00
|
|
|
3333
|
|
|
|
3334
|
Implement O(n) unique element set creation.
* lib/m4sugar/m4sugar.m4 (m4_set_add, m4_set_add_all)
(m4_set_contains, m4_set_contents, m4_set_delete)
(m4_set_difference, m4_set_dump, m4_set_empty, m4_set_foreach)
(m4_set_intersection, m4_set_list, m4_set_listc, m4_set_remove)
(m4_set_size, m4_set_union): New macros.
* lib/m4sugar/foreach.m4 (m4_set_add_all): Add O(n) fallback for
m4 1.4.x.
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS, AC_SUBST): Use
new m4_set API for the set most likely to be large.
* doc/autoconf.texi (Set manipulation Macros): New node.
* NEWS: Mention new macros.
* tests/m4sugar.at (m4@&t@_set): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-28 20:35:34 +08:00
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|