* 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
|
|
|
|
|
|
|
## --------- ##
|
|
|
|
## 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
|
|
|
|
|
|
|
|
|
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])
|
|
|
|
|
|
|
|
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])
|
|
|
|
]],
|
|
|
|
[[
|
|
|
|
|
|
|
|
|
|
|
|
one, two
|
|
|
|
[one, two]
|
|
|
|
active|active
|
|
|
|
one
|
|
|
|
one
|
|
|
|
two
|
|
|
|
two
|
|
|
|
one active two
|
|
|
|
onetwo
|
|
|
|
]])
|
|
|
|
|
|
|
|
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])
|
|
|
|
|
|
|
|
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])
|
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
|
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
|
|
|
|
]])
|
|
|
|
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
|