# HG changeset patch # User John W. Eaton # Date 1233881884 18000 # Node ID 7838271ee25c70bf9e30c93454286aa0d4406c2d # Parent 6e9887f9cf9f646de4e166f3236279e106c071b0 symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call diff -r 6e9887f9cf9f -r 7838271ee25c src/ChangeLog --- a/src/ChangeLog Thu Feb 05 19:39:38 2009 -0500 +++ b/src/ChangeLog Thu Feb 05 19:58:04 2009 -0500 @@ -1,5 +1,10 @@ 2009-02-05 John W. Eaton + * symtab.cc (symbol_table::fcn_info::cn_info_rep::xfind): + New function. + (symbol_table::fcn_info::cn_info_rep::find): + Use it to avoid recursive call. + * graphics.cc (Fdrawnow): Return after errors. Don't strip trailing directory separator from name used in call to file_stat. diff -r 6e9887f9cf9f -r 7838271ee25c src/symtab.cc --- 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 diff -r 6e9887f9cf9f -r 7838271ee25c src/symtab.h --- a/src/symtab.h Thu Feb 05 19:39:38 2009 -0500 +++ b/src/symtab.h Thu Feb 05 19:58:04 2009 -0500 @@ -702,6 +702,10 @@ private: + octave_value + xfind (tree_argument_list *args, const string_vector& arg_names, + octave_value_list& evaluated_args, bool& args_evaluated); + // No copying! fcn_info_rep (const fcn_info_rep&);