44 |
|
|
45 |
#define M4_SYMTAB_DEFAULT_SIZE 2047 |
#define M4_SYMTAB_DEFAULT_SIZE 2047 |
46 |
|
|
47 |
static int symbol_destroy (const void *name, void *symbol, |
static int symbol_destroy (m4_hash *hash, const void *name, |
48 |
void *ignored); |
void *symbol, void *ignored); |
49 |
static int arg_destroy (const void *name, void *arg, |
static int arg_destroy (m4_hash *hash, const void *name, |
50 |
void *arg_signature); |
void *arg, void *ignored); |
51 |
|
|
52 |
/* Pointer to symbol table. */ |
/* Pointer to symbol table. */ |
53 |
m4_hash *m4__symtab = 0; |
m4_hash *m4__symtab = 0; |
122 |
on every symbol so that m4_symbol_popdef() doesn't try to preserve |
on every symbol so that m4_symbol_popdef() doesn't try to preserve |
123 |
the table entry. */ |
the table entry. */ |
124 |
static int |
static int |
125 |
symbol_destroy (const void *name, void *symbol, void *ignored) |
symbol_destroy (m4_hash *hash, const void *name, void *symbol, void *ignored) |
126 |
{ |
{ |
127 |
char *key = xstrdup ((char *) name); |
char *key = xstrdup ((char *) name); |
128 |
|
|
129 |
SYMBOL_TRACED ((m4_symbol *) symbol) = FALSE; |
SYMBOL_TRACED ((m4_symbol *) symbol) = FALSE; |
130 |
|
|
131 |
while (key && m4_hash_lookup (m4__symtab, key)) |
while (key && m4_hash_lookup (hash, key)) |
132 |
m4_symbol_popdef (key); |
m4_symbol_popdef (key); |
133 |
|
|
134 |
XFREE (key); |
XFREE (key); |
218 |
|
|
219 |
if (TOKEN_ARG_SIGNATURE (stale)) |
if (TOKEN_ARG_SIGNATURE (stale)) |
220 |
{ |
{ |
221 |
m4_hash_apply (TOKEN_ARG_SIGNATURE (stale), |
m4_hash_apply (TOKEN_ARG_SIGNATURE (stale), arg_destroy, NULL); |
|
arg_destroy, TOKEN_ARG_SIGNATURE (stale)); |
|
222 |
m4_hash_delete (TOKEN_ARG_SIGNATURE (stale)); |
m4_hash_delete (TOKEN_ARG_SIGNATURE (stale)); |
223 |
} |
} |
224 |
if (TOKEN_TYPE (stale) == M4_TOKEN_TEXT) |
if (TOKEN_TYPE (stale) == M4_TOKEN_TEXT) |
240 |
/* Callback used by m4_symbol_popdef () to release the memory used |
/* Callback used by m4_symbol_popdef () to release the memory used |
241 |
by values in the arg_signature hash. */ |
by values in the arg_signature hash. */ |
242 |
static int |
static int |
243 |
arg_destroy (const void *name, void *arg, void *arg_signature) |
arg_destroy (m4_hash *hash, const void *name, void *arg, void *ignored) |
244 |
{ |
{ |
245 |
struct m4_token_arg *token_arg = (struct m4_token_arg *) arg; |
struct m4_token_arg *token_arg = (struct m4_token_arg *) arg; |
246 |
|
|
247 |
assert (name); |
assert (name); |
248 |
assert (arg_signature); |
assert (hash); |
249 |
|
|
250 |
if (TOKEN_ARG_DEFAULT (token_arg)) |
if (TOKEN_ARG_DEFAULT (token_arg)) |
251 |
XFREE (TOKEN_ARG_DEFAULT (token_arg)); |
XFREE (TOKEN_ARG_DEFAULT (token_arg)); |
252 |
xfree (token_arg); |
xfree (token_arg); |
253 |
xfree (m4_hash_remove ((m4_hash *) arg_signature, (const char *) name)); |
xfree (m4_hash_remove (hash, (const char *) name)); |
254 |
|
|
255 |
return 0; |
return 0; |
256 |
} |
} |
407 |
faster macro version from m4private.h. */ |
faster macro version from m4private.h. */ |
408 |
#undef m4_symtab_apply |
#undef m4_symtab_apply |
409 |
int |
int |
410 |
m4_symtab_apply (m4_symtab_apply_func *func, void *data) |
m4_symtab_apply (m4_symtab_apply_func *func, void *userdata) |
411 |
{ |
{ |
412 |
return m4_hash_apply (m4__symtab, (m4_hash_apply_func *) func, data); |
return m4_hash_apply (m4__symtab, (m4_hash_apply_func *) func, userdata); |
413 |
} |
} |
414 |
|
|
415 |
/* Pop all values from the symbol associated with NAME. */ |
/* Pop all values from the symbol associated with NAME. */ |