changeset 20884:f1b2a2dbc0e1

2015 Code Sprint: use ovl () in C++ files. * __dsearchn__.cc, balance.cc, colloc.cc, data.cc, debug.cc, dirfns.cc, eig.cc, file-io.cc, getgrent.cc, getpwent.cc, givens.cc, help.cc, hess.cc, mgorth.cc, quad.cc: Replace assignments to retval(?) with calls to ovl().
author José Luis García Pallero <jgpallero@gmail.com>
date Sun, 13 Dec 2015 07:59:40 -0800
parents c7d881aec36c
children e5f78891ad9e
files libinterp/corefcn/__dsearchn__.cc libinterp/corefcn/balance.cc libinterp/corefcn/colloc.cc libinterp/corefcn/data.cc libinterp/corefcn/debug.cc libinterp/corefcn/dirfns.cc libinterp/corefcn/eig.cc libinterp/corefcn/file-io.cc libinterp/corefcn/getgrent.cc libinterp/corefcn/getpwent.cc libinterp/corefcn/givens.cc libinterp/corefcn/help.cc libinterp/corefcn/hess.cc libinterp/corefcn/mgorth.cc libinterp/corefcn/quad.cc
diffstat 15 files changed, 134 insertions(+), 203 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__dsearchn__.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/__dsearchn__.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -95,8 +95,7 @@
           pxi += n;
         }
 
-      retval(1) = dist;
-      retval(0) = idx;
+      retval = ovl (idx, dist);
     }
 
   return retval;
--- a/libinterp/corefcn/balance.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/balance.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -158,17 +158,17 @@
               FloatComplexAEPBALANCE result (fcaa, noperm, noscal);
 
               if (nargout == 0 || nargout == 1)
-                retval(0) = result.balanced_matrix ();
+                retval = ovl (result.balanced_matrix ());
               else if (nargout == 2)
                 {
-                  retval(1) = result.balanced_matrix ();
-                  retval(0) = result.balancing_matrix ();
+                  retval = ovl (result.balancing_matrix (),
+                                result.balanced_matrix ());
                 }
               else
                 {
-                  retval(2) = result.balanced_matrix ();
-                  retval(1) = result.permuting_vector ();
-                  retval(0) = result.scaling_vector ();
+                  retval = ovl (result.scaling_vector (),
+                                result.permuting_vector (),
+                                result.balanced_matrix ());
                 }
 
             }
@@ -177,17 +177,17 @@
               FloatAEPBALANCE result (faa, noperm, noscal);
 
               if (nargout == 0 || nargout == 1)
-                retval(0) = result.balanced_matrix ();
+                retval = ovl (result.balanced_matrix ());
               else if (nargout == 2)
                 {
-                  retval(1) = result.balanced_matrix ();
-                  retval(0) = result.balancing_matrix ();
+                  retval = ovl (result.balancing_matrix (),
+                                result.balanced_matrix ());
                 }
               else
                 {
-                  retval(2) = result.balanced_matrix ();
-                  retval(1) = result.permuting_vector ();
-                  retval(0) = result.scaling_vector ();
+                  retval = ovl (result.scaling_vector (),
+                                result.permuting_vector (),
+                                result.balanced_matrix ());
                 }
             }
         }
@@ -198,17 +198,17 @@
               ComplexAEPBALANCE result (caa, noperm, noscal);
 
               if (nargout == 0 || nargout == 1)
-                retval(0) = result.balanced_matrix ();
+                retval = ovl (result.balanced_matrix ());
               else if (nargout == 2)
                 {
-                  retval(1) = result.balanced_matrix ();
-                  retval(0) = result.balancing_matrix ();
+                  retval = ovl (result.balancing_matrix (),
+                                result.balanced_matrix ());
                 }
               else
                 {
-                  retval(2) = result.balanced_matrix ();
-                  retval(1) = result.permuting_vector ();
-                  retval(0) = result.scaling_vector ();
+                  retval = ovl (result.scaling_vector (),
+                                result.permuting_vector (),
+                                result.balanced_matrix ());
                 }
             }
           else
@@ -216,17 +216,17 @@
               AEPBALANCE result (aa, noperm, noscal);
 
               if (nargout == 0 || nargout == 1)
-                retval(0) = result.balanced_matrix ();
+                retval = ovl (result.balanced_matrix ());
               else if (nargout == 2)
                 {
-                  retval(1) = result.balanced_matrix ();
-                  retval(0) = result.balancing_matrix ();
+                  retval = ovl (result.balancing_matrix (),
+                                result.balanced_matrix ());
                 }
               else
                 {
-                  retval(2) = result.balanced_matrix ();
-                  retval(1) = result.permuting_vector ();
-                  retval(0) = result.scaling_vector ();
+                  retval = ovl (result.scaling_vector (),
+                                result.permuting_vector (),
+                                result.balanced_matrix ());
                 }
             }
         }
--- a/libinterp/corefcn/colloc.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/colloc.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -95,10 +95,7 @@
   Matrix B = wts.second ();
   ColumnVector q = wts.quad_weights ();
 
-  retval(3) = q;
-  retval(2) = B;
-  retval(1) = A;
-  retval(0) = r;
+  retval = ovl (r, A, B, q);
 
   return retval;
 }
--- a/libinterp/corefcn/data.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/data.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -500,7 +500,7 @@
     print_usage ();
 
   if (nargout < 2)
-    retval(0) = args(0).log2 ();
+    retval = ovl (args(0).log2 ());
   else if (args(0).is_single_type ())
     {
       if (args(0).is_real_type ())
@@ -510,8 +510,7 @@
           // FIXME: should E be an int value?
           FloatMatrix e;
           map_2_xlog2 (x, f, e);
-          retval(1) = e;
-          retval(0) = f;
+          retval = ovl (f, e);
         }
       else if (args(0).is_complex_type ())
         {
@@ -520,8 +519,7 @@
           // FIXME: should E be an int value?
           FloatNDArray e;
           map_2_xlog2 (x, f, e);
-          retval(1) = e;
-          retval(0) = f;
+          retval = ovl (f, e);
         }
     }
   else if (args(0).is_real_type ())
@@ -531,8 +529,7 @@
       // FIXME: should E be an int value?
       Matrix e;
       map_2_xlog2 (x, f, e);
-      retval(1) = e;
-      retval(0) = f;
+      retval = ovl (f, e);
     }
   else if (args(0).is_complex_type ())
     {
@@ -541,8 +538,7 @@
       // FIXME: should E be an int value?
       NDArray e;
       map_2_xlog2 (x, f, e);
-      retval(1) = e;
-      retval(0) = f;
+      retval = ovl (f, e);
     }
   else
     gripe_wrong_type_arg ("log2", args(0));
@@ -6378,9 +6374,7 @@
 
 #endif
 
-  retval(2) = sys;
-  retval(1) = usr;
-  retval(0) = sys + usr;
+  retval = ovl (sys + usr, usr, sys);
 
   return retval;
 }
@@ -6455,22 +6449,20 @@
 @seealso{sortrows, issorted}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
-  sortmode smode = ASCENDING;
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
 
-  bool return_idx = nargout > 1;
-
+  sortmode smode = ASCENDING;
+  bool return_idx = (nargout > 1);
+  bool have_sortmode = (nargin > 1 && args(1).is_string ()); 
   octave_value arg = args(0);
 
   int dim = 0;
   if (nargin > 1)
     {
-      if (args(1).is_string ())
+      if (have_sortmode)
         {
           std::string mode = args(1).string_value ();
           if (mode == "ascend")
@@ -6486,7 +6478,7 @@
 
   if (nargin > 2)
     {
-      if (args(1).is_string ())
+      if (have_sortmode)
         error ("sort: DIM must be a valid dimension");
 
       std::string mode = args(2).xstring_value ("sort: MODE must be a string");
@@ -6500,9 +6492,8 @@
     }
 
   const dim_vector dv = arg.dims ();
-  if (nargin == 1 || args(1).is_string ())
+  if (nargin == 1 || have_sortmode)
     {
-      // Find first non singleton dimension
       dim = dv.first_non_singleton ();
     }
   else
@@ -6511,17 +6502,19 @@
         error ("sort: DIM must be a valid dimension");
     }
 
+  octave_value_list retval (return_idx ? 2 : 1);
+
   if (return_idx)
     {
-      retval.resize (2);
-
       Array<octave_idx_type> sidx;
 
+      // NOTE: Can not change this to ovl() call because arg.sort changes sidx
+      //       and objects are declared const in ovl prototype.
       retval(0) = arg.sort (sidx, dim, smode);
-      retval(1) = idx_vector (sidx, dv(dim)); // No checking, extent is known.
+      retval(1) = idx_vector (sidx, dv(dim));  // No checking, extent is known.
     }
   else
-    retval(0) = arg.sort (dim, smode);
+    retval = ovl (arg.sort (dim, smode));
 
   return retval;
 }
@@ -6880,8 +6873,8 @@
 %!error <needs a vector> issorted ([])
 
 ## Test input validation
-%!error issorted () 
-%!error issorted (1,2,3,4) 
+%!error issorted ()
+%!error issorted (1,2,3,4)
 %!error <second argument must be a string> issorted (1, 2)
 %!error <second argument must be a string> issorted (1, {"rows"})
 %!error <sparse matrices not yet supported> issorted (sparse ([1 2 3]), "rows")
--- a/libinterp/corefcn/debug.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/debug.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -1212,8 +1212,8 @@
                                                      curr_frame,
                                                      false);
 
-      retval(1) = curr_frame < 0 ? 1 : curr_frame + 1;
-      retval(0) = stk;
+      retval = ovl (stk,
+                    curr_frame < 0 ? 1 : curr_frame + 1);
     }
 
   return retval;
--- a/libinterp/corefcn/dirfns.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/dirfns.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -123,7 +123,7 @@
 @end deftypefn")
 {
   int nargin = args.length ();
- 
+
   if (nargin > 1)
     print_usage ();
 
--- a/libinterp/corefcn/eig.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/eig.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -153,7 +153,7 @@
 
       if (nargout == 0 || nargout == 1)
         {
-          retval(0) = result.eigenvalues ();
+          retval = ovl (result.eigenvalues ());
         }
       else
         {
@@ -161,8 +161,7 @@
 
           FloatComplexDiagMatrix d (result.eigenvalues ());
 
-          retval(1) = d;
-          retval(0) = result.eigenvectors ();
+          retval = ovl (result.eigenvectors (), d);
         }
     }
   else
@@ -204,7 +203,7 @@
 
       if (nargout == 0 || nargout == 1)
         {
-          retval(0) = result.eigenvalues ();
+          retval = ovl (result.eigenvalues ());
         }
       else
         {
@@ -212,8 +211,7 @@
 
           ComplexDiagMatrix d (result.eigenvalues ());
 
-          retval(1) = d;
-          retval(0) = result.eigenvectors ();
+          retval = ovl (result.eigenvectors (), d);
         }
     }
 
--- a/libinterp/corefcn/file-io.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/file-io.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -339,8 +339,7 @@
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  retval(1) = 0;
-  retval(0) = -1;
+  retval = ovl (-1, 0);
 
   octave_stream os = octave_stream_list::lookup (args(0), who);
 
@@ -352,8 +351,7 @@
 
   if (! err)
     {
-      retval(1) = tmp.length ();
-      retval(0) = tmp;
+      retval = ovl (tmp, tmp.length ());
     }
 
   return retval;
@@ -386,8 +384,7 @@
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  retval(1) = 0.0;
-  retval(0) = -1.0;
+  retval = ovl (-1.0, 0.0);
 
   octave_stream os = octave_stream_list::lookup (args(0), who);
 
@@ -399,8 +396,7 @@
 
   if (! err)
     {
-      retval(1) = tmp.length ();
-      retval(0) = tmp;
+      retval = ovl (tmp, tmp.length ());
     }
 
   return retval;
@@ -627,7 +623,7 @@
 {
   octave_value_list retval;
 
-  retval(0) = -1.0;
+  retval = ovl (-1.0);
 
   int nargin = args.length ();
 
@@ -650,9 +646,7 @@
         {
           string_vector tmp = octave_stream_list::get_info (args(0));
 
-          retval(2) = tmp(2);
-          retval(1) = tmp(1);
-          retval(0) = tmp(0);
+          retval = ovl (tmp(0), tmp(1), tmp(2));
 
           return retval;
         }
@@ -670,15 +664,13 @@
 
   if (os)
     {
-      retval(1) = "";
-      retval(0) = octave_stream_list::insert (os);
+      retval = ovl (octave_stream_list::insert (os), "");
     }
   else
     {
       int error_number = 0;
 
-      retval(1) = os.error (false, error_number);
-      retval(0) = -1.0;
+      retval = ovl (-1.0, os.error (false, error_number));
     }
 
   return retval;
@@ -990,9 +982,7 @@
   if (nargin == 0)
     print_usage ();
 
-  retval(2) = -1.0;
-  retval(1) = "unknown error";
-  retval(0) = "";
+  retval = ovl ("", "unknown error", -1.0);
 
   octave_ostrstream *ostr = new octave_ostrstream ();
 
@@ -1097,15 +1087,13 @@
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
       if (args(1).is_string ())
-        retval = os.oscanf (args(1), who);
+        retval = ovl (os.oscanf (args(1), who));
       else
         error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
     {
-      retval(2) = "unknown error";
-      retval(1) = 0.0;
-      retval(0) = Matrix ();
+      retval = ovl (Matrix (), 0.0, "unknown error");
 
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
@@ -1120,9 +1108,7 @@
 
           octave_value tmp = os.scanf (args(1), size, count, who);
 
-          retval(2) = os.error ();
-          retval(1) = count;
-          retval(0) = tmp;
+          retval = ovl (tmp, count, os.error ());
         }
       else
         error ("%s: format must be a string", who.c_str ());
@@ -1179,7 +1165,7 @@
       if (os.is_valid ())
         {
           if (args(1).is_string ())
-            retval = os.oscanf (args(1), who);
+            retval = ovl (os.oscanf (args(1), who));
           else
             error ("%s: format TEMPLATE must be a string", who.c_str ());
         }
@@ -1188,10 +1174,7 @@
     }
   else
     {
-      retval(3) = -1.0;
-      retval(2) = "unknown error";
-      retval(1) = 0.0;
-      retval(0) = Matrix ();
+      retval = ovl (Matrix (), 0.0, "unknown error", -1.0);
 
       std::string data = get_sscanf_data (args(0));
 
@@ -1215,10 +1198,8 @@
               // position will clear it.
               std::string errmsg = os.error ();
 
-              retval(3) = (os.eof () ? data.length () : os.tell ()) + 1;
-              retval(2) = errmsg;
-              retval(1) = count;
-              retval(0) = tmp;
+              retval = ovl (tmp, count, errmsg,
+                            (os.eof () ? data.length () : os.tell ()) + 1);
             }
           else
             error ("%s: format TEMPLATE must be a string",
@@ -1476,8 +1457,7 @@
   if (nargin < 1 || nargin > 5)
     print_usage ();
 
-  retval(1) = -1.0;
-  retval(0) = Matrix ();
+  retval = ovl (Matrix (), -1.0);
 
   octave_stream os = octave_stream_list::lookup (args(0), "fread");
 
@@ -1509,8 +1489,7 @@
 
   octave_value tmp = do_fread (os, size, prec, skip, arch, count);
 
-  retval(1) = count;
-  retval(0) = tmp;
+  retval = ovl (tmp, count);
 
   return retval;
 }
@@ -1670,8 +1649,7 @@
 
   std::string error_message = os.error (clear, error_number);
 
-  retval(1) = error_number;
-  retval(0) = error_message;
+  retval = ovl (error_message, error_number);
 
   return retval;
 }
@@ -1863,8 +1841,7 @@
   if (args.length () != 0)
     print_usage ();
 
-  retval(1) = std::string ();
-  retval(0) = -1;
+  retval = ovl (-1, std::string ());
 
   FILE *fid = gnulib::tmpfile ();
 
@@ -1877,15 +1854,14 @@
       octave_stream s = octave_stdiostream::create (nm, fid, md);
 
       if (s)
-        retval(0) = octave_stream_list::insert (s);
+        retval = ovl (octave_stream_list::insert (s));
       else
         error ("tmpfile: failed to create octave_stdiostream object");
 
     }
   else
     {
-      retval(1) = gnulib::strerror (errno);
-      retval(0) = -1;
+      retval = ovl (-1, gnulib::strerror (errno));
     }
 
   return retval;
@@ -1914,18 +1890,14 @@
 @seealso{tempname, tempdir, P_tmpdir, tmpfile, fopen}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  retval(2) = std::string ();
-  retval(1) = std::string ();
-  retval(0) = -1;
+  std::string tmpl8 = args(0).xstring_value ("mkstemp: TEMPLATE argument must be a string");
 
-  std::string tmpl8 = args(0).xstring_value ("mkstemp: TEMPLATE argument must be a string");
+  octave_value_list retval = ovl (-1, "", "");
 
   OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1);
   strcpy (tmp, tmpl8.c_str ());
@@ -1934,8 +1906,8 @@
 
   if (fd < 0)
     {
+      retval(0) = fd;
       retval(2) = gnulib::strerror (errno);
-      retval(0) = fd;
     }
   else
     {
@@ -1943,7 +1915,12 @@
 
       FILE *fid = fdopen (fd, fopen_mode);
 
-      if (fid)
+      if (! fid)
+        {
+          retval(0) = -1;
+          retval(2) = gnulib::strerror (errno);
+        }
+      else
         {
           std::string nm = tmp;
 
@@ -1951,21 +1928,14 @@
 
           octave_stream s = octave_stdiostream::create (nm, fid, md);
 
-          if (s)
-            {
-              retval(1) = nm;
-              retval(0) = octave_stream_list::insert (s);
+          if (! s)
+            error ("mkstemp: failed to create octave_stdiostream object");
 
-              if (nargin == 2 && args(1).is_true ())
-                mark_for_deletion (nm);
-            }
-          else
-            error ("mkstemp: failed to create octave_stdiostream object");
-        }
-      else
-        {
-          retval(2) = gnulib::strerror (errno);
-          retval(0) = -1;
+          retval(0) = octave_stream_list::insert (s);
+          retval(1) = nm;
+
+          if (nargin == 2 && args(1).is_true ())
+            mark_for_deletion (nm);
         }
     }
 
@@ -2043,7 +2013,7 @@
     }
 
   if (status >= 0)
-    retval(0) = status;
+    retval = ovl (status);
 
   return retval;
 }
--- a/libinterp/corefcn/getgrent.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/getgrent.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -54,10 +54,10 @@
       m.assign ("gid", static_cast<double> (gr.gid ()));
       m.assign ("mem", octave_value (gr.mem ()));
 
-      retval = m;
+      retval = ovl (m);
     }
   else
-    retval = 0;
+    retval = ovl (0);
 
   return retval;
 }
@@ -81,8 +81,7 @@
   // octave_group::getgrent may set msg.
   octave_value val = mk_gr_map (octave_group::getgrent (msg));
 
-  retval(1) = msg;
-  retval(0) = val;
+  retval = ovl (val, msg);
 
   return retval;
 }
@@ -113,8 +112,7 @@
       // octave_group::getgrgid may set msg.
       octave_value val = mk_gr_map (octave_group::getgrgid (gid, msg));
 
-      retval(1) = msg;
-      retval(0) = val;
+      retval = ovl (val, msg);
     }
 
   else
@@ -145,8 +143,7 @@
   // octave_group::getgrnam may set msg.
   octave_value val = mk_gr_map (octave_group::getgrnam (s.c_str (), msg));
 
-  retval(1) = msg;
-  retval(0) = val;
+  retval = ovl (val, msg);
 
   return retval;
 }
@@ -168,8 +165,7 @@
   // octave_group::setgrent may set msg.
   int status = octave_group::setgrent (msg);
 
-  retval(1) = msg;
-  retval(0) = static_cast<double> (status);
+  retval = ovl (static_cast<double> (status), msg);
 
   return retval;
 }
@@ -191,8 +187,7 @@
   // octave_group::endgrent may set msg.
   int status = octave_group::endgrent (msg);
 
-  retval(1) = msg;
-  retval(0) = static_cast<double> (status);
+  retval = ovl (static_cast<double> (status), msg);
 
   return retval;
 }
--- a/libinterp/corefcn/getpwent.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/getpwent.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -57,10 +57,10 @@
       m.assign ("dir", pw.dir ());
       m.assign ("shell", pw.shell ());
 
-      retval = m;
+      retval = ovl (m);
     }
   else
-    retval = 0;
+    retval = ovl (0);
 
   return retval;
 }
@@ -85,8 +85,7 @@
   // octave_passwd::getpwent may set msg.
   octave_value val = mk_pw_map (octave_passwd::getpwent (msg));
 
-  retval(1) = msg;
-  retval(0) = val;
+  retval = ovl (val, msg);
 
   return retval;
 }
@@ -117,8 +116,7 @@
       // octave_passwd::getpwuid may set msg.
       octave_value val = mk_pw_map (octave_passwd::getpwuid (uid, msg));
 
-      retval(1) = msg;
-      retval(0) = val;
+      retval = ovl (val, msg);
     }
   else
     error ("getpwuid: UID must be an integer");
@@ -148,8 +146,7 @@
   // octave_passwd::getpwnam may set msg.
   octave_value val = mk_pw_map (octave_passwd::getpwnam (s, msg));
 
-  retval(1) = msg;
-  retval(0) = val;
+  retval = ovl (val, msg);
 
   return retval;
 }
@@ -171,8 +168,7 @@
   // octave_passwd::setpwent may set msg.
   int status = octave_passwd::setpwent (msg);
 
-  retval(1) = msg;
-  retval(0) = static_cast<double> (status);
+  retval = ovl (static_cast<double> (status), msg);
 
   return retval;
 }
@@ -194,8 +190,7 @@
   // octave_passwd::endpwent may set msg.
   int status = octave_passwd::endpwent (msg);
 
-  retval(1) = msg;
-  retval(0) = static_cast<double> (status);
+  retval = ovl (static_cast<double> (status), msg);
 
   return retval;
 }
--- a/libinterp/corefcn/givens.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/givens.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -92,12 +92,11 @@
             {
             case 0:
             case 1:
-              retval(0) = result;
+              retval = ovl (result);
               break;
 
             case 2:
-              retval(1) = result (0, 1);
-              retval(0) = result (0, 0);
+              retval = ovl (result(0, 0), result(0, 1));
               break;
             }
         }
@@ -112,12 +111,11 @@
             {
             case 0:
             case 1:
-              retval(0) = result;
+              retval = ovl (result);
               break;
 
             case 2:
-              retval(1) = result (0, 1);
-              retval(0) = result (0, 0);
+              retval = ovl (result(0, 0), result(0, 1));
               break;
             }
         }
@@ -135,12 +133,11 @@
             {
             case 0:
             case 1:
-              retval(0) = result;
+              retval = ovl (result);
               break;
 
             case 2:
-              retval(1) = result (0, 1);
-              retval(0) = result (0, 0);
+              retval = ovl (result(0, 0), result(0, 1));
               break;
             }
         }
@@ -155,12 +152,11 @@
             {
             case 0:
             case 1:
-              retval(0) = result;
+              retval = ovl (result);
               break;
 
             case 2:
-              retval(1) = result (0, 1);
-              retval(0) = result (0, 0);
+              retval = ovl (result(0, 0), result(0, 1));
               break;
             }
         }
--- a/libinterp/corefcn/help.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/help.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -1101,8 +1101,7 @@
 
   do_get_help_text (name, text, format);
 
-  retval(1) = format;
-  retval(0) = text;
+  retval = ovl (text, format);
 
   return retval;
 }
@@ -1164,8 +1163,7 @@
 
   do_get_help_text_from_file (fname, text, format);
 
-  retval(1) = format;
-  retval(0) = text;
+  retval = ovl (text, format);
 
   return retval;
 }
--- a/libinterp/corefcn/hess.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/hess.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -96,11 +96,11 @@
           FloatHESS result (tmp);
 
           if (nargout <= 1)
-            retval(0) = result.hess_matrix ();
+            retval = ovl (result.hess_matrix ());
           else
             {
-              retval(1) = result.hess_matrix ();
-              retval(0) = result.unitary_hess_matrix ();
+              retval = ovl (result.unitary_hess_matrix (),
+                            result.hess_matrix ());
             }
         }
       else if (arg.is_complex_type ())
@@ -110,11 +110,11 @@
           FloatComplexHESS result (ctmp);
 
           if (nargout <= 1)
-            retval(0) = result.hess_matrix ();
+            retval = ovl (result.hess_matrix ());
           else
             {
-              retval(1) = result.hess_matrix ();
-              retval(0) = result.unitary_hess_matrix ();
+              retval = ovl (result.unitary_hess_matrix (),
+                            result.hess_matrix ());
             }
         }
     }
@@ -127,11 +127,11 @@
           HESS result (tmp);
 
           if (nargout <= 1)
-            retval(0) = result.hess_matrix ();
+            retval = ovl (result.hess_matrix ());
           else
             {
-              retval(1) = result.hess_matrix ();
-              retval(0) = result.unitary_hess_matrix ();
+              retval = ovl (result.unitary_hess_matrix (),
+                            result.hess_matrix ());
             }
         }
       else if (arg.is_complex_type ())
@@ -141,11 +141,11 @@
           ComplexHESS result (ctmp);
 
           if (nargout <= 1)
-            retval(0) = result.hess_matrix ();
+            retval = ovl (result.hess_matrix ());
           else
             {
-              retval(1) = result.hess_matrix ();
-              retval(0) = result.unitary_hess_matrix ();
+              retval = ovl (result.unitary_hess_matrix (),
+                            result.hess_matrix ());
             }
         }
       else
--- a/libinterp/corefcn/mgorth.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/mgorth.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -98,8 +98,7 @@
           FloatComplexMatrix V = arg_v.float_complex_matrix_value ();
           FloatComplexRowVector h;
           do_mgorth (x, V, h);
-          retval(1) = h;
-          retval(0) = x;
+          retval = ovl (x, h);
         }
       else
         {
@@ -107,8 +106,7 @@
           FloatMatrix V = arg_v.float_matrix_value ();
           FloatRowVector h;
           do_mgorth (x, V, h);
-          retval(1) = h;
-          retval(0) = x;
+          retval = ovl (x, h);
         }
     }
   else
@@ -119,8 +117,7 @@
           ComplexMatrix V = arg_v.complex_matrix_value ();
           ComplexRowVector h;
           do_mgorth (x, V, h);
-          retval(1) = h;
-          retval(0) = x;
+          retval = ovl (x, h);
         }
       else
         {
@@ -128,8 +125,7 @@
           Matrix V = arg_v.matrix_value ();
           RowVector h;
           do_mgorth (x, V, h);
-          retval(1) = h;
-          retval(0) = x;
+          retval = ovl (x, h);
         }
     }
 
--- a/libinterp/corefcn/quad.cc	Sat Dec 12 21:34:06 2015 -0500
+++ b/libinterp/corefcn/quad.cc	Sun Dec 13 07:59:40 2015 -0800
@@ -306,10 +306,7 @@
           break;
         }
 
-      retval(3) = abserr;
-      retval(2) = nfun;
-      retval(1) = ier;
-      retval(0) = val;
+      retval = ovl (val, ier, nfun, abserr);
 
     }
   else
@@ -401,10 +398,7 @@
           break;
         }
 
-      retval(3) = abserr;
-      retval(2) = nfun;
-      retval(1) = ier;
-      retval(0) = val;
+      retval = ovl (val, ier, nfun, abserr);
     }
 
   if (fcn_name.length ())