changeset 20918:6f0bd96f93c0

maint: Use new C++ archetype in more files. Place input validation first in files. Move declaration of retval down in function to be closer to point of usage. Eliminate else clause after if () error. Use "return ovl()" where it makes sense. * __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __lin_interpn__.cc, balance.cc, betainc.cc, bitfcns.cc, bsxfun.cc, cellfun.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, dirfns.cc, dlmread.cc, dot.cc, eig.cc, error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, ov-type-conv.h: Use new C++ archetype in more files.
author Rik <rik@octave.org>
date Wed, 16 Dec 2015 15:00:31 -0800
parents a7051a169cad
children cfb58d9805fa
files libinterp/corefcn/__dispatch__.cc libinterp/corefcn/__dsearchn__.cc libinterp/corefcn/__ichol__.cc libinterp/corefcn/__lin_interpn__.cc libinterp/corefcn/balance.cc libinterp/corefcn/betainc.cc libinterp/corefcn/bitfcns.cc libinterp/corefcn/bsxfun.cc libinterp/corefcn/cellfun.cc libinterp/corefcn/colloc.cc libinterp/corefcn/conv2.cc libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/data.cc libinterp/corefcn/debug.cc libinterp/corefcn/dirfns.cc libinterp/corefcn/dlmread.cc libinterp/corefcn/dot.cc libinterp/corefcn/eig.cc libinterp/corefcn/error.cc libinterp/corefcn/fft.cc libinterp/corefcn/fft2.cc libinterp/corefcn/fftn.cc libinterp/corefcn/file-io.cc libinterp/octave-value/ov-type-conv.h
diffstat 26 files changed, 1015 insertions(+), 1266 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__dispatch__.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/__dispatch__.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -42,8 +42,6 @@
 DEFUN (__dispatch__, args, nargout,
        "Undocumented internal function")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
@@ -59,6 +57,8 @@
   if (nargin > 2)
     t = args(2).xstring_value ("__dispatch__: third argument must be a type name");
 
+  octave_value retval;
+
   if (nargin == 1)
     {
       if (nargout > 0)
--- a/libinterp/corefcn/__dsearchn__.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/__dsearchn__.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -40,8 +40,6 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 2)
     print_usage ();
 
@@ -50,55 +48,51 @@
 
   if (x.rows () != xi.rows () || x.columns () < 1)
     error ("__dsearch__: number of rows of X and XI must match");
-  else
-    {
-      octave_idx_type n = x.rows ();
-      octave_idx_type nx = x.columns ();
-      octave_idx_type nxi = xi.columns ();
+
+  octave_idx_type n = x.rows ();
+  octave_idx_type nx = x.columns ();
+  octave_idx_type nxi = xi.columns ();
 
-      ColumnVector idx (nxi);
-      double *pidx = idx.fortran_vec ();
-      ColumnVector dist (nxi);
-      double *pdist = dist.fortran_vec ();
+  ColumnVector idx (nxi);
+  double *pidx = idx.fortran_vec ();
+  ColumnVector dist (nxi);
+  double *pdist = dist.fortran_vec ();
 
 #define DIST(dd, y, yi, m) \
-  dd = 0.; \
-  for (octave_idx_type k = 0; k < m; k++) \
-   { \
-     double yd = y[k] - yi[k]; \
-     dd += yd * yd; \
-   } \
-  dd = sqrt (dd);
+dd = 0.; \
+for (octave_idx_type k = 0; k < m; k++) \
+{ \
+ double yd = y[k] - yi[k]; \
+ dd += yd * yd; \
+} \
+dd = sqrt (dd);
 
-      const double *pxi = xi.fortran_vec ();
-      for (octave_idx_type i = 0; i < nxi; i++)
+  const double *pxi = xi.fortran_vec ();
+  for (octave_idx_type i = 0; i < nxi; i++)
+    {
+      double d0;
+      const double *px = x.fortran_vec ();
+      DIST(d0, px, pxi, n);
+      *pidx = 1.;
+      for (octave_idx_type j = 1; j < nx; j++)
         {
-          double d0;
-          const double *px = x.fortran_vec ();
-          DIST(d0, px, pxi, n);
-          *pidx = 1.;
-          for (octave_idx_type j = 1; j < nx; j++)
+          px += n;
+          double d;
+          DIST (d, px, pxi, n);
+          if (d < d0)
             {
-              px += n;
-              double d;
-              DIST (d, px, pxi, n);
-              if (d < d0)
-                {
-                  d0 = d;
-                  *pidx = static_cast<double>(j + 1);
-                }
-              OCTAVE_QUIT;
+              d0 = d;
+              *pidx = static_cast<double>(j + 1);
             }
-
-          *pdist++ = d0;
-          pidx++;
-          pxi += n;
+          OCTAVE_QUIT;
         }
 
-      retval = ovl (idx, dist);
+      *pdist++ = d0;
+      pidx++;
+      pxi += n;
     }
 
-  return retval;
+  return ovl (idx, dist);
 }
 
 /*
--- a/libinterp/corefcn/__ichol__.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/__ichol__.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -184,16 +184,10 @@
 @deftypefnx {} {@var{L} =} __ichol0__ (@var{A}, @var{michol})\n\
 Undocumented internal function.\n\
 @end deftypefn")
-
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
+
   std::string michol = "off";
-
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-
   if (nargin == 2)
     michol = args(1).string_value ();
 
@@ -201,7 +195,7 @@
   // so it's structure does not change during the algorithm.  The same input
   // matrix is used to build the output matrix due to that fact.
   octave_value_list param_list;
-  if (!args(0).is_complex_type ())
+  if (! args(0).is_complex_type ())
     {
       SparseMatrix sm = args(0).sparse_matrix_value ();
       param_list.append (sm);
@@ -209,7 +203,7 @@
       ichol_0 <SparseMatrix, double, ichol_mult_real,
                ichol_checkpivot_real> (sm, michol);
 
-      retval(0) = sm;
+      return ovl (sm);
     }
   else
     {
@@ -219,17 +213,14 @@
       ichol_0 <SparseComplexMatrix, Complex, ichol_mult_complex,
                ichol_checkpivot_complex> (sm, michol);
 
-      retval(0) = sm;
+      return ovl (sm);
     }
-
-  return retval;
 }
 
 template <typename octave_matrix_t, typename T,  T (*ichol_mult) (T, T),
           bool (*ichol_checkpivot) (T)>
 void ichol_t (const octave_matrix_t& sm, octave_matrix_t& L, const T* cols_norm,
               const T droptol, const std::string michol = "off")
-
 {
 
   const octave_idx_type n = sm.cols ();
@@ -432,17 +423,12 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
   int nargin = args.length ();
   // Default values of parameters
   std::string michol = "off";
   double droptol = 0;
 
-  if (nargin < 1 || nargin > 3)
-    print_usage ();
-
   // Don't repeat input validation of arguments done in ichol.m
-
   if (nargin >= 2)
     droptol = args(1).double_value ();
 
@@ -466,7 +452,7 @@
                double, ichol_mult_real, ichol_checkpivot_real>
                (sm_l, L, cols_norm.fortran_vec (), droptol, michol);
 
-      retval(0) = L;
+      return ovl (L);
     }
   else
     {
@@ -485,10 +471,8 @@
                (sm_l, L, cols_norm.fortran_vec (),
                 Complex (droptol), michol);
 
-      retval(0) = L;
+      return ovl (L);
     }
-
-  return retval;
 }
 
 /*
--- a/libinterp/corefcn/__lin_interpn__.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/__lin_interpn__.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -265,13 +265,13 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin % 2 == 0)
     print_usage ();
 
+  octave_value retval;
+
   // dimension of the problem
   int n = (nargin-1)/2;
 
--- a/libinterp/corefcn/balance.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/balance.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -91,13 +91,13 @@
 (SIAM Journal on Scientific and Statistical Computing, 1981).\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3 || nargout < 0)
     print_usage ();
 
+  octave_value_list retval;
+
   // determine if it's AEP or GEP
   bool AEPcase = nargin == 1 || args(1).is_string ();
 
--- a/libinterp/corefcn/betainc.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/betainc.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -65,11 +65,11 @@
 @seealso{betaincinv, beta, betaln}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 3)
     print_usage ();
 
+  octave_value retval;
+
   octave_value x_arg = args(0);
   octave_value a_arg = args(1);
   octave_value b_arg = args(2);
@@ -298,11 +298,11 @@
 @seealso{betainc, beta, betaln}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 3)
     print_usage ();
 
+  octave_value retval;
+
   octave_value x_arg = args(0);
   octave_value a_arg = args(1);
   octave_value b_arg = args(2);
@@ -396,7 +396,6 @@
       retval = Array<float> (retval.array_value ());
     }
 
-
   return retval;
 }
 
--- a/libinterp/corefcn/bitfcns.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/bitfcns.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -154,11 +154,11 @@
 octave_value
 bitop (const std::string& fname, const octave_value_list& args)
 {
-  octave_value retval;
-
   if (args.length () != 2)
     print_usage ();
 
+  octave_value retval;
+
   if (args(0).class_name () == octave_scalar::static_class_name ()
       || args(0).class_name () == octave_float_scalar::static_class_name ()
       || args(0).class_name () == octave_bool::static_class_name ()
@@ -570,21 +570,19 @@
 @seealso{bitand, bitor, bitxor, bitset, bitget, bitcmp, intmax, flintmax}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
-  int nbits = 64;
+  NDArray n = args(1).xarray_value ("bitshift: K must be a scalar or array of integers");
 
-  NDArray n = args(1).xarray_value ("bitshift: K must be a scalar or array of integers");
+  int nbits = 64;
 
   if (nargin == 3)
     {
-      // FIXME: for compatibility, we should accept an array
-      // or a scalar as the third argument.
+      // FIXME: for compatibility, we should accept an array or a scalar
+      //        as the third argument.
       if (args(2).numel () > 1)
         error ("bitshift: N must be a scalar integer");
       else
@@ -596,10 +594,28 @@
         }
     }
 
+  octave_value retval;
+
   octave_value m_arg = args(0);
   std::string cname = m_arg.class_name ();
 
-  if (cname == "uint8")
+  if (cname == "double")
+    {
+      static const int bits_in_mantissa
+        = std::numeric_limits<double>::digits;
+
+      nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
+      int64_t mask = max_mantissa_value<double> ();
+      if (nbits < bits_in_mantissa)
+        mask = mask >> (bits_in_mantissa - nbits);
+      else if (nbits < 1)
+        mask = 0;
+      int bits_in_type = sizeof (double)
+        * std::numeric_limits<unsigned char>::digits;
+      NDArray m = m_arg.array_value ();
+      DO_BITSHIFT ();
+    }
+  else if (cname == "uint8")
     DO_UBITSHIFT (uint8, nbits < 8 ? nbits : 8);
   else if (cname == "uint16")
     DO_UBITSHIFT (uint16, nbits < 16 ? nbits : 16);
@@ -615,22 +631,6 @@
     DO_SBITSHIFT (int32, nbits < 32 ? nbits : 32);
   else if (cname == "int64")
     DO_SBITSHIFT (int64, nbits < 64 ? nbits : 64);
-  else if (cname == "double")
-    {
-      static const int bits_in_mantissa
-        = std::numeric_limits<double>::digits;
-
-      nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
-      int64_t mask = max_mantissa_value<double> ();
-      if (nbits < bits_in_mantissa)
-        mask = mask >> (bits_in_mantissa - nbits);
-      else if (nbits < 1)
-        mask = 0;
-      int bits_in_type = sizeof (double)
-        * std::numeric_limits<unsigned char>::digits;
-      NDArray m = m_arg.array_value ();
-      DO_BITSHIFT ();
-    }
   else if (cname == "single")
     {
       static const int bits_in_mantissa
@@ -679,26 +679,21 @@
 @seealso{intmax, realmax, realmin}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  std::string cname = "double";
-
   int nargin = args.length ();
 
   if (nargin > 1)
     print_usage ();
 
+  std::string cname = "double";
   if (nargin == 1)
     cname = args(0).xstring_value ("flintmax: argument must be a string");
 
   if (cname == "double")
-    retval = (static_cast<double> (max_mantissa_value<double> () + 1));
+    return ovl (static_cast<double> (max_mantissa_value<double> () + 1));
   else if (cname == "single")
-    retval = (static_cast<float> (max_mantissa_value<float> () + 1));
+    return ovl (static_cast<float> (max_mantissa_value<float> () + 1));
   else
     error ("flintmax: not defined for class '%s'", cname.c_str ());
-
-  return retval;
 }
 
 /*
@@ -749,18 +744,17 @@
 @seealso{intmin, flintmax}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  std::string cname = "int32";
-
   int nargin = args.length ();
 
   if (nargin > 1)
     print_usage ();
 
+  std::string cname = "int32";
   if (nargin == 1)
     cname = args(0).xstring_value ("intmax: argument must be a string");
 
+  octave_value retval;
+
   if (cname == "uint8")
     retval = octave_uint8 (std::numeric_limits<uint8_t>::max ());
   else if (cname == "uint16")
@@ -837,18 +831,17 @@
 @seealso{intmax, flintmax}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  std::string cname = "int32";
-
   int nargin = args.length ();
 
   if (nargin > 1)
     print_usage ();
 
+  std::string cname = "int32";
   if (nargin == 1)
     cname = args(0).xstring_value ("intmin: argument must be a string");
 
+  octave_value retval;
+
   if (cname == "uint8")
     retval = octave_uint8 (std::numeric_limits<uint8_t>::min ());
   else if (cname == "uint16")
--- a/libinterp/corefcn/bsxfun.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/bsxfun.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -335,13 +335,10 @@
 @seealso{arrayfun, cellfun}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 3)
     print_usage ();
 
   octave_value func = args(0);
-
   if (func.is_string ())
     {
       std::string name = func.string_value ();
@@ -349,26 +346,25 @@
       if (func.is_undefined ())
         error ("bsxfun: invalid function name: %s", name.c_str ());
     }
-  else if (! (args(0).is_function_handle ()
-              || args(0).is_inline_function ()))
+  else if (! (args(0).is_function_handle () || args(0).is_inline_function ()))
     error ("bsxfun: F must be a string or function handle");
 
+  octave_value_list retval;
+
   const octave_value A = args(1);
   const octave_value B = args(2);
 
   if (func.is_builtin_function ()
-      || (func.is_function_handle ()
-          && ! A.is_object () && ! B.is_object ()))
+      || (func.is_function_handle () && ! A.is_object () && ! B.is_object ()))
     {
       // This may break if the default behavior is overridden.  But if you
-      // override arithmetic operators for builtin classes, you should
-      // expect mayhem anyway (constant folding etc).  Querying
-      // is_overloaded() may not be exactly what we need here.
+      // override arithmetic operators for builtin classes, you should expect
+      // mayhem anyway (constant folding etc).  Querying is_overloaded() may
+      // not be exactly what we need here.
       octave_function *fcn_val = func.function_value ();
       if (fcn_val)
         {
-          octave_value tmp = maybe_optimized_builtin (fcn_val->name (),
-                                                      A, B);
+          octave_value tmp = maybe_optimized_builtin (fcn_val->name (), A, B);
           if (tmp.is_defined ())
             retval(0) = tmp;
         }
@@ -392,10 +388,7 @@
 
       for (octave_idx_type i = 0; i < nd; i++)
         if (dva(i) != dvb(i) && dva(i) != 1 && dvb(i) != 1)
-          {
-            error ("bsxfun: dimensions of A and B must match");
-            break;
-          }
+          error ("bsxfun: dimensions of A and B must match");
 
       // Find the size of the output
       dim_vector dvc;
@@ -462,14 +455,13 @@
               if (maybe_update_column (Bc, B, dvb, dvc, i, idxB))
                 inputs (1) = Bc;
 
-              octave_value_list tmp = func.do_multi_index_op (1,
-                                                              inputs);
+              octave_value_list tmp = func.do_multi_index_op (1, inputs);
 
 #define BSXINIT(T, CLS, EXTRACTOR) \
   (result_type == CLS) \
     { \
       have_ ## T = true; \
-      result_ ## T = tmp (0). EXTRACTOR ## _array_value (); \
+      result_ ## T = tmp(0). EXTRACTOR ## _array_value (); \
       result_ ## T .resize (dvc); \
     }
 
@@ -512,19 +504,19 @@
                             }
                         }
                       else if BSXINIT(boolNDArray, "logical", bool)
-                        else if BSXINIT(int8NDArray, "int8", int8)
-                          else if BSXINIT(int16NDArray, "int16", int16)
-                            else if BSXINIT(int32NDArray, "int32", int32)
-                              else if BSXINIT(int64NDArray, "int64", int64)
-                                else if BSXINIT(uint8NDArray, "uint8", uint8)
-                                  else if BSXINIT(uint16NDArray, "uint16", uint16)
-                                    else if BSXINIT(uint32NDArray, "uint32", uint32)
-                                      else if BSXINIT(uint64NDArray, "uint64", uint64)
-                                        else
-                                          {
-                                            C = tmp (0);
-                                            C = C.resize (dvc);
-                                          }
+                      else if BSXINIT(int8NDArray, "int8", int8)
+                      else if BSXINIT(int16NDArray, "int16", int16)
+                      else if BSXINIT(int32NDArray, "int32", int32)
+                      else if BSXINIT(int64NDArray, "int64", int64)
+                      else if BSXINIT(uint8NDArray, "uint8", uint8)
+                      else if BSXINIT(uint16NDArray, "uint16", uint16)
+                      else if BSXINIT(uint32NDArray, "uint32", uint32)
+                      else if BSXINIT(uint64NDArray, "uint64", uint64)
+                      else
+                        {
+                          C = tmp(0);
+                          C = C.resize (dvc);
+                        }
                     }
                 }
               else
@@ -609,11 +601,11 @@
 #define BSXLOOP(T, CLS, EXTRACTOR) \
   (have_ ## T) \
     { \
-      if (tmp (0).class_name () != CLS) \
+      if (tmp(0).class_name () != CLS) \
         { \
           have_ ## T = false; \
           C = result_ ## T; \
-          C = do_cat_op (C, tmp (0), ra_idx); \
+          C = do_cat_op (C, tmp(0), ra_idx); \
         } \
       else \
         result_ ## T .insert (tmp(0). EXTRACTOR ## _array_value (), ra_idx); \
--- a/libinterp/corefcn/cellfun.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/cellfun.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -401,21 +401,22 @@
 @seealso{arrayfun, structfun, spfun}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
   int nargin = args.length ();
-  int nargout1 = (nargout < 1 ? 1 : nargout);
 
   if (nargin < 2)
     print_usage ();
 
-  octave_value func = args(0);
-
   if (! args(1).is_cell ())
     error ("cellfun: C must be a cell array");
 
+  octave_value_list retval;
+  int nargout1 = (nargout < 1 ? 1 : nargout);
+
+  octave_value func = args(0);
+
   if (func.is_string ())
     {
-      retval = try_cellfun_internal_ops<boolNDArray,NDArray>(args, nargin);
+      retval = try_cellfun_internal_ops<boolNDArray,NDArray> (args, nargin);
 
       if (! retval.empty ())
         return retval;
@@ -443,9 +444,6 @@
           if (func.is_undefined ())
             error ("cellfun: invalid function NAME: %s", name.c_str ());
         }
-
-      if (! retval.empty ())
-        return retval;
     }
 
   if (func.is_function_handle () || func.is_inline_function ()
@@ -457,18 +455,17 @@
 
       get_mapper_fun_options (args, nargin, uniform_output, error_handler);
 
-      // The following is an optimisation because the symbol table can
-      // give a more specific function class, so this can result in
-      // fewer polymorphic function calls as the function gets called
-      // for each value of the array.
+      // The following is an optimization because the symbol table can give a
+      // more specific function class, so this can result in fewer polymorphic
+      // function calls as the function gets called for each value of the array.
       {
         if (func.is_function_handle ())
           {
             octave_fcn_handle* f = func.fcn_handle_value ();
 
             // Overloaded function handles need to check the type of the
-            // arguments for each element of the array, so they cannot
-            // be optimised this way.
+            // arguments for each element of the array, so they cannot be
+            // optimized this way.
             if (f -> is_overloaded ())
               goto nevermind;
           }
@@ -478,10 +475,10 @@
 
         if (f.is_defined ())
           {
-            //Except for these two which are special cases...
+            // Except for these two which are special cases...
             if (name != "size" && name != "class")
               {
-                //Try first the optimised code path for built-in functions
+                // Try first the optimized code path for built-in functions
                 octave_value_list tmp_args = args;
                 tmp_args(0) = name;
 
@@ -497,9 +494,8 @@
                   return retval;
               }
 
-            //Okay, we tried, doesn't work, let's do the best we can
-            //instead and avoid polymorphic calls for each element of
-            //the array.
+            // Okay, we tried, doesn't work, let's do the best we can instead
+            // and avoid polymorphic calls for each element of the array.
             func = f;
           }
       }
@@ -520,8 +516,7 @@
 
       dim_vector fdims (1, 1);
 
-      // Collect arguments.  Pre-fill scalar elements of inputlist
-      // array.
+      // Collect arguments.  Pre-fill scalar elements of inputlist array.
 
       for (int j = 0; j < nargin; j++)
         {
@@ -597,10 +592,10 @@
                             {
                               octave_value val = tmp(j);
 
-                              if (val.numel () == 1)
-                                retv[j] = val.resize (fdims);
-                              else
+                              if (val.numel () != 1)
                                 error ("cellfun: all values must be scalars when UniformOutput = true");
+
+                              retv[j] = val.resize (fdims);
                             }
                         }
                     }
@@ -614,14 +609,12 @@
 
                               if (! retv[j].fast_elem_insert (count, val))
                                 {
-                                  if (val.numel () == 1)
-                                    {
-                                      idx_list.front ()(0) = count + 1.0;
-                                      retv[j].assign (octave_value::op_asn_eq,
-                                                      idx_type, idx_list, val);
-                                    }
-                                  else
+                                  if (val.numel () != 1)
                                     error ("cellfun: all values must be scalars when UniformOutput = true");
+
+                                  idx_list.front ()(0) = count + 1.0;
+                                  retv[j].assign (octave_value::op_asn_eq,
+                                                  idx_type, idx_list, val);
                                 }
                             }
                         }
@@ -1126,20 +1119,19 @@
 @seealso{spfun, cellfun, structfun}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
   int nargin = args.length ();
-  int nargout1 = (nargout < 1 ? 1 : nargout);
 
   if (nargin < 2)
     print_usage ();
 
+  octave_value_list retval;
+  int nargout1 = (nargout < 1 ? 1 : nargout);
+  bool symbol_table_lookup = false;
   octave_value func = args(0);
-  bool symbol_table_lookup = false;
 
   if (func.is_string ())
     {
       // See if we can convert the string into a function.
-
       std::string name = args(0).string_value ();
 
       if (! valid_identifier (name))
@@ -1170,10 +1162,9 @@
   if (func.is_function_handle () || func.is_inline_function ()
       || func.is_function ())
     {
-      // The following is an optimisation because the symbol table can
-      // give a more specific function class, so this can result in
-      // fewer polymorphic function calls as the function gets called
-      // for each value of the array.
+      // The following is an optimization because the symbol table can give a
+      // more specific function class, so this can result in fewer polymorphic
+      // function calls as the function gets called for each value of the array.
 
       if (! symbol_table_lookup)
         {
@@ -1181,10 +1172,9 @@
             {
               octave_fcn_handle* f = func.fcn_handle_value ();
 
-              // Overloaded function handles need to check the type of
-              // the arguments for each element of the array, so they
-              // cannot be optimised this way.
-
+              // Overloaded function handles need to check the type of the
+              // arguments for each element of the array, so they cannot be
+              // optimized this way.
               if (f -> is_overloaded ())
                 goto nevermind;
             }
@@ -1211,8 +1201,7 @@
 
       dim_vector fdims (1, 1);
 
-      // Collect arguments.  Pre-fill scalar elements of inputlist
-      // array.
+      // Collect arguments.  Pre-fill scalar elements of inputlist array.
 
       for (int j = 0; j < nargin; j++)
         {
@@ -1233,17 +1222,13 @@
               for (int i = j+1; i < nargin; i++)
                 {
                   if (mask[i] && inputs[i].dims () != fdims)
-                    {
-                      error_with_id ("Octave:invalid-input-arg",
-                                     "arrayfun: dimensions mismatch");
-                      return retval;
-                    }
+                    error_with_id ("Octave:invalid-input-arg",
+                                   "arrayfun: dimensions mismatch");
                 }
               break;
             }
         }
 
-
       unwind_protect frame;
       frame.protect_var (buffer_error_messages);
 
@@ -1275,11 +1260,8 @@
                                    error_handler);
 
               if (nargout > 0 && tmp.length () < nargout)
-                {
-                  error_with_id ("Octave:invalid-fun-call",
-                                 "arrayfun: function returned fewer than nargout values");
-                  return retval;
-                }
+                error_with_id ("Octave:invalid-fun-call",
+                               "arrayfun: function returned fewer than nargout values");
 
               if  (nargout > 0
                    || (nargout == 0
@@ -1301,11 +1283,8 @@
                               if (val.numel () == 1)
                                 retv[j] = val.resize (fdims);
                               else
-                                {
-                                  error_with_id ("Octave:invalid-fun-call",
-                                                 "arrayfun: all values must be scalars when UniformOutput = true");
-                                  break;
-                                }
+                                error_with_id ("Octave:invalid-fun-call",
+                                               "arrayfun: all values must be scalars when UniformOutput = true");
                             }
                         }
                     }
@@ -1326,11 +1305,8 @@
                                                       idx_type, idx_list, val);
                                     }
                                   else
-                                    {
-                                      error_with_id ("Octave:invalid-fun-call",
-                                                     "arrayfun: all values must be scalars when UniformOutput = true");
-                                      break;
-                                    }
+                                    error_with_id ("Octave:invalid-fun-call",
+                                                   "arrayfun: all values must be scalars when UniformOutput = true");
                                 }
                             }
                         }
@@ -1376,11 +1352,8 @@
                                    error_handler);
 
               if (nargout > 0 && tmp.length () < nargout)
-                {
-                  error_with_id ("Octave:invalid-fun-call",
-                                 "arrayfun: function returned fewer than nargout values");
-                  return retval;
-                }
+                error_with_id ("Octave:invalid-fun-call",
+                               "arrayfun: function returned fewer than nargout values");
 
               if  (nargout > 0
                    || (nargout == 0
@@ -1807,17 +1780,16 @@
 @seealso{mat2cell}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  octave_value retval;
+
   octave_value array = args(0);
 
   Array<int> dimv;
-
   if (nargin > 1)
     dimv = args(1).int_vector_value (true);
 
@@ -2138,13 +2110,13 @@
 @seealso{num2cell, cell2mat}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2)
     print_usage ();
 
+  octave_value retval;
+
   // Prepare indices.
   OCTAVE_LOCAL_BUFFER (Array<octave_idx_type>, d, nargin-1);
 
@@ -2412,7 +2384,8 @@
     print_usage ();
 
   const Cell x = args(0).xcell_value ("cellindexmat: X must be a cell");
-  NoAlias<Cell> y(x.dims ());
+
+  NoAlias<Cell> y (x.dims ());
   octave_idx_type nel = x.numel ();
   octave_value_list idx = args.slice (1, args.length () - 1);
 
--- a/libinterp/corefcn/colloc.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/colloc.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -43,8 +43,6 @@
 @cite{Solution of Differential Equation Models by Polynomial Approximation}.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
@@ -54,7 +52,6 @@
     error ("colloc: N must be a scalar");
 
   double tmp = args(0).double_value ();
-
   if (xisnan (tmp))
     error ("colloc: N cannot be NaN");
 
@@ -70,16 +67,11 @@
     {
       std::string s = args(i).xstring_value ("colloc: optional arguments must be strings");
 
-      if ((s.length () == 1 && (s[0] == 'R' || s[0] == 'r'))
-          || s == "right")
-        {
-          right = 1;
-        }
+      if ((s.length () == 1 && (s[0] == 'R' || s[0] == 'r')) || s == "right")
+        right = 1;
       else if ((s.length () == 1 && (s[0] == 'L' || s[0] == 'l'))
                || s == "left")
-        {
-          left = 1;
-        }
+        left = 1;
       else
         error ("colloc: string argument must be \"left\" or \"right\"");
     }
@@ -95,7 +87,6 @@
   Matrix B = wts.second ();
   ColumnVector q = wts.quad_weights ();
 
-  retval = ovl (r, A, B, q);
+  return ovl (r, A, B, q);
+}
 
-  return retval;
-}
--- a/libinterp/corefcn/conv2.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/conv2.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -64,16 +64,15 @@
 @seealso{conv, convn}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  octave_value tmp;
   int nargin = args.length ();
+
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+
   std::string shape = "full";   // default
   bool separable = false;
   convn_type ct = convn_full;
 
-  if (nargin < 2 || nargin > 4)
-    print_usage ();
-
   if (nargin == 3)
     {
       if (args(2).is_string ())
@@ -99,10 +98,11 @@
   else
     error ("conv2: SHAPE type not valid");
 
+  octave_value retval;
+
   if (separable)
     {
       // If user requests separable, check first two params are vectors
-
       if (! (1 == args(0).rows () || 1 == args(0).columns ())
           || ! (1 == args(1).rows () || 1 == args(1).columns ()))
         error ("conv2: arguments must be vectors for separable option");
@@ -305,15 +305,14 @@
 @seealso{conv2, conv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  octave_value tmp;
   int nargin = args.length ();
-  std::string shape = "full";   // default
-  convn_type ct = convn_full;
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  std::string shape = "full";   // default
+  convn_type ct = convn_full;
+
   if (nargin == 3)
     shape = args(2).xstring_value ("convn: SHAPE must be a string");
 
@@ -326,6 +325,8 @@
   else
     error ("convn: SHAPE type not valid");
 
+  octave_value retval;
+
   if (args(0).is_single_type () || args(1).is_single_type ())
     {
       if (args(0).is_complex_type () || args(1).is_complex_type ())
--- a/libinterp/corefcn/daspk.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/daspk.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -277,11 +277,16 @@
 @seealso{dassl}\n\
 @end deftypefn")
 {
-  octave_value_list retval (4);
+  int nargin = args.length ();
+
+  if (nargin < 4 || nargin > 5)
+    print_usage ();
 
   warned_fcn_imaginary = false;
   warned_jac_imaginary = false;
 
+  octave_value_list retval (4);
+
   unwind_protect frame;
 
   frame.protect_var (call_depth);
@@ -290,11 +295,6 @@
   if (call_depth > 1)
     DASPK_ABORT1 ("invalid recursive call");
 
-  int nargin = args.length ();
-
-  if (nargin < 4 || nargin > 5)
-    print_usage ();
-
   std::string fcn_name, fname, jac_name, jname;
   daspk_fcn = 0;
   daspk_jac = 0;
@@ -333,7 +333,7 @@
                   daspk_jac = extract_function (c(1), "daspk", jac_name,
                                                 jname, "; endfunction");
 
-                  if (!daspk_jac)
+                  if (! daspk_jac)
                     {
                       if (fcn_name.length ())
                         clear_function (fcn_name);
@@ -346,7 +346,7 @@
         DASPK_ABORT1 ("incorrect number of elements in cell array");
     }
 
-  if (!daspk_fcn && ! f_arg.is_cell ())
+  if (! daspk_fcn && ! f_arg.is_cell ())
     {
       if (f_arg.is_function_handle () || f_arg.is_inline_function ())
         daspk_fcn = f_arg.function_value ();
@@ -388,7 +388,7 @@
                                                   jac_name, jname,
                                                   "; endfunction");
 
-                    if (!daspk_jac)
+                    if (! daspk_jac)
                       {
                         if (fcn_name.length ())
                           clear_function (fcn_name);
--- a/libinterp/corefcn/dasrt.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/dasrt.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -356,12 +356,17 @@
 @seealso{dasrt_options, daspk, dasrt, lsode}\n\
 @end deftypefn")
 {
-  octave_value_list retval (5);
+  int nargin = args.length ();
+
+  if (nargin < 4 || nargin > 6)
+    print_usage ();
 
   warned_fcn_imaginary = false;
   warned_jac_imaginary = false;
   warned_cf_imaginary = false;
 
+  octave_value_list retval (5);
+
   unwind_protect frame;
 
   frame.protect_var (call_depth);
@@ -370,11 +375,6 @@
   if (call_depth > 1)
     DASRT_ABORT1 ("invalid recursive call");
 
-  int nargin = args.length ();
-
-  if (nargin < 4 || nargin > 6)
-    print_usage ();
-
   int argp = 0;
   std::string fcn_name, fname, jac_name, jname;
   dasrt_f = 0;
@@ -419,7 +419,7 @@
                   dasrt_j = extract_function (c(1), "dasrt", jac_name, jname,
                                               "; endfunction");
 
-                  if (!dasrt_j)
+                  if (! dasrt_j)
                     {
                       if (fcn_name.length ())
                         clear_function (fcn_name);
@@ -432,7 +432,7 @@
         DASRT_ABORT1 ("incorrect number of elements in cell array");
     }
 
-  if (!dasrt_f && ! f_arg.is_cell ())
+  if (! dasrt_f && ! f_arg.is_cell ())
     {
       if (f_arg.is_function_handle () || f_arg.is_inline_function ())
         dasrt_f = f_arg.function_value ();
--- a/libinterp/corefcn/dassl.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/dassl.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -278,11 +278,16 @@
 @seealso{daspk, dasrt, lsode}\n\
 @end deftypefn")
 {
-  octave_value_list retval (4);
+  int nargin = args.length ();
+
+  if (nargin < 4 || nargin > 5)
+    print_usage ();
 
   warned_fcn_imaginary = false;
   warned_jac_imaginary = false;
 
+  octave_value_list retval (4);
+
   unwind_protect frame;
 
   frame.protect_var (call_depth);
@@ -291,11 +296,6 @@
   if (call_depth > 1)
     DASSL_ABORT1 ("invalid recursive call");
 
-  int nargin = args.length ();
-
-  if (nargin < 4 || nargin > 5)
-    print_usage ();
-
   std::string fcn_name, fname, jac_name, jname;
   dassl_fcn = 0;
   dassl_jac = 0;
@@ -334,7 +334,7 @@
                   dassl_jac = extract_function (c(1), "dassl", jac_name,
                                                 jname, "; endfunction");
 
-                  if (!dassl_jac)
+                  if (! dassl_jac)
                     {
                       if (fcn_name.length ())
                         clear_function (fcn_name);
@@ -347,7 +347,7 @@
         DASSL_ABORT1 ("incorrect number of elements in cell array");
     }
 
-  if (!dassl_fcn && ! f_arg.is_cell ())
+  if (! dassl_fcn && ! f_arg.is_cell ())
     {
       if (f_arg.is_function_handle () || f_arg.is_inline_function ())
         dassl_fcn = f_arg.function_value ();
@@ -389,7 +389,7 @@
                                                   jac_name, jname,
                                                   "; endfunction");
 
-                    if (!dassl_jac)
+                    if (! dassl_jac)
                       {
                         if (fcn_name.length ())
                           clear_function (fcn_name);
--- a/libinterp/corefcn/data.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/data.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -90,8 +90,6 @@
 
 #define ANY_ALL(FCN) \
  \
-  octave_value retval; \
- \
   int nargin = args.length (); \
  \
   if (nargin < 1 || nargin > 2) \
@@ -100,11 +98,10 @@
   int dim = (nargin == 1 ? -1 : args(1).int_value (#FCN ": DIM must be an integer") - 1); \
  \
   if (dim >= -1) \
-    retval = args(0).FCN (dim); \
+    return octave_value (args(0).FCN (dim)); \
   else \
     error (#FCN ": invalid dimension argument = %d", dim + 1); \
  \
-  return retval
 
 DEFUN (all, args, ,
        "-*- texinfo -*-\n\
@@ -219,11 +216,11 @@
 @seealso{tan, tand, tanh, atanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 2)
     print_usage ();
 
+  octave_value retval;
+
   if (! args(0).is_numeric_type ())
     gripe_wrong_type_arg ("atan2", args(0));
   else if (! args(1).is_numeric_type ())
@@ -494,11 +491,11 @@
 @seealso{pow2, log, log10, exp}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 1)
     print_usage ();
 
+  octave_value_list retval;
+
   if (nargout < 2)
     retval = ovl (args(0).log2 ());
   else if (args(0).is_single_type ())
@@ -602,11 +599,11 @@
 @seealso{mod}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 2)
     print_usage ();
 
+  octave_value retval;
+
   if (! args(0).is_numeric_type ())
     gripe_wrong_type_arg ("rem", args(0));
   else if (! args(1).is_numeric_type ())
@@ -782,11 +779,11 @@
 @seealso{rem}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 2)
     print_usage ();
 
+  octave_value retval;
+
   if (! args(0).is_numeric_type ())
     gripe_wrong_type_arg ("mod", args(0));
   else if (! args(1).is_numeric_type ())
@@ -929,8 +926,6 @@
 
 #define NATIVE_REDUCTION(FCN, BOOL_FCN) \
  \
-  octave_value retval; \
- \
   int nargin = args.length (); \
  \
   bool isnative = false; \
@@ -952,116 +947,79 @@
   if (nargin < 1 || nargin > 2) \
     print_usage (); \
  \
+  octave_value retval; \
+ \
   octave_value arg = args(0); \
  \
   int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
  \
-  if (dim >= -1) \
-    { \
-      if (arg.is_sparse_type ()) \
-        { \
-          if (arg.is_real_type ()) \
-            { \
-              SparseMatrix tmp = arg.sparse_matrix_value (); \
+  if (dim < -1) \
+    error (#FCN ": invalid dimension argument = %d", dim + 1); \
  \
-              retval = tmp.FCN (dim); \
-            } \
-          else \
-            { \
-              SparseComplexMatrix tmp \
-                = arg.sparse_complex_matrix_value (); \
- \
-              retval = tmp.FCN (dim); \
-            } \
+  if (arg.is_sparse_type ()) \
+    { \
+      if (arg.is_real_type ()) \
+        { \
+          SparseMatrix tmp = arg.sparse_matrix_value (); \
+\
+          retval = tmp.FCN (dim); \
         } \
       else \
         { \
-          if (isnative) \
+          SparseComplexMatrix tmp \
+            = arg.sparse_complex_matrix_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+    } \
+  else \
+    { \
+      if (isnative) \
+        { \
+          if NATIVE_REDUCTION_1 (FCN, uint8, dim) \
+          else if NATIVE_REDUCTION_1 (FCN, uint16, dim) \
+          else if NATIVE_REDUCTION_1 (FCN, uint32, dim) \
+          else if NATIVE_REDUCTION_1 (FCN, uint64, dim) \
+          else if NATIVE_REDUCTION_1 (FCN, int8, dim) \
+          else if NATIVE_REDUCTION_1 (FCN, int16, dim) \
+          else if NATIVE_REDUCTION_1 (FCN, int32, dim) \
+          else if NATIVE_REDUCTION_1 (FCN, int64, dim) \
+          else if (arg.is_bool_type ()) \
             { \
-              if NATIVE_REDUCTION_1 (FCN, uint8, dim) \
-              else if NATIVE_REDUCTION_1 (FCN, uint16, dim) \
-              else if NATIVE_REDUCTION_1 (FCN, uint32, dim) \
-              else if NATIVE_REDUCTION_1 (FCN, uint64, dim) \
-              else if NATIVE_REDUCTION_1 (FCN, int8, dim) \
-              else if NATIVE_REDUCTION_1 (FCN, int16, dim) \
-              else if NATIVE_REDUCTION_1 (FCN, int32, dim) \
-              else if NATIVE_REDUCTION_1 (FCN, int64, dim) \
-              else if (arg.is_bool_type ()) \
-                { \
-                  boolNDArray tmp = arg.bool_array_value (); \
- \
-                  retval = boolNDArray (tmp.BOOL_FCN (dim)); \
-                } \
-              else if (arg.is_char_matrix ()) \
+              boolNDArray tmp = arg.bool_array_value (); \
+\
+              retval = boolNDArray (tmp.BOOL_FCN (dim)); \
+            } \
+          else if (arg.is_char_matrix ()) \
+            { \
+              error (#FCN, ": invalid char type"); \
+            } \
+          else if (!isdouble && arg.is_single_type ()) \
+            { \
+              if (arg.is_complex_type ()) \
                 { \
-                  error (#FCN, ": invalid char type"); \
-                } \
-              else if (!isdouble && arg.is_single_type ()) \
-                { \
-                  if (arg.is_complex_type ()) \
-                    { \
-                      FloatComplexNDArray tmp = \
-                        arg.float_complex_array_value (); \
- \
-                      retval = tmp.FCN (dim); \
-                    } \
-                  else if (arg.is_real_type ()) \
-                    { \
-                      FloatNDArray tmp = arg.float_array_value (); \
- \
-                      retval = tmp.FCN (dim); \
-                    } \
-                } \
-              else if (arg.is_complex_type ()) \
-                { \
-                  ComplexNDArray tmp = arg.complex_array_value (); \
- \
+                  FloatComplexNDArray tmp = \
+                    arg.float_complex_array_value (); \
+\
                   retval = tmp.FCN (dim); \
                 } \
               else if (arg.is_real_type ()) \
                 { \
-                  NDArray tmp = arg.array_value (); \
- \
+                  FloatNDArray tmp = arg.float_array_value (); \
+\
                   retval = tmp.FCN (dim); \
                 } \
-              else \
-                { \
-                  gripe_wrong_type_arg (#FCN, arg); \
-                  return retval; \
-                } \
             } \
-          else if (arg.is_bool_type ()) \
-            { \
-              boolNDArray tmp = arg.bool_array_value (); \
- \
-              retval = tmp.FCN (dim); \
-            } \
-          else if (!isdouble && arg.is_single_type ()) \
+          else if (arg.is_complex_type ()) \
             { \
-              if (arg.is_real_type ()) \
-                { \
-                  FloatNDArray tmp = arg.float_array_value (); \
- \
-                  retval = tmp.FCN (dim); \
-                } \
-              else if (arg.is_complex_type ()) \
-                { \
-                  FloatComplexNDArray tmp = \
-                    arg.float_complex_array_value (); \
- \
-                  retval = tmp.FCN (dim); \
-                } \
+              ComplexNDArray tmp = arg.complex_array_value (); \
+\
+              retval = tmp.FCN (dim); \
             } \
           else if (arg.is_real_type ()) \
             { \
               NDArray tmp = arg.array_value (); \
- \
-              retval = tmp.FCN (dim); \
-            } \
-          else if (arg.is_complex_type ()) \
-            { \
-              ComplexNDArray tmp = arg.complex_array_value (); \
- \
+\
               retval = tmp.FCN (dim); \
             } \
           else \
@@ -1070,69 +1028,39 @@
               return retval; \
             } \
         } \
-      else \
-        error (#FCN ": invalid dimension argument = %d", dim + 1); \
-    } \
- \
-  return retval
-
-#define DATA_REDUCTION(FCN) \
- \
-  octave_value retval; \
- \
-  int nargin = args.length (); \
- \
-  if (nargin < 1 || nargin > 2) \
-    print_usage (); \
- \
-  octave_value arg = args(0); \
- \
-  int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
- \
-  if (dim >= -1) \
-    { \
-      if (arg.is_real_type ()) \
+      else if (arg.is_bool_type ()) \
         { \
-          if (arg.is_sparse_type ()) \
+          boolNDArray tmp = arg.bool_array_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+      else if (!isdouble && arg.is_single_type ()) \
+        { \
+          if (arg.is_real_type ()) \
             { \
-              SparseMatrix tmp = arg.sparse_matrix_value (); \
- \
+              FloatNDArray tmp = arg.float_array_value (); \
+\
               retval = tmp.FCN (dim); \
             } \
-          else if (arg.is_single_type ()) \
+          else if (arg.is_complex_type ()) \
             { \
-              FloatNDArray tmp = arg.float_array_value (); \
- \
-              retval = tmp.FCN (dim); \
-            } \
-          else \
-            { \
-              NDArray tmp = arg.array_value (); \
- \
+              FloatComplexNDArray tmp = \
+                arg.float_complex_array_value (); \
+\
               retval = tmp.FCN (dim); \
             } \
         } \
+      else if (arg.is_real_type ()) \
+        { \
+          NDArray tmp = arg.array_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
       else if (arg.is_complex_type ()) \
         { \
-          if (arg.is_sparse_type ()) \
-            { \
-              SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
- \
-              retval = tmp.FCN (dim); \
-            } \
-          else if (arg.is_single_type ()) \
-            { \
-              FloatComplexNDArray tmp \
-                = arg.float_complex_array_value (); \
- \
-              retval = tmp.FCN (dim); \
-            } \
-          else \
-            { \
-              ComplexNDArray tmp = arg.complex_array_value (); \
- \
-              retval = tmp.FCN (dim); \
-            } \
+          ComplexNDArray tmp = arg.complex_array_value (); \
+\
+          retval = tmp.FCN (dim); \
         } \
       else \
         { \
@@ -1140,8 +1068,73 @@
           return retval; \
         } \
     } \
+ \
+  return retval
+
+#define DATA_REDUCTION(FCN) \
+ \
+  int nargin = args.length (); \
+ \
+  if (nargin < 1 || nargin > 2) \
+    print_usage (); \
+ \
+  octave_value retval; \
+ \
+  octave_value arg = args(0); \
+ \
+  int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+ \
+  if (dim < -1) \
+    error (#FCN ": invalid dimension argument = %d", dim + 1); \
+ \
+  if (arg.is_real_type ()) \
+    { \
+      if (arg.is_sparse_type ()) \
+        { \
+          SparseMatrix tmp = arg.sparse_matrix_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+      else if (arg.is_single_type ()) \
+        { \
+          FloatNDArray tmp = arg.float_array_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+      else \
+        { \
+          NDArray tmp = arg.array_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+    } \
+  else if (arg.is_complex_type ()) \
+    { \
+      if (arg.is_sparse_type ()) \
+        { \
+          SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+      else if (arg.is_single_type ()) \
+        { \
+          FloatComplexNDArray tmp \
+            = arg.float_complex_array_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+      else \
+        { \
+          ComplexNDArray tmp = arg.complex_array_value (); \
+\
+          retval = tmp.FCN (dim); \
+        } \
+    } \
   else \
-    error (#FCN ": invalid dimension argument = %d", dim + 1); \
+    { \
+      gripe_wrong_type_arg (#FCN, arg); \
+      return retval; \
+    } \
  \
   return retval
 
@@ -1194,8 +1187,6 @@
 @seealso{sum, cumprod}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   bool isnative = false;
@@ -1217,8 +1208,6 @@
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  octave_value arg = args(0);
-
   int dim = -1;
   if (nargin == 2)
     {
@@ -1227,6 +1216,9 @@
         error ("cumsum: invalid dimension argument = %d", dim + 1);
     }
 
+  octave_value retval;
+  octave_value arg = args(0);
+
   switch (arg.builtin_type ())
     {
     case btyp_double:
@@ -1352,13 +1344,13 @@
 @var{k}-th diagonal of the matrix.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
 
+  octave_value retval;
+
   if (nargin == 1)
     retval = args(0).diag ();
   else if (nargin == 2)
@@ -1482,8 +1474,6 @@
 @seealso{cumprod, sum}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   bool isnative = false;
@@ -1505,6 +1495,8 @@
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  octave_value retval;
+
   octave_value arg = args(0);
 
   int dim = -1;
@@ -2555,9 +2547,7 @@
 
   // FIXME: maybe we should create an idx_vector object here
   //        and pass that to permute?
-
   int n = vec.numel ();
-
   for (int i = 0; i < n; i++)
     vec(i)--;
 
@@ -2789,15 +2779,13 @@
 
       const dim_vector dv = args(0).dims ();
 
-      if (nd > 0)
-        {
-          if (nd <= dv.length ())
-            retval(0) = dv(nd-1);
-          else
-            retval(0) = 1;
-        }
+      if (nd < 1)
+        error ("size: requested dimension DIM (= %d) out of range", nd);
+
+      if (nd <= dv.length ())
+        retval(0) = dv(nd-1);
       else
-        error ("size: requested dimension DIM (= %d) out of range", nd);
+        retval(0) = 1;
     }
   else
     print_usage ();
@@ -2960,8 +2948,6 @@
 @seealso{cumsum, sumsq, prod}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   bool isnative = false;
@@ -2986,8 +2972,6 @@
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  octave_value arg = args(0);
-
   int dim = -1;
   if (nargin == 2)
     {
@@ -2996,6 +2980,9 @@
         error ("sum: invalid dimension DIM = %d", dim + 1);
     }
 
+  octave_value retval;
+  octave_value arg = args(0);
+
   switch (arg.builtin_type ())
     {
     case btyp_double:
@@ -3292,13 +3279,13 @@
 @seealso{real, imag, iscomplex, abs, arg}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  octave_value retval;
+
   if (nargin == 1)
     {
       octave_value arg = args(0);
@@ -3402,16 +3389,13 @@
             }
           else
             {
-              if (re_val.dims () == im_val.dims ())
-                {
-                  SparseComplexMatrix result;
-                  result = SparseComplexMatrix (re_val)
-                    + Complex (0, 1) * SparseComplexMatrix (im_val);
-                  retval = octave_value (
-                                         new octave_sparse_complex_matrix (result));
-                }
-              else
+              if (re_val.dims () != im_val.dims ())
                 error ("complex: dimension mismatch");
+
+              SparseComplexMatrix result;
+              result = SparseComplexMatrix (re_val)
+                + Complex (0, 1) * SparseComplexMatrix (im_val);
+              retval = octave_value (new octave_sparse_complex_matrix (result));
             }
         }
       else if (re.is_single_type () || im.is_single_type ())
@@ -3462,20 +3446,18 @@
                 {
                   const FloatNDArray im_val = im.float_array_value ();
 
-                  if (re_val.dims () == im_val.dims ())
-                    {
-                      FloatComplexNDArray result (re_val.dims (),
-                                                  FloatComplex ());
-
-                      for (octave_idx_type i = 0; i < re_val.numel (); i++)
-                        result.xelem (i) = FloatComplex (re_val(i),
-                                                         im_val(i));
-
-                      retval = octave_value (new octave_float_complex_matrix
-                                             (result));
-                    }
-                  else
+                  if (re_val.dims () != im_val.dims ())
                     error ("complex: dimension mismatch");
+                  
+                  FloatComplexNDArray result (re_val.dims (),
+                                              FloatComplex ());
+
+                  for (octave_idx_type i = 0; i < re_val.numel (); i++)
+                    result.xelem (i) = FloatComplex (re_val(i),
+                                                     im_val(i));
+
+                  retval = octave_value (new octave_float_complex_matrix
+                                         (result));
                 }
             }
         }
@@ -3521,18 +3503,15 @@
             {
               const NDArray im_val = im.array_value ();
 
-              if (re_val.dims () == im_val.dims ())
-                {
-                  ComplexNDArray result (re_val.dims (), Complex ());
-
-                  for (octave_idx_type i = 0; i < re_val.numel (); i++)
-                    result.xelem (i) = Complex (re_val(i), im_val(i));
-
-                  retval = octave_value (
-                                         new octave_complex_matrix (result));
-                }
-              else
+              if (re_val.dims () != im_val.dims ())
                 error ("complex: dimension mismatch");
+
+              ComplexNDArray result (re_val.dims (), Complex ());
+
+              for (octave_idx_type i = 0; i < re_val.numel (); i++)
+                result.xelem (i) = Complex (re_val(i), im_val(i));
+
+              retval = octave_value (new octave_complex_matrix (result));
             }
         }
     }
@@ -4977,8 +4956,6 @@
 @seealso{speye, ones, zeros}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   oct_data_conv::data_type dt = oct_data_conv::dt_double;
@@ -4996,6 +4973,8 @@
   if (nargin > 2)
     print_usage ();
 
+  octave_value retval;
+
   if (nargin == 0)
     retval = identity_matrix (1, 1, dt);
   else if (nargin == 1)
@@ -5096,20 +5075,16 @@
 @seealso{logspace}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  octave_idx_type npoints = 100;
-
   if (nargin != 2 && nargin != 3)
     print_usage ();
 
+  octave_idx_type npoints = 100;
   if (nargin == 3)
     {
       // Apparently undocumented Matlab.  If the third arg is an empty
       // numeric value, the number of points defaults to 1.
-
       octave_value arg_3 = args(2);
 
       if (arg_3.is_numeric_type () && arg_3.is_empty ())
@@ -5131,13 +5106,15 @@
 
   if (! isvector1 || ! isvector2)
     error ("linspace: A, B must be scalars or vectors");
-  else if (arg_1.is_single_type () || arg_2.is_single_type ())
+
+  octave_value retval;
+
+  if (arg_1.is_single_type () || arg_2.is_single_type ())
     {
       if (arg_1.is_complex_type () || arg_2.is_complex_type ())
         retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
       else
         retval = do_linspace<FloatMatrix> (arg_1, arg_2, npoints);
-
     }
   else
     {
@@ -5254,13 +5231,13 @@
 @seealso{reshape, postpad, prepad, cat}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2)
     print_usage ();
 
+  octave_value retval;
+
   if (nargin == 2)
     {
       Array<double> vec = args(1).vector_value ();
@@ -5331,13 +5308,13 @@
 @seealso{resize, vec, postpad, cat, squeeze}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2)
     print_usage ();
 
+  octave_value retval;
+
   dim_vector new_dims;
 
   if (nargin == 2)
@@ -5352,10 +5329,7 @@
       for (octave_idx_type i = 0; i < new_size.numel (); i++)
         {
           if (new_size(i) < 0)
-            {
-              error ("reshape: SIZE must be non-negative");
-              break;
-            }
+            error ("reshape: SIZE must be non-negative");
           else
             new_dims(i) = new_size(i);
         }
@@ -5370,10 +5344,7 @@
           if (args(i).is_empty ())
             {
               if (empty_dim > 0)
-                {
-                  error ("reshape: only a single dimension can be unknown");
-                  break;
-                }
+                error ("reshape: only a single dimension can be unknown");
               else
                 {
                   empty_dim = i;
@@ -5385,10 +5356,7 @@
               new_dims(i-1) = args(i).idx_type_value ();
 
               if (new_dims(i-1) < 0)
-                {
-                  error ("reshape: SIZE must be non-negative");
-                  break;
-                }
+                error ("reshape: SIZE must be non-negative");
             }
         }
 
@@ -5456,14 +5424,12 @@
 @seealso{vech, resize, cat}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  int dim = 1;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage () ;
 
+  int dim = 1;
   if (nargin == 2)
     {
       dim = args(1).idx_type_value ();
@@ -5474,8 +5440,8 @@
 
   octave_value colon (octave_value::magic_colon_t);
   octave_value arg = args(0);
-  retval = arg.single_subsref ("(", colon);
-
+
+  octave_value retval = arg.single_subsref ("(", colon);
 
   if (dim > 1)
     {
@@ -5599,8 +5565,6 @@
 @seealso{cond, svd}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 && nargin > 3)
@@ -5608,75 +5572,75 @@
 
   octave_value x_arg = args(0);
 
-  if (x_arg.ndims () == 2)
+  if (x_arg.ndims () != 2)
+    error ("norm: only valid for 2-D objects");
+
+  enum { sfmatrix, sfcols, sfrows, sffrob, sfinf } strflag = sfmatrix;
+  if (nargin > 1 && args(nargin-1).is_string ())
     {
-      enum { sfmatrix, sfcols, sfrows, sffrob, sfinf } strflag = sfmatrix;
-      if (nargin > 1 && args(nargin-1).is_string ())
+      std::string str = args(nargin-1).string_value ();
+      if (str == "cols" || str == "columns")
+        strflag = sfcols;
+      else if (str == "rows")
+        strflag = sfrows;
+      else if (str == "fro")
+        strflag = sffrob;
+      else if (str == "inf")
+        strflag = sfinf;
+      else
+        error ("norm: unrecognized option: %s", str.c_str ());
+      // we've handled the last parameter, so act as if it was removed
+      nargin --;
+    }
+
+  octave_value p_arg = (nargin > 1) ? args(1) : octave_value (2);
+
+  if (p_arg.is_empty ())
+    p_arg = octave_value (2);
+  else if (p_arg.is_string ())
+    {
+      std::string str = p_arg.string_value ();
+      if ((strflag == sfcols || strflag == sfrows))
         {
-          std::string str = args(nargin-1).string_value ();
-          if (str == "cols" || str == "columns")
-            strflag = sfcols;
-          else if (str == "rows")
-            strflag = sfrows;
+          if (str == "cols" || str == "columns" || str == "rows")
+            error ("norm: invalid combination of options");
           else if (str == "fro")
-            strflag = sffrob;
+            p_arg = octave_value (2);
           else if (str == "inf")
-            strflag = sfinf;
+            p_arg = octave_Inf;
           else
             error ("norm: unrecognized option: %s", str.c_str ());
-          // we've handled the last parameter, so act as if it was removed
-          nargin --;
         }
-
-      octave_value p_arg = (nargin > 1) ? args(1) : octave_value (2);
-
-      if (p_arg.is_empty ())
-        p_arg = octave_value (2);
-      else if (p_arg.is_string ())
-        {
-          std::string str = p_arg.string_value ();
-          if ((strflag == sfcols || strflag == sfrows))
-            {
-              if (str == "cols" || str == "columns" || str == "rows")
-                error ("norm: invalid combination of options");
-              else if (str == "fro")
-                p_arg = octave_value (2);
-              else if (str == "inf")
-                p_arg = octave_Inf;
-              else
-                error ("norm: unrecognized option: %s", str.c_str ());
-            }
-          else
-            error ("norm: invalid combination of options");
-        }
-      else if (! p_arg.is_scalar_type ())
-        gripe_wrong_type_arg ("norm", p_arg, true);
-
-      switch (strflag)
-        {
-        case sfmatrix:
-          retval(0) = xnorm (x_arg, p_arg);
-          break;
-
-        case sfcols:
-          retval(0) = xcolnorms (x_arg, p_arg);
-          break;
-
-        case sfrows:
-          retval(0) = xrownorms (x_arg, p_arg);
-          break;
-
-        case sffrob:
-          retval(0) = xfrobnorm (x_arg);
-          break;
-
-        case sfinf:
-          retval(0) = xnorm (x_arg, octave_Inf);
-          break;
-        }
+      else
+        error ("norm: invalid combination of options");
     }
-  else
-    error ("norm: only valid for 2-D objects");
+  else if (! p_arg.is_scalar_type ())
+    gripe_wrong_type_arg ("norm", p_arg, true);
+
+  octave_value retval;
+
+  switch (strflag)
+    {
+    case sfmatrix:
+      retval = xnorm (x_arg, p_arg);
+      break;
+
+    case sfcols:
+      retval = xcolnorms (x_arg, p_arg);
+      break;
+
+    case sfrows:
+      retval = xrownorms (x_arg, p_arg);
+      break;
+
+    case sffrob:
+      retval = xfrobnorm (x_arg);
+      break;
+
+    case sfinf:
+      retval = xnorm (x_arg, octave_Inf);
+      break;
+    }
 
   return retval;
 }
@@ -5872,13 +5836,13 @@
                             octave_value::assign_op aop,
                             const octave_value_list& args)
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin == 0)
     print_usage ();
 
+  octave_value retval;
+
   if (nargin == 1)
     retval = args(0);
   else if (nargin == 2)
@@ -6171,9 +6135,8 @@
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
-  return (nargin == 2)
-    ? do_colon_op (args(0), args(1))
-    : do_colon_op (args(0), args(1), args (2));
+  return (nargin == 2) ? do_colon_op (args(0), args(1))
+                       : do_colon_op (args(0), args(1), args(2));
 }
 
 static double tic_toc_timestamp = -1.0;
@@ -6255,15 +6218,13 @@
 @seealso{tic, cputime}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  double start_time = tic_toc_timestamp;
-
   if (nargin > 1)
     print_usage ();
 
+  double start_time = tic_toc_timestamp;
+
   if (nargin == 1)
     {
       octave_uint64 id = args(0).xuint64_scalar_value ("toc: invalid ID");
@@ -6276,22 +6237,21 @@
            / CLOCKS_PER_SEC);
 
       // FIXME: should we also check to see whether the start
-      // time is after the beginning of this Octave session?
+      //        time is after the beginning of this Octave session?
     }
 
   if (start_time < 0)
     error ("toc called before timer set");
+
+  octave_time now;
+
+  double etime = now.double_value () - start_time;
+
+  octave_value retval;
+  if (nargout > 0)
+    retval = etime;
   else
-    {
-      octave_time now;
-
-      double tmp = now.double_value () - start_time;
-
-      if (nargout > 0)
-        retval = tmp;
-      else
-        octave_stdout << "Elapsed time is " << tmp << " seconds.\n";
-    }
+    octave_stdout << "Elapsed time is " << etime << " seconds.\n";
 
   return retval;
 }
@@ -6693,16 +6653,14 @@
 //
 // This function does not yet support sparse matrices.
 
+// FIXME: Is this function used anymore?  12/14/2015
 DEFUN (__sort_rows_idx__, args, ,
        "-*- texinfo -*-\n\
 @deftypefn {} {} __sort_rows_idx__ (@var{a}, @var{mode})\n\
 Undocumented internal function.\n\
 @end deftypefn\n")
 {
-  octave_value retval;
-
   int nargin = args.length ();
-  sortmode smode = ASCENDING;
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
@@ -6710,6 +6668,7 @@
   if (nargin == 2 && ! args(1).is_string ())
     error ("__sort_rows_idx__: second argument must be a string");
 
+  sortmode smode = ASCENDING;
   if (nargin > 1)
     {
       std::string mode = args(1).string_value ();
@@ -6725,23 +6684,20 @@
 
   if (arg.is_sparse_type ())
     error ("__sort_rows_idx__: sparse matrices not yet supported");
-  if (arg.ndims () == 2)
-    {
-      Array<octave_idx_type> idx = arg.sort_rows_idx (smode);
-
-      retval = octave_value (idx, true, true);
-    }
-  else
+
+  if (arg.ndims () != 2)
     error ("__sort_rows_idx__: needs a 2-dimensional object");
 
-  return retval;
+  Array<octave_idx_type> idx = arg.sort_rows_idx (smode);
+
+  return octave_value (idx, true, true);
 }
 
 static sortmode
 get_sort_mode_option (const octave_value& arg)
 {
   // FIXME: we initialize to UNSORTED here to avoid a GCC warning
-  // about possibly using sortmode uninitialized.
+  //        about possibly using sortmode uninitialized.
   // FIXME: shouldn't these modes be scoped inside a class?
   sortmode smode = UNSORTED;
 
@@ -6779,8 +6735,6 @@
 @seealso{sort, sortrows}\n\
 @end deftypefn\n")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
@@ -6804,23 +6758,25 @@
         smode = get_sort_mode_option (args(1));
     }
 
+  octave_value retval;
+
   octave_value arg = args(0);
 
   if (by_rows)
     {
       if (arg.is_sparse_type ())
         error ("issorted: sparse matrices not yet supported");
-      if (arg.ndims () == 2)
-        retval = arg.is_sorted_rows (smode) != UNSORTED;
-      else
+      if (arg.ndims () != 2)
         error ("issorted: A must be a 2-dimensional object");
+
+      retval = arg.is_sorted_rows (smode) != UNSORTED;
     }
   else
     {
-      if (arg.dims ().is_vector ())
-        retval = args(0).is_sorted (smode) != UNSORTED;
-      else
+      if (! arg.dims ().is_vector ())
         error ("issorted: needs a vector");
+
+      retval = args(0).is_sorted (smode) != UNSORTED;
     }
 
   return retval;
@@ -6896,15 +6852,11 @@
 @seealso{sort, min, max}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
-  octave_value argx = args(0);
-
   int dim = -1;
   if (nargin == 3)
     {
@@ -6912,9 +6864,13 @@
       if (dim < 0)
         error ("nth_element: DIM must be a valid dimension");
     }
+
+  octave_value argx = args(0);
   if (dim < 0)
     dim = argx.dims ().first_non_singleton ();
 
+  octave_value retval;
+
   try
     {
       idx_vector n = args(1).index_vector ();
@@ -6992,8 +6948,6 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 && nargin > 3)
@@ -7002,6 +6956,8 @@
   if (! args(0).is_numeric_type ())
     error ("__accumarray_sum__: first argument must be numeric");
 
+  octave_value retval;
+
   try
     {
       idx_vector idx = args(0).index_vector ();
@@ -7081,8 +7037,6 @@
 do_accumarray_minmax_fun (const octave_value_list& args,
                           bool ismin)
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 3 && nargin > 4)
@@ -7091,6 +7045,8 @@
   if (! args(0).is_numeric_type ())
     error ("accumarray: first argument must be numeric");
 
+  octave_value retval;
+
   try
     {
       idx_vector idx = args(0).index_vector ();
@@ -7215,8 +7171,6 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 && nargin > 4)
@@ -7225,6 +7179,8 @@
   if (! args(0).is_numeric_type ())
     error ("__accumdim_sum__: first argument must be numeric");
 
+  octave_value retval;
+
   try
     {
       idx_vector idx = args(0).index_vector ();
@@ -7364,14 +7320,14 @@
 @seealso{logical, diff}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 3)
     print_usage ();
 
   if (! (args(0).is_bool_type () || args(0).is_numeric_type ()))
     error ("merge: first argument must be logical or numeric");
 
+  octave_value retval;
+
   octave_value mask_val = args(0);
 
   if (mask_val.is_scalar_type ())
@@ -7598,8 +7554,6 @@
 @seealso{sort, merge}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
@@ -7629,9 +7583,7 @@
         dim -= 1;
     }
 
-  retval = do_diff (args(0), order, dim);
-
-  return retval;
+  return do_diff (args(0), order, dim);
 }
 
 /*
@@ -7713,51 +7665,49 @@
 
   if (rm.rows () != 2 || rm.ndims () != 2)
     error ("repelems: R must be a matrix with two rows");
-  else
+
+  octave_value x = args(0);
+
+  NoAlias< Array<octave_idx_type> > r (rm.dims ());
+
+  for (octave_idx_type i = 0; i < rm.numel (); i++)
     {
-      octave_value x = args(0);
-
-      NoAlias< Array<octave_idx_type> > r (rm.dims ());
-
-      for (octave_idx_type i = 0; i < rm.numel (); i++)
-        {
-          octave_idx_type rx = rm(i);
-          if (static_cast<double> (rx) != rm(i))
-            error ("repelems: R must be a matrix of integers");
-
-          r(i) = rx;
-        }
-
-      switch (x.builtin_type ())
-        {
+      octave_idx_type rx = rm(i);
+      if (static_cast<double> (rx) != rm(i))
+        error ("repelems: R must be a matrix of integers");
+
+      r(i) = rx;
+    }
+
+  switch (x.builtin_type ())
+    {
 #define BTYP_BRANCH(X, EX) \
-        case btyp_ ## X: \
-          retval = do_repelems (x.EX ## _value (), r); \
-          break;
-
-          BTYP_BRANCH (double, array);
-          BTYP_BRANCH (float, float_array);
-          BTYP_BRANCH (complex, complex_array);
-          BTYP_BRANCH (float_complex, float_complex_array);
-          BTYP_BRANCH (bool, bool_array);
-          BTYP_BRANCH (char, char_array);
-
-          BTYP_BRANCH (int8,  int8_array);
-          BTYP_BRANCH (int16, int16_array);
-          BTYP_BRANCH (int32, int32_array);
-          BTYP_BRANCH (int64, int64_array);
-          BTYP_BRANCH (uint8,  uint8_array);
-          BTYP_BRANCH (uint16, uint16_array);
-          BTYP_BRANCH (uint32, uint32_array);
-          BTYP_BRANCH (uint64, uint64_array);
-
-          BTYP_BRANCH (cell, cell);
-          //BTYP_BRANCH (struct, map);//FIXME
+    case btyp_ ## X: \
+      retval = do_repelems (x.EX ## _value (), r); \
+      break;
+
+      BTYP_BRANCH (double, array);
+      BTYP_BRANCH (float, float_array);
+      BTYP_BRANCH (complex, complex_array);
+      BTYP_BRANCH (float_complex, float_complex_array);
+      BTYP_BRANCH (bool, bool_array);
+      BTYP_BRANCH (char, char_array);
+
+      BTYP_BRANCH (int8,  int8_array);
+      BTYP_BRANCH (int16, int16_array);
+      BTYP_BRANCH (int32, int32_array);
+      BTYP_BRANCH (int64, int64_array);
+      BTYP_BRANCH (uint8,  uint8_array);
+      BTYP_BRANCH (uint16, uint16_array);
+      BTYP_BRANCH (uint32, uint32_array);
+      BTYP_BRANCH (uint64, uint64_array);
+
+      BTYP_BRANCH (cell, cell);
+      //BTYP_BRANCH (struct, map);//FIXME
 #undef BTYP_BRANCH
 
-        default:
-          gripe_wrong_type_arg ("repelems", x);
-        }
+    default:
+      gripe_wrong_type_arg ("repelems", x);
     }
 
   return retval;
@@ -7772,27 +7722,24 @@
 @seealso{base64_decode}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 1)
     print_usage ();
 
   if (! args(0).is_numeric_type ())
     error ("base64_encode: encoding is supported only for numeric arrays");
-  else if (args(0).is_complex_type ()
-           || args(0).is_sparse_type ())
+  else if (args(0).is_complex_type () || args(0).is_sparse_type ())
     error ("base64_encode: encoding complex or sparse data is not supported");
 
+  octave_value_list retval;
+
   if (args(0).is_integer_type ())
     {
 #define MAKE_INT_BRANCH(X) \
       if (args(0).is_ ## X ## _type ()) \
         { \
           const X##NDArray in = args(0).  X## _array_value (); \
-          size_t inlen = \
-            in.numel () * sizeof (X## _t) / sizeof (char); \
-          const char* inc = \
-            reinterpret_cast<const char*> (in.data ()); \
+          size_t inlen = in.numel () * sizeof (X## _t) / sizeof (char); \
+          const char* inc = reinterpret_cast<const char*> (in.data ()); \
           char* out; \
           if (octave_base64_encode (inc, inlen, &out)) \
             { \
--- a/libinterp/corefcn/debug.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/debug.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -1115,6 +1115,11 @@
 static octave_value_list
 do_dbstack (const octave_value_list& args, int nargout, std::ostream& os)
 {
+  int nargin = args.length ();
+
+  if (nargin > 2)
+    print_usage ();
+
   octave_value_list retval;
 
   unwind_protect frame;
@@ -1123,13 +1128,6 @@
 
   size_t nskip = 0;
 
-  int nargin = args.length ();
-
-  // dbstack accepts up to 2 arguments.
-
-  if (nargin > 2)
-    print_usage ();
-
   if (nargin == 1 || nargin == 2)
     {
       int n = 0;
@@ -1360,52 +1358,50 @@
 @seealso{dbcont, dbquit}\n\
 @end deftypefn")
 {
-  if (Vdebugging)
-    {
-      int nargin = args.length ();
+  if (! Vdebugging)
+    error ("dbstep: can only be called in debug mode");
+
+  int nargin = args.length ();
 
-      if (nargin > 1)
-        print_usage ();
+  if (nargin > 1)
+    print_usage ();
 
-      if (nargin == 1)
+  if (nargin == 1)
+    {
+      std::string arg = args(0).xstring_value ("dbstep: input argument must be a string");
+
+      if (arg == "in")
         {
-          std::string arg = args(0).xstring_value ("dbstep: input argument must be a string");
+          Vdebugging = false;
+
+          tree_evaluator::dbstep_flag = -1;
+        }
+      else if (arg == "out")
+        {
+          Vdebugging = false;
 
-          if (arg == "in")
-            {
-              Vdebugging = false;
+          tree_evaluator::dbstep_flag = -2;
+        }
+      else
+        {
+          int n = atoi (arg.c_str ());
 
-              tree_evaluator::dbstep_flag = -1;
-            }
-          else if (arg == "out")
+          if (n > 0)
             {
               Vdebugging = false;
 
-              tree_evaluator::dbstep_flag = -2;
+              tree_evaluator::dbstep_flag = n;
             }
           else
-            {
-              int n = atoi (arg.c_str ());
-
-              if (n > 0)
-                {
-                  Vdebugging = false;
-
-                  tree_evaluator::dbstep_flag = n;
-                }
-              else
-                error ("dbstep: invalid argument");
-            }
-        }
-      else
-        {
-          Vdebugging = false;
-
-          tree_evaluator::dbstep_flag = 1;
+            error ("dbstep: invalid argument");
         }
     }
   else
-    error ("dbstep: can only be called in debug mode");
+    {
+      Vdebugging = false;
+
+      tree_evaluator::dbstep_flag = 1;
+    }
 
   return octave_value_list ();
 }
@@ -1419,17 +1415,15 @@
 @seealso{dbstep, dbquit}\n\
 @end deftypefn")
 {
-  if (Vdebugging)
-    {
-      if (args.length () != 0)
-        print_usage ();
+  if (! Vdebugging)
+    error ("dbcont: can only be called in debug mode");
 
-      Vdebugging = false;
+  if (args.length () != 0)
+    print_usage ();
 
-      tree_evaluator::reset_debug_state ();
-    }
-  else
-    error ("dbcont: can only be called in debug mode");
+  Vdebugging = false;
+
+  tree_evaluator::reset_debug_state ();
 
   return octave_value_list ();
 }
@@ -1442,19 +1436,17 @@
 @seealso{dbcont, dbstep}\n\
 @end deftypefn")
 {
-  if (Vdebugging)
-    {
-      if (args.length () != 0)
-        print_usage ();
+  if (! Vdebugging)
+    error ("dbquit: can only be called in debug mode");
 
-      Vdebugging = false;
+  if (args.length () != 0)
+    print_usage ();
 
-      tree_evaluator::reset_debug_state ();
+  Vdebugging = false;
 
-      octave_throw_interrupt_exception ();
-    }
-  else
-    error ("dbquit: can only be called in debug mode");
+  tree_evaluator::reset_debug_state ();
+
+  octave_throw_interrupt_exception ();
 
   return octave_value_list ();
 }
@@ -1481,8 +1473,6 @@
 With a logical argument @var{flag}, set the state on or off.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin > 1)
@@ -1495,5 +1485,6 @@
 
   tree_evaluator::quiet_breakpoint_flag = state;
 
-  return retval;
+  return octave_value_list ();
 }
+
--- a/libinterp/corefcn/dirfns.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/dirfns.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -563,21 +563,22 @@
 @seealso{pathsep}\n\
 @end deftypefn")
 {
-  octave_value retval;
+  int nargin = args.length ();
 
-  int nargin = args.length ();
   if (nargin > 1)
     print_usage ();
 
+  octave_value retval;
+
   if (nargin == 0)
     retval = file_ops::dir_sep_str ();
   else
     {
       std::string s = args(0).xstring_value ("filesep: argument must be a string");
-      if (s == "all")
-        retval = file_ops::dir_sep_chars ();
-      else
+      if (s != "all")
         error ("filesep: argument must be \"all\"");
+
+      retval = file_ops::dir_sep_chars ();
     }
 
   return retval;
@@ -591,13 +592,13 @@
 @seealso{filesep}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin > 1)
     print_usage ();
 
+  octave_value retval;
+
   if (nargout > 0 || nargin == 0)
     retval = dir_path::path_sep_str ();
 
--- a/libinterp/corefcn/dlmread.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/dlmread.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -188,8 +188,6 @@
 @seealso{csvread, textscan, textread, dlmwrite}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   double empty_value = 0.0;
@@ -460,11 +458,9 @@
     }
 
   if (iscmplx)
-    retval(0) = cdata;
+    return octave_value (cdata);
   else
-    retval(0) = rdata;
-
-  return retval;
+    return octave_value (rdata);
 }
 
 /*
--- a/libinterp/corefcn/dot.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/dot.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -122,116 +122,108 @@
 @seealso{cross, divergence}\n\
 @end deftypefn")
 {
-  octave_value retval;
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  octave_value retval;
   octave_value argx = args(0);
   octave_value argy = args(1);
 
-  if (argx.is_numeric_type () && argy.is_numeric_type ())
-    {
-      dim_vector dimx = argx.dims ();
-      dim_vector dimy = argy.dims ();
-      bool match = dimx == dimy;
-      if (! match && nargin == 2
-          && dimx.is_vector () && dimy.is_vector ())
-        {
-          // Change to column vectors.
-          dimx = dimx.redim (1);
-          argx = argx.reshape (dimx);
-          dimy = dimy.redim (1);
-          argy = argy.reshape (dimy);
-          match = dimx == dimy;
-        }
+  if (! argx.is_numeric_type () || ! argy.is_numeric_type ())
+    error ("dot: X and Y must be numeric");
 
-      if (match)
-        {
-          int dim;
-          if (nargin == 2)
-            dim = dimx.first_non_singleton ();
-          else
-            dim = args(2).int_value (true) - 1;
+  dim_vector dimx = argx.dims ();
+  dim_vector dimy = argy.dims ();
+  bool match = dimx == dimy;
+  if (! match && nargin == 2 && dimx.is_vector () && dimy.is_vector ())
+    {
+      // Change to column vectors.
+      dimx = dimx.redim (1);
+      argx = argx.reshape (dimx);
+      dimy = dimy.redim (1);
+      argy = argy.reshape (dimy);
+      match = dimx == dimy;
+    }
 
-          if (dim < 0)
-            error ("dot: DIM must be a valid dimension");
-          else
-            {
-              octave_idx_type m, n, k;
-              dim_vector dimz;
-              if (argx.is_complex_type () || argy.is_complex_type ())
-                {
-                  if (argx.is_single_type () || argy.is_single_type ())
-                    {
-                      FloatComplexNDArray x = argx.float_complex_array_value ();
-                      FloatComplexNDArray y = argy.float_complex_array_value ();
-                      get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      FloatComplexNDArray z (dimz);
+  if (! match)
+    error ("dot: sizes of X and Y must match");
 
-                      F77_XFCN (cdotc3, CDOTC3, (m, n, k,
-                                                 x.data (), y.data (),
-                                                 z.fortran_vec ()));
-                      retval = z;
-                    }
-                  else
-                    {
-                      ComplexNDArray x = argx.complex_array_value ();
-                      ComplexNDArray y = argy.complex_array_value ();
-                      get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      ComplexNDArray z (dimz);
+  int dim;
+  if (nargin == 2)
+    dim = dimx.first_non_singleton ();
+  else
+    dim = args(2).int_value (true) - 1;
 
-                      F77_XFCN (zdotc3, ZDOTC3, (m, n, k,
-                                                 x.data (), y.data (),
-                                                 z.fortran_vec ()));
-                      retval = z;
-                    }
-                }
-              else if (argx.is_float_type () && argy.is_float_type ())
-                {
-                  if (argx.is_single_type () || argy.is_single_type ())
-                    {
-                      FloatNDArray x = argx.float_array_value ();
-                      FloatNDArray y = argy.float_array_value ();
-                      get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      FloatNDArray z (dimz);
+  if (dim < 0)
+    error ("dot: DIM must be a valid dimension");
 
-                      F77_XFCN (sdot3, SDOT3, (m, n, k, x.data (), y.data (),
-                                               z.fortran_vec ()));
-                      retval = z;
-                    }
-                  else
-                    {
-                      NDArray x = argx.array_value ();
-                      NDArray y = argy.array_value ();
-                      get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      NDArray z (dimz);
+  octave_idx_type m, n, k;
+  dim_vector dimz;
+  if (argx.is_complex_type () || argy.is_complex_type ())
+    {
+      if (argx.is_single_type () || argy.is_single_type ())
+        {
+          FloatComplexNDArray x = argx.float_complex_array_value ();
+          FloatComplexNDArray y = argy.float_complex_array_value ();
+          get_red_dims (dimx, dimy, dim, dimz, m, n, k);
+          FloatComplexNDArray z (dimz);
 
-                      F77_XFCN (ddot3, DDOT3, (m, n, k, x.data (), y.data (),
-                                               z.fortran_vec ()));
-                      retval = z;
-                    }
-                }
-              else
-                {
-                  // Non-optimized evaluation.
-                  octave_value_list tmp;
-                  tmp(1) = dim + 1;
-                  tmp(0) = do_binary_op (octave_value::op_el_mul, argx, argy);
-
-                  tmp = feval ("sum", tmp, 1);
-                  if (! tmp.empty ())
-                    retval = tmp(0);
-                }
-            }
+          F77_XFCN (cdotc3, CDOTC3, (m, n, k,
+                                     x.data (), y.data (),
+                                     z.fortran_vec ()));
+          retval = z;
         }
       else
-        error ("dot: sizes of X and Y must match");
+        {
+          ComplexNDArray x = argx.complex_array_value ();
+          ComplexNDArray y = argy.complex_array_value ();
+          get_red_dims (dimx, dimy, dim, dimz, m, n, k);
+          ComplexNDArray z (dimz);
 
+          F77_XFCN (zdotc3, ZDOTC3, (m, n, k,
+                                     x.data (), y.data (),
+                                     z.fortran_vec ()));
+          retval = z;
+        }
+    }
+  else if (argx.is_float_type () && argy.is_float_type ())
+    {
+      if (argx.is_single_type () || argy.is_single_type ())
+        {
+          FloatNDArray x = argx.float_array_value ();
+          FloatNDArray y = argy.float_array_value ();
+          get_red_dims (dimx, dimy, dim, dimz, m, n, k);
+          FloatNDArray z (dimz);
+
+          F77_XFCN (sdot3, SDOT3, (m, n, k, x.data (), y.data (),
+                                   z.fortran_vec ()));
+          retval = z;
+        }
+      else
+        {
+          NDArray x = argx.array_value ();
+          NDArray y = argy.array_value ();
+          get_red_dims (dimx, dimy, dim, dimz, m, n, k);
+          NDArray z (dimz);
+
+          F77_XFCN (ddot3, DDOT3, (m, n, k, x.data (), y.data (),
+                                   z.fortran_vec ()));
+          retval = z;
+        }
     }
   else
-    error ("dot: X and Y must be numeric");
+    {
+      // Non-optimized evaluation.
+      octave_value_list tmp;
+      tmp(1) = dim + 1;
+      tmp(0) = do_binary_op (octave_value::op_el_mul, argx, argy);
+
+      tmp = feval ("sum", tmp, 1);
+      if (! tmp.empty ())
+        retval = tmp(0);
+    }
 
   return retval;
 }
@@ -293,94 +285,89 @@
 @end example\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 2)
     print_usage ();
 
+  octave_value retval;
+
   octave_value argx = args(0);
   octave_value argy = args(1);
 
-  if (argx.is_numeric_type () && argy.is_numeric_type ())
-    {
-      const dim_vector dimx = argx.dims ();
-      const dim_vector dimy = argy.dims ();
-      int nd = dimx.length ();
-      octave_idx_type m = dimx(0);
-      octave_idx_type k = dimx(1);
-      octave_idx_type n = dimy(1);
-      octave_idx_type np = 1;
-      bool match = dimy(0) == k && nd == dimy.length ();
-      dim_vector dimz = dim_vector::alloc (nd);
-      dimz(0) = m;
-      dimz(1) = n;
-      for (int i = 2; match && i < nd; i++)
-        {
-          match = match && dimx(i) == dimy(i);
-          dimz(i) = dimx(i);
-          np *= dimz(i);
-        }
-
-      if (match)
-        {
-          if (argx.is_complex_type () || argy.is_complex_type ())
-            {
-              if (argx.is_single_type () || argy.is_single_type ())
-                {
-                  FloatComplexNDArray x = argx.float_complex_array_value ();
-                  FloatComplexNDArray y = argy.float_complex_array_value ();
-                  FloatComplexNDArray z (dimz);
+  if (! argx.is_numeric_type () || ! argy.is_numeric_type ())
+    error ("blkmm: A and B must be numeric");
 
-                  F77_XFCN (cmatm3, CMATM3, (m, n, k, np,
-                                             x.data (), y.data (),
-                                             z.fortran_vec ()));
-                  retval = z;
-                }
-              else
-                {
-                  ComplexNDArray x = argx.complex_array_value ();
-                  ComplexNDArray y = argy.complex_array_value ();
-                  ComplexNDArray z (dimz);
+  const dim_vector dimx = argx.dims ();
+  const dim_vector dimy = argy.dims ();
+  int nd = dimx.length ();
+  octave_idx_type m = dimx(0);
+  octave_idx_type k = dimx(1);
+  octave_idx_type n = dimy(1);
+  octave_idx_type np = 1;
+  bool match = dimy(0) == k && nd == dimy.length ();
+  dim_vector dimz = dim_vector::alloc (nd);
+  dimz(0) = m;
+  dimz(1) = n;
+  for (int i = 2; match && i < nd; i++)
+    {
+      match = match && dimx(i) == dimy(i);
+      dimz(i) = dimx(i);
+      np *= dimz(i);
+    }
 
-                  F77_XFCN (zmatm3, ZMATM3, (m, n, k, np,
-                                             x.data (), y.data (),
-                                             z.fortran_vec ()));
-                  retval = z;
-                }
-            }
-          else
-            {
-              if (argx.is_single_type () || argy.is_single_type ())
-                {
-                  FloatNDArray x = argx.float_array_value ();
-                  FloatNDArray y = argy.float_array_value ();
-                  FloatNDArray z (dimz);
+  if (! match)
+    error ("blkmm: A and B dimensions don't match: (%s) and (%s)",
+           dimx.str ().c_str (), dimy.str ().c_str ());
 
-                  F77_XFCN (smatm3, SMATM3, (m, n, k, np,
-                                             x.data (), y.data (),
-                                             z.fortran_vec ()));
-                  retval = z;
-                }
-              else
-                {
-                  NDArray x = argx.array_value ();
-                  NDArray y = argy.array_value ();
-                  NDArray z (dimz);
+  if (argx.is_complex_type () || argy.is_complex_type ())
+    {
+      if (argx.is_single_type () || argy.is_single_type ())
+        {
+          FloatComplexNDArray x = argx.float_complex_array_value ();
+          FloatComplexNDArray y = argy.float_complex_array_value ();
+          FloatComplexNDArray z (dimz);
 
-                  F77_XFCN (dmatm3, DMATM3, (m, n, k, np,
-                                             x.data (), y.data (),
-                                             z.fortran_vec ()));
-                  retval = z;
-                }
-            }
+          F77_XFCN (cmatm3, CMATM3, (m, n, k, np,
+                                     x.data (), y.data (),
+                                     z.fortran_vec ()));
+          retval = z;
         }
       else
-        error ("blkmm: A and B dimensions don't match: (%s) and (%s)",
-               dimx.str ().c_str (), dimy.str ().c_str ());
+        {
+          ComplexNDArray x = argx.complex_array_value ();
+          ComplexNDArray y = argy.complex_array_value ();
+          ComplexNDArray z (dimz);
 
+          F77_XFCN (zmatm3, ZMATM3, (m, n, k, np,
+                                     x.data (), y.data (),
+                                     z.fortran_vec ()));
+          retval = z;
+        }
     }
   else
-    error ("blkmm: A and B must be numeric");
+    {
+      if (argx.is_single_type () || argy.is_single_type ())
+        {
+          FloatNDArray x = argx.float_array_value ();
+          FloatNDArray y = argy.float_array_value ();
+          FloatNDArray z (dimz);
+
+          F77_XFCN (smatm3, SMATM3, (m, n, k, np,
+                                     x.data (), y.data (),
+                                     z.fortran_vec ()));
+          retval = z;
+        }
+      else
+        {
+          NDArray x = argx.array_value ();
+          NDArray y = argy.array_value ();
+          NDArray z (dimz);
+
+          F77_XFCN (dmatm3, DMATM3, (m, n, k, np,
+                                     x.data (), y.data (),
+                                     z.fortran_vec ()));
+          retval = z;
+        }
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/eig.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/eig.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -50,13 +50,13 @@
 @seealso{eigs, svd}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin > 2 || nargin == 0)
     print_usage ();
 
+  octave_value_list retval;
+
   octave_value arg_a, arg_b;
 
   octave_idx_type nr_a, nr_b, nc_a, nc_b;
@@ -72,7 +72,7 @@
   else if (arg_is_empty > 0)
     return octave_value_list (2, Matrix ());
 
-  if (!(arg_a.is_single_type () || arg_a.is_double_type ()))
+  if (! arg_a.is_double_type () && ! arg_a.is_single_type ())
     {
       gripe_wrong_type_arg ("eig", arg_a);
       return retval;
@@ -88,7 +88,7 @@
       if (arg_is_empty < 0)
         return retval;
       else if (arg_is_empty > 0)
-        return octave_value_list (2, Matrix ());
+        return ovl (2, Matrix ());
 
       if (!(arg_b.is_single_type () || arg_b.is_double_type ()))
         {
@@ -158,7 +158,6 @@
       else
         {
           // Blame it on Matlab.
-
           FloatComplexDiagMatrix d (result.eigenvalues ());
 
           retval = ovl (result.eigenvectors (), d);
@@ -208,7 +207,6 @@
       else
         {
           // Blame it on Matlab.
-
           ComplexDiagMatrix d (result.eigenvalues ());
 
           retval = ovl (result.eigenvectors (), d);
--- a/libinterp/corefcn/error.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/error.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -911,123 +911,121 @@
 
   const octave_scalar_map err = args(0).scalar_map_value ();
 
-  if (err.contains ("message") && err.contains ("identifier"))
-    {
-      std::string msg = err.contents ("message").string_value ();
-      std::string id = err.contents ("identifier").string_value ();
-      int len = msg.length ();
+  if (! err.contains ("message") || ! err.contains ("identifier"))
+    error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
+
+  std::string msg = err.contents ("message").string_value ();
+  std::string id = err.contents ("identifier").string_value ();
+  int len = msg.length ();
+
+  std::string file;
+  std::string nm;
+  int l = -1;
+  int c = -1;
+
+  octave_map err_stack = initialize_last_error_stack ();
 
-      std::string file;
-      std::string nm;
-      int l = -1;
-      int c = -1;
+  if (err.contains ("stack"))
+    {
+      err_stack = err.contents ("stack").map_value ();
 
-      octave_map err_stack = initialize_last_error_stack ();
+      if (err_stack.numel () > 0)
+        {
+          if (err_stack.contains ("file"))
+            file = err_stack.contents ("file")(0).string_value ();
 
-      if (err.contains ("stack"))
-        {
-          err_stack = err.contents ("stack").map_value ();
+          if (err_stack.contains ("name"))
+            nm = err_stack.contents ("name")(0).string_value ();
+
+          if (err_stack.contains ("line"))
+            l = err_stack.contents ("line")(0).nint_value ();
 
-          if (err_stack.numel () > 0)
-            {
-              if (err_stack.contains ("file"))
-                file = err_stack.contents ("file")(0).string_value ();
-
-              if (err_stack.contains ("name"))
-                nm = err_stack.contents ("name")(0).string_value ();
-
-              if (err_stack.contains ("line"))
-                l = err_stack.contents ("line")(0).nint_value ();
+          if (err_stack.contains ("column"))
+            c = err_stack.contents ("column")(0).nint_value ();
+        }
+    }
 
-              if (err_stack.contains ("column"))
-                c = err_stack.contents ("column")(0).nint_value ();
-            }
+  // Ugh.
+  std::string tmp_msg (msg);
+  if (tmp_msg[len-1] == '\n')
+    {
+      if (len > 1)
+        {
+          tmp_msg.erase (len - 1);
+          rethrow_error (id.c_str (), "%s\n", tmp_msg.c_str ());
         }
+    }
+  else
+    rethrow_error (id.c_str (), "%s", tmp_msg.c_str ());
 
-      // Ugh.
-      std::string tmp_msg (msg);
-      if (tmp_msg[len-1] == '\n')
+  // FIXME: is this the right thing to do for Vlast_error_stack?
+  //        Should it be saved and restored with unwind_protect?
+
+  Vlast_error_stack = err_stack;
+
+  if (err.contains ("stack"))
+    {
+      if (file.empty ())
         {
-          if (len > 1)
+          if (nm.empty ())
             {
-              tmp_msg.erase (len - 1);
-              rethrow_error (id.c_str (), "%s\n", tmp_msg.c_str ());
-            }
-        }
-      else
-        rethrow_error (id.c_str (), "%s", tmp_msg.c_str ());
-
-      // FIXME: is this the right thing to do for Vlast_error_stack?
-      //        Should it be saved and restored with unwind_protect?
-
-      Vlast_error_stack = err_stack;
-
-      if (err.contains ("stack"))
-        {
-          if (file.empty ())
-            {
-              if (nm.empty ())
+              if (l > 0)
                 {
-                  if (l > 0)
-                    {
-                      if (c > 0)
-                        pr_where_1 (std::cerr,
-                                    "error: near line %d, column %d",
-                                    l, c);
-                      else
-                        pr_where_1 (std::cerr, "error: near line %d", l);
-                    }
-                }
-              else
-                {
-                  if (l > 0)
-                    {
-                      if (c > 0)
-                        pr_where_1 (std::cerr,
-                                    "error: called from '%s' near line %d, column %d",
-                                    nm.c_str (), l, c);
-                      else
-                        pr_where_1 (std::cerr,
-                                    "error: called from '%d' near line %d",
-                                    nm.c_str (), l);
-                    }
+                  if (c > 0)
+                    pr_where_1 (std::cerr,
+                                "error: near line %d, column %d",
+                                l, c);
+                  else
+                    pr_where_1 (std::cerr, "error: near line %d", l);
                 }
             }
           else
             {
-              if (nm.empty ())
+              if (l > 0)
                 {
-                  if (l > 0)
-                    {
-                      if (c > 0)
-                        pr_where_1 (std::cerr,
-                                    "error: in file %s near line %d, column %d",
-                                    file.c_str (), l, c);
-                      else
-                        pr_where_1 (std::cerr,
-                                    "error: in file %s near line %d",
-                                    file.c_str (), l);
-                    }
+                  if (c > 0)
+                    pr_where_1 (std::cerr,
+                                "error: called from '%s' near line %d, column %d",
+                                nm.c_str (), l, c);
+                  else
+                    pr_where_1 (std::cerr,
+                                "error: called from '%d' near line %d",
+                                nm.c_str (), l);
                 }
-              else
+            }
+        }
+      else
+        {
+          if (nm.empty ())
+            {
+              if (l > 0)
                 {
-                  if (l > 0)
-                    {
-                      if (c > 0)
-                        pr_where_1 (std::cerr,
-                                    "error: called from '%s' in file %s near line %d, column %d",
-                                    nm.c_str (), file.c_str (), l, c);
-                      else
-                        pr_where_1 (std::cerr,
-                                    "error: called from '%d' in file %s near line %d",
-                                    nm.c_str (), file.c_str (), l);
-                    }
+                  if (c > 0)
+                    pr_where_1 (std::cerr,
+                                "error: in file %s near line %d, column %d",
+                                file.c_str (), l, c);
+                  else
+                    pr_where_1 (std::cerr,
+                                "error: in file %s near line %d",
+                                file.c_str (), l);
+                }
+            }
+          else
+            {
+              if (l > 0)
+                {
+                  if (c > 0)
+                    pr_where_1 (std::cerr,
+                                "error: called from '%s' in file %s near line %d, column %d",
+                                nm.c_str (), file.c_str (), l, c);
+                  else
+                    pr_where_1 (std::cerr,
+                                "error: called from '%d' in file %s near line %d",
+                                nm.c_str (), file.c_str (), l);
                 }
             }
         }
     }
-  else
-    error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
 
   return retval;
 }
@@ -1169,17 +1167,18 @@
 @seealso{warning, lasterror}\n\
 @end deftypefn")
 {
-  octave_value retval;
 
   int nargin = args.length ();
 
+  if (nargin == 0)
+    print_usage ();
+
+  octave_value retval;
+
   octave_value_list nargs = args;
 
   std::string id;
 
-  if (nargin == 0)
-    print_usage ();
-
   bool have_fmt = false;
 
   if (nargin == 1 && args(0).is_map ())
--- a/libinterp/corefcn/fft.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/fft.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -42,13 +42,12 @@
 static octave_value
 do_fft (const octave_value_list &args, const char *fcn, int type)
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
 
+  octave_value retval;
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
   octave_idx_type n_points = -1;
@@ -61,13 +60,10 @@
           double dval = args(1).double_value ();
           if (xisnan (dval))
             error ("%s: number of points (N) cannot be NaN", fcn);
-          else
-            {
-              n_points = NINTbig (dval);
-              if (n_points < 0)
-                error ("%s: number of points (N) must be greater than zero",
-                       fcn);
-            }
+
+          n_points = NINTbig (dval);
+          if (n_points < 0)
+            error ("%s: number of points (N) must be greater than zero", fcn);
         }
     }
 
--- a/libinterp/corefcn/fft2.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/fft2.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -44,13 +44,12 @@
 static octave_value
 do_fft2 (const octave_value_list &args, const char *fcn, int type)
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
 
+  octave_value retval;
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
   octave_idx_type n_rows = -1;
@@ -60,12 +59,10 @@
       double dval = args(1).double_value ();
       if (xisnan (dval))
         error ("%s: number of rows (N) cannot be NaN", fcn);
-      else
-        {
-          n_rows = NINTbig (dval);
-          if (n_rows < 0)
-            error ("%s: number of rows (N) must be greater than zero", fcn);
-        }
+
+      n_rows = NINTbig (dval);
+      if (n_rows < 0)
+        error ("%s: number of rows (N) must be greater than zero", fcn);
     }
 
   octave_idx_type n_cols = -1;
@@ -74,12 +71,10 @@
       double dval = args(2).double_value ();
       if (xisnan (dval))
         error ("%s: number of columns (M) cannot be NaN", fcn);
-      else
-        {
-          n_cols = NINTbig (dval);
-          if (n_cols < 0)
-            error ("%s: number of columns (M) must be greater than zero", fcn);
-        }
+
+      n_cols = NINTbig (dval);
+      if (n_cols < 0)
+        error ("%s: number of columns (M) must be greater than zero", fcn);
     }
 
   for (int i = 0; i < dims.length (); i++)
--- a/libinterp/corefcn/fftn.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/fftn.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -43,13 +43,12 @@
 static octave_value
 do_fftn (const octave_value_list &args, const char *fcn, int type)
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  octave_value retval;
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
 
@@ -66,20 +65,15 @@
 
       if (val.columns () != dims.length () || val.rows () != 1)
         error ("%s: SIZE must be a vector of length dim", fcn);
-      else
+
+      for (int i = 0; i < dims.length (); i++)
         {
-          for (int i = 0; i < dims.length (); i++)
-            {
-              if (xisnan (val(i,0)))
-                error ("%s: SIZE has invalid NaN entries", fcn);
-              else if (NINTbig (val(i,0)) < 0)
-                error ("%s: all dimensions in SIZE must be greater than zero",
-                       fcn);
-              else
-                {
-                  dims(i) = NINTbig(val(i,0));
-                }
-            }
+          if (xisnan (val(i,0)))
+            error ("%s: SIZE has invalid NaN entries", fcn);
+          else if (NINTbig (val(i,0)) < 0)
+            error ("%s: all dimensions in SIZE must be greater than zero", fcn);
+          else
+            dims(i) = NINTbig(val(i,0));
         }
     }
 
--- a/libinterp/corefcn/file-io.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/file-io.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -258,8 +258,6 @@
 @seealso{ferror, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 1)
     print_usage ();
 
@@ -269,7 +267,7 @@
 
   os.clearerr ();
 
-  return retval;
+  return octave_value_list ();
 }
 
 DEFUN (fflush, args, ,
@@ -287,13 +285,12 @@
 @seealso{fopen, fclose}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   if (args.length () != 1)
     print_usage ();
 
+  octave_value retval = -1;
+
   // FIXME: any way to avoid special case for stdout?
-
   int fid = octave_stream_list::get_file_number (args(0));
 
   if (fid == 1)
@@ -332,15 +329,11 @@
 {
   static std::string who = "fgetl";
 
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  retval = ovl (-1, 0);
-
   octave_stream os = octave_stream_list::lookup (args(0), who);
 
   octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
@@ -350,11 +343,9 @@
   std::string tmp = os.getl (len_arg, err, who);
 
   if (! err)
-    {
-      retval = ovl (tmp, tmp.length ());
-    }
-
-  return retval;
+    return ovl (tmp, tmp.length ());
+  else
+    return ovl (-1, 0);
 }
 
 DEFUN (fgets, args, ,
@@ -377,15 +368,11 @@
 {
   static std::string who = "fgets";
 
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  retval = ovl (-1.0, 0.0);
-
   octave_stream os = octave_stream_list::lookup (args(0), who);
 
   octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
@@ -395,11 +382,9 @@
   std::string tmp = os.gets (len_arg, err, who);
 
   if (! err)
-    {
-      retval = ovl (tmp, tmp.length ());
-    }
-
-  return retval;
+    return ovl (tmp, tmp.length ());
+  else
+    return ovl (-1.0, 0.0);
 }
 
 DEFUN (fskipl, args, ,
@@ -423,8 +408,6 @@
 {
   static std::string who = "fskipl";
 
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
@@ -439,9 +422,9 @@
   off_t tmp = os.skipl (count_arg, err, who);
 
   if (! err)
-    retval = tmp;
-
-  return retval;
+    return ovl (tmp);
+  else
+    return octave_value_list ();
 }
 
 
@@ -621,15 +604,13 @@
 @seealso{fclose, fgets, fgetl, fscanf, fread, fputs, fdisp, fprintf, fwrite, fskipl, fseek, frewind, ftell, feof, ferror, fclear, fflush, freport, umask}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
-  retval = ovl (-1.0);
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
 
+  octave_value_list retval = ovl (-1.0);
+
   if (nargin == 1)
     {
       if (args(0).is_string ())
@@ -638,7 +619,6 @@
           // is not the string "all", we assume it is a file to open
           // with MODE = "r".  To open a file called "all", you have
           // to supply more than one argument.
-
           if (nargout < 2 && args(0).string_value () == "all")
             return octave_stream_list::open_file_numbers ();
         }
@@ -663,9 +643,7 @@
   octave_stream os = do_stream_open (args(0), mode, arch, "fopen", fid);
 
   if (os)
-    {
-      retval = ovl (octave_stream_list::insert (os), "");
-    }
+    retval = ovl (octave_stream_list::insert (os), "");
   else
     {
       int error_number = 0;
@@ -721,8 +699,6 @@
 @seealso{fseek, ftell, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 1)
     print_usage ();
 
@@ -733,9 +709,9 @@
   result = os.rewind ();
 
   if (nargout > 0)
-    retval = result;
-
-  return retval;
+    return ovl (result);
+  else
+    return octave_value_list ();
 }
 
 DEFUN (fseek, args, ,
@@ -757,8 +733,6 @@
 @seealso{fskipl, frewind, ftell, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
@@ -766,12 +740,9 @@
 
   octave_stream os = octave_stream_list::lookup (args(0), "fseek");
 
-  octave_value origin_arg = (nargin == 3)
-    ? args(2) : octave_value (-1.0);
+  octave_value origin_arg = (nargin == 3) ? args(2) : octave_value (-1.0);
 
-  retval = os.seek (args(1), origin_arg);
-
-  return retval;
+  return octave_value (os.seek (args(1), origin_arg));
 }
 
 DEFUN (ftell, args, ,
@@ -782,16 +753,12 @@
 @seealso{fseek, frewind, feof, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   if (args.length () != 1)
     print_usage ();
 
   octave_stream os = octave_stream_list::lookup (args(0), "ftell");
 
-  retval = os.tell ();
-
-  return retval;
+  return octave_value (os.tell ());
 }
 
 DEFUN (fprintf, args, nargout,
@@ -815,49 +782,43 @@
 {
   static std::string who = "fprintf";
 
-  octave_value retval;
-
-  int result = -1;
-
   int nargin = args.length ();
 
   if (! (nargin > 1 || (nargin > 0 && args(0).is_string ())))
     print_usage ();
 
+  int result;
+
   octave_stream os;
   int fmt_n = 0;
 
   if (args(0).is_string ())
-    {
-      os = octave_stream_list::lookup (1, who);
-    }
+    os = octave_stream_list::lookup (1, who);
   else
     {
       fmt_n = 1;
       os = octave_stream_list::lookup (args(0), who);
     }
 
-  if (args(fmt_n).is_string ())
-    {
-      octave_value_list tmp_args;
-
-      if (nargin > 1 + fmt_n)
-        {
-          tmp_args.resize (nargin-fmt_n-1, octave_value ());
-
-          for (int i = fmt_n + 1; i < nargin; i++)
-            tmp_args(i-fmt_n-1) = args(i);
-        }
-
-      result = os.printf (args(fmt_n), tmp_args, who);
-    }
-  else
+  if (! args(fmt_n).is_string ())
     error ("%s: format TEMPLATE must be a string", who.c_str ());
 
+  octave_value_list tmp_args;
+
+  if (nargin > 1 + fmt_n)
+    {
+      tmp_args.resize (nargin-fmt_n-1, octave_value ());
+
+      for (int i = fmt_n + 1; i < nargin; i++)
+        tmp_args(i-fmt_n-1) = args(i);
+    }
+
+  result = os.printf (args(fmt_n), tmp_args, who);
+
   if (nargout > 0)
-    retval = result;
-
-  return retval;
+    return octave_value (result);
+  else
+    return octave_value_list ();
 }
 
 DEFUN (printf, args, nargout,
@@ -880,36 +841,32 @@
 {
   static std::string who = "printf";
 
-  octave_value retval;
-
-  int result = -1;
-
   int nargin = args.length ();
 
   if (nargin == 0)
     print_usage ();
 
-  if (args(0).is_string ())
-    {
-      octave_value_list tmp_args;
-
-      if (nargin > 1)
-        {
-          tmp_args.resize (nargin-1, octave_value ());
+  int result;
 
-          for (int i = 1; i < nargin; i++)
-            tmp_args(i-1) = args(i);
-        }
-
-      result = stdout_stream.printf (args(0), tmp_args, who);
-    }
-  else
+  if (! args(0).is_string ())
     error ("%s: format TEMPLATE must be a string", who.c_str ());
 
+  octave_value_list tmp_args;
+
+  if (nargin > 1)
+    {
+      tmp_args.resize (nargin-1, octave_value ());
+
+      for (int i = 1; i < nargin; i++)
+        tmp_args(i-1) = args(i);
+    }
+
+  result = stdout_stream.printf (args(0), tmp_args, who);
+
   if (nargout > 0)
-    retval = result;
-
-  return retval;
+    return ovl (result);
+  else
+    return octave_value_list ();
 }
 
 DEFUN (fputs, args, ,
@@ -1068,43 +1025,39 @@
 {
   static std::string who = "fscanf";
 
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  octave_value_list retval;
+
   if (nargin == 3 && args(2).is_string ())
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (args(1).is_string ())
-        retval = ovl (os.oscanf (args(1), who));
-      else
+      if (! args(1).is_string ())
         error ("%s: format TEMPLATE must be a string", who.c_str ());
+
+      retval = ovl (os.oscanf (args(1), who));
     }
   else
     {
-      retval = ovl (Matrix (), 0.0, "unknown error");
-
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (args(1).is_string ())
-        {
-          octave_idx_type count = 0;
+      if (! args(1).is_string ())
+        error ("%s: format must be a string", who.c_str ());
+
+      octave_idx_type count = 0;
 
-          Array<double> size = (nargin == 3)
-            ? args(2).vector_value ()
-            : Array<double> (dim_vector (1, 1),
-                             lo_ieee_inf_value ());
+      Array<double> size = (nargin == 3)
+        ? args(2).vector_value ()
+        : Array<double> (dim_vector (1, 1),
+                         lo_ieee_inf_value ());
 
-          octave_value tmp = os.scanf (args(1), size, count, who);
+      octave_value tmp = os.scanf (args(1), size, count, who);
 
-          retval = ovl (tmp, count, os.error ());
-        }
-      else
-        error ("%s: format must be a string", who.c_str ());
+      retval = ovl (tmp, count, os.error ());
     }
 
   return retval;
@@ -1142,65 +1095,54 @@
 {
   static std::string who = "sscanf";
 
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  octave_value_list retval;
+
   if (nargin == 3 && args(2).is_string ())
     {
       std::string data = get_sscanf_data (args(0));
 
       octave_stream os = octave_istrstream::create (data);
 
-      if (os.is_valid ())
-        {
-          if (args(1).is_string ())
-            retval = ovl (os.oscanf (args(1), who));
-          else
-            error ("%s: format TEMPLATE must be a string", who.c_str ());
-        }
-      else
+      if (! os.is_valid ())
         error ("%s: unable to create temporary input buffer", who.c_str ());
+
+      if (! args(1).is_string ())
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
+
+      retval = ovl (os.oscanf (args(1), who));
     }
   else
     {
-      retval = ovl (Matrix (), 0.0, "unknown error", -1.0);
-
       std::string data = get_sscanf_data (args(0));
 
       octave_stream os = octave_istrstream::create (data);
 
-      if (os.is_valid ())
-        {
-          if (args(1).is_string ())
-            {
-              octave_idx_type count = 0;
+      if (! os.is_valid ())
+        error ("%s: unable to create temporary input buffer", who.c_str ());
 
-              Array<double> size = (nargin == 3)
-                ? args(2).vector_value ()
-                : Array<double> (dim_vector (1, 1),
-                                 lo_ieee_inf_value ());
+      if (! args(1).is_string ())
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
 
-              octave_value tmp = os.scanf (args(1), size, count, who);
+      octave_idx_type count = 0;
 
-              // FIXME: is this the right thing to do?
-              // Extract error message first, because getting
-              // position will clear it.
-              std::string errmsg = os.error ();
+      Array<double> size = (nargin == 3) ? args(2).vector_value ()
+                                         : Array<double> (dim_vector (1, 1),
+                                                          lo_ieee_inf_value ());
+
+      octave_value tmp = os.scanf (args(1), size, count, who);
 
-              retval = ovl (tmp, count, errmsg,
-                            (os.eof () ? data.length () : os.tell ()) + 1);
-            }
-          else
-            error ("%s: format TEMPLATE must be a string",
-                   who.c_str ());
-        }
-      else
-        error ("%s: unable to create temporary input buffer",
-               who.c_str  ());
+      // FIXME: is this the right thing to do?
+      // Extract error message first, because getting
+      // position will clear it.
+      std::string errmsg = os.error ();
+
+      retval = ovl (tmp, count, errmsg,
+                    (os.eof () ? data.length () : os.tell ()) + 1);
     }
 
   return retval;
@@ -1443,15 +1385,11 @@
 @seealso{fwrite, fgets, fgetl, fscanf, fopen}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 5)
     print_usage ();
 
-  retval = ovl (Matrix (), -1.0);
-
   octave_stream os = octave_stream_list::lookup (args(0), "fread");
 
   octave_value size = lo_ieee_inf_value ();
@@ -1482,9 +1420,7 @@
 
   octave_value tmp = do_fread (os, size, prec, skip, arch, count);
 
-  retval = ovl (tmp, count);
-
-  return retval;
+  return ovl (tmp, count);
 }
 
 static int
@@ -1620,8 +1556,6 @@
 @seealso{fclear, fopen}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
@@ -1642,9 +1576,7 @@
 
   std::string error_message = os.error (clear, error_number);
 
-  retval = ovl (error_message, error_number);
-
-  return retval;
+  return ovl (error_message, error_number);
 }
 
 DEFUNX ("popen", Fpopen, args, ,
@@ -1685,14 +1617,14 @@
 @seealso{popen2}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   if (args.length () != 2)
     print_usage ();
 
   std::string name = args(0).xstring_value ("popen: COMMAND must be a string");
   std::string mode = args(1).xstring_value ("popen: MODE must be a string");
 
+  octave_value retval;
+
   if (mode == "r")
     {
       octave_stream ips = octave_iprocstream::create (name);
@@ -1746,8 +1678,6 @@
 @seealso{mkstemp, tempdir, P_tmpdir, tmpfile}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin > 2)
@@ -1829,12 +1759,10 @@
 @seealso{tempname, mkstemp, tempdir, P_tmpdir}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 0)
     print_usage ();
 
-  retval = ovl (-1, std::string ());
+  octave_value_list retval;
 
   FILE *fid = gnulib::tmpfile ();
 
@@ -1846,11 +1774,10 @@
 
       octave_stream s = octave_stdiostream::create (nm, fid, md);
 
-      if (s)
-        retval = ovl (octave_stream_list::insert (s));
-      else
+      if (! s)
         error ("tmpfile: failed to create octave_stdiostream object");
 
+      retval = ovl (octave_stream_list::insert (s), "");
     }
   else
     {
@@ -1984,31 +1911,22 @@
 @seealso{fopen, mkdir, mkfifo}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
-  int status = 0;
-
   if (args.length () != 1)
     print_usage ();
 
   int mask = args(0).xint_value ("umask: MASK must be an integer");
 
   if (mask < 0)
-    {
-      status = -1;
-      error ("umask: MASK must be a positive integer value");
-    }
-  else
-    {
-      int oct_mask = convert (mask, 8, 10);
+    error ("umask: MASK must be a positive integer value");
 
-      status = convert (octave_umask (oct_mask), 10, 8);
-    }
+  int oct_mask = convert (mask, 8, 10);
+
+  int status = convert (octave_umask (oct_mask), 10, 8);
 
   if (status >= 0)
-    retval = ovl (status);
-
-  return retval;
+    return ovl (status);
+  else
+    return octave_value_list ();
 }
 
 static octave_value
--- a/libinterp/octave-value/ov-type-conv.h	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/octave-value/ov-type-conv.h	Wed Dec 16 15:00:31 2015 -0800
@@ -76,11 +76,11 @@
 
 #define OCTAVE_TYPE_CONV_BODY3(NAME, MATRIX_RESULT_T, SCALAR_RESULT_T) \
  \
-  octave_value retval; \
- \
   if (args.length () != 1) \
     print_usage (); \
  \
+  octave_value retval; \
+ \
   const octave_value arg = args(0); \
  \
   int t_result = MATRIX_RESULT_T::static_type_id (); \
@@ -97,7 +97,7 @@
       gripe_invalid_conversion (arg_tname, result_tname); \
     } \
  \
-  return retval
+  return retval;
 
 #define OCTAVE_TYPE_CONV_BODY(NAME) \
   OCTAVE_TYPE_CONV_BODY3 (NAME, octave_ ## NAME ## _matrix, \