summaryrefslogtreecommitdiff
path: root/modules/m4.c
Commit message (Collapse)AuthorAgeFilesLines
* Add debugmode(o) to control dumpdef output location.Eric Blake2008-12-231-1/+5
| | | | | | | | | | | | | | | | | * m4/m4module.h (M4_DEBUG_TRACE_OUTPUT_DUMPDEF): New enumerator. (M4_DEBUG_TRACE_VERBOSE): Update. * m4/debug.c (m4_debug_decode): Support new debug option. * src/freeze.c (produce_debugmode_state): Likewise. * modules/m4.c (dumpdef): When set, force dumpdef to stderr rather than the debug file. * src/main.c (usage): Document it. * doc/m4.texinfo (Debugmode, Dumpdef, Debugging options) (Debugfile): Likewise. * NEWS: Likewise. Based on an autoconf bug report by Paolo Bonzini. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit df6bfeeaac6bdc1ef8e5406c6ac051af2c10d0d8)
* Stage 27: Allow embedded NUL in text processing macros.Eric Blake2008-12-021-17/+40
| | | | | | | | | | | | | | | | | | | | | | | | * modules/m4.c (m4_expand_ranges): Don't append extra bytes. (translit): Manage NUL bytes. * modules/format.c (format): Likewise. * modules/gnu.c (substitute, regexp_substitute): Likewise. (m4_resyntax_encode_safe): Add parameter. (regexp, patsubst, renamesyms): Update callers. (regexp_compile): Adjust error message. * modules/evalparse.c (m4_evaluate): Use consistent message. (end_text): New variable. (eval_init_lex): Add parameter. (eval_lex): Detect embedded NUL. * src/freeze.c (reload_frozen_state): Likewise. * doc/m4.texinfo (Format): Update to cover new behavior. (Eval): Mention that result is unquoted. * tests/freeze.at (reloading nul): Enhance test. * tests/null.m4: Likewise. * tests/null.err: Update expected output. * tests/null.out: Likewise. * tests/options.at (--regexp-syntax): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Tweak error message on command line failure.Eric Blake2008-09-251-5/+7
| | | | | | | | | | | | | | | | | | * m4/m4private.h (includes): Use "quotearg.h". * src/main.c (process_file, main): Use nicer quotes for file name in error messages. * m4/input.c (file_clean, m4_push_file): Likewise. * m4/module.c (m4__module_open): Likewise. * src/freeze.c (produce_frozen_state, reload_frozen_state): Likewise. * modules/gnu.c (debugfile): Likewise. * modules/m4.c (undivert, include): Likewise. * tests/others.at (directory, stdin closed): Update tests. * tests/options.at (file names, --debugmode): Likewise. * doc/m4.texinfo (Debugmode): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 5116db0fcd37e4480062b4819dca17a98a7890d7)
* Typos in source code comments.Ralf Wildenhues2008-09-011-4/+5
| | | | | | | | * modules/m4.c: Fix typos in comments. * m4/input.c: Likewise. * src/main.c: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Revert speed regression from 2008-06-16.Eric Blake2008-06-191-3/+7
| | | | | | | | | | | | | * m4/output.c (m4_shipout_int): Avoid obstack_printf in hot path. * modules/m4.c (numb_obstack): Likewise. * m4/input.c (MATCH): Use fewer conditionals, and factor adjustment of S... (match_input): ...here for smaller code size. * m4/syntax.c (m4_reset_syntax, m4_set_quotes, m4_set_comment): Supply trailing NUL to delimiters, to meet contract of faster MATCH. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 25b: Handle embedded NUL in changesyntax and friends.Eric Blake2008-06-181-21/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_set_quotes, m4_set_comment, m4_set_syntax): Add parameter. (m4_reset_syntax): New prototype. * m4/syntax.c (add_syntax_set, subtract_syntax_set) (set_syntax_set, m4_set_quotes, m4_set_comment): Add parameter, to handle embedded NUL. (m4_set_syntax): Likewise. Also, split code to reset the table... (m4_reset_syntax): ...into a new function. (m4_syntax_create): Adjust callers. * m4/input.c (match_input, MATCH): Add parameter. (m4__next_token, m4__next_token_is_open): Adjust callers. * modules/m4.h (m4_expand_ranges_func): Add parameter. * modules/m4.c (dumpdef): Handle NUL in dumped quotes. (changequote, changecom, translit, m4_expand_ranges): Track delimiter length. * modules/gnu.c (changesyntax): Handle embedded NUL. * src/freeze.c (reload_frozen_state): Adjust callers. * tests/freeze.at (reloading nul): Enhance test. * tests/null.m4: Likewise. * tests/null.out: Update expected output. * tests/null.err: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 25a: Use obstack_printf for easier output.Eric Blake2008-06-161-25/+28
| | | | | | | | | | | | | | * ltdl/m4/gnulib-cache.m4: Import obstack-printf-posix module. * m4/macro.c (trace_format): Delete; use obstack_printf instead. (trace_header, trace_pre, trace_post): All callers updated. * m4/output.c (m4_shipout_int, m4_tmpname): Use obstack_printf. (m4_divert_text): Speed up syncline output. * modules/m4.c (dumpdef): Handle embedded NUL. (numb_obstack): Speed up eval output. (maketemp): Use obstack_printf. * modules/format.c (format): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Add missing const qualifications.Eric Blake2008-06-161-1/+1
| | | | | | | | | | | | | | | | | | * m4/resyntax.c (m4_resyntax_map): Declare array elements as const. * modules/gnu.c (m4_builtin_table, m4_macro_table): Likewise. * modules/import.c (m4_builtin_table): Likewise. * modules/load.c (m4_builtin_table, m4_macro_table): Likewise. * modules/m4.c (m4_builtin_table): Likewise. * modules/modtest.c (m4_builtin_table, m4_macro_table): Likewise. * modules/mpeval.c (m4_builtin_table, m4_macro_table): Likewise. * modules/perl.c (m4_builtin_table, m4_macro_table): Likewise. * modules/shadow.c (m4_builtin_table, m4_macro_table): Likewise. * modules/stdlib.c (m4_builtin_table): Likewise. * modules/time.c (m4_builtin_table): Likewise. * modules/traditional.c (m4_macro_table): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 24b: Allow embedded NUL in macro names.Eric Blake2008-06-021-26/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_symtab_apply_func, m4_symbol_lookup) (m4_symbol_pushdef, m4_symbol_define, m4_symbol_popdef) (m4_symbol_rename, m4_symbol_delete): Add length parameter. (m4_string): New type. * ltdl/m4/gnulib-cache.m4: Import xmemdup0 module. * m4/hash.c (m4_hash_string_hash, m4_hash_string_cmp): Account for length. * m4/symtab.c (m4_symtab_delete, m4_symtab_apply, symtab_fetch) (m4__symtab_remove_module_references, symbol_destroy_CB) (m4_symbol_lookup, m4_symbol_pushdef, m4_symbol_define) (m4_symbol_popdef, m4_symbol_rename, m4_set_symbol_name_traced) (m4_symbol_delete): Likewise. * modules/m4.h (struct m4_dump_symbol_data): Adjust type to allow passing length. * m4/macro.c (expand_token): Adjust all callers. * m4/module.c (install_builtin_table, install_macro_table): Likewise. * m4/utility.c (m4_symbol_value_lookup): Likewise. * modules/gnu.c (indir, renamesyms, m4symbols): Likewise. * modules/m4.c (define, undefine, pushdef, popdef) (dumpdef_cmp_CB, dump_symbol_CB, m4_dump_symbols, dumpdef) (traceon, traceoff): Likewise. * src/main.c (main): Likewise. * src/freeze.c (dump_symbol_CB, reload_frozen_state): Likewise. * tests/freeze.at (reloading nul): Augment test. * tests/null.out: Adjust expected output. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 24a: Use full call context in error reporting.Eric Blake2008-06-021-43/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_error, m4_warn): Change parameter type. (m4_error_at_line, m4_warn_at_line): Delete. (m4_debug_set_output, m4_skip_line, m4_bad_argc, m4_numeric_arg) (m4_parse_truth_arg, m4_symbol_value_lookup): Adjust all clients. * m4/m4private.h (m4__next_token): Likewise. * m4/utility.c (m4_verror_at_line): Alter parameter, and use caller's location if caller is provided. (m4_error, m4_warn): Change parameter type. (m4_error_at_line, m4_warn_at_line): Delete. (m4_bad_argc, m4_numeric_arg, m4_parse_truth_arg) (m4_symbol_value_lookup): Adjust all callers. * m4/debug.c (set_debug_file, m4_debug_set_output): Likewise. * m4/input.c (m4_skip_line, m4__next_token): Likewise. * m4/macro.c (expand_argument, collect_arguments, m4_macro_call) (process_macro): Likewise. * modules/m4.h (m4_make_temp_func): Likewise. * modules/evalparse.c (m4_evaluate): Likewise. * modules/format.c (arg_int, arg_long, arg_double, format): Likewise. * modules/gnu.c (builtin, changeresyntax, changesyntax, debugfile) (debuglen, debugmode, esyscmd, indir, mkdtemp, patsubst, regexp) (renamesyms, syncoutput, regexp_compile, substitute) (regexp_substitute, m4_resyntax_encode_safe): Likewise. * modules/m4.c (define, undefine, pushdef, popdef, ifdef, ifelse) (m4_dump_symbols, defn, syscmd, incr, decr, divert, undivert, dnl) (include, maketemp, mkstemp, m4exit, traceon, traceoff, substr): Likewise. * modules/stdlib.c (setenv, getpwuid, srand): Likewise. * modules/time.c (ctime, gmtime, localtime, mktime, strftime): Likewise. * tests/options.at (--syncoutput): Add test for invalid command-line argument. Split xfailed portion... (--syncoutput and diversions): ...into new test. (unknown option): New test. * tests/freeze.at (reloading unknown builtin): Update expected output. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 22: allow builtin token concatenation outside $@.Eric Blake2008-05-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Avoid -Wshadow compiler warnings.Eric Blake2008-05-011-6/+6
| | | | | | | | | | | | * 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>
* Fix regression in define from 2008-02-22.Eric Blake2008-05-011-2/+2
| | | | | | | | | | | * 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>
* Stage 21b: $@ concatenates builtins, m4wrap takes builtins.Eric Blake2008-04-141-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Allow back-referenced macro names; fixes 2008-03-13 regression.Eric Blake2008-04-101-18/+8
| | | | | | | | | | * 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>
* Stage 20b: make m4wrap obey POSIX fifo ordering.Eric Blake2008-03-181-7/+1
| | | | | | | | | | | | | | | | | | | * 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 19c: allow builtin tokens in more macros.Eric Blake2008-03-131-37/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-131-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 17: pass argv through quoted strings.Eric Blake2008-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | * 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>
* Stage 16: cache quotes and improve m4_arg_print.Eric Blake2008-02-201-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Avoid some magic numbers.Eric Blake2008-02-181-2/+2
| | | | | | | | | | | | | | | * 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>
* Consistently use size_t for number of arguments.Eric Blake2008-02-021-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_builtin_func): Alter prototype. (struct m4_builtin): Adjust type of min_args, max_args. (M4BUILTIN, M4BUILTIN_HANDLER): Adjust all builtins. (m4_bad_argc, m4_dump_args, m4_macro_call, m4_arg_argc) (m4_arg_symbol, m4_is_arg_text, m4_is_arg_func, m4_arg_text) (m4_arg_equal, m4_arg_empty, m4_arg_len, m4_arg_func) (m4_arg_print, m4_push_arg): Adjust all clients. * m4/m4private.h (struct m4__symbol_chain, m4_symbol_value) (m4_macro_args): Adjust type of various fields. (m4__push_arg_quote): Adjust all clients. * m4/input.c (m4_pop_wrapup): Likewise. * m4/macro.c (m4_macro_call, trace_pre, make_argv_ref) (arg_symbol, m4_arg_symbol, m4_is_arg_text, m4_is_arg_func) (m4_arg_text, m4_arg_equal, m4_arg_empty, m4_arg_len) (m4_arg_func, m4_arg_print, m4_make_argv_ref, m4_push_arg) (m4__push_arg_quote, m4_push_args, m4_arg_argc): Likewise. * m4/utility.c (m4_bad_argc, m4_dump_args): Likewise. * modules/evalparse.c (m4_evaluate): Likewise. * modules/gnu.c (changesyntax): Likewise. * modules/m4.c (m4_dump_symbols, undefine, popdef, ifelse, defn) (undivert, traceon, traceoff): Likewise. * modules/m4.h (m4_dump_symbols_func): Likewise. * modules/perl.c (perleval): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 12c: add macro for m4_arg_len.Eric Blake2008-01-261-13/+10
| | | | | | | | | | | | | * m4/m4module.h (M4ARGLEN): New macro. * m4/macro.c (process_macro): Adjust all callers. * m4/utility.c (m4_dump_args): Likewise. * modules/m4.c (divert, maketemp, mkstemp, m4wrap, len, index) (substr): Likewise. * modules/gnu.c (builtin, indir, mkdtemp, patsubst, regexp) (renamesyms): Likewise. * modules/stdlib.c (setenv): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 12b: add m4_string_pair.Eric Blake2008-01-251-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_string_pair): New type. (m4_get_syntax_quotes, m4_get_syntax_comments): New prototypes. (m4_symbol_value_print, m4_symbol_print, m4_shipout_string_trunc): Alter signature. * m4/m4private.h (struct m4_string): Delete. (struct m4_syntax_table): Combine quote and comment members. (m4_get_syntax_lquote, m4_get_syntax_rquote, m4_get_syntax_bcomm) (m4_get_syntax_ecomm): Adjust accessors. (m4_get_syntax_quotes, m4_get_syntax_comments): New fast accessors. * m4/symtab.c (m4_symbol_value_print, m4_symbol_print): Alter signatures. * m4/input.c (string_print, composite_print, m4_input_print): All callers updated. * m4/syntax.c (m4_syntax_delete, m4_set_syntax) (check_is_single_quotes, m4_set_quotes, set_quote_age) (m4_get_syntax_lquote, m4_get_syntax_rquote) (m4_get_syntax_quotes, check_is_single_comments, m4_set_comment) (m4_get_syntax_bcomm, m4_get_syntax_ecomm) (m4_get_syntax_comments): Likewise. * m4/macro.c (trace_prepre, trace_pre, m4_push_args): Likewise. * m4/output.c (m4_shipout_string, m4_shipout_string_trunc): Likewise. * modules/m4.c (dumpdef, m4_make_temp): Likewise. * src/freeze.c (produce_frozen_state): Likewise. * tests/freeze.at (reloading unknown builtin): Update test. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 10: avoid extra copying of strings and comments.Eric Blake2008-01-161-4/+5
| | | | | | | | | | | | | | | | | | | | | * ltdl/m4/gnulib-cache.m4: Import intprops and vasnprintf-posix modules. * m4/m4private.h (m4__token_type): Adjust prototype. * m4/input.c (m4__next_token): Support new parameter. * m4/macro.c (m4_macro_expand_input, expand_token) (expand_argument, collect_arguments): Adjust callers. * modules/m4.c (ntoa): Tighten buffer size. * m4/output.c (m4_tmpname): Guarantee no buffer overflow. * modules/format.c (arg_int, arg_long, arg_double): New helper functions, to detect overflow or unparsed characters. (ARG_INT, ARG_LONG, ARG_STR, ARG_DOUBLE): Adjust to check for missing or excess arguments. (format): Likewise, and also output directly into obstack if there is room. * doc/m4.texinfo (History): Update for new year. (Format): Test for new warnings. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 9: share rather than copy single-arg refs.Eric Blake2007-12-201-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ltdl/m4/gnulib-cache.m4: Import memmem and quote modules. * m4/m4module.h (m4_arg_scratch): New prototype. * m4/m4private.h (m4__push_symbol): Add parameter. (m4_arg_scratch): Add fast accessor. (struct m4): Add expansion_level member, taken... * m4/macro.c (expansion_level): ...from here. Adjust all users. (expand_argument): Minor cleanup. (expand_macro): Track scratch space per macro call. (m4_arg_scratch): New function. (m4_make_argv_ref): Call new function. (m4_push_arg): Push reference to $0. (m4_push_args): Rework separator usage, since separators will usually be inlined. (process_macro): Allow embedded NUL. * m4/input.c (INPUT_INLINE_THRESHOLD): New define. (m4__push_symbol): Add parameter. Inline short strings, and save references through rescanning. * m4/symtab.c (m4_set_symbol_value_text): Weaken assertion. * modules/m4.c (errprint, index): Handle NUL transparently. (dumpdef, translit): Use scratch space, rather than expansion stack. * modules/gnu.c (renamesyms, m4symbols): Likewise. * tests/others.at (nul character): New test. (iso8859): Quote absolute file name, remove XFAIL. * tests/iso8859.m4: Avoid raw NUL in output. * tests/null.m4: New file. * tests/null.out: Likewise. * tests/null.err: Likewise. * Makefile.am (OTHER_FILES): Distribute new files. * .gitattributes: Treat new files as text. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 6: convert builtins to push arg at a time.Eric Blake2007-12-081-11/+16
| | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_shipout_text): Rename... (m4_divert_text): ...to this, to avoid confusion with m4_shipout_* that does not worry about sync lines. (m4_shipout_string_trunc): New prototype. * m4/output.c (m4_shipout_text): Rename... (m4_divert_text): ...to this. (m4_shipout_string): Move guts... (m4_shipout_string_trunc): ...to this new function. * m4/macro.c (m4_push_arg, m4_push_args): New functions. (expand_token, process_macro): Update callers. * m4/input.c (string_print): Likewise. * modules/m4.c (ifdef, ifelse, shift, substr, translit, divert): Likewise. * modules/gnu.c (patsubst): Likewise. (debuglen): Use SIZE_MAX for unlimited debug length. * src/main.c (main): Likewise. * m4/m4.c (m4_create): Default max_debug_length to SIZE_MAX, not zero. Signed-off-by: Eric Blake <ebb9@byu.net>
* Minor security fix: Quote output of mkstemp.Eric Blake2007-12-071-19/+28
| | | | | | | | * modules/m4.c (m4_make_temp): Produce quoted output. * doc/m4.texinfo (Mkstemp, Mkdtemp): Update the documentation and tests. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 5: add notion of quote age.Eric Blake2007-12-071-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_get_symbol_value_quote_age): New prototype. (m4_set_symbol_value_text): Adjust prototype. (m4_has_syntax): Factor out the unsigned char cast. * m4/m4private.h (struct m4_syntax_table): Add syntax_age and quote_age members. (m4__quote_age, m4__safe_quotes): New accessor macros, no need for functions at this point. (struct m4_symbol_value, struct m4_macro_args): Add quote_age member. (m4_set_symbol_value_text): Adjust fast accessor. (m4_get_symbol_value_quote_age): New fast accessor. * m4/symtab.c (m4_set_symbol_value_text): Add parameter. (m4_get_symbol_value_quote_age): New function. (m4_symbol_value_copy): Adjust callers. * m4/macro.c (expand_token): Add parameter, and track quote age. (expand_argument, collect_arguments): Track quote age. (m4_macro_expand_input, process_macro, m4_make_argv_ref) (m4_macro_expand_input): Update callers. (m4_arg_text, m4_arg_len, m4_arg_func): Abort on type mismatch. * m4/input.c: Comment cleanups. (struct m4_input_block): Reduce size. (m4__next_token): Report quote age. (m4_push_builtin, init_builtin_token): Update callers. * m4/utility.c (skip_space): Adjust callers. * m4/module.c (install_macro_table): Likewise. * m4/syntax.c (m4_set_syntax): Initialize and update quote age. (m4_set_quotes, m4_set_comment): Detect no-op changes, and update quote age. (set_quote_age): New helper function. (check_is_single_quotes, check_is_single_comments): Adjust callers. * src/freeze.c (reload_frozen_state): Likewise. * src/main.c (main): Likewise. * modules/m4.c (define, pushdef): No need to set macro text. * tests/builtins.at (changequote, defn): New tests. * examples/wrapfifo.m4: New file. * examples/wraplifo.m4: New file. * Makefile.am (dist_pkgdata_DATA): Distribute new examples. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 4: route indir, builtin through ref; make argv opaque.Eric Blake2007-11-291-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/system_.h (obstack_regrow): Fix precedence. * m4/m4module.h (m4_arg_equal, m4_arg_empty, m4_make_argv_ref): New prototypes. (struct m4_macro_args): Move... * m4/m4private.h (struct m4_macro_args): ...here, making it opaque to modules. Add has_ref member. (bool_bitfield): New helper typedef. (struct m4_symbol_chain): Add flatten and len members. * m4/macro.c (empty_symbol): New placeholder, for optimizing comparison with empty string. (m4_macro_expand_input): Initialize it. (collect_arguments): Alter signature, and populate new fields. (trace_pre, trace_post): Remove redundant parameter. (expand_macro): Alter handling of obstacks. (m4_arg_symbol): Account for wrapped argv. (m4_arg_equal, m4_arg_empty, m4_make_argv_ref): New methods. (m4_arg_text, m4_arg_len, m4_arg_func): Use new methods. * modules/m4.c (ifelse, syscmd): Likewise. * modules/evalparse.c (m4_evaluate): Likewise. (undefine, popdef, m4_dump_symbols): Optimize. * modules/gnu.c (builtin, indir, esyscmd, debugfile): Use new methods. (changesyntax, regexp): Optimize. * m4/output.c (diversion_storage): Use typedef. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 3b: cache length, rather than computing it, in modules.Eric Blake2007-11-291-53/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/hash.c (m4_hash_remove): Avoid double free on remove failure. * m4/output.c (m4_shipout_string): Change semantics of len param. (m4_shipout_int): Use cached length. * m4/input.c (m4_push_string_finish): Likewise. * modules/m4.h (m4_make_temp_func): Add parameter. * m4/macro.c (expand_token, m4_arg_len): Use cached length. (collect_arguments, expand_macro): Alter signature. (trace_format): Don't use out-of-scope buffer. (process_macro): All callers changed. * m4/utility.c (m4_dump_args): Likewise. * m4/symtab.c (m4_symbol_value_print): Likewise. * modules/gnu.c (__file__, __program__, builtin, indir) (m4symbols, mkdtemp, regexp_compile, regexp_substitute, renamesyms, patsubst, regexp, regexp_compile): Likewise. * modules/load.c (m4modules): Likewise. * modules/m4.c (defn, m4wrap, maketemp, m4_make_temp) (numb_obstack, ifdef, ifelse, divert, len, substr): Likewise. * modules/perl.c (perleval): Likewise. * modules/stdlib.c (getcwd, getenv, getlogin, getpwnam, getpwuid) (hostname, uname, setenv): Likewise. * modules/mpeval.c (numb_obstack): Likewise. * src/freeze.c (dump_symbol_CB): Likewise. * doc/m4.texinfo (Renamesyms, Dumpdef, Changesyntax): Adjust test. * tests/builtins.at (mkstemp): Likewise. * tests/others.at (iso8859): XFAIL this test, now that length-based handling allows NUL through part but not all of M4. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 3a: cache length, rather than computing it, in libm4.Eric Blake2007-11-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (struct m4_macro_args): Cache length. (m4_get_symbol_len, m4_get_symbol_value_len): New accessors. (m4_set_symbol_value_text): Change signature. * m4/m4private.h (struct m4_symbol_value): Store string length. (m4_get_symbol_value_text, m4_get_symbol_value_placeholder) (m4_set_symbol_value_placeholder): Update accordingly. (m4_set_symbol_value_text): Change signature. (m4_get_symbol_value_len): New accessor. * m4/input.c (struct m4_input_block, string_peek, string_read) (string_unget, string_print, m4_push_string_finish) (m4_push_wrapup): Track length of string input. (m4__next_token): Adjust all users of symbol text to track length, too. * m4/macro.c (expand_argument, collect_arguments): Likewise. * m4/module.c (install_macro_table): Likewise. * modules/gnu.c (builtin, indir): Likewise. * modules/m4.c (define, pushdef): Likewise. * src/main.c (main): Likewise. * src/freeze.c (reload_frozen_state): Likewise. * m4/symtab.c (m4_symbol_value_copy): Likewise. (m4_get_symbol_value_len): New function. (m4_get_symbol_value_text, m4_get_symbol_value_placeholder) (m4_set_symbol_value_text, m4_set_symbol_value_placeholder): Adjust implementation. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 2: use accessors, not direct reference, into argv.Eric Blake2007-11-271-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4private.h (m4_arg_argc): New fast accessor. * m4/m4module.h (m4_arg_argc, m4_arg_symbol, m4_is_arg_text) (m4_is_arg_func, m4_arg_text, m4_arg_len, m4_arg_func): New prototypes. (m4_builtin_func, M4BUILTIN, M4BUILTIN_HANDLER, m4_dump_args) (m4_macro_call): Make argc unsigned. (M4ARG): Use new accessors. * modules/m4.c (define, pushdef): Likewise. (undefine, popdef, ifelse, m4_dump_symbols, defn, undivert) (traceon, traceoff): Make argc unsigned. * modules/m4.h (m4_dump_symbols_func): Likewise. * modules/evalparse.c (m4_evaluate): Likewise. * modules/gnu.c (builtin, indir): Use new accessors. (changesyntax): Make argc unsigned. * modules/perl.c (perleval): Likewise. * m4/utility.c (m4_dump_args): Use new accessors. * m4/macro.c (trace_pre): Likewise. (m4_arg_symbol, m4_arg_argc, m4_is_arg_text, m4_is_arg_func) (m4_arg_text, m4_arg_len, m4_arg_func): New functions. (expand_macro, trace_pre, trace_post, m4_macro_call): Update argc usage. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 1: convert m4_symbol_value** into new object.Eric Blake2007-11-241-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | * ltdl/m4/gnulib-cache.m4: Import flexmember module. * m4/m4module.h (m4_macro_args): New type, will be opaque to modules later. (m4_builtin_func, M4BUILTIN, M4BUILTIN_HANDLER, m4_dump_args) (m4_macro_call): Alter signature to use m4_macro_args object. (M4ARG): Redefine to access new struct. * m4/m4private.h (M4_SYMBOL_COMP): New enumerator. (struct m4_symbol_chain): New type. (struct m4_symbol_value): Add chain alternative. * m4/macro.c (collect_arguments): Build new struct. (expand_macro, m4_macro_call, process_macro, trace_pre) (trace_post): Adjust implementation to use it. * m4/utility.c (m4_dump_args): Likewise. * modules/gnu.c (builtin, indir): Likewise. * modules/format.c (format): Likewise. * modules/m4.h (m4_dump_symbols_func): Likewise. * modules/m4.c (m4_dump_symbols, define, pushdef, defn, ifelse) (shift, include, errprint, m4wrap): Likewise. * modules/evalparse.c (m4_evaluate): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Pass only macro name to utility functions.Eric Blake2007-11-241-12/+15
| | | | | | | | | | | | | | | | * m4/m4module.h (m4_bad_argc, m4_numeric_arg): Adjust signature. * m4/utility.c (m4_bad_argc, m4_numeric_arg): Adjust implementation. * m4/macro.c (m4_macro_call): Adjust callers. * modules/gnu.c (builtin, debuglen): Likewise. * modules/m4.c (ifelse, incr, decr, divert, undivert, m4exit) (substr): Likewise. * modules/evalparse.c (m4_evaluate): Likewise. * modules/stdlib.c (setenv, getpwuid, srand): Likewise. * modules/time.c (ctime, gmtime, localtime, mktime, strftime): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Add macro name to debugfile messages.Eric Blake2007-11-231-3/+3
| | | | | | | | | | | * m4/m4module.h (m4_debug_set_output): Add parameter. * m4/debug.c (m4_debug_set_output, set_debug_file): Pass macro name through. * modules/gnu.c (debugfile): Adjust caller. * modules/m4.c (m4exit): Likewise. * src/main.c (main): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Factor out handling of macro name in error messages.Eric Blake2007-11-231-26/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_error, m4_error_at_line, m4_warn) (m4_warn_at_line): Add new parameter. * m4/utility.c (m4_verror_at_line): New helper method. (m4_error, m4_error_at_line, m4_warn, m4_warn_at_line): Add new parameter. (m4_bad_argc, m4_numeric_arg, m4_parse_truth_arg): All callers changed. * m4/debug.c: Likewise. * m4/input.c: Likewise. * m4/macro.c: Likewise. * m4/module.c: Likewise. * m4/output.c: Likewise. * m4/path.c: Likewise. * modules/evalparse.c: Likewise. * modules/format.c: Likewise. * modules/gnu.c: Likewise. * modules/load.c: Likewise. * modules/m4.c: Likewise. * modules/mpeval.c: Likewise. * src/freeze.c: Likewise. * src/main.c: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix 'm4 -F file -t undefined'.Eric Blake2007-10-181-3/+1
| | | | | | | | | | | | | * src/freeze.c (produce_symbol_dump): Skip trace placeholders. * src/freeze.c (dump_symbol_CB): Also skip void symbols. * tests/freeze.at (reloading unknown builtin): Test for this bug. * m4/m4module.h (m4_symtab_apply): Add parameter. * m4/symtab.c (m4_symtab_apply): Ignore trace placeholders when requested. (m4_symtab_delete, symtab_dump): Adjust callers. * modules/m4.c (m4_dump_symbols): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Another Autoconf usage pattern optimization.Eric Blake2007-10-061-2/+14
| | | | | | | | * modules/m4.c (m4_index): Optimize search for one byte. * doc/m4.texinfo (Index macro, Regexp, Patsubst): Test the new code paths. Signed-off-by: Eric Blake <ebb9@byu.net>
* Be consistent about using 'module' for m4_module types andGary V. Vaughan2007-10-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 'handle' for lt_dlhandle types: * m4/m4private.h (m4_symbol_value): Rename handle element to method. Changed all references. (VALUE_MODULE, SYMBOL_MODULE): Renamed from VALUE_HANDLE and SYMBOL_HANDLE respectively. Changed all references. * m4/m4module.h (M4INIT_HANDLER, M4FINISH_HANDLER): Ditto. * m4/builtin.c (m4_builtin_find_by_name) (m4_builtin_find_by_func): Use module as the parameter name for pointers of type 'm4_module'. * m4/module.c (module_remove, m4_get_module_name) (install_builtin_table, install_macro_table) (m4_module_make_resident, m4__module_next, m4_module_refcount): Ditto. * src/freeze.c (produce_module_dump): Ditto. * m4/input.c (m4_input_block): Rename handle element to method. Changed all references. * m4/symtab.c (m4__symtab_remove_module_references): Ditto. * modules/load.c: Use module as the variable name for pointers of type 'm4_module'. * modules/m4.c: Ditto. * modules/perl.c: Ditto. * modules/shadow.c: Ditto.
* Wrap lt_dlhandle in struct m4_module.Eric Blake2007-10-061-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (includes): No longer require clients to know about lt_dlhandle. (m4_module): New opaque declaration. (m4_export): Delete unused type. (M4INIT_HANDLER, M4FINISH_HANDLER, m4_module_init_func) (m4_module_finish_func, m4_module_load, m4_get_module_name) (m4_builtin_find_by_name, m4_builtin_find_by_func): Use new wrapper. (m4_module_makeresident, m4_module_refcount): New declarations. * m4/m4private.h (includes): Move <ltdl.h> here. (m4_module): New declaration. Simple for now, but intended for growth. (m4__module_open, m4__module_next, m4__module_find) (m4__symtab_remove_module_references): Use new wrapper. * m4/builtin.c (m4_builtin_find_by_name, m4_builtin_find_by_func): Likewise. * m4/module.c (m4_get_module_name, m4_module_import) (m4_module_load): Likewise. (install_builtin_table, install_macro_table): Likewise. Also, change return type since these always returned NULL and no one used the result. (m4_module_makereside
* Normalize all GPL license notices.Eric Blake2007-10-061-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/COPYING.LIB: Delete - libm4 is not distributed under LGPLv2 at this time. * Makefile.am: Update license wording. * bootstrap: Likewise. * commit: Likewise. * configure.ac: Likewise. * ltdl/config/mailnotify: Likewise. * ltdl/config/mkstamp: Likewise. * ltdl/m4/debug.m4: Likewise. * ltdl/m4/gmp.m4: Likewise. * ltdl/m4/m4-error.m4: Likewise. * ltdl/m4/m4-getopt.m4: Likewise. * ltdl/m4/m4-gettext.m4: Likewise. * ltdl/m4/m4-obstack.m4: Likewise. * ltdl/m4/m4-regex.m4: Likewise. * ltdl/m4/stackovf.m4: Likewise. * m4/builtin.c: Likewise. * m4/debug.c: Likewise. * m4/hash.c: Likewise. * m4/hash.h: Likewise. * m4/input.c: Likewise. * m4/m4.c: Likewise. * m4/m4module.h: Likewise. * m4/m4private.h: Likewise. * m4/macro.c: Likewise. * m4/module.c: Likewise. * m4/output.c: Likewise. * m4/path.c: Likewise. * m4/resyntax.c: Likewise. * m4/symtab.c: Likewise. * m4/syntax.c: Likewise. * m4/system_.h: Likewise. * m4/utility.c: Likewise. * modules/evalp
* Upgrade to GPLv3, and document 1.4.10.Eric Blake2007-10-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bootstrap: Adjust to GPLv3. (func_update): Port from branch. * ltdl/m4/gnulib-cache.m4: Augment with 'gnulib-tool --local-dir=local --import gpl-3.0'. * doc/m4.texinfo (History): Mention 1.4.11. (Copying This Package): New appendix. * NEWS: Document 1.4.10. * local/doc/gpl-3.0.texi.diff: New file. * Makefile.am: Update license. (doc_m4_TEXINFOS, EXTRA_DIST): Distribute additions. * commit: Update license. * configure.ac: Likewise. * ltdl/config/mailnotify: Likewise. * ltdl/config/mkstamp: Likewise. * ltdl/m4/debug.m4: Likewise. * ltdl/m4/gmp.m4: Likewise. * ltdl/m4/m4-error.m4: Likewise. * ltdl/m4/m4-getopt.m4: Likewise. * ltdl/m4/m4-gettext.m4: Likewise. * ltdl/m4/m4-obstack.m4: Likewise. * ltdl/m4/m4-regex.m4: Likewise. * ltdl/m4/stackovf.m4: Likewise. * m4/builtin.c: Likewise. * m4/debug.c: Likewise. * m4/hash.c: Likewise. * m4/hash.h: Likewise. * m4/input.c: Likewise. * m4/m4.c: Likewise. * m4/m4module.h: Likewise. * m4/m4private.
* Add extension to divert builtin.Eric Blake2007-10-061-1/+6
| | | | | | | | | | | | | | * modules/m4.c (builtin_divert): Immediately divert second argument. * m4/output.c (m4_output_text): Allow 0 length. Fixes regression from two days ago. (m4_shipout_text): Short-circuit on zero length. * tests/freeze.at (loading format 2): Expand test to catch regression. Also check out-of-range version. * tests/builtins.at (divert): Expand test to check corner cases of extension. * NEWS: Document the extension. Reported by Daniel Richard G.
* Provide consistent shift semantics regardless of hardware.Eric Blake2007-10-061-12/+17
| | | | | | | * modules/m4.c (numb_lshift, numb_rshift, numb_urshift): Mask before shifting. (number, unumber): Always use [u]intmax_t. Reported by Gary V. Vaughan.
* Support POSIX flush semantics on all platforms.Eric Blake2007-10-061-11/+8
| | | | | * modules/m4.c (m4_sysval_flush): Rely on gnulib. * ltdl/m4/gnulib-cache.m4: Fix typo in previous commit.
* Work around cygwin and mingw fseeko bugs.Eric Blake2007-10-061-2/+2
| | | | | | * ltdl/m4/gnulib-cache.m4: Augment with 'gnulib-tool --import fseeko'. * modules/m4.c (m4_sysval_flush): Prefer fseeko over fseek.
* * modules/m4.c (numb_ratio, numb_divide, numb_modulo): AvoidEric Blake2007-10-061-3/+7
| | | | | SIGFPE on x86 architectures. Reported by Ralf Wildenhues.
* M4 was designed to have a small number of header files definingGary V. Vaughan2007-10-061-11/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the interfaces to several source files each. Keeping this in mind allows us to tidy things up considerably. Having done this, it becomes clear that some of the installed headers reference other headers which are not installed (but that's another patch): * m4/m4private.h (stdio--.h, stdlib--.h, unistd--.h): Moved from here... * m4/system_.h (gnu/stdio--.h, gnu/stdlib--.h, gnu/unistd--.h): ...to here, so client modules can benefit too. (assert.h, errno.h, limits.h, sys/stat.h): Include one here at the lowest level to save doing it multiple times elsewhere. * m4/debug.c (stdio.h): Removed. The portable <gnu/stdio--.h> is already included via m4private.h. * modules/time.c (stdio.h): Ditto. * modules/gnu.c (stdlib.h): Ditto resp <gnu/stdlib--.h>. * modules/stdlib.c (stdlib.h, unistd.h): Ditto resp <gnu/stdlib--.h> and <gnu/unistd--.h>, * m4/m4private.h (m4module.h): Use angle brackets for an installed file. * m4/hash.h (system.h): Ditto. * modules/gnu.c (progname.h): Removed. * src/freeze.c (m4/system.h, m4private.h): Already included vi m4.h. * m4/m4private.h (assert.h, errno.h): Already included via m4/m4module.h. * m4/input.c (ctype.h): Ditto. * m4/module.c (ltdl.h): Ditto. * m4/output.c (errno.h, limits.h, stdio.h, sys/types.h, sys/stat.h) (unistd.h): Ditto. * m4/path.c (config.h, stdlib.h): Ditto. * m4/utility.c (config.h): Ditto. * modules/evalparse.c (assert.h, ctype.h): Ditto. * modules/gnu.c (assert.h, ctype.h, errno.h): Ditto. * modules/import.c (assert.h): Ditto. * modules/m4.c (assert.h, errno.h): Ditto. * modules/modtest.c (assert.h): Ditto. * modules/stdlib.c (sys/types.h): DittAo. * src/m4.h (ctype.h, errno.h, string.h, sys/types.h, ltdl.h): Ditto. * src/stackovf.c (assert.h): Ditto. * modules/gnu.c (m4/m4module.h, m4private.h): Build using the faster private interfaces when NDEBUG is defined. * modules/import.c (m4/m4module.h, m4private.h): Ditto. * modules/load.c (m4/m4module.h, m4private.h): Ditto. * modules/m4.c (m4/m4module.h, m4private.h): Ditto. * modules/modtest.c (m4/m4module.h, m4private.h): Ditto. * modules/mpeval.c (m4/m4module.h, m4private.h): Ditto. * modules/perl.c (m4/m4module.h, m4private.h): Ditto. * modules/shadow.c (m4/m4module.h, m4private.h): Ditto. * modules/time.c (m4/m4module.h, m4private.h): Ditto. * modules/traditional.c (m4/m4module.h, m4private.h): Ditto. * src/m4.h (locale.h): Moved from here... * src/main.h: ...to here. (m4private.h): Already included via m4.h. * src/stackovf.c (m4private.h): Ditto.
* POSIX XCU ERN 137 was approved.Eric Blake2007-10-061-9/+0
| | | | | | | | | | | | | | | | | | | * modules/mpeval.c (numb_extension): Delete. * modules/m4.c (numb_extension): Likewise. * modules/evalparse.c (comma_term, condition_term): Always implement ?: and , operators. * m4/symtab.c: Update comment to match reality. * src/freeze.c (produce_frozen_state, reload_frozen_state): Avoid dereferencing context directly when accessor exists. * src/main.c (usage): Prefer GNU_M4 over EMACS. (struct macro_definition): Rename... (struct deferred): ...to match usage. All uses changed. * doc/m4.texinfo (Eval): Document this change. (Operation modes, Changeresyntax): Fix wording to prefer GNU_M4 over emacs. (Preprocessor features, Changesyntax): Fix inaccuracies. * NEWS: Import branch NEWS items for 1.4.x series. Document change in eval.