m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to m4/src/Attic/symtab.c,v [branch]


From: Eric Blake
Subject: Changes to m4/src/Attic/symtab.c,v [branch]
Date: Tue, 06 Jun 2006 12:33:15 +0000

CVSROOT:        /sources/m4
Module name:    m4
Branch:         branch
Changes by:     Eric Blake <ericb>      06/06/06 12:33:13

Index: src/symtab.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/symtab.c,v
retrieving revision 1.1.1.1.2.5
retrieving revision 1.1.1.1.2.6
diff -u -b -r1.1.1.1.2.5 -r1.1.1.1.2.6
--- src/symtab.c        6 Jun 2006 12:28:46 -0000       1.1.1.1.2.5
+++ src/symtab.c        6 Jun 2006 12:33:13 -0000       1.1.1.1.2.6
@@ -297,25 +297,35 @@
     }
 }
 
-/*----------------------------------------------------------------------.
-| 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        |
-| 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.                                
|
-`----------------------------------------------------------------------*/
+| 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.     |
+|                                                                 |
+| FUNC may safely call lookup_symbol with mode SYMBOL_POPDEF or           |
+| SYMBOL_LOOKUP, but any other mode can break the iteration.      |
+`-----------------------------------------------------------------*/
 
 void
 hack_all_symbols (hack_symbol *func, const char *data)
 {
   size_t h;
   symbol *sym;
+  symbol *next;
 
   for (h = 0; h < hash_table_size; h++)
     {
-      for (sym = symtab[h]; sym != NULL; sym = SYMBOL_NEXT (sym))
+      /* We allow func to call SYMBOL_POPDEF, which can invalidate
+         sym, so we must grab the next element to traverse before
+         calling func.  */
+      for (sym = symtab[h]; sym != NULL; sym = next)
+        {
+          next = SYMBOL_NEXT (sym);
        (*func) (sym, data);
     }
+    }
 }
 
 #ifdef DEBUG_SYM




reply via email to

[Prev in Thread] Current Thread [Next in Thread]