# HG changeset patch # User jwe # Date 1150224953 0 # Node ID 6bd94066d360a39daed6a5740fa775587ad98913 # Parent 6a558a8763df809c02095347e61ff51ddb2229f2 [project @ 2006-06-13 18:55:53 by jwe] diff -r 6a558a8763df -r 6bd94066d360 src/ChangeLog --- a/src/ChangeLog Tue Jun 13 16:43:44 2006 +0000 +++ b/src/ChangeLog Tue Jun 13 18:55:53 2006 +0000 @@ -1,5 +1,8 @@ 2006-06-13 John W. Eaton + * pt-stmt.cc (tree_statement_list::eval): Revise previous change + to preserve return-last-value-computed semantics. + * DLD-FUNCTIONS/fsolve.cc (hybrd_info_to_fsolve_info): Warn about invalid values of INFO from MINPACK instead of calling panic_impossible. diff -r 6a558a8763df -r 6bd94066d360 src/pt-stmt.cc --- a/src/pt-stmt.cc Tue Jun 13 16:43:44 2006 +0000 +++ b/src/pt-stmt.cc Tue Jun 13 18:55:53 2006 +0000 @@ -154,42 +154,58 @@ { octave_value_list retval; + static octave_value_list empty_list; + if (error_state) return retval; - for (iterator p = begin (); p != end (); p++) - { - tree_statement *elt = *p; + iterator p = begin (); - if (elt) + if (p != end ()) + { + while (true) { - OCTAVE_QUIT; + tree_statement *elt = *p++; + + if (elt) + { + OCTAVE_QUIT; - // Clear preivous values before next statement is evaluated - // so that we aren't holding an extra reference to a value - // that may be used next. For example, in code like this: - // - // X = rand (N); ## refcount should be 1 after this statement. - // X(idx) = val; ## no extra copy should be needed, but - // ## we will be faked out if retval is not - // ## cleared between statements here. + retval = elt->eval (silent, nargout, function_body); + + if (error_state) + break; + + if (tree_break_command::breaking + || tree_continue_command::continuing) + break; + + if (tree_return_command::returning) + break; - retval = octave_value_list (); - - retval = elt->eval (silent, nargout, function_body); - - if (error_state) - break; + if (p == end ()) + break; + else + { + // Clear preivous values before next statement is + // evaluated so that we aren't holding an extra + // reference to a value that may be used next. For + // example, in code like this: + // + // X = rand (N); ## refcount for X should be 1 + // ## after this statement + // + // X(idx) = val; ## no extra copy of X should be + // ## needed, but we will be faked + // ## out if retval is not cleared + // ## between statements here - if (tree_break_command::breaking - || tree_continue_command::continuing) - break; - - if (tree_return_command::returning) - break; + retval = empty_list; + } + } + else + error ("invalid statement found in statement list!"); } - else - error ("invalid statement found in statement list!"); } return retval;