diff src/symtab.cc @ 8691:7838271ee25c

symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
author John W. Eaton <jwe@octave.org>
date Thu, 05 Feb 2009 19:58:04 -0500
parents 188d38a553c7
children f57c9fdb6836
line wrap: on
line diff
--- a/src/symtab.cc	Thu Feb 05 19:39:38 2009 -0500
+++ b/src/symtab.cc	Thu Feb 05 19:58:04 2009 -0500
@@ -488,8 +488,27 @@
   (tree_argument_list *args, const string_vector& arg_names,
    octave_value_list& evaluated_args, bool& args_evaluated)
 {
-  static bool deja_vu = false;
+  octave_value retval = xfind (args, arg_names, evaluated_args, args_evaluated);
+
+  if (! retval.is_defined ())
+    {
+      // It is possible that the user created a file on the fly since
+      // the last prompt or chdir, so try updating the load path and
+      // searching again.
+
+      load_path::update ();
 
+      retval = xfind (args, arg_names, evaluated_args, args_evaluated);
+    }
+
+  return retval;
+}
+
+octave_value
+symbol_table::fcn_info::fcn_info_rep::xfind
+  (tree_argument_list *args, const string_vector& arg_names,
+   octave_value_list& evaluated_args, bool& args_evaluated)
+{
   // Subfunction.  I think it only makes sense to check for
   // subfunctions if we are currently executing a function defined
   // from a .m file.
@@ -672,29 +691,9 @@
   if (fcn.is_defined ())
     return fcn;
 
-  // Built-in function.
-
-  if (built_in_function.is_defined ())
-    return built_in_function;
-
-  // At this point, we failed to find anything.  It is possible that
-  // the user created a file on the fly since the last prompt or
-  // chdir, so try updating the load path and searching again.
-
-  octave_value retval;
+  // Built-in function (might be undefined).
 
-  if (! deja_vu)
-    {
-      load_path::update ();
-
-      deja_vu = true;
-
-      retval = find (args, arg_names, evaluated_args, args_evaluated);
-    }
-
-  deja_vu = false;
-
-  return retval;
+  return built_in_function;
 }
 
 octave_value