(M4_BUILTIN_SIDE_EFFECT): New enumerators.
(struct m4_builtin): New member flags replaces groks_macro_args,
blind_if_no_args. min_args and max_args are now 0-based.
Rearrange members to reduce size on platforms where function
pointers are 64 bits but regular pointers are 32.
(m4_bad_argc): Add argument.
* m4/m4private.h (VALUE_SIDE_EFFECT_ARGS_BIT): New define.
* m4/utility.c (m4_bad_argc): Simplify calculation, and take side
effect into account.
* m4/module.c (install_builtin_table): Adjust all users affected
by this API change.
* m4/macro.c (m4_macro_call): Likewise.
* src/freeze.c (reload_frozen_state): Likewise.
* modules/m4.c (builtin_functions, ifelse, syscmd): Likewise.
* modules/gnu.c (builtin_functions, builtin, esyscmd): Likewise.
* modules/import.c (builtin_functions): Likewise.
* modules/load.c (builtin_functions): Likewise.
* modules/modtest.c (builtin_functions): Likewise.
* modules/mpeval.c (builtin_f
m4_syntax_table', and then add one of these to `struct m4'. The
ripple effect through the code to both change formerly global
references, and make sure a suitable context is available in
lexical scope is disproportionately large compared to the size of
the change proper. This change is a large part of decoupling
syntax.c from the rest of the code that uses it.
* m4/m4private.h (struct m4): Add a syntax field.
* m4/m4.c (m4_create): Initialise it,
(m4_delete): Recycle it.
(m4_get_symtab): Remove hand coded version...
(m4_get_symbol_table): ...and generate this with cpp. Changed all
callers.
* m4/m4module.h (m4_context_field_table): Add an extra field so we
can generate m4_get_symbol_table. Add a new row for
m4_get_syntax_table.
(M4SYNTAX): Syntactic sugar for module writers.
(m4_symtab): Renamed to m4_symbol_table. Changed all callers.
(m4_syntax_table): New home for syntax related formerly global
variables.
* m4/m4private.h (struct m4_syntax_table): Define it.
* m4/input.c (m4_input_init): Initialisation of these formerly
global variables moved...
* m4/syntax.c (m4_syntax_create): ...to here.
* m4/input.c (m4_input_exit): And similarly, recycling of the
memory used by those values moved...
* m4/syntax.c (m4_syntax_delete): ...to here.
* m4/m4module.h (DEF_LQUOTE, DEF_RQUOTE, DEF_BCOMM, DEF_ECOMM):
Moved to m4/m4private.h.
* m4/syntax.c (m4_get_syntax_lquote, m4_get_syntax_rquote)
(m4_get_syntax_bcomm, m4_get_syntax_ecomm)
(m4_is_syntax_single_quotes, m4_is_syntax_single_comments)
(m4_is_syntax_macro_escaped): New accessors for m4_syntax_table
objects. Changed all callers that used to directly access the
global equivalents.
(m4__single_quotes, m4__single_comments, m4__use_macro_escape):
Removed and incorporated into m4_syntax_table structure.
* m4/utility.c (lquote, rquote, bcomm, ecomm): Ditto.
* m4/syntax.c (m4_set_syntax): Now returns an error status,
instead of requiring a `struct m4' to generate its own errors.
Changed all callers.
* src/main.c (main): Now that the syntax table is initialised as
part of m4_create, we have to manually wipe the syntax entries if
we are about to read a frozen file.
source: Moved the option variables out of global space and into
`struct m4'; made `m4_symtab' a real datatype, so that it's api
is not marred passing `struct m4' around just so it can decide
whether to keep traced symbol names or not. Added setters and
getters for the formerly global option variables, and obviously
changed a vast number of functions to take a `struct m4' and use
the getter funcs to find option values.
* m4/utility.c (interactive, sync_output, debug_level)
(no_gnu_extensions, prefix_all_builtins, suppress_warnings)
(max_debug_argument_length, warning_status, nesting_limit)
(discard_comments): Removed.
* m4/m4module (warning_status, no_gnu_extensions, nesting_limit)
(debug_level, max_debug_argument_length, prefix_all_builtins)
(suppress_warnings, discard_comments, interactive, sync_output):
Removed from here...
* m4/m4private.h (struct m4): ...and equivalent fields added to
this structure.
(m4_get_warning_status_opt, m4_get_no_gnu_extensions_opt)
(m4_get_nesting_limit_opt, m4_get_debug_level_opt)
(m4_get_max_debug_arg_length_opt, m4_get_prefix_builtins_opt)
(m4_get_suppress_warnings_opt, m4_get_discard_comments_opt)
(m4_get_interactive_opt, m4_get_sync_output_opt): Fast access
macros for the new fields.
* m4/m4module.h (m4_context_field_table)
(m4_context_opt_bit_table): Helper macros used to generate
prototypes, setters and getters for new option fields
consistently.
* m4/m4.c (m4_get_warning_status_opt, m4_get_no_gnu_extensions_opt)
(m4_get_nesting_limit_opt, m4_get_debug_level_opt)
(m4_get_max_debug_arg_length_opt, m4_get_prefix_builtins_opt)
(m4_get_suppress_warnings_opt, m4_get_discard_comments_opt)
(m4_get_interactive_opt, m4_get_sync_output_opt)
(m4_set_warning_status_opt, m4_set_no_gnu_extensions_opt)
(m4_set_nesting_limit_opt, m4_set_debug_level_opt)
(m4_set_max_debug_arg_length_opt, m4_set_prefix_builtins_opt)
(m4_set_suppress_warnings_opt, m4_set_discard_comments_opt)
(m4_set_interactive_opt, m4_set_sync_output_opt): Addressable
setter and getter functions generated by cpp from
m4_context_field_table and m4_context_opt_bit_table, exported as
part of the module api. Changed all callers.
* m4/symtab (struct m4_symtab): Used as the concrete type for
m4_symtab now.
(m4_symtab_create): Allocate and initialise a new struct.
(m4_symtab_apply): New function that works like m4_hash_apply, but
with different callbacks specific to symbol tables. Changed all
callers.
(symbol_destroy, arg_destroy, arg_copy): Renamed
symbol_destroy_CB, arg_destroy_CB, arg_copy_CB to remind me that
they have unused parameters for a reason!
(dump_symbol_CB): New callback to dump the contents of a single
symbol.
(symtob_dump): Rewritten in terms of dump_symbol_CB.
* m4/utility.c (m4_dump_symbol): Renamed to m4_dump_symbol_CB.
Changed all callers.
* m4/m4.c (m4_create): By default point the `nuke_trace_bit' field
of the contained `m4_symtab' at the `no_gnu_extensions' field.
Although I'm not convinced these semantics are correct, they are
at least consistent with how things were before this delta. Also
set the default nesting limit to M4_DEFAULT_NESTING_LIMIT.
argument range checking, tabulate the maxima and minima for all
builtins in each module. This forces us to consider what the
valid ranges for each builtin should be, and moves the checking
code out of each builtin implementation and into the builtin
caller infrastructure.
* m4/m4module.h (struct m4_builtin): Add argument minima and
maxima.
* m4/m4private.h (struct m4_token): Reflect them here too.
* m4/input.c (struct input_block): ...and here.
(m4_token_copy): New function for token copying.
(init_macro_token): Copy them from a token to the input stack.
(m4_next_token): Don't forget to initialise them for text
macros.
* m4/macro.c (expand_argument): Use m4_token_copy, and also
check argument counts before calling the builtin handler.
* m4/symtab.c (m4_symbol_builtin): Take minima and maxima params.
(m4_symbol_macro): Likewise.
* m4/builtin.c (m4_builtin_pushdef): Add min_args and max_args
parameters. Updated all callers.
(m4_builtin_define): Ditto.
(m4_macro_pushdef, m4_macro_define): Ditto.
* m4/symtab.c (m4_symbol_builtin, m4_symbol_define): Ditto.
* modules/evalparse.c: Declare argument counts for defined
builtins and remove explicit calls to m4_bad_argc().
* modules/gnu.c: Ditto.
* modules/load.c: Ditto.
* modules/m4.c: Ditto.
* modules/modtest.c: Ditto.
* modules/mpeval.c: Ditto.
* modules/perl.c: Ditto.
* modules/shadow.c: Ditto.
* modules/stdlib.c: Ditto.
* modules/time.c: Ditto.
* TODO: Updated.