summaryrefslogtreecommitdiff
path: root/m4/module.c
diff options
context:
space:
mode:
authorGary V. Vaughan <gary@gnu.org>2003-06-17 15:17:45 +0000
committerEric Blake <ebb9@byu.net>2007-10-05 21:58:36 -0600
commitf8a2482e5d923aef2935407199ebb98e396e04aa (patch)
tree58cdb1c48cb35eb803e2ee4a6e99be76cab12bbc /m4/module.c
parent54070bf3cbb42d625c876f5d903257774f00f244 (diff)
downloadm4-f8a2482e5d923aef2935407199ebb98e396e04aa.tar.gz
Still refactoring furiously. This delta represents a change in
semantics to symtab.c. Instead of building temporary m4_tokens in the caller, and copying fields in the methods, we now create the actual m4_token for hashing in the caller so the methods just slot them in directly. Also, this means that we don't lookup a symbol and get back an allocated but VOID token to copy fields into, we create the token we want to push and pass that to m4_symbol_define or m4_symbol_pushdef. And that's it. There are a few other small changes to stop knowledge of the implementation of symtab.c leaking out into other files. * m4/macro.c (expand_argument): Comment typo corrected. * m4/symtab.c (symtab_fetch): New function to fetch the address of an interned symbol. (m4_symbol_pushdef): Take an extra value parameter and use this directly as the new top of the value stack. All callers changed to build a token and pass responsibility for memory in, rather than copying as we used to. (m4_symbol_define): Also use the new value parameter directly as a replacement for the top of the value stack. All callers changed to build a token as above. (m4_set_symbol_traced): New function to set the traced bit on the named symbol, creating it if necessary. (symbol_popval): The guts of the old m4_symbol_popdef. (m4_symbol_popdef): Use it. * m4/builtin.c (m4_symbol_set_token): Removed, (m4__symbol_set_builtin, m4__symbol_set_macro): Removed and replaced... * m4/module.c (m4_set_module_builtin_table) (m4_set_module_macro_table): ...with these more orthogonal functions. * m4/m4module.h (m4_macro_pushdef, m4_macro_define) (m4_builtin_pushdef, m4_builtin_define): Removed. No longer required. * m4/builtin.c (M4_ARG_SIGNATURE_DEFAULT_SIZE) (m4_arg_signature_parse): Moved... * m4/symtab.c: ...to here. * m4/input.c (m4_token_copy): Arghh... I'm amazed this didn't screw something up. Moved... * m4/symtab.c (m4_token_copy): ...to here, and fixed so that it actually does a proper deep copy of source to dest.
Diffstat (limited to 'm4/module.c')
-rw-r--r--m4/module.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/m4/module.c b/m4/module.c
index 5fb41d1f..2b9c2356 100644
--- a/m4/module.c
+++ b/m4/module.c
@@ -121,19 +121,25 @@ m4_set_module_builtin_table (m4 *context, lt_dlhandle handle,
const m4_builtin *table)
{
const m4_builtin *bp;
- m4_token token;
assert (handle);
assert (table);
- bzero (&token, sizeof (m4_token));
- TOKEN_TYPE (&token) = M4_TOKEN_FUNC;
- TOKEN_HANDLE (&token) = handle;
-
for (bp = table; bp->name != NULL; bp++)
{
- int flags = 0;
- char *name;
+ m4_token *token = XCALLOC (m4_token, 1);
+ char * name;
+
+ TOKEN_TYPE (token) = M4_TOKEN_FUNC;
+ TOKEN_FUNC (token) = bp->func;
+ TOKEN_HANDLE (token) = handle;
+ TOKEN_MIN_ARGS (token) = bp->min_args;
+ TOKEN_MAX_ARGS (token) = bp->max_args;
+
+ if (bp->groks_macro_args)
+ BIT_SET (TOKEN_FLAGS (token), TOKEN_MACRO_ARGS_BIT);
+ if (bp->blind_if_no_args)
+ BIT_SET (TOKEN_FLAGS (token), TOKEN_BLIND_ARGS_BIT);
if (prefix_all_builtins)
{
@@ -146,15 +152,8 @@ m4_set_module_builtin_table (m4 *context, lt_dlhandle handle,
else
name = (char *) bp->name;
- if (bp->groks_macro_args) BIT_SET (flags, TOKEN_MACRO_ARGS_BIT);
- if (bp->blind_if_no_args) BIT_SET (flags, TOKEN_BLIND_ARGS_BIT);
-
- TOKEN_FUNC (&token) = bp->func;
- TOKEN_FLAGS (&token) = flags;
- TOKEN_MIN_ARGS (&token) = bp->min_args;
- TOKEN_MAX_ARGS (&token) = bp->max_args;
- m4_builtin_pushdef (context, name, &token);
+ m4_symbol_pushdef (M4SYMTAB, name, token);
if (prefix_all_builtins)
xfree (name);
@@ -174,19 +173,20 @@ m4_get_module_macro_table (lt_dlhandle handle)
}
void
-m4_set_module_macro_table (m4 *context, lt_dlhandle handle, const m4_macro *table)
+m4_set_module_macro_table (m4 *context, lt_dlhandle handle,
+ const m4_macro *table)
{
const m4_macro *mp;
- m4_token token;
-
- bzero (&token, sizeof (m4_token));
- TOKEN_TYPE (&token) = M4_TOKEN_TEXT;
- TOKEN_HANDLE (&token) = handle;
for (mp = table; mp->name != NULL; mp++)
{
- TOKEN_TEXT (&token) = (char *) mp->value;
- m4_macro_pushdef (context, mp->name, &token);
+ m4_token *token = XCALLOC (m4_token, 1);
+
+ TOKEN_TYPE (token) = M4_TOKEN_TEXT;
+ TOKEN_TEXT (token) = xstrdup (mp->value);
+ TOKEN_HANDLE (token) = handle;
+
+ m4_symbol_pushdef (M4SYMTAB, mp->name, token);
}
}