diff options
Diffstat (limited to 'm4/m4private.h')
-rw-r--r-- | m4/m4private.h | 508 |
1 files changed, 254 insertions, 254 deletions
diff --git a/m4/m4private.h b/m4/m4private.h index d1dc79a2..ab5c299b 100644 --- a/m4/m4private.h +++ b/m4/m4private.h @@ -33,16 +33,16 @@ typedef struct m4__macro_arg_stacks m4__macro_arg_stacks; typedef struct m4__symbol_chain m4__symbol_chain; typedef enum { - M4_SYMBOL_VOID, /* Traced but undefined, u is invalid. */ - M4_SYMBOL_TEXT, /* Plain text, u.u_t is valid. */ - M4_SYMBOL_FUNC, /* Builtin function, u.func is valid. */ - M4_SYMBOL_PLACEHOLDER, /* Placeholder for unknown builtin from -R. */ - M4_SYMBOL_COMP /* Composite symbol, u.u_c.c is valid. */ + M4_SYMBOL_VOID, /* Traced but undefined, u is invalid. */ + M4_SYMBOL_TEXT, /* Plain text, u.u_t is valid. */ + M4_SYMBOL_FUNC, /* Builtin function, u.func is valid. */ + M4_SYMBOL_PLACEHOLDER, /* Placeholder for unknown builtin from -R. */ + M4_SYMBOL_COMP /* Composite symbol, u.u_c.c is valid. */ } m4__symbol_type; -#define BIT_TEST(flags, bit) (((flags) & (bit)) == (bit)) -#define BIT_SET(flags, bit) ((flags) |= (bit)) -#define BIT_RESET(flags, bit) ((flags) &= ~(bit)) +#define BIT_TEST(flags, bit) (((flags) & (bit)) == (bit)) +#define BIT_SET(flags, bit) ((flags) |= (bit)) +#define BIT_RESET(flags, bit) ((flags) &= ~(bit)) /* Gnulib's stdbool doesn't work with bool bitfields. For nicer debugging, use bool when we know it works, but use the more @@ -57,89 +57,89 @@ typedef unsigned int bool_bitfield; /* --- CONTEXT MANAGEMENT --- */ struct m4 { - m4_symbol_table * symtab; - m4_syntax_table * syntax; + m4_symbol_table * symtab; + m4_syntax_table * syntax; - const char * current_file; /* Current input file. */ - int current_line; /* Current input line. */ - int output_line; /* Current output line. */ + const char * current_file; /* Current input file. */ + int current_line; /* Current input line. */ + int output_line; /* Current output line. */ - FILE * debug_file; /* File for debugging output. */ - m4_obstack trace_messages; - int exit_status; /* Cumulative exit status. */ - int current_diversion; /* Current output diversion. */ + FILE * debug_file; /* File for debugging output. */ + m4_obstack trace_messages; + int exit_status; /* Cumulative exit status. */ + int current_diversion; /* Current output diversion. */ /* Option flags (set in src/main.c). */ - size_t nesting_limit; /* -L */ - int debug_level; /* -d */ - size_t max_debug_arg_length; /* -l */ - int regexp_syntax; /* -r */ - int opt_flags; + size_t nesting_limit; /* -L */ + int debug_level; /* -d */ + size_t max_debug_arg_length; /* -l */ + int regexp_syntax; /* -r */ + int opt_flags; /* __PRIVATE__: */ - m4__search_path_info *search_path; /* The list of path directories. */ - m4__macro_arg_stacks *arg_stacks; /* Array of current argv refs. */ - size_t stacks_count; /* Size of arg_stacks. */ - size_t expansion_level;/* Macro call nesting level. */ + m4__search_path_info *search_path; /* The list of path directories. */ + m4__macro_arg_stacks *arg_stacks; /* Array of current argv refs. */ + size_t stacks_count; /* Size of arg_stacks. */ + size_t expansion_level;/* Macro call nesting level. */ }; -#define M4_OPT_PREFIX_BUILTINS_BIT (1 << 0) /* -P */ -#define M4_OPT_SUPPRESS_WARN_BIT (1 << 1) /* -Q */ -#define M4_OPT_DISCARD_COMMENTS_BIT (1 << 2) /* -c */ -#define M4_OPT_INTERACTIVE_BIT (1 << 3) /* -e */ -#define M4_OPT_SYNCOUTPUT_BIT (1 << 4) /* -s */ -#define M4_OPT_POSIXLY_CORRECT_BIT (1 << 5) /* -G/POSIXLY_CORRECT */ -#define M4_OPT_FATAL_WARN_BIT (1 << 6) /* -E once */ -#define M4_OPT_WARN_EXIT_BIT (1 << 7) /* -E twice */ -#define M4_OPT_SAFER_BIT (1 << 8) /* --safer */ +#define M4_OPT_PREFIX_BUILTINS_BIT (1 << 0) /* -P */ +#define M4_OPT_SUPPRESS_WARN_BIT (1 << 1) /* -Q */ +#define M4_OPT_DISCARD_COMMENTS_BIT (1 << 2) /* -c */ +#define M4_OPT_INTERACTIVE_BIT (1 << 3) /* -e */ +#define M4_OPT_SYNCOUTPUT_BIT (1 << 4) /* -s */ +#define M4_OPT_POSIXLY_CORRECT_BIT (1 << 5) /* -G/POSIXLY_CORRECT */ +#define M4_OPT_FATAL_WARN_BIT (1 << 6) /* -E once */ +#define M4_OPT_WARN_EXIT_BIT (1 << 7) /* -E twice */ +#define M4_OPT_SAFER_BIT (1 << 8) /* --safer */ /* Fast macro versions of accessor functions for public fields of m4, that also have an identically named function exported in m4module.h. */ #ifdef NDEBUG -# define m4_get_symbol_table(C) ((C)->symtab) -# define m4_set_symbol_table(C, V) ((C)->symtab = (V)) -# define m4_get_syntax_table(C) ((C)->syntax) -# define m4_set_syntax_table(C, V) ((C)->syntax = (V)) -# define m4_get_current_file(C) ((C)->current_file) -# define m4_set_current_file(C, V) ((C)->current_file = (V)) -# define m4_get_current_line(C) ((C)->current_line) -# define m4_set_current_line(C, V) ((C)->current_line = (V)) -# define m4_get_output_line(C) ((C)->output_line) -# define m4_set_output_line(C, V) ((C)->output_line = (V)) -# define m4_get_debug_file(C) ((C)->debug_file) -# define m4_set_debug_file(C, V) ((C)->debug_file = (V)) -# define m4_get_trace_messages(C) ((C)->trace_messages) -# define m4_set_trace_messages(C, V) ((C)->trace_messages = (V)) -# define m4_get_exit_status(C) ((C)->exit_status) -# define m4_set_exit_status(C, V) ((C)->exit_status = (V)) -# define m4_get_current_diversion(C) ((C)->current_diversion) -# define m4_set_current_diversion(C, V) ((C)->current_diversion = (V)) -# define m4_get_nesting_limit_opt(C) ((C)->nesting_limit) -# define m4_set_nesting_limit_opt(C, V) ((C)->nesting_limit = (V)) -# define m4_get_debug_level_opt(C) ((C)->debug_level) -# define m4_set_debug_level_opt(C, V) ((C)->debug_level = (V)) -# define m4_get_max_debug_arg_length_opt(C) ((C)->max_debug_arg_length) -# define m4_set_max_debug_arg_length_opt(C, V) ((C)->max_debug_arg_length=(V)) -# define m4_get_regexp_syntax_opt(C) ((C)->regexp_syntax) -# define m4_set_regexp_syntax_opt(C, V) ((C)->regexp_syntax = (V)) - -# define m4_get_prefix_builtins_opt(C) \ +# define m4_get_symbol_table(C) ((C)->symtab) +# define m4_set_symbol_table(C, V) ((C)->symtab = (V)) +# define m4_get_syntax_table(C) ((C)->syntax) +# define m4_set_syntax_table(C, V) ((C)->syntax = (V)) +# define m4_get_current_file(C) ((C)->current_file) +# define m4_set_current_file(C, V) ((C)->current_file = (V)) +# define m4_get_current_line(C) ((C)->current_line) +# define m4_set_current_line(C, V) ((C)->current_line = (V)) +# define m4_get_output_line(C) ((C)->output_line) +# define m4_set_output_line(C, V) ((C)->output_line = (V)) +# define m4_get_debug_file(C) ((C)->debug_file) +# define m4_set_debug_file(C, V) ((C)->debug_file = (V)) +# define m4_get_trace_messages(C) ((C)->trace_messages) +# define m4_set_trace_messages(C, V) ((C)->trace_messages = (V)) +# define m4_get_exit_status(C) ((C)->exit_status) +# define m4_set_exit_status(C, V) ((C)->exit_status = (V)) +# define m4_get_current_diversion(C) ((C)->current_diversion) +# define m4_set_current_diversion(C, V) ((C)->current_diversion = (V)) +# define m4_get_nesting_limit_opt(C) ((C)->nesting_limit) +# define m4_set_nesting_limit_opt(C, V) ((C)->nesting_limit = (V)) +# define m4_get_debug_level_opt(C) ((C)->debug_level) +# define m4_set_debug_level_opt(C, V) ((C)->debug_level = (V)) +# define m4_get_max_debug_arg_length_opt(C) ((C)->max_debug_arg_length) +# define m4_set_max_debug_arg_length_opt(C, V) ((C)->max_debug_arg_length=(V)) +# define m4_get_regexp_syntax_opt(C) ((C)->regexp_syntax) +# define m4_set_regexp_syntax_opt(C, V) ((C)->regexp_syntax = (V)) + +# define m4_get_prefix_builtins_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_PREFIX_BUILTINS_BIT)) -# define m4_get_suppress_warnings_opt(C) \ +# define m4_get_suppress_warnings_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_SUPPRESS_WARN_BIT)) -# define m4_get_discard_comments_opt(C) \ +# define m4_get_discard_comments_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_DISCARD_COMMENTS_BIT)) -# define m4_get_interactive_opt(C) \ +# define m4_get_interactive_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_INTERACTIVE_BIT)) -# define m4_get_syncoutput_opt(C) \ +# define m4_get_syncoutput_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_SYNCOUTPUT_BIT)) -# define m4_get_posixly_correct_opt(C) \ +# define m4_get_posixly_correct_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_POSIXLY_CORRECT_BIT)) -# define m4_get_fatal_warnings_opt(C) \ +# define m4_get_fatal_warnings_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_FATAL_WARN_BIT)) -# define m4_get_warnings_exit_opt(C) \ +# define m4_get_warnings_exit_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_WARN_EXIT_BIT)) -# define m4_get_safer_opt(C) \ +# define m4_get_safer_opt(C) \ (BIT_TEST((C)->opt_flags, M4_OPT_SAFER_BIT)) /* No fast opt bit set macros, as they would need to evaluate their @@ -148,7 +148,7 @@ struct m4 { /* Accessors for private fields of m4, which have no function version exported in m4module.h. */ -#define m4__get_search_path(C) ((C)->search_path) +#define m4__get_search_path(C) ((C)->search_path) /* --- BUILTIN MANAGEMENT --- */ @@ -160,7 +160,7 @@ struct m4__builtin can be used for additional bits beyond what is allowed for modules. */ m4_builtin builtin; - m4_module *module; /* Module that owns this builtin. */ + m4_module *module; /* Module that owns this builtin. */ }; typedef struct m4__builtin m4__builtin; @@ -173,32 +173,32 @@ extern void m4__builtin_print (m4_obstack *, const m4__builtin *, bool, /* --- MODULE MANAGEMENT --- */ -#define USER_MODULE_PATH_ENV "M4MODPATH" -#define BUILTIN_SYMBOL "m4_builtin_table" -#define MACRO_SYMBOL "m4_macro_table" -#define INIT_SYMBOL "m4_init_module" -#define FINISH_SYMBOL "m4_finish_module" +#define USER_MODULE_PATH_ENV "M4MODPATH" +#define BUILTIN_SYMBOL "m4_builtin_table" +#define MACRO_SYMBOL "m4_macro_table" +#define INIT_SYMBOL "m4_init_module" +#define FINISH_SYMBOL "m4_finish_module" /* Representation of a loaded m4 module. */ struct m4_module { - lt_dlhandle handle; /* All ltdl module information. */ - int refcount; /* Count of loads not matched by unload. */ - m4__builtin *builtins; /* Sorted array of builtins. */ - size_t builtins_len; /* Number of builtins. */ + lt_dlhandle handle; /* All ltdl module information. */ + int refcount; /* Count of loads not matched by unload. */ + m4__builtin *builtins; /* Sorted array of builtins. */ + size_t builtins_len; /* Number of builtins. */ }; -extern void m4__module_init (m4 *context); +extern void m4__module_init (m4 *context); extern m4_module * m4__module_open (m4 *context, const char *name, m4_obstack *obs); -extern void m4__module_exit (m4 *context); +extern void m4__module_exit (m4 *context); extern m4_module * m4__module_next (m4_module *); extern m4_module * m4__module_find (const char *name); /* Fast macro versions of symbol table accessor functions, that also have an identically named function exported in m4module.h. */ #ifdef NDEBUG -# define m4_module_refcount(M) ((M)->refcount) +# define m4_module_refcount(M) ((M)->refcount) #endif @@ -206,49 +206,49 @@ extern m4_module * m4__module_find (const char *name); struct m4_symbol { - bool traced; /* True if this symbol is traced. */ - m4_symbol_value *value; /* Linked list of pushdef'd values. */ + bool traced; /* True if this symbol is traced. */ + m4_symbol_value *value; /* Linked list of pushdef'd values. */ }; /* Type of a link in a symbol chain. */ enum m4__symbol_chain_type { - M4__CHAIN_STR, /* Link contains a string, u.u_s is valid. */ - M4__CHAIN_FUNC, /* Link contains builtin token, u.builtin is valid. */ - M4__CHAIN_ARGV, /* Link contains a $@ reference, u.u_a is valid. */ - M4__CHAIN_LOC /* Link contains m4wrap location, u.u_l is valid. */ + M4__CHAIN_STR, /* Link contains a string, u.u_s is valid. */ + M4__CHAIN_FUNC, /* Link contains builtin token, u.builtin is valid. */ + M4__CHAIN_ARGV, /* Link contains a $@ reference, u.u_a is valid. */ + M4__CHAIN_LOC /* Link contains m4wrap location, u.u_l is valid. */ }; /* Composite symbols are built of a linked list of chain objects. */ struct m4__symbol_chain { - m4__symbol_chain *next; /* Pointer to next link of chain. */ - enum m4__symbol_chain_type type; /* Type of this link. */ - unsigned int quote_age; /* Quote_age of this link, or 0. */ + m4__symbol_chain *next; /* Pointer to next link of chain. */ + enum m4__symbol_chain_type type; /* Type of this link. */ + unsigned int quote_age; /* Quote_age of this link, or 0. */ union { struct { - const char *str; /* Pointer to text. */ - size_t len; /* Remaining length of str. */ - size_t level; /* Expansion level of content, or SIZE_MAX. */ - } u_s; /* M4__CHAIN_STR. */ - const m4__builtin *builtin; /* M4__CHAIN_FUNC. */ + const char *str; /* Pointer to text. */ + size_t len; /* Remaining length of str. */ + size_t level; /* Expansion level of content, or SIZE_MAX. */ + } u_s; /* M4__CHAIN_STR. */ + const m4__builtin *builtin; /* M4__CHAIN_FUNC. */ struct { - m4_macro_args *argv; /* Reference to earlier $@. */ - size_t index; /* Argument index within argv. */ - bool_bitfield flatten : 1; /* True to treat builtins as text. */ - bool_bitfield comma : 1; /* True when `,' is next input. */ - bool_bitfield skip_last : 1; /* True if last argument omitted. */ - bool_bitfield has_func : 1; /* True if argv includes func. */ - const m4_string_pair *quotes; /* NULL for $*, quotes for $@. */ - } u_a; /* M4__CHAIN_ARGV. */ + m4_macro_args *argv; /* Reference to earlier $@. */ + size_t index; /* Argument index within argv. */ + bool_bitfield flatten : 1; /* True to treat builtins as text. */ + bool_bitfield comma : 1; /* True when `,' is next input. */ + bool_bitfield skip_last : 1; /* True if last argument omitted. */ + bool_bitfield has_func : 1; /* True if argv includes func. */ + const m4_string_pair *quotes; /* NULL for $*, quotes for $@. */ + } u_a; /* M4__CHAIN_ARGV. */ struct { - const char *file; /* File where subsequent links originate. */ - int line; /* Line where subsequent links originate. */ - } u_l; /* M4__CHAIN_LOC. */ + const char *file; /* File where subsequent links originate. */ + int line; /* Line where subsequent links originate. */ + } u_l; /* M4__CHAIN_LOC. */ } u; }; @@ -256,34 +256,34 @@ struct m4__symbol_chain name, and for arguments to a macro invocation. */ struct m4_symbol_value { - m4_symbol_value * next; - m4_module * module; - unsigned int flags; + m4_symbol_value * next; + m4_module * module; + unsigned int flags; - m4_hash * arg_signature; - size_t min_args; - size_t max_args; - size_t pending_expansions; + m4_hash * arg_signature; + size_t min_args; + size_t max_args; + size_t pending_expansions; - m4__symbol_type type; + m4__symbol_type type; union { struct { - size_t len; /* Length of string. */ - const char * text; /* String contents. */ + size_t len; /* Length of string. */ + const char * text; /* String contents. */ /* Quote age when this string was built, or zero to force a rescan of the string. Ignored for 0 len. */ - unsigned int quote_age; - } u_t; /* Valid when type is TEXT, PLACEHOLDER. */ - const m4__builtin * builtin;/* Valid when type is FUNC. */ + unsigned int quote_age; + } u_t; /* Valid when type is TEXT, PLACEHOLDER. */ + const m4__builtin * builtin;/* Valid when type is FUNC. */ struct { - m4__symbol_chain *chain; /* First link of the chain. */ - m4__symbol_chain *end; /* Last link of the chain. */ - bool_bitfield wrapper : 1; /* True if this is a $@ ref. */ - bool_bitfield has_func : 1; /* True if chain includes func. */ - } u_c; /* Valid when type is COMP. */ + m4__symbol_chain *chain; /* First link of the chain. */ + m4__symbol_chain *end; /* Last link of the chain. */ + bool_bitfield wrapper : 1; /* True if this is a $@ ref. */ + bool_bitfield has_func : 1; /* True if chain includes func. */ + } u_c; /* Valid when type is COMP. */ } u; }; @@ -327,12 +327,12 @@ struct m4_macro_args macro.c for a much more detailed comment on usage. */ struct m4__macro_arg_stacks { - size_t refcount; /* Number of active $@ references at this level. */ - size_t argcount; /* Number of argv at this level. */ - m4_obstack *args; /* Content of arguments. */ - m4_obstack *argv; /* Argv pointers into args. */ - void *args_base; /* Location for clearing the args obstack. */ - void *argv_base; /* Location for clearing the argv obstack. */ + size_t refcount; /* Number of active $@ references at this level. */ + size_t argcount; /* Number of argv at this level. */ + m4_obstack *args; /* Content of arguments. */ + m4_obstack *argv; /* Argv pointers into args. */ + void *args_base; /* Location for clearing the args obstack. */ + void *argv_base; /* Location for clearing the argv obstack. */ }; /* Opaque structure for managing call context information. Contains @@ -341,74 +341,74 @@ struct m4__macro_arg_stacks changes global context in the meantime. */ struct m4_call_info { - const char *file; /* The file containing the macro invocation. */ - int line; /* The line the macro was called on. */ - size_t call_id; /* The unique sequence call id of the macro. */ - int trace : 1; /* True to trace this macro. */ - int debug_level : 31; /* The debug level for tracing the macro call. */ - const char *name; /* The macro name. */ - size_t name_len; /* The length of name. */ + const char *file; /* The file containing the macro invocation. */ + int line; /* The line the macro was called on. */ + size_t call_id; /* The unique sequence call id of the macro. */ + int trace : 1; /* True to trace this macro. */ + int debug_level : 31; /* The debug level for tracing the macro call. */ + const char *name; /* The macro name. */ + size_t name_len; /* The length of name. */ }; -extern size_t m4__adjust_refcount (m4 *, size_t, bool); -extern bool m4__arg_adjust_refcount (m4 *, m4_macro_args *, bool); -extern void m4__push_arg_quote (m4 *, m4_obstack *, m4_macro_args *, +extern size_t m4__adjust_refcount (m4 *, size_t, bool); +extern bool m4__arg_adjust_refcount (m4 *, m4_macro_args *, bool); +extern void m4__push_arg_quote (m4 *, m4_obstack *, m4_macro_args *, size_t, const m4_string_pair *); -extern bool m4__arg_print (m4 *, m4_obstack *, m4_macro_args *, +extern bool m4__arg_print (m4 *, m4_obstack *, m4_macro_args *, size_t, const m4_string_pair *, bool, m4__symbol_chain **, const char *, size_t *, bool, bool); -#define VALUE_NEXT(T) ((T)->next) -#define VALUE_MODULE(T) ((T)->module) -#define VALUE_FLAGS(T) ((T)->flags) -#define VALUE_ARG_SIGNATURE(T) ((T)->arg_signature) -#define VALUE_MIN_ARGS(T) ((T)->min_args) -#define VALUE_MAX_ARGS(T) ((T)->max_args) -#define VALUE_PENDING(T) ((T)->pending_expansions) - -#define SYMBOL_NEXT(S) (VALUE_NEXT ((S)->value)) -#define SYMBOL_MODULE(S) (VALUE_MODULE ((S)->value)) -#define SYMBOL_FLAGS(S) (VALUE_FLAGS ((S)->value)) -#define SYMBOL_ARG_SIGNATURE(S) (VALUE_ARG_SIGNATURE ((S)->value)) -#define SYMBOL_MIN_ARGS(S) (VALUE_MIN_ARGS ((S)->value)) -#define SYMBOL_MAX_ARGS(S) (VALUE_MAX_ARGS ((S)->value)) -#define SYMBOL_PENDING(S) (VALUE_PENDING ((S)->value)) +#define VALUE_NEXT(T) ((T)->next) +#define VALUE_MODULE(T) ((T)->module) +#define VALUE_FLAGS(T) ((T)->flags) +#define VALUE_ARG_SIGNATURE(T) ((T)->arg_signature) +#define VALUE_MIN_ARGS(T) ((T)->min_args) +#define VALUE_MAX_ARGS(T) ((T)->max_args) +#define VALUE_PENDING(T) ((T)->pending_expansions) + +#define SYMBOL_NEXT(S) (VALUE_NEXT ((S)->value)) +#define SYMBOL_MODULE(S) (VALUE_MODULE ((S)->value)) +#define SYMBOL_FLAGS(S) (VALUE_FLAGS ((S)->value)) +#define SYMBOL_ARG_SIGNATURE(S) (VALUE_ARG_SIGNATURE ((S)->value)) +#define SYMBOL_MIN_ARGS(S) (VALUE_MIN_ARGS ((S)->value)) +#define SYMBOL_MAX_ARGS(S) (VALUE_MAX_ARGS ((S)->value)) +#define SYMBOL_PENDING(S) (VALUE_PENDING ((S)->value)) /* Fast macro versions of symbol table accessor functions, that also have an identically named function exported in m4module.h. */ #ifdef NDEBUG -# define m4_get_symbol_traced(S) ((S)->traced) -# define m4_get_symbol_value(S) ((S)->value) -# define m4_set_symbol_value(S, V) ((S)->value = (V)) +# define m4_get_symbol_traced(S) ((S)->traced) +# define m4_get_symbol_value(S) ((S)->value) +# define m4_set_symbol_value(S, V) ((S)->value = (V)) /* m4_symbol_value_{create,delete} are too complex for a simple macro. */ -# define m4_is_symbol_value_text(V) ((V)->type == M4_SYMBOL_TEXT) -# define m4_is_symbol_value_func(V) ((V)->type == M4_SYMBOL_FUNC) -# define m4_is_symbol_value_void(V) ((V)->type == M4_SYMBOL_VOID) -# define m4_is_symbol_value_placeholder(V) \ +# define m4_is_symbol_value_text(V) ((V)->type == M4_SYMBOL_TEXT) +# define m4_is_symbol_value_func(V) ((V)->type == M4_SYMBOL_FUNC) +# define m4_is_symbol_value_void(V) ((V)->type == M4_SYMBOL_VOID) +# define m4_is_symbol_value_placeholder(V) \ ((V)->type == M4_SYMBOL_PLACEHOLDER) -# define m4_get_symbol_value_text(V) ((V)->u.u_t.text) -# define m4_get_symbol_value_len(V) ((V)->u.u_t.len) -# define m4_get_symbol_value_quote_age(V) ((V)->u.u_t.quote_age) -# define m4_get_symbol_value_func(V) ((V)->u.builtin->builtin.func) +# define m4_get_symbol_value_text(V) ((V)->u.u_t.text) +# define m4_get_symbol_value_len(V) ((V)->u.u_t.len) +# define m4_get_symbol_value_quote_age(V) ((V)->u.u_t.quote_age) +# define m4_get_symbol_value_func(V) ((V)->u.builtin->builtin.func) # define m4_get_symbol_value_builtin(V) (&(V)->u.builtin->builtin) -# define m4_get_symbol_value_placeholder(V) \ +# define m4_get_symbol_value_placeholder(V) \ ((V)->u.u_t.text) -# define m4_symbol_value_flatten_args(V) \ +# define m4_symbol_value_flatten_args(V) \ (BIT_TEST ((V)->flags, VALUE_FLATTEN_ARGS_BIT)) -# define m4_set_symbol_value_text(V, T, L, A) \ - ((V)->type = M4_SYMBOL_TEXT, (V)->u.u_t.text = (T), \ +# define m4_set_symbol_value_text(V, T, L, A) \ + ((V)->type = M4_SYMBOL_TEXT, (V)->u.u_t.text = (T), \ (V)->u.u_t.len = (L), (V)->u.u_t.quote_age = (A)) -# define m4_set_symbol_value_placeholder(V, T) \ +# define m4_set_symbol_value_placeholder(V, T) \ ((V)->type = M4_SYMBOL_PLACEHOLDER, (V)->u.u_t.text = (T)) -# define m4__set_symbol_value_builtin(V, B) \ - ((V)->type = M4_SYMBOL_FUNC, (V)->u.builtin = (B), \ - VALUE_MODULE (V) = (B)->module, \ - VALUE_FLAGS (V) = (B)->builtin.flags, \ - VALUE_MIN_ARGS (V) = (B)->builtin.min_args, \ +# define m4__set_symbol_value_builtin(V, B) \ + ((V)->type = M4_SYMBOL_FUNC, (V)->u.builtin = (B), \ + VALUE_MODULE (V) = (B)->module, \ + VALUE_FLAGS (V) = (B)->builtin.flags, \ + VALUE_MIN_ARGS (V) = (B)->builtin.min_args, \ VALUE_MAX_ARGS (V) = (B)->builtin.max_args) #endif @@ -419,26 +419,26 @@ extern bool m4__arg_print (m4 *, m4_obstack *, m4_macro_args *, m4_builtin.flags to m4_symbol_arg.flags. We can use additional bits for private use. */ -#define VALUE_FLATTEN_ARGS_BIT (1 << 0) -#define VALUE_BLIND_ARGS_BIT (1 << 1) -#define VALUE_SIDE_EFFECT_ARGS_BIT (1 << 2) -#define VALUE_DELETED_BIT (1 << 3) +#define VALUE_FLATTEN_ARGS_BIT (1 << 0) +#define VALUE_BLIND_ARGS_BIT (1 << 1) +#define VALUE_SIDE_EFFECT_ARGS_BIT (1 << 2) +#define VALUE_DELETED_BIT (1 << 3) struct m4_symbol_arg { - int index; - int flags; - char * default_val; + int index; + int flags; + char * default_val; }; -#define SYMBOL_ARG_INDEX(A) ((A)->index) -#define SYMBOL_ARG_FLAGS(A) ((A)->flags) -#define SYMBOL_ARG_DEFAULT(A) ((A)->default_val) +#define SYMBOL_ARG_INDEX(A) ((A)->index) +#define SYMBOL_ARG_FLAGS(A) ((A)->flags) +#define SYMBOL_ARG_DEFAULT(A) ((A)->default_val) /* m4_symbol_arg.flags bit masks: */ -#define SYMBOL_ARG_REST_BIT (1 << 0) -#define SYMBOL_ARG_KEY_BIT (1 << 1) +#define SYMBOL_ARG_REST_BIT (1 << 0) +#define SYMBOL_ARG_KEY_BIT (1 << 1) extern void m4__symtab_remove_module_references (m4_symbol_table *, m4_module *); @@ -452,16 +452,16 @@ extern bool m4__symbol_value_print (m4 *, m4_symbol_value *, m4_obstack *, /* CHAR_RETRY must be last, because we size the syntax table to hold all other characters and sentinels. */ -#define CHAR_EOF (UCHAR_MAX + 1) /* Return on EOF. */ -#define CHAR_BUILTIN (UCHAR_MAX + 2) /* Return for BUILTIN token. */ -#define CHAR_QUOTE (UCHAR_MAX + 3) /* Return for quoted string. */ -#define CHAR_ARGV (UCHAR_MAX + 4) /* Return for $@ reference. */ -#define CHAR_RETRY (UCHAR_MAX + 5) /* Return for end of input block. */ +#define CHAR_EOF (UCHAR_MAX + 1) /* Return on EOF. */ +#define CHAR_BUILTIN (UCHAR_MAX + 2) /* Return for BUILTIN token. */ +#define CHAR_QUOTE (UCHAR_MAX + 3) /* Return for quoted string. */ +#define CHAR_ARGV (UCHAR_MAX + 4) /* Return for $@ reference. */ +#define CHAR_RETRY (UCHAR_MAX + 5) /* Return for end of input block. */ -#define DEF_LQUOTE "`" /* Default left quote delimiter. */ -#define DEF_RQUOTE "\'" /* Default right quote delimiter. */ -#define DEF_BCOMM "#" /* Default begin comment delimiter. */ -#define DEF_ECOMM "\n" /* Default end comment delimiter. */ +#define DEF_LQUOTE "`" /* Default left quote delimiter. */ +#define DEF_RQUOTE "\'" /* Default right quote delimiter. */ +#define DEF_BCOMM "#" /* Default begin comment delimiter. */ +#define DEF_ECOMM "\n" /* Default end comment delimiter. */ struct m4_syntax_table { /* Please read the comment at the top of input.c for details. table @@ -469,8 +469,8 @@ struct m4_syntax_table { unsigned short table[CHAR_RETRY]; unsigned short orig[CHAR_RETRY]; - m4_string_pair quote; /* Quote delimiters. */ - m4_string_pair comm; /* Comment delimiters. */ + m4_string_pair quote; /* Quote delimiters. */ + m4_string_pair comm; /* Comment delimiters. */ char dollar; /* Dollar character, if is_single_dollar. */ @@ -514,26 +514,26 @@ struct m4_syntax_table { /* Fast macro versions of syntax table accessor functions, that also have an identically named function exported in m4module.h. */ #ifdef NDEBUG -# define m4_get_syntax_lquote(S) ((S)->quote.str1) -# define m4_get_syntax_rquote(S) ((S)->quote.str2) -# define m4_get_syntax_bcomm(S) ((S)->comm.str1) -# define m4_get_syntax_ecomm(S) ((S)->comm.str2) -# define m4_get_syntax_quotes(S) (&(S)->quote) -# define m4_get_syntax_comments(S) (&(S)->comm) - -# define m4_is_syntax_single_quotes(S) ((S)->is_single_quotes) -# define m4_is_syntax_single_comments(S) ((S)->is_single_comments) -# define m4_is_syntax_single_dollar(S) ((S)->is_single_dollar) -# define m4_is_syntax_macro_escaped(S) ((S)->is_macro_escaped) +# define m4_get_syntax_lquote(S) ((S)->quote.str1) +# define m4_get_syntax_rquote(S) ((S)->quote.str2) +# define m4_get_syntax_bcomm(S) ((S)->comm.str1) +# define m4_get_syntax_ecomm(S) ((S)->comm.str2) +# define m4_get_syntax_quotes(S) (&(S)->quote) +# define m4_get_syntax_comments(S) (&(S)->comm) + +# define m4_is_syntax_single_quotes(S) ((S)->is_single_quotes) +# define m4_is_syntax_single_comments(S) ((S)->is_single_comments) +# define m4_is_syntax_single_dollar(S) ((S)->is_single_dollar) +# define m4_is_syntax_macro_escaped(S) ((S)->is_macro_escaped) #endif /* Return the current quote age. */ -#define m4__quote_age(S) ((S)->quote_age) +#define m4__quote_age(S) ((S)->quote_age) /* Return true if the current quote age guarantees that parsing the current token in the context of a quoted string of the same quote age will give the same parse. */ -#define m4__safe_quotes(S) (((S)->quote_age & 0xffff) != 0) +#define m4__safe_quotes(S) (((S)->quote_age & 0xffff) != 0) /* Set or refresh the cached quote. */ extern const m4_string_pair *m4__quote_cache (m4_syntax_table *, @@ -541,48 +541,48 @@ extern const m4_string_pair *m4__quote_cache (m4_syntax_table *, const m4_string_pair *); /* Clear the cached quote. */ -#define m4__quote_uncache(S) ((S)->cached_quote = NULL) +#define m4__quote_uncache(S) ((S)->cached_quote = NULL) /* --- MACRO MANAGEMENT --- */ /* Various different token types. */ typedef enum { - M4_TOKEN_EOF, /* End of file, M4_SYMBOL_VOID. */ - M4_TOKEN_NONE, /* Discardable token, M4_SYMBOL_VOID. */ - M4_TOKEN_STRING, /* Quoted string, M4_SYMBOL_TEXT or M4_SYMBOL_COMP. */ - M4_TOKEN_COMMENT, /* Comment, M4_SYMBOL_TEXT or M4_SYMBOL_COMP. */ - M4_TOKEN_SPACE, /* Whitespace, M4_SYMBOL_TEXT. */ - M4_TOKEN_WORD, /* An identifier, M4_SYMBOL_TEXT. */ - M4_TOKEN_OPEN, /* Argument list start, M4_SYMBOL_TEXT. */ - M4_TOKEN_COMMA, /* Argument separator, M4_SYMBOL_TEXT. */ - M4_TOKEN_CLOSE, /* Argument list end, M4_SYMBOL_TEXT. */ - M4_TOKEN_SIMPLE, /* Single character, M4_SYMBOL_TEXT. */ - M4_TOKEN_MACDEF, /* Builtin token, M4_SYMBOL_FUNC or M4_SYMBOL_COMP. */ - M4_TOKEN_ARGV /* A series of parameters, M4_SYMBOL_COMP. */ + M4_TOKEN_EOF, /* End of file, M4_SYMBOL_VOID. */ + M4_TOKEN_NONE, /* Discardable token, M4_SYMBOL_VOID. */ + M4_TOKEN_STRING, /* Quoted string, M4_SYMBOL_TEXT or M4_SYMBOL_COMP. */ + M4_TOKEN_COMMENT, /* Comment, M4_SYMBOL_TEXT or M4_SYMBOL_COMP. */ + M4_TOKEN_SPACE, /* Whitespace, M4_SYMBOL_TEXT. */ + M4_TOKEN_WORD, /* An identifier, M4_SYMBOL_TEXT. */ + M4_TOKEN_OPEN, /* Argument list start, M4_SYMBOL_TEXT. */ + M4_TOKEN_COMMA, /* Argument separator, M4_SYMBOL_TEXT. */ + M4_TOKEN_CLOSE, /* Argument list end, M4_SYMBOL_TEXT. */ + M4_TOKEN_SIMPLE, /* Single character, M4_SYMBOL_TEXT. */ + M4_TOKEN_MACDEF, /* Builtin token, M4_SYMBOL_FUNC or M4_SYMBOL_COMP. */ + M4_TOKEN_ARGV /* A series of parameters, M4_SYMBOL_COMP. */ } m4__token_type; -extern void m4__make_text_link (m4_obstack *, m4__symbol_chain **, +extern void m4__make_text_link (m4_obstack *, m4__symbol_chain **, m4__symbol_chain **); -extern void m4__append_builtin (m4_obstack *, const m4__builtin *, +extern void m4__append_builtin (m4_obstack *, const m4__builtin *, m4__symbol_chain **, m4__symbol_chain **); -extern bool m4__push_symbol (m4 *, m4_symbol_value *, size_t, +extern bool m4__push_symbol (m4 *, m4_symbol_value *, size_t, bool); -extern m4_obstack *m4__push_wrapup_init (m4 *, const m4_call_info *, +extern m4_obstack *m4__push_wrapup_init (m4 *, const m4_call_info *, m4__symbol_chain ***); -extern void m4__push_wrapup_finish (void); -extern m4__token_type m4__next_token (m4 *, m4_symbol_value *, int *, +extern void m4__push_wrapup_finish (void); +extern m4__token_type m4__next_token (m4 *, m4_symbol_value *, int *, m4_obstack *, bool, const m4_call_info *); -extern bool m4__next_token_is_open (m4 *); +extern bool m4__next_token_is_open (m4 *); /* Fast macro versions of macro argv accessor functions, that also have an identically named function exported in m4module.h. */ #ifdef NDEBUG -# define m4_arg_argc(A) (A)->argc -# define m4_arg_info(A) (A)->info -# define m4_arg_scratch(C) \ +# define m4_arg_argc(A) (A)->argc +# define m4_arg_info(A) (A)->info +# define m4_arg_scratch(C) \ ((C)->arg_stacks[(C)->expansion_level - 1].argv) #endif /* NDEBUG */ @@ -592,15 +592,15 @@ extern bool m4__next_token_is_open (m4 *); typedef struct m4__search_path m4__search_path; struct m4__search_path { - m4__search_path *next; /* next directory to search */ - const char *dir; /* directory */ + m4__search_path *next; /* next directory to search */ + const char *dir; /* directory */ int len; }; struct m4__search_path_info { - m4__search_path *list; /* the list of path directories */ - m4__search_path *list_end; /* the end of same */ - int max_length; /* length of longest directory name */ + m4__search_path *list; /* the list of path directories */ + m4__search_path *list_end; /* the end of same */ + int max_length; /* length of longest directory name */ }; extern void m4__include_init (m4 *); @@ -616,18 +616,18 @@ extern void m4__include_init (m4 *); /* Convenience macro to zero a variable after freeing it. */ -#define DELETE(Expr) ((Expr) = (free ((void *) Expr), (void *) 0)) +#define DELETE(Expr) ((Expr) = (free ((void *) Expr), (void *) 0)) #if DEBUG -# define DEBUG_INCL 1 -# define DEBUG_INPUT 1 -# define DEBUG_MACRO 1 -# define DEBUG_MODULES 1 -# define DEBUG_OUTPUT 1 -# define DEBUG_STKOVF 1 -# define DEBUG_SYM 1 -# define DEBUG_SYNTAX 1 +# define DEBUG_INCL 1 +# define DEBUG_INPUT 1 +# define DEBUG_MACRO 1 +# define DEBUG_MODULES 1 +# define DEBUG_OUTPUT 1 +# define DEBUG_STKOVF 1 +# define DEBUG_SYM 1 +# define DEBUG_SYNTAX 1 #endif #endif /* m4private.h */ |