diff src/parse.y @ 7755:ea9cb4d68dbf

avoid installing subfunctions twice
author John W. Eaton <jwe@octave.org>
date Sun, 04 May 2008 23:36:31 -0400
parents 5c6c6f4803c8
children 5adeea5de26c
line wrap: on
line diff
--- a/src/parse.y	Sun May 04 21:45:47 2008 -0400
+++ b/src/parse.y	Sun May 04 23:36:31 2008 -0400
@@ -2529,21 +2529,7 @@
       help_buf.pop ();
     }
 
-  if (lexer_flags.parsing_nested_function)
-    {
-      std::string nm = fcn->name ();
-
-      fcn->mark_as_nested_function ();
-
-      symbol_table::install_subfunction (nm, octave_value (fcn));
-
-      if (lexer_flags.parsing_nested_function < 0)
-	{
-	  lexer_flags.parsing_nested_function = 0;
-	  symbol_table::reset_parent_scope ();
-	}
-    }
-  else if (reading_fcn_file)
+  if (reading_fcn_file && ! lexer_flags.parsing_nested_function)
     curr_fcn_ptr = fcn;
   else
     curr_fcn_ptr = 0;
@@ -2566,11 +2552,31 @@
 	fcn->stash_leading_comment (lc);
 
       fcn->define_ret_list (ret_list);
+
+      if (lexer_flags.parsing_nested_function)
+	{
+	  std::string nm = fcn->name ();
+
+	  fcn->mark_as_nested_function ();
+
+	  symbol_table::install_subfunction (nm, octave_value (fcn));
+
+	  if (lexer_flags.parsing_nested_function < 0)
+	    {
+	      lexer_flags.parsing_nested_function = 0;
+	      symbol_table::reset_parent_scope ();
+	    }
+	}
+      else if (! curr_fcn_ptr)
+	{
+	  // FIXME -- there should be a better way to indicate that we
+	  // should create a tree_function_def object other than
+	  // looking at curr_fcn_ptr...
+
+	  retval = new tree_function_def (fcn);
+	}
     }
 
-  if (! curr_fcn_ptr)
-    retval = new tree_function_def (fcn);
-
   return retval;
 }