# HG changeset patch # User John W. Eaton # Date 1222277464 14400 # Node ID 54b41376e381691eaa00b93efdf0a937b72bb651 # Parent 31d7885d98690ca9823082227870063bfb43514c ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2008-09-24 John W. Eaton + * ov-usr-fcn.cc (octave_user_function::do_multi_index_op): + Add symbol_table::clear_variables cleanup function to the + unwind_protect stack after the parameter list cleanup functions. + * load-path.cc (load_path::do_initialize): Check for OCTAVE_PATH in the environment, not OCTAVE_LOADPATH. diff --git a/src/ov-usr-fcn.cc b/src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -375,11 +375,6 @@ unwind_protect::add (symbol_table::pop_context); } - else - { - // Force symbols to be undefined again when this function exits. - unwind_protect::add (symbol_table::clear_variables); - } // Save and restore args passed for recursive calls. @@ -411,6 +406,21 @@ unwind_protect::add (clear_param_list, ret_list); + if (call_depth == 0) + { + // Force symbols to be undefined again when this function + // exits. + // + // This cleanup function is added to the unwind_protect stack + // after the calls to clear the parameter lists so that local + // variables will be cleared before the parameter lists are + // cleared. That way, any function parameters that have been + // declared global will be unmarked as global before they are + // undefined by the clear_param_list cleanup function. + + unwind_protect::add (symbol_table::clear_variables); + } + // The following code is in a separate scope to avoid warnings from // G++ about `goto abort' crossing the initialization of some // variables.