m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/m4/symtab.c,v


From: Eric Blake
Subject: Changes to m4/m4/symtab.c,v
Date: Thu, 18 Oct 2007 16:45:55 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      07/10/18 16:45:54

Index: m4/symtab.c
===================================================================
RCS file: /sources/m4/m4/m4/symtab.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- m4/symtab.c 12 Sep 2007 01:14:48 -0000      1.77
+++ m4/symtab.c 18 Oct 2007 16:45:53 -0000      1.78
@@ -82,13 +82,19 @@
   assert (symtab);
   assert (symtab->table);
 
-  m4_symtab_apply  (symtab, symbol_destroy_CB, NULL);
+  m4_symtab_apply (symtab, true, symbol_destroy_CB, NULL);
   m4_hash_delete (symtab->table);
   free (symtab);
 }
 
+/* For every symbol in SYMTAB, execute the callback FUNC with the name
+   and value of the symbol being visited, and the opaque parameter
+   USERDATA.  Skip undefined symbols that are placeholders for
+   traceon, unless INCLUDE_TRACE is true.  If FUNC returns non-NULL,
+   abort the iteration and return the same result; otherwise return
+   NULL when iteration completes.  */
 void *
-m4_symtab_apply (m4_symbol_table *symtab,
+m4_symtab_apply (m4_symbol_table *symtab, bool include_trace,
                 m4_symtab_apply_func *func, void *userdata)
 {
   m4_hash_iterator *place  = NULL;
@@ -100,10 +106,10 @@
 
   while ((place = m4_get_hash_iterator_next (symtab->table, place)))
     {
-      result = (*func) (symtab,
-                       (const char *) m4_get_hash_iterator_key   (place),
-                       (m4_symbol *)  m4_get_hash_iterator_value (place),
-                       userdata);
+      m4_symbol *symbol = m4_get_hash_iterator_value (place);
+      if (symbol->value || include_trace)
+       result = func (symtab, (const char *) m4_get_hash_iterator_key (place),
+                      symbol, userdata);
 
       if (result != NULL)
        {
@@ -700,7 +706,7 @@
 static M4_GNUC_UNUSED void *
 symtab_dump (m4_symbol_table *symtab)
 {
-  return m4_symtab_apply (symtab, dump_symbol_CB, NULL);
+  return m4_symtab_apply (symtab, true, dump_symbol_CB, NULL);
 }
 
 static void *




reply via email to

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