* 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
|
|
|
|
|
|
|
|
|
2001-01-17 23:26:42 +08:00
|
|
|
# Order of the tests:
|
|
|
|
# - m4_warn
|
|
|
|
#
|
|
|
|
# - m4_require
|
|
|
|
# uses warn/error code.
|
|
|
|
#
|
2007-10-04 23:43:59 +08:00
|
|
|
# - m4_split
|
|
|
|
#
|
2007-10-12 04:46:40 +08:00
|
|
|
# - m4_append
|
|
|
|
#
|
2007-10-14 01:11:44 +08:00
|
|
|
# - m4_join
|
|
|
|
#
|
2001-01-17 23:26:42 +08:00
|
|
|
# - m4_text_wrap
|
2007-10-04 23:43:59 +08:00
|
|
|
# uses m4_split code.
|
2001-01-17 23:26:42 +08:00
|
|
|
|
2008-07-19 02:05:43 +08:00
|
|
|
## --------- ##
|
|
|
|
## m4_defn. ##
|
|
|
|
## --------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_defn])
|
|
|
|
|
|
|
|
AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine])
|
|
|
|
|
|
|
|
# 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])
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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])
|
|
|
|
|
|
|
|
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],
|
|
|
|
[[m4_append_uniq([str], [a], [ ])
|
|
|
|
m4_append_uniq([str], [a b], [ ])
|
|
|
|
m4_divert([0])dnl
|
|
|
|
str
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR([-o-], 0, [[a a b
|
|
|
|
]], [[script.4s:2: 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
|
|
|
|
|
|
|
|
|
* 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],
|
2006-06-20 13:35:38 +08:00
|
|
|
[[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])
|
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
|
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
|
|
|
|
|
|
|
## ---------- ##
|
|
|
|
## M4 Loops. ##
|
|
|
|
## ---------- ##
|
|
|
|
|
|
|
|
AT_SETUP([M4 loops])
|
|
|
|
|
|
|
|
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
|
|
|
|
]],
|
|
|
|
[[ 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
|
|
|
|
]], [])
|
|
|
|
|
|
|
|
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
|
|
|
|
2006-02-21 05:43:05 +08:00
|
|
|
AT_CLEANUP
|
2007-10-18 03:51:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
## --------------- ##
|
|
|
|
## m4_map{,_sep}. ##
|
|
|
|
## --------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([m4@&t@_map])
|
|
|
|
AT_KEYWORDS([m4@&t@_apply])
|
|
|
|
AT_KEYWORDS([m4@&t@_count])
|
|
|
|
|
|
|
|
AT_CHECK_M4SUGAR_TEXT([[dnl
|
|
|
|
m4_map([m4_count], [])
|
|
|
|
m4_map([ m4_count], [[],
|
|
|
|
[[1]],
|
|
|
|
[[1], [2]]])
|
|
|
|
m4_map_sep([m4_eval], [,], [[[1+2]],
|
|
|
|
[[10], [16]]])
|
|
|
|
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])])
|
|
|
|
]],
|
|
|
|
[[
|
|
|
|
0 1 2
|
|
|
|
3,a
|
|
|
|
pass1
|
|
|
|
pass
|
|
|
|
]], [])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
## ------------ ##
|
|
|
|
## 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])
|
|
|
|
|
|
|
|
AT_KEYWORDS([m4@&t@_foreach m4@&t@_foreach_w m4@&t@_shiftn m4@&t@_dquote_elt
|
2008-07-29 21:12:26 +08:00
|
|
|
m4@&t@_join m4@&t@_joinall m4@&t@_list_cmp m4@&t@_max m4@&t@_min
|
|
|
|
m4@&t@_reverse])
|
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
|
|
|
|
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
|
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
|
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
|
|
|
|
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
|
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
|
|
|
|
m4@&t@_set_listc m4@&t@_set_remove m4@&t@_set_size m4@&t@_set_union])
|
|
|
|
|
|
|
|
# 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])
|
|
|
|
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
|
|
|
|
|
|
|
|
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])
|
|
|
|
m4_count(m4_shift(m4_set_intersection([a], [b])))
|
|
|
|
]], [[38894
|
|
|
|
5000
|
|
|
|
5000
|
|
|
|
5000
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_CLEANUP
|