changeset 9315:73e36b147e45

properly clear global variables
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 08 Jun 2009 14:57:41 +0200
parents 3a447ea9e77b
children c539ec5726e7
files src/ChangeLog src/symtab.h
diffstat 2 files changed, 24 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-08  Jaroslav Hajek  <highegg@gmail.com>
+
+	* symtab.h (symbol_table::do_clear_global,
+	symbol_table::do_clear_global_pattern): Properly erase from both local
+	and global table.
+
 2009-06-08  Jaroslav Hajek  <highegg@gmail.com>
 
 	* variables.cc (Fclear): Clear also globals when called without
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -2143,15 +2143,14 @@
 	symbol_record& sr = p->second;
 
 	if (sr.is_global ())
-	  {
-	    global_table_iterator q = global_table.find (name);
-
-	    if (q != global_table.end ())
-	      global_table.erase (q);
-
-	    sr.unmark_global ();
-	  }
+          sr.unmark_global ();
       }
+
+    global_table_iterator q = global_table.find (name);
+
+    if (q != global_table.end ())
+      global_table.erase (q);
+
   }
 
   void do_clear_variable (const std::string& name)
@@ -2170,19 +2169,18 @@
       {
 	symbol_record& sr = p->second;
 
-	if (sr.is_global ())
-	  {
-	    if (pattern.match (sr.name ()))
-	      {
-		global_table_iterator q = global_table.find (sr.name ());
-
-		if (q != global_table.end ())
-		  global_table.erase (q);
-
-		sr.unmark_global ();
-	      }
-	  }
+	if (sr.is_global () && pattern.match (sr.name ()))
+          sr.unmark_global ();
       }
+
+    for (global_table_iterator q = global_table.begin (); 
+         q != global_table.end (); q++)
+      {
+	if (pattern.match (q->first))
+          global_table.erase (q);
+      }
+
+
   }
 
   void do_clear_variable_pattern (const std::string& pat)