Commit Graph

609 Commits

Author SHA1 Message Date
Eric Blake
e752d8d90f Mention proper fix for zsh users.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Recommend zsh
version known to work.
Suggested by Paolo Bonzini.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-29 15:47:18 -06:00
Eric Blake
c0af9c5e4e Document current beta-quality status.
* configure.ac: Reflect fact that change to git-version-gen
produces -, but not always a letter, on non-release builds.
* BUGS: Mention known issues.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Ask for help in
debugging platforms with deficient shells.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-29 09:30:23 -06:00
Eric Blake
7abb73425a Alter signature of AS_INIT_GENERATED.
* lib/m4sugar/m4sh.m4 (AS_INIT_GENERATED): Add parameters, and
manage here-doc and chmod in place.  This also allows future
changes for optimizing the child via diversion/m4_wrap magic.
* lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Update
caller.
* doc/autoconf.texi (Initialization Macros) <AS_INIT_GENERATED>:
Update the documentation.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-29 06:30:40 -06:00
Eric Blake
c602a5c6d0 Use _m4_stack_reverse in m4_set.
* lib/m4sugar/m4sugar.m4 (_m4_set_contents_1)
(_m4_set_contents_2): Rewrite to share _m4_stack_reverse
implementation.
(m4_set_contents, m4_set_foreach, m4_set_list, m4_set_listc)
(m4_set_map): Adjust callers to new API.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-29 06:29:38 -06:00
Eric Blake
52773c7b70 Add m4_stack_foreach_sep.
* lib/m4sugar/m4sugar.m4 (m4_stack_foreach_sep)
(m4_stack_foreach_sep_lifo): New macros.
(_m4_stack_reverse): Adjust prototype, to support it.
(m4_copy): Use fewer macros.
* tests/m4sugar.at (m4@&t@_stack_foreach): Rename...
(m4@&t@_stack): ...and add m4_stack_foreach_sep tests.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-29 06:28:37 -06:00
Paolo Bonzini
250422b094 Rewrite handling of diversion and expansion stack.
* NEWS: Document stricter requirement on m4_init.
* lib/m4sugar/m4sugar.m4 (m4_divert_stack): New, replacing
_m4_divert_n_stack.
(_m4_divert_stack_push): New.
(m4_divert): Use _m4_divert_stack_push and replace m4_define with
m4_popdef.
(m4_divert_push): Use _m4_divert_stack_push.
(m4_divert_pop): Use m4_divert_stack instead of _m4_divert_n_stack,
pop _m4_divert_stack instead of m4_divert_stack.
(m4_expansion_stack): New.  Update comment above it.
(m4_expansion_stack_push, m4_expansion_stack_pop): Work on
_m4_expansion_stack instead of m4_expansion_stack.
(m4_expansion_stack_dump): Check presence of _m4_expansion_stack
instead of m4_expansion_stack.  Use m4_expansion_stack's expansion
instead of the definition, and compensate for the trailing newline
in the expansion.
(m4_warn, _m4_defun_pro, _m4_defun_epi): Check presence of
_m4_expansion_stack instead of m4_expansion_stack.
(m4_newline): Expand first argument after the newline.
(m4_init): Use m4_divert_stack instead of _m4_divert_n_stack,
* tests/m4sugar.at (m4_append, m4_text_wrap): Invoke m4_init.
* tests/tools.at (whitespace in file names, the empty token): Likewise.
2008-10-29 08:00:08 +01:00
Eric Blake
63ec266226 Reduce forks while searching for better shell.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_REQUIRED)
(_AS_DETECT_SUGGESTED): No need to provide extra subshell; _AS_RUN
already does the job.
(_AS_DETECT_BETTER_SHELL): Simplify AS_EXIT when not run in a trap
0 context.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-28 21:33:46 -06:00
Eric Blake
2376807bbd Use m4_map_args in more places.
* lib/m4sugar/m4sugar.m4 (m4_defn, m4_dumpdef, m4_popdef)
(m4_undefine, m4_combine): Use m4_map_args, rather than
m4_foreach.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-28 14:02:47 -06:00
Eric Blake
0b08f40fc7 Override m4 1.4.x dumpdef, as it breaks autom4te.
* lib/m4sugar/m4sugar.m4 (m4_dumpdef): New implementation.
* doc/autoconf.texi (Redefined M4 Macros) <m4_dumpdef>: Mention
semantic differences as well as m4_dumpdefs.
* NEWS: Likewise.
* tests/m4sugar.at (m4@&t@_dumpdef): New test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-28 14:02:34 -06:00
Eric Blake
0a951c9da7 Allow m4sugar to be used without autom4te, such as in bison.
* lib/m4sugar/m4sugar.m4 (m4_text_wrap, m4_qlen): Document that
alternate escape sequences can be used.
(m4_text_box): Likewise.  Don't output quadrigraphs.
(m4_qdelta): Delete unused macro.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-28 13:45:45 -06:00
Paolo Bonzini
1415907c2d add m4_stack_foreach and m4_stack_foreach_lifo
* lib/m4sugar/m4sugar.m4 (_m4_stack_reverse): New from _m4_copy.
(m4_stack_foreach, m4_stack_foreach_lifo): New.
(m4_copy): Use m4_stack_foreach and m4_curry.
(_m4_dumpdefs_down, _m4_dumpdefs_up): Remove.
(m4_dumpdefs): Rewrite using m4_stack_foreach_lifo.
* tests/m4sugar.at (m4_stack_foreach): New test.
2008-10-28 18:29:25 +01:00
Eric Blake
cfa144a955 Use AS_VAR_ARITH.
* lib/autotest/general.m4 (at_func_arith): Delete; replace all
clients with AS_VAR_ARITH instead.
* lib/autoconf/general.m4 (_AC_COMPUTE_INT_COMPILE): Use new
macro.
* lib/autoconf/programs.m4 (_AC_FEATURE_CHECK_LENGTH): Likewise.
* tests/torture.at (Torturing config.status): Likewise.
* tests/tools.at (autom4te --force): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-27 16:11:59 -06:00
Eric Blake
bc9d68de41 Add AS_VAR_ARITH.
* lib/m4sugar/m4sh.m4 (_AS_VAR_ARITH_PREPARE, _AS_VAR_ARITH_WORKS)
(AS_VAR_ARITH): New macros.
(_AS_PREPARE, AS_PREPARE): Emit preparation.
* tests/m4sh.at (AS@&t@_VAR_ARITH): New test.
* doc/autoconf.texi (Polymorphic Variables) <AS_VAR_ARITH>:
Document new macro.
(Limitations of Usual Tools) <expr>: Mention portability problem
if first argument starts with -.
(Shell Substitutions) <$((expression))>: Mention it.
* NEWS: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-27 16:11:56 -06:00
Eric Blake
ce2d0f043c Simplify _AS_PREPARE handling of functions.
* lib/m4sugar/m4sh.m4 (AS_REQUIRE_SHELL_FN): Factor...
(_AS_REQUIRE_SHELL_FN): ...into new helper macro.
(_AS_PREPARE): Temporarily redefine AS_REQUIRE_SHELL_FN to make
this task easier.
(_AS_LINENO_PREPARE): Make more efficient.
(_AS_MKDIR_P_PREPARE): Simplify use in _AS_PREPARE.
(_AS_UNSET_PREPARE): Avoid blank newline.
(AS_INIT): Emit as_func_unset alongside other functions.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-25 06:45:57 -06:00
Eric Blake
b4bb9caba2 Make m4_defun_init more robust.
* lib/m4sugar/m4sugar.m4 (m4_defun_init): Handle indirect macro
names, and correct number of arguments.
(m4_copy): Also set up location of the copy.
(m4_defun): When copied, use current macro name, not original.
* tests/m4sugar.at (m4@&t@_require: one-shot initialization):
Update test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-24 11:24:32 -06:00
Eric Blake
d0c5f482d5 Optimize clients of AS_REQUIRE.
* lib/m4sugar/m4sugar.m4 (m4_defun): Add undocumented third
argument.
(m4_defun_init): New undocumented macro.
* lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG, AS_MESSAGE, AS_BASENAME)
(_AS_DIRNAME_EXPR, AS_DIRNAME, AS_ECHO, AS_ECHO_N, AS_TEST_X)
(AS_LN_S, AS_MKDIR_P, _AS_PATH_WALK, AS_VERSION_COMPARE)
(AS_TR_SH, AS_TR_CPP, AS_VAR_APPEND, AS_VAR_PUSHDEF): Use it to
simplify these macros once the one-shot initialization is
complete.
* tests/m4sugar.at (m4@&t@_require: one-shot initialization): New
test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-24 07:13:17 -06:00
Eric Blake
2922868b72 Improve m4_copy.
* lib/m4sugar/m4sugar.m4 (m4_copy): Add second implementation for
public use.
(_m4_copy): New macro, which preserves pushdef stacks.
(_m4_defun_pro_outer): Bypass it, for speed.
(m4_init): Bypass new implementation, since it breaks on m4_defn.
* bin/autoupdate.in (handle_autoconf_macros): Likewise.
* lib/autoconf/general.m4 (AC_PREREQ): Undefine before redefining,
now that m4_copy checks this.
* doc/autoconf.texi (Redefined M4 Macros) <m4_copy>: Document
this, as well as m4_rename.
* lib/autoconf/autoconf.m4 (m4_copy): Temporarily redefine when
renaming builtins.
* NEWS: Likewise.
* tests/m4sugar.at (m4@&t@_defn): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-24 06:41:49 -06:00
Eric Blake
f6ca9fec69 Remove excess dnl from m4sh.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL, _AS_PREPARE)
(_AS_SHELL_FN_WORK, _AS_SHELL_SANITIZE, AS_IF, _AS_ECHO_LOG)
(AS_MESSAGE, AS_ERROR, AS_BASENAME, _AS_BASENAME_PREPARE)
(_AS_DIRNAME_EXPR, AS_DIRNAME, _AS_DIRNAME_PREPARE, AS_ECHO)
(AS_ECHO_N, AS_TEST_X, AS_EXECUTABLE_P, _AS_ME_PREPARE)
(_AS_LINENO_PREPARE, AS_LN_S, AS_MKDIR_P, _AS_PATH_WALK)
(AS_SET_CATFILE, AS_HELP_STRING, AS_TMPDIR, AS_VERSION_COMPARE)
(_AS_TR_SH_PREPARE, AS_TR_SH, _AS_TR_CPP_PREPARE, AS_TR_CPP)
(_AS_TR_PREPARE, AS_VAR_APPEND, AS_VAR_PUSHDEF)
(AS_INIT_GENERATED): Use fewer dnl in m4sh macro bodies.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-23 09:37:47 -06:00
Eric Blake
d7921337d3 Formatting tweak: balance () with m4sh case statements.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL)
(_AS_SHELL_SANITIZE, _AS_ECHO_N_PREPARE, _AS_ECHO_PREPARE)
(AS_SET_CATFILE, _AS_TEST_PREPARE): Add strategic shell comments.
(_AS_CASE, _AS_CASE_DEFAULT, AS_CASE): Rearrange newlines, to
allow output of strategic shell comments.
(AS_VERSION_COMPARE): Use AS_CASE.
* tests/m4sh.at (AS@&t@_IF and AS@&t@_CASE): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-23 06:13:06 -06:00
Eric Blake
ca7380b2a8 Allow AS_VAR_SET_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_VAR_SET_IF): Allow continuation of
line.
* lib/autoconf/general.m4 (AC_CACHE_VAL): Supply newline no longer
provided by AS_VAR_SET_IF.
* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Adjust
clients.
* lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise.
* tests/m4sh.at (AS@&t@_VAR basics): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-21 21:04:20 -06:00
Eric Blake
0467924f24 Allow AS_VAR_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_VAR_IF): Allow continuation of line.
* lib/autoconf/functions.m4 (AC_CHECK_FUNC): Adjust clients.
* lib/autoconf/general.m4 (AC_CHECK_FILE, AC_CHECK_DECL):
Likewise.
* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL)
(_AC_CHECK_HEADER_NEW, _AC_CHECK_HEADER_OLD)
(_AC_CHECK_HEADER_DIRENT): Likewise.
* lib/autoconf/libs.m4 (AC_CHECK_LIB): Likewise.
* lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW, AC_CHECK_MEMBER):
Likewise.
* tests/m4sh.at (AS@&t@_VAR basics): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-21 21:04:11 -06:00
Eric Blake
e84e41e106 Allow AS_CASE in shell lists.
* lib/m4sugar/m4sh.m4 (AS_CASE): Always execute test, in case of
side effects.  Allow continuation of script on same line as esac.
* lib/autoconf/c.m4 (AC_PROG_CC_STDC): Adjust client.
* tests/m4sh.at (AS@&t@_IF and AS@&t@_CASE): Enhance test.
* NEWS: Document the subtle change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-21 21:04:02 -06:00
Eric Blake
b837cd019d Allow AS_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_IF): Always execute test, in case of
side effects.  Allow continuation of script on same line as fi.
(_AS_DETECT_BETTER_SHELL): Adjust clients.
(AS_VAR_IF, AS_VAR_SET_IF): For now, supply newline no longer
given by AS_IF.
* lib/autoconf/c.m4 (_AC_PROG_PREPROC_WORKS_IFELSE): Likewise.
* lib/autoconf/general.m4 (_AC_ENABLE_IF): Likewise.
(AC_EGREP_CPP, _AC_RUN_IFELSE): Adjust client.
* lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise.
* doc/autoconf.texi (Common Shell Constructs) <AS_IF>: Fix typo.
(Polymorphic Variables): Move mention of dnl to the only two
AS_VAR functions that need it.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-21 21:03:57 -06:00
Eric Blake
86ce15b622 Add AS_VAR_APPEND.
* lib/m4sugar/m4sh.m4 (_AS_VAR_APPEND_PREPARE)
(_AS_VAR_APPEND_WORKS, AS_VAR_APPEND): New macros.
(AS_PREPARE, _AS_PREPARE): Emit preparation.
* tests/m4sh.at (AS@&t@_VAR_APPEND): New test.
* doc/autoconf.texi (Polymorphic Variables) <AS_VAR_APPEND>:
Document new macro.
<AS_VAR_SET>: Mention ramification of `""` rules.
* NEWS: Mention new macro.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-21 15:03:17 -06:00
Paolo Bonzini
89839f42af Use a shell function for _AC_PREPROC_IFELSE.
* lib/autoconf/general.m4 (_AC_PREPROC_IFELSE_BODY): New macro.
(_AC_PREPROC_IFELSE): Use a shell function.
* lib/m4sugar/m4sh.m4 (AS_REQUIRE): Factor for faster execution.
(AS_REQUIRE_SHELL_FN): Bypass AS_REQUIRE if function has already
been provided.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-21 10:42:34 -06:00
Eric Blake
b8b7615a43 Add banners to generated files.
* lib/m4sugar/m4sh.m4 (_AS_SHELL_SANITIZE): Use m4_text_box for
existing banner.
(AS_INIT): Add new banners at strategic points.
* lib/autoconf/general.m4 (AC_INIT): Alter banner location, and
make consistent with other banners.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-21 08:00:57 -06:00
Paolo Bonzini
5969d90008 Make sure that nested AS_REQUIRE do not lose the desired diversion.
* lib/m4sugar/m4sh.m4 (AS_REQUIRE): Expand _m4_divert_desired before
passing it to m4_divert_require, so that its content is not used
anymore.
* tests/m4sh.at (Nested AS_REQUIRE): New testcase.
2008-10-19 00:01:16 +02:00
Eric Blake
c6b172ee19 Add m4_curry.
* lib/m4sugar/m4sugar.m4 (m4_curry, _m4_curry): New macros.
* tests/m4sugar.at (m4@&t@_map_args): Rename...
(m4@&t@_map_args and m4@&t@_curry): ...and add currying tests.
* doc/autoconf.texi (Looping constructs) <m4_map_args>: Document
currying as a way to add parameters.
(Evaluation Macros) <m4_curry>: Document the new macro.
* NEWS: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 16:32:27 -06:00
Eric Blake
a00c4430ba Improve suggested test filtering.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_SUGGESTED_PRUNE): New macro,
extracted from...
(_AS_DETECT_BETTER_SHELL): ...here, to use faster API.  No need to
check for an empty required set.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 16:23:21 -06:00
Eric Blake
92f34215fc Add m4_set_map.
* lib/m4sugar/m4sugar.m4 (m4_set_foreach): New macro.
* tests/m4sugar.at (m4@&t@_set): Enhance test.
* doc/autoconf.texi (Set manipulation Macros) <m4_set_map>:
Document it.
* NEWS: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 16:02:48 -06:00
Eric Blake
f4ace96990 Document m4_map_args.
* lib/m4sugar/m4sugar.m4 (m4_transform, m4_transform_pair):
Rename...
(m4_map_args, m4_map_args_pair): ...to these names, and document.
(m4_version_unletter): Use the interface.
* lib/m4sugar/foreach.m4 (m4_map_args, m4_map_args_pair)
(_m4_map_args_, _m4_map_args_pair_, _m4_map_args_pair_end):
Perform same renames.
* lib/m4sugar/m4sh.m4 (AS_CASE, AS_IF): Adjust callers.
* tests/m4sugar.at (m4@&t@_map_args): New test.
(recursion): Adjust caller.
* tests/m4sh.at (AS@&t@_IF and AS@&t@_CASE): Likewise.
* doc/autoconf.texi (Looping constructs) <m4_map_args>: Document
this interface.
* NEWS: Mention the new macros.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 16:00:57 -06:00
Eric Blake
093eca1787 Reduce vertical whitespace in configure.
* lib/autoconf/general.m4 (AC_INIT): Silence newline output during
m4 side effect initializations.
* lib/m4sugar/m4sh.m4 (AS_PREPARE): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 15:48:51 -06:00
Eric Blake
c7f3d4ef19 Test AS_VAR interfaces.
* tests/m4sh.at (AS@&t@_VAR): New test.
* lib/m4sugar/m4sh.m4 (AS_VAR_PUSHDEF): Force expansion of
_AS_TR_SH_PREPARE at top level, rather than argument collection.
(AS_TR_SH): Support command substitution.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 15:48:17 -06:00
Eric Blake
6e3761f85f Add AS_VAR_COPY.
* lib/m4sugar/m4sh.m4 (AS_VAR_COPY): New macro.
(AS_VAR_IF): Use it, instead of the broken AS_VAR_GET.
* lib/autoconf/general.m4 (AC_CACHE_CHECK): Likewise.
* lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise.
* lib/autotest/general.m4 (_AT_FINISH): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 14:07:11 -06:00
Eric Blake
7fdde10b5f Sort AS_VAR_* interfaces.
* lib/m4sugar/m4sh.m4 (AS_VAR_GET): Reduce output to one line.
(AS_VAR_TEST_SET, AS_VAR_SET, AS_VAR_SET_IF, AS_VAR_POPDEF): Sort,
no code changes.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-17 14:01:49 -06:00
Eric Blake
29f8f14acd Allow comments before functions emitted by m4sh.
* lib/m4sugar/m4sh.m4 (AS_REQUIRE_SHELL_FN): Add comment
argument.  Supply closing comment, to ease readability.
(_AS_MKDIR_P_PREPARE): Adjust caller.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-16 20:25:28 -06:00
Eric Blake
d99fef0e1e Add AS_FUNCTION_DESCRIBE.
* lib/m4sugar/m4sh.m4 (AS_FUNCTION_DESCRIBE): New macro.
* lib/autotest/general.m4 (AT_INIT): Use it.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-16 19:59:11 -06:00
Eric Blake
257a2a68d0 Speed up m4_qlen with caching.
* lib/m4sugar/m4sugar.m4 (_m4_qlen): Renamed from old m4_qlen.
(m4_qlen): Cache results for speed.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-16 10:50:25 -06:00
Paolo Bonzini
a38c243f00 Fix Libtool's config.lt test.
* lib/m4sugar/m4sh.m4 (_AS_PREPARE): Disable AS_REQUIRE while
expanding it.
2008-10-16 10:41:51 +02:00
Eric Blake
7eba1c0ae0 Break circular require chain in _AS_LINENO_PREPARE.
* lib/m4sugar/m4sh.m4 (_AS_LINENO_PREPARE): Ensure that logging is
disabled when reporting LINENO failure, since logging requires
LINENO.
* doc/autoconf.texi (Initialization Macros): Recommend m4_pushdef,
not m4_rename, since the latter is undocumented.
* lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Avoid
m4_rename, as it does not yet handle pushdef stacks.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-15 16:19:04 -06:00
Eric Blake
6edff90b47 Cleanups to previous patches.
* doc/autoconf.texi (Portable Shell): Minor edits.
(Limitations of Builtins): Touch up wording.
* lib/m4sugar/m4sh.m4 (AS_LINENO_PUSH): Nuke trailing whitespace.
(_AS_SHELL_SANITIZE): Wrap comments less than 80 columns.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-15 11:22:25 -06:00
Paolo Bonzini
26ba5ebd23 Assume a (possibly buggy) unset' is present after a better shell' was found.
* lib/autoconf/general.m4 (_AC_CACHE_DUMP): Use AS_UNSET.
* lib/autoconf/programs.m4 (AC_PROG_SED): Use AS_UNSET.
* lib/m4sugar/m4sh.m4 (_AS_UNSET_PREPARE): Provide $as_unset as an
alias for AS_UNSET, for backwards compatibility.
(_AS_DETECT_BETTER_SHELL): Set BASH_ENV and ENV to /dev/null in case
the shell does not support unset.
(_AS_SHELL_SANITIZE): Work around Bash 2.01 bugs.  Unset BASH_ENV.
(AS_INIT, _AS_PREPARE, AS_PREPARE): Call it.
(AS_UNSET): Assume it is there but it might fail if the variable is
not set.  Use it throughout instead of $as_unset.
2008-10-15 16:05:07 +02:00
Paolo Bonzini
d73b293fd3 Turn AS_SHELL_SANITIZE into a for-Libtool-only wrapper.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_REQUIRED, _AS_DETECT_SUGGESTED): Remove
m4_require of _AS_DETECT_BETTER_SHELL.
(_AS_CLEANUP): Add it here.
(_AS_DETECT_BETTER_SHELL): Just expand the test instead of appending it
to _AS_CLEANUP.
(_AS_SHELL_SANITIZE): New name of the old AS_SHELL_SANITIZE macro.
(AS_SHELL_SANITIZE): New macro hacking around Libtool misuse.
(AS_PREPARE): Use _AS_SHELL_SANITIZE.
(AS_INIT): Add m4_provide of itself.
2008-10-15 16:04:39 +02:00
Paolo Bonzini
cde022163b Use "test x$foo = xyes" to avoid upsetting Libtool's sh.test.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL, _AS_SHELL_FN_WORK): Use
"test x$foo = xyes".
2008-10-15 16:04:08 +02:00
Paolo Bonzini
6265de13fe Trim down the size of the better-shell test.
* lib/m4sugar/m4sh.at (_AT_DETECT_BETTER_SHELL): Store the common
snippets into shell variables.
(_AS_RUN): Rewrite.
2008-10-15 11:06:02 +02:00
Paolo Bonzini
270c996180 Support a stack of LINENO values for AS_MESSAGE.
* lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG): If defined, use $as_lineno as
the line number emitted to the log file.
(AS_LINENO_PUSH, AS_LINENO_POP): New.
* tests/m4sh.at (LINENO Stack): New test.
2008-10-15 11:06:01 +02:00
Paolo Bonzini
920874ceda Use m4_require to implement AS_REQUIRE.
* lib/m4sugar/m4sugar.m4 (_m4_require_call): Accept a third argument.
(m4_require): Pass it.
(m4_divert_require): New.
* lib/m4sugar/m4sh.m4 (AS_REQUIRE): Rewrite using m4_divert_require.
Remove comment about differences with m4_require.
* tests/m4sh.at (AS_REQUIRE_SHELL_FN and m4_require): Update to test
the expected behavior.
(Nested AS_REQUIRE_SHELL_FN): New test.
2008-10-14 15:14:12 +02:00
Paolo Bonzini
45f473304f Add and document AS_INIT_GENERATED.
* lib/m4sugar/m4sh.m4 (AS_INIT_GENERATED): New.
* lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Use it.
* doc/autoconf.texi (Initialization macros): Document it.
2008-10-13 18:01:21 +02:00
Eric Blake
0ba284a888 Use consistent shell function style.
* lib/m4sugar/m4sh.m4 (_AS_PREPARE, AS_REQUIRE_SHELL_FN)
(_AS_SHELL_FN_WORK): Imitate GNU Coding Standards for C
functions.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-13 08:50:25 -06:00
Paolo Bonzini
c04c47665c place names of contributors under m4 rather than shell comments
2008-10-12  Paolo Bonzini  <bonzini@gnu.org>

	* lib/m4sugar/m4sh.m4 (_AS_LINENO_PREPARE): Place names of
	contributors under m4 rather than shell comments.
2008-10-13 14:27:35 +02:00
Paolo Bonzini
06bceefef2 Add and document AS_ME_PREPARE and AS_LINENO_PREPARE
2008-10-10  Paolo Bonzini  <bonzini@gnu.org>

	* lib/m4sugar/m4sh.m4 (AS_ME_PREPARE, AS_LINENO_PREPARE): New.
	* doc/autoconf.texi (Initialization macros): Document them.
	(Portable Shell): Refer to AS_LINENO_PREPARE.

	* bin/autoconf.as: Invoke AS_ME_PREPARE.
	* lib/autotest/general.m4: Likewise.
2008-10-11 13:30:38 +02:00
Eric Blake
523ee0e116 Fix _AS_MKDIR_P usage.
* lib/m4sugar/m4sh.m4 (_AS_MKDIR_P): Correct documentation to
match implementation.
(_AS_PREPARE, _AS_MKDIR_P_PREPARE): Adjust callers.
* doc/autoconf.texi (Programming in M4sh) <AS_MKDIR_P>: Tweak
wording to better match behavior.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-10 08:40:09 -06:00
Paolo Bonzini
b9de80b2dc use a shell function for AS_MKDIR_P
2008-10-10  Paolo Bonzini  <bonzini@gnu.org>

	* m4sugar/m4sh.m4 (_AS_MKDIR_P): New, from AS_MKDIR_P.  Adjust
	meaning of as_mkdir_p to be `false' or a full `mkdir -p' command.
	(AS_MKDIR_P): Just dispatch to as_func_mkdir_p.
	(_AS_PREPARE): Define shell functions.
	(_AS_MKDIR_P_PREPARE): Set as_mkdir_p according to the above change.
	Define shell functions.
2008-10-10 15:03:22 +02:00
Eric Blake
01dd2bedd0 Only prepare $as_me if it will be used.
* lib/m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Avoid unconditional
preparation.
(_AS_ECHO_LOG): Depend on $LINENO preparation.
(AS_MESSAGE): Depend on $as_me preparation.
(AS_TMPDIR): Use AS_ERROR, rather than a hand-rolled copy.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-09 10:58:11 -06:00
Paolo Bonzini
dd0654cc13 more cleanup before adding shell functions
2008-10-09  Paolo Bonzini  <bonzini@gnu.org>

	* m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Delay setting as_me
	until the M4SH-INIT diversion using _AS_ME_PREPARE.
	(_AS_PREPARE): Invoke _AS_EXPR_PREPARE before _AS_BASENAME_PREPARE
	and _AS_DIRNAME_PREPARE, and _AS_BASENAME_PREPARE and _AS_ME_PREPARE
	before _AS_LINENO_PREPARE.
	(AS_PREPARE): Include all the AS_REQUIREs manually.
	(_AS_ME_PREPARE): New.
	(_AS_LINENO_PREPARE): Use m4_defun.
2008-10-09 16:04:59 +02:00
Paolo Bonzini
34b79a8a83 avoid problems when _AS_BASENAME_EXPR are invoked before _AS_EXPR_PREPARE
2008-10-09  Paolo Bonzini  <bonzini@gnu.org>

	* m4sugar/m4sh.m4 (_AS_BASENAME_EXPR, _AS_DIRNAME_EXPR): Do not
	require _AS_EXPR_PREPARE.
	(_AS_BASENAME_PREPARE, _AS_DIRNAME_PREPARE): Do it here.
	(_AS_PREPARE): Add _AS_BASENAME_PREPARE.
2008-10-09 15:41:14 +02:00
Paolo Bonzini
734abde3de remove shell function "spy" 2008-10-08 06:17:43 -06:00
Paolo Bonzini
926ed6a975 place _AS_UNSET_PREPARE in the right diversion 2008-10-08 06:10:10 -06:00
Eric Blake
f789b40e97 Avoid repeating required shell tests in suggested set.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_REQUIRED, _AS_DETECT_SUGGESTED):
Use m4_set, rather than m4_expand_once/m4_append.
(_AS_DETECT_SUGGESTED): Adjust to new storage layout, and filter
required tests out of suggested tests.
Reported by Paolo Bonzini.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-08 05:53:45 -06:00
Eric Blake
6f106cdead Ensure _AS_CLEANUP is defined.
* lib/m4sugar/m4sh.m4 (_AS_CLEANUP): Give initial definition.
* tests/m4sh.at (AS@&t@_INIT cleanup): Expose the need for this.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-07 12:11:01 -06:00
Eric Blake
7e1c6397cc Improve m4sh maintainability.
* lib/m4sugar/m4sh.m4: Sort macros for sanitizing the shell; no
code change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-07 10:55:05 -06:00
Eric Blake
a2f7e1aa97 Fix m4 quoting in previous patch.
* lib/m4sugar/m4sh.m4 (AS_REQUIRE_SHELL_FN): Determine diversion
name prior to invoking AS_REQUIRE.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-07 06:14:34 -06:00
Paolo Bonzini
95268678f0 add a separate diversion for shell functions
* lib/m4sugar/m4sh.m4 (M4SH-INIT-FN): New diversion.
(AS_REQUIRE): Accept diversion parameter.
(AS_REQUIRE_SHELL_FN): Use it.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-06 21:35:11 -06:00
Eric Blake
b30850a851 Add m4_default_quoted.
* lib/m4sugar/m4sugar.m4 (m4_default_quoted): New macro.
(m4_for, m4_expand_once, m4_text_wrap, m4_text_box): Use it.
* doc/autoconf.texi (Conditional constructs): Document it.
* NEWS: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-10-06 20:19:32 -06:00
Eric Blake
d0098d52bc Fix off-by-one bug in _m4_shiftn.
* lib/m4sugar/foreach.m4 (_m4_shiftn): Handle case when shifting
all arguments.
* tests/m4sugar.at (M4 loops): Test it.
Reported by Akim Demaille.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-27 20:30:25 -06:00
Eric Blake
5391c02b40 Adjust to recent m4 1.6 change to support m4_debugmode(d).
* lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Move
freeze-time decision of using faster 1.6 implementation...
(m4_init): ...to a runtime decision, and add use of new debugmode
flag.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-25 16:28:29 -06:00
Eric Blake
ce818dc20b Add reminder to keep dual implementations in sync.
* lib/m4sugar/m4sugar.m4: Add comments.
* lib/m4sugar/foreach.m4: Likewise.
Suggested by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-22 07:26:33 -06:00
Eric Blake
550a9fa1e1 Avoid extra side effects in m4sugar list expansion.
* lib/m4sugar/m4sugar.m4 (m4_mapall_sep, m4_list_cmp): Wrap
around...
(_m4_mapall_sep, _m4_list_cmp_raw): ...new helpers, to avoid
duplicate side effects.
(m4_version_compare): Adjust caller.
* lib/m4sugar/foreach.m4 (m4_list_cmp): Rename...
(_m4_list_cmp_raw): ...to match m4sugar.
* doc/autoconf.texi (Looping constructs): Document the behavior of
side effects.
* tests/m4sugar.at (M4 loops, m4@&t@_map, m4@&t@_version_compare):
Ensure only one side effect.
(recursion): Fix test typo.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-21 22:17:33 -06:00
Jim Meyering
f5de6cdf5a Avoid shell parse errors after interrupt due to empty ``.
* doc/autoconf.texi (Shell Substitutions): Document the issue.
* lib/m4sugar/m4sh.m4 (AS_VAR_IF): New function.
* lib/autoconf/functions.m4 (AC_CHECK_FUNC): Use it in place of
"test AS_VAR_GET([...]) = yes"
* lib/autoconf/general.m4 (AC_CHECK_FILE, AC_CHECK_DECL): Likewise.
* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Likewise.
(_AC_CHECK_HEADER_NEW, _AC_CHECK_HEADER_OLD): Likewise.
(_AC_CHECK_HEADER_DIRENT): Likewise.
* lib/autoconf/libs.m4 (AC_CHECK_LIB): Likewise.
* lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW, AC_CHECK_MEMBER): Likewise.
* lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Use
temporary variable to work around the issue.
* tests/foreign.at (Libtool): Quote result of command
substitution.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
2008-08-19 23:00:51 +02:00
Eric Blake
aeff96ce94 Fix m4_map regression from 2007-10-16.
* lib/m4sugar/m4sugar.m4 (_m4_apply): New macro.
(m4_map): Ignore empty sublists.  For a list consisting of only an
empty sublist, this restores 2.61 behavior of being a no-op.
(m4_map_sep): Likewise, and expand separator.
(m4_mapall, m4_mapall_sep): New macros, to regain 2.62 behavior.
(_m4_map): Rewrite, to be common base for all four variants.
* lib/m4sugar/foreach.m4 (_m4_map): Adjust to new prototype.
* tests/m4sugar.at (m4@&t@_map): Add tests.
* doc/autoconf.texi (Looping constructs) <m4_map>: Document new
macros, and mention ramifications of expanded separator.
* NEWS: Mention the change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-15 07:06:39 -06:00
Eric Blake
903b58ef95 Implement m4_transform_pair, to speed up AS_IF.
* lib/m4sugar/m4sugar.m4 (m4_transform, m4_transform_pair): New
macros, undocumented for now.
* lib/m4sugar/foreach.m4 (m4_transform, m4_transform_pair): Also
the m4 1.4.x counterparts.
* lib/m4sugar/m4sh.m4 (AS_IF, AS_CASE): Use it.
* tests/m4sh.at (AS@&t@_IF and AS@&t@_CASE): Test it.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-14 21:51:40 -06:00
Eric Blake
ce0298d64e Optimize m4_bmatch.
* lib/m4sugar/foreach.m4 (m4_bmatch): Provide linear
implementation for m4 1.4.x.
* tests/m4sugar.at (m4@&t@_bmatch): New test.
(recursion): Test the linear nature.
* NEWS: Document the fix.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-12 15:29:39 -06:00
Eric Blake
430dd8892b Fix m4_cond corner case.
* lib/m4sugar/foreach.m4 (_m4_cond): Ensure alternate
implementation allows concatenation with subsequent text.
* tests/m4sugar.at (m4@&t@_cond): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-12 09:18:53 -06:00
Eric Blake
694606d338 Add linear m4_cond for m4 1.4.x.
* lib/m4sugar/m4sugar.m4 (m4_cond): Split into...
(_m4_cond): ...this, for fewer macros per iteration.
* lib/m4sugar/foreach.m4 (_m4_cond): New implementation.
* tests/m4sugar.at (recursion): Test it.
* NEWS: Document the linear guarantee.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-06 09:57:08 -06:00
Eric Blake
565b34d33b Speed up diversion handling.
* lib/m4sugar/m4sugar.m4 (m4_divert, m4_divert_push)
(m4_divert_pop, m4_divert_text): Avoid dnl for fewer macro
expansions.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-06 09:56:59 -06:00
Eric Blake
550a531311 Fix bugs in previous version of m4_bpatsubsts.
* lib/m4sugar/foreach.m4 (_m4_bpatsubsts): Don't expand $1, and
allow concatenation with subsequent text.
* tests/m4sugar.at (m4@&t@_bpatsubsts): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-30 09:45:21 -06:00
Eric Blake
8d81fd7f28 Add linear m4_bpatsubsts for m4 1.4.x.
* lib/m4sugar/m4sugar.m4 (m4_bpatsubsts): Match documentation
about anchors, even for only one substitution.
* lib/m4sugar/foreach.m4 (_m4_bpatsubsts): New implementation.
* doc/autoconf.texi (Conditional constructs) <m4_bpatsubsts>:
Clarify behavior with regard to quoting.
* tests/m4sugar.at (recursion): Test scaling of m4_bpatsubsts.
(m4@&t@_bpatsubsts): New test.
* NEWS: Document the linear guarantee.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-29 20:37:30 -06:00
Eric Blake
a40eef5129 Tweak m4_do semantics.
* lib/m4sugar/m4sugar.m4 (m4_do): Don't concat final argument with
subsequent text.
* lib/m4sugar/foreach.m4 (m4_do): Don't concat intermediate
arguments, and avoid infinite loop.
* doc/autoconf.texi (Evaluation Macros) <m4_do>: Document the
behavior.
* tests/m4sugar.at (m4@&t@_do): New test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-29 19:36:20 -06:00
Eric Blake
8f5c14ff91 Optimize m4_for.
* lib/m4sugar/m4sugar.m4 (m4_for): Use fewer macros.
(_m4_for): Take additional parameter, for fewer m4_indir calls.
* lib/m4sugar/foreach.m4 (_m4_foreach, _m4_shiftn, m4_do)
(m4_reverse, _m4_list_pad, _m4_list_cmp): Adjust all callers.
* doc/autoconf.texi (Looping constructs) <m4_for>: Document subtle
semantic change caused by the optimization.
* tests/m4sugar.at (M4 loops): Test the new semantics.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-29 19:36:18 -06:00
Eric Blake
c39d9a4678 One more m4_list_cmp tweak.
* lib/m4sugar/m4sugar.m4 (_m4_list_cmp_1): Don't defer shift.
* lib/m4sugar/foreach.m4 (m4_list_cmp): Fix comment.
* tests/m4sugar.at (recursion): Test both directions of list
disparity.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-29 08:28:01 -06:00
Eric Blake
4766c77f42 Add m4_reverse, and improve m4_list_cmp.
* lib/m4sugar/m4sugar.m4 (m4_reverse): New macro.
(m4_list_cmp): Rewrite to give linear behavior with M4 1.6 on an
m4_reverse'd list.
* lib/m4sugar/foreach.m4 (m4_reverse): Add the M4 1.4.x
counterpart.
* tests/m4sugar.at (recursion): Test it.
* doc/autoconf.texi (Evaluation Macros) <m4_reverse>: Document
it.
(Text processing Macros) <m4_append>: Cross-reference to m4_set.
* NEWS: Mention new macro.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-29 07:12:26 -06:00
Eric Blake
64474728e7 Avoid _m4_shiftn for m4 1.6 speedup.
* lib/m4sugar/m4sugar.m4 (m4_foreach, _m4_foreach, m4_map)
(_m4_map, m4_map_sep): Rewrite recursion to use one less m4_if.
* lib/m4sugar/foreach.m4 (_m4_map): Accomodate changed signature.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-28 11:42:14 -06:00
Eric Blake
3f1a601013 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 06:35:34 -06:00
Eric Blake
e48d698fdc Avoid infinite aclocal loop.
* lib/m4sugar/m4sugar.m4 (m4_init): Bypass m4_include tracing, so
that aclocal doesn't insist on finding m4sugar/foreach.m4.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-25 21:13:23 -06:00
Eric Blake
dbb9fe36bf 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-25 17:42:29 -06:00
Eric Blake
36d8106f6d Support multiple arguments to m4_defn, m4_popdef, and m4_undefine.
* lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Loop
through all variables, per POSIX and newer m4.
(_m4_text_wrap): Exploit the looping capabilities.
* tests/m4sugar.at (m4@&t@_defn): Test this.
* NEWS: Document it.
* doc/autoconf.texi (Redefined M4 Macros) <m4_defn, m4_popdef>
<m4_undefine>: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-19 13:11:45 -06:00
Eric Blake
8c938c72f0 Reduce overhead of m4_builtin([defn]).
* lib/m4sugar/m4sugar.m4 (_m4_defn, _m4_popdef, _m4_undefine): New
internal macros, which are slightly more efficient than
m4_builtin([defn]) and company.
(m4_defn, m4_popdef, m4_undefine, m4_warn, m4_ifset)
(_m4_dumpdefs_up, _m4_dumpdefs_down, _m4_wrap, m4_for)
(_m4_divert_n_stack, m4_divert_pop, m4_expansion_stack_push)
(m4_expansion_stack_dump, _m4_defun_pro, _m4_defun_epi)
(_m4_defun_epi_outer, _m4_require_call, m4_combine, m4_append)
(_m4_append_uniq, m4_append_uniq_w, _m4_text_wrap, m4_text_box)
(m4_version_prereq): Use them.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-19 10:53:10 -06:00
Eric Blake
434bdc105b Use warnings from m4 when available.
* lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Don't
define slower wrapper if m4 will warn on our behalf; key off of
__m4_version__, added alongside the new warnings in m4 1.6.
* tests/m4sugar.at (m4@&t@_defn): New test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-19 09:28:18 -06:00
Eric Blake
65ff0e8f88 Add m4_joinall.
* lib/m4sugar/m4sugar.m4 (m4_joinall, _m4_joinall): New macros.
* tests/m4sugar.at (m4@&t@_join): Test them.
* doc/autoconf.texi (Text processing Macros) <m4_join>: Document
m4_joinall.
* NEWS: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-18 20:18:37 -06:00
Eric Blake
ebe1f38cba Revert m4_prepend; it is less efficient, and unused by bison.
* lib/m4sugar/m4sugar.m4 (m4_prepend, m4_prepend_uniq)
(m4_prepend_uniq_w): Delete addition from 2008-07-11.
(_m4_grow_uniq_1): Rename back...
(_m4_append_uniq): ...to this.
* NEWS: Revert NEWS blurb.
* doc/autoconf.texi (Text processing Macros) <m4_prepend>: Delete.
* tests/m4sugar.at (m4@&t@_prepend): Delete.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-16 14:47:46 -06:00
Eric Blake
6eb7c48491 Avoid failure if version.m4 is omitted but m4_PACKAGE_* unused.
* lib/m4sugar/m4sugar.m4 (m4_version_compare): Provide alternate
definition for non-Autoconf clients of m4sugar.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-15 14:53:21 -06:00
Eric Blake
0bc266ef15 Tighten bound of potential speed of m4_append.
* doc/autoconf.texi (Text processing Macros) <m4_append>
<m4_prepend>: If m4 is fixed, m4_append can be linear rather than
O(n log n).
* lib/m4sugar/m4sugar.m4 (m4_append, m4_append_uniq): Fix comments.
Analysis by Bruno Haible.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-14 10:13:28 -06:00
Eric Blake
8d6a868692 Inherit improvements from bison's fork of m4sugar.
* lib/m4sugar/m4sugar.m4 (m4_PACKAGE_VERSION): Ignore failure to
find version.texi, since bison does not provide it.
(m4_prepend): Add new macro, from bison.
(m4_prepend_uniq, m4_prepend_uniq_w): Add new macros, for
completeness.
(_m4_append_uniq): Rename...
(_m4_grow_uniq_1): ...to this to share implementation, and
optimize initial assignment.
(m4_append_uniq_w): Adjust caller.
* NEWS: Document new macros.
* doc/autoconf.texi (Text processing Macros) <m4_append>: Mention
speed consideration.
<m4_prepend>: Document the new prepend variants.
* tests/m4sugar.at (m4@&t@_prepend): New test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-11 11:14:46 -06:00
Eric Blake
5fb9f9c1a2 Work around M4 1.6 warning on undefined macros.
* lib/m4sugar/m4sugar.m4 (changeword, symbols): Don't rename if
not already available as builtins.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-11 10:10:53 -06:00
Eric Blake
4d953cea64 Allow unbalanced () in m4_expand.
* lib/m4sugar/m4sugar.m4 (m4_expand, _m4_expand): Use more complex
quotes.
(m4_noquote, _m4_split): Use consistent complex quote.
* tests/autotest.at (Left paren, Right paren): Test this.
(Parentheses): Ensure new quadrigraphs still work.
(AT_CHECK_AT_TITLE_CHAR): All title char tests exercise m4_expand.
* NEWS: Mention the fix.
* doc/autoconf.texi (Quadrigraphs): Revert mention of macros that
require quadrigraphs for ().
(Evaluation Macros) <m4_expand>: Relax the restriction against
unbalanced ().
(Pretty Help Strings) <AS_HELP_STRING>: Likewise.
(Writing Testsuites) <AT_SETUP>: Likewise.
Reported by Joel E. Denny, fix suggested by Noah Misch.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-23 09:32:05 -06:00
Eric Blake
c60735fbb8 Support unbalanced () in AT_SETUP by adding two new quadrigraphs.
* bin/autom4te.in (handle_output): Substitute @{:@ and @:}@.
(handle_traces): Likewise.
* lib/m4sugar/m4sugar.m4 (m4_qlen): Account for new quadrigraphs.
* tests/autotest.at (AT_CHECK_AT_TITLE_CHAR): Add new tests.
* doc/autoconf.texi (Quadrigraphs): Document them.
(Evaluation Macros) <m4_expand>: Enhance documentation.
(Text processing Macros) <m4_text_box>: Document cases where
quadrigraphs can help for problemetic unbalanced parentheses.
(Pretty Help Strings) <AS_HELP_STRING>: Likewise.
(Writing Testsuites) <AT_SETUP>: Likewise.
(Limitations of Builtins) <case>: Consolidate text on unbalanced
parentheses, and add an example of creative comments.
* NEWS: Document the addition.
Reported by Joel E. Denny.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-22 16:28:14 -06:00
Eric Blake
a91e2a71d2 Use GPLv2+ plus exception as license for release.
Return back to GPLv2+, until the text of the exceptions is
finalized, reverting the change from 2007-07-03 and the first
part of the change from 2007-07-20.

Also:
* COPYING: Revert to GPLv2.
* COPYINGv3: New file, since some auxiliary build tools, used for
building autoconf and not installed, are GPLv3.
* Makefile.am (EXTRA_DIST): Distribute COPYINGv3.
* NEWS: Remove mention of GPLv3.
* README: Clarify situation regarding GPLv3.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-05 17:04:48 -06:00
Eric Blake
f6bc7b22d4 Don't swallow $1 in textual local variables.
* lib/m4sugar/m4sugar.m4 (m4_combine): Don't use overquoting and
expansion of text arguments, as that swallows $1.
(m4_text_wrap): Likewise, by splitting out...
(_m4_text_wrap): ...new helper macro.  Also, allow arbitrary
expression for width.
* tests/m4sugar.at (m4@&t@_text_wrap): Test this.
(m4@&t@_combine): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-21 11:32:46 -06:00
Eric Blake
3c108e5e9d Fix yesterday's regression in m4_wrap([$1]).
* lib/m4sugar/m4sugar.m4 (_m4_wrap): Don't directly invoke wrapped
text, since it may contain text that looks like parameters.
* tests/m4sh.at (AS@&t@_INIT cleanup): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-11 20:05:49 -06:00
Eric Blake
39ed7a3e19 Tweak m4_wrap to force FIFO or LIFO semantics.
* lib/m4sugar/m4sugar.m4 (m4_wrap): Override M4 implementation.
(m4_wrap_lifo, _m4_wrap): New macros.
* lib/m4sugar/m4sh.m4 (AS_INIT): Combine all cleanup into known
order, prior to m4sugar's.
(_AS_DETECT_BETTER_SHELL): Use cleanup parameter, rather than
m4_wrap.
* lib/autotest/general.m4 (AT_INIT): Combine all cleanup into
known order, prior to m4sh's.
* doc/autoconf.texi (Diagnostic Macros) <m4_fatal>: Document
argument.
(Redefined M4 Macros) <m4_wrap>: Rewrite documentation to match
new behavior.
* tests/m4sh.at (AS_INIT cleanup): New test.
* NEWS: Document the change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-11 18:58:31 -06:00
Eric Blake
e3d1e29bc3 Documentation improvements.
* doc/autoconf.texi (Looping constructs): s/recurses/repeats/.
(Evaluation Macros): Drop `1' suffix from metasyntax variable name
that preceeds @dots.  Improve wording.
(Text processing Macros): Drop `1' suffix from metasyntax variable
name that preceeds @dots.
(Number processing Macros): Drop `1' suffix from metasyntax
variable name that preceeds @dots.  Improve wording.
* lib/m4sugar/m4sugar.m4 (m4_cmp): Comment wording fix.
Suggested by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-03 06:29:00 -07:00
Eric Blake
f4d0beaefa * lib/m4sugar/m4sugar.m4 (m4_qlen): Use fewer macros.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-01-15 08:49:08 -07:00
Eric Blake
af2f1f262c Fix thinko in earlier patch - m4_join isn't defined yet.
* lib/m4sugar/m4sugar.m4 (m4_expansion_stack_push, _m4_defun_pro)
(_m4_defun_pro_outer, _m4_defun_epi, _m4_defun_epi_outer)
(m4_require): Use m4_do, not m4_join.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-12-12 16:31:21 -07:00
Eric Blake
18e4a9e117 Optimize AC_REQUIRE.
* lib/m4sugar/m4sugar.m4 (m4_expansion_stack_push, _m4_defun_pro)
(_m4_defun_pro_outer, _m4_defun_epi, _m4_defun_epi_outer)
(m4_require): Avoid extra macro calls.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-12-12 14:18:25 -07:00
Ralf Wildenhues
5779945993 * lib/m4sugar/m4sh.m4 (AS_TMPDIR): Use $as_me, not $me. 2007-11-14 21:55:59 +01:00
Jim Meyering
48520ed2f7 Adapt dependencies, now that a version change doesn't modify configure.ac
* GNUmakefile: Remove "make clean" kludge.
* lib/m4sugar/Makefile.am (version.m4): Depend on Makefile, not
configure.ac.
Don't redirect directly to target.
Use $@, not literal "version.m4".
2007-11-13 08:56:32 +01:00
Ralf Wildenhues
610817462b * doc/autoconf.texi (Making testsuite Scripts): Document
":;{" shorthand as in previous patch.

2007-11-12  Paul Eggert  <eggert@cs.ucla.edu>

* doc/autoconf.texi (Limitations of Builtins): Document problem
with { ... } a bit more clearly.  Suggest ":;{" as a shorthand
for the workaround.
* lib/m4sugar/Makefile.am (version.m4): Detect 'echo' failure.
Use ":;{" shorthand.
* tests/Makefile.am ($(srcdir)/package.m4): Likewise.
2007-11-12 23:30:58 -08:00
Ralf Wildenhues
bf5fec7028 * lib/m4sugar/Makefile.am (version.m4): Another bash bug workaround. 2007-11-04 17:00:57 +01:00
Eric Blake
dd3c3f2e27 Adjust version comparison to account for git snapshot numbers.
* lib/m4sugar/m4sugar.m4 (_m4_version_unletter): Also treat - as a
component separator.
* doc/autoconf.texi (Number processing Macros)
<m4_version_compare>: Document this change.
* tests/m4sugar.at (m4@&t@_version_compare): Test it.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-11-03 07:20:47 -06:00
Jim Meyering
7ffc555888 Remove all generated files from version control.
* aclocal.m4: Remove.
* configure: Remove.
* Makefile.in: Remove, along with all other Makefile.in in subdirs.
* .gitignore: Add aclocal.m4, configure and Makefile.in.  Sort.
* README-hacking: New file: how to build from just-checked-out sources.
2007-10-27 12:44:59 +02:00
Eric Blake
17b1f091f4 Improve corner case of m4_expand.
* lib/m4sugar/m4sugar.m4 (m4_expand, _m4_expand): Rewrite more
efficiently.
* tests/m4sh.at (AS@&t@_HELP_STRING): Test overquoted comma.
* doc/autoconf.texi (Evaluation Macros) <m4_expand>: Update
documentation.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-23 21:04:12 -06:00
Eric Blake
49d1c176cc s/parenthesis/parentheses/ where appropriate.
* doc/autoconf.texi: Fix typos.
* lib/m4sugar/m4sugar.m4: Likewise.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-19 07:08:59 -06:00
Eric Blake
8c73ae256c Document m4_expand limitation.
* lib/m4sugar/m4sugar.m4 (m4_expand): Mention problem with
unbalanced parse.
* doc/autoconf.texi (Pretty Help Strings, Evaluation Macros)
(Writing Testsuites): Mention limitations inherited from
m4_expand.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-19 06:38:48 -06:00
Eric Blake
5b6f53e441 Fix AT_TESTED, AT_KEYWORDS.
* lib/m4sugar/m4sugar.m4 (m4_append_uniq): Warn if separator
occurs in string, as duplicates may be added.
(_m4_append_uniq): New helper macro.
(m4_append_uniq_w): New macro.
* lib/autotest/general.m4 (AT_TESTED, AT_KEYWORDS): Fix
duplication bug by using new macro.
(AT_INIT) <at_tested>: Restore newline separators.  Invoke tested
programs with stdin redirected, so programs that don't
understand --version won't try to behave interactively.
* tests/autotest.at (Tested programs): Catch this bug.
* tests/m4sugar.at (m4@&t@_append): Test new macro.
* tests/local.at (AT_TESTED): Add m4, perl.
* doc/autoconf.texi (Text processing Macros): Document
m4_append_uniq_w, and update text on m4_append.
* NEWS: Document the addition.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-18 09:46:19 -06:00
Eric Blake
0c0e7bbd41 Fix m4_combine for empty suffix list.
* lib/m4sugar/m4sugar.m4 (m4_combine): Check for suffix list.
* doc/autoconf.texi (Text processing Macros): Document this.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-17 10:02:04 -06:00
Eric Blake
f2ea75eb03 Add m4_combine, based on Libtool's lt_combine.
* lib/m4sugar/m4sugar.m4 (m4_combine): New macro.
* doc/autoconf.texi (Text processing Macros): Document it.
* NEWS: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-17 07:13:00 -06:00
Ralf Wildenhues
bbb9c9628d Fix `configure --help=recursive' in unconfigured/read-only trees.
* lib/m4sugar/m4sh.m4 (_AS_LN_S_PREPARE): Avoid errors when `.'
is not writable, use 'cp -p' in this case, in the hope that it
will not actually be needed.  Still try removing files, in case
of other write errors.
* lib/autoconf/general.m4 (_AC_INIT_SRCDIR): For ac_confdir,
use $as_myself, not $0.
(_AC_INIT_HELP): For --help=recursive, if the subdir does not
exist, try again in the the source tree.  This change assumes
that the subpackage configure script is capable of running
--help=recursive in the source tree.
* tests/torture.at (Configuring subdirectories, Deep Package):
Adjust tests to expose both issues, also try invocation as
`sh configure ...' and plain `configure ...' with PATH adjusted.
* NEWS, THANKS: Update.
Report by Hans Ulrich Niedermann.
2007-10-16 23:50:03 +02:00
Eric Blake
96a08a7ee4 m4_map is a looping construct.
* lib/m4sugar/m4sugar.m4 (m4_map, _m4_map, m4_map_sep): Move.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-16 12:18:24 -06:00
Eric Blake
33239cbd38 Fix m4_map, and add some more utility macros.
* lib/m4sugar/m4sugar.m4 (m4_apply, m4_count, m4_dquote_elt)
(m4_echo, m4_make_list): New documented macros.
(_m4_quote, _m4_shift2): New helper macros.
(m4_map): Change semantics to allow calling macro without
arguments.
(m4_map_sep): Likewise.  Also change semantics to quote separator,
to match m4_join and m4_append.
(m4_version_unletter): Fix use of m4_map.
* doc/autoconf.texi (Evaluation Macros): Document m4_apply,
m4_count, m4_dquote_elt, m4_echo, m4_make_list.
(Text processing Macros): Mention m4_dquote as a faster
alternative to joining with commas.
(Looping constructs): Document m4_map, m4_map_sep.
* NEWS: Mention new macros.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-16 12:00:00 -06:00
Eric Blake
f3b4cc104e A few more m4sugar improvements, to benefit libtool.
* lib/m4sugar/m4sugar.m4 (m4_bpatsubsts, _m4_shiftn): Reduce size
of expansion by avoiding extra uses of $@.
(m4_shiftn): Avoid extra dnl, and forbid shifting by 0.
(_m4_cdr): New helper macro.
(_m4_map, m4_map_sep): Use it to reduce size of expansion.
(_m4_shift3): New helper macro.
(_m4_foreach): Swap argument order, and use new macro to reduce
size of expansion.
* doc/autoconf.texi (Looping constructs) <m4_shiftn>: Mention that
count must be positive.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-16 06:23:10 -06:00
Eric Blake
10a850e84a Enhance AS_HELP_STRING.
* lib/m4sugar/m4sugar.m4 (m4_text_wrap): Don't expand arguments,
and reduce number of expansions.
* lib/m4sugar/m4sh.m4 (AS_HELP_STRING): Rework to use m4_expand,
and to take indent and wrap column numbers.
* tests/m4sh.at (AS@&t@_HELP_STRING): Update the test.
* doc/autoconf.texi (Pretty Help Strings): Document details about
arguments.
(Text processing Macros): Minor tweaks.
* NEWS: Document this change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-15 12:18:24 -06:00
Eric Blake
fd1344033b Fix 2007-10-03 regression with AT_SETUP([a, b]).
* lib/m4sugar/m4sugar.m4 (m4_expand): New macro.
* lib/autotest/general.m4 (AT_SETUP): Use it to preserve
whitespace after single-quoted comma.
* tests/autotest.at (AT_CHECK_AT_TITLE_CHAR): Test this.
* NEWS: Revert caveat about semantics change on comma.
* doc/autoconf.texi (Programming in M4): Lighten the warning on
using m4sugar; it is stabilizing.
(Redefined M4 Macros): Touch up wording on M4 builtins.
(Evaluation Macros): Document m4_expand.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-15 08:43:21 -06:00
Eric Blake
72431d8c84 Change m4_join to match libtool's ltsugar semantics.
* lib/m4sugar/m4sugar.m4 (m4_join): Just define this, not defun.
Ignore empty arguments, using...
(_m4_join): ...this new helper.
* tests/m4sugar.at (m4@&t@_join): New test.
* doc/autoconf.texi (Text processing Macros): Document new
semantics of m4_join.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-13 11:11:44 -06:00
Eric Blake
6e1d6e2c5b 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 08:09:08 -06:00
Eric Blake
b171ca4ed3 Some more m4sugar documentation.
* lib/m4sugar/m4sugar.m4: Clean up macro order.
* doc/autoconf.texi (Programming in M4): Lighten the warning on
using m4sugar; it is stabilizing and useful.
(Redefined M4 Macros): Touch up wording on M4 builtins; sort.  Add
m4_divert, m4_undivert, __file__, __line__, __oline__.
(Diagnostics): New node, documenting m4_assert, m4_errprintn,
m4_fatal, m4_location, m4_warn.
(Diversion support): New node, documenting m4_divert_push,
m4_divert_pop, m4_divert_text, m4_divert_once.
(Text processing Macros): Sort.  Add m4_flatten, m4_join,
m4_newline, m4_strip, m4_text_box, m4_text_wrap.
(Programming in M4sh, Macro Names): Document namespace
limitations.  Mention that non-Automake macros should not begin
with `AM_'.
(Reporting Messages): Mark AC_DIAGNOSE, AC_WARNING, and AC_FATAL
as obsolescent.
(Printing Messages): Change cross-reference.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-12 15:55:56 -06:00
Eric Blake
be938d2dec Document interaction of recent m4_append change with Libtool HEAD.
* lib/m4sugar/m4sugar.m4 (m4_append): Document semantics change.
(m4_append_uniq): Add new parameters, based on lt_append_uniq.
* tests/m4sugar.at (m4@&t@_append): New test.
* NEWS: Document semantics change.
* doc/autoconf.texi (Text processing Macros): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-12 15:01:31 -06:00
Eric Blake
b4df79e1ab Avoid some overhead from m4_defn and m4_popdef.
* lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Only
pass on first argument, since we are documented that way.
(m4_for, m4_append_uniq, m4_text_wrap): Optimize out defined-ness
check where it is safe to do so.
(m4_append): Likewise, and quote the separator.
(m4_text_box): Likewise, and avoid regex, also be robust to
expansion and quadrigraphs.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-10 16:04:01 -06:00
Eric Blake
45b46a7467 Another AC_DEFINE speedup.
* lib/autoconf/general.m4 (AC_DEFINE_TRACE): Move parameter
elision...
(_AC_DEFINE_Q): ...here, and only do it once.
* lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Avoid overquoting.
* lib/m4sugar/m4sh.m4 (AS_LITERAL_IF): Fix m4_defn overquoting
introduced 2007-10-05.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-10 14:36:27 -06:00
Eric Blake
028272af52 Reduce number of forks at startup.
* lib/m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Speed up NLS
sanitization.
* configure: Regenerate.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-10 07:13:39 -06:00
Eric Blake
2c63638e2b Improve header of bin/autoconf.
* lib/m4sugar/m4sh.m4 (AS_INIT): Add a 'generated from' notice.
* lib/autoconf/general.m4 (_AC_INIT_NOTICE): Override new notice
from M4sh.
* bin/autoconf.as: Put copyright up front in generated file.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-09 17:15:43 -06:00
Eric Blake
94a9faded7 Fix regression in m4_text_wrap from 2007-10-05.
* lib/m4sugar/m4sugar.m4 (m4_max, m4_min): New macros.
(m4_sign): Sort.
(m4_text_wrap): Fix off-by-one error in rewrite from m4_for to
m4_format.
* lib/autotest/general.m4 (AT_SETUP): Avoid negative width.
* tests/autotest.at (Long test title, Longer test title): Test
this fix, beyond what AS_HELP_STRING already tests.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-08 14:09:22 -06:00
Eric Blake
a83ac461c6 Avoid m4 warnings on bad m4_format usage.
* lib/m4sugar/m4sugar.m4 (m4_text_wrap): Use %*s, in case width
evaulates to 0.
* lib/autotest/general.m4 (AT_ordinal): Likewise; also ensure that
enough arguments are provided.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-08 10:46:21 -06:00
Paul Eggert
df45b2a924 Don't assume "." is writeable, for commands like "autoconf --version".
* lib/m4sugar/m4sh.m4 (_AS_PATH_SEPARATOR_PREPARE): Use a
different heuristic instead, one that doesn't rely on creating
files.
2007-10-05 15:31:06 -07:00
Eric Blake
4e9078ba0b Provide better short-circuiting operation.
* lib/m4sugar/m4sugar.m4 (m4_cond, m4_newline): New macros.
(m4_text_wrap): Use it.  Also avoid useless m4_for.
* lib/m4sugar/m4sh.m4 (_AS_QUOTE_IFELSE, AS_LITERAL_IF): Use
new macro.
(_AS_IDENTIFIER_IF): Likewise, and fix bug when $1 is [,].
* lib/autotest/general.m4 (_AT_DECIDE_TRACEABLE): Use new macros
to avoid regexps.
* doc/autoconf.texi (Redefined M4 Macros): Expand m4_if
documentation.  Sort m4_mkstemp, m4_undefine.  Move m4_ifndef...
(Conditional constructs): ...here, to new section.  Also document
m4_cond, m4_ifval, m4_n, m4_ifvaln, m4_ifset, m4_case, m4_bmatch,
m4_bpatsubsts, and m4_default.
(Looping constructs): Document m4_shiftn, m4_shift2, m4_shift3,
m4_do.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-05 11:25:20 -06:00
Eric Blake
2152c1e75f Fix recent testsuite failures.
* lib/autotest/general.m4 (AT_INIT, AT_SETUP): Double-quote text
that must not be re-expanded after AS_ESCAPE.
* lib/m4sugar/m4sh.m4 (_AS_IDENTIFIER_IF): Don't expand $1 when
checking if it is an identifier.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-04 17:07:42 -06:00
Eric Blake
10fa310839 One more round of m4_foreach_w speedups.
* lib/m4sugar/m4sugar.m4 (m4_flatten): Only use regex if newline
is present.
(_m4_split): Avoid useless expansions inside definition.  Move
argument defaulting...
(m4_split): ...here.  Change alternate quote to something less
likely to appear in $1.  Also, special case space as regexp...
(m4_foreach_w): ...to avoid regexp on single-term list.
(m4_default, m4_defn, m4_popdef, m4_undefine, _m4_foreach): Avoid
useless expansions inside definition.
* tests/m4sugar.at (m4@&t@_split): Add tests.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-04 10:09:38 -06:00
Eric Blake
e76d30be25 Optimize checking for identifiers.
* lib/m4sugar/m4sh.m4 (AS_IDENTIFIER_IF, _AS_IDENTIFIER_IF): New
macros, more efficient than regex on m4_re_word.
* lib/autoconf/general.m4 (AC_SUBST, AC_DEFINE_TRACE_LITERAL):
Rewrite in terms of new macro.  As a side-effect, AC_DEFINE can
now use @&t@.
* configure: Regenerate.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-03 17:22:46 -06:00
Eric Blake
987a333766 Another round of regex avoidance.
* lib/m4sugar/m4sugar.m4 (m4_cr_alnum, m4_cr_all)
(_m4_define_cr_not, m4_cr_not_letters, m4_cr_not_LETTERS)
(m4_cr_not_Letters, m4_cr_not_digits, m4_cr_not_alnum)
(m4_cr_not_symbols1, m4_cr_not_symbols2): New macros, implementing
character ranges useful in m4_translit.
(m4_toupper, m4_tolower): Optimize the constant portion of
definition.
* lib/m4sugar/m4sh.m4 (AS_LITERAL_IF): Also reject @S|@ because it
creates $, and reject [] thanks to AS_TR_SH rewrite.
(AS_TR_SH, AS_TR_CPP): Use just translit, not bpatsubst.
(AS_ESCAPE): Factor...
(_AS_ESCAPE): ...into new macro, with second argument required.
Avoid regex in common case.
(_AS_QUOTE): Use new macro.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-03 15:42:42 -06:00
Eric Blake
1a128bd6e6 Whitespace cleanup.
* lib/autoconf/types.m4: Avoid space-tab.
* lib/m4sugar/m4sh.m4: Use tab consistently.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-03 15:36:43 -06:00
Paul Eggert
9174b63f95 * lib/m4sugar/m4sugar.m4 (m4_shift2, m4_shift3): New macros.
(m4_shiftn): Remove no-longer-needed optimization.  Perhaps we
should remove m4_shiftn entirely?
(m4_case, b4_bmatch, m4_map_sep, m4_bpatsubsts, m4_join):
Prefer m4_shift2 and m4_shift3 to m4_shiftn.
* lib/autoconf/lang.m4 (_AC_LANG_DISPATCH): Likewise.
* lib/m4sugar/m4sh.m4 (AS_CASE, AS_IF): Likewise.
* tests/autotest.at (AT_CHECK_AT_TEST): Likewise.
2007-10-03 13:06:08 -07:00
Eric Blake
7b96e241f7 Comment touchups.
* lib/m4sugar/m4sugar.m4: Grammar fixes in comments.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-03 08:09:04 -06:00
Eric Blake
53b2e90b42 Optimize appending text.
* lib/m4sugar/m4sugar.m4 (m4_append_uniq): Use index, not regular
expressions.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-02 20:23:03 -06:00
Eric Blake
57e51969f0 Optimize recursion.
* lib/m4sugar/m4sugar.m4 (m4_shiftn): This macro is called in a
lot of hot spots; optimize it for 2 and 3 shifts.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-02 15:26:34 -06:00
Eric Blake
7113f1b07c Optimize AC_PREREQ and other m4sugar numerics.
* lib/m4sugar/m4sugar.m4 (m4_sign): Write with m4_eval.
(m4_cmp): Compare arbitrary expressions, without overflow.
(m4_version_unletter): Also recognize capital letters.
(m4_version_compare): Avoid regex when splitting version number
string.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-02 07:04:11 -06:00
Eric Blake
615300a1d5 Allow nameless iteration.
* lib/m4sugar/m4sugar.m4 (m4_for, _m4_for): Access variable
indirectly.
* tests/m4sugar.at (myvar): Test this.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-09-30 06:45:33 -06:00
Eric Blake
b2dda0adc7 Speed optimization: avoid m4 regex when other algorithms work.
* lib/m4sugar/m4sh.m4 (AS_LITERAL_IF): Rewrite without regex.
(_AS_QUOTE_IFELSE): Likewise.
* lib/m4sugar/m4sugar.m4 (m4_strip): Reduce from 3 to 2 regex.
(m4_bpatsubsts): Split...
(_m4_bpatsubsts): ...so that recursion can avoid patsubst on empty
regex.
(_m4_divert()): Define, to avoid m4 warning on `m4_divert'.
(m4_qlen): Optimize on short strings, to avoid regex.
(m4_sign): Avoid regex, and fix bug with `01' and `-0'.
* lib/autoconf/general.m4 (AC_CACHE_VAL): Rewrite without regex.
(AC_DEFINE_TRACE): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-09-29 21:44:10 -06:00
Eric Blake
b2e3fcf5bb Squelch changeword in m4sugar.
* lib/m4sugar/m4sugar.m4 (changeword): Disable this experimental
feature of m4 1.4.x.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-09-27 19:55:38 -06:00
Eric Blake
afdb9d6e9f Configure whitespace touchups.
* lib/autoconf/general.m4 (_AC_INIT_HELP): Fix alignment of
installation directories, and avoid TAB, in configure --help
output.
* configure.ac: Avoid extra trailing newline.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Avoid space-tab.
* lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Avoid TAB in
config.status --help output.
* configure: Regenerate.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-09-27 19:35:55 -06:00
Eric Blake
f444a9fa8e Fix underquotation in AS_HELP_STRING.
* lib/m4sugar/m4sh.m4 (AS_HELP_STRING): Don't underquote lhs
argument.
* lib/m4sugar/m4sugar.m4 (m4_text_wrap): Don't underquote
first-prefix argument.
* tests/m4sh.at (AS@&t@_HELP_STRING): Test this fix.
* NEWS: Document AS_HELP_STRING fix.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-09-27 19:29:49 -06:00
Eric Blake
46d7a04b49 Typo fixes.
* lib/autoconf/general.m4 (AC_SUBST): Fix typo in comment.
* lib/m4sugar/m4sh.m4 (AS_VAR_PUSHDEF): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-09-25 17:05:50 -06:00