[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 19-gary-revert-15-gary-cleanup-from-renaming-token-data-to-symbol.p
From: |
Gary V. Vaughan |
Subject: |
FYI: 19-gary-revert-15-gary-cleanup-from-renaming-token-data-to-symbol.patch |
Date: |
Sun, 30 Sep 2001 15:50:05 +0100 |
User-agent: |
Mutt/1.3.22.1i |
Index: ChangeLog
from Gary V. Vaughan <address@hidden>
Reverted my large patch for removing the old m4_symbol
structure on 2001-09-20. We are still not happy about the way
trace works in conjunction with defn and undefine, and leaving
the reverted patch active prevents us from moving the traced
bit from the definition back to the symbol.
2001-09-30 Gary V. Vaughan <address@hidden>
Index: m4/debug.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/debug.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 debug.c
--- m4/debug.c 2001/09/20 03:48:05 1.6
+++ m4/debug.c 2001/09/30 14:40:24
@@ -44,12 +44,6 @@ m4_debug_init (void)
obstack_init (&trace);
}
-void
-m4_debug_exit (void)
-{
- obstack_free (&trace, NULL);
-}
-
/* Function to decode the debugging flags OPTS. Used by main while
@@ -326,7 +320,7 @@ m4_trace_prepre (const char *name, int i
/* Format the parts of a trace line, that can be made before the macro is
actually expanded. Used from expand_macro (). */
void
-m4_trace_pre (const char *name, int id, int argc, m4_symbol **argv)
+m4_trace_pre (const char *name, int id, int argc, m4_token_data **argv)
{
int i;
const m4_builtin *bp;
@@ -343,14 +337,14 @@ m4_trace_pre (const char *name, int id,
if (i != 1)
m4_trace_format (", ");
- switch (M4_SYMBOL_TYPE (argv[i]))
+ switch (M4_TOKEN_DATA_TYPE (argv[i]))
{
case M4_TOKEN_TEXT:
- m4_trace_format ("%l%S%r", M4_SYMBOL_TEXT (argv[i]));
+ m4_trace_format ("%l%S%r", M4_TOKEN_DATA_TEXT (argv[i]));
break;
case M4_TOKEN_FUNC:
- bp = m4_builtin_find_by_func (NULL, M4_SYMBOL_FUNC (argv[i]));
+ bp = m4_builtin_find_by_func (NULL, M4_TOKEN_DATA_FUNC(argv[i]));
if (bp == NULL)
{
M4ERROR ((warning_status, 0, _("\
@@ -380,7 +374,7 @@ INTERNAL ERROR: Bad token data type (m4_
/* Format the final part of a trace line and print it all. Used from
expand_macro (). */
void
-m4_trace_post (const char *name, int id, int argc, m4_symbol **argv,
+m4_trace_post (const char *name, int id, int argc, m4_token_data **argv,
const char *expanded)
{
if (debug_level & M4_DEBUG_TRACE_CALL)
Index: m4/hash.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/hash.c,v
retrieving revision 1.3
diff -u -p -u -r1.3 hash.c
--- m4/hash.c 2001/09/20 03:48:05 1.3
+++ m4/hash.c 2001/09/30 14:40:25
@@ -271,9 +271,8 @@ m4_hash_remove (m4_hash *hash, const voi
/* Return the address of the value field of the first node in
HASH that has a matching KEY. The address is returned so that
- an explicit 0 value can be distinguished from a failed lookup
- (also 0). Fortuitously for M4, this also means that the value
- field can be changed `in situ' to implement a value stack. */
+ an explicit 0 value can be distinguihed from a failed lookup
+ (also 0). */
void **
m4_hash_lookup (m4_hash *hash, const void *key)
{
@@ -364,17 +363,6 @@ m4_hash_bucket_insert (m4_hash *hash, m4
while (bucket);
}
-void
-m4_hash_exit (void)
-{
- while (m4_hash_node_free_list)
- {
- m4_hash_node *stale = m4_hash_node_free_list;
- m4_hash_node_free_list = M4_HASH_NODE_NEXT (stale);
- xfree (stale);
- }
-}
-
struct m4_hash_iterator
@@ -460,10 +448,10 @@ m4_hash_iterator_key (m4_hash_iterator *
return M4_HASH_NODE_KEY (M4_ITERATOR_PLACE (place));
}
-void **
+void *
m4_hash_iterator_value (m4_hash_iterator *place)
{
assert (place);
- return &M4_HASH_NODE_VAL (M4_ITERATOR_PLACE (place));
+ return M4_HASH_NODE_VAL (M4_ITERATOR_PLACE (place));
}
Index: m4/hash.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/hash.h,v
retrieving revision 1.2
diff -u -p -u -r1.2 hash.h
--- m4/hash.h 2001/09/20 03:48:05 1.2
+++ m4/hash.h 2001/09/30 14:40:25
@@ -44,15 +44,15 @@ void m4_hash_insert (m4_hash *hash, con
void * m4_hash_remove (m4_hash *hash, const void *key);
void ** m4_hash_lookup (m4_hash *hash, const void *key);
size_t m4_hash_length (m4_hash *hash);
-void m4_hash_exit (void);
+
typedef struct m4_hash_iterator m4_hash_iterator;
m4_hash_iterator * m4_hash_iterator_next (const m4_hash *hash,
m4_hash_iterator *place);
const void * m4_hash_iterator_key (m4_hash_iterator *place);
-void ** m4_hash_iterator_value (m4_hash_iterator
*place);
+void * m4_hash_iterator_value (m4_hash_iterator *place);
END_C_DECLS
Index: m4/input.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/input.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 input.c
--- m4/input.c 2001/09/20 03:48:05 1.11
+++ m4/input.c 2001/09/30 14:40:27
@@ -142,7 +142,7 @@ static int file_peek (void);
static int file_read (void);
static void file_unget (int ch);
static void file_clean (void);
-static void init_macro_token (m4_symbol *symbol);
+static void init_macro_token (m4_token_data *td);
static int macro_peek (void);
static int macro_read (void);
static int match_input (const unsigned char *s);
@@ -594,7 +594,7 @@ m4_pop_wrapup (void)
/* When a MACRO token is seen, next_token () uses init_macro_token
to retrieve the value of the function pointer. */
static void
-init_macro_token (m4_symbol *symbol)
+init_macro_token (m4_token_data *td)
{
if (isp->funcs->read_func != macro_read)
{
@@ -603,10 +603,10 @@ init_macro_token (m4_symbol *symbol)
abort ();
}
- M4_SYMBOL_TYPE (symbol) = M4_TOKEN_FUNC;
- M4_SYMBOL_FUNC (symbol) = isp->u.u_m.func;
- M4_SYMBOL_HANDLE (symbol) = isp->u.u_m.handle;
- M4_SYMBOL_TRACED (symbol) = isp->u.u_m.traced;
+ M4_TOKEN_DATA_TYPE (td) = M4_TOKEN_FUNC;
+ M4_TOKEN_DATA_FUNC (td) = isp->u.u_m.func;
+ M4_TOKEN_DATA_HANDLE (td) = isp->u.u_m.handle;
+ M4_TOKEN_TRACED (td) = isp->u.u_m.traced;
}
@@ -794,18 +794,6 @@ m4_input_init (void)
}
void
-m4_input_exit (void)
-{
- XFREE (lquote.string);
- XFREE (rquote.string);
- XFREE (bcomm.string);
- XFREE (ecomm.string);
- obstack_free (&wrapup_stack, NULL);
- obstack_free (&input_stack, NULL);
- obstack_free (&token_stack, NULL);
-}
-
-void
m4_syntax_init (void)
{
int ch;
@@ -1009,7 +997,7 @@ m4_set_syntax (char key, const unsigned
The storage pointed to by the fields in TD is therefore subject to
change the next time next_token () is called. */
m4_token_t
-m4_next_token (m4_symbol *symbol)
+m4_next_token (m4_token_data *td)
{
int ch;
int quote_level;
@@ -1031,10 +1019,10 @@ m4_next_token (m4_symbol *symbol)
if (ch == CHAR_MACRO) /* MACRO TOKEN */
{
- init_macro_token (symbol);
+ init_macro_token (td);
(void) next_char ();
#ifdef DEBUG_INPUT
- print_token("next_token", M4_TOKEN_MACDEF, symbol);
+ print_token("next_token", M4_TOKEN_MACDEF, td);
#endif
return M4_TOKEN_MACDEF;
}
@@ -1200,8 +1188,8 @@ m4_next_token (m4_symbol *symbol)
obstack_1grow (&token_stack, '\0');
- M4_SYMBOL_TYPE (symbol) = M4_TOKEN_TEXT;
- M4_SYMBOL_TEXT (symbol) = obstack_finish (&token_stack);
+ M4_TOKEN_DATA_TYPE (td) = M4_TOKEN_TEXT;
+ M4_TOKEN_DATA_TEXT (td) = obstack_finish (&token_stack);
#ifdef DEBUG_INPUT
print_token("next_token", type, td);
@@ -1216,29 +1204,29 @@ m4_next_token (m4_symbol *symbol)
static void lex_debug (void);
int
-m4_print_token (const char *s, m4_token_t t, m4_symbol *symbol)
+m4_print_token (const char *s, m4_token_t t, m4_token_data *td)
{
fprintf (stderr, "%s: ", s);
switch (t)
{ /* TOKSW */
case M4_TOKEN_SIMPLE:
- fprintf (stderr, "char\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));
+ fprintf (stderr, "char\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
break;
case M4_TOKEN_WORD:
- fprintf (stderr, "word\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));
+ fprintf (stderr, "word\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
break;
case M4_TOKEN_STRING:
- fprintf (stderr, "string\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));
+ fprintf (stderr, "string\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
break;
case M4_TOKEN_SPACE:
- fprintf (stderr, "space\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));
+ fprintf (stderr, "space\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
break;
case M4_TOKEN_MACDEF:
- fprintf (stderr, "macro 0x%x\n", (int)M4_SYMBOL_FUNC (symbol));
+ fprintf (stderr, "macro 0x%x\n", (int)M4_TOKEN_DATA_FUNC (td));
break;
case M4_TOKEN_EOF:
@@ -1256,9 +1244,9 @@ static void
lex_debug (void)
{
m4_token_t t;
- m4_symbol symbol;
+ m4_token_data td;
- while ((t = next_token (&symbol)) != NULL)
- print_token ("lex", t, &symbol);
+ while ((t = next_token (&td)) != NULL)
+ print_token ("lex", t, &td);
}
#endif
Index: m4/ltdl.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/ltdl.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 ltdl.c
--- m4/ltdl.c 2001/09/20 03:48:05 1.10
+++ m4/ltdl.c 2001/09/30 14:40:35
@@ -91,9 +91,6 @@ Foundation, Inc., 59 Temple Place, Suite
#include "ltdl.h"
-#if WITH_DMALLOC
-# include <dmalloc.h>
-#endif
@@ -166,18 +163,6 @@ LT_GLOBAL_DATA void (*lt_dlfree) LT_PA
/* The following macros reduce the amount of typing needed to cast
assigned memory. */
-#if WITH_DMALLOC
-
-#define LT_DLMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp)))
-#define LT_DLREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp)))
-#define LT_DLFREE(p) \
- LT_STMT_START { if (p) (p) = (xfree (p), (lt_ptr) 0); } LT_STMT_END
-
-#define LT_EMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp)))
-#define LT_EREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp)))
-
-#else
-
#define LT_DLMALLOC(tp, n) ((tp *) lt_dlmalloc ((n) * sizeof(tp)))
#define LT_DLREALLOC(tp, p, n) ((tp *) rpl_realloc ((p), (n) * sizeof(tp)))
#define LT_DLFREE(p) \
@@ -186,10 +171,8 @@ LT_GLOBAL_DATA void (*lt_dlfree) LT_PA
#define LT_EMALLOC(tp, n) ((tp *) lt_emalloc ((n) * sizeof(tp)))
#define LT_EREALLOC(tp, p, n) ((tp *) lt_erealloc ((p), (n) * sizeof(tp)))
-#endif
-
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \
- if ((p) != (q)) { if (p) lt_dlfree (p); (p) = (q); (q) = 0; } \
+ if ((p) != (q)) { lt_dlfree (p); (p) = (q); (q) = 0; } \
} LT_STMT_END
@@ -895,10 +878,10 @@ char *
lt_estrdup (str)
const char *str;
{
- char *copy = strdup (str);
- if (LT_STRLEN (str) && !copy)
+ char *dup = strdup (str);
+ if (LT_STRLEN (str) && !dup)
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
- return copy;
+ return dup;
}
@@ -1699,17 +1682,9 @@ static int lt_argz_insert LT_PARAM
static int lt_argz_insertinorder LT_PARAMS((char **pargz,
size_t *pargz_len,
const char *entry));
-static int lt_argz_insertdir LT_PARAMS((char **pargz,
- size_t *pargz_len,
- const char *dirnam,
- struct dirent *dp));
static int lt_dlpath_insertdir LT_PARAMS((char **ppath,
char *before,
const char *dir));
-static int list_files_by_dir LT_PARAMS((const char *dirnam,
- char **pargz,
- size_t *pargz_len));
-static int file_not_found LT_PARAMS((void));
static char *user_search_path= 0;
static lt_dlloader *loaders = 0;
@@ -2917,7 +2892,7 @@ lt_dlopen (filename)
/* If the last error messge store was `FILE_NOT_FOUND', then return
non-zero. */
-static int
+int
file_not_found ()
{
const char *error = 0;
@@ -2942,6 +2917,7 @@ lt_dlopenext (filename)
char * ext = 0;
int len;
int errors = 0;
+ int file_found = 1; /* until proven otherwise */
if (!filename)
{
@@ -3302,9 +3278,6 @@ lt_dlclose (handle)
errors += handle->loader->module_close (data, handle->module);
errors += unload_deplibs(handle);
-
- /* It is up to the callers to free the data itself. */
- LT_DLFREE (handle->caller_data);
LT_DLFREE (handle->info.filename);
LT_DLFREE (handle->info.name);
Index: m4/m4module.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/m4module.h,v
retrieving revision 1.30
diff -u -p -u -r1.30 m4module.h
--- m4/m4module.h 2001/09/20 22:01:34 1.30
+++ m4/m4module.h 2001/09/30 14:40:36
@@ -32,8 +32,9 @@ BEGIN_C_DECLS
typedef struct m4_symbol m4_symbol;
typedef struct m4_module_data m4_module_data;
+typedef struct m4_token_data m4_token_data;
-typedef void m4_builtin_func (struct obstack *, int, struct m4_symbol **);
+typedef void m4_builtin_func (struct obstack *, int, struct m4_token_data **);
typedef void *m4_module_func (const char *);
typedef int m4_symtab_apply_func (const char *name, m4_symbol *symbol, void
*data);
@@ -55,13 +56,12 @@ typedef struct {
} m4_builtin;
-extern void m4_module_init (void);
-extern lt_dlhandle m4_module_load (const char*, struct obstack*);
-extern void m4_module_unload (const char*, struct obstack*);
-extern void m4_module_unload_all (void);
-extern lt_dlhandle m4_module_open (const char*, struct obstack*);
-extern void m4_module_close (lt_dlhandle, struct obstack*);
-extern void m4_module_close_all (struct obstack*);
+extern void m4_module_init (void);
+extern lt_dlhandle m4_module_load (const char*, struct obstack*);
+extern void m4_module_unload (const char*, struct obstack*);
+extern lt_dlhandle m4_module_open (const char*, struct obstack*);
+extern void m4_module_close (lt_dlhandle, struct obstack*);
+extern void m4_module_close_all (struct obstack*);
extern const char *m4_module_name (lt_dlhandle);
extern m4_builtin *m4_module_builtins (lt_dlhandle);
@@ -94,7 +94,6 @@ extern m4_hash *m4_symtab;
extern void m4_symtab_init (void);
extern int m4_symtab_apply (m4_symtab_apply_func *, void *);
extern void m4_symtab_remove_module_references (lt_dlhandle);
-extern void m4_symtab_exit (void);
extern m4_symbol *m4_symbol_lookup (const char *);
extern m4_symbol *m4_symbol_pushdef (const char *);
@@ -128,20 +127,20 @@ typedef enum {
typedef void m4_module_init_func (lt_dlhandle, struct obstack*);
typedef void m4_module_finish_func (lt_dlhandle, struct obstack*);
-extern m4_token_data_t m4_symbol_type (m4_symbol*);
-extern char *m4_symbol_text (m4_symbol*);
-extern m4_builtin_func *m4_symbol_func (m4_symbol*);
+extern m4_token_data_t m4_token_data_type (m4_token_data*);
+extern char *m4_token_data_text (m4_token_data*);
+extern m4_builtin_func *m4_token_data_func (m4_token_data*);
-#define M4ARG(i) (argc > (i) ? m4_symbol_text (argv[i]) : "")
+#define M4ARG(i) (argc > (i) ? m4_token_data_text (argv[i]) : "")
#define M4BUILTIN(name) \
static void CONC(builtin_, name) \
- (struct obstack *, int , m4_symbol **);
+ (struct obstack *, int , m4_token_data **);
#define M4BUILTIN_HANDLER(name) \
static void CONC(builtin_, name) (obs, argc, argv) \
- struct obstack *obs; int argc; m4_symbol **argv;
+ struct obstack *obs; int argc; m4_token_data **argv;
#define M4INIT_HANDLER(name) \
void CONC(name, CONC(_LTX_, m4_init_module)) \
@@ -193,12 +192,12 @@ m4_string ecomm;
#define DEF_BCOMM "#"
#define DEF_ECOMM "\n"
-boolean m4_bad_argc (m4_symbol *, int, int, int);
+boolean m4_bad_argc (m4_token_data *, int, int, int);
const char *m4_skip_space (const char *);
-boolean m4_numeric_arg (m4_symbol *, const char *, int *);
+boolean m4_numeric_arg (m4_token_data *, const char *, int *);
void m4_shipout_int (struct obstack *, int);
void m4_shipout_string (struct obstack*, const char*, int, boolean);
-void m4_dump_args (struct obstack *obs, int argc, m4_symbol **argv, const char
*sep, boolean quoted);
+void m4_dump_args (struct obstack *obs, int argc, m4_token_data **argv, const
char *sep, boolean quoted);
FILE *m4_debug;
@@ -292,15 +291,14 @@ FILE *m4_debug;
while (0)
void m4_debug_init (void);
-void m4_debug_exit (void);
int m4_debug_decode (const char *);
void m4_debug_flush_files (void);
boolean m4_debug_set_output (const char *);
void m4_debug_message_prefix (void);
void m4_trace_prepre (const char *, int);
-void m4_trace_pre (const char *, int, int, m4_symbol **);
-void m4_trace_post (const char *, int, int, m4_symbol **,
+void m4_trace_pre (const char *, int, int, m4_token_data **);
+void m4_trace_post (const char *, int, int, m4_token_data **,
const char *);
/* Exit code from last "syscmd" command. */
@@ -309,8 +307,8 @@ int m4_expansion_level;
const char *m4_expand_ranges (const char *s, struct obstack *obs);
void m4_expand_input (void);
-void m4_call_macro (m4_symbol *, int, m4_symbol **, struct obstack *);
-void m4_process_macro (struct obstack *obs, m4_symbol *symbol, int argc,
m4_symbol **argv);
+void m4_call_macro (m4_symbol *, int, m4_token_data **, struct obstack *);
+void m4_process_macro (struct obstack *obs, m4_symbol *symbol, int argc,
m4_token_data **argv);
@@ -377,10 +375,9 @@ int m4_current_line;
extern int m4_syntax_code (char ch);
extern void m4_input_init (void);
-extern void m4_input_exit (void);
extern void m4_syntax_init (void);
extern int m4_peek_input (void);
-extern m4_token_t m4_next_token (m4_symbol *);
+extern m4_token_t m4_next_token (m4_token_data *);
extern void m4_skip_line (void);
/* push back input */
@@ -402,7 +399,6 @@ int m4_current_diversion;
int m4_output_current_line;
extern void m4_output_init (void);
-extern void m4_output_exit (void);
extern void m4_shipout_text (struct obstack *, const char *, int);
extern void m4_make_diversion (int);
extern void m4_insert_diversion (int);
@@ -449,7 +445,7 @@ struct m4_dump_symbol_data
};
extern int m4_dump_symbol (const char *name, m4_symbol *symbol, void *data);
-extern void m4_dump_symbols (struct m4_dump_symbol_data *data, int argc,
m4_symbol **argv, boolean complain);
+extern void m4_dump_symbols (struct m4_dump_symbol_data *data, int argc,
m4_token_data **argv, boolean complain);
Index: m4/m4private.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/m4private.h,v
retrieving revision 1.10
diff -u -p -u -r1.10 m4private.h
--- m4/m4private.h 2001/09/20 03:48:05 1.10
+++ m4/m4private.h 2001/09/30 14:40:36
@@ -33,8 +33,8 @@ struct m4_module_data {
};
-struct m4_symbol {
- m4_symbol * next;
+struct m4_token_data {
+ m4_token_data * next;
m4_token_data_t type;
boolean traced;
boolean macro_args;
@@ -46,33 +46,42 @@ struct m4_symbol {
} u;
};
-#define M4_SYMBOL_NEXT(Symbol) ((Symbol)->next)
-#define M4_SYMBOL_TYPE(Symbol) ((Symbol)->type)
-#define M4_SYMBOL_TRACED(Symbol) ((Symbol)->traced)
-#define M4_SYMBOL_MACRO_ARGS(Symbol) ((Symbol)->macro_args)
-#define M4_SYMBOL_BLIND_NO_ARGS(Symbol) ((Symbol)->blind_no_args)
-#define M4_SYMBOL_HANDLE(Symbol) ((Symbol)->handle)
-#define M4_SYMBOL_TEXT(Symbol) ((Symbol)->u.text)
-#define M4_SYMBOL_FUNC(Symbol) ((Symbol)->u.func)
+#define M4_TOKEN_DATA_NEXT(Td) ((Td)->next)
+#define M4_TOKEN_DATA_TYPE(Td) ((Td)->type)
+#define M4_TOKEN_TRACED(Td) ((Td)->traced)
+#define M4_TOKEN_MACRO_ARGS(Td) ((Td)->macro_args)
+#define M4_TOKEN_BLIND_NO_ARGS(Td) ((Td)->blind_no_args)
+#define M4_TOKEN_DATA_HANDLE(Td) ((Td)->handle)
+#define M4_TOKEN_DATA_TEXT(Td) ((Td)->u.text)
+#define M4_TOKEN_DATA_FUNC(Td) ((Td)->u.func)
/* Redefine the exported function to this faster
macro based version for internal use by the m4 code. */
#undef M4ARG
-#define M4ARG(i) (argc > (i) ? M4_SYMBOL_TEXT (argv[i]) : "")
+#define M4ARG(i) (argc > (i) ? M4_TOKEN_DATA_TEXT (argv[i]) : "")
+struct m4_symbol
+{
+ m4_token_data *data;
+};
+
+#define M4_SYMBOL_DATA(S) ((S)->data)
+#define M4_SYMBOL_DATA_NEXT(S) (M4_TOKEN_DATA_NEXT (M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_TYPE(S) (M4_TOKEN_DATA_TYPE (M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_TRACED(S) (M4_TOKEN_TRACED (M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_MACRO_ARGS(S) (M4_TOKEN_MACRO_ARGS
(M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_BLIND_NO_ARGS(S) (M4_TOKEN_BLIND_NO_ARGS (M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_TEXT(S) (M4_TOKEN_DATA_TEXT (M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_FUNC(S) (M4_TOKEN_DATA_FUNC (M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_HANDLE(S) (M4_TOKEN_DATA_HANDLE (M4_SYMBOL_DATA(S)))
/* Debugging the memory allocator. */
#if WITH_DMALLOC
-# define DMALLOC_FUNC_CHECK
-# include <dmalloc.h>
-
-/* Dmalloc expects us to use a void returning xfree. */
-# undef XFREE
-# define XFREE(p) if (p) xfree (p)
-
-#endif /* WITH_DMALLOC */
+# define DMALLOC_FUNC_CHECK
+# include <dmalloc.h>
+#endif
/* Other debug stuff. */
Index: m4/macro.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/macro.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 macro.c
--- m4/macro.c 2001/09/20 03:48:05 1.13
+++ m4/macro.c 2001/09/30 14:40:37
@@ -23,8 +23,8 @@
#include "m4.h"
#include "m4private.h"
-static void expand_macro (const char *name, m4_symbol *token);
-static void expand_token (struct obstack *, m4_token_t t, m4_symbol *token);
+static void expand_macro (const char *name, m4_symbol *);
+static void expand_token (struct obstack *, m4_token_t, m4_token_data *);
/* Current recursion level in expand_macro (). */
int m4_expansion_level = 0;
@@ -37,10 +37,10 @@ void
m4_expand_input (void)
{
m4_token_t t;
- m4_symbol tokenbuf;
+ m4_token_data td;
- while ((t = m4_next_token (&tokenbuf)) != M4_TOKEN_EOF)
- expand_token ((struct obstack *) NULL, t, &tokenbuf);
+ while ((t = m4_next_token (&td)) != M4_TOKEN_EOF)
+ expand_token ((struct obstack *) NULL, t, &td);
}
@@ -49,10 +49,10 @@ m4_expand_input (void)
macro definition. If they have, they are expanded as macros, otherwise
the text are just copied to the output. */
static void
-expand_token (struct obstack *obs, m4_token_t t, m4_symbol *token)
+expand_token (struct obstack *obs, m4_token_t t, m4_token_data *td)
{
m4_symbol *symbol;
- char *text = xstrdup (M4_SYMBOL_TEXT (token));
+ char *text = xstrdup (M4_TOKEN_DATA_TEXT (td));
switch (t)
{ /* TOKSW */
@@ -79,8 +79,8 @@ expand_token (struct obstack *obs, m4_to
&& M4_SYMBOL_BLIND_NO_ARGS (symbol)
&& !M4_IS_OPEN(m4_peek_input ())))
{
- m4_shipout_text (obs, M4_SYMBOL_TEXT (token),
- strlen (M4_SYMBOL_TEXT (token)));
+ m4_shipout_text (obs, M4_TOKEN_DATA_TEXT (td),
+ strlen (M4_TOKEN_DATA_TEXT (td)));
}
else
expand_macro (p, symbol);
@@ -95,9 +95,8 @@ expand_token (struct obstack *obs, m4_to
XFREE (text);
}
-
-
+
/* This function parses one argument to a macro call. It expects the first
left parenthesis, or the separating comma to have been read by the
caller. It skips leading whitespace, and reads and expands tokens,
@@ -106,19 +105,19 @@ expand_token (struct obstack *obs, m4_to
the last for the active macro call. The argument are build on the
obstack OBS, indirectly through expand_token (). */
static boolean
-expand_argument (struct obstack *obs, m4_symbol *argp)
+expand_argument (struct obstack *obs, m4_token_data *argp)
{
m4_token_t t;
- m4_symbol tokenbuf;
+ m4_token_data td;
char *text;
int paren_level;
- M4_SYMBOL_TYPE (argp) = M4_TOKEN_VOID;
+ M4_TOKEN_DATA_TYPE (argp) = M4_TOKEN_VOID;
/* Skip leading white space. */
do
{
- t = m4_next_token (&tokenbuf);
+ t = m4_next_token (&td);
}
while (t == M4_TOKEN_SPACE);
@@ -126,30 +125,31 @@ expand_argument (struct obstack *obs, m4
while (1)
{
+
switch (t)
{ /* TOKSW */
case M4_TOKEN_SIMPLE:
- text = M4_SYMBOL_TEXT (&tokenbuf);
- if ((M4_IS_COMMA (*text) || M4_IS_CLOSE (*text)) && paren_level == 0)
+ text = M4_TOKEN_DATA_TEXT (&td);
+ if ((M4_IS_COMMA(*text) || M4_IS_CLOSE(*text)) && paren_level == 0)
{
/* The argument MUST be finished, whether we want it or not. */
obstack_1grow (obs, '\0');
text = obstack_finish (obs);
- if (M4_SYMBOL_TYPE (argp) == M4_TOKEN_VOID)
+ if (M4_TOKEN_DATA_TYPE (argp) == M4_TOKEN_VOID)
{
- M4_SYMBOL_TYPE (argp) = M4_TOKEN_TEXT;
- M4_SYMBOL_TEXT (argp) = text;
+ M4_TOKEN_DATA_TYPE (argp) = M4_TOKEN_TEXT;
+ M4_TOKEN_DATA_TEXT (argp) = text;
}
- return (boolean) (M4_IS_COMMA (*M4_SYMBOL_TEXT (&tokenbuf)));
+ return (boolean) (M4_IS_COMMA(*M4_TOKEN_DATA_TEXT (&td)));
}
if (M4_IS_OPEN(*text))
paren_level++;
else if (M4_IS_CLOSE(*text))
paren_level--;
- expand_token (obs, t, &tokenbuf);
+ expand_token (obs, t, &td);
break;
case M4_TOKEN_EOF:
@@ -160,16 +160,16 @@ expand_argument (struct obstack *obs, m4
case M4_TOKEN_WORD:
case M4_TOKEN_SPACE:
case M4_TOKEN_STRING:
- expand_token (obs, t, &tokenbuf);
+ expand_token (obs, t, &td);
break;
case M4_TOKEN_MACDEF:
if (obstack_object_size (obs) == 0)
{
- M4_SYMBOL_TYPE (argp) = M4_TOKEN_FUNC;
- M4_SYMBOL_HANDLE (argp) = M4_SYMBOL_HANDLE (&tokenbuf);
- M4_SYMBOL_FUNC (argp) = M4_SYMBOL_FUNC (&tokenbuf);
- M4_SYMBOL_TRACED (argp) = M4_SYMBOL_TRACED (&tokenbuf);
+ M4_TOKEN_DATA_TYPE (argp) = M4_TOKEN_FUNC;
+ M4_TOKEN_DATA_HANDLE (argp) = M4_TOKEN_DATA_HANDLE (&td);
+ M4_TOKEN_DATA_FUNC (argp) = M4_TOKEN_DATA_FUNC (&td);
+ M4_TOKEN_TRACED (argp) = M4_TOKEN_TRACED (&td);
}
break;
@@ -179,7 +179,7 @@ INTERNAL ERROR: Bad token type in expand
abort ();
}
- t = m4_next_token (&tokenbuf);
+ t = m4_next_token (&td);
}
}
@@ -191,32 +191,32 @@ collect_arguments (const char *name, m4_
struct obstack *argptr, struct obstack *arguments)
{
int ch; /* lookahead for ( */
- m4_symbol tokenbuf;
- m4_symbol *token;
+ m4_token_data td;
+ m4_token_data *tdp;
boolean more_args;
boolean groks_macro_args = M4_SYMBOL_MACRO_ARGS (symbol);
- M4_SYMBOL_TYPE (&tokenbuf) = M4_TOKEN_TEXT;
- M4_SYMBOL_TEXT (&tokenbuf) = (char *) name;
- token = (m4_symbol *) obstack_copy (arguments, (void *) &tokenbuf, sizeof
(tokenbuf));
- obstack_grow (argptr, (void *) &token, sizeof (token));
+ M4_TOKEN_DATA_TYPE (&td) = M4_TOKEN_TEXT;
+ M4_TOKEN_DATA_TEXT (&td) = (char *) name;
+ tdp = (m4_token_data *) obstack_copy (arguments, (void *) &td, sizeof (td));
+ obstack_grow (argptr, (void *) &tdp, sizeof (tdp));
ch = m4_peek_input ();
if (M4_IS_OPEN(ch))
{
- m4_next_token (&tokenbuf); /* gobble parenthesis */
+ m4_next_token (&td); /* gobble parenthesis */
do
{
- more_args = expand_argument (arguments, &tokenbuf);
+ more_args = expand_argument (arguments, &td);
- if (!groks_macro_args && M4_SYMBOL_TYPE (&tokenbuf) == M4_TOKEN_FUNC)
+ if (!groks_macro_args && M4_TOKEN_DATA_TYPE (&td) == M4_TOKEN_FUNC)
{
- M4_SYMBOL_TYPE (&tokenbuf) = M4_TOKEN_TEXT;
- M4_SYMBOL_TEXT (&tokenbuf) = "";
+ M4_TOKEN_DATA_TYPE (&td) = M4_TOKEN_TEXT;
+ M4_TOKEN_DATA_TEXT (&td) = "";
}
- token = (m4_symbol *)
- obstack_copy (arguments, (void *) &tokenbuf, sizeof (tokenbuf));
- obstack_grow (argptr, (void *) &token, sizeof (token));
+ tdp = (m4_token_data *)
+ obstack_copy (arguments, (void *) &td, sizeof (td));
+ obstack_grow (argptr, (void *) &tdp, sizeof (tdp));
}
while (more_args);
}
@@ -231,7 +231,7 @@ collect_arguments (const char *name, m4_
arguments to the call, stored in the ARGV table. The expansion is
left on the obstack EXPANSION. Macro tracing is also handled here. */
void
-m4_call_macro (m4_symbol *symbol, int argc, m4_symbol **argv,
+m4_call_macro (m4_symbol *symbol, int argc, m4_token_data **argv,
struct obstack *expansion)
{
switch (M4_SYMBOL_TYPE (symbol))
@@ -263,7 +263,7 @@ expand_macro (const char *name, m4_symbo
{
struct obstack arguments;
struct obstack argptr;
- m4_symbol **argv;
+ m4_token_data **argv;
int argc;
struct obstack *expansion;
const char *expanded;
@@ -289,8 +289,8 @@ ERROR: Recursion limit of %d exceeded, u
collect_arguments (name, symbol, &argptr, &arguments);
- argc = obstack_object_size (&argptr) / sizeof (m4_symbol *);
- argv = (m4_symbol **) obstack_finish (&argptr);
+ argc = obstack_object_size (&argptr) / sizeof (m4_token_data *);
+ argv = (m4_token_data **) obstack_finish (&argptr);
if (traced)
m4_trace_pre (name, my_call_id, argc, argv);
@@ -315,7 +315,7 @@ ERROR: Recursion limit of %d exceeded, u
as usual. */
void
m4_process_macro (struct obstack *obs, m4_symbol *symbol, int argc,
- m4_symbol **argv)
+ m4_token_data **argv)
{
const unsigned char *text;
int i;
@@ -344,7 +344,7 @@ m4_process_macro (struct obstack *obs, m
text = endp;
}
if (i < argc)
- m4_shipout_string (obs, M4_SYMBOL_TEXT (argv[i]), 0, FALSE);
+ m4_shipout_string (obs, M4_TOKEN_DATA_TEXT (argv[i]), 0, FALSE);
break;
case '#': /* number of arguments */
Index: m4/module.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/module.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 module.c
--- m4/module.c 2001/09/20 03:48:05 1.12
+++ m4/module.c 2001/09/30 14:40:39
@@ -59,14 +59,14 @@
* names to the expansion text. Any macros defined in `m4_macro_table'
* are installed into the M4 symbol table with m4_macro_table_install().
*
- * Each time a module is loaded, the module function
+ * Each time a module is loaded, the module function
* "void m4_init_module (lt_dlhandle handle, struct obstack *obs)" is
* called, if defined. Any value stored in OBS by this function becomes
- * the expansion of the macro which called it. Before M4 exits, all
+ * the expansion of the macro which called it. Before M4 exits, all
* modules are unloaded and the function
* "void m4_finish_module (lt_dlhandle handle, struct obstack *obs)" is
* called, if defined. It is safe to load the same module several times:
- * the init and finish functions will also be called multiple times in
+ * the init and finish functions will also be called multiple times in
* this case.
*
* To unload a module, use m4_module_unload(). which uses
@@ -83,8 +83,6 @@
#define M4_FINISH_SYMBOL "m4_finish_module"
static const char* m4_module_dlerror (void);
-static int m4_module_remove (lt_dlhandle handle,
- struct obstack *obs);
static lt_dlcaller_id m4_caller_id = 0;
@@ -169,7 +167,7 @@ void
m4_module_init (void)
{
int errors = 0;
-
+
/* Do this only once! If we already have a caller_id, then the
module system has already been initialised. */
if (m4_caller_id)
@@ -179,11 +177,9 @@ m4_module_init (void)
return;
}
-#if !WITH_DMALLOC
/* initialise libltdl's memory management. */
lt_dlmalloc = xmalloc;
lt_dlfree = (void (*)(void*)) xfree;
-#endif
errors = lt_dlinit ();
@@ -205,7 +201,7 @@ m4_module_init (void)
++errors;
}
}
-
+
if (!errors)
errors = lt_dlsetsearchpath (MODULE_PATH);
@@ -294,7 +290,7 @@ m4_module_open (const char *name, struct
if (handle)
{
const lt_dlinfo *info = lt_dlgetinfo (handle);
-
+
if (info && (info->ref_count == 1))
{
m4_module_data *data = XMALLOC (m4_module_data, 1);
@@ -308,7 +304,7 @@ m4_module_open (const char *name, struct
if (stale)
{
xfree (stale);
-
+
M4ERROR ((warning_status, 0,
_("Warning: overiding stale caller data in module
`%s'"),
name));
@@ -327,11 +323,11 @@ void
m4_module_close (lt_dlhandle handle, struct obstack *obs)
{
m4_module_finish_func *finish_func = 0;
- char *name = 0;
+ const char *name = 0;
int errors = 0;
-
+
assert (handle);
- name = xstrdup (m4_module_name (handle));
+ name = m4_module_name (handle);
/* Run any finishing function for the opened module. */
finish_func = (m4_module_finish_func *) lt_dlsym (handle, M4_FINISH_SYMBOL);
@@ -344,19 +340,21 @@ m4_module_close (lt_dlhandle handle, str
M4_DEBUG_MESSAGE1("module %s: finish hook called", name);
#endif /* DEBUG_MODULES */
}
-
+
if (!lt_dlisresident (handle))
{
- const lt_dlinfo *info = lt_dlgetinfo (handle);
+ {
+ const lt_dlinfo *info = lt_dlgetinfo (handle);
- /* When we are about to unload the module for the final
- time, be sure to release any client data memory. */
- if (info && (info->ref_count == 1))
- {
- m4_module_data *stale
- = lt_dlcaller_set_data (m4_caller_id, handle, 0);
- XFREE (stale);
- }
+ /* When we are about to unload the module for the final
+ time, be sure to release any client data memory. */
+ if (info && (info->ref_count == 1))
+ {
+ m4_module_data *stale
+ = lt_dlcaller_set_data (m4_caller_id, handle, 0);
+ xfree (stale);
+ }
+ }
errors = lt_dlclose (handle);
if (!errors)
@@ -366,10 +364,6 @@ m4_module_close (lt_dlhandle handle, str
#endif /* DEBUG_MODULES */
}
}
-#ifdef DEBUG_MODULES
- else
- M4_DEBUG_MESSAGE1("module %s: resident module not closed", name);
-#endif /* DEBUG_MODULES */
if (errors)
{
@@ -377,8 +371,6 @@ m4_module_close (lt_dlhandle handle, str
_("ERROR: cannot close module `%s': %s"),
name, m4_module_dlerror ()));
}
-
- xfree (name);
}
void
@@ -392,10 +384,6 @@ m4_module_close_all (struct obstack *obs
closed, even to find the address of the next handle. */
lt_dlhandle pending = handle;
handle = lt_dlhandle_next (handle);
-#ifdef DEBUG_MODULES
- M4_DEBUG_MESSAGE1("module %s: attempting module close",
- m4_module_name (pending));
-#endif /* DEBUG_MODULES */
m4_module_close (pending, obs);
}
@@ -450,46 +438,6 @@ m4_module_load (const char *name, struct
return handle;
}
-int
-m4_module_remove (lt_dlhandle handle, struct obstack *obs)
-{
- const lt_dlinfo *info = 0;
- int errors = 0;
-
- assert (handle);
-
- info = lt_dlgetinfo (handle);
-
- /* Only do the actual close when the number of calls to close this
- module is equal to the number of times it was opened. */
-#ifdef DEBUG_MODULES
- if (info->ref_count > 1)
- {
- M4_DEBUG_MESSAGE2("module %s: now has %d references.",
- m4_module_name (handle), info->ref_count -1);
- }
-#endif /* DEBUG_MODULES */
-
- if (info->ref_count == 1)
- {
- /* Remove the table references only when ref_count is *exactly*
- equal to 1. If m4_module_close is called again on a
- resident module after the references have already been
- removed, we needn't try to remove them again! */
- m4_symtab_remove_module_references (handle);
-
-#ifdef DEBUG_MODULES
- M4_DEBUG_MESSAGE1("module %s: symbols unloaded",
- m4_module_name (handle));
-#endif /* DEBUG_MODULES */
- }
-
- if (!errors)
- m4_module_close (handle, obs);
-
- return errors;
-}
-
/* Unload a module. */
void
m4_module_unload (const char *name, struct obstack *obs)
@@ -512,51 +460,40 @@ m4_module_unload (const char *name, stru
++errors;
}
else
- errors = m4_module_remove (handle, obs);
-
- if (errors)
- {
- M4ERROR ((EXIT_FAILURE, 0,
- _("ERROR: cannot unload module `%s': %s"),
- name, m4_module_dlerror ()));
- }
-}
-
-void
-m4_module_unload_all (void)
-{
- lt_dlhandle handle = lt_dlhandle_next (0);
- int errors = 0;
-
- while (handle && !errors)
{
- lt_dlhandle pending = handle;
- const lt_dlinfo *info = lt_dlgetinfo (pending);
+ const lt_dlinfo *info = lt_dlgetinfo (handle);
- /* We are *really* shutting down here, so freeing the module
- data is required. */
- if (info)
+ /* Only do the actual close when the number of calls to close this
+ module is equal to the number of times it was opened. */
+ if (info->ref_count > 1)
{
- m4_module_data *stale
- = lt_dlcaller_set_data (m4_caller_id, handle, 0);
- XFREE (stale);
+#ifdef DEBUG_MODULES
+ M4_DEBUG_MESSAGE2("module %s: now has %d references.",
+ name, info->ref_count -1);
+#endif /* DEBUG_MODULES */
}
- /* If we are about to unload the final reference, move on to the
- next handle before we unload the current one. */
- if (info->ref_count <= 1)
- handle = lt_dlhandle_next (pending);
+ if (info->ref_count == 1)
+ {
+ /* Remove the table references only when ref_count is *exactly*
+ equal to 1. If m4_module_close is called again on a
+ resident module after the references have already been
+ removed, we needn't try to remove them again! */
+ m4_symtab_remove_module_references (handle);
- errors = m4_module_remove (pending, 0);
+#ifdef DEBUG_MODULES
+ M4_DEBUG_MESSAGE1("module %s: symbols unloaded", name);
+#endif /* DEBUG_MODULES */
+ }
}
if (!errors)
- errors = lt_dlexit();
+ m4_module_close (handle, obs);
if (errors)
{
M4ERROR ((EXIT_FAILURE, 0,
- _("ERROR: cannot unload all modules: %s"),
- m4_module_dlerror ()));
+ _("ERROR: cannot unload module `%s': %s"),
+ name, m4_module_dlerror ()));
}
}
Index: m4/output.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/output.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 output.c
--- m4/output.c 2001/09/20 03:48:05 1.6
+++ m4/output.c 2001/09/30 14:40:40
@@ -105,7 +105,7 @@ int m4_output_current_line;
void
m4_output_init (void)
{
- diversion_table = XMALLOC (struct diversion, 1);
+ diversion_table = (struct diversion *) xmalloc (sizeof (struct diversion));
diversions = 1;
diversion_table[0].file = stdout;
diversion_table[0].buffer = NULL;
@@ -120,14 +120,6 @@ m4_output_init (void)
output_unused = 0;
}
-void
-m4_output_exit (void)
-{
- assert (diversions = 1);
- XFREE (diversion_table);
-}
-
-
#ifdef HAVE_MKTEMP
#ifndef HAVE_MKSTEMP
@@ -691,3 +683,4 @@ m4_freeze_diversions (file)
if (saved_number != last_inserted)
fprintf (file, "D%d,0\n\n", saved_number);
}
+
Index: m4/symtab.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/symtab.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 symtab.c
--- m4/symtab.c 2001/09/20 03:48:05 1.22
+++ m4/symtab.c 2001/09/30 14:40:41
@@ -18,11 +18,6 @@
02111-1307 USA
*/
-#include "m4private.h"
-
-#define DEBUG_SYM /* Define this to see runtime debug info. */
-#undef DEBUG_SYM
-
/* This file handles all the low level work around the symbol table. The
symbol table is an abstract hash table type implemented in hash.c. Each
symbol is represented by `struct m4_symbol', which is stored in the hash
@@ -32,13 +27,13 @@
simply ordered on the stack by age. The most recently pushed definition
will then always be the first found. */
+#include "m4private.h"
+
static size_t m4_symtab_hash (const void *key);
static int m4_symtab_cmp (const void *key, const void *try);
-static void m4_token_data_delete (m4_symbol *data);
-static void m4_symbol_pop (m4_symbol **psymbol);
-static void m4_symbol_del (m4_symbol **psymbol);
-static int m4_symbol_destroy (const char *name, m4_symbol *symbol,
- void *data);
+static void m4_token_data_delete (m4_token_data *data);
+static void m4_symbol_pop (m4_symbol *symbol);
+static void m4_symbol_del (m4_symbol *symbol);
/* Pointer to symbol table. */
@@ -52,21 +47,6 @@ m4_symtab_init (void)
m4_symtab = m4_hash_new (m4_symtab_hash, m4_symtab_cmp);
}
-int
-m4_symbol_destroy (const char *name, m4_symbol *symbol, void *data)
-{
- m4_symbol_delete (name);
- return 0;
-}
-
-void
-m4_symtab_exit (void)
-{
- m4_symtab_apply (m4_symbol_destroy, NULL);
- m4_hash_delete (m4_symtab);
- m4_hash_exit ();
-}
-
/* Return a hashvalue for a string, from GNU-emacs. */
size_t
m4_symtab_hash (const void *key)
@@ -94,45 +74,50 @@ m4_symtab_cmp (const void *key, const vo
void
-m4_token_data_delete (m4_symbol *data)
+m4_token_data_delete (m4_token_data *data)
{
assert (data);
- assert (M4_SYMBOL_NEXT (data) == 0);
+ assert (M4_TOKEN_DATA_NEXT (data) == 0);
- if (M4_SYMBOL_TYPE (data) == M4_TOKEN_TEXT)
- XFREE (M4_SYMBOL_TEXT (data));
+ if (M4_TOKEN_DATA_TYPE (data) == M4_TOKEN_TEXT)
+ XFREE (M4_TOKEN_DATA_TEXT (data));
XFREE (data);
}
-
void
-m4_symbol_pop (m4_symbol **psymbol)
+m4_symbol_pop (m4_symbol *symbol)
{
- m4_symbol *stale;
+ m4_token_data *stale;
- assert (psymbol);
- assert (*psymbol);
+ assert (symbol);
+ assert (M4_SYMBOL_DATA_NEXT (symbol));
- stale = *psymbol;
- *psymbol = M4_SYMBOL_NEXT (stale);
+ stale = M4_SYMBOL_DATA (symbol);
+ M4_SYMBOL_DATA (symbol) = M4_TOKEN_DATA_NEXT (stale);
#ifndef NDEBUG
- M4_SYMBOL_NEXT (stale) = 0;
+ M4_TOKEN_DATA_NEXT (stale) = 0;
#endif
m4_token_data_delete (stale);
}
-
/* Free all storage associated with a symbol. */
void
-m4_symbol_del (m4_symbol **psymbol)
+m4_symbol_del (m4_symbol *symbol)
{
- assert (psymbol);
- assert (*psymbol);
+ assert (symbol);
+
+ while (M4_SYMBOL_DATA_NEXT (symbol))
+ m4_symbol_pop (symbol);
+
+ assert (M4_SYMBOL_DATA_NEXT (symbol) == 0);
+
+ if (M4_SYMBOL_TYPE (symbol) == M4_TOKEN_TEXT)
+ XFREE (M4_SYMBOL_TEXT (symbol));
- while (*psymbol)
- m4_symbol_pop (psymbol);
+ XFREE (M4_SYMBOL_DATA (symbol));
+ XFREE (symbol);
}
@@ -157,15 +142,21 @@ m4_symbol_pushdef (const char *name)
/* Insert a name in the symbol table. If there is already a symbol
with the name, push the new value on top of the value stack for
this symbol. */
- m4_symbol *symbol = XCALLOC (m4_symbol, 1);;
- M4_SYMBOL_TYPE (symbol) = M4_TOKEN_VOID;
+ m4_symbol *symbol = 0;
+ m4_token_data *value = XCALLOC (m4_token_data, 1);
if (psymbol)
{
- M4_SYMBOL_NEXT (symbol) = *psymbol;
- *psymbol = symbol;
+ symbol = *psymbol;
+ M4_TOKEN_DATA_NEXT (value) = M4_SYMBOL_DATA (symbol);
}
else
+ symbol = XCALLOC (m4_symbol, 1);
+
+ M4_SYMBOL_DATA (symbol) = value;
+ M4_SYMBOL_TYPE (symbol) = M4_TOKEN_VOID;
+
+ if (!psymbol)
m4_hash_insert (m4_symtab, xstrdup (name), symbol);
return symbol;
@@ -176,11 +167,11 @@ m4_symbol_pushdef (const char *name)
m4_symbol *
m4_symbol_define (const char *name)
{
- m4_symbol **psymbol = (m4_symbol **) m4_hash_lookup (m4_symtab, name);
- if (psymbol)
- return *psymbol;
+ m4_symbol *res = m4_symbol_lookup (name);
+ if (res)
+ return res;
else
- return m4_symbol_pushdef (name);
+ m4_symbol_pushdef (name);
}
@@ -192,12 +183,12 @@ m4_symbol_popdef (const char *name)
assert (psymbol);
- if (M4_SYMBOL_NEXT (*psymbol))
- m4_symbol_pop (psymbol);
+ if (M4_SYMBOL_DATA_NEXT (*psymbol))
+ m4_symbol_pop (*psymbol);
else
{
xfree (m4_hash_remove (m4_symtab, name));
- m4_symbol_del (psymbol);
+ m4_symbol_del (*psymbol);
}
}
@@ -209,13 +200,8 @@ m4_symbol_delete (const char *name)
m4_symbol **psymbol = (m4_symbol **) m4_hash_lookup (m4_symtab, name);
assert (psymbol);
-
-#ifdef DEBUG_SYM
- M4_DEBUG_MESSAGE1("symbol %s recycled.", name);
-#endif
-
xfree (m4_hash_remove (m4_symtab, name));
- m4_symbol_del (psymbol);
+ m4_symbol_del (*psymbol);
}
@@ -267,43 +253,42 @@ m4_symtab_remove_module_references (lt_d
assert (handle);
- /* Traverse each symbol name in the hash table. */
while ((place = m4_hash_iterator_next (m4_symtab, place)))
{
- m4_symbol **psymbol = (m4_symbol **) m4_hash_iterator_value (place);
- m4_symbol *current = *psymbol;
+ m4_symbol *symbol = (m4_symbol *) m4_hash_iterator_value (place);
+ m4_token_data *data = M4_SYMBOL_DATA (symbol);
- /* Examine each value in the value stack associated with this
- symbol name. */
- while (M4_SYMBOL_NEXT (current))
+ /* Purge any shadowed references. */
+ while (M4_TOKEN_DATA_NEXT (data))
{
- m4_symbol *next = M4_SYMBOL_NEXT (current);
+ m4_token_data *next = M4_TOKEN_DATA_NEXT (data);
- if (M4_SYMBOL_HANDLE (next) == handle)
+ if (M4_TOKEN_DATA_HANDLE (next) == handle)
{
- M4_SYMBOL_NEXT (current) = M4_SYMBOL_NEXT (next);
+ M4_TOKEN_DATA_NEXT (data) = M4_TOKEN_DATA_NEXT (next);
m4_token_data_delete (next);
}
else
- current = next;
+ data = next;
}
- /* Purge live reference.
- This must be performed after the shadowed values have been weeded
- so that the symbol key can be removed from the hash table if this
- last value matches too. */
- if (M4_SYMBOL_HANDLE (*psymbol) == handle)
+ /* Purge live reference. */
+ if (M4_SYMBOL_HANDLE (symbol) == handle)
{
- if (!M4_SYMBOL_NEXT (*psymbol))
- xfree (m4_hash_remove (m4_symtab, m4_hash_iterator_key (place)));
- m4_symbol_pop (psymbol);
+ if (M4_SYMBOL_DATA_NEXT (symbol))
+ m4_symbol_pop (symbol);
+ else
+ {
+ xfree (m4_hash_remove (m4_symtab, m4_hash_iterator_key (place)));
+ m4_symbol_del (symbol);
+ }
}
}
}
-/* The following function is used for the cases where we want to do
+/* The following function is used for the cases, where we want to do
something to each and every symbol in the table. The function
- m4_symtab_apply () traverses the symbol table, and calls a specified
+ hack_all_symbols () traverses the symbol table, and calls a specified
function FUNC for each symbol in the table. FUNC is called with a
pointer to the symbol, and the DATA argument. */
int
@@ -316,9 +301,9 @@ m4_symtab_apply (m4_symtab_apply_func *f
while ((place = m4_hash_iterator_next (m4_symtab, place)))
{
- const char *name = (const char *) m4_hash_iterator_key (place);
- m4_symbol **psymbol = (m4_symbol **) m4_hash_iterator_value (place);
- result = (*func) (name, *psymbol, data);
+ const char *name = (const char *) m4_hash_iterator_key (place);
+ m4_symbol *symbol = (m4_symbol *) m4_hash_iterator_value (place);
+ result = (*func) (name, symbol, data);
if (result != 0)
break;
@@ -336,17 +321,17 @@ static int symtab_print_list (const char
static void
symtab_debug (void)
{
- m4_token_t t;
- m4_symbol tokenbuf;
+ m4_token_data_t t;
+ m4_token_data td;
const char *text;
m4_symbol *s;
int delete;
- while ((t = m4_next_token (&tokenbuf)) != M4_TOKEN_EOF)
+ while ((t = m4_next_token (&td)) != NULL)
{
if (t != M4_TOKEN_WORD)
continue;
- text = M4_SYMBOL_TEXT (&tokenbuf);
+ text = M4_TOKEN_DATA_TEXT (&td);
if (*text == '_')
{
delete = 1;
Index: m4/utility.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/utility.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 utility.c
--- m4/utility.c 2001/09/20 03:48:05 1.14
+++ m4/utility.c 2001/09/30 14:40:41
@@ -79,21 +79,21 @@ m4_string ecomm;
internal data structure, so they are safe to export for use in
external modules. */
m4_token_data_t
-m4_symbol_type (m4_symbol *name)
+m4_token_data_type (m4_token_data *name)
{
- return M4_SYMBOL_TYPE(name);
+ return M4_TOKEN_DATA_TYPE(name);
}
char *
-m4_symbol_text (m4_symbol *name)
+m4_token_data_text (m4_token_data *name)
{
- return M4_SYMBOL_TEXT(name);
+ return M4_TOKEN_DATA_TEXT(name);
}
m4_builtin_func *
-m4_symbol_func (m4_symbol *name)
+m4_token_data_func (m4_token_data *name)
{
- return M4_SYMBOL_FUNC(name);
+ return M4_TOKEN_DATA_FUNC(name);
}
@@ -104,13 +104,13 @@ m4_symbol_func (m4_symbol *name)
negative if not applicable, MAX is the maximum number, negative if not
applicable. */
boolean
-m4_bad_argc (m4_symbol *name, int argc, int min, int max)
+m4_bad_argc (m4_token_data *name, int argc, int min, int max)
{
if (min > 0 && argc < min)
{
M4WARN ((warning_status, 0,
_("Warning: %s: too few arguments"),
- M4_SYMBOL_TEXT (name)));
+ M4_TOKEN_DATA_TEXT (name)));
return TRUE;
}
@@ -118,7 +118,7 @@ m4_bad_argc (m4_symbol *name, int argc,
{
M4WARN ((warning_status, 0,
_("Warning: %s: too many arguments (ignored)"),
- M4_SYMBOL_TEXT (name)));
+ M4_TOKEN_DATA_TEXT (name)));
/* Return FALSE, otherwise it is not exactly `ignored'. */
return FALSE;
}
@@ -138,7 +138,7 @@ m4_skip_space (const char *arg)
VALUEP. If the conversion fails, print error message for macro MACRO.
Return TRUE iff conversion succeeds. */
boolean
-m4_numeric_arg (m4_symbol *macro, const char *arg, int *valuep)
+m4_numeric_arg (m4_token_data *macro, const char *arg, int *valuep)
{
char *endp;
@@ -147,7 +147,7 @@ m4_numeric_arg (m4_symbol *macro, const
{
M4WARN ((warning_status, 0,
_("Warning: %s: non-numeric argument: %s"),
- M4_SYMBOL_TEXT (macro), arg));
+ M4_TOKEN_DATA_TEXT (macro), arg));
return FALSE;
}
return TRUE;
@@ -157,7 +157,7 @@ m4_numeric_arg (m4_symbol *macro, const
/* Print ARGC arguments from the table ARGV to obstack OBS, separated by
SEP, and quoted by the current quotes, if QUOTED is TRUE. */
void
-m4_dump_args (struct obstack *obs, int argc, m4_symbol **argv,
+m4_dump_args (struct obstack *obs, int argc, m4_token_data **argv,
const char *sep, boolean quoted)
{
int i;
@@ -168,7 +168,7 @@ m4_dump_args (struct obstack *obs, int a
if (i > 1)
obstack_grow (obs, sep, len);
- m4_shipout_string (obs, M4_SYMBOL_TEXT (argv[i]), 0, quoted);
+ m4_shipout_string (obs, M4_TOKEN_DATA_TEXT (argv[i]), 0, quoted);
}
}
@@ -243,7 +243,7 @@ m4_dump_symbol (const char *name, m4_sym
symbols, otherwise, only the specified symbols. */
void
m4_dump_symbols (struct m4_dump_symbol_data *data, int argc,
- m4_symbol **argv, boolean complain)
+ m4_token_data **argv, boolean complain)
{
data->base = (const char **) obstack_base (data->obs);
data->size = 0;
@@ -259,9 +259,9 @@ m4_dump_symbols (struct m4_dump_symbol_d
for (i = 1; i < argc; i++)
{
- symbol = m4_symbol_lookup (M4_SYMBOL_TEXT (argv[i]));
+ symbol = m4_symbol_lookup (M4_TOKEN_DATA_TEXT (argv[i]));
if (symbol != NULL && M4_SYMBOL_TYPE (symbol) != M4_TOKEN_VOID)
- m4_dump_symbol (M4_SYMBOL_TEXT (argv[i]), symbol, data);
+ m4_dump_symbol (M4_TOKEN_DATA_TEXT (argv[i]), symbol, data);
else if (complain)
M4WARN ((warning_status, 0,
_("Warning: %s: undefined name: %s"),
Index: modules/evalparse.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/evalparse.c,v
retrieving revision 1.1
diff -u -p -u -r1.1 evalparse.c
--- modules/evalparse.c 2001/09/20 22:01:34 1.1
+++ modules/evalparse.c 2001/09/30 14:40:42
@@ -766,7 +766,7 @@ simple_term (eval_token et, number *v1)
/* Main entry point, called from "eval" and "mpeval" builtins. */
void
-m4_evaluate (struct obstack *obs, int argc, m4_symbol **argv)
+m4_evaluate (struct obstack *obs, int argc, m4_token_data **argv)
{
int radix = 10;
int min = 1;
Index: modules/format.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/format.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 format.c
--- modules/format.c 2001/09/20 03:48:05 1.10
+++ modules/format.c 2001/09/30 14:40:44
@@ -24,36 +24,36 @@
#define ARG_INT(argc, argv) \
((argc == 0) ? 0 : \
- (--argc, argv++, atoi (M4_SYMBOL_TEXT (argv[-1]))))
+ (--argc, argv++, atoi (M4_TOKEN_DATA_TEXT (argv[-1]))))
#define ARG_UINT(argc, argv) \
((argc == 0) ? 0 : \
- (--argc, argv++, (unsigned int) atoi (M4_SYMBOL_TEXT (argv[-1]))))
+ (--argc, argv++, (unsigned int) atoi (M4_TOKEN_DATA_TEXT (argv[-1]))))
#define ARG_LONG(argc, argv) \
((argc == 0) ? 0 : \
- (--argc, argv++, atol (M4_SYMBOL_TEXT (argv[-1]))))
+ (--argc, argv++, atol (M4_TOKEN_DATA_TEXT (argv[-1]))))
#define ARG_ULONG(argc, argv) \
((argc == 0) ? 0 : \
- (--argc, argv++, (unsigned long) atol (M4_SYMBOL_TEXT (argv[-1]))))
+ (--argc, argv++, (unsigned long) atol (M4_TOKEN_DATA_TEXT (argv[-1]))))
#define ARG_STR(argc, argv) \
((argc == 0) ? "" : \
- (--argc, argv++, M4_SYMBOL_TEXT (argv[-1])))
+ (--argc, argv++, M4_TOKEN_DATA_TEXT (argv[-1])))
#define ARG_DOUBLE(argc, argv) \
((argc == 0) ? 0 : \
- (--argc, argv++, atof (M4_SYMBOL_TEXT (argv[-1]))))
+ (--argc, argv++, atof (M4_TOKEN_DATA_TEXT (argv[-1]))))
/* The main formatting function. Output is placed on the obstack OBS, the
first argument in ARGV is the formatting string, and the rest is
arguments for the string. */
-void format (struct obstack *obs, int argc, m4_symbol **argv);
+void format (struct obstack *obs, int argc, m4_token_data **argv);
void
-format (struct obstack *obs, int argc, m4_symbol **argv)
+format (struct obstack *obs, int argc, m4_token_data **argv)
{
char *fmt; /* format control string */
const char *fstart; /* beginning of current format spec */
Index: modules/gnu.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/gnu.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 gnu.c
--- modules/gnu.c 2001/09/20 03:48:05 1.10
+++ modules/gnu.c 2001/09/30 14:40:45
@@ -171,8 +171,8 @@ M4BUILTIN_HANDLER (changesyntax)
for (i = 1; i < argc; i++)
{
- m4_set_syntax (*M4_SYMBOL_TEXT (argv[i]),
- m4_expand_ranges (M4_SYMBOL_TEXT (argv[i])+1, obs));
+ m4_set_syntax (*M4_TOKEN_DATA_TEXT (argv[i]),
+ m4_expand_ranges (M4_TOKEN_DATA_TEXT (argv[i])+1, obs));
}
}
@@ -270,8 +270,8 @@ M4BUILTIN_HANDLER (regexp)
if (m4_bad_argc (argv[0], argc, 3, 4))
return;
- victim = M4_SYMBOL_TEXT (argv[1]);
- regexp = M4_SYMBOL_TEXT (argv[2]);
+ victim = M4_TOKEN_DATA_TEXT (argv[1]);
+ regexp = M4_TOKEN_DATA_TEXT (argv[2]);
buf.buffer = NULL;
buf.allocated = 0;
@@ -301,7 +301,7 @@ M4BUILTIN_HANDLER (regexp)
m4_shipout_int (obs, startpos);
else if (startpos >= 0)
{
- repl = M4_SYMBOL_TEXT (argv[3]);
+ repl = M4_TOKEN_DATA_TEXT (argv[3]);
substitute (obs, victim, repl, ®s);
}
@@ -331,7 +331,7 @@ M4BUILTIN_HANDLER (patsubst)
if (m4_bad_argc (argv[0], argc, 3, 4))
return;
- regexp = M4_SYMBOL_TEXT (argv[2]);
+ regexp = M4_TOKEN_DATA_TEXT (argv[2]);
buf.buffer = NULL;
buf.allocated = 0;
@@ -348,7 +348,7 @@ M4BUILTIN_HANDLER (patsubst)
return;
}
- victim = M4_SYMBOL_TEXT (argv[1]);
+ victim = M4_TOKEN_DATA_TEXT (argv[1]);
length = strlen (victim);
offset = 0;
@@ -433,18 +433,18 @@ M4BUILTIN_HANDLER (syncoutput)
if (m4_bad_argc (argv[0], argc, 2, 2))
return;
- if (M4_SYMBOL_TYPE (argv[1]) != M4_TOKEN_TEXT)
+ if (M4_TOKEN_DATA_TYPE (argv[1]) != M4_TOKEN_TEXT)
return;
- if (M4_SYMBOL_TEXT(argv[1])[0] == '0'
- || M4_SYMBOL_TEXT(argv[1])[0] == 'n'
- || (M4_SYMBOL_TEXT(argv[1])[0] == 'o'
- && M4_SYMBOL_TEXT(argv[1])[1] == 'f'))
+ if (M4_TOKEN_DATA_TEXT(argv[1])[0] == '0'
+ || M4_TOKEN_DATA_TEXT(argv[1])[0] == 'n'
+ || (M4_TOKEN_DATA_TEXT(argv[1])[0] == 'o'
+ && M4_TOKEN_DATA_TEXT(argv[1])[1] == 'f'))
sync_output = 0;
- else if (M4_SYMBOL_TEXT(argv[1])[0] == '1'
- || M4_SYMBOL_TEXT(argv[1])[0] == 'y'
- || (M4_SYMBOL_TEXT(argv[1])[0] == 'o'
- && M4_SYMBOL_TEXT(argv[1])[1] == 'n'))
+ else if (M4_TOKEN_DATA_TEXT(argv[1])[0] == '1'
+ || M4_TOKEN_DATA_TEXT(argv[1])[0] == 'y'
+ || (M4_TOKEN_DATA_TEXT(argv[1])[0] == 'o'
+ && M4_TOKEN_DATA_TEXT(argv[1])[1] == 'n'))
sync_output = 1;
}
Index: modules/m4.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/m4.c,v
retrieving revision 1.23
diff -u -p -u -r1.23 m4.c
--- modules/m4.c 2001/09/20 22:01:34 1.23
+++ modules/m4.c 2001/09/30 14:40:46
@@ -92,7 +92,8 @@ typedef unsigned long int unumber;
#endif
-static void include (int argc, m4_symbol **argv, boolean silent);
+static void include (int argc, m4_token_data **argv,
+ boolean silent);
static int set_trace (const char *name, m4_symbol *symbol,
void *data);
static const char *ntoa (number value, int radix);
@@ -150,7 +151,7 @@ M4BUILTIN_HANDLER (define)
if (m4_bad_argc (argv[0], argc, 2, 3))
return;
- if (M4_SYMBOL_TYPE (argv[1]) != M4_TOKEN_TEXT)
+ if (M4_TOKEN_DATA_TYPE (argv[1]) != M4_TOKEN_TEXT)
return;
if (argc == 2)
@@ -159,7 +160,7 @@ M4BUILTIN_HANDLER (define)
return;
}
- switch (M4_SYMBOL_TYPE (argv[2]))
+ switch (M4_TOKEN_DATA_TYPE (argv[2]))
{
case M4_TOKEN_TEXT:
m4_macro_define (M4ARG (1), NULL, M4ARG (2));
@@ -167,9 +168,9 @@ M4BUILTIN_HANDLER (define)
case M4_TOKEN_FUNC:
{
- lt_dlhandle handle = M4_SYMBOL_HANDLE (argv[2]);
- const m4_builtin * builtin = 0;
- m4_symbol * symbol = 0;
+ lt_dlhandle handle = M4_TOKEN_DATA_HANDLE (argv[2]);
+ const m4_builtin *builtin = 0;
+ m4_symbol *symbol = 0;
/* If we find a TOKEN_FUNC with no defining module, then
somewhere along the way we have lost the module handle. */
@@ -179,12 +180,12 @@ M4BUILTIN_HANDLER (define)
and blind_no_args flags? May as well carry these around with
the traced flag, and save a _lot_ of lookup time. */
builtin = m4_builtin_find_by_func (m4_module_builtins (handle),
- M4_SYMBOL_FUNC (argv[2]));
+ M4_TOKEN_DATA_FUNC (argv[2]));
- symbol = m4_builtin_define (M4ARG (1), handle, builtin);
+ symbol = m4_builtin_define (M4ARG (1), handle, builtin);
/* Be sure to propogate the flags from the TOKEN_FUNC. */
- M4_SYMBOL_TRACED (symbol) = M4_SYMBOL_TRACED (argv[2]);
+ M4_SYMBOL_TRACED (symbol) = M4_TOKEN_TRACED (argv[2]);
}
return;
}
@@ -210,7 +211,7 @@ M4BUILTIN_HANDLER (pushdef)
if (m4_bad_argc (argv[0], argc, 2, 3))
return;
- if (M4_SYMBOL_TYPE (argv[1]) != M4_TOKEN_TEXT)
+ if (M4_TOKEN_DATA_TYPE (argv[1]) != M4_TOKEN_TEXT)
return;
if (argc == 2)
@@ -219,7 +220,7 @@ M4BUILTIN_HANDLER (pushdef)
return;
}
- switch (M4_SYMBOL_TYPE (argv[2]))
+ switch (M4_TOKEN_DATA_TYPE (argv[2]))
{
case M4_TOKEN_TEXT:
m4_macro_pushdef (M4ARG (1), NULL, M4ARG (2));
@@ -227,15 +228,15 @@ M4BUILTIN_HANDLER (pushdef)
case M4_TOKEN_FUNC:
{
- lt_dlhandle handle = M4_SYMBOL_HANDLE (argv[2]);
- const m4_builtin * builtin = 0;
+ lt_dlhandle handle = M4_TOKEN_DATA_HANDLE (argv[2]);
+ const m4_builtin *builtin = 0;
/* If we find a TOKEN_FUNC with no defining module, then
somewhere along the way we have lost the module handle. */
assert (handle);
builtin = m4_builtin_find_by_func (m4_module_builtins (handle),
- M4_SYMBOL_FUNC (argv[2]));
+ M4_TOKEN_DATA_FUNC (argv[2]));
m4_builtin_pushdef (M4ARG (1), handle, builtin);
}
@@ -535,8 +536,8 @@ M4BUILTIN_HANDLER (changequote)
if (m4_bad_argc (argv[0], argc, 1, 3))
return;
- m4_set_quotes ((argc >= 2) ? M4_SYMBOL_TEXT (argv[1]) : NULL,
- (argc >= 3) ? M4_SYMBOL_TEXT (argv[2]) : NULL);
+ m4_set_quotes ((argc >= 2) ? M4_TOKEN_DATA_TEXT (argv[1]) : NULL,
+ (argc >= 3) ? M4_TOKEN_DATA_TEXT (argv[2]) : NULL);
}
/* Change the current comment delimiters. The function set_comment ()
@@ -549,8 +550,8 @@ M4BUILTIN_HANDLER (changecom)
if (argc == 1)
m4_set_comment ("", ""); /* disable comments */
else
- m4_set_comment (M4_SYMBOL_TEXT (argv[1]),
- (argc >= 3) ? M4_SYMBOL_TEXT (argv[2]) : NULL);
+ m4_set_comment (M4_TOKEN_DATA_TEXT (argv[1]),
+ (argc >= 3) ? M4_TOKEN_DATA_TEXT (argv[2]) : NULL);
}
@@ -561,7 +562,7 @@ M4BUILTIN_HANDLER (changecom)
/* Generic include function. Include the file given by the first argument,
if it exists. Complain about inaccesible files iff SILENT is FALSE. */
static void
-include (int argc, m4_symbol **argv, boolean silent)
+include (int argc, m4_token_data **argv, boolean silent)
{
FILE *fp;
char *name = NULL;
Index: src/freeze.c
===================================================================
RCS file: /cvsroot/m4/m4/src/freeze.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 freeze.c
--- src/freeze.c 2001/09/20 03:48:05 1.17
+++ src/freeze.c 2001/09/30 14:40:48
@@ -128,8 +128,8 @@ produce_symbol_dump (FILE *file, m4_hash
while ((place = m4_hash_iterator_next (hash, place)))
{
- const char *symbol_name = (const char *)m4_hash_iterator_key
(place);
- m4_symbol *symbol = *(m4_symbol
**)m4_hash_iterator_value(place);
+ const char *symbol_name = m4_hash_iterator_key (place);
+ m4_symbol *symbol = m4_hash_iterator_value (place);
lt_dlhandle handle = M4_SYMBOL_HANDLE (symbol);
const char *module_name = handle ? m4_module_name (handle) :
NULL;
const m4_builtin *bp;
Index: src/m4.h
===================================================================
RCS file: /cvsroot/m4/m4/src/m4.h,v
retrieving revision 1.9
diff -u -p -u -r1.9 m4.h
--- src/m4.h 2001/09/20 03:48:05 1.9
+++ src/m4.h 2001/09/30 14:40:48
@@ -99,7 +99,6 @@ char *mktemp ();
#ifdef USE_STACKOVF
void setup_stackovf_trap (char *const *, char *const *,
void (*handler) (void));
-void stackovf_exit (void);
#endif
Index: src/main.c
===================================================================
RCS file: /cvsroot/m4/m4/src/main.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 main.c
--- src/main.c 2001/09/20 03:48:05 1.25
+++ src/main.c 2001/09/30 14:40:48
@@ -516,21 +516,10 @@ warranty; not even for MERCHANTABILITY o
m4_undivert_all ();
}
- m4_module_unload_all ();
-
- /* The remaining cleanup functions systematically free all of the
- memory we still have pointers to. By definition, if there is
- anything left when we're done: it was caused by a memory leak.
- Strictly, we don't need to do this, but it makes leak detection
- a whole lot easier! */
- m4_symtab_exit ();
- m4_output_exit ();
- m4_input_exit ();
- m4_debug_exit ();
-
-#ifdef USE_STACKOVF
- stackovf_exit ();
-#endif
+ {
+ struct obstack *obs = 0;
+ m4_module_close_all (obs);
+ }
exit (exit_status);
}
Index: src/stackovf.c
===================================================================
RCS file: /cvsroot/m4/m4/src/stackovf.c,v
retrieving revision 1.7
diff -u -p -u -r1.7 stackovf.c
--- src/stackovf.c 2001/09/20 03:48:05 1.7
+++ src/stackovf.c 2001/09/30 14:40:50
@@ -118,7 +118,6 @@ extern int sigstack (struct sigstack *,
extern int sigvec (int, struct sigvec *, struct sigvec *);
#endif
-static const char *stackbuf;
static const char *stackbot;
static const char *stackend;
static const char *arg0;
@@ -336,14 +335,12 @@ setup_stackovf_trap (char *const *argv,
{
stack_t ss;
- stackbuf = (char *) xmalloc (SIGSTKSZ);
-
ss.ss_size = SIGSTKSZ;
- ss.ss_sp = (void *) stackbuf;
+ ss.ss_sp = xmalloc (ss.ss_size);
ss.ss_flags = 0;
if (sigaltstack (&ss, (stack_t *) 0) < 0)
{
- xfree (stackbuf);
+ xfree (ss.ss_sp);
error (1, errno, "sigaltstack");
}
}
@@ -353,7 +350,7 @@ setup_stackovf_trap (char *const *argv,
{
struct sigstack ss;
- stackbuf = (char *) xmalloc (2 * SIGSTKSZ);
+ char *stackbuf = xmalloc (2 * SIGSTKSZ);
ss.ss_sp = stackbuf + SIGSTKSZ;
ss.ss_onstack = 0;
@@ -409,12 +406,6 @@ Error - Do not know how to catch signals
#endif /* HAVE_SIGVEC && defined(SV_ONSTACK) */
#endif /* HAVE_SIGALTSTACK && defined(SA_ONSTACK) */
-}
-
-void
-stackovf_exit (void)
-{
- XFREE (stackbuf);
}
#endif /* USE_STACKOVF */
--
())_. 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 \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: 19-gary-revert-15-gary-cleanup-from-renaming-token-data-to-symbol.patch,
Gary V. Vaughan <=