745 Commits

Author SHA1 Message Date
Gary V. Vaughan
cceb922d06 Factor load functionality into include builtin.
* m4/module.c (m4__module_open): Instead of calling lt_dlopenext
right away, use the preload hint first incase path searching has
been disabled by POSIXLY_CORRECT.  Otherwise fallback to a
manual path search to override libltdl's algorithm.
* m4/m4module.h: Adjust.
* m4/path.c (FILE_SUFFIXES): Order to try suffixes in our path
search algorithm.
(NO_SUFFIXES): Alternatively, how to to search a path without
adding file suffixes.
(m4_path_search): Add a new suffixes parameter defaulting to
NO_SUFFIXES.  Adjust all callers.
(m4_load_filename): New generic load function that tries to
open a matched file first as a module, and if that fails fall
back to as (possibly frozen) m4 input.
(m4_fopen): New function with close on exec functionality.
* modules/m4.c (include, sinclude): Use m4_load_filename to
overload these builtins to work with modules too.
* modules/load.c (load): Removed this builtin.
* src/main.c: Remove Dynamic loading features section, and
M4MODPATH support.
(long_options): Remove "load-module", "unload-module" and
"module-directory" options.
(OPTSTRING): Remove 'M' and 'm' options.
(process_file): Use m4_load_filename to support module names
on the command line.
* Makefile.am (TESTS_ENVIRONMENT): No need for abs_top_builddir
any more.
* doc/m4.texinfo: Update examples.
(Dynamic loading features, Load): Removed.
(Command line files): Describe how non-option arguments are
treated to try to find a matching macro file or dso.
(Include): Describe additional dso loading features if a
suitable text file cannot be found.
(Modules): Updated.
* tests/builtins.at, tests/m4.in, tests/modules.at,
tests/options.at: Adjust test cases and calling conventions
to new semantics.
* NEWS: Updated.
2008-05-06 15:44:20 -04:00
Eric Blake
c2a2811a8b Stage 22: allow builtin token concatenation outside $@.
* m4/m4module.h (m4_is_arg_composite): New prototype.
(m4_symbol_value_copy): Change return type.
(m4_arg_text): Add parameter.
(M4ARG): Adjust callers.
* m4/m4private.h: Adjust comments.
* m4/symtab.c (m4_symbol_value_copy): Detect when builtins are
flattened.
* m4/input.c (init_builtin_token): Add parameter, and allow
concatenating builtins.
(m4__next_token): Adjust caller.
* m4/macro.c (m4_is_arg_composite): New function.
(expand_argument): Allow builtin concatenation.
(m4_arg_text): Add parameter.
(m4__arg_adjust_refcount, m4__arg_print): Adjust callers.
(m4_arg_equal): Fix comparison of builtin tokens.
* modules/m4.c (define, pushdef): Warn when flattening builtins.
* doc/m4.texinfo (Define): Remove dead comment.
(Defn): Update to reflect code changes.
* tests/builtins.at (defn): Remove xfail.
* NEWS: Document this change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-05-05 20:54:23 -06:00
Eric Blake
bc9b4d7bf1 Document define_blind.
* doc/m4.texinfo (Ifelse): Add a new composite macro.
* THANKS: Update.
Suggested by Mike R.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-05-03 13:31:14 -06:00
Eric Blake
1dd98ea10e Avoid -Wshadow compiler warnings.
* m4/output.c (threshold_diversion_CB): s/div/diversion/.
* m4/macro.c (make_argv_ref, arg_symbol, m4_arg_symbol)
(m4_is_arg_text, m4_is_arg_func, m4_arg_text, m4_arg_empty)
(m4_arg_len, m4_arg_func, m4__arg_print, m4_make_argv_ref)
(m4_push_arg, m4__push_arg_quote): s/index/arg/.
* modules/format.c (format): Likewise.
* modules/m4.c (ifelse): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-05-01 12:05:03 -06:00
Eric Blake
6abccf89a8 Improve debugmode testing, based on recent branch-1.6 regressions.
* doc/m4.texinfo (Debugmode): Enhance tests.
* tests/generate.awk: Run tests from stdin, not input.m4.  Support
stderr munging when using -I examples.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-05-01 08:53:18 -06:00
Eric Blake
c3e7dc1839 Fix regression in define from 2008-02-22.
* m4/m4module.h (m4_symbol_value_copy): Add parameter.
* m4/symtab.c (m4_symbol_value_copy): Support copying $@
back-references.
* m4/macro.c (expand_argument): Update callers.
* modules/m4.c (define, pushdef): Likewise.
* tests/builtins.at (define): Enhance test to catch this.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-05-01 06:53:47 -06:00
Eric Blake
e6db1ee757 Simplify previous patch.
* tests/m4.in: Compress assignment.
Suggested by Gary V. Vaughan.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-21 20:57:45 -06:00
Eric Blake
118acde8f3 Fix --disable-shared testsuite regression from previous patch.
* tests/m4.in: Export M4MODPATH, so that recursive m4 invocations
will also work.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-21 16:46:34 -06:00
Eric Blake
5b54035664 Fix spelling of attribution to Christopher Strachey.
* doc/m4.texinfo (History, Inhibiting Invocation): Fix typo.
* THANKS: Update.
Reported by Fernando Carrijo.

Signed-off-by: Eric Blake <ebb9@byu.net>
(cherry picked from commit 05528e98e0257bcccbb5001b8ff09293e42d19b6)
2008-04-21 16:37:07 -06:00
Eric Blake
97a7769765 Fix testsuite bug when SIGPIPE is ignored.
* tests/builtins.at (divert): Consume all of m4's output, to avoid
spurious write failure.
* src/main.c (main): In batch mode, restore default handling of
SIGPIPE.
* doc/m4.texinfo (Operation modes): Document SIGPIPE behavior.
* THANKS: Update.
Reported by Bob Proulx, via his autobuilder.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-17 09:06:12 -06:00
Eric Blake
693e6ecc74 Fix 'make installcheck' after './configure --prefix-progname'.
* tests/testsuite.at (AT_CHECK_M4): Allow overriding the m4
program name.
(HELP_OTHER, PREPARE_TESTS): Document and use $M4.
* tests/builtins.at (patsubst): Avoid space-tab.
(divert, mkdtemp, mkstemp): Adjust tests to use $M4.
* tests/options.at (--debugfile): Likewise.
* tests/others.at (stdin seekable): Likewise.
(fstab): Avoid space-tab.
* Makefile.am (installcheck-local): Accomodate transformed name.
(DISTCHECK_CONFIGURE_FLAGS): Ensure no regressions, by using gm4
during 'make distcheck'.
* cfg.mk: New file, borrowed from branch.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-15 22:19:00 -06:00
Eric Blake
404e78ea54 Update prerequisite tools to match recent releases.
* configure.ac (AC_PREREQ): Rely on released autoconf.
(LT_PREREQ): Rely on released libtool.
* tests/testsuite.at (m4_version_prereq): Update dependence.
* bootstrap: Mention prerequisites.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-15 13:41:21 -06:00
Eric Blake
ce0c0b372d Work around OS/2 limitation of printf(1).
* tests/null.m4: Use m4, not printf, to generate NUL byte.
* tests/null.out: Check for esyscmd failure.
Reported by Elbert Pol.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-15 11:20:30 -06:00
Eric Blake
0fe33c9c7d Stage 21b: $@ concatenates builtins, m4wrap takes builtins.
* m4/m4module.h (m4_push_builtin): Add parameter.
(m4_builtin_print, m4_push_wrapup_init, m4_push_wrapup_finish)
(m4_arg_print, m4_symbol_value_print): Rename and reduce scope...
* m4/m4private.h (m4__builtin_print, m4__push_wrapup_init)
(m4__push_wrapup_finish, m4__arg_print, m4__symbol_value_print):
...to these, in some cases adding a parameter.
(m4__append_builtin): New prototype.
* m4/builtin.c (m4_builtin_print): Alter signature to print
builtin to a growing symbol chain.
* m4/symtab.c (m4__symbol_value_print): Alter signature.
(m4_symbol_print, dump_symbol_CB): Adjust callers.
* m4/input.c (builtin_peek, builtin_read, builtin_unget)
(builtin_print, builtin_funcs): Delete, handled via composite
blocks now.
(struct m4_input_block): Delete u.builtin member.
(init_builtin_token): Only use composite block.
(m4__append_builtin): New function.
(m4_push_builtin, m4__push_wrapup_init): Alter signature.
(m4__push_symbol): Allow builtin tokens.
(m4__push_wrapup_finish): Rename.
(composite_print, m4_print_token): Adjust callers.
* m4/macro.c (m4_wrap_args, collect_arguments): Allow builtin
tokens.
(m4__arg_print): Alter signature.
(trace_prepre, trace_pre, m4_arg_text, m4_arg_equal): Adjust
callers.
* modules/m4.c (m4wrap): Allow builtin tokens.
(defn, errprint): Adjust callers.
* modules/gnu.c (builtin): Likewise.
* doc/m4.texinfo (M4wrap): New test.
(Debuglen): Adjust expected output.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-14 21:09:14 -06:00
Eric Blake
b6964b5f0e Stage 21a: Optimize checks for end of input.
* m4/input.c (eof_funcs, input_eof): New objects.
(eof_peek, eof_read, eof_unget): New functions.
(file_clean, m4_push_string_init, pop_input, m4_push_wrapup_init)
(m4_pop_wrapup, next_char, peek_char, unget_input, m4_input_init)
(m4_input_exit): Use placeholder to guarantee non-NULL isp and
wsp.
(next_char): Rename retry to allow_unget, and change sense for
easier manipulation.  All callers changed.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-14 21:08:27 -06:00
Eric Blake
03c4e545af Improve OS/2 detection.
* modules/gnu.c (m4_macro_table): Ensure all possible identifiers
are defined, not just the first.  The testsuite ensures that
exactly one gets defined.
* m4/system_.h [__EMX__]: OS/2 is not Unix-compatible, no matter
what other pre-defined macros it has.
* THANKS: Update.
Reported by Elbert Pol.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-14 17:14:33 -06:00
Eric Blake
eef195f8cd Ensure __m4_version__ is unquoted.
* tests/builtins.at (__m4_@&t@version__): Augment test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-14 06:37:56 -06:00
Eric Blake
49e254060b Avoid GNU make failure on tarball.
* Makefile.am (EXTRA_DIST): Distribute cfg.mk and maint.mk.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-14 06:31:13 -06:00
Eric Blake
38f06945a3 Allow back-referenced macro names; fixes 2008-03-13 regression.
* m4/m4module.h (m4_symbol_value_lookup): Change prototype.
* m4/utility.c (m4_symbol_value_lookup): Change signature.
* modules/m4.c (undefine, popdef, ifdef, m4_dump_symbols, defn):
Adjust all callers.
* tests/others.at (ifndef): New test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-10 14:15:51 -06:00
Eric Blake
e098cd5590 Be namespace clean for M4 version; fixes 2008-04-08 regression.
* configure.ac (version): Rename...
(M4_VERSION): ...to this, since using 'version' broke po.m4.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-10 14:12:48 -06:00
Eric Blake
d77ce2bf23 Mention 1.4.11 release.
* doc/m4.texinfo (History, Defn, Ifdef, Ifelse, M4wrap)
(Extensions, Improved foreach): Distinguish 1.4.11 and 1.6.
(Format): Add test of C99 hex-float parsing.
* NEWS: Mention 1.4.11 release.
* tests/builtins.at (divert): Add additional test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-09 16:51:52 -06:00
Eric Blake
0b8410450c Overhaul inter-version releases to work with git.
* configure.ac (version): New variable, which has nicer version
contents when using git 1.5.5+, hardcoded to 1.9a otherwise.
(TIMESTAMP): Delete, since CVS id expansion died with transition
to git.
(AM_INIT_AUTOMAKE): Use version to decide gnu vs. gnits.
* build-aux/mkstamp: Delete, no longer used.
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Kill, to speed up
rebuilds when timestamps don't matter.
(MKSTAMP): Delete, no longer used.
(EXTRA_DIST): No longer worry about mkstamp.
(.version): New rule and distributed file.
(doc/m4.1, tests/package.m4): Depend on .version, not
configure.ac, for timestamp.
* ltdl/m4/gnulib-cache.m4: Import git-version-gen module.
* modules/gnu.c (__m4_version__): TIMESTAMP no longer exists.
* src/main.c (main): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-08 12:12:53 -06:00
Eric Blake
359f9f0c4c Use GNUmakefile module.
* ltdl/m4/gnulib-cache.m4: Import gnumakefile module.
* Makefile.am: Split off maintainer rules...
* maint.mk: ...into this new file.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-28 06:44:20 -06:00
Eric Blake
6608fa6d08 Stage 20b: make m4wrap obey POSIX fifo ordering.
* m4/m4module.h (m4_wrap_args): Add prototype.
* m4/m4private.h (enum m4__symbol_chain_type): Add M4__CHAIN_LOC.
(struct m4__symbol_chain): Add struct u_l.
* m4/input.c (m4_push_wrapup_init, m4_push_wrapup_finish): Use
new link type.
(composite_peek, composite_read, composite_clean): Handle location
link.
* m4/macro.c (m4_wrap_args): New function.
* modules/m4.c (m4wrap): Use it.
* doc/m4.texinfo (M4wrap): Sync with branch and POSIX.
(Extensions): Document extension of multiple arguments.
(Location, Improved m4wrap): Adjust example to match FIFO order.
* tests/builtins.at (wrap): Likewise.
* NEWS: Document this change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-18 14:00:39 -06:00
Eric Blake
1761b0d68f Stage 20a: reduce unget's in input engine.
* m4/input.c (struct input_funcs): Alter read_func prototype.
(next_char, file_read, buildin_read, string_read, composite_read):
Add allow_argv parameter.
(init_builtin_token, init_argv_symbol): Require all prior input to
be consumed.
(m4_skip_line, match_input, consume_syntax): Adjust callers.
(m4__next_token): Consume first byte without peek.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-17 16:03:57 -06:00
Eric Blake
44c6706b4f Update for fresh bootstrap.
* ltdl/m4/gnulib-cache.m4: Updated copyright from upstream.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-17 08:16:45 -06:00
Eric Blake
6b1c5a2cbd Document join, in order to fix bug in m4wrap example.
* examples/join.m4: New file.
* examples/wraplifo2.m4: Likewise.
* Makefile.am (EXTRA_DIST): Add new files.
* doc/m4.texinfo (Improved m4wrap): New node.
(Defn, Location): Enhance tests.
(Shift): Document the composit macro join.
(Incompatibilities): Move documentation of LIFO vs. FIFO...
(M4wrap): ...here, to match improved example.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-15 20:52:36 -06:00
Eric Blake
a2df6b461c Stage 19c: allow builtin tokens in more macros.
* m4/m4module.h (m4_symbol_value_lookup, m4_builtin_print): New
prototypes.
* m4/m4private.h (enum m4__symbol_chain_type): Add
M4__CHAIN_FUNC.
(struct m4__symbol_chain): Add builtin member.
* m4/utility.c (m4_symbol_value_lookup): New method.
* m4/builtin.c (m4_builtin_print): New function.
* m4/symtab.c (m4_symbol_value_print): Use it.
* m4/input.c (builtin_print): Likewise.
(m4__push_symbol): Allow pushing builtin tokens.
(composite_peek, composite_read, composite_unget, composite_clean)
(composite_print): Handle builtin tokens.
(init_builtin_token): Allow builtin tokens from composite input.
(m4__next_token): Flatten builtins inside comment or string.
* m4/macro.c (expand_argument): Strengthen assertion.
(collect_arguments, m4_arg_equal, m4_arg_print, m4_push_args):
Handle builtin tokens.
(arg_symbol): Add parameter, and allow NULL level.
(m4_arg_symbol, m4__push_arg_quote): Adjust callers.
(m4_arg_text): Ensure all builtins have been flattened.
* modules/m4.c (defn, dumpdef, popdef, traceoff, traceon)
(undefine, m4_dump_symbols): Warn on invalid macro names.
(ifdef, ifelse, shift): Handle builtin tokens.
* modules/gnu.c (m4symbols): Likewise.
* doc/m4.texinfo (Defn, Ifdef, Ifelse): Document and test the new
behavior.
(Debuglen): Likewise, and remove xfail.
* NEWS: Mention the change.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-13 21:09:33 -06:00
Eric Blake
2f49d755e5 Stage 19b: invert sense of bit for handling builtin tokens.
* m4/m4module.h (M4BUILTIN_ENTRY): New convenience macro.
(M4_BUILTIN_GROKS_MACRO): Rename...
(M4_BUILTIN_FLATTEN_ARGS): ...and invert sense.
(m4_symbol_value_groks_macro, m4_symbol_groks_macro): Likewise...
(m4_symbol_value_flatten_args, m4_symbol_flatten_args): ...to
this.
* m4/m4private.h (VALUE_MACRO_ARGS_BIT)
(m4_symbol_value_groks_macro): Likewise...
(VALUE_FLATTEN_ARGS_BIT, m4_symbol_value_flatten_args): ...to
this.
* m4/symtab.c (m4_symbol_value_groks_macro): Likewise...
(m4_symbol_value_flatten_args): ...to this.
* m4/macro.c (collect_arguments): Accomodate changed sense.
* m4/module.c (m4__module_open): Require arguments if flattening
is requested.
* m4/input.c (m4_push_string_finish): For now, flatten all
builtins pushed as back-references.
* modules/gnu.c (m4_builtin_table, builtin): Adjust all clients.
* modules/import.c (m4_builtin_table): Likewise.
* modules/load.c (m4_builtin_table): Likewise.
* modules/modtest.c (m4_builtin_table): Likewise.
* modules/mpeval.c (m4_builtin_table): Likewise.
* modules/perl.c (m4_builtin_table): Likewise.
* modules/shadow.c (m4_builtin_table): Likewise.
* modules/stdlib.c (m4_builtin_table): Likewise.
* modules/time.c (m4_builtin_table): Likewise.
* modules/m4.c (m4_builtin_table): Likewise.
(mkstemp): Undo #undef hack from 2006-10-23, now that macro names
are stringized without preprocessor expansion.
* doc/m4.texinfo (Defn): Update comments to match reality.
(Debuglen): Update test now that user macros pass builtin tokens.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-13 21:09:32 -06:00
Eric Blake
d621af1bae Stage 19a: sort and cache builtins loaded by a module.
* m4/m4module.h (m4_set_symbol_value_builtin): Delete.  Use
m4_builtin_find_by_* instead.
(m4_builtin_find_by_func): Change return type.
* m4/m4private.h (m4__builtin): New struct.
(m4_module): Add sorted list of loaded builtins.
(struct m4_symbol_value): Change type of builtin value.
(m4__set_symbol_value_builtin): New prototype and fast accessor.
(m4_get_symbol_value_func, m4_get_symbol_value_builtin): Adjust to
new field type.
* m4/symtab.c (m4_set_symbol_value_builtin): Rename...
(m4__set_symbol_value_builtin): ...and populate additional fields,
based on new type.
(m4_get_symbol_value_func, m4_get_symbol_value_builtin): Adjust to
new field type.
* m4/module.c (install_builtin_table): Use cached table.
(compare_builtin_CB): New helper function.
(m4__module_open): Populate table.
(module_remove): Free table.
* m4/builtin.c (compare_builtin_name_CB): New helper function.
(m4_builtin_find_by_name): Rewrite to use sorted table.
(m4_builtin_find_by_func): Change return type.
* m4/input.c (struct m4_input_block): Simplify u_b, since most
fields can be determined from builtin.
(builtin_peek, builtin_read, builtin_unget, init_builtin_token)
(m4__next_token): Alter parsing so that only init_builtin_token
consumes a builtin.
(builtin_print, m4_push_builtin): Adjust all users.
* tests/macros.at (Arity, defn, and freeze): Fix typo.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-13 21:09:31 -06:00
Eric Blake
951a9ef5bb Consistently cast malloc results, for C++ compilation.
* m4/builtin.c (m4_builtin_find_by_name): Add cast.
* m4/hash.c (m4_hash_new, m4_get_hash_iterator_next, node_new)
(m4_hash_resize, maybe_grow): Likewise.
* m4/m4.c (m4_create): Likewise.
* m4/macro.c (expand_macro): Likewise.
* m4/output.c (m4_tmpname): Likewise.
* m4/path.c (search_path_add): Likewise.
* m4/symtab.c (m4_symtab_create, m4_symbol_value_create)
(symtab_fetch): Likewise.
* m4/syntax.c (m4_syntax_create): Likewise.
* modules/gnu.c (regexp_compile): Likewise.
* src/main.c (main): Likewise.
* src/freeze.c (reload_frozen_state): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-13 12:06:23 -06:00
Eric Blake
2510870d46 Fix nested builtin(`shift',$@) regression from 2008-02-23.
* m4/macro.c (make_argv_ref): Don't output expansion text when
making wrapper for builtin or indir.
* tests/builtins.at (builtin): New test.
* NEWS: Document the fix.
Reported by Andreas Schwab.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-06 20:56:44 -07:00
Eric Blake
9eb0ac9c38 The gnulib module free was deprecated.
* ltdl/m4/gnulib-cache.m4: Remove free module.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-04 17:22:55 -07:00
Eric Blake
a3952d3933 Import news from 1.4.10b.
* NEWS: Update from branch.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-29 08:35:45 -07:00
Eric Blake
cfdd338da4 Stage 18: try harder to reuse argv in recursion.
* m4/macro.c (make_argv_ref): Avoid wrapping $@ when possible.
(m4_push_args): Let make_argv_ref take care of pending data.
* doc/m4.texinfo (Improved foreach): Tweak wording to match new
performance capability.
* tests/others.at (recursion): Add tests to avoid performance
regression.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-22 21:22:38 -07:00
Eric Blake
ff7e7bf197 Update NEWS.
* NEWS: Document change to __gnu__ on 2008-02-11.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-22 12:57:57 -07:00
Eric Blake
2cdf327333 Stage 17: pass argv through quoted strings.
* m4/m4module.h (m4_arg_equal, m4_arg_len): Add parameter.
(M4ARGLEN): Adjust definition.
* m4/m4private.h (struct m4__symbol_chain): Add has_func member.
(struct m4_symbol_value): Add wrapper and has_func members.
(struct m4_macro_args): Add flatten and has_func members.
* m4/input.c (append_quote_token): Return argv refs inside quoted
strings.
(init_argv_symbol): Populate new fields.
* m4/macro.c (expand_argument, collect_arguments, make_argv_ref)
(m4_make_argv_ref): Likewise.
(arg_symbol, arg_mark, m4_is_arg_text, m4_is_arg_func): Use new
fields.
(m4_arg_equal, m4_arg_len): Handle quoted argv references, and add
new parameter.
* modules/m4.c (ifelse): Adjust caller.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-22 05:43:04 -07:00
Gary V. Vaughan
47f7469edb Fix regression in argument collection, from 2008-01-21.
* m4/input.c (m4__next_token): When DEBUG_INPUT is defined,
undo argument collection optimisation for strings, so that
m4_print_token doesn't abort when it otherwise receives an
unprintable M4_SYMBOL_VOID type token.
2008-02-22 00:15:28 +08:00
Eric Blake
def1f82375 Stage 16: cache quotes and improve m4_arg_print.
* m4/m4module.h (m4_symbol_value_print, m4_symbol_print)
(m4_arg_print): Adjust prototypes.
(m4_dump_args): Delete.
(m4_push_wrapup): Split...
(m4_push_wrapup_init, m4_push_wrapup_finish): ...into these
prototypes.
* m4/m4private.h (struct m4_syntax_table): Add cached_quote
member.
(m4__quote_cache, m4__quote_uncache): New prototypes.
* m4/syntax.c (m4_syntax_create): Initialize the cache.
(m4__quote_cache): New function.
(m4_set_syntax): Update caller.
* m4/symtab.c (m4_symbol_value_print): Add parameter.
(m4_symbol_print, dump_symbol_CB): Adjust all callers.
* m4/utility.c (m4_dump_args): Delete; callers should use
m4_arg_print instead.
* m4/input.c (m4_push_wrapup_init, m4_push_wrapup_finish): Split
implementation, and allow embedded NUL.
(m4_print_token, pop_input, composite_print, composite_peek):
(composite_read, append_quote_token): Adjust all callers.
* m4/macro.c (trace_prepre, m4_arg_text, make_argv_ref):
Likewise.
(m4_arg_print): Add parameters.
(trace_pre): Rewrite in terms of m4_arg_print.
* modules/m4.c (errprint): Likewise.
(m4wrap): Rewrite to allow embedded NUL.
(dumpdef): Adjust caller.
* doc/m4.texinfo (Debuglen): Enhance debuglen test.
* tests/null.m4: Test for NUL in m4wrap.
* tests/null.out: Update expected output.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-20 21:37:30 -07:00
Eric Blake
50fe32db83 Revert accidental checkin from previous patch.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-20 20:07:14 -07:00
Eric Blake
3ec47b1812 Fix out-of-bounds read for sanitized macro names, from 2008-02-06.
* m4/utility.c (m4_verror_at_line): Properly terminate the string.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-20 17:11:02 -07:00
Eric Blake
85a18b6ade * doc/m4.texinfo (Debuglen, Changesyntax): Fix typos.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-20 07:57:41 -07:00
Eric Blake
b5b24ec23e Clean up example on filtering defined symbols.
* doc/m4.texinfo (Foreach, Improved foreach): Document another
shortcoming in foreach.m4, and improve filter example by using
foreach2.m4.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-19 13:36:43 -07:00
Eric Blake
daed50d635 * src/main.c (usage): Fix typo.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-19 08:59:45 -07:00
Eric Blake
2e81b08037 Avoid some magic numbers.
* m4/m4private.h (CHAR_EOF, CHAR_BUILTIN, CHAR_QUOTE, CHAR_ARGV)
(CHAR_RETRY): Define in terms of UCHAR_MAX.
* m4/syntax.c (m4_syntax_create, set_syntax_set)
(reset_syntax_set, check_is_single_quotes)
(check_is_single_comments, check_is_macro_escaped)
(m4_set_quotes, m4_set_comment): Likewise.
* modules/gnu.c (regexp_compile): Likewise.
* modules/m4.c (translit): Likewise.
* src/freeze.c (produce_syntax_dump): Likewise.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-18 06:24:08 -07:00
Eric Blake
06991b51ef Add regression test for multi-character quote recursion.
* examples/foreach2.m4: Use $0 rather than spelling out name.
* examples/foreachq2.m4: Likewise.
* examples/forloop2.m4: Likewise.
* examples/hanoi.m4: Likewise.
* examples/trace.m4: Likewise.
* doc/m4.texinfo (Improved forloop): Document advantage of $0.
(Improved foreach): Adjust dump from file.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-16 14:50:13 -07:00
Eric Blake
5d083e4726 Stage 15: return argv refs back to collect_arguments.
* m4/m4private.h (CHAR_ARGV): New input engine sentinel.
(enum m4__token_type): Add M4_TOKEN_ARGV.
(struct m4__symbol_chain): Add skip_last member to argv link.
(m4__next_token): Add parameter.
* m4/input.c (peek_char, file_peek, builtin_peek, string_peek)
(composite_peek, m4__next_token): Add new parameter.
(composite_read, append_quote_token): Support argv in quotes.
(init_argv_symbol): New function.
(m4__push_symbol, match_input, consume_syntax)
(m4__next_token_is_open, m4_print_token): Adjust callers.
* m4/macro.c (m4_macro_expand_input, m4__arg_adjust_refcount)
(arg_mark, m4_arg_text, make_argv_ref): Likewise.
(expand_argument, collect_arguments): Handle new token.
(arg_symbol): Drill through $@ reference.
* m4/syntax.c (set_quote_age): Detect disabled comments.
* m4/symtab.c (dump_symbol_CB) [DEBUG_SYM]: Fix debug code.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-16 05:27:14 -07:00
Eric Blake
7f0b47b96e * modules/gnu.c (regexp_compile): Use a fastmap for regex speed.
Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-15 16:46:50 -07:00
Eric Blake
e3dce8bbfd Fix texinfo grammar.
* doc/m4.texinfo (Eval, Incompatibilities): Use @. after capital.
(History): Use @: after abbreviations.
(M4exit): Use correct Latin abbreviation.
(Dumpdef, Debugmode, Frozen file format 2): Use correct spacing
between sentences.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-13 20:38:42 -07:00
Eric Blake
4af40c4d6f Allow builtin text macros to specify number of arguments.
* m4/m4module.h (struct m4_macro): Add argument limits to builtin
text macros.
* m4/module.c (install_macro_table): Allow text macros to warn on
extra arguments.
* modules/gnu.c (m4_macro_table): Update all clients.
* modules/load.c (m4_macro_table): Likewise.
* modules/mpeval.c (m4_macro_table): Likewise.
* modules/perl.c (m4_macro_table): Likewise.
* modules/shadow.c (m4_macro_table): Likewise.
* modules/traditional.c (m4_macro_table): Likewise.
* modules/modtest.c (m4_macro_table): Likewise.  Also add text
macros, for testing this.
* doc/m4.texinfo (Standard Modules): Update text, and enhance
test.
* tests/modules.at (modules: text): New test.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-11 13:33:08 -07:00