Mercurial > hg > octave-nkf
diff src/ov-usr-fcn.cc @ 8142:54b41376e381
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
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 24 Sep 2008 13:31:04 -0400 |
parents | b3e667f1ab4c |
children | 188d38a553c7 |
line wrap: on
line diff
--- 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.