changeset 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 3a9a56999ce5 (current diff) 000cd393f3c1 (diff)
children 9546bb28648c
files doc/interpreter/system.txi src/ov-usr-fcn.cc
diffstat 3 files changed, 81 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/system.txi	Tue Apr 17 13:18:56 2012 -0400
+++ b/doc/interpreter/system.txi	Thu Apr 19 16:26:56 2012 -0400
@@ -53,7 +53,7 @@
 Microseconds after the second (0-999999).
 
 @item sec
-Seconds after the minute (0-61).  This number can be 61 to account
+Seconds after the minute (0-60).  This number can be 60 to account
 for leap seconds.
 
 @item min
--- 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]);
+*/
--- a/src/pt-assign.cc	Tue Apr 17 13:18:56 2012 -0400
+++ b/src/pt-assign.cc	Thu Apr 19 16:26:56 2012 -0400
@@ -431,7 +431,30 @@
                     }
                 }
               else
-                error ("element number %d undefined in return list", k+1);
+                {
+                  // This can happen for a function like
+                  //
+                  //   function varargout = f ()
+                  //     varargout{1} = nargout;
+                  //   endfunction
+                  //
+                  // called with
+                  //
+                  //    [a, ~] = f ();
+                  //
+                  // Then the list of of RHS values will contain one
+                  // element but we are iterating over the list of all
+                  // RHS values.  We shouldn't complain that a value we
+                  // don't need is missing from the list.
+
+                  if (ult.is_black_hole ())
+                    {
+                      k++;
+                      continue;
+                    }
+                  else
+                    error ("element number %d undefined in return list", k+1);
+                }
             }
 
           if (error_state)
@@ -467,6 +490,19 @@
   return retval;
 }
 
+/*
+%!function varargout = f ()
+%!  varargout{1} = nargout;
+%!endfunction
+%!
+%!test
+%! [a, ~] = f ();
+%! assert (a, 2);
+%!test
+%! [a, ~, ~, ~, ~] = f ();
+%! assert (a, 5);
+*/
+
 std::string
 tree_multi_assignment::oper (void) const
 {