[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 10-gary-refactor-hash-apply.patch
From: |
Gary V. Vaughan |
Subject: |
FYI: 10-gary-refactor-hash-apply.patch |
Date: |
Fri, 13 Jun 2003 15:09:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030529 |
Applied to HEAD.
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____
/ )= GNU Hacker http://www.gnu.org/software/(libtool|m4) \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/
Index: ChangeLog
from Gary V. Vaughan <address@hidden>
* m4/hash.c (m4_hash_apply): Pass an initial hash table parameter
to the callback. Callbacks should not need to hardcode the
hashtable they are working from, nor should we have to waste the
userdata parameter to pass the table in.
* m4/hash.h (m4_hash_apply_func): Require the initial table
parameter.
* m4/symtab.c (symtab_destroy): Use the passed table instead
of hardcoding m4__symtab.
(m4_symbol_popdef): Don't use the userdata parameter to pass the
table to arg_destroy.
(arg_destroy): Use the hash parameter, ignore userdata.
* modules/m4.c (set_trace): Make it fit the m4_hash_apply_func
prototype.
(traceon, traceoff): Call set_trace with the extra initial
parameter.
2003-06-13 Gary V. Vaughan <address@hidden>
Index: m4/hash.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/hash.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 hash.c
--- m4/hash.c 6 Jun 2003 16:14:05 -0000 1.8
+++ m4/hash.c 13 Jun 2003 13:53:58 -0000
@@ -518,7 +518,7 @@ m4_hash_apply (m4_hash *hash, m4_hash_ap
while ((place = m4_hash_iterator_next (hash, place)))
{
- result = (*func) (m4_hash_iterator_key (place),
+ result = (*func) (hash, m4_hash_iterator_key (place),
m4_hash_iterator_value (place), data);
if (result != 0)
Index: m4/hash.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/hash.h,v
retrieving revision 1.7
diff -u -p -u -r1.7 hash.h
--- m4/hash.h 6 Jun 2003 16:14:05 -0000 1.7
+++ m4/hash.h 13 Jun 2003 13:53:58 -0000
@@ -55,7 +55,8 @@ int m4_hash_string_cmp (const void *ke
typedef struct m4_hash_iterator m4_hash_iterator;
-typedef int m4_hash_apply_func (const void *key, void *value, void *data);
+typedef int m4_hash_apply_func (m4_hash *hash, const void *key, void *value,
+ void *userdata);
m4_hash_iterator * m4_hash_iterator_next (const m4_hash *hash,
m4_hash_iterator *place);
@@ -64,7 +65,7 @@ void * m4_hash_iterator_value (m4_hash
int m4_hash_apply (m4_hash *hash,
m4_hash_apply_func *func,
- void *data);
+ void *userdata);
END_C_DECLS
Index: m4/m4module.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/m4module.h,v
retrieving revision 1.44
diff -u -p -u -r1.44 m4module.h
--- m4/m4module.h 13 Jun 2003 13:05:45 -0000 1.44
+++ m4/m4module.h 13 Jun 2003 13:53:58 -0000
@@ -75,7 +75,7 @@ extern m4_macro *m4_module_macros (
typedef struct m4_symtab m4_symtab;
-typedef int m4_symtab_apply_func (const void *key, void *value, void *data);
+typedef int m4_symtab_apply_func (m4_hash *hash, const void *key, void *value,
void *data);
extern int m4_symtab_apply (m4_symtab_apply_func*, void*);
Index: m4/symtab.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/symtab.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 symtab.c
--- m4/symtab.c 13 Jun 2003 13:05:45 -0000 1.33
+++ m4/symtab.c 13 Jun 2003 13:53:58 -0000
@@ -44,10 +44,10 @@
#define M4_SYMTAB_DEFAULT_SIZE 2047
-static int symbol_destroy (const void *name, void *symbol,
- void *ignored);
-static int arg_destroy (const void *name, void *arg,
- void *arg_signature);
+static int symbol_destroy (m4_hash *hash, const void *name,
+ void *symbol, void *ignored);
+static int arg_destroy (m4_hash *hash, const void *name,
+ void *arg, void *ignored);
/* Pointer to symbol table. */
m4_hash *m4__symtab = 0;
@@ -122,13 +122,13 @@ m4__symtab_exit (void)
on every symbol so that m4_symbol_popdef() doesn't try to preserve
the table entry. */
static int
-symbol_destroy (const void *name, void *symbol, void *ignored)
+symbol_destroy (m4_hash *hash, const void *name, void *symbol, void *ignored)
{
char *key = xstrdup ((char *) name);
SYMBOL_TRACED ((m4_symbol *) symbol) = FALSE;
- while (key && m4_hash_lookup (m4__symtab, key))
+ while (key && m4_hash_lookup (hash, key))
m4_symbol_popdef (key);
XFREE (key);
@@ -218,8 +218,7 @@ m4_symbol_popdef (const char *name)
if (TOKEN_ARG_SIGNATURE (stale))
{
- m4_hash_apply (TOKEN_ARG_SIGNATURE (stale),
- arg_destroy, TOKEN_ARG_SIGNATURE (stale));
+ m4_hash_apply (TOKEN_ARG_SIGNATURE (stale), arg_destroy, NULL);
m4_hash_delete (TOKEN_ARG_SIGNATURE (stale));
}
if (TOKEN_TYPE (stale) == M4_TOKEN_TEXT)
@@ -241,17 +240,17 @@ m4_symbol_popdef (const char *name)
/* Callback used by m4_symbol_popdef () to release the memory used
by values in the arg_signature hash. */
static int
-arg_destroy (const void *name, void *arg, void *arg_signature)
+arg_destroy (m4_hash *hash, const void *name, void *arg, void *ignored)
{
struct m4_token_arg *token_arg = (struct m4_token_arg *) arg;
assert (name);
- assert (arg_signature);
+ assert (hash);
if (TOKEN_ARG_DEFAULT (token_arg))
XFREE (TOKEN_ARG_DEFAULT (token_arg));
xfree (token_arg);
- xfree (m4_hash_remove ((m4_hash *) arg_signature, (const char *) name));
+ xfree (m4_hash_remove (hash, (const char *) name));
return 0;
}
@@ -408,9 +407,9 @@ symtab_print_list (const void *name, voi
faster macro version from m4private.h. */
#undef m4_symtab_apply
int
-m4_symtab_apply (m4_symtab_apply_func *func, void *data)
+m4_symtab_apply (m4_symtab_apply_func *func, void *userdata)
{
- return m4_hash_apply (m4__symtab, (m4_hash_apply_func *) func, data);
+ return m4_hash_apply (m4__symtab, (m4_hash_apply_func *) func, userdata);
}
/* Pop all values from the symbol associated with NAME. */
Index: modules/m4.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/m4.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 m4.c
--- modules/m4.c 13 Jun 2003 13:05:46 -0000 1.37
+++ modules/m4.c 13 Jun 2003 13:53:58 -0000
@@ -94,8 +94,8 @@ typedef unsigned long int unumber;
static void include (int argc, m4_token **argv,
boolean silent);
-static int set_trace (const void *ignored, void *symbol,
- void *data);
+static int set_trace (m4_hash *hash, const void *ignored,
+ void *symbol, void *userdata);
static const char *ntoa (number value, int radix);
static void numb_obstack (struct obstack *obs, const number value,
const int radix, int min);
@@ -582,9 +582,10 @@ M4BUILTIN_HANDLER (m4wrap)
tracing of a macro. It disables tracing if DATA is NULL, otherwise it
enable tracing. */
static int
-set_trace (const void *ignored, void *symbol, void *data)
+set_trace (m4_hash *hash, const void *ignored, void *symbol,
+ void *userdata)
{
- SYMBOL_TRACED ((m4_symbol *) symbol) = (boolean) (data != NULL);
+ SYMBOL_TRACED ((m4_symbol *) symbol) = (boolean) (userdata != NULL);
return 0;
}
@@ -600,7 +601,7 @@ M4BUILTIN_HANDLER (traceon)
const char *name = M4ARG (i);
m4_symbol *symbol = m4_symbol_lookup (name);
if (symbol != NULL)
- set_trace (name, symbol, (char *) obs);
+ set_trace (NULL, NULL, symbol, (char *) obs);
else
M4WARN ((warning_status, 0,
_("Warning: %s: undefined name: %s"), M4ARG (0), name));
@@ -620,7 +621,7 @@ M4BUILTIN_HANDLER (traceoff)
const char *name = M4ARG (i);
m4_symbol *symbol = m4_symbol_lookup (name);
if (symbol != NULL)
- set_trace (name, symbol, NULL);
+ set_trace (NULL, NULL, symbol, NULL);
else
M4WARN ((warning_status, 0,
_("Warning: %s: undefined name: %s"), M4ARG (0), name));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: 10-gary-refactor-hash-apply.patch,
Gary V. Vaughan <=