Mercurial > octave-nkf
diff src/ov-usr-fcn.cc @ 14573:1c0f0e8f9a1b
maint: periodic merge of stable to default
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 Apr 2012 16:26:56 -0400 |
parents | be18c9e359bf 6131fead3135 |
children | f7afecdd87ef |
line wrap: on
line diff
--- a/src/ov-usr-fcn.cc Tue Apr 17 13:18:56 2012 -0400 +++ b/src/ov-usr-fcn.cc Thu Apr 19 16:26:56 2012 -0400 @@ -602,6 +602,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; @@ -623,11 +626,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, , @@ -924,3 +927,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]); +*/