diff options
author | Eric Blake <ebb9@byu.net> | 2008-03-13 13:48:49 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2008-03-13 21:09:32 -0600 |
commit | 2f49d755e50a574e5a772893f3f5d683495084bc (patch) | |
tree | e9492b7fcfd6458ca256783f6d09b03f86d06853 | |
parent | d621af1bae17e8f6dc2384b71acab9ef21ef51bd (diff) | |
download | m4-2f49d755e50a574e5a772893f3f5d683495084bc.tar.gz |
Stage 19b: invert sense of bit for handling builtin tokens.
* m4/m4module.h (M4BUILTIN_ENTRY): New convenience macro.
(M4_BUILTIN_GROKS_MACRO): Rename...
(M4_BUILTIN_FLATTEN_ARGS): ...and invert sense.
(m4_symbol_value_groks_macro, m4_symbol_groks_macro): Likewise...
(m4_symbol_value_flatten_args, m4_symbol_flatten_args): ...to
this.
* m4/m4private.h (VALUE_MACRO_ARGS_BIT)
(m4_symbol_value_groks_macro): Likewise...
(VALUE_FLATTEN_ARGS_BIT, m4_symbol_value_flatten_args): ...to
this.
* m4/symtab.c (m4_symbol_value_groks_macro): Likewise...
(m4_symbol_value_flatten_args): ...to this.
* m4/macro.c (collect_arguments): Accomodate changed sense.
* m4/module.c (m4__module_open): Require arguments if flattening
is requested.
* m4/input.c (m4_push_string_finish): For now, flatten all
builtins pushed as back-references.
* modules/gnu.c (m4_builtin_table, builtin): Adjust all clients.
* modules/import.c (m4_builtin_table): Likewise.
* modules/load.c (m4_builtin_table): Likewise.
* modules/modtest.c (m4_builtin_table): Likewise.
* modules/mpeval.c (m4_builtin_table): Likewise.
* modules/perl.c (m4_builtin_table): Likewise.
* modules/shadow.c (m4_builtin_table): Likewise.
* modules/stdlib.c (m4_builtin_table): Likewise.
* modules/time.c (m4_builtin_table): Likewise.
* modules/m4.c (m4_builtin_table): Likewise.
(mkstemp): Undo #undef hack from 2006-10-23, now that macro names
are stringized without preprocessor expansion.
* doc/m4.texinfo (Defn): Update comments to match reality.
(Debuglen): Update test now that user macros pass builtin tokens.
Signed-off-by: Eric Blake <ebb9@byu.net>
-rw-r--r-- | ChangeLog | 37 | ||||
-rw-r--r-- | doc/m4.texinfo | 24 | ||||
-rw-r--r-- | m4/input.c | 4 | ||||
-rw-r--r-- | m4/m4module.h | 79 | ||||
-rw-r--r-- | m4/m4private.h | 6 | ||||
-rw-r--r-- | m4/macro.c | 7 | ||||
-rw-r--r-- | m4/module.c | 2 | ||||
-rw-r--r-- | m4/symtab.c | 6 | ||||
-rw-r--r-- | modules/gnu.c | 16 | ||||
-rw-r--r-- | modules/import.c | 12 | ||||
-rw-r--r-- | modules/load.c | 11 | ||||
-rw-r--r-- | modules/m4.c | 13 | ||||
-rw-r--r-- | modules/modtest.c | 10 | ||||
-rw-r--r-- | modules/mpeval.c | 9 | ||||
-rw-r--r-- | modules/perl.c | 8 | ||||
-rw-r--r-- | modules/shadow.c | 10 | ||||
-rw-r--r-- | modules/stdlib.c | 10 | ||||
-rw-r--r-- | modules/time.c | 13 |
18 files changed, 160 insertions, 117 deletions
@@ -1,5 +1,42 @@ 2008-03-13 Eric Blake <ebb9@byu.net> + Stage 19b: invert sense of bit for handling builtin tokens. + Pass builtin tokens by default, rather than as the exception, so + that the logic can consistently refer to flattening arguments. + Memory impact: none. + Speed impact: none. + * 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. + Stage 19a: sort and cache builtins loaded by a module. Rather than repeatedly using dlsym to browse the builtin table, copy off the table at module load time. Then, the input engine diff --git a/doc/m4.texinfo b/doc/m4.texinfo index 909f8e3e..018c9c81 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -2176,10 +2176,13 @@ empty string in most other contexts. @comment FIXME - Other implementations, such as Solaris, can pass a @comment builtin token around to other macros, flattening it only on output: @comment define(foo, a`'defn(`divnum')b) -@comment len(foo) => 3 -@comment index(foo, defn(`divnum') => 1 -@comment foo => ab -@comment It may be worth making some changes to support this behavior. +@comment defn(`foo') => ab +@comment dumpdef(`foo') => foo: a<divnum>b +@comment len(defn(`foo')) => 3 +@comment index(defn(`foo'), defn(`divnum')) => 1 +@comment foo => a0b +@comment It may be worth making some changes to support this behavior, +@comment or something similar to it. The macro @code{defn} is recognized only with parameters. @end deffn @@ -2279,6 +2282,7 @@ of expected contexts can sometimes trigger warnings. But most of the time, such tokens are silently converted to the empty string. @example +$ @kbd{m4 -d} defn(`defn') @result{} define(defn(`divnum'), `cannot redefine a builtin token') @@ -2286,6 +2290,8 @@ define(defn(`divnum'), `cannot redefine a builtin token') @result{} divnum @result{}0 +len(defn(`divnum')) +@result{}0 define(`echo', `$@@') @result{} define(`mydivnum', echo(defn(`divnum'))) @@ -2294,10 +2300,10 @@ mydivnum @result{} @end example -Since @code{defn} can take more than one argument, it can be used to -concatenate multiple macros into one. -@comment FIXME - we don't yet handle mixing text and builtins. This -@comment example passes under Solaris (minus the warning). +A warning is issued if @var{name} is undefined. Also, at present, +concatenating a builtin token with anything else is not supported as a +macro definition, and a warning is issued. +@comment FIXME - handle defining macros with mixed text and builtins. @comment xfail @example @@ -3877,7 +3883,7 @@ echo(`1', `long string') @result{}1,long string echo(defn(`changequote')) @error{}m4trace: -2- defn(`change...') -> <changequote> -@error{}m4trace: -1- echo(`') -> ``'' +@error{}m4trace: -1- echo(<changequote>) -> ``'' @result{} debuglen @result{}debuglen @@ -554,6 +554,10 @@ m4__push_symbol (m4 *context, m4_symbol_value *value, size_t level, bool inuse) return false; } } + else if (m4_is_symbol_value_func (value)) + { + /* TODO - use the builtin, rather than flattening it. */ + } else { /* For composite values, if argv is already in use, creating diff --git a/m4/m4module.h b/m4/m4module.h index 05bc7af5..0941d2be 100644 --- a/m4/m4module.h +++ b/m4/m4module.h @@ -46,10 +46,11 @@ typedef void m4_builtin_func (m4 *, m4_obstack *, size_t, m4_macro_args *); /* The value of m4_builtin flags is built from these: */ enum { - /* Set if macro can handle non-text tokens, such as builtin macro - tokens; if clear, non-text tokens are flattened to the empty - string before invoking the builtin. */ - M4_BUILTIN_GROKS_MACRO = (1 << 0), + /* Set if macro flattens non-text tokens, such as builtin macro + tokens, to the empty string prior to invoking the builtin; if + clear, non-text tokens must be transparently handled by the + builtin. May only be set if max_args is nonzero. */ + M4_BUILTIN_FLATTEN_ARGS = (1 << 0), /* Set if macro should only be recognized with arguments; may only be set if min_args is nonzero. */ M4_BUILTIN_BLIND = (1 << 1), @@ -89,29 +90,65 @@ struct m4_string_pair size_t len2; /* Second length. */ }; +/* Declare a prototype for the function "builtin_<NAME>". Note that + the function name includes any macro expansion of NAME. */ #define M4BUILTIN(name) \ static void CONC (builtin_, name) \ - (m4 *context, m4_obstack *obs, size_t argc, m4_macro_args *argv); + (m4 *, m4_obstack *, size_t, m4_macro_args *); +/* Begin the implementation of the function "builtin_<NAME>", + declaring parameter names that can be used by other helper macros + in this file. Note that the function name includes any macro + expansion of NAME. */ #define M4BUILTIN_HANDLER(name) \ static void CONC (builtin_, name) \ - (m4 *context, m4_obstack *obs, size_t argc, m4_macro_args *argv) + (m4 *context, m4_obstack *obs, size_t argc, m4_macro_args *argv) +/* Declare a prototype, then begin the implementation of the function + "<NAME>_LTX_m4_init_module", which will automatically be registered + as the initialization function for module NAME. Note that NAME is + intentionally used literally, rather than subjected to macro + expansion. */ #define M4INIT_HANDLER(name) \ - void CONC (name, CONC (_LTX_, m4_init_module)) \ - (m4 *context, m4_module *module, m4_obstack *obs); \ - void CONC (name, CONC (_LTX_, m4_init_module)) \ - (m4 *context, m4_module *module, m4_obstack *obs) - + void name ## _LTX_m4_init_module \ + (m4 *, m4_module *, m4_obstack *); \ + void name ## _LTX_m4_init_module \ + (m4 *context, m4_module *module, m4_obstack *obs) + +/* Declare a prototype, then begin the implementation of the function + "<NAME>_LTX_m4_init_module", which will automatically be registered + as the cleanup function for module NAME. Note that NAME is + intentionally used literally, rather than subjected to macro + expansion. */ #define M4FINISH_HANDLER(name) \ - void CONC (name, CONC (_LTX_, m4_finish_module)) \ - (m4 *context, m4_module *module, m4_obstack *obs); \ - void CONC (name, CONC (_LTX_, m4_finish_module)) \ - (m4 *context, m4_module *module, m4_obstack *obs) - + void name ## _LTX_m4_finish_module \ + (m4 *, m4_module *, m4_obstack *); \ + void name ## _LTX_m4_finish_module \ + (m4 *context, m4_module *module, m4_obstack *obs) + +/* Declare a variable S of type "<S>_func" to be a pointer to the + function named S imported from the module M, or NULL if the import + fails. Note that M and S are intentionally used literally rather + than subjected to macro expansion, in all but the variable name. */ #define M4_MODULE_IMPORT(M, S) \ - CONC (S, _func) *S = (CONC (S, _func) *) \ - m4_module_import (context, STR (M), STR (S), obs) + S ## _func *S = (S ## _func *) m4_module_import (context, #M, #S, obs) + +/* Build an entry in a builtin table, for the builtin N implemented by + the function "builtin_<N>" with name NAME. Build the flags from + the appropriate combination of M4_BUILTIN_FLAG_* based on M if the + builtin transparently supports macro tokens, B if it is blind, and + S if it has side effects. Specify that the builtin takes MIN and + MAX arguments. Note that N is subject to macro expansion, and that + NAME is generally used as #N to avoid clashes with builtins named + after a standard function that is defined as a macro. */ +#define M4BUILTIN_ENTRY(N, NAME, M, B, S, MIN, MAX) \ + { \ + CONC (builtin_, N), NAME, \ + (((!(M) && (MAX)) ? M4_BUILTIN_FLATTEN_ARGS : 0) \ + | (((B) && (MIN)) ? M4_BUILTIN_BLIND : 0) \ + | (((S) && (MIN)) ? M4_BUILTIN_SIDE_EFFECT : 0)), \ + MIN, MAX \ + }, /* Grab the text contents of argument I, or abort if the argument is not text. Assumes that `m4 *context' and `m4_macro_args *argv' are @@ -252,7 +289,7 @@ extern bool m4_symbol_value_print (m4 *, m4_symbol_value *, m4_obstack *, extern void m4_symbol_print (m4 *, m4_symbol *, m4_obstack *, const m4_string_pair *, bool, size_t, bool); -extern bool m4_symbol_value_groks_macro (m4_symbol_value *); +extern bool m4_symbol_value_flatten_args (m4_symbol_value *); #define m4_is_symbol_void(symbol) \ (m4_is_symbol_value_void (m4_get_symbol_value (symbol))) @@ -272,8 +309,8 @@ extern bool m4_symbol_value_groks_macro (m4_symbol_value *); (m4_get_symbol_value_builtin (m4_get_symbol_value (symbol))) #define m4_get_symbol_placeholder(symbol) \ (m4_get_symbol_value_placeholder (m4_get_symbol_value (symbol))) -#define m4_symbol_groks_macro(symbol) \ - (m4_symbol_value_groks_macro (m4_get_symbol_value (symbol))) +#define m4_symbol_flatten_args(symbol) \ + (m4_symbol_value_flatten_args (m4_get_symbol_value (symbol))) extern m4_symbol_value *m4_symbol_value_create (void); extern void m4_symbol_value_delete (m4_symbol_value *); diff --git a/m4/m4private.h b/m4/m4private.h index c6cc639e..65bcbe09 100644 --- a/m4/m4private.h +++ b/m4/m4private.h @@ -366,8 +366,8 @@ extern void m4__push_arg_quote (m4 *, m4_obstack *, m4_macro_args *, # define m4_get_symbol_value_builtin(V) (&(V)->u.builtin->builtin) # define m4_get_symbol_value_placeholder(V) \ ((V)->u.u_t.text) -# define m4_symbol_value_groks_macro(V) (BIT_TEST ((V)->flags, \ - VALUE_MACRO_ARGS_BIT)) +# 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), \ @@ -389,7 +389,7 @@ extern void m4__push_arg_quote (m4 *, m4_obstack *, m4_macro_args *, m4_builtin.flags to m4_symbol_arg.flags. We can use additional bits for private use. */ -#define VALUE_MACRO_ARGS_BIT (1 << 0) +#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) @@ -584,17 +584,14 @@ collect_arguments (m4 *context, const char *name, size_t len, m4_symbol_value token; m4_symbol_value *tokenp; bool more_args; - bool groks_macro_args; m4_macro_args args; m4_macro_args *argv; - groks_macro_args = BIT_TEST (SYMBOL_FLAGS (symbol), VALUE_MACRO_ARGS_BIT); - args.argc = 1; args.inuse = false; args.wrapper = false; args.has_ref = false; - args.flatten = !groks_macro_args; + args.flatten = m4_symbol_flatten_args (symbol); args.has_func = false; /* Must copy here, since we are consuming tokens, and since symbol table can be changed during argument collection. */ @@ -618,7 +615,7 @@ collect_arguments (m4 *context, const char *name, size_t len, if ((m4_is_symbol_value_text (tokenp) && !m4_get_symbol_value_len (tokenp)) - || (!groks_macro_args && m4_is_symbol_value_func (tokenp))) + || (args.flatten && m4_is_symbol_value_func (tokenp))) { obstack_free (arguments, tokenp); tokenp = &empty_symbol; diff --git a/m4/module.c b/m4/module.c index 4b157005..2bda5f61 100644 --- a/m4/module.c +++ b/m4/module.c @@ -451,6 +451,8 @@ m4__module_open (m4 *context, const char *name, m4_obstack *obs) assert (bp->min_args > 0 || (bp->flags & (M4_BUILTIN_BLIND | M4_BUILTIN_SIDE_EFFECT)) == 0); + assert (bp->max_args + || (bp->flags & M4_BUILTIN_FLATTEN_ARGS) == 0); assert ((bp->flags & ~M4_BUILTIN_FLAGS_MASK) == 0); memcpy (&builtin->builtin, bp, sizeof *bp); diff --git a/m4/symtab.c b/m4/symtab.c index 8b68132a..995495f7 100644 --- a/m4/symtab.c +++ b/m4/symtab.c @@ -711,12 +711,12 @@ m4_get_symbol_traced (m4_symbol *symbol) return symbol->traced; } -#undef m4_symbol_value_groks_macro +#undef m4_symbol_value_flatten_args bool -m4_symbol_value_groks_macro (m4_symbol_value *value) +m4_symbol_value_flatten_args (m4_symbol_value *value) { assert (value); - return BIT_TEST (value->flags, VALUE_MACRO_ARGS_BIT); + return BIT_TEST (value->flags, VALUE_FLATTEN_ARGS_BIT); } #undef m4_get_symbol_value diff --git a/modules/gnu.c b/modules/gnu.c index b4c36afc..d34cb4ba 100644 --- a/modules/gnu.c +++ b/modules/gnu.c @@ -61,7 +61,7 @@ /* Generate prototypes for each builtin handler function. */ -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler) +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler) builtin_functions #undef BUILTIN @@ -69,12 +69,9 @@ /* Generate a table for mapping m4 symbol names to handler functions. */ m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) + builtin_functions #undef BUILTIN @@ -448,7 +445,7 @@ M4BUILTIN_HANDLER (builtin) (bp->flags & M4_BUILTIN_SIDE_EFFECT) != 0)) { m4_macro_args *new_argv; - bool flatten = (bp->flags & M4_BUILTIN_GROKS_MACRO) == 0; + bool flatten = (bp->flags & M4_BUILTIN_FLATTEN_ARGS) != 0; new_argv = m4_make_argv_ref (context, argv, name, M4ARGLEN (1), true, flatten); bp->func (context, obs, argc - 1, new_argv); @@ -683,9 +680,8 @@ M4BUILTIN_HANDLER (indir) else { m4_macro_args *new_argv; - bool flatten = !m4_symbol_groks_macro (symbol); new_argv = m4_make_argv_ref (context, argv, name, M4ARGLEN (1), - true, flatten); + true, m4_symbol_flatten_args (symbol)); m4_macro_call (context, m4_get_symbol_value (symbol), obs, argc - 1, new_argv); } diff --git a/modules/import.c b/modules/import.c index 93b197d5..8b5fc055 100644 --- a/modules/import.c +++ b/modules/import.c @@ -1,5 +1,5 @@ /* GNU m4 -- A simple macro processor - Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of GNU M4. @@ -36,18 +36,14 @@ BUILTIN (symbol_fail, false, false, false, 0, 1) \ BUILTIN (module_fail, false, false, false, 0, 1) \ -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler) +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler) builtin_functions #undef BUILTIN m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) builtin_functions #undef BUILTIN diff --git a/modules/load.c b/modules/load.c index 5ea72424..e169796a 100644 --- a/modules/load.c +++ b/modules/load.c @@ -42,7 +42,7 @@ /* Generate prototypes for each builtin handler function. */ -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler) +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler) builtin_functions #undef BUILTIN @@ -50,12 +50,9 @@ /* Generate a table for mapping m4 symbol names to handler functions. */ m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) + builtin_functions #undef BUILTIN diff --git a/modules/m4.c b/modules/m4.c index f5f07665..ca37befb 100644 --- a/modules/m4.c +++ b/modules/m4.c @@ -55,10 +55,6 @@ extern const char *m4_expand_ranges (const char *s, m4_obstack *obs); extern void m4_make_temp (m4 *context, m4_obstack *obs, const char *macro, const char *name, size_t len, bool dir); -/* stdlib--.h defines mkstemp to a safer replacement, but this - interferes with our preprocessor table of builtin definitions. */ -#undef mkstemp - /* Maintain each of the builtins implemented in this modules along with their details in a single table for easy maintenance. @@ -121,12 +117,9 @@ static void numb_obstack (m4_obstack *obs, number value, /* Generate a table for mapping m4 symbol names to handler functions. */ m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC (builtin_, handler), STR (handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) + builtin_functions #undef BUILTIN diff --git a/modules/modtest.c b/modules/modtest.c index f2d39eac..ab23f5f6 100644 --- a/modules/modtest.c +++ b/modules/modtest.c @@ -40,18 +40,14 @@ extern bool export_test (const char *foo); #define builtin_functions \ BUILTIN (test, false, false, false, 0, 0) -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler) +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler) builtin_functions #undef BUILTIN m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) builtin_functions #undef BUILTIN diff --git a/modules/mpeval.c b/modules/mpeval.c index ab9a040f..7bd2139b 100644 --- a/modules/mpeval.c +++ b/modules/mpeval.c @@ -100,7 +100,7 @@ #define numb_decr(n) numb_minus (n, numb_ONE) /* Generate prototypes for each builtin handler function. */ -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler) +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler) builtin_functions #undef BUILTIN @@ -109,11 +109,8 @@ m4_builtin m4_builtin_table[] = { #define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) + builtin_functions #undef BUILTIN diff --git a/modules/perl.c b/modules/perl.c index 61db8032..811a114b 100644 --- a/modules/perl.c +++ b/modules/perl.c @@ -48,12 +48,8 @@ m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC (builtin_, handler), STR (handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) builtin_functions #undef BUILTIN diff --git a/modules/shadow.c b/modules/shadow.c index 1a15798f..db8515ed 100644 --- a/modules/shadow.c +++ b/modules/shadow.c @@ -38,18 +38,14 @@ BUILTIN (test, false, false, false, 0, -1 ) \ -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler) +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler) builtin_functions #undef BUILTIN m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) builtin_functions #undef BUILTIN diff --git a/modules/stdlib.c b/modules/stdlib.c index 0849d3d1..c24fa2b9 100644 --- a/modules/stdlib.c +++ b/modules/stdlib.c @@ -57,18 +57,14 @@ BUILTIN (uname, false, false, false, 0, 0 ) \ -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler); +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler); builtin_functions #undef BUILTIN m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) builtin_functions #undef BUILTIN diff --git a/modules/time.c b/modules/time.c index 9807ae06..4febc8c5 100644 --- a/modules/time.c +++ b/modules/time.c @@ -1,5 +1,6 @@ /* GNU m4 -- A simple macro processor - Copyright (C) 1999, 2000, 2001, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2006, 2007, 2008 Free Software + Foundation, Inc. This file is part of GNU M4. @@ -50,7 +51,7 @@ BUILTIN (strftime, false, true, false, 2, 2 ) \ -#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN(handler) +#define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler) builtin_functions # if HAVE_MKTIME mktime_functions @@ -62,12 +63,8 @@ m4_builtin m4_builtin_table[] = { -#define BUILTIN(handler, macros, blind, side, min, max) \ - { CONC(builtin_, handler), STR(handler), \ - ((macros ? M4_BUILTIN_GROKS_MACRO : 0) \ - | (blind ? M4_BUILTIN_BLIND : 0) \ - | (side ? M4_BUILTIN_SIDE_EFFECT : 0)), \ - min, max }, +#define BUILTIN(handler, macros, blind, side, min, max) \ + M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max) builtin_functions # if HAVE_MKTIME |