diff src/symtab.cc @ 7968:0d607e8dbbfa

eliminate curr_parent_function; fix subfunction lookup
author John W. Eaton <jwe@octave.org>
date Wed, 23 Jul 2008 17:16:50 -0400
parents db6478d9c669
children 5bf4e2c13ed8
line wrap: on
line diff
--- a/src/symtab.cc	Tue Jul 22 17:24:17 2008 -0400
+++ b/src/symtab.cc	Wed Jul 23 17:16:50 2008 -0400
@@ -404,29 +404,40 @@
 
   scope_val_iterator r = subfunctions.find (xcurrent_scope);
 
+  octave_function *curr_fcn = 0;
+
   if (r != subfunctions.end ())
     {
       // FIXME -- out-of-date check here.
 
       return r->second;
     }
-  else if (curr_parent_function)
+  else
     {
-      scope_id pscope = curr_parent_function->scope ();
+      curr_fcn = octave_call_stack::current ();
 
-      r = subfunctions.find (pscope);
+      if (curr_fcn)
+	{
+	  scope_id pscope = curr_fcn->parent_fcn_scope ();
 
-      if (r != subfunctions.end ())
-	{
-	  // FIXME -- out-of-date check here.
+	  if (pscope > 0)
+	    {
+	      r = subfunctions.find (pscope);
 
-	  return r->second;
+	      if (r != subfunctions.end ())
+		{
+		  // FIXME -- out-of-date check here.
+
+		  return r->second;
+		}
+	    }
 	}
     }
 
   // Private function.
 
-  octave_function *curr_fcn = octave_call_stack::current ();
+  if (! curr_fcn)
+    curr_fcn = octave_call_stack::current ();
 
   if (curr_fcn)
     {