summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Factor load functionality into include builtin.include-dsoGary V. Vaughan2008-05-0615-327/+399
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Stage 22: allow builtin token concatenation outside $@.Eric Blake2008-05-0510-152/+207
| | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Document define_blind.Eric Blake2008-05-033-0/+65
| | | | | | | | * doc/m4.texinfo (Ifelse): Add a new composite macro. * THANKS: Update. Suggested by Mike R. Signed-off-by: Eric Blake <ebb9@byu.net>
* Avoid -Wshadow compiler warnings.Eric Blake2008-05-015-84/+93
| | | | | | | | | | | | * 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>
* Improve debugmode testing, based on recent branch-1.6 regressions.Eric Blake2008-05-013-11/+56
| | | | | | | | * 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>
* Fix regression in define from 2008-02-22.Eric Blake2008-05-016-20/+49
| | | | | | | | | | | * 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>
* Simplify previous patch.Eric Blake2008-04-212-5/+5
| | | | | | | * tests/m4.in: Compress assignment. Suggested by Gary V. Vaughan. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix --disable-shared testsuite regression from previous patch.Eric Blake2008-04-212-4/+13
| | | | | | | * tests/m4.in: Export M4MODPATH, so that recursive m4 invocations will also work. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix spelling of attribution to Christopher Strachey.Eric Blake2008-04-213-2/+10
| | | | | | | | | * 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)
* Fix testsuite bug when SIGPIPE is ignored.Eric Blake2008-04-175-3/+19
| | | | | | | | | | | | * 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>
* Fix 'make installcheck' after './configure --prefix-progname'.Eric Blake2008-04-157-15/+92
| | | | | | | | | | | | | | | | | * 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>
* Update prerequisite tools to match recent releases.Eric Blake2008-04-155-10/+16
| | | | | | | | | * 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>
* Work around OS/2 limitation of printf(1).Eric Blake2008-04-153-0/+7
| | | | | | | | * 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>
* Stage 21b: $@ concatenates builtins, m4wrap takes builtins.Eric Blake2008-04-1410-244/+276
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Stage 21a: Optimize checks for end of input.Eric Blake2008-04-142-58/+101
| | | | | | | | | | | | | * 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>
* Improve OS/2 detection.Eric Blake2008-04-144-5/+18
| | | | | | | | | | | | * 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>
* Ensure __m4_version__ is unquoted.Eric Blake2008-04-142-1/+12
| | | | | | * tests/builtins.at (__m4_@&t@version__): Augment test. Signed-off-by: Eric Blake <ebb9@byu.net>
* Avoid GNU make failure on tarball.Eric Blake2008-04-142-1/+6
| | | | | | * Makefile.am (EXTRA_DIST): Distribute cfg.mk and maint.mk. Signed-off-by: Eric Blake <ebb9@byu.net>
* Allow back-referenced macro names; fixes 2008-03-13 regression.Eric Blake2008-04-105-23/+53
| | | | | | | | | | * 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>
* Be namespace clean for M4 version; fixes 2008-04-08 regression.Eric Blake2008-04-102-4/+12
| | | | | | | * configure.ac (version): Rename... (M4_VERSION): ...to this, since using 'version' broke po.m4. Signed-off-by: Eric Blake <ebb9@byu.net>
* Mention 1.4.11 release.Eric Blake2008-04-094-28/+83
| | | | | | | | | | * 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>
* Overhaul inter-version releases to work with git.Eric Blake2008-04-0811-98/+46
| | | | | | | | | | | | | | | | | | | | | * 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>
* Use GNUmakefile module.Eric Blake2008-03-286-37/+65
| | | | | | | | * 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>
* Stage 20b: make m4wrap obey POSIX fifo ordering.Eric Blake2008-03-189-55/+193
| | | | | | | | | | | | | | | | | | | * 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>
* Stage 20a: reduce unget's in input engine.Eric Blake2008-03-172-50/+79
| | | | | | | | | | | | * 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>
* Update for fresh bootstrap.Eric Blake2008-03-172-2/+7
| | | | | | * ltdl/m4/gnulib-cache.m4: Updated copyright from upstream. Signed-off-by: Eric Blake <ebb9@byu.net>
* Document join, in order to fix bug in m4wrap example.Eric Blake2008-03-155-1/+321
| | | | | | | | | | | | | * 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>
* Stage 19c: allow builtin tokens in more macros.Eric Blake2008-03-1312-139/+454
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Stage 19b: invert sense of bit for handling builtin tokens.Eric Blake2008-03-1318-117/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Stage 19a: sort and cache builtins loaded by a module.Eric Blake2008-03-138-134/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Consistently cast malloc results, for C++ compilation.Eric Blake2008-03-1312-45/+65
| | | | | | | | | | | | | | | | | | * 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>
* Fix nested builtin(`shift',$@) regression from 2008-02-23.Eric Blake2008-03-064-3/+41
| | | | | | | | | | * 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>
* The gnulib module free was deprecated.Eric Blake2008-03-042-2/+7
| | | | | | * ltdl/m4/gnulib-cache.m4: Remove free module. Signed-off-by: Eric Blake <ebb9@byu.net>
* Import news from 1.4.10b.Eric Blake2008-02-292-19/+78
| | | | | | * NEWS: Update from branch. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 18: try harder to reuse argv in recursion.Eric Blake2008-02-224-48/+117
| | | | | | | | | | | * 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>
* Update NEWS.Eric Blake2008-02-222-2/+12
| | | | | | * NEWS: Document change to __gnu__ on 2008-02-11. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 17: pass argv through quoted strings.Eric Blake2008-02-226-61/+183
| | | | | | | | | | | | | | | | | | | | * 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>
* Fix regression in argument collection, from 2008-01-21.Gary V. Vaughan2008-02-222-0/+17
| | | | | | | * 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.
* Stage 16: cache quotes and improve m4_arg_print.Eric Blake2008-02-2012-146/+287
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Revert accidental checkin from previous patch.Eric Blake2008-02-201-2/+1
| | | | Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix out-of-bounds read for sanitized macro names, from 2008-02-06.Eric Blake2008-02-203-1/+7
| | | | | | | * m4/utility.c (m4_verror_at_line): Properly terminate the string. Reported by Ralf Wildenhues. Signed-off-by: Eric Blake <ebb9@byu.net>
* * doc/m4.texinfo (Debuglen, Changesyntax): Fix typos.Eric Blake2008-02-202-3/+7
| | | | Signed-off-by: Eric Blake <ebb9@byu.net>
* Clean up example on filtering defined symbols.Eric Blake2008-02-192-27/+59
| | | | | | | | * 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>
* * src/main.c (usage): Fix typo.Eric Blake2008-02-192-1/+5
| | | | Signed-off-by: Eric Blake <ebb9@byu.net>
* Avoid some magic numbers.Eric Blake2008-02-186-23/+37
| | | | | | | | | | | | | | | * 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>
* Add regression test for multi-character quote recursion.Eric Blake2008-02-167-10/+61
| | | | | | | | | | | | * 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>
* Stage 15: return argv refs back to collect_arguments.Eric Blake2008-02-166-89/+277
| | | | | | | | | | | | | | | | | | | | | * 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>
* * modules/gnu.c (regexp_compile): Use a fastmap for regex speed.Eric Blake2008-02-152-0/+6
| | | | Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix texinfo grammar.Eric Blake2008-02-132-8/+17
| | | | | | | | | | * 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>
* Allow builtin text macros to specify number of arguments.Eric Blake2008-02-1112-39/+129
| | | | | | | | | | | | | | | | | | | | * 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>