# HG changeset patch # User John W. Eaton # Date 1334773294 14400 # Node ID 6131fead3135a9d6d74fe8a035c25c77fd785fcd # Parent d07d96e53612af19a13f669349cd986109ce2c8f ensure isargout is not sticky * ov-usr-fcn.cc (octave_user_function::bind_automatic_vars): Ensure .ignored. is undefined by default. New tests. diff -r d07d96e53612 -r 6131fead3135 src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc Tue Apr 17 14:42:49 2012 -0400 +++ b/src/ov-usr-fcn.cc Wed Apr 18 14:21:34 2012 -0400 @@ -598,6 +598,9 @@ if (takes_varargs ()) symbol_table::varref ("varargin") = va_args.cell_value (); + // Force .ignored. variable to be undefined by default. + symbol_table::varref (".ignored.") = octave_value (); + if (lvalue_list) { octave_idx_type nbh = 0; @@ -619,11 +622,11 @@ } symbol_table::varref (".ignored.") = bh; - - symbol_table::mark_hidden (".ignored."); - symbol_table::mark_automatic (".ignored."); } } + + symbol_table::mark_hidden (".ignored."); + symbol_table::mark_automatic (".ignored."); } DEFUN (nargin, args, , @@ -873,3 +876,40 @@ return retval; } + +/* +%!function [x, y] = try_isargout () +%! if (isargout (1)) +%! if (isargout (2)) +%! x = 1; y = 2; +%! else +%! x = -1; +%! endif +%! else +%! if (isargout (2)) +%! y = -2; +%! else +%! error ("no outputs requested"); +%! endif +%! endif +%!endfunction +%! +%!test +%! [x, y] = try_isargout (); +%! assert ([x, y], [1, 2]); +%! +%!test +%! [x, ~] = try_isargout (); +%! assert (x, -1); +%! +%!test +%! [~, y] = try_isargout (); +%! assert (y, -2); +%! +%!error [~, ~] = try_isargout (); +%! +%% Check to see that isargout isn't sticky: +%!test +%! [x, y] = try_isargout (); +%! assert ([x, y], [1, 2]); +*/