* lib/m4sugar/m4sugar.m4 (_m4_index): New internal macro.
(m4_init): Only use it in older m4.
* lib/autoconf/general.m4 (_AC_DEFINE_Q): Use it to avoid
m4_format bug in older m4.
* lib/autoconf/status.m4 (_AC_CONFIG_COMPUTE_DEST): Likewise.
Reported by Bob Proulx.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/general.m4 (_AC_DEFINE_Q): Use m4_format rather
than m4_bpatsubst to grab string prefix.
* lib/autoconf/status.m4 (_AC_CONFIG_REGISTER)
(_AC_CONFIG_REGISTER_DEST, AC_CONFIG_SUBDIRS): Likewise.
(_AC_FILE_DEPENDENCY_TRACE_COLON): Use m4_translit instead of
m4_bpatsubst to change bytes.
(_AC_CONFIG_DEPENDENCY_DEFAULT): Use m4_index rather than
m4_bmatch to find byte.
(_AC_CONFIG_COMPUTE_DEST): New helper macro.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/status.m4 (_AC_CONFIG_FOOS, AC_CONFIG_SUBDIRS): Use
m4_map_args_w.
(_AC_OUTPUT_FILE): Use m4_map_args_sep and m4_map_args.
(_AC_OUTPUT_FILE_ADJUST_DIR): New helper macro.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/general.m4 (AC_CHECK_FILES): Use m4_map_args_w,
and avoid typo.
(AC_CHECK_DECLS, AC_CHECK_DECLS_ONCE): Use m4_map_args_sep.
(_AC_CHECK_FILES, _AC_CHECK_DECLS, _AC_CHECK_DECL_ONCE): New
helper macros.
(AC_LIBSOURCES): Use m4_map_args.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/types.m4 (AC_CHECK_TYPES, AC_CHECK_MEMBERS): Use
m4_map_args_sep.
(_AC_CHECK_TYPES, _AC_CHECK_MEMBERS): New helper macros.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/headers.m4 (AH_CHECK_HEADERS)
(AH_CHECK_HEADERS_DIRENT): Rename...
(_AH_CHECK_HEADER, _AH_CHECK_HEADER_DIRENT): ...and take only one
argument, rather than a list.
(AC_CHECK_HEADERS, AC_CHECK_HEADERS_ONCE):
Adjust callers to use m4_map_args_w.
(AC_HEADER_DIRENT): Adjust caller to use m4_map_args.
(_AC_CHECK_HEADER_ONCE): New helper macro.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/functions.m4 (_AH_CHECK_FUNCS): Rename...
(_AH_CHECK_FUNC): ...and take only one argument, rather than a
list.
(AC_CHECK_FUNCS, AC_CHECK_FUNCS_ONCE): Adjust callers to use
m4_map_args_w.
(_AC_CHECK_FUNC_ONCE): New helper macro.
(AC_REPLACE_FUNCS): Use m4_map_args_w.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/m4sh.m4 (_AS_ECHO_PREPARE): Cater to Solaris ksh.
* doc/autoconf.texi (Limitations of Builtins) <printf>: Document
the print workaround.
Idea by Paolo Bonzini.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/general.m4 (_AC_RUN_LOG_STDERR): Avoid grep/rm/cat
sequence when the program's stderr was empty, while providing a
conftest.err file even in that case.
(_AC_CACHE_DUMP): Fix mismatched parenthesis.
* NEWS: Document it.
* doc/autoconf.texi (Present But Cannot Be Compiled): Document it.
* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Implement it
and adjust warning.
* tests/semantics.at (AC_CHECK_HEADERS): Test new semantics.
* lib/m4sugar/m4sugar.m4 (m4_map_args_w): New macro, undocumented
for now.
(_m4_split): Allow user control over separator.
(m4_split): Adjust caller.
(m4_foreach_w, m4_append_uniq_w, _m4_text_wrap): Rewrite to use
m4_map_args_w.
* tests/m4sugar.at (m4@&t@_append): Augment test keywords.
(M4 loops): Test new interface.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/foreach.m4 (m4_dquote_elt, m4_join, m4_joinall)
(_m4_minmax, m4_set_add_all): Use _m4_foreach instead of
m4_foreach.
* lib/m4sugar/m4sugar.m4 (_m4_joinall): Use m4_map_args_sep
instead of m4_foreach or m4_map_args.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/m4sugar.m4 (m4_map_args_sep): New macro.
(_m4_map): Change API to cover more of m4_map*.
* lib/m4sugar/foreach.m4 (_m4_map): Adjust to new API.
(m4_map_args): Delete.
* tests/m4sugar.at (m4@&t@_map_args and m4@&t@_curry): Enhance
test.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/m4sugar.m4 (_m4_for): Alter API to make it easier to
avoid m4_define by some clients.
(m4_for): Adjust caller.
* lib/m4sugar/foreach.m4 (_m4_foreach, m4_case, m4_bmatch)
(_m4_cond, _m4_bpatsubsts, _m4_shiftn, m4_do, m4_reverse)
(_m4_map, m4_map_args, m4_map_args_pair, _m4_list_pad)
(_m4_list_cmp): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/general.m4 (_AC_INIT_PARSE_ARGS): Detect case of
missing variable name, with fewer forks. Quote invalid arguments
in message, in case they include spaces.
* lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS)
(_AC_OUTPUT_MAIN_LOOP): Quote invalid arguments.
* lib/autotest/general.m4 (AT_INIT): Likewise.
Reported by Jeff Squyres.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/autoconf/c.m4 (AC_LANG_CONFTEST(C)): Define instead of
AC_LANG_SOURCE(C).
* lib/autoconf/general.m4 (_AC_INIT_PREPARE): Add a comment at the
top of confdefs.h, which also works around cpp deficiencies.
* lib/autoconf/lang.m4 (AC_LANG_DEFINE): Define AC_LANG_CONFTEST(xyz)
(AC_LANG_CONFTEST): Dispatch based on _AC_LANG.
(AC_LANG_CONFTEST()): New.
* lib/autoconf/headers.m4 (AC_CHECK_HEADER): Adjust naming.
(_AC_CHECK_HEADER_PREPROC_BODY): New name of _AC_CHECK_HEADER_OLD_BODY.
(_AC_CHECK_HEADER_COMPILE_BODY): New name of _AC_CHECK_HEADER_NEW_BODY.
(_AC_CHECK_HEADER_PREPROC): New name of _AC_CHECK_HEADER_OLD.
(_AC_CHECK_HEADER_COMPILE): New name of _AC_CHECK_HEADER_NEW.
* tests/semantics.at (AC_CHECK_HEADERS_OLD, AC_CHECK_HEADER_NEW):
Give better name.
* lib/m4sugar/m4sugar.m4 (m4_divert_stack): Use fewer macros, and
avoid extra newlines.
(m4_divert_stack_push): Compute location here, rather than caller.
(m4_divert_push): Update caller.
(m4_divert): Likewise, and also adjust current diversion name.
(m4_divert_pop): Simplify rule that diversion stack must never go
empty.
(_m4_require_call): Bypass diversion stack when collecting
required macro text.
(m4_init): Set current diversion without requiring m4_init.
* lib/m4sugar/m4sh.m4 (AS_INIT): Avoid too many pops.
* lib/autotest/general.m4 (AT_INIT): Likewise.
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Schedule wrapped
text to run prior to m4sugar cleanup.
* doc/autoconf.texi (Text processing Macros) <m4_newline>: Mention
optional argument.
(Conditional constructs) <m4_ifvaln, m4_n>: Mention use of dnl.
* NEWS: Undo blurb about m4_divert.
* tests/m4sugar.at (m4@&t@_divert_stack): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/m4sugar.m4 (m4_expansion_stack): Use fewer macros;
always output 'top level'.
(_m4_expansion_stack_entry): New macro, to format the string only
when needed.
(m4_expansion_stack_push): Only push a macro name.
(m4_warn, _m4_defun_pro): Update callers.
(m4_expansion_stack_pop, m4_expansion_stack_dump): Delete.
(_m4_defun_epi, m4_fatal): Inline the calls.
* tests/m4sugar.at (m4@&t@_expansion_stack): New test.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/m4sh.m4 (_AS_VAR_APPEND_WORKS): Remove suggestion;
we still use += if available, but should not reject shells (like
dash) that don't provide it.
(_AS_DETECT_SUGGESTED): Document a policy for m4sh.
Reported by Paolo Bonzini.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/m4sh.m4 (_AS_CASE, _AS_CASE_DEFAULT): Always provide
a non-empty command list.
(AS_CASE): Always guarantee that a case will match.
* doc/autoconf.texi (Limitations of Builtins) <case>: Document the
Solaris bug, and mention AS_CASE.
Signed-off-by: Eric Blake <ebb9@byu.net>
* lib/m4sugar/m4sh.m4 (_AS_LINENO_WORKS): Enhance the test, so
that we can choose which of two tests to trust.
(_AS_RUN): Set flag when alternate shell is running.
(_AS_DETECT_EXPAND): New macro.
(_AS_DETECT_BETTER_SHELL): Use it to massage LINENO tests.
Signed-off-by: Eric Blake <ebb9@byu.net>
* 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>
* 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>
* 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>
* 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>
* 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.
* 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>
* lib/autotest/general.m4 (_AT_CHECK): Truncate files to hold
standard output and standard error before the test, use append
mode for writing.
* THANKS: Update.
Caught by Bob Proulx' build daemons, analysis and suggested fix
by Stéphane Chazelas.
Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* 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>
* 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>
* 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.