/[m4]/m4/m4/symtab.c
ViewVC logotype

Diff of /m4/m4/symtab.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by gary, Fri Jun 13 13:05:45 2003 UTC revision 1.34 by gary, Fri Jun 13 13:54:36 2003 UTC
# Line 44  Line 44 
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;
# Line 122  m4__symtab_exit (void) Line 122  m4__symtab_exit (void)
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);
# Line 218  m4_symbol_popdef (const char *name) Line 218  m4_symbol_popdef (const char *name)
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)
# Line 241  m4_symbol_popdef (const char *name) Line 240  m4_symbol_popdef (const char *name)
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  }  }
# Line 408  symtab_print_list (const void *name, voi Line 407  symtab_print_list (const void *name, voi
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.  */

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26