changeset 20813:7349de0bf744

maint: merge away accidental head
author Torsten <ttl@justmail.de>
date Sun, 06 Dec 2015 09:14:55 +0100
parents d9ca869ca124 (diff) ed770c16a3e8 (current diff)
children 2da4058d65c7
files
diffstat 117 files changed, 7723 insertions(+), 8778 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/mk-opts.pl	Fri Dec 04 22:05:07 2015 +0100
+++ b/build-aux/mk-opts.pl	Sun Dec 06 09:14:55 2015 +0100
@@ -932,11 +932,14 @@
 
   int nargin = args.length ();
 
+  if (nargin > 2)
+    print_usage ();
+
   if (nargin == 0)
     {
       print_$CLASS_NAME (octave_stdout);
     }
-  else if (nargin == 1 || nargin == 2)
+  else
     {
       std::string keyword = args(0).xstring_value ("$OPT_FCN_NAME: expecting keyword as first argument");
 
@@ -945,8 +948,6 @@
       else
         set_$CLASS_NAME (keyword, args(1));
     }
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/__contourc__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/__contourc__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -44,6 +44,7 @@
 #include "error.h"
 #include "oct-obj.h"
 
+// FIXME: this looks like trouble...
 static Matrix this_contour;
 static Matrix contourc;
 static int elem;
@@ -303,28 +304,22 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 4)
-    {
-      RowVector X = args(0).row_vector_value ();
-      RowVector Y = args(1).row_vector_value ();
-      Matrix Z = args(2).matrix_value ();
-      RowVector L = args(3).row_vector_value ();
-
-      contourc.resize (2, 0);
-
-      for (int i = 0; i < L.numel (); i++)
-        cntr (X, Y, Z, L (i));
-
-      end_contour ();
-
-      retval = contourc;
-    }
-  else
+  if (args.length () != 4)
     print_usage ();
 
-  return retval;
+  RowVector X = args(0).row_vector_value ();
+  RowVector Y = args(1).row_vector_value ();
+  Matrix Z = args(2).matrix_value ();
+  RowVector L = args(3).row_vector_value ();
+
+  contourc.resize (2, 0);
+
+  for (int i = 0; i < L.numel (); i++)
+    cntr (X, Y, Z, L (i));
+
+  end_contour ();
+
+  return octave_value (contourc);
 }
 
 /*
--- a/libinterp/corefcn/__dispatch__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/__dispatch__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -46,61 +46,59 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0 && nargin < 4)
-    {
-      std::string f, r, t;
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
 
-      f = args(0).xstring_value ("__dispatch__: first argument must be a function name");
+  std::string f, r, t;
 
-      if (nargin > 1)
-        r = args(1).xstring_value ("__dispatch__: second argument must be a function name");
+  f = args(0).xstring_value ("__dispatch__: first argument must be a function name");
 
-      if (nargin > 2)
-        t = args(2).xstring_value ("__dispatch__: third argument must be a type name");
+  if (nargin > 1)
+    r = args(1).xstring_value ("__dispatch__: second argument must be a function name");
 
-      if (nargin == 1)
+  if (nargin > 2)
+    t = args(2).xstring_value ("__dispatch__: third argument must be a type name");
+
+  if (nargin == 1)
+    {
+      if (nargout > 0)
         {
-          if (nargout > 0)
-            {
-              symbol_table::fcn_info::dispatch_map_type dm
-                = symbol_table::get_dispatch (f);
-
-              size_t len = dm.size ();
-
-              Cell type_field (len, 1);
-              Cell name_field (len, 1);
+          symbol_table::fcn_info::dispatch_map_type dm
+            = symbol_table::get_dispatch (f);
 
-              symbol_table::fcn_info::dispatch_map_type::const_iterator p
-                = dm.begin ();
+          size_t len = dm.size ();
 
-              for (size_t i = 0; i < len; i++)
-                {
-                  type_field(i) = p->first;
-                  name_field(i) = p->second;
+          Cell type_field (len, 1);
+          Cell name_field (len, 1);
 
-                  p++;
-                }
-
-              octave_scalar_map m;
+          symbol_table::fcn_info::dispatch_map_type::const_iterator p
+            = dm.begin ();
 
-              m.assign ("type", type_field);
-              m.assign ("name", name_field);
+          for (size_t i = 0; i < len; i++)
+            {
+              type_field(i) = p->first;
+              name_field(i) = p->second;
 
-              retval = m;
+              p++;
             }
-          else
-            symbol_table::print_dispatch (octave_stdout, f);
-        }
-      else if (nargin == 2)
-        {
-          t = r;
-          symbol_table::clear_dispatch (f, t);
+
+          octave_scalar_map m;
+
+          m.assign ("type", type_field);
+          m.assign ("name", name_field);
+
+          retval = m;
         }
       else
-        symbol_table::add_dispatch (f, t, r);
+        symbol_table::print_dispatch (octave_stdout, f);
+    }
+  else if (nargin == 2)
+    {
+      t = r;
+      symbol_table::clear_dispatch (f, t);
     }
   else
-    print_usage ();
+    symbol_table::add_dispatch (f, t, r);
 
   return retval;
 }
--- a/libinterp/corefcn/__dsearchn__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/__dsearchn__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -44,10 +44,7 @@
   octave_value_list retval;
 
   if (nargin != 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   Matrix x = args(0).matrix_value ().transpose ();
   Matrix xi = args(1).matrix_value ().transpose ();
--- a/libinterp/corefcn/__ichol__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/__ichol__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -202,10 +202,7 @@
   std::string michol = "off";
 
   if (nargout > 1 || nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (nargin == 2)
     michol = args(1).string_value ();
@@ -456,10 +453,7 @@
   double droptol = 0;
 
   if (nargout > 1 || nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Don't repeat input validation of arguments done in ichol.m
 
--- a/libinterp/corefcn/__ilu__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/__ilu__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -140,10 +140,7 @@
   std::string milu;
 
   if (nargout > 2 || nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // In ILU0 algorithm the zero-pattern of the input matrix is preserved so
   // it's structure does not change during the algorithm.  The same input
@@ -480,10 +477,7 @@
   double droptol = 0;
 
   if (nargout != 2 || nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Don't repeat input validation of arguments done in ilu.m
   if (nargin >= 2)
@@ -954,14 +948,12 @@
 
   int nargin = args.length ();
   std::string milu = "";
-  double droptol = 0, thresh = 1;
+  double droptol = 0;
+  double thresh = 1;
   double udiag = 0;
 
   if (nargout < 2 || nargout > 3 || nargin < 1 || nargin > 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Don't repeat input validation of arguments done in ilu.m
   if (nargin >= 2)
--- a/libinterp/corefcn/__lin_interpn__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/__lin_interpn__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -277,11 +277,8 @@
 
   int nargin = args.length ();
 
-  if (nargin < 2 ||  nargin % 2 == 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin < 2 || nargin % 2 == 0)
+    print_usage ();
 
   // dimension of the problem
   int n = (nargin-1)/2;
--- a/libinterp/corefcn/__qp__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/__qp__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -493,34 +493,32 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 8)
-    {
-      const ColumnVector x0  (args(0) . vector_value ());
-      const Matrix H         (args(1) . matrix_value ());
-      const ColumnVector q   (args(2) . vector_value ());
-      const Matrix Aeq       (args(3) . matrix_value ());
-      const ColumnVector beq (args(4) . vector_value ());
-      const Matrix Ain       (args(5) . matrix_value ());
-      const ColumnVector bin (args(6) . vector_value ());
-      const int maxit        (args(7) . int_value ());
+  if (args.length () != 8)
+    print_usage ();
 
-      int iter = 0;
+  const ColumnVector x0  (args(0) . vector_value ());
+  const Matrix H         (args(1) . matrix_value ());
+  const ColumnVector q   (args(2) . vector_value ());
+  const Matrix Aeq       (args(3) . matrix_value ());
+  const ColumnVector beq (args(4) . vector_value ());
+  const Matrix Ain       (args(5) . matrix_value ());
+  const ColumnVector bin (args(6) . vector_value ());
+  const int maxit        (args(7) . int_value ());
 
-      // Copying the initial guess in the working variable
-      ColumnVector x = x0;
+  int iter = 0;
 
-      // Reordering the Lagrange multipliers
-      ColumnVector lambda;
-
-      int info = qp (H, q, Aeq, beq, Ain, bin, maxit, x, lambda, iter);
+  // Copying the initial guess in the working variable
+  ColumnVector x = x0;
 
-      retval(3) = iter;
-      retval(2) = info;
-      retval(1) = lambda;
-      retval(0) = x;
-    }
-  else
-    print_usage ();
+  // Reordering the Lagrange multipliers
+  ColumnVector lambda;
+
+  int info = qp (H, q, Aeq, beq, Ain, bin, maxit, x, lambda, iter);
+
+  retval(3) = iter;
+  retval(2) = info;
+  retval(1) = lambda;
+  retval(0) = x;
 
   return retval;
 }
--- a/libinterp/corefcn/balance.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/balance.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -96,10 +96,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3 || nargout < 0 || nargout > 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // determine if it's AEP or GEP
   bool AEPcase = nargin == 1 || args(1).is_string ();
--- a/libinterp/corefcn/besselj.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/besselj.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -85,53 +85,113 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  bool scaled = false;
+  if (nargin == 3)
     {
-      bool scaled = false;
-      if (nargin == 3)
+      octave_value opt_arg = args(2);
+      bool rpt_error = false;
+
+      if (! opt_arg.is_scalar_type ())
+        rpt_error = true;
+      else if (opt_arg.is_numeric_type ())
         {
-          octave_value opt_arg = args(2);
-          bool rpt_error = false;
+          double opt_val = opt_arg.double_value ();
+          if (opt_val != 0.0 && opt_val != 1.0)
+            rpt_error = true;
+          scaled = (opt_val == 1.0);
+        }
+      else if (opt_arg.is_bool_type ())
+        scaled = opt_arg.bool_value ();
 
-          if (! opt_arg.is_scalar_type ())
-            rpt_error = true;
-          else if (opt_arg.is_numeric_type ())
+      if (rpt_error)
+        {
+          error ("%s: OPT must be 0 (or false) or 1 (or true)", fn);
+          return retval;
+        }
+    }
+
+  octave_value alpha_arg = args(0);
+  octave_value x_arg = args(1);
+
+  if (alpha_arg.is_single_type () || x_arg.is_single_type ())
+    {
+      if (alpha_arg.is_scalar_type ())
+        {
+          float alpha = args(0).xfloat_value ("%s: ALPHA must be a scalar or matrix", fn);
+
+          if (x_arg.is_scalar_type ())
             {
-              double opt_val = opt_arg.double_value ();
-              if (opt_val != 0.0 && opt_val != 1.0)
-                rpt_error = true;
-              scaled = (opt_val == 1.0);
+              FloatComplex x = x_arg.xfloat_complex_value ("%s: X must be a scalar or matrix", fn);
+
+              octave_idx_type ierr;
+              octave_value result;
+
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = static_cast<float> (ierr);
+
+              retval(0) = result;
             }
-          else if (opt_arg.is_bool_type ())
-            scaled = opt_arg.bool_value ();
+          else
+            {
+              FloatComplexNDArray x
+                = x_arg.xfloat_complex_array_value ("%s: X must be a scalar or matrix", fn);
 
-          if (rpt_error)
-            {
-              error ("%s: OPT must be 0 (or false) or 1 (or true)", fn);
-              return retval;
+              Array<octave_idx_type> ierr;
+              octave_value result;
+
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
+
+              retval(0) = result;
             }
         }
+      else
+        {
+          dim_vector dv0 = args(0).dims ();
+          dim_vector dv1 = args(1).dims ();
 
-      octave_value alpha_arg = args(0);
-      octave_value x_arg = args(1);
+          bool args0_is_row_vector = (dv0(1) == dv0.numel ());
+          bool args1_is_col_vector = (dv1(0) == dv1.numel ());
+
+          if (args0_is_row_vector && args1_is_col_vector)
+            {
+              FloatRowVector ralpha = args(0).xfloat_row_vector_value ("%s: ALPHA must be a scalar or matrix", fn);
 
-      if (alpha_arg.is_single_type () || x_arg.is_single_type ())
-        {
-          if (alpha_arg.is_scalar_type ())
+              FloatComplexColumnVector cx =
+                x_arg.xfloat_complex_column_vector_value ("%s: X must be a scalar or matrix", fn);
+
+              Array<octave_idx_type> ierr;
+              octave_value result;
+
+              DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
+
+              retval(0) = result;
+            }
+          else
             {
-              float alpha = args(0).xfloat_value ("%s: ALPHA must be a scalar or matrix", fn);
+              FloatNDArray alpha = args(0).xfloat_array_value ("%s: ALPHA must be a scalar or matrix", fn);
 
               if (x_arg.is_scalar_type ())
                 {
                   FloatComplex x = x_arg.xfloat_complex_value ("%s: X must be a scalar or matrix", fn);
 
-                  octave_idx_type ierr;
+                  Array<octave_idx_type> ierr;
                   octave_value result;
 
                   DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
                   if (nargout > 1)
-                    retval(1) = static_cast<float> (ierr);
+                    retval(1) = NDArray (ierr);
 
                   retval(0) = result;
                 }
@@ -151,84 +211,83 @@
                   retval(0) = result;
                 }
             }
+        }
+    }
+  else
+    {
+      if (alpha_arg.is_scalar_type ())
+        {
+          double alpha = args(0).xdouble_value ("%s: ALPHA must be a scalar or matrix", fn);
+
+          if (x_arg.is_scalar_type ())
+            {
+              Complex x = x_arg.xcomplex_value ("%s: X must be a scalar or matrix", fn);
+
+              octave_idx_type ierr;
+              octave_value result;
+
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = static_cast<double> (ierr);
+
+              retval(0) = result;
+            }
           else
             {
-              dim_vector dv0 = args(0).dims ();
-              dim_vector dv1 = args(1).dims ();
-
-              bool args0_is_row_vector = (dv0(1) == dv0.numel ());
-              bool args1_is_col_vector = (dv1(0) == dv1.numel ());
-
-              if (args0_is_row_vector && args1_is_col_vector)
-                {
-                  FloatRowVector ralpha = args(0).xfloat_row_vector_value ("%s: ALPHA must be a scalar or matrix", fn);
-
-                  FloatComplexColumnVector cx =
-                    x_arg.xfloat_complex_column_vector_value ("%s: X must be a scalar or matrix", fn);
+              ComplexNDArray x = x_arg.xcomplex_array_value ("%s: X must be a scalar or matrix", fn);
 
-                  Array<octave_idx_type> ierr;
-                  octave_value result;
-
-                  DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
-
-                  if (nargout > 1)
-                    retval(1) = NDArray (ierr);
-
-                  retval(0) = result;
-                }
-              else
-                {
-                  FloatNDArray alpha = args(0).xfloat_array_value ("%s: ALPHA must be a scalar or matrix", fn);
+              Array<octave_idx_type> ierr;
+              octave_value result;
 
-                  if (x_arg.is_scalar_type ())
-                    {
-                      FloatComplex x = x_arg.xfloat_complex_value ("%s: X must be a scalar or matrix", fn);
-
-                      Array<octave_idx_type> ierr;
-                      octave_value result;
-
-                      DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                      if (nargout > 1)
-                        retval(1) = NDArray (ierr);
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
-                      retval(0) = result;
-                    }
-                  else
-                    {
-                      FloatComplexNDArray x
-                        = x_arg.xfloat_complex_array_value ("%s: X must be a scalar or matrix", fn);
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
 
-                      Array<octave_idx_type> ierr;
-                      octave_value result;
-
-                      DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                      if (nargout > 1)
-                        retval(1) = NDArray (ierr);
-
-                      retval(0) = result;
-                    }
-                }
+              retval(0) = result;
             }
         }
       else
         {
-          if (alpha_arg.is_scalar_type ())
+          dim_vector dv0 = args(0).dims ();
+          dim_vector dv1 = args(1).dims ();
+
+          bool args0_is_row_vector = (dv0(1) == dv0.numel ());
+          bool args1_is_col_vector = (dv1(0) == dv1.numel ());
+
+          if (args0_is_row_vector && args1_is_col_vector)
             {
-              double alpha = args(0).xdouble_value ("%s: ALPHA must be a scalar or matrix", fn);
+              RowVector ralpha = args(0).xrow_vector_value ("%s: ALPHA must be a scalar or matrix", fn);
+
+              ComplexColumnVector cx =
+                x_arg.xcomplex_column_vector_value ("%s: X must be a scalar or matrix", fn);
+
+              Array<octave_idx_type> ierr;
+              octave_value result;
+
+              DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
+
+              retval(0) = result;
+            }
+          else
+            {
+              NDArray alpha = args(0).xarray_value ("%s: ALPHA must be a scalar or matrix", fn);
 
               if (x_arg.is_scalar_type ())
                 {
                   Complex x = x_arg.xcomplex_value ("%s: X must be a scalar or matrix", fn);
 
-                  octave_idx_type ierr;
+                  Array<octave_idx_type> ierr;
                   octave_value result;
 
                   DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
                   if (nargout > 1)
-                    retval(1) = static_cast<double> (ierr);
+                    retval(1) = NDArray (ierr);
 
                   retval(0) = result;
                 }
@@ -247,69 +306,8 @@
                   retval(0) = result;
                 }
             }
-          else
-            {
-              dim_vector dv0 = args(0).dims ();
-              dim_vector dv1 = args(1).dims ();
-
-              bool args0_is_row_vector = (dv0(1) == dv0.numel ());
-              bool args1_is_col_vector = (dv1(0) == dv1.numel ());
-
-              if (args0_is_row_vector && args1_is_col_vector)
-                {
-                  RowVector ralpha = args(0).xrow_vector_value ("%s: ALPHA must be a scalar or matrix", fn);
-
-                  ComplexColumnVector cx =
-                    x_arg.xcomplex_column_vector_value ("%s: X must be a scalar or matrix", fn);
-
-                  Array<octave_idx_type> ierr;
-                  octave_value result;
-
-                  DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
-
-                  if (nargout > 1)
-                    retval(1) = NDArray (ierr);
-
-                  retval(0) = result;
-                }
-              else
-                {
-                  NDArray alpha = args(0).xarray_value ("%s: ALPHA must be a scalar or matrix", fn);
-
-                  if (x_arg.is_scalar_type ())
-                    {
-                      Complex x = x_arg.xcomplex_value ("%s: X must be a scalar or matrix", fn);
-
-                      Array<octave_idx_type> ierr;
-                      octave_value result;
-
-                      DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                      if (nargout > 1)
-                        retval(1) = NDArray (ierr);
-
-                      retval(0) = result;
-                    }
-                  else
-                    {
-                      ComplexNDArray x = x_arg.xcomplex_array_value ("%s: X must be a scalar or matrix", fn);
-
-                      Array<octave_idx_type> ierr;
-                      octave_value result;
-
-                      DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                      if (nargout > 1)
-                        retval(1) = NDArray (ierr);
-
-                      retval(0) = result;
-                    }
-                }
-            }
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -425,11 +423,14 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+
   if (nargin == 2)
     {
       retval = do_bessel (BESSEL_H1, "besselh", args, nargout);
     }
-  else if (nargin == 3 || nargin == 4)
+  else
     {
       octave_idx_type kind = args(1).xint_value ("besselh: invalid value of K");
 
@@ -448,8 +449,6 @@
       else
         error ("besselh: K must be 1 or 2");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -505,59 +504,57 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0 && nargin < 4)
-    {
-      bool scale = (nargin == 3);
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
 
-      int kind = 0;
+  bool scale = (nargin == 3);
 
-      if (nargin > 1)
-        {
-          kind = args(0).xint_value ("airy: K must be an integer value");
+  int kind = 0;
 
-          if (kind < 0 || kind > 3)
-            error ("airy: K must be 0, 1, 2, or 3");
-        }
-
-      int idx = nargin == 1 ? 0 : 1;
+  if (nargin > 1)
+    {
+      kind = args(0).xint_value ("airy: K must be an integer value");
 
-      if (args(idx).is_single_type ())
-        {
-          FloatComplexNDArray z = args(idx).xfloat_complex_array_value ("airy: Z must be a complex matrix");
+      if (kind < 0 || kind > 3)
+        error ("airy: K must be 0, 1, 2, or 3");
+    }
 
-          Array<octave_idx_type> ierr;
-          octave_value result;
+  int idx = nargin == 1 ? 0 : 1;
 
-          if (kind > 1)
-            result = biry (z, kind == 3, scale, ierr);
-          else
-            result = airy (z, kind == 1, scale, ierr);
+  if (args(idx).is_single_type ())
+    {
+      FloatComplexNDArray z = args(idx).xfloat_complex_array_value ("airy: Z must be a complex matrix");
 
-          if (nargout > 1)
-            retval(1) = NDArray (ierr);
-
-          retval(0) = result;
-        }
-      else
-        {
-          ComplexNDArray z = args(idx).xcomplex_array_value ("airy: Z must be a complex matrix");
+      Array<octave_idx_type> ierr;
+      octave_value result;
 
-          Array<octave_idx_type> ierr;
-          octave_value result;
+      if (kind > 1)
+        result = biry (z, kind == 3, scale, ierr);
+      else
+        result = airy (z, kind == 1, scale, ierr);
 
-          if (kind > 1)
-            result = biry (z, kind == 3, scale, ierr);
-          else
-            result = airy (z, kind == 1, scale, ierr);
+      if (nargout > 1)
+        retval(1) = NDArray (ierr);
 
-          if (nargout > 1)
-            retval(1) = NDArray (ierr);
-
-          retval(0) = result;
-        }
+      retval(0) = result;
     }
   else
-    print_usage ();
+    {
+      ComplexNDArray z = args(idx).xcomplex_array_value ("airy: Z must be a complex matrix");
+
+      Array<octave_idx_type> ierr;
+      octave_value result;
+
+      if (kind > 1)
+        result = biry (z, kind == 3, scale, ierr);
+      else
+        result = airy (z, kind == 1, scale, ierr);
+
+      if (nargout > 1)
+        retval(1) = NDArray (ierr);
+
+      retval(0) = result;
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/betainc.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/betainc.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -69,179 +69,177 @@
 
   int nargin = args.length ();
 
-  if (nargin == 3)
-    {
-      octave_value x_arg = args(0);
-      octave_value a_arg = args(1);
-      octave_value b_arg = args(2);
+  if (nargin != 3)
+    print_usage ();
 
-      // FIXME: Can we make a template version of the duplicated code below
-      if (x_arg.is_single_type () || a_arg.is_single_type ()
-          || b_arg.is_single_type ())
-        {
-          if (x_arg.is_scalar_type ())
-            {
-              float x = x_arg.float_value ();
+  octave_value x_arg = args(0);
+  octave_value a_arg = args(1);
+  octave_value b_arg = args(2);
 
-              if (a_arg.is_scalar_type ())
-                {
-                  float a = a_arg.float_value ();
-
-                  if (b_arg.is_scalar_type ())
-                    {
-                      float b = b_arg.float_value ();
+  // FIXME: Can we make a template version of the duplicated code below
+  if (x_arg.is_single_type () || a_arg.is_single_type ()
+      || b_arg.is_single_type ())
+    {
+      if (x_arg.is_scalar_type ())
+        {
+          float x = x_arg.float_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<float> b = b_arg.float_array_value ();
+          if (a_arg.is_scalar_type ())
+            {
+              float a = a_arg.float_value ();
 
-                      retval = betainc (x, a, b);
-                    }
+              if (b_arg.is_scalar_type ())
+                {
+                  float b = b_arg.float_value ();
+
+                  retval = betainc (x, a, b);
                 }
               else
                 {
-                  Array<float> a = a_arg.float_array_value ();
-
-                  if (b_arg.is_scalar_type ())
-                    {
-                      float b = b_arg.float_value ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<float> b = b_arg.float_array_value ();
-
-                      retval = betainc (x, a, b);
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
           else
             {
-              Array<float> x = x_arg.float_array_value ();
-
-              if (a_arg.is_scalar_type ())
-                {
-                  float a = a_arg.float_value ();
+              Array<float> a = a_arg.float_array_value ();
 
-                  if (b_arg.is_scalar_type ())
-                    {
-                      float b = b_arg.float_value ();
+              if (b_arg.is_scalar_type ())
+                {
+                  float b = b_arg.float_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<float> b = b_arg.float_array_value ();
-
-                      retval = betainc (x, a, b);
-                    }
+                  retval = betainc (x, a, b);
                 }
               else
                 {
-                  Array<float> a = a_arg.float_array_value ();
-
-                  if (b_arg.is_scalar_type ())
-                    {
-                      float b = b_arg.float_value ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<float> b = b_arg.float_array_value ();
-
-                      retval = betainc (x, a, b);
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
         }
       else
         {
-          if (x_arg.is_scalar_type ())
-            {
-              double x = x_arg.double_value ();
+          Array<float> x = x_arg.float_array_value ();
 
-              if (a_arg.is_scalar_type ())
-                {
-                  double a = a_arg.double_value ();
+          if (a_arg.is_scalar_type ())
+            {
+              float a = a_arg.float_value ();
 
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+              if (b_arg.is_scalar_type ())
+                {
+                  float b = b_arg.float_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
-
-                      retval = betainc (x, a, b);
-                    }
+                  retval = betainc (x, a, b);
                 }
               else
                 {
-                  Array<double> a = a_arg.array_value ();
-
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
-
-                      retval = betainc (x, a, b);
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
           else
             {
-              Array<double> x = x_arg.array_value ();
-
-              if (a_arg.is_scalar_type ())
-                {
-                  double a = a_arg.double_value ();
+              Array<float> a = a_arg.float_array_value ();
 
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+              if (b_arg.is_scalar_type ())
+                {
+                  float b = b_arg.float_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
-
-                      retval = betainc (x, a, b);
-                    }
+                  retval = betainc (x, a, b);
                 }
               else
                 {
-                  Array<double> a = a_arg.array_value ();
-
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                      retval = betainc (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
-
-                      retval = betainc (x, a, b);
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
         }
     }
   else
-    print_usage ();
+    {
+      if (x_arg.is_scalar_type ())
+        {
+          double x = x_arg.double_value ();
+
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+          else
+            {
+              Array<double> a = a_arg.array_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+        }
+      else
+        {
+          Array<double> x = x_arg.array_value ();
+
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+          else
+            {
+              Array<double> a = a_arg.array_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+        }
+    }
 
   return retval;
 }
@@ -306,103 +304,102 @@
 
   int nargin = args.length ();
 
-  if (nargin == 3)
-    {
-      octave_value x_arg = args(0);
-      octave_value a_arg = args(1);
-      octave_value b_arg = args(2);
+  if (nargin != 3)
+    print_usage ();
+
+  octave_value x_arg = args(0);
+  octave_value a_arg = args(1);
+  octave_value b_arg = args(2);
 
-      if (x_arg.is_scalar_type ())
+  if (x_arg.is_scalar_type ())
+    {
+      double x = x_arg.double_value ();
+
+      if (a_arg.is_scalar_type ())
         {
-          double x = x_arg.double_value ();
+          double a = a_arg.double_value ();
 
-          if (a_arg.is_scalar_type ())
+          if (b_arg.is_scalar_type ())
             {
-              double a = a_arg.double_value ();
-
-              if (b_arg.is_scalar_type ())
-                {
-                  double b = b_arg.double_value ();
+              double b = b_arg.double_value ();
 
-                  retval = betaincinv (x, a, b);
-                }
-              else
-                {
-                  Array<double> b = b_arg.array_value ();
-
-                  retval = betaincinv (x, a, b);
-                }
+              retval = betaincinv (x, a, b);
             }
           else
             {
-              Array<double> a = a_arg.array_value ();
-
-              if (b_arg.is_scalar_type ())
-                {
-                  double b = b_arg.double_value ();
+              Array<double> b = b_arg.array_value ();
 
-                  retval = betaincinv (x, a, b);
-                }
-              else
-                {
-                  Array<double> b = b_arg.array_value ();
-
-                  retval = betaincinv (x, a, b);
-                }
+              retval = betaincinv (x, a, b);
             }
         }
       else
         {
-          Array<double> x = x_arg.array_value ();
+          Array<double> a = a_arg.array_value ();
+
+          if (b_arg.is_scalar_type ())
+            {
+              double b = b_arg.double_value ();
 
-          if (a_arg.is_scalar_type ())
+              retval = betaincinv (x, a, b);
+            }
+          else
             {
-              double a = a_arg.double_value ();
+              Array<double> b = b_arg.array_value ();
 
-              if (b_arg.is_scalar_type ())
-                {
-                  double b = b_arg.double_value ();
+              retval = betaincinv (x, a, b);
+            }
+        }
+    }
+  else
+    {
+      Array<double> x = x_arg.array_value ();
 
-                  retval = betaincinv (x, a, b);
-                }
-              else
-                {
-                  Array<double> b = b_arg.array_value ();
+      if (a_arg.is_scalar_type ())
+        {
+          double a = a_arg.double_value ();
 
-                  retval = betaincinv (x, a, b);
-                }
+          if (b_arg.is_scalar_type ())
+            {
+              double b = b_arg.double_value ();
+
+              retval = betaincinv (x, a, b);
             }
           else
             {
-              Array<double> a = a_arg.array_value ();
-
-              if (b_arg.is_scalar_type ())
-                {
-                  double b = b_arg.double_value ();
+              Array<double> b = b_arg.array_value ();
 
-                  retval = betaincinv (x, a, b);
-                }
-              else
-                {
-                  Array<double> b = b_arg.array_value ();
-
-                  retval = betaincinv (x, a, b);
-                }
+              retval = betaincinv (x, a, b);
             }
         }
+      else
+        {
+          Array<double> a = a_arg.array_value ();
 
-      // FIXME: It would be better to have an algorithm for betaincinv which
-      // accepted float inputs and returned float outputs.  As it is, we do
-      // extra work to calculate betaincinv to double precision and then throw
-      // that precision away.
-      if (x_arg.is_single_type () || a_arg.is_single_type ()
-          || b_arg.is_single_type ())
-        {
-          retval = Array<float> (retval.array_value ());
+          if (b_arg.is_scalar_type ())
+            {
+              double b = b_arg.double_value ();
+
+              retval = betaincinv (x, a, b);
+            }
+          else
+            {
+              Array<double> b = b_arg.array_value ();
+
+              retval = betaincinv (x, a, b);
+            }
         }
     }
-  else
-    print_usage ();
+
+  // FIXME: It would be better to have an algorithm for betaincinv which
+  // accepted float inputs and returned float outputs.  As it is, we do
+  // extra work to calculate betaincinv to double precision and then throw
+  // that precision away.
+  if (x_arg.is_single_type () || a_arg.is_single_type ()
+      || b_arg.is_single_type ())
+    {
+      retval = Array<float> (retval.array_value ());
+    }
+
 
   return retval;
 }
--- a/libinterp/corefcn/bitfcns.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/bitfcns.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -156,209 +156,205 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 2)
+    print_usage ();
 
-  if (nargin == 2)
+  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 ()
+      || args(1).class_name () == octave_scalar::static_class_name ()
+      || args(1).class_name () == octave_float_scalar::static_class_name ()
+      || args(1).class_name () == octave_bool::static_class_name ())
     {
-      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 ()
-          || args(1).class_name () == octave_scalar::static_class_name ()
-          || args(1).class_name () == octave_float_scalar::static_class_name ()
-          || args(1).class_name () == octave_bool::static_class_name ())
-        {
-          bool arg0_is_int = bitop_arg_is_int (args(0));
-          bool arg1_is_int = bitop_arg_is_int (args(1));
+      bool arg0_is_int = bitop_arg_is_int (args(0));
+      bool arg1_is_int = bitop_arg_is_int (args(1));
 
-          bool arg0_is_bool = bitop_arg_is_bool (args(0));
-          bool arg1_is_bool = bitop_arg_is_bool (args(1));
-
-          bool arg0_is_float = bitop_arg_is_float (args(0));
-          bool arg1_is_float = bitop_arg_is_float (args(1));
+      bool arg0_is_bool = bitop_arg_is_bool (args(0));
+      bool arg1_is_bool = bitop_arg_is_bool (args(1));
 
-          if (! (arg0_is_int || arg1_is_int))
-            {
-              if (arg0_is_bool && arg1_is_bool)
-                {
-                  boolNDArray x (args(0).bool_array_value ());
-                  boolNDArray y (args(1).bool_array_value ());
+      bool arg0_is_float = bitop_arg_is_float (args(0));
+      bool arg1_is_float = bitop_arg_is_float (args(1));
 
-                  retval = bitopx (fname, x, y).bool_array_value ();
-                }
-              else if (arg0_is_float && arg1_is_float)
-                {
-                  uint64NDArray x (args(0).float_array_value ());
-                  uint64NDArray y (args(1).float_array_value ());
+      if (! (arg0_is_int || arg1_is_int))
+        {
+          if (arg0_is_bool && arg1_is_bool)
+            {
+              boolNDArray x (args(0).bool_array_value ());
+              boolNDArray y (args(1).bool_array_value ());
 
-                  retval = bitopx (fname, x, y).float_array_value ();
-                }
-              else if (! (arg0_is_float || arg1_is_float))
-                {
-                  uint64NDArray x (args(0).array_value ());
-                  uint64NDArray y (args(1).array_value ());
+              retval = bitopx (fname, x, y).bool_array_value ();
+            }
+          else if (arg0_is_float && arg1_is_float)
+            {
+              uint64NDArray x (args(0).float_array_value ());
+              uint64NDArray y (args(1).float_array_value ());
 
-                  retval = bitopx (fname, x, y).array_value ();
-                }
-              else
-                {
-                  int p = (arg0_is_float ? 1 : 0);
-                  int q = (arg0_is_float ? 0 : 1);
+              retval = bitopx (fname, x, y).float_array_value ();
+            }
+          else if (! (arg0_is_float || arg1_is_float))
+            {
+              uint64NDArray x (args(0).array_value ());
+              uint64NDArray y (args(1).array_value ());
 
-                  uint64NDArray x (args(p).array_value ());
-                  uint64NDArray y (args(q).float_array_value ());
-
-                  retval = bitopx (fname, x, y).float_array_value ();
-                }
+              retval = bitopx (fname, x, y).array_value ();
             }
           else
             {
-              int p = (arg0_is_int ? 1 : 0);
-              int q = (arg0_is_int ? 0 : 1);
-
-              NDArray dx = args(p).array_value ();
-
-              if (args(q).type_id () == octave_uint64_matrix::static_type_id ()
-                  || args(q).type_id () == octave_uint64_scalar::static_type_id ())
-                {
-                  uint64NDArray x (dx);
-                  uint64NDArray y = args(q).uint64_array_value ();
-
-                  retval = bitopx (fname, x, y);
-                }
-              else if (args(q).type_id () == octave_uint32_matrix::static_type_id ()
-                       || args(q).type_id () == octave_uint32_scalar::static_type_id ())
-                {
-                  uint32NDArray x (dx);
-                  uint32NDArray y = args(q).uint32_array_value ();
-
-                  retval = bitopx (fname, x, y);
-                }
-              else if (args(q).type_id () == octave_uint16_matrix::static_type_id ()
-                       || args(q).type_id () == octave_uint16_scalar::static_type_id ())
-                {
-                  uint16NDArray x (dx);
-                  uint16NDArray y = args(q).uint16_array_value ();
-
-                  retval = bitopx (fname, x, y);
-                }
-              else if (args(q).type_id () == octave_uint8_matrix::static_type_id ()
-                       || args(q).type_id () == octave_uint8_scalar::static_type_id ())
-                {
-                  uint8NDArray x (dx);
-                  uint8NDArray y = args(q).uint8_array_value ();
+              int p = (arg0_is_float ? 1 : 0);
+              int q = (arg0_is_float ? 0 : 1);
 
-                  retval = bitopx (fname, x, y);
-                }
-              else if (args(q).type_id () == octave_int64_matrix::static_type_id ()
-                       || args(q).type_id () == octave_int64_scalar::static_type_id ())
-                {
-                  int64NDArray x (dx);
-                  int64NDArray y = args(q).int64_array_value ();
-
-                  retval = bitopx (fname, x, y);
-                }
-              else if (args(q).type_id () == octave_int32_matrix::static_type_id ()
-                       || args(q).type_id () == octave_int32_scalar::static_type_id ())
-                {
-                  int32NDArray x (dx);
-                  int32NDArray y = args(q).int32_array_value ();
+              uint64NDArray x (args(p).array_value ());
+              uint64NDArray y (args(q).float_array_value ());
 
-                  retval = bitopx (fname, x, y);
-                }
-              else if (args(q).type_id () == octave_int16_matrix::static_type_id ()
-                       || args(q).type_id () == octave_int16_scalar::static_type_id ())
-                {
-                  int16NDArray x (dx);
-                  int16NDArray y = args(q).int16_array_value ();
-
-                  retval  = bitopx (fname, x, y);
-                }
-              else if (args(q).type_id () == octave_int8_matrix::static_type_id ()
-                       || args(q).type_id () == octave_int8_scalar::static_type_id ())
-                {
-                  int8NDArray x (dx);
-                  int8NDArray y = args(q).int8_array_value ();
-
-                  retval = bitopx (fname, x, y);
-                }
-              else
-                error ("%s: invalid operand type", fname.c_str ());
+              retval = bitopx (fname, x, y).float_array_value ();
             }
         }
-      else if (args(0).class_name () == args(1).class_name ())
+      else
         {
-          if (args(0).type_id () == octave_uint64_matrix::static_type_id ()
-              || args(0).type_id () == octave_uint64_scalar::static_type_id ())
+          int p = (arg0_is_int ? 1 : 0);
+          int q = (arg0_is_int ? 0 : 1);
+
+          NDArray dx = args(p).array_value ();
+
+          if (args(q).type_id () == octave_uint64_matrix::static_type_id ()
+              || args(q).type_id () == octave_uint64_scalar::static_type_id ())
             {
-              uint64NDArray x = args(0).uint64_array_value ();
-              uint64NDArray y = args(1).uint64_array_value ();
+              uint64NDArray x (dx);
+              uint64NDArray y = args(q).uint64_array_value ();
+
+              retval = bitopx (fname, x, y);
+            }
+          else if (args(q).type_id () == octave_uint32_matrix::static_type_id ()
+                   || args(q).type_id () == octave_uint32_scalar::static_type_id ())
+            {
+              uint32NDArray x (dx);
+              uint32NDArray y = args(q).uint32_array_value ();
 
               retval = bitopx (fname, x, y);
             }
-          else if (args(0).type_id () == octave_uint32_matrix::static_type_id ()
-                   || args(0).type_id () == octave_uint32_scalar::static_type_id ())
+          else if (args(q).type_id () == octave_uint16_matrix::static_type_id ()
+                   || args(q).type_id () == octave_uint16_scalar::static_type_id ())
             {
-              uint32NDArray x = args(0).uint32_array_value ();
-              uint32NDArray y = args(1).uint32_array_value ();
+              uint16NDArray x (dx);
+              uint16NDArray y = args(q).uint16_array_value ();
 
               retval = bitopx (fname, x, y);
             }
-          else if (args(0).type_id () == octave_uint16_matrix::static_type_id ()
-                   || args(0).type_id () == octave_uint16_scalar::static_type_id ())
+          else if (args(q).type_id () == octave_uint8_matrix::static_type_id ()
+                   || args(q).type_id () == octave_uint8_scalar::static_type_id ())
             {
-              uint16NDArray x = args(0).uint16_array_value ();
-              uint16NDArray y = args(1).uint16_array_value ();
-
-              retval = bitopx (fname, x, y);
-            }
-          else if (args(0).type_id () == octave_uint8_matrix::static_type_id ()
-                   || args(0).type_id () == octave_uint8_scalar::static_type_id ())
-            {
-              uint8NDArray x = args(0).uint8_array_value ();
-              uint8NDArray y = args(1).uint8_array_value ();
+              uint8NDArray x (dx);
+              uint8NDArray y = args(q).uint8_array_value ();
 
               retval = bitopx (fname, x, y);
             }
-          else if (args(0).type_id () == octave_int64_matrix::static_type_id ()
-                   || args(0).type_id () == octave_int64_scalar::static_type_id ())
+          else if (args(q).type_id () == octave_int64_matrix::static_type_id ()
+                   || args(q).type_id () == octave_int64_scalar::static_type_id ())
             {
-              int64NDArray x = args(0).int64_array_value ();
-              int64NDArray y = args(1).int64_array_value ();
+              int64NDArray x (dx);
+              int64NDArray y = args(q).int64_array_value ();
 
               retval = bitopx (fname, x, y);
             }
-          else if (args(0).type_id () == octave_int32_matrix::static_type_id ()
-                   || args(0).type_id () == octave_int32_scalar::static_type_id ())
+          else if (args(q).type_id () == octave_int32_matrix::static_type_id ()
+                   || args(q).type_id () == octave_int32_scalar::static_type_id ())
             {
-              int32NDArray x = args(0).int32_array_value ();
-              int32NDArray y = args(1).int32_array_value ();
+              int32NDArray x (dx);
+              int32NDArray y = args(q).int32_array_value ();
 
               retval = bitopx (fname, x, y);
             }
-          else if (args(0).type_id () == octave_int16_matrix::static_type_id ()
-                   || args(0).type_id () == octave_int16_scalar::static_type_id ())
+          else if (args(q).type_id () == octave_int16_matrix::static_type_id ()
+                   || args(q).type_id () == octave_int16_scalar::static_type_id ())
             {
-              int16NDArray x = args(0).int16_array_value ();
-              int16NDArray y = args(1).int16_array_value ();
+              int16NDArray x (dx);
+              int16NDArray y = args(q).int16_array_value ();
 
-              retval = bitopx (fname, x, y);
+              retval  = bitopx (fname, x, y);
             }
-          else if (args(0).type_id () == octave_int8_matrix::static_type_id ()
-                   || args(0).type_id () == octave_int8_scalar::static_type_id ())
+          else if (args(q).type_id () == octave_int8_matrix::static_type_id ()
+                   || args(q).type_id () == octave_int8_scalar::static_type_id ())
             {
-              int8NDArray x = args(0).int8_array_value ();
-              int8NDArray y = args(1).int8_array_value ();
+              int8NDArray x (dx);
+              int8NDArray y = args(q).int8_array_value ();
 
               retval = bitopx (fname, x, y);
             }
           else
             error ("%s: invalid operand type", fname.c_str ());
         }
+    }
+  else if (args(0).class_name () == args(1).class_name ())
+    {
+      if (args(0).type_id () == octave_uint64_matrix::static_type_id ()
+          || args(0).type_id () == octave_uint64_scalar::static_type_id ())
+        {
+          uint64NDArray x = args(0).uint64_array_value ();
+          uint64NDArray y = args(1).uint64_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
+      else if (args(0).type_id () == octave_uint32_matrix::static_type_id ()
+               || args(0).type_id () == octave_uint32_scalar::static_type_id ())
+        {
+          uint32NDArray x = args(0).uint32_array_value ();
+          uint32NDArray y = args(1).uint32_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
+      else if (args(0).type_id () == octave_uint16_matrix::static_type_id ()
+               || args(0).type_id () == octave_uint16_scalar::static_type_id ())
+        {
+          uint16NDArray x = args(0).uint16_array_value ();
+          uint16NDArray y = args(1).uint16_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
+      else if (args(0).type_id () == octave_uint8_matrix::static_type_id ()
+               || args(0).type_id () == octave_uint8_scalar::static_type_id ())
+        {
+          uint8NDArray x = args(0).uint8_array_value ();
+          uint8NDArray y = args(1).uint8_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
+      else if (args(0).type_id () == octave_int64_matrix::static_type_id ()
+               || args(0).type_id () == octave_int64_scalar::static_type_id ())
+        {
+          int64NDArray x = args(0).int64_array_value ();
+          int64NDArray y = args(1).int64_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
+      else if (args(0).type_id () == octave_int32_matrix::static_type_id ()
+               || args(0).type_id () == octave_int32_scalar::static_type_id ())
+        {
+          int32NDArray x = args(0).int32_array_value ();
+          int32NDArray y = args(1).int32_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
+      else if (args(0).type_id () == octave_int16_matrix::static_type_id ()
+               || args(0).type_id () == octave_int16_scalar::static_type_id ())
+        {
+          int16NDArray x = args(0).int16_array_value ();
+          int16NDArray y = args(1).int16_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
+      else if (args(0).type_id () == octave_int8_matrix::static_type_id ()
+               || args(0).type_id () == octave_int8_scalar::static_type_id ())
+        {
+          int8NDArray x = args(0).int8_array_value ();
+          int8NDArray y = args(1).int8_array_value ();
+
+          retval = bitopx (fname, x, y);
+        }
       else
-        error ("%s: must have matching operand types", fname.c_str ());
+        error ("%s: invalid operand type", fname.c_str ());
     }
   else
-    print_usage ();
+    error ("%s: must have matching operand types", fname.c_str ());
 
   return retval;
 }
@@ -570,82 +566,80 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      int nbits = 64;
+  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");
-
-      if (nargin == 3)
+  if (nargin == 3)
+    {
+      // 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
         {
-          // 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
-            {
-              nbits = args(2).xint_value ("bitshift: N must be an integer");
+          nbits = args(2).xint_value ("bitshift: N must be an integer");
 
-              if (nbits < 0)
-                error ("bitshift: N must be positive");
-            }
+          if (nbits < 0)
+            error ("bitshift: N must be positive");
         }
+    }
 
-      octave_value m_arg = args(0);
-      std::string cname = m_arg.class_name ();
+  octave_value m_arg = args(0);
+  std::string cname = m_arg.class_name ();
 
-      if (cname == "uint8")
-        DO_UBITSHIFT (uint8, nbits < 8 ? nbits : 8);
-      else if (cname == "uint16")
-        DO_UBITSHIFT (uint16, nbits < 16 ? nbits : 16);
-      else if (cname == "uint32")
-        DO_UBITSHIFT (uint32, nbits < 32 ? nbits : 32);
-      else if (cname == "uint64")
-        DO_UBITSHIFT (uint64, nbits < 64 ? nbits : 64);
-      else if (cname == "int8")
-        DO_SBITSHIFT (int8, nbits < 8 ? nbits : 8);
-      else if (cname == "int16")
-        DO_SBITSHIFT (int16, nbits < 16 ? nbits : 16);
-      else if (cname == "int32")
-        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;
+  if (cname == "uint8")
+    DO_UBITSHIFT (uint8, nbits < 8 ? nbits : 8);
+  else if (cname == "uint16")
+    DO_UBITSHIFT (uint16, nbits < 16 ? nbits : 16);
+  else if (cname == "uint32")
+    DO_UBITSHIFT (uint32, nbits < 32 ? nbits : 32);
+  else if (cname == "uint64")
+    DO_UBITSHIFT (uint64, nbits < 64 ? nbits : 64);
+  else if (cname == "int8")
+    DO_SBITSHIFT (int8, nbits < 8 ? nbits : 8);
+  else if (cname == "int16")
+    DO_SBITSHIFT (int16, nbits < 16 ? nbits : 16);
+  else if (cname == "int32")
+    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
-            = std::numeric_limits<float>::digits;
-          nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
-          int64_t mask = max_mantissa_value<float> ();
-          if (nbits < bits_in_mantissa)
-            mask = mask >> (bits_in_mantissa - nbits);
-          else if (nbits < 1)
-            mask = 0;
-          int bits_in_type = sizeof (float)
-                             * std::numeric_limits<unsigned char>::digits;
-          FloatNDArray m = m_arg.float_array_value ();
-          DO_BITSHIFT (Float);
-        }
-      else
-        error ("bitshift: not defined for %s objects", cname.c_str ());
+      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
+        = std::numeric_limits<float>::digits;
+      nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
+      int64_t mask = max_mantissa_value<float> ();
+      if (nbits < bits_in_mantissa)
+        mask = mask >> (bits_in_mantissa - nbits);
+      else if (nbits < 1)
+        mask = 0;
+      int bits_in_type = sizeof (float)
+        * std::numeric_limits<unsigned char>::digits;
+      FloatNDArray m = m_arg.float_array_value ();
+      DO_BITSHIFT (Float);
     }
   else
-    print_usage ();
+    error ("bitshift: not defined for %s objects", cname.c_str ());
 
   return retval;
 }
@@ -678,16 +672,16 @@
 @end deftypefn")
 {
   octave_value retval;
+
   std::string cname = "double";
+
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_string ())
-    cname = args(0).string_value ();
-  else if (nargin != 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
+
+  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));
@@ -737,16 +731,16 @@
 @end deftypefn")
 {
   octave_value retval;
+
   std::string cname = "int32";
+
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_string ())
-    cname = args(0).string_value ();
-  else if (nargin != 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
+    cname = args(0).xstring_value ("intmax: argument must be a string");
 
   if (cname == "uint8")
     retval = octave_uint8 (std::numeric_limits<uint8_t>::max ());
@@ -808,16 +802,16 @@
 @end deftypefn")
 {
   octave_value retval;
+
   std::string cname = "int32";
+
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_string ())
-    cname = args(0).string_value ();
-  else if (nargin != 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
+    cname = args(0).xstring_value ("intmin: argument must be a string");
 
   if (cname == "uint8")
     retval = octave_uint8 (std::numeric_limits<uint8_t>::min ());
@@ -853,12 +847,8 @@
 @seealso{intmax}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = octave_int<octave_idx_type> (dim_vector::dim_max ());
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_int<octave_idx_type> (dim_vector::dim_max ()));
 }
--- a/libinterp/corefcn/bsxfun.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/bsxfun.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -135,8 +135,10 @@
 
 #define REGISTER_OP_HANDLER(OP, BTYP, NDA, FUNOP) \
   bsxfun_handler_table[OP][BTYP] = bsxfun_forward_op<NDA, FUNOP>
+
 #define REGISTER_REL_HANDLER(REL, BTYP, NDA, FUNREL) \
   bsxfun_handler_table[REL][BTYP] = bsxfun_forward_rel<NDA, FUNREL>
+
 #define REGISTER_STD_HANDLERS(BTYP, NDA) \
   REGISTER_OP_HANDLER (bsxfun_builtin_plus, BTYP, NDA, bsxfun_add); \
   REGISTER_OP_HANDLER (bsxfun_builtin_minus, BTYP, NDA, bsxfun_sub); \
@@ -338,132 +340,131 @@
 
   if (nargin != 3)
     print_usage ();
-  else
-    {
-      octave_value func = args(0);
+
+  octave_value func = args(0);
 
-      if (func.is_string ())
-        {
-          std::string name = func.string_value ();
-          func = symbol_table::find_function (name);
-          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 ()))
-        error ("bsxfun: F must be a string or function handle");
+  if (func.is_string ())
+    {
+      std::string name = func.string_value ();
+      func = symbol_table::find_function (name);
+      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 ()))
+    error ("bsxfun: F must be a string or function handle");
+
+  const octave_value A = args(1);
+  const octave_value B = args(2);
 
-      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 ()))
+  if (func.is_builtin_function ()
+      || (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.
+      octave_function *fcn_val = func.function_value ();
+      if (fcn_val)
         {
-          // 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.
-          octave_function *fcn_val = func.function_value ();
-          if (fcn_val)
-            {
-              octave_value tmp = maybe_optimized_builtin (fcn_val->name (),
-                                                          A, B);
-              if (tmp.is_defined ())
-                retval(0) = tmp;
-            }
+          octave_value tmp = maybe_optimized_builtin (fcn_val->name (),
+                                                      A, B);
+          if (tmp.is_defined ())
+            retval(0) = tmp;
+        }
+    }
+
+  if (retval.empty ())
+    {
+      dim_vector dva = A.dims ();
+      octave_idx_type nda = dva.length ();
+      dim_vector dvb = B.dims ();
+      octave_idx_type ndb = dvb.length ();
+      octave_idx_type nd = nda;
+
+      if (nda > ndb)
+        dvb.resize (nda, 1);
+      else if (nda < ndb)
+        {
+          dva.resize (ndb, 1);
+          nd = ndb;
         }
 
-      if (retval.empty ())
-        {
-          dim_vector dva = A.dims ();
-          octave_idx_type nda = dva.length ();
-          dim_vector dvb = B.dims ();
-          octave_idx_type ndb = dvb.length ();
-          octave_idx_type nd = nda;
+      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;
+          }
 
-          if (nda > ndb)
-            dvb.resize (nda, 1);
-          else if (nda < ndb)
-            {
-              dva.resize (ndb, 1);
-              nd = ndb;
-            }
+      // Find the size of the output
+      dim_vector dvc;
+      dvc.resize (nd);
 
-          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;
-              }
+      for (octave_idx_type i = 0; i < nd; i++)
+        dvc(i) = (dva(i) < 1 ? dva(i)
+                  : (dvb(i) < 1 ? dvb(i)
+                     : (dva(i) > dvb(i)
+                        ? dva(i) : dvb(i))));
 
-          // Find the size of the output
-          dim_vector dvc;
-          dvc.resize (nd);
-
-          for (octave_idx_type i = 0; i < nd; i++)
-            dvc(i) = (dva(i) < 1 ? dva(i)
-                                 : (dvb(i) < 1 ? dvb(i)
-                                               : (dva(i) > dvb(i)
-                                                   ? dva(i) : dvb(i))));
-
-          if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1)
-            {
-              octave_value_list inputs;
-              inputs (0) = A;
-              inputs (1) = B;
-              retval = func.do_multi_index_op (1, inputs);
-            }
-          else if (dvc.numel () < 1)
-            {
-              octave_value_list inputs;
-              inputs (0) = A.resize (dvc);
-              inputs (1) = B.resize (dvc);
-              retval = func.do_multi_index_op (1, inputs);
-            }
-          else
-            {
-              octave_idx_type ncount = 1;
-              for (octave_idx_type i = 1; i < nd; i++)
-                ncount *= dvc(i);
+      if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1)
+        {
+          octave_value_list inputs;
+          inputs (0) = A;
+          inputs (1) = B;
+          retval = func.do_multi_index_op (1, inputs);
+        }
+      else if (dvc.numel () < 1)
+        {
+          octave_value_list inputs;
+          inputs (0) = A.resize (dvc);
+          inputs (1) = B.resize (dvc);
+          retval = func.do_multi_index_op (1, inputs);
+        }
+      else
+        {
+          octave_idx_type ncount = 1;
+          for (octave_idx_type i = 1; i < nd; i++)
+            ncount *= dvc(i);
 
 #define BSXDEF(T) \
-              T result_ ## T; \
-              bool have_ ## T = false;
+  T result_ ## T; \
+  bool have_ ## T = false;
 
-              BSXDEF(NDArray);
-              BSXDEF(ComplexNDArray);
-              BSXDEF(FloatNDArray);
-              BSXDEF(FloatComplexNDArray);
-              BSXDEF(boolNDArray);
-              BSXDEF(int8NDArray);
-              BSXDEF(int16NDArray);
-              BSXDEF(int32NDArray);
-              BSXDEF(int64NDArray);
-              BSXDEF(uint8NDArray);
-              BSXDEF(uint16NDArray);
-              BSXDEF(uint32NDArray);
-              BSXDEF(uint64NDArray);
+          BSXDEF(NDArray);
+          BSXDEF(ComplexNDArray);
+          BSXDEF(FloatNDArray);
+          BSXDEF(FloatComplexNDArray);
+          BSXDEF(boolNDArray);
+          BSXDEF(int8NDArray);
+          BSXDEF(int16NDArray);
+          BSXDEF(int32NDArray);
+          BSXDEF(int64NDArray);
+          BSXDEF(uint8NDArray);
+          BSXDEF(uint16NDArray);
+          BSXDEF(uint32NDArray);
+          BSXDEF(uint64NDArray);
 
-              octave_value Ac ;
-              octave_value_list idxA;
-              octave_value Bc;
-              octave_value_list idxB;
-              octave_value C;
-              octave_value_list inputs;
-              Array<int> ra_idx (dim_vector (dvc.length (), 1), 0);
+          octave_value Ac ;
+          octave_value_list idxA;
+          octave_value Bc;
+          octave_value_list idxB;
+          octave_value C;
+          octave_value_list inputs;
+          Array<int> ra_idx (dim_vector (dvc.length (), 1), 0);
 
 
-              for (octave_idx_type i = 0; i < ncount; i++)
-                {
-                  if (maybe_update_column (Ac, A, dva, dvc, i, idxA))
-                    inputs (0) = Ac;
+          for (octave_idx_type i = 0; i < ncount; i++)
+            {
+              if (maybe_update_column (Ac, A, dva, dvc, i, idxA))
+                inputs (0) = Ac;
 
-                  if (maybe_update_column (Bc, B, dvb, dvc, i, idxB))
-                    inputs (1) = Bc;
+              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) \
@@ -473,138 +474,138 @@
       result_ ## T .resize (dvc); \
     }
 
-                  if (i == 0)
+              if (i == 0)
+                {
+                  if (! tmp(0).is_sparse_type ())
                     {
-                      if (! tmp(0).is_sparse_type ())
+                      std::string result_type = tmp(0).class_name ();
+                      if (result_type == "double")
                         {
-                          std::string result_type = tmp(0).class_name ();
-                          if (result_type == "double")
+                          if (tmp(0).is_real_type ())
                             {
-                              if (tmp(0).is_real_type ())
-                                {
-                                  have_NDArray = true;
-                                  result_NDArray = tmp(0).array_value ();
-                                  result_NDArray.resize (dvc);
-                                }
-                              else
-                                {
-                                  have_ComplexNDArray = true;
-                                  result_ComplexNDArray =
-                                    tmp(0).complex_array_value ();
-                                  result_ComplexNDArray.resize (dvc);
-                                }
+                              have_NDArray = true;
+                              result_NDArray = tmp(0).array_value ();
+                              result_NDArray.resize (dvc);
                             }
-                          else if (result_type == "single")
+                          else
                             {
-                              if (tmp(0).is_real_type ())
-                                {
-                                  have_FloatNDArray = true;
-                                  result_FloatNDArray
-                                    = tmp(0).float_array_value ();
-                                  result_FloatNDArray.resize (dvc);
-                                }
-                              else
-                                {
-                                  have_ComplexNDArray = true;
-                                  result_ComplexNDArray =
-                                    tmp(0).complex_array_value ();
-                                  result_ComplexNDArray.resize (dvc);
-                                }
+                              have_ComplexNDArray = true;
+                              result_ComplexNDArray =
+                                tmp(0).complex_array_value ();
+                              result_ComplexNDArray.resize (dvc);
                             }
-                          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 if (result_type == "single")
+                        {
+                          if (tmp(0).is_real_type ())
+                            {
+                              have_FloatNDArray = true;
+                              result_FloatNDArray
+                                = tmp(0).float_array_value ();
+                              result_FloatNDArray.resize (dvc);
+                            }
                           else
                             {
-                              C = tmp (0);
-                              C = C.resize (dvc);
+                              have_ComplexNDArray = true;
+                              result_ComplexNDArray =
+                                tmp(0).complex_array_value ();
+                              result_ComplexNDArray.resize (dvc);
+                            }
+                        }
+                      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
+                {
+                  update_index (ra_idx, dvc, i);
+
+                  if (have_FloatNDArray
+                      || have_FloatComplexNDArray)
+                    {
+                      if (! tmp(0).is_float_type ())
+                        {
+                          if (have_FloatNDArray)
+                            {
+                              have_FloatNDArray = false;
+                              C = result_FloatNDArray;
                             }
+                          else
+                            {
+                              have_FloatComplexNDArray = false;
+                              C = result_FloatComplexNDArray;
+                            }
+                          C = do_cat_op (C, tmp(0), ra_idx);
+                        }
+                      else if (tmp(0).is_double_type ())
+                        {
+                          if (tmp(0).is_complex_type ()
+                              && have_FloatNDArray)
+                            {
+                              result_ComplexNDArray =
+                                ComplexNDArray (result_FloatNDArray);
+                              result_ComplexNDArray.insert
+                                (tmp(0).complex_array_value (), ra_idx);
+                              have_FloatComplexNDArray = false;
+                              have_ComplexNDArray = true;
+                            }
+                          else
+                            {
+                              result_NDArray =
+                                NDArray (result_FloatNDArray);
+                              result_NDArray.insert
+                                (tmp(0).array_value (), ra_idx);
+                              have_FloatNDArray = false;
+                              have_NDArray = true;
+                            }
+                        }
+                      else if (tmp(0).is_real_type ())
+                        result_FloatNDArray.insert
+                          (tmp(0).float_array_value (), ra_idx);
+                      else
+                        {
+                          result_FloatComplexNDArray =
+                            FloatComplexNDArray (result_FloatNDArray);
+                          result_FloatComplexNDArray.insert
+                            (tmp(0).float_complex_array_value (),
+                             ra_idx);
+                          have_FloatNDArray = false;
+                          have_FloatComplexNDArray = true;
                         }
                     }
-                  else
+                  else if (have_NDArray)
                     {
-                      update_index (ra_idx, dvc, i);
-
-                      if (have_FloatNDArray
-                          || have_FloatComplexNDArray)
+                      if (! tmp(0).is_float_type ())
                         {
-                          if (! tmp(0).is_float_type ())
-                            {
-                              if (have_FloatNDArray)
-                                {
-                                  have_FloatNDArray = false;
-                                  C = result_FloatNDArray;
-                                }
-                              else
-                                {
-                                  have_FloatComplexNDArray = false;
-                                  C = result_FloatComplexNDArray;
-                                }
-                              C = do_cat_op (C, tmp(0), ra_idx);
-                            }
-                          else if (tmp(0).is_double_type ())
-                            {
-                              if (tmp(0).is_complex_type ()
-                                  && have_FloatNDArray)
-                                {
-                                  result_ComplexNDArray =
-                                    ComplexNDArray (result_FloatNDArray);
-                                  result_ComplexNDArray.insert
-                                    (tmp(0).complex_array_value (), ra_idx);
-                                  have_FloatComplexNDArray = false;
-                                  have_ComplexNDArray = true;
-                                }
-                              else
-                                {
-                                  result_NDArray =
-                                    NDArray (result_FloatNDArray);
-                                  result_NDArray.insert
-                                    (tmp(0).array_value (), ra_idx);
-                                  have_FloatNDArray = false;
-                                  have_NDArray = true;
-                                }
-                            }
-                          else if (tmp(0).is_real_type ())
-                            result_FloatNDArray.insert
-                              (tmp(0).float_array_value (), ra_idx);
-                          else
-                            {
-                              result_FloatComplexNDArray =
-                                FloatComplexNDArray (result_FloatNDArray);
-                              result_FloatComplexNDArray.insert
-                                (tmp(0).float_complex_array_value (),
-                                 ra_idx);
-                              have_FloatNDArray = false;
-                              have_FloatComplexNDArray = true;
-                            }
+                          have_NDArray = false;
+                          C = result_NDArray;
+                          C = do_cat_op (C, tmp(0), ra_idx);
                         }
-                      else if (have_NDArray)
+                      else if (tmp(0).is_real_type ())
+                        result_NDArray.insert (tmp(0).array_value (),
+                                               ra_idx);
+                      else
                         {
-                          if (! tmp(0).is_float_type ())
-                            {
-                              have_NDArray = false;
-                              C = result_NDArray;
-                              C = do_cat_op (C, tmp(0), ra_idx);
-                            }
-                          else if (tmp(0).is_real_type ())
-                            result_NDArray.insert (tmp(0).array_value (),
-                                                   ra_idx);
-                          else
-                            {
-                              result_ComplexNDArray =
-                                ComplexNDArray (result_NDArray);
-                              result_ComplexNDArray.insert
-                                (tmp(0).complex_array_value (), ra_idx);
-                              have_NDArray = false;
-                              have_ComplexNDArray = true;
-                            }
+                          result_ComplexNDArray =
+                            ComplexNDArray (result_NDArray);
+                          result_ComplexNDArray.insert
+                            (tmp(0).complex_array_value (), ra_idx);
+                          have_NDArray = false;
+                          have_ComplexNDArray = true;
                         }
+                    }
 
 #define BSXLOOP(T, CLS, EXTRACTOR) \
   (have_ ## T) \
@@ -619,41 +620,40 @@
         result_ ## T .insert (tmp(0). EXTRACTOR ## _array_value (), ra_idx); \
     }
 
-                      else if BSXLOOP(ComplexNDArray, "double", complex)
-                      else if BSXLOOP(boolNDArray, "logical", bool)
-                      else if BSXLOOP(int8NDArray, "int8", int8)
-                      else if BSXLOOP(int16NDArray, "int16", int16)
-                      else if BSXLOOP(int32NDArray, "int32", int32)
-                      else if BSXLOOP(int64NDArray, "int64", int64)
-                      else if BSXLOOP(uint8NDArray, "uint8", uint8)
-                      else if BSXLOOP(uint16NDArray, "uint16", uint16)
-                      else if BSXLOOP(uint32NDArray, "uint32", uint32)
-                      else if BSXLOOP(uint64NDArray, "uint64", uint64)
-                      else
-                        C = do_cat_op (C, tmp(0), ra_idx);
-                    }
+                  else if BSXLOOP(ComplexNDArray, "double", complex)
+                  else if BSXLOOP(boolNDArray, "logical", bool)
+                  else if BSXLOOP(int8NDArray, "int8", int8)
+                  else if BSXLOOP(int16NDArray, "int16", int16)
+                  else if BSXLOOP(int32NDArray, "int32", int32)
+                  else if BSXLOOP(int64NDArray, "int64", int64)
+                  else if BSXLOOP(uint8NDArray, "uint8", uint8)
+                  else if BSXLOOP(uint16NDArray, "uint16", uint16)
+                  else if BSXLOOP(uint32NDArray, "uint32", uint32)
+                  else if BSXLOOP(uint64NDArray, "uint64", uint64)
+                  else
+                    C = do_cat_op (C, tmp(0), ra_idx);
                 }
+            }
 
 #define BSXEND(T) \
   (have_ ## T) \
     retval(0) = result_ ## T;
 
-              if BSXEND(NDArray)
-              else if BSXEND(ComplexNDArray)
-              else if BSXEND(FloatNDArray)
-              else if BSXEND(FloatComplexNDArray)
-              else if BSXEND(boolNDArray)
-              else if BSXEND(int8NDArray)
-              else if BSXEND(int16NDArray)
-              else if BSXEND(int32NDArray)
-              else if BSXEND(int64NDArray)
-              else if BSXEND(uint8NDArray)
-              else if BSXEND(uint16NDArray)
-              else if BSXEND(uint32NDArray)
-              else if BSXEND(uint64NDArray)
-              else
-                retval(0) = C;
-            }
+          if BSXEND(NDArray)
+          else if BSXEND(ComplexNDArray)
+          else if BSXEND(FloatNDArray)
+          else if BSXEND(FloatComplexNDArray)
+          else if BSXEND(boolNDArray)
+          else if BSXEND(int8NDArray)
+          else if BSXEND(int16NDArray)
+          else if BSXEND(int32NDArray)
+          else if BSXEND(int64NDArray)
+          else if BSXEND(uint8NDArray)
+          else if BSXEND(uint16NDArray)
+          else if BSXEND(uint32NDArray)
+          else if BSXEND(uint64NDArray)
+          else
+            retval(0) = C;
         }
     }
 
--- a/libinterp/corefcn/cellfun.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/cellfun.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -416,20 +416,12 @@
   int nargout1 = (nargout < 1 ? 1 : nargout);
 
   if (nargin < 2)
-    {
-      error ("cellfun: function requires at least 2 arguments");
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value func = args(0);
 
   if (! args(1).is_cell ())
-    {
-      error ("cellfun: C must be a cell array");
-
-      return retval;
-    }
+    error ("cellfun: C must be a cell array");
 
   if (func.is_string ())
     {
@@ -1167,12 +1159,7 @@
   int nargout1 = (nargout < 1 ? 1 : nargout);
 
   if (nargin < 2)
-    {
-      error_with_id ("Octave:invalid-fun-call",
-                     "arrayfun: function requires at least 2 arguments");
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value func = args(0);
   bool symbol_table_lookup = false;
@@ -1855,67 +1842,68 @@
 @seealso{mat2cell}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
   int nargin =  args.length ();
-  octave_value retval;
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
-  else
+
+  octave_value array = args(0);
+
+  Array<int> dimv;
+
+  if (nargin > 1)
+    dimv = args(1).int_vector_value (true);
+
+  if (array.is_bool_type ())
+    retval = do_num2cell (array.bool_array_value (), dimv);
+  else if (array.is_char_matrix ())
+    retval = do_num2cell (array.char_array_value (), dimv);
+  else if (array.is_numeric_type ())
     {
-      octave_value array = args(0);
-      Array<int> dimv;
-      if (nargin > 1)
-        dimv = args(1).int_vector_value (true);
-
-      if (array.is_bool_type ())
-        retval = do_num2cell (array.bool_array_value (), dimv);
-      else if (array.is_char_matrix ())
-        retval = do_num2cell (array.char_array_value (), dimv);
-      else if (array.is_numeric_type ())
+      if (array.is_integer_type ())
         {
-          if (array.is_integer_type ())
-            {
-              if (array.is_int8_type ())
-                retval = do_num2cell (array.int8_array_value (), dimv);
-              else if (array.is_int16_type ())
-                retval = do_num2cell (array.int16_array_value (), dimv);
-              else if (array.is_int32_type ())
-                retval = do_num2cell (array.int32_array_value (), dimv);
-              else if (array.is_int64_type ())
-                retval = do_num2cell (array.int64_array_value (), dimv);
-              else if (array.is_uint8_type ())
-                retval = do_num2cell (array.uint8_array_value (), dimv);
-              else if (array.is_uint16_type ())
-                retval = do_num2cell (array.uint16_array_value (), dimv);
-              else if (array.is_uint32_type ())
-                retval = do_num2cell (array.uint32_array_value (), dimv);
-              else if (array.is_uint64_type ())
-                retval = do_num2cell (array.uint64_array_value (), dimv);
-            }
-          else if (array.is_complex_type ())
-            {
-              if (array.is_single_type ())
-                retval = do_num2cell (array.float_complex_array_value (), dimv);
-              else
-                retval = do_num2cell (array.complex_array_value (), dimv);
-            }
+          if (array.is_int8_type ())
+            retval = do_num2cell (array.int8_array_value (), dimv);
+          else if (array.is_int16_type ())
+            retval = do_num2cell (array.int16_array_value (), dimv);
+          else if (array.is_int32_type ())
+            retval = do_num2cell (array.int32_array_value (), dimv);
+          else if (array.is_int64_type ())
+            retval = do_num2cell (array.int64_array_value (), dimv);
+          else if (array.is_uint8_type ())
+            retval = do_num2cell (array.uint8_array_value (), dimv);
+          else if (array.is_uint16_type ())
+            retval = do_num2cell (array.uint16_array_value (), dimv);
+          else if (array.is_uint32_type ())
+            retval = do_num2cell (array.uint32_array_value (), dimv);
+          else if (array.is_uint64_type ())
+            retval = do_num2cell (array.uint64_array_value (), dimv);
+        }
+      else if (array.is_complex_type ())
+        {
+          if (array.is_single_type ())
+            retval = do_num2cell (array.float_complex_array_value (), dimv);
           else
-            {
-              if (array.is_single_type ())
-                retval = do_num2cell (array.float_array_value (), dimv);
-              else
-                retval = do_num2cell (array.array_value (), dimv);
-            }
+            retval = do_num2cell (array.complex_array_value (), dimv);
+        }
+      else
+        {
+          if (array.is_single_type ())
+            retval = do_num2cell (array.float_array_value (), dimv);
+          else
+            retval = do_num2cell (array.array_value (), dimv);
         }
-      else if (array.is_object ())
-        retval = do_object2cell (array, dimv);
-      else if (array.is_map ())
-        retval = do_num2cell (array.map_value (), dimv);
-      else if (array.is_cell ())
-        retval = do_num2cell (array.cell_value (), dimv);
-      else
-        gripe_wrong_type_arg ("num2cell", array);
     }
+  else if (array.is_object ())
+    retval = do_object2cell (array, dimv);
+  else if (array.is_map ())
+    retval = do_num2cell (array.map_value (), dimv);
+  else if (array.is_cell ())
+    retval = do_num2cell (array.cell_value (), dimv);
+  else
+    gripe_wrong_type_arg ("num2cell", array);
 
   return retval;
 }
@@ -2189,75 +2177,79 @@
 @seealso{num2cell, cell2mat}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 2)
     print_usage ();
-  else
-    {
-      // Prepare indices.
-      OCTAVE_LOCAL_BUFFER (Array<octave_idx_type>, d, nargin-1);
 
-      for (int i = 1; i < nargin; i++)
-        d[i-1] = args(i).octave_idx_type_vector_value (true);
+  // Prepare indices.
+  OCTAVE_LOCAL_BUFFER (Array<octave_idx_type>, d, nargin-1);
+
+  for (int i = 1; i < nargin; i++)
+    d[i-1] = args(i).octave_idx_type_vector_value (true);
 
-      octave_value a = args(0);
-      bool sparse = a.is_sparse_type ();
-      if (sparse && nargin > 3)
-        {
-          error ("mat2cell: sparse arguments only support 2-D indexing");
-          return retval;
-        }
+  octave_value a = args(0);
+  bool sparse = a.is_sparse_type ();
+  if (sparse && nargin > 3)
+    {
+      error ("mat2cell: sparse arguments only support 2-D indexing");
+      return retval;
+    }
+
+  switch (a.builtin_type ())
+    {
+    case btyp_double:
+      {
+        if (sparse)
+          retval = do_mat2cell_2d (a.sparse_matrix_value (), d, nargin-1);
+        else
+          retval = do_mat2cell (a.array_value (), d, nargin - 1);
+      }
+      break;
 
-      switch (a.builtin_type ())
-        {
-        case btyp_double:
-          {
-            if (sparse)
-              retval = do_mat2cell_2d (a.sparse_matrix_value (), d, nargin-1);
-            else
-              retval = do_mat2cell (a.array_value (), d, nargin - 1);
-            break;
-          }
-        case btyp_complex:
-          {
-            if (sparse)
-              retval = do_mat2cell_2d (a.sparse_complex_matrix_value (), d,
-                                       nargin-1);
-            else
-              retval = do_mat2cell (a.complex_array_value (), d, nargin - 1);
-            break;
-          }
-#define BTYP_BRANCH(X,Y) \
-        case btyp_ ## X: \
-            retval = do_mat2cell (a.Y ## _value (), d, nargin - 1); \
-          break
+    case btyp_complex:
+      {
+        if (sparse)
+          retval = do_mat2cell_2d (a.sparse_complex_matrix_value (), d,
+                                   nargin-1);
+        else
+          retval = do_mat2cell (a.complex_array_value (), d, nargin - 1);
+      }
+      break;
+
+#define BTYP_BRANCH(X, Y) \
+  case btyp_ ## X: \
+    retval = do_mat2cell (a.Y ## _value (), d, nargin - 1); \
+    break
 
-        BTYP_BRANCH (float, float_array);
-        BTYP_BRANCH (float_complex, float_complex_array);
-        BTYP_BRANCH (bool, bool_array);
-        BTYP_BRANCH (char, char_array);
+      BTYP_BRANCH (float, float_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 (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);
+      BTYP_BRANCH (cell, cell);
+      BTYP_BRANCH (struct, map);
+
 #undef BTYP_BRANCH
 
-        case btyp_func_handle:
-          gripe_wrong_type_arg ("mat2cell", a);
-          break;
-        default:
-          retval = do_mat2cell (a, d, nargin-1);
-        }
+    case btyp_func_handle:
+      gripe_wrong_type_arg ("mat2cell", a);
+      break;
+
+    default:
+      retval = do_mat2cell (a, d, nargin-1);
+      break;
     }
 
   return retval;
@@ -2338,103 +2330,103 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
-  if (nargin == 3 || nargin == 4)
+
+  if (nargin < 3 || nargin > 4)
+    print_usage ();
+
+  octave_value x = args(0);
+  Array<octave_idx_type> lb = args(1).octave_idx_type_vector_value ();
+  Array<octave_idx_type> ub = args(2).octave_idx_type_vector_value ();
+  int dim = -1;
+  if (nargin == 4)
     {
-      octave_value x = args(0);
-      Array<octave_idx_type> lb = args(1).octave_idx_type_vector_value ();
-      Array<octave_idx_type> ub = args(2).octave_idx_type_vector_value ();
-      int dim = -1;
-      if (nargin == 4)
-        {
-          dim = args(3).int_value () - 1;
-          if (dim < 0)
-            error ("cellslices: DIM must be a valid dimension");
-        }
+      dim = args(3).int_value () - 1;
+      if (dim < 0)
+        error ("cellslices: DIM must be a valid dimension");
+    }
 
-      if (lb.numel () != ub.numel ())
-        error ("cellslices: the lengths of LB and UB must match");
-      else
+  if (lb.numel () != ub.numel ())
+    error ("cellslices: the lengths of LB and UB must match");
+  else
+    {
+      Cell retcell;
+      if (! x.is_sparse_type () && x.is_matrix_type ())
         {
-          Cell retcell;
-          if (! x.is_sparse_type () && x.is_matrix_type ())
+          // specialize for some dense arrays.
+          if (x.is_bool_type ())
+            retcell = do_cellslices_nda (x.bool_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_char_matrix ())
+            retcell = do_cellslices_nda (x.char_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_integer_type ())
             {
-              // specialize for some dense arrays.
-              if (x.is_bool_type ())
-                retcell = do_cellslices_nda (x.bool_array_value (),
-                                             lb, ub, dim);
-              else if (x.is_char_matrix ())
-                retcell = do_cellslices_nda (x.char_array_value (),
+              if (x.is_int8_type ())
+                retcell = do_cellslices_nda (x.int8_array_value (),
                                              lb, ub, dim);
-              else if (x.is_integer_type ())
-                {
-                  if (x.is_int8_type ())
-                    retcell = do_cellslices_nda (x.int8_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_int16_type ())
-                    retcell = do_cellslices_nda (x.int16_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_int32_type ())
-                    retcell = do_cellslices_nda (x.int32_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_int64_type ())
-                    retcell = do_cellslices_nda (x.int64_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_uint8_type ())
-                    retcell = do_cellslices_nda (x.uint8_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_uint16_type ())
-                    retcell = do_cellslices_nda (x.uint16_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_uint32_type ())
-                    retcell = do_cellslices_nda (x.uint32_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_uint64_type ())
-                    retcell = do_cellslices_nda (x.uint64_array_value (),
-                                                 lb, ub, dim);
-                }
-              else if (x.is_complex_type ())
-                {
-                  if (x.is_single_type ())
-                    retcell = do_cellslices_nda (x.float_complex_array_value (),
-                                                 lb, ub, dim);
-                  else
-                    retcell = do_cellslices_nda (x.complex_array_value (),
-                                                 lb, ub, dim);
-                }
+              else if (x.is_int16_type ())
+                retcell = do_cellslices_nda (x.int16_array_value (),
+                                             lb, ub, dim);
+              else if (x.is_int32_type ())
+                retcell = do_cellslices_nda (x.int32_array_value (),
+                                             lb, ub, dim);
+              else if (x.is_int64_type ())
+                retcell = do_cellslices_nda (x.int64_array_value (),
+                                             lb, ub, dim);
+              else if (x.is_uint8_type ())
+                retcell = do_cellslices_nda (x.uint8_array_value (),
+                                             lb, ub, dim);
+              else if (x.is_uint16_type ())
+                retcell = do_cellslices_nda (x.uint16_array_value (),
+                                             lb, ub, dim);
+              else if (x.is_uint32_type ())
+                retcell = do_cellslices_nda (x.uint32_array_value (),
+                                             lb, ub, dim);
+              else if (x.is_uint64_type ())
+                retcell = do_cellslices_nda (x.uint64_array_value (),
+                                             lb, ub, dim);
+            }
+          else if (x.is_complex_type ())
+            {
+              if (x.is_single_type ())
+                retcell = do_cellslices_nda (x.float_complex_array_value (),
+                                             lb, ub, dim);
               else
-                {
-                  if (x.is_single_type ())
-                    retcell = do_cellslices_nda (x.float_array_value (),
-                                                 lb, ub, dim);
-                  else
-                    retcell = do_cellslices_nda (x.array_value (),
-                                                 lb, ub, dim);
-                }
+                retcell = do_cellslices_nda (x.complex_array_value (),
+                                             lb, ub, dim);
             }
           else
             {
-              // generic code.
-              octave_idx_type n = lb.numel ();
-              retcell = Cell (1, n);
-              const dim_vector dv = x.dims ();
-              int ndims = dv.length ();
-              if (dim < 0)
-                dim = dv.first_non_singleton ();
-              ndims = std::max (ndims, dim + 1);
-              octave_value_list idx (ndims, octave_value::magic_colon_t);
-              for (octave_idx_type i = 0; i < n; i++)
-                {
-                  idx(dim) = Range (lb(i), ub(i));
-                  retcell(i) = x.do_index_op (idx);
-                }
+              if (x.is_single_type ())
+                retcell = do_cellslices_nda (x.float_array_value (),
+                                             lb, ub, dim);
+              else
+                retcell = do_cellslices_nda (x.array_value (),
+                                             lb, ub, dim);
             }
-
-          retval = retcell;
         }
+      else
+        {
+          // generic code.
+          octave_idx_type n = lb.numel ();
+          retcell = Cell (1, n);
+          const dim_vector dv = x.dims ();
+          int ndims = dv.length ();
+          if (dim < 0)
+            dim = dv.first_non_singleton ();
+          ndims = std::max (ndims, dim + 1);
+          octave_value_list idx (ndims, octave_value::magic_colon_t);
+          for (octave_idx_type i = 0; i < n; i++)
+            {
+              idx(dim) = Range (lb(i), ub(i));
+              retcell(i) = x.do_index_op (idx);
+            }
+        }
+
+      retval = retcell;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2464,28 +2456,22 @@
 @seealso{cellslices, cellfun}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () >= 1)
-    {
-      const Cell x = args(0).xcell_value ("cellindexmat: X must be a cell");
-      NoAlias<Cell> y(x.dims ());
-      octave_idx_type nel = x.numel ();
-      octave_value_list idx = args.slice (1, args.length () - 1);
-
-      for (octave_idx_type i = 0; i < nel; i++)
-        {
-          octave_quit ();
-
-          octave_value tmp = x(i);
-
-          y(i) = tmp.do_index_op (idx);
-        }
-
-      retval = y;
-    }
-  else
+  if (args.length () == 0)
     print_usage ();
 
-  return retval;
+  const Cell x = args(0).xcell_value ("cellindexmat: X must be a cell");
+  NoAlias<Cell> y(x.dims ());
+  octave_idx_type nel = x.numel ();
+  octave_value_list idx = args.slice (1, args.length () - 1);
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    {
+      octave_quit ();
+
+      octave_value tmp = x(i);
+
+      y(i) = tmp.do_index_op (idx);
+    }
+
+  return octave_value (y);
 }
--- a/libinterp/corefcn/colloc.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/colloc.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -48,31 +48,19 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (! args(0).is_scalar_type ())
-    {
-      error ("colloc: N must be a scalar");
-      return retval;
-    }
+    error ("colloc: N must be a scalar");
 
   double tmp = args(0).double_value ();
 
   if (xisnan (tmp))
-    {
-      error ("colloc: N cannot be NaN");
-      return retval;
-    }
+    error ("colloc: N cannot be NaN");
 
   octave_idx_type ncol = NINTbig (tmp);
   if (ncol < 0)
-    {
-      error ("colloc: N must be positive");
-      return retval;
-    }
+    error ("colloc: N must be positive");
 
   octave_idx_type ntot = ncol;
   octave_idx_type left = 0;
--- a/libinterp/corefcn/conv2.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/conv2.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -69,31 +69,26 @@
   int nargin = args.length ();
   std::string shape = "full";   // default
   bool separable = false;
-  convn_type ct;
+  convn_type ct = convn_full;
 
-  if (nargin < 2)
-    {
-      print_usage ();
-      return retval;
-    }
-  else if (nargin == 3)
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+
+  if (nargin == 3)
     {
       if (args(2).is_string ())
         shape = args(2).string_value ();
       else
         separable = true;
     }
-  else if (nargin >= 4)
+  else if (nargin == 4)
     {
       separable = true;
       shape = args(3).string_value ();
     }
 
   if (args(0).ndims () > 2 || args(1).ndims () > 2)
-    {
-      error ("conv2: A and B must be 1-D vectors or 2-D matrices");
-      return retval;
-    }
+    error ("conv2: A and B must be 1-D vectors or 2-D matrices");
 
   if (shape == "full")
     ct = convn_full;
@@ -102,11 +97,7 @@
   else if (shape == "valid")
     ct = convn_valid;
   else
-    {
-      error ("conv2: SHAPE type not valid");
-      print_usage ();
-      return retval;
-    }
+    error ("conv2: SHAPE type not valid");
 
   if (separable)
     {
@@ -114,10 +105,7 @@
 
       if (! (1 == args(0).rows () || 1 == args(0).columns ())
           || ! (1 == args(1).rows () || 1 == args(1).columns ()))
-        {
-          print_usage ();
-          return retval;
-        }
+        error ("conv2: arguments must be vectors for separable option");
 
       if (args(0).is_single_type () || args(1).is_single_type ()
           || args(2).is_single_type ())
@@ -321,14 +309,12 @@
   octave_value tmp;
   int nargin = args.length ();
   std::string shape = "full";   // default
-  convn_type ct;
+  convn_type ct = convn_full;
 
   if (nargin < 2 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
-  else if (nargin == 3)
+    print_usage ();
+
+  if (nargin == 3)
     shape = args(2).xstring_value ("convn: SHAPE must be a string");
 
   if (shape == "full")
@@ -338,11 +324,7 @@
   else if (shape == "valid")
     ct = convn_valid;
   else
-    {
-      error ("convn: SHAPE type not valid");
-      print_usage ();
-      return retval;
-    }
+    error ("convn: SHAPE type not valid");
 
   if (args(0).is_single_type () || args(1).is_single_type ())
     {
--- a/libinterp/corefcn/daspk.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/daspk.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -292,177 +292,175 @@
 
   int nargin = args.length ();
 
-  if (nargin > 3 && nargin < 6)
+  if (nargin < 4 || nargin > 5)
+    print_usage ();
+
+  std::string fcn_name, fname, jac_name, jname;
+  daspk_fcn = 0;
+  daspk_jac = 0;
+
+  octave_value f_arg = args(0);
+
+  if (f_arg.is_cell ())
     {
-      std::string fcn_name, fname, jac_name, jname;
-      daspk_fcn = 0;
-      daspk_jac = 0;
-
-      octave_value f_arg = args(0);
+      Cell c = f_arg.cell_value ();
+      if (c.numel () == 1)
+        f_arg = c(0);
+      else if (c.numel () == 2)
+        {
+          if (c(0).is_function_handle () || c(0).is_inline_function ())
+            daspk_fcn = c(0).function_value ();
+          else
+            {
+              fcn_name = unique_symbol_name ("__daspk_fcn__");
+              fname = "function y = ";
+              fname.append (fcn_name);
+              fname.append (" (x, xdot, t) y = ");
+              daspk_fcn = extract_function
+                (c(0), "daspk", fcn_name, fname, "; endfunction");
+            }
 
-      if (f_arg.is_cell ())
+          if (daspk_fcn)
+            {
+              if (c(1).is_function_handle () || c(1).is_inline_function ())
+                daspk_jac = c(1).function_value ();
+              else
+                {
+                  jac_name = unique_symbol_name ("__daspk_jac__");
+                  jname = "function jac = ";
+                  jname.append (jac_name);
+                  jname.append (" (x, xdot, t, cj) jac = ");
+                  daspk_jac = extract_function (c(1), "daspk", jac_name,
+                                                jname, "; endfunction");
+
+                  if (!daspk_jac)
+                    {
+                      if (fcn_name.length ())
+                        clear_function (fcn_name);
+                      daspk_fcn = 0;
+                    }
+                }
+            }
+        }
+      else
+        DASPK_ABORT1 ("incorrect number of elements in cell array");
+    }
+
+  if (!daspk_fcn && ! f_arg.is_cell ())
+    {
+      if (f_arg.is_function_handle () || f_arg.is_inline_function ())
+        daspk_fcn = f_arg.function_value ();
+      else
         {
-          Cell c = f_arg.cell_value ();
-          if (c.numel () == 1)
-            f_arg = c(0);
-          else if (c.numel () == 2)
+          switch (f_arg.rows ())
             {
-              if (c(0).is_function_handle () || c(0).is_inline_function ())
-                daspk_fcn = c(0).function_value ();
-              else
+            case 1:
+              do
                 {
                   fcn_name = unique_symbol_name ("__daspk_fcn__");
                   fname = "function y = ";
                   fname.append (fcn_name);
                   fname.append (" (x, xdot, t) y = ");
-                  daspk_fcn = extract_function
-                              (c(0), "daspk", fcn_name, fname, "; endfunction");
+                  daspk_fcn = extract_function (f_arg, "daspk", fcn_name,
+                                                fname, "; endfunction");
                 }
+              while (0);
+              break;
 
-              if (daspk_fcn)
-                {
-                  if (c(1).is_function_handle () || c(1).is_inline_function ())
-                    daspk_jac = c(1).function_value ();
-                  else
-                    {
-                      jac_name = unique_symbol_name ("__daspk_jac__");
-                      jname = "function jac = ";
-                      jname.append (jac_name);
-                      jname.append (" (x, xdot, t, cj) jac = ");
-                      daspk_jac = extract_function (c(1), "daspk", jac_name,
-                                                    jname, "; endfunction");
-
-                      if (!daspk_jac)
-                        {
-                          if (fcn_name.length ())
-                            clear_function (fcn_name);
-                          daspk_fcn = 0;
-                        }
-                    }
-                }
-            }
-          else
-            DASPK_ABORT1 ("incorrect number of elements in cell array");
-        }
+            case 2:
+              {
+                string_vector tmp = f_arg.all_strings ();
 
-      if (!daspk_fcn && ! f_arg.is_cell ())
-        {
-          if (f_arg.is_function_handle () || f_arg.is_inline_function ())
-            daspk_fcn = f_arg.function_value ();
-          else
-            {
-              switch (f_arg.rows ())
-                {
-                case 1:
-                  do
-                    {
-                      fcn_name = unique_symbol_name ("__daspk_fcn__");
-                      fname = "function y = ";
-                      fname.append (fcn_name);
-                      fname.append (" (x, xdot, t) y = ");
-                      daspk_fcn = extract_function (f_arg, "daspk", fcn_name,
-                                                    fname, "; endfunction");
-                    }
-                  while (0);
-                  break;
+                fcn_name = unique_symbol_name ("__daspk_fcn__");
+                fname = "function y = ";
+                fname.append (fcn_name);
+                fname.append (" (x, xdot, t) y = ");
+                daspk_fcn = extract_function (tmp(0), "daspk", fcn_name,
+                                              fname, "; endfunction");
 
-                case 2:
+                if (daspk_fcn)
                   {
-                    string_vector tmp = f_arg.all_strings ();
+                    jac_name = unique_symbol_name ("__daspk_jac__");
+                    jname = "function jac = ";
+                    jname.append (jac_name);
+                    jname.append (" (x, xdot, t, cj) jac = ");
+                    daspk_jac = extract_function (tmp(1), "daspk",
+                                                  jac_name, jname,
+                                                  "; endfunction");
 
-                    fcn_name = unique_symbol_name ("__daspk_fcn__");
-                    fname = "function y = ";
-                    fname.append (fcn_name);
-                    fname.append (" (x, xdot, t) y = ");
-                    daspk_fcn = extract_function (tmp(0), "daspk", fcn_name,
-                                                  fname, "; endfunction");
-
-                    if (daspk_fcn)
+                    if (!daspk_jac)
                       {
-                        jac_name = unique_symbol_name ("__daspk_jac__");
-                        jname = "function jac = ";
-                        jname.append (jac_name);
-                        jname.append (" (x, xdot, t, cj) jac = ");
-                        daspk_jac = extract_function (tmp(1), "daspk",
-                                                      jac_name, jname,
-                                                      "; endfunction");
-
-                        if (!daspk_jac)
-                          {
-                            if (fcn_name.length ())
-                              clear_function (fcn_name);
-                            daspk_fcn = 0;
-                          }
+                        if (fcn_name.length ())
+                          clear_function (fcn_name);
+                        daspk_fcn = 0;
                       }
                   }
-                }
+              }
             }
         }
+    }
 
-      if (! daspk_fcn)
-        DASPK_ABORT ();
+  if (! daspk_fcn)
+    DASPK_ABORT ();
 
-      ColumnVector state = args(1).xvector_value ("daspk: initial state X_0 must be a vector");
+  ColumnVector state = args(1).xvector_value ("daspk: initial state X_0 must be a vector");
 
-      ColumnVector deriv = args(2).xvector_value ("daspk: initial derivatives XDOT_0 must be a vector");
+  ColumnVector deriv = args(2).xvector_value ("daspk: initial derivatives XDOT_0 must be a vector");
 
-      ColumnVector out_times = args(3).xvector_value ("daspk: output time variable T must be a vector");
+  ColumnVector out_times = args(3).xvector_value ("daspk: output time variable T must be a vector");
 
-      ColumnVector crit_times;
-      int crit_times_set = 0;
-      if (nargin > 4)
-        {
-          crit_times = args(4).xvector_value ("daspk: list of critical times T_CRIT must be a vector");
-
-          crit_times_set = 1;
-        }
+  ColumnVector crit_times;
+  int crit_times_set = 0;
+  if (nargin > 4)
+    {
+      crit_times = args(4).xvector_value ("daspk: list of critical times T_CRIT must be a vector");
 
-      if (state.numel () != deriv.numel ())
-        DASPK_ABORT1 ("X_0 and XDOT_0 must have the same size");
-
-      double tzero = out_times (0);
+      crit_times_set = 1;
+    }
 
-      DAEFunc func (daspk_user_function);
-      if (daspk_jac)
-        func.set_jacobian_function (daspk_user_jacobian);
+  if (state.numel () != deriv.numel ())
+    DASPK_ABORT1 ("X_0 and XDOT_0 must have the same size");
 
-      DASPK dae (state, deriv, tzero, func);
-      dae.set_options (daspk_opts);
+  double tzero = out_times (0);
 
-      Matrix output;
-      Matrix deriv_output;
+  DAEFunc func (daspk_user_function);
+  if (daspk_jac)
+    func.set_jacobian_function (daspk_user_jacobian);
+
+  DASPK dae (state, deriv, tzero, func);
+  dae.set_options (daspk_opts);
 
-      if (crit_times_set)
-        output = dae.integrate (out_times, deriv_output, crit_times);
-      else
-        output = dae.integrate (out_times, deriv_output);
+  Matrix output;
+  Matrix deriv_output;
 
-      if (fcn_name.length ())
-        clear_function (fcn_name);
-      if (jac_name.length ())
-        clear_function (jac_name);
-
-      std::string msg = dae.error_message ();
+  if (crit_times_set)
+    output = dae.integrate (out_times, deriv_output, crit_times);
+  else
+    output = dae.integrate (out_times, deriv_output);
 
-      retval(3) = msg;
-      retval(2) = static_cast<double> (dae.integration_state ());
+  if (fcn_name.length ())
+    clear_function (fcn_name);
+  if (jac_name.length ())
+    clear_function (jac_name);
+
+  std::string msg = dae.error_message ();
 
-      if (dae.integration_ok ())
-        {
-          retval(1) = deriv_output;
-          retval(0) = output;
-        }
-      else
-        {
-          retval(1) = Matrix ();
-          retval(0) = Matrix ();
+  retval(3) = msg;
+  retval(2) = static_cast<double> (dae.integration_state ());
 
-          if (nargout < 3)
-            error ("daspk: %s", msg.c_str ());
-        }
+  if (dae.integration_ok ())
+    {
+      retval(1) = deriv_output;
+      retval(0) = output;
     }
   else
-    print_usage ();
+    {
+      retval(1) = Matrix ();
+      retval(0) = Matrix ();
+
+      if (nargout < 3)
+        error ("daspk: %s", msg.c_str ());
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/dasrt.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/dasrt.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -370,16 +370,12 @@
   if (call_depth > 1)
     DASRT_ABORT1 ("invalid recursive call");
 
-  int argp = 0;
-
   int nargin = args.length ();
 
   if (nargin < 4 || nargin > 6)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
+  int argp = 0;
   std::string fcn_name, fname, jac_name, jname;
   dasrt_f = 0;
   dasrt_j = 0;
--- a/libinterp/corefcn/dassl.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/dassl.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -293,178 +293,176 @@
 
   int nargin = args.length ();
 
-  if (nargin > 3 && nargin < 6 && nargout < 5)
+  if (nargin < 4 || nargin > 5 || nargout > 4)
+    print_usage ();
+
+  std::string fcn_name, fname, jac_name, jname;
+  dassl_fcn = 0;
+  dassl_jac = 0;
+
+  octave_value f_arg = args(0);
+
+  if (f_arg.is_cell ())
     {
-      std::string fcn_name, fname, jac_name, jname;
-      dassl_fcn = 0;
-      dassl_jac = 0;
-
-      octave_value f_arg = args(0);
+      Cell c = f_arg.cell_value ();
+      if (c.numel () == 1)
+        f_arg = c(0);
+      else if (c.numel () == 2)
+        {
+          if (c(0).is_function_handle () || c(0).is_inline_function ())
+            dassl_fcn = c(0).function_value ();
+          else
+            {
+              fcn_name = unique_symbol_name ("__dassl_fcn__");
+              fname = "function y = ";
+              fname.append (fcn_name);
+              fname.append (" (x, xdot, t) y = ");
+              dassl_fcn = extract_function (c(0), "dassl", fcn_name, fname,
+                                            "; endfunction");
+            }
 
-      if (f_arg.is_cell ())
+          if (dassl_fcn)
+            {
+              if (c(1).is_function_handle () || c(1).is_inline_function ())
+                dassl_jac = c(1).function_value ();
+              else
+                {
+                  jac_name = unique_symbol_name ("__dassl_jac__");
+                  jname = "function jac = ";
+                  jname.append (jac_name);
+                  jname.append (" (x, xdot, t, cj) jac = ");
+                  dassl_jac = extract_function (c(1), "dassl", jac_name,
+                                                jname, "; endfunction");
+
+                  if (!dassl_jac)
+                    {
+                      if (fcn_name.length ())
+                        clear_function (fcn_name);
+                      dassl_fcn = 0;
+                    }
+                }
+            }
+        }
+      else
+        DASSL_ABORT1 ("incorrect number of elements in cell array");
+    }
+
+  if (!dassl_fcn && ! f_arg.is_cell ())
+    {
+      if (f_arg.is_function_handle () || f_arg.is_inline_function ())
+        dassl_fcn = f_arg.function_value ();
+      else
         {
-          Cell c = f_arg.cell_value ();
-          if (c.numel () == 1)
-            f_arg = c(0);
-          else if (c.numel () == 2)
+          switch (f_arg.rows ())
             {
-              if (c(0).is_function_handle () || c(0).is_inline_function ())
-                dassl_fcn = c(0).function_value ();
-              else
+            case 1:
+              do
                 {
                   fcn_name = unique_symbol_name ("__dassl_fcn__");
                   fname = "function y = ";
                   fname.append (fcn_name);
                   fname.append (" (x, xdot, t) y = ");
-                  dassl_fcn = extract_function (c(0), "dassl", fcn_name, fname,
-                                                "; endfunction");
+                  dassl_fcn = extract_function (f_arg, "dassl", fcn_name,
+                                                fname, "; endfunction");
                 }
+              while (0);
+              break;
 
-              if (dassl_fcn)
-                {
-                  if (c(1).is_function_handle () || c(1).is_inline_function ())
-                    dassl_jac = c(1).function_value ();
-                  else
-                    {
-                      jac_name = unique_symbol_name ("__dassl_jac__");
-                      jname = "function jac = ";
-                      jname.append (jac_name);
-                      jname.append (" (x, xdot, t, cj) jac = ");
-                      dassl_jac = extract_function (c(1), "dassl", jac_name,
-                                                    jname, "; endfunction");
-
-                      if (!dassl_jac)
-                        {
-                          if (fcn_name.length ())
-                            clear_function (fcn_name);
-                          dassl_fcn = 0;
-                        }
-                    }
-                }
-            }
-          else
-            DASSL_ABORT1 ("incorrect number of elements in cell array");
-        }
+            case 2:
+              {
+                string_vector tmp = f_arg.all_strings ();
 
-      if (!dassl_fcn && ! f_arg.is_cell ())
-        {
-          if (f_arg.is_function_handle () || f_arg.is_inline_function ())
-            dassl_fcn = f_arg.function_value ();
-          else
-            {
-              switch (f_arg.rows ())
-                {
-                case 1:
-                  do
-                    {
-                      fcn_name = unique_symbol_name ("__dassl_fcn__");
-                      fname = "function y = ";
-                      fname.append (fcn_name);
-                      fname.append (" (x, xdot, t) y = ");
-                      dassl_fcn = extract_function (f_arg, "dassl", fcn_name,
-                                                    fname, "; endfunction");
-                    }
-                  while (0);
-                  break;
+                fcn_name = unique_symbol_name ("__dassl_fcn__");
+                fname = "function y = ";
+                fname.append (fcn_name);
+                fname.append (" (x, xdot, t) y = ");
+                dassl_fcn = extract_function (tmp(0), "dassl", fcn_name,
+                                              fname, "; endfunction");
 
-                case 2:
+                if (dassl_fcn)
                   {
-                    string_vector tmp = f_arg.all_strings ();
+                    jac_name = unique_symbol_name ("__dassl_jac__");
+                    jname = "function jac = ";
+                    jname.append (jac_name);
+                    jname.append (" (x, xdot, t, cj) jac = ");
+                    dassl_jac = extract_function (tmp(1), "dassl",
+                                                  jac_name, jname,
+                                                  "; endfunction");
 
-                    fcn_name = unique_symbol_name ("__dassl_fcn__");
-                    fname = "function y = ";
-                    fname.append (fcn_name);
-                    fname.append (" (x, xdot, t) y = ");
-                    dassl_fcn = extract_function (tmp(0), "dassl", fcn_name,
-                                                  fname, "; endfunction");
-
-                    if (dassl_fcn)
+                    if (!dassl_jac)
                       {
-                        jac_name = unique_symbol_name ("__dassl_jac__");
-                        jname = "function jac = ";
-                        jname.append (jac_name);
-                        jname.append (" (x, xdot, t, cj) jac = ");
-                        dassl_jac = extract_function (tmp(1), "dassl",
-                                                      jac_name, jname,
-                                                      "; endfunction");
-
-                        if (!dassl_jac)
-                          {
-                            if (fcn_name.length ())
-                              clear_function (fcn_name);
-                            dassl_fcn = 0;
-                          }
+                        if (fcn_name.length ())
+                          clear_function (fcn_name);
+                        dassl_fcn = 0;
                       }
                   }
-                }
+              }
             }
         }
-
-      if (! dassl_fcn)
-        DASSL_ABORT ();
+    }
 
-      ColumnVector state = args(1).xvector_value ("dassl: initial state X_0 must be a vector");
-
-      ColumnVector deriv = args(2).xvector_value ("dassl: initial derivatives XDOT_0 must be a vector");
+  if (! dassl_fcn)
+    DASSL_ABORT ();
 
-      ColumnVector out_times = args(3).xvector_value ("dassl: output time variable T must be a vector");
+  ColumnVector state = args(1).xvector_value ("dassl: initial state X_0 must be a vector");
 
-      ColumnVector crit_times;
-      int crit_times_set = 0;
-      if (nargin > 4)
-        {
-          crit_times = args(4).xvector_value ("dassl: list of critical times T_CRIT must be a vector");
+  ColumnVector deriv = args(2).xvector_value ("dassl: initial derivatives XDOT_0 must be a vector");
+
+  ColumnVector out_times = args(3).xvector_value ("dassl: output time variable T must be a vector");
 
-          crit_times_set = 1;
-        }
-
-      if (state.numel () != deriv.numel ())
-        DASSL_ABORT1 ("X and XDOT_0 must have the same size");
-
-      double tzero = out_times (0);
+  ColumnVector crit_times;
+  int crit_times_set = 0;
+  if (nargin > 4)
+    {
+      crit_times = args(4).xvector_value ("dassl: list of critical times T_CRIT must be a vector");
 
-      DAEFunc func (dassl_user_function);
-      if (dassl_jac)
-        func.set_jacobian_function (dassl_user_jacobian);
+      crit_times_set = 1;
+    }
 
-      DASSL dae (state, deriv, tzero, func);
+  if (state.numel () != deriv.numel ())
+    DASSL_ABORT1 ("X and XDOT_0 must have the same size");
 
-      dae.set_options (dassl_opts);
+  double tzero = out_times (0);
 
-      Matrix output;
-      Matrix deriv_output;
+  DAEFunc func (dassl_user_function);
+  if (dassl_jac)
+    func.set_jacobian_function (dassl_user_jacobian);
 
-      if (crit_times_set)
-        output = dae.integrate (out_times, deriv_output, crit_times);
-      else
-        output = dae.integrate (out_times, deriv_output);
+  DASSL dae (state, deriv, tzero, func);
 
-      if (fcn_name.length ())
-        clear_function (fcn_name);
-      if (jac_name.length ())
-        clear_function (jac_name);
+  dae.set_options (dassl_opts);
 
-      std::string msg = dae.error_message ();
+  Matrix output;
+  Matrix deriv_output;
 
-      retval(3) = msg;
-      retval(2) = static_cast<double> (dae.integration_state ());
+  if (crit_times_set)
+    output = dae.integrate (out_times, deriv_output, crit_times);
+  else
+    output = dae.integrate (out_times, deriv_output);
+
+  if (fcn_name.length ())
+    clear_function (fcn_name);
+  if (jac_name.length ())
+    clear_function (jac_name);
 
-      if (dae.integration_ok ())
-        {
-          retval(1) = deriv_output;
-          retval(0) = output;
-        }
-      else
-        {
-          retval(1) = Matrix ();
-          retval(0) = Matrix ();
+  std::string msg = dae.error_message ();
+
+  retval(3) = msg;
+  retval(2) = static_cast<double> (dae.integration_state ());
 
-          if (nargout < 3)
-            error ("dassl: %s", msg.c_str ());
-        }
+  if (dae.integration_ok ())
+    {
+      retval(1) = deriv_output;
+      retval(0) = output;
     }
   else
-    print_usage ();
+    {
+      retval(1) = Matrix ();
+      retval(0) = Matrix ();
+
+      if (nargout < 3)
+        error ("dassl: %s", msg.c_str ());
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/data.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/data.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -94,17 +94,15 @@
  \
   int nargin = args.length (); \
  \
-  if (nargin == 1 || nargin == 2) \
-    { \
-      int dim = (nargin == 1 ? -1 : args(1).int_value (#FCN ": DIM must be an integer") - 1); \
+  if (nargin < 1 || nargin > 2) \
+    print_usage (); \
+ \
+  int dim = (nargin == 1 ? -1 : args(1).int_value (#FCN ": DIM must be an integer") - 1); \
  \
-      if (dim >= -1) \
-        retval = args(0).FCN (dim); \
-      else \
-        error (#FCN ": invalid dimension argument = %d", dim + 1); \
-    } \
+  if (dim >= -1) \
+    retval = args(0).FCN (dim); \
   else \
-    print_usage (); \
+    error (#FCN ": invalid dimension argument = %d", dim + 1); \
  \
   return retval
 
@@ -223,47 +221,43 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("atan2", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("atan2", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("atan2: not defined for complex numbers");
+  else if (args(0).is_single_type () || args(1).is_single_type ())
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("atan2", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("atan2", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("atan2: not defined for complex numbers");
-      else if (args(0).is_single_type () || args(1).is_single_type ())
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = atan2f (args(0).float_value (), args(1).float_value ());
+      else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = atan2f (args(0).float_value (), args(1).float_value ());
-          else
-            {
-              FloatNDArray a0 = args(0).float_array_value ();
-              FloatNDArray a1 = args(1).float_array_value ();
-              retval = binmap<float> (a0, a1, ::atan2f, "atan2");
-            }
+          FloatNDArray a0 = args(0).float_array_value ();
+          FloatNDArray a1 = args(1).float_array_value ();
+          retval = binmap<float> (a0, a1, ::atan2f, "atan2");
+        }
+    }
+  else
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = atan2 (args(0).scalar_value (), args(1).scalar_value ());
+      else if (args(0).is_sparse_type ())
+        {
+          SparseMatrix m0 = args(0).sparse_matrix_value ();
+          SparseMatrix m1 = args(1).sparse_matrix_value ();
+          retval = binmap<double> (m0, m1, ::atan2, "atan2");
         }
       else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = atan2 (args(0).scalar_value (), args(1).scalar_value ());
-          else if (args(0).is_sparse_type ())
-            {
-              SparseMatrix m0 = args(0).sparse_matrix_value ();
-              SparseMatrix m1 = args(1).sparse_matrix_value ();
-              retval = binmap<double> (m0, m1, ::atan2, "atan2");
-            }
-          else
-            {
-              NDArray a0 = args(0).array_value ();
-              NDArray a1 = args(1).array_value ();
-              retval = binmap<double> (a0, a1, ::atan2, "atan2");
-            }
+          NDArray a0 = args(0).array_value ();
+          NDArray a1 = args(1).array_value ();
+          retval = binmap<double> (a0, a1, ::atan2, "atan2");
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -407,18 +401,18 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2)
+    print_usage ();
+
   if (nargin == 2)
-    {
-      retval = do_hypot (args(0), args(1));
-    }
-  else if (nargin >= 3)
+    retval = do_hypot (args(0), args(1));
+  else
     {
       retval = args(0);
+
       for (int i = 1; i < nargin; i++)
         retval = do_hypot (retval, args(i));
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -502,58 +496,56 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  if (nargout < 2)
+    retval(0) = args(0).log2 ();
+  else if (args(0).is_single_type ())
     {
-      if (nargout < 2)
-        retval(0) = args(0).log2 ();
-      else if (args(0).is_single_type ())
+      if (args(0).is_real_type ())
         {
-          if (args(0).is_real_type ())
-            {
-              FloatNDArray f;
-              FloatNDArray x = args(0).float_array_value ();
-              // FIXME: should E be an int value?
-              FloatMatrix e;
-              map_2_xlog2 (x, f, e);
-              retval(1) = e;
-              retval(0) = f;
-            }
-          else if (args(0).is_complex_type ())
-            {
-              FloatComplexNDArray f;
-              FloatComplexNDArray x = args(0).float_complex_array_value ();
-              // FIXME: should E be an int value?
-              FloatNDArray e;
-              map_2_xlog2 (x, f, e);
-              retval(1) = e;
-              retval(0) = f;
-            }
-        }
-      else if (args(0).is_real_type ())
-        {
-          NDArray f;
-          NDArray x = args(0).array_value ();
+          FloatNDArray f;
+          FloatNDArray x = args(0).float_array_value ();
           // FIXME: should E be an int value?
-          Matrix e;
+          FloatMatrix e;
           map_2_xlog2 (x, f, e);
           retval(1) = e;
           retval(0) = f;
         }
       else if (args(0).is_complex_type ())
         {
-          ComplexNDArray f;
-          ComplexNDArray x = args(0).complex_array_value ();
+          FloatComplexNDArray f;
+          FloatComplexNDArray x = args(0).float_complex_array_value ();
           // FIXME: should E be an int value?
-          NDArray e;
+          FloatNDArray e;
           map_2_xlog2 (x, f, e);
           retval(1) = e;
           retval(0) = f;
         }
-      else
-        gripe_wrong_type_arg ("log2", args(0));
+    }
+  else if (args(0).is_real_type ())
+    {
+      NDArray f;
+      NDArray x = args(0).array_value ();
+      // FIXME: should E be an int value?
+      Matrix e;
+      map_2_xlog2 (x, f, e);
+      retval(1) = e;
+      retval(0) = f;
+    }
+  else if (args(0).is_complex_type ())
+    {
+      ComplexNDArray f;
+      ComplexNDArray x = args(0).complex_array_value ();
+      // FIXME: should E be an int value?
+      NDArray e;
+      map_2_xlog2 (x, f, e);
+      retval(1) = e;
+      retval(0) = f;
     }
   else
-    print_usage ();
+    gripe_wrong_type_arg ("log2", args(0));
 
   return retval;
 }
@@ -616,86 +608,85 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("rem", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("rem", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("rem: not defined for complex numbers");
+  else if (args(0).is_integer_type () || args(1).is_integer_type ())
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("rem", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("rem", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("rem: not defined for complex numbers");
-      else if (args(0).is_integer_type () || args(1).is_integer_type ())
+      builtin_type_t btyp0 = args(0).builtin_type ();
+      builtin_type_t btyp1 = args(1).builtin_type ();
+      if (btyp0 == btyp_double || btyp0 == btyp_float)
+        btyp0 = btyp1;
+      if (btyp1 == btyp_double || btyp1 == btyp_float)
+        btyp1 = btyp0;
+
+      if (btyp0 == btyp1)
         {
-          builtin_type_t btyp0 = args(0).builtin_type ();
-          builtin_type_t btyp1 = args(1).builtin_type ();
-          if (btyp0 == btyp_double || btyp0 == btyp_float)
-            btyp0 = btyp1;
-          if (btyp1 == btyp_double || btyp1 == btyp_float)
-            btyp1 = btyp0;
-
-          if (btyp0 == btyp1)
+          switch (btyp0)
             {
-              switch (btyp0)
-                {
 #define MAKE_INT_BRANCH(X) \
-                case btyp_ ## X: \
-                    { \
-                    X##NDArray a0 = args(0).X##_array_value (); \
-                    X##NDArray a1 = args(1).X##_array_value (); \
-                    retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
-                    } \
-                  break;
-                MAKE_INT_BRANCH (int8);
-                MAKE_INT_BRANCH (int16);
-                MAKE_INT_BRANCH (int32);
-                MAKE_INT_BRANCH (int64);
-                MAKE_INT_BRANCH (uint8);
-                MAKE_INT_BRANCH (uint16);
-                MAKE_INT_BRANCH (uint32);
-                MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    { \
+      X##NDArray a0 = args(0).X##_array_value (); \
+      X##NDArray a1 = args(1).X##_array_value (); \
+      retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
+    } \
+    break;
+
+              MAKE_INT_BRANCH (int8);
+              MAKE_INT_BRANCH (int16);
+              MAKE_INT_BRANCH (int32);
+              MAKE_INT_BRANCH (int64);
+              MAKE_INT_BRANCH (uint8);
+              MAKE_INT_BRANCH (uint16);
+              MAKE_INT_BRANCH (uint32);
+              MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
-                default:
-                  panic_impossible ();
-                }
-            }
-          else
-            error ("rem: cannot combine %s and %d",
-                   args(0).class_name ().c_str (),
-                   args(1).class_name ().c_str ());
-        }
-      else if (args(0).is_single_type () || args(1).is_single_type ())
-        {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xrem (args(0).float_value (), args(1).float_value ());
-          else
-            {
-              FloatNDArray a0 = args(0).float_array_value ();
-              FloatNDArray a1 = args(1).float_array_value ();
-              retval = binmap<float> (a0, a1, xrem<float>, "rem");
+
+            default:
+              panic_impossible ();
             }
         }
       else
+        error ("rem: cannot combine %s and %d",
+               args(0).class_name ().c_str (),
+               args(1).class_name ().c_str ());
+    }
+  else if (args(0).is_single_type () || args(1).is_single_type ())
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xrem (args(0).float_value (), args(1).float_value ());
+      else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xrem (args(0).scalar_value (), args(1).scalar_value ());
-          else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
-            {
-              SparseMatrix m0 = args(0).sparse_matrix_value ();
-              SparseMatrix m1 = args(1).sparse_matrix_value ();
-              retval = binmap<double> (m0, m1, xrem<double>, "rem");
-            }
-          else
-            {
-              NDArray a0 = args(0).array_value ();
-              NDArray a1 = args(1).array_value ();
-              retval = binmap<double> (a0, a1, xrem<double>, "rem");
-            }
+          FloatNDArray a0 = args(0).float_array_value ();
+          FloatNDArray a1 = args(1).float_array_value ();
+          retval = binmap<float> (a0, a1, xrem<float>, "rem");
         }
     }
   else
-    print_usage ();
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xrem (args(0).scalar_value (), args(1).scalar_value ());
+      else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
+        {
+          SparseMatrix m0 = args(0).sparse_matrix_value ();
+          SparseMatrix m1 = args(1).sparse_matrix_value ();
+          retval = binmap<double> (m0, m1, xrem<double>, "rem");
+        }
+      else
+        {
+          NDArray a0 = args(0).array_value ();
+          NDArray a1 = args(1).array_value ();
+          retval = binmap<double> (a0, a1, xrem<double>, "rem");
+        }
+    }
 
   return retval;
 }
@@ -797,86 +788,85 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("mod", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("mod", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("mod: not defined for complex numbers");
+  else if (args(0).is_integer_type () || args(1).is_integer_type ())
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("mod", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("mod", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("mod: not defined for complex numbers");
-      else if (args(0).is_integer_type () || args(1).is_integer_type ())
+      builtin_type_t btyp0 = args(0).builtin_type ();
+      builtin_type_t btyp1 = args(1).builtin_type ();
+      if (btyp0 == btyp_double || btyp0 == btyp_float)
+        btyp0 = btyp1;
+      if (btyp1 == btyp_double || btyp1 == btyp_float)
+        btyp1 = btyp0;
+
+      if (btyp0 == btyp1)
         {
-          builtin_type_t btyp0 = args(0).builtin_type ();
-          builtin_type_t btyp1 = args(1).builtin_type ();
-          if (btyp0 == btyp_double || btyp0 == btyp_float)
-            btyp0 = btyp1;
-          if (btyp1 == btyp_double || btyp1 == btyp_float)
-            btyp1 = btyp0;
-
-          if (btyp0 == btyp1)
+          switch (btyp0)
             {
-              switch (btyp0)
-                {
 #define MAKE_INT_BRANCH(X) \
-                case btyp_ ## X: \
-                    { \
-                    X##NDArray a0 = args(0).X##_array_value (); \
-                    X##NDArray a1 = args(1).X##_array_value (); \
-                    retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
-                    } \
-                  break;
-                MAKE_INT_BRANCH (int8);
-                MAKE_INT_BRANCH (int16);
-                MAKE_INT_BRANCH (int32);
-                MAKE_INT_BRANCH (int64);
-                MAKE_INT_BRANCH (uint8);
-                MAKE_INT_BRANCH (uint16);
-                MAKE_INT_BRANCH (uint32);
-                MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    { \
+      X##NDArray a0 = args(0).X##_array_value (); \
+      X##NDArray a1 = args(1).X##_array_value (); \
+      retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
+    } \
+    break;
+
+              MAKE_INT_BRANCH (int8);
+              MAKE_INT_BRANCH (int16);
+              MAKE_INT_BRANCH (int32);
+              MAKE_INT_BRANCH (int64);
+              MAKE_INT_BRANCH (uint8);
+              MAKE_INT_BRANCH (uint16);
+              MAKE_INT_BRANCH (uint32);
+              MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
-                default:
-                  panic_impossible ();
-                }
-            }
-          else
-            error ("mod: cannot combine %s and %d",
-                   args(0).class_name ().c_str (),
-                   args(1).class_name ().c_str ());
-        }
-      else if (args(0).is_single_type () || args(1).is_single_type ())
-        {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xmod (args(0).float_value (), args(1).float_value ());
-          else
-            {
-              FloatNDArray a0 = args(0).float_array_value ();
-              FloatNDArray a1 = args(1).float_array_value ();
-              retval = binmap<float> (a0, a1, xmod<float>, "mod");
+
+            default:
+              panic_impossible ();
             }
         }
       else
+        error ("mod: cannot combine %s and %d",
+               args(0).class_name ().c_str (),
+               args(1).class_name ().c_str ());
+    }
+  else if (args(0).is_single_type () || args(1).is_single_type ())
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xmod (args(0).float_value (), args(1).float_value ());
+      else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xmod (args(0).scalar_value (), args(1).scalar_value ());
-          else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
-            {
-              SparseMatrix m0 = args(0).sparse_matrix_value ();
-              SparseMatrix m1 = args(1).sparse_matrix_value ();
-              retval = binmap<double> (m0, m1, xmod<double>, "mod");
-            }
-          else
-            {
-              NDArray a0 = args(0).array_value ();
-              NDArray a1 = args(1).array_value ();
-              retval = binmap<double> (a0, a1, xmod<double>, "mod");
-            }
+          FloatNDArray a0 = args(0).float_array_value ();
+          FloatNDArray a1 = args(1).float_array_value ();
+          retval = binmap<float> (a0, a1, xmod<float>, "mod");
         }
     }
   else
-    print_usage ();
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xmod (args(0).scalar_value (), args(1).scalar_value ());
+      else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
+        {
+          SparseMatrix m0 = args(0).sparse_matrix_value ();
+          SparseMatrix m1 = args(1).sparse_matrix_value ();
+          retval = binmap<double> (m0, m1, xmod<double>, "mod");
+        }
+      else
+        {
+          NDArray a0 = args(0).array_value ();
+          NDArray a1 = args(1).array_value ();
+          retval = binmap<double> (a0, a1, xmod<double>, "mod");
+        }
+    }
 
   return retval;
 }
@@ -963,107 +953,74 @@
       nargin --; \
     } \
  \
-  if (nargin == 1 || nargin == 2) \
-    { \
-      octave_value arg = args(0); \
+  if (nargin < 1 || nargin > 2) \
+    print_usage (); \
+ \
+  octave_value arg = args(0); \
  \
-      int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+  int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
  \
-      if (dim >= -1) \
+  if (dim >= -1) \
+    { \
+      if (arg.is_sparse_type ()) \
         { \
-          if (arg.is_sparse_type ()) \
+          if (arg.is_real_type ()) \
             { \
-              if (arg.is_real_type ()) \
-                { \
-                  SparseMatrix tmp = arg.sparse_matrix_value (); \
+              SparseMatrix tmp = arg.sparse_matrix_value (); \
  \
-                  retval = tmp.FCN (dim); \
-                } \
-              else \
-                { \
-                  SparseComplexMatrix tmp \
-                    = arg.sparse_complex_matrix_value (); \
- \
-                  retval = tmp.FCN (dim); \
-                } \
+              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 ()) \
-                    { \
-                      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 ()) \
-                        { \
-                          FloatComplexNDArray tmp = \
-                            arg.float_complex_array_value (); \
+              SparseComplexMatrix tmp \
+                = arg.sparse_complex_matrix_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 (); \
- \
-                      retval = tmp.FCN (dim); \
-                    } \
-                  else if (arg.is_real_type ()) \
-                    { \
-                      NDArray tmp = arg.array_value (); \
- \
-                      retval = tmp.FCN (dim); \
-                    } \
-                  else \
-                    { \
-                      gripe_wrong_type_arg (#FCN, arg); \
-                      return retval; \
-                    } \
-                } \
+              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 ()) \
                 { \
                   boolNDArray tmp = arg.bool_array_value (); \
  \
-                  retval = tmp.FCN (dim); \
+                  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_real_type ()) \
-                    { \
-                      FloatNDArray tmp = arg.float_array_value (); \
- \
-                      retval = tmp.FCN (dim); \
-                    } \
-                  else if (arg.is_complex_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 (); \
+ \
+                  retval = tmp.FCN (dim); \
                 } \
               else if (arg.is_real_type ()) \
                 { \
@@ -1071,84 +1028,45 @@
  \
                   retval = tmp.FCN (dim); \
                 } \
-              else if (arg.is_complex_type ()) \
-                { \
-                  ComplexNDArray tmp = arg.complex_array_value (); \
- \
-                  retval = tmp.FCN (dim); \
-                } \
               else \
                 { \
                   gripe_wrong_type_arg (#FCN, arg); \
                   return retval; \
                 } \
             } \
-          else \
-            error (#FCN ": invalid dimension argument = %d", dim + 1); \
-        } \
- \
-    } \
-  else \
-    print_usage (); \
- \
-  return retval
-
-#define DATA_REDUCTION(FCN) \
- \
-  octave_value retval; \
+          else if (arg.is_bool_type ()) \
+            { \
+              boolNDArray tmp = arg.bool_array_value (); \
  \
-  int nargin = args.length (); \
- \
-  if (nargin == 1 || nargin == 2) \
-    { \
-      octave_value arg = args(0); \
- \
-      int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+              retval = tmp.FCN (dim); \
+            } \
+          else if (!isdouble && arg.is_single_type ()) \
+            { \
+              if (arg.is_real_type ()) \
+                { \
+                  FloatNDArray tmp = arg.float_array_value (); \
  \
-      if (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 ()) \
+              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 \
             { \
@@ -1159,8 +1077,75 @@
       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 ()) \
+        { \
+          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 \
+        { \
+          gripe_wrong_type_arg (#FCN, arg); \
+          return retval; \
+        } \
+    } \
   else \
-    print_usage (); \
+    error (#FCN ": invalid dimension argument = %d", dim + 1); \
  \
   return retval
 
@@ -1233,87 +1218,87 @@
       nargin --;
     }
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  int dim = -1;
+  if (nargin == 2)
+    {
+      dim = args(1).int_value () - 1;
+      if (dim < 0)
+        error ("cumsum: invalid dimension argument = %d", dim + 1);
+    }
+
+  switch (arg.builtin_type ())
     {
-      octave_value arg = args(0);
-
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value () - 1;
-          if (dim < 0)
-            error ("cumsum: invalid dimension argument = %d", dim + 1);
-        }
-
-      switch (arg.builtin_type ())
-        {
-        case btyp_double:
-          if (arg.is_sparse_type ())
-            retval = arg.sparse_matrix_value ().cumsum (dim);
-          else
-            retval = arg.array_value ().cumsum (dim);
-          break;
-        case btyp_complex:
-          if (arg.is_sparse_type ())
-            retval = arg.sparse_complex_matrix_value ().cumsum (dim);
-          else
-            retval = arg.complex_array_value ().cumsum (dim);
-          break;
-        case btyp_float:
-          if (isdouble)
-            retval = arg.array_value ().cumsum (dim);
-          else
-            retval = arg.float_array_value ().cumsum (dim);
-          break;
-        case btyp_float_complex:
-          if (isdouble)
-            retval = arg.complex_array_value ().cumsum (dim);
-          else
-            retval = arg.float_complex_array_value ().cumsum (dim);
-          break;
+    case btyp_double:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_matrix_value ().cumsum (dim);
+      else
+        retval = arg.array_value ().cumsum (dim);
+      break;
+    case btyp_complex:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_complex_matrix_value ().cumsum (dim);
+      else
+        retval = arg.complex_array_value ().cumsum (dim);
+      break;
+    case btyp_float:
+      if (isdouble)
+        retval = arg.array_value ().cumsum (dim);
+      else
+        retval = arg.float_array_value ().cumsum (dim);
+      break;
+    case btyp_float_complex:
+      if (isdouble)
+        retval = arg.complex_array_value ().cumsum (dim);
+      else
+        retval = arg.float_complex_array_value ().cumsum (dim);
+      break;
 
 #define MAKE_INT_BRANCH(X) \
-          case btyp_ ## X: \
-            if (isnative) \
-              retval = arg.X ## _array_value ().cumsum (dim); \
-            else \
-              retval = arg.array_value ().cumsum (dim); \
-            break;
-          MAKE_INT_BRANCH (int8);
-          MAKE_INT_BRANCH (int16);
-          MAKE_INT_BRANCH (int32);
-          MAKE_INT_BRANCH (int64);
-          MAKE_INT_BRANCH (uint8);
-          MAKE_INT_BRANCH (uint16);
-          MAKE_INT_BRANCH (uint32);
-          MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    if (isnative) \
+      retval = arg.X ## _array_value ().cumsum (dim); \
+    else \
+      retval = arg.array_value ().cumsum (dim); \
+    break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
 
-        case btyp_bool:
-          if (arg.is_sparse_type ())
-            {
-              SparseMatrix cs = arg.sparse_matrix_value ().cumsum (dim);
-              if (isnative)
-                retval = cs != 0.0;
-              else
-                retval = cs;
-            }
+    case btyp_bool:
+      if (arg.is_sparse_type ())
+        {
+          SparseMatrix cs = arg.sparse_matrix_value ().cumsum (dim);
+          if (isnative)
+            retval = cs != 0.0;
           else
-            {
-              NDArray cs = arg.bool_array_value ().cumsum (dim);
-              if (isnative)
-                retval = cs != 0.0;
-              else
-                retval = cs;
-            }
-          break;
-
-        default:
-          gripe_wrong_type_arg ("cumsum", arg);
+            retval = cs;
         }
+      else
+        {
+          NDArray cs = arg.bool_array_value ().cumsum (dim);
+          if (isnative)
+            retval = cs != 0.0;
+          else
+            retval = cs;
+        }
+      break;
+
+    default:
+      gripe_wrong_type_arg ("cumsum", arg);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1375,15 +1360,18 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_defined ())
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+
+  if (nargin == 1)
     retval = args(0).diag ();
-  else if (nargin == 2 && args(0).is_defined () && args(1).is_defined ())
+  else if (nargin == 2)
     {
       octave_idx_type k = args(1).xint_value ("diag: invalid argument K");
 
       retval = args(0).diag (k);
     }
-  else if (nargin == 3)
+  else
     {
       octave_value arg0 = args(0);
 
@@ -1397,8 +1385,6 @@
       else
         error ("diag: V must be a vector");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1520,86 +1506,87 @@
       nargin --;
     }
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  int dim = -1;
+  if (nargin == 2)
+    {
+      dim = args(1).int_value () - 1;
+      if (dim < 0)
+        error ("prod: invalid dimension DIM = %d", dim + 1);
+    }
+
+  switch (arg.builtin_type ())
     {
-      octave_value arg = args(0);
-
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value () - 1;
-          if (dim < 0)
-            error ("prod: invalid dimension DIM = %d", dim + 1);
-        }
-
-      switch (arg.builtin_type ())
-        {
-        case btyp_double:
-          if (arg.is_sparse_type ())
-            retval = arg.sparse_matrix_value ().prod (dim);
-          else
-            retval = arg.array_value ().prod (dim);
-          break;
-        case btyp_complex:
-          if (arg.is_sparse_type ())
-            retval = arg.sparse_complex_matrix_value ().prod (dim);
-          else
-            retval = arg.complex_array_value ().prod (dim);
-          break;
-        case btyp_float:
-          if (isdouble)
-            retval = arg.float_array_value ().dprod (dim);
-          else
-            retval = arg.float_array_value ().prod (dim);
-          break;
-        case btyp_float_complex:
-          if (isdouble)
-            retval = arg.float_complex_array_value ().dprod (dim);
-          else
-            retval = arg.float_complex_array_value ().prod (dim);
-          break;
+    case btyp_double:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_matrix_value ().prod (dim);
+      else
+        retval = arg.array_value ().prod (dim);
+      break;
+    case btyp_complex:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_complex_matrix_value ().prod (dim);
+      else
+        retval = arg.complex_array_value ().prod (dim);
+      break;
+    case btyp_float:
+      if (isdouble)
+        retval = arg.float_array_value ().dprod (dim);
+      else
+        retval = arg.float_array_value ().prod (dim);
+      break;
+    case btyp_float_complex:
+      if (isdouble)
+        retval = arg.float_complex_array_value ().dprod (dim);
+      else
+        retval = arg.float_complex_array_value ().prod (dim);
+      break;
 
 #define MAKE_INT_BRANCH(X) \
-          case btyp_ ## X: \
-            if (isnative) \
-              retval = arg.X ## _array_value ().prod (dim); \
-            else \
-              retval = arg.array_value ().prod (dim); \
-            break;
-          MAKE_INT_BRANCH (int8);
-          MAKE_INT_BRANCH (int16);
-          MAKE_INT_BRANCH (int32);
-          MAKE_INT_BRANCH (int64);
-          MAKE_INT_BRANCH (uint8);
-          MAKE_INT_BRANCH (uint16);
-          MAKE_INT_BRANCH (uint32);
-          MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    if (isnative) \
+      retval = arg.X ## _array_value ().prod (dim); \
+    else \
+      retval = arg.array_value ().prod (dim); \
+    break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
 
           // GAGME: Accursed Matlab compatibility...
-        case btyp_char:
-          retval = arg.array_value (true).prod (dim);
-          break;
-        case btyp_bool:
-          if (arg.is_sparse_type ())
-            {
-              if (isnative)
-                retval = arg.sparse_bool_matrix_value ().all (dim);
-              else
-                retval = arg.sparse_matrix_value ().prod (dim);
-            }
-          else if (isnative)
-            retval = arg.bool_array_value ().all (dim);
+    case btyp_char:
+      retval = arg.array_value (true).prod (dim);
+      break;
+
+    case btyp_bool:
+      if (arg.is_sparse_type ())
+        {
+          if (isnative)
+            retval = arg.sparse_bool_matrix_value ().all (dim);
           else
-            retval = NDArray (arg.bool_array_value ().all (dim));
-          break;
-
-        default:
-          gripe_wrong_type_arg ("prod", arg);
+            retval = arg.sparse_matrix_value ().prod (dim);
         }
+      else if (isnative)
+        retval = arg.bool_array_value ().all (dim);
+      else
+        retval = NDArray (arg.bool_array_value ().all (dim));
+      break;
+
+    default:
+      gripe_wrong_type_arg ("prod", arg);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1927,9 +1914,9 @@
 {
   octave_value retval;
 
-  // We may need to convert elements of the list to cells, so make a
-  // copy.  This should be efficient, it is done mostly by incrementing
-  // reference counts.
+  // We may need to convert elements of the list to cells, so make a copy.
+  // This should be efficient, it is done mostly by incrementing reference
+  // counts.
   octave_value_list args = xargs;
 
   int n_args = args.length ();
@@ -2663,14 +2650,10 @@
 @seealso{numel, size}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).length ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).length ());
 }
 
 DEFUN (ndims, args, ,
@@ -2690,14 +2673,10 @@
 @seealso{size}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).ndims ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).ndims ());
 }
 
 DEFUN (numel, args, ,
@@ -2888,14 +2867,10 @@
 @seealso{nzmax, nonzeros, find}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).nnz ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).nnz ());
 }
 
 DEFUN (nzmax, args, ,
@@ -2909,14 +2884,10 @@
 @seealso{nnz, spalloc, sparse}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).nzmax ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).nzmax ());
 }
 
 DEFUN (rows, args, ,
@@ -2926,15 +2897,38 @@
 @seealso{columns, size, length, numel, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).rows ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
-}
+  return octave_value (args(0).rows ());
+}
+
+/*
+%!assert (rows (ones (2,5)), 2)
+%!assert (rows (ones (5,2)), 5)
+%!assert (rows (ones (5,4,3,2)), 5)
+%!assert (rows (ones (3,4,5,2)), 3)
+
+%!assert (rows (cell (2,5)), 2)
+%!assert (rows (cell (5,2)), 5)
+%!assert (rows (cell (5,4,3,2)), 5)
+%!assert (rows (cell (3,4,5,2)), 3)
+
+%!test
+%! x(2,5,3).a = 1;
+%! assert (rows (x), 2);
+%! y(5,4,3).b = 2;
+%! assert (rows (y), 5);
+
+%!assert (rows ("Hello World"), 1)
+
+%!assert (rows ([]), 0)
+%!assert (rows (zeros (2,0), 2))
+
+## Test input validation
+%!error rows ()
+%!error rows (1,2)
+*/
 
 DEFUN (columns, args, ,
        "-*- texinfo -*-\n\
@@ -2943,14 +2937,10 @@
 @seealso{rows, size, length, numel, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).columns ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).columns ());
 }
 
 DEFUN (sum, args, ,
@@ -3013,101 +3003,105 @@
       nargin --;
     }
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  int dim = -1;
+  if (nargin == 2)
     {
-      octave_value arg = args(0);
-
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value () - 1;
-          if (dim < 0)
-            error ("sum: invalid dimension DIM = %d", dim + 1);
-        }
-
-      switch (arg.builtin_type ())
+      dim = args(1).int_value () - 1;
+      if (dim < 0)
+        error ("sum: invalid dimension DIM = %d", dim + 1);
+    }
+
+  switch (arg.builtin_type ())
+    {
+    case btyp_double:
+      if (arg.is_sparse_type ())
         {
-        case btyp_double:
-          if (arg.is_sparse_type ())
-            {
-              if (isextra)
-                warning ("sum: 'extra' not yet implemented for sparse matrices");
-              retval = arg.sparse_matrix_value ().sum (dim);
-            }
-          else if (isextra)
-            retval = arg.array_value ().xsum (dim);
-          else
-            retval = arg.array_value ().sum (dim);
-          break;
-        case btyp_complex:
-          if (arg.is_sparse_type ())
-            {
-              if (isextra)
-                warning ("sum: 'extra' not yet implemented for sparse matrices");
-              retval = arg.sparse_complex_matrix_value ().sum (dim);
-            }
-          else if (isextra)
-            retval = arg.complex_array_value ().xsum (dim);
-          else
-            retval = arg.complex_array_value ().sum (dim);
-          break;
-        case btyp_float:
-          if (isdouble || isextra)
-            retval = arg.float_array_value ().dsum (dim);
-          else
-            retval = arg.float_array_value ().sum (dim);
-          break;
-        case btyp_float_complex:
-          if (isdouble || isextra)
-            retval = arg.float_complex_array_value ().dsum (dim);
-          else
-            retval = arg.float_complex_array_value ().sum (dim);
-          break;
+          if (isextra)
+            warning ("sum: 'extra' not yet implemented for sparse matrices");
+          retval = arg.sparse_matrix_value ().sum (dim);
+        }
+      else if (isextra)
+        retval = arg.array_value ().xsum (dim);
+      else
+        retval = arg.array_value ().sum (dim);
+      break;
+
+    case btyp_complex:
+      if (arg.is_sparse_type ())
+        {
+          if (isextra)
+            warning ("sum: 'extra' not yet implemented for sparse matrices");
+          retval = arg.sparse_complex_matrix_value ().sum (dim);
+        }
+      else if (isextra)
+        retval = arg.complex_array_value ().xsum (dim);
+      else
+        retval = arg.complex_array_value ().sum (dim);
+      break;
+
+    case btyp_float:
+      if (isdouble || isextra)
+        retval = arg.float_array_value ().dsum (dim);
+      else
+        retval = arg.float_array_value ().sum (dim);
+      break;
+
+    case btyp_float_complex:
+      if (isdouble || isextra)
+        retval = arg.float_complex_array_value ().dsum (dim);
+      else
+        retval = arg.float_complex_array_value ().sum (dim);
+      break;
 
 #define MAKE_INT_BRANCH(X) \
-          case btyp_ ## X: \
-            if (isnative) \
-              retval = arg.X ## _array_value ().sum (dim); \
-            else \
-              retval = arg.X ## _array_value ().dsum (dim); \
-            break;
-          MAKE_INT_BRANCH (int8);
-          MAKE_INT_BRANCH (int16);
-          MAKE_INT_BRANCH (int32);
-          MAKE_INT_BRANCH (int64);
-          MAKE_INT_BRANCH (uint8);
-          MAKE_INT_BRANCH (uint16);
-          MAKE_INT_BRANCH (uint32);
-          MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    if (isnative) \
+      retval = arg.X ## _array_value ().sum (dim); \
+    else \
+      retval = arg.X ## _array_value ().dsum (dim); \
+    break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
 
-          // GAGME: Accursed Matlab compatibility...
-        case btyp_char:
-          if (isextra)
-            retval = arg.array_value (true).xsum (dim);
+      // GAGME: Accursed Matlab compatibility...
+    case btyp_char:
+      if (isextra)
+        retval = arg.array_value (true).xsum (dim);
+      else
+        retval = arg.array_value (true).sum (dim);
+      break;
+
+    case btyp_bool:
+      if (arg.is_sparse_type ())
+        {
+          if (isnative)
+            retval = arg.sparse_bool_matrix_value ().any (dim);
           else
-            retval = arg.array_value (true).sum (dim);
-          break;
-        case btyp_bool:
-          if (arg.is_sparse_type ())
-            {
-              if (isnative)
-                retval = arg.sparse_bool_matrix_value ().any (dim);
-              else
-                retval = arg.sparse_bool_matrix_value ().sum (dim);
-            }
-          else if (isnative)
-            retval = arg.bool_array_value ().any (dim);
-          else
-            retval = arg.bool_array_value ().sum (dim);
-          break;
-
-        default:
-          gripe_wrong_type_arg ("sum", arg);
+            retval = arg.sparse_bool_matrix_value ().sum (dim);
         }
+      else if (isnative)
+        retval = arg.bool_array_value ().any (dim);
+      else
+        retval = arg.bool_array_value ().sum (dim);
+      break;
+
+    default:
+      gripe_wrong_type_arg ("sum", arg);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -3225,14 +3219,10 @@
 @seealso{isfloat, isinteger, ischar, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_bool_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_bool_type ());
 }
 
 DEFALIAS (isbool, islogical);
@@ -3261,14 +3251,10 @@
 @seealso{isfloat, ischar, islogical, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_integer_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_integer_type ());
 }
 
 DEFUN (iscomplex, args, ,
@@ -3278,14 +3264,10 @@
 @seealso{isreal, isnumeric, islogical, ischar, isfloat, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_complex_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_complex_type ());
 }
 
 DEFUN (isfloat, args, ,
@@ -3297,14 +3279,10 @@
 @seealso{isinteger, ischar, islogical, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_float_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_float_type ());
 }
 
 // FIXME: perhaps this should be implemented with an
@@ -3338,6 +3316,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   if (nargin == 1)
     {
       octave_value arg = args(0);
@@ -3384,7 +3365,7 @@
             }
         }
     }
-  else if (nargin == 2)
+  else
     {
       octave_value re = args(0);
       octave_value im = args(1);
@@ -3575,8 +3556,6 @@
             }
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -3591,14 +3570,10 @@
 @seealso{iscomplex, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_real_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_real_type ());
 }
 
 DEFUN (isempty, args, ,
@@ -3609,14 +3584,10 @@
 @seealso{isnull, isa}\n\
 @end deftypefn")
 {
-  octave_value retval = false;
-
-  if (args.length () == 1)
-    retval = args(0).is_empty ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_empty ());
 }
 
 /*
@@ -3634,14 +3605,10 @@
 @seealso{isinteger, isfloat, isreal, iscomplex, islogical, ischar, iscell, isstruct, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_numeric_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_numeric_type ());
 }
 
 /*
@@ -3667,14 +3634,10 @@
 @seealso{isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).numel () == 1;
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).numel () == 1);
 }
 
 /*
@@ -3706,17 +3669,12 @@
 @seealso{isscalar, ismatrix, size, rows, columns, length}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && (sz(0) == 1 || sz(1) == 1);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && (sz(0) == 1 || sz(1) == 1));
 }
 
 /*
@@ -3746,17 +3704,12 @@
 @seealso{iscolumn, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && sz(0) == 1;
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(0) == 1);
 }
 
 /*
@@ -3796,17 +3749,12 @@
 @seealso{isrow, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && sz(1) == 1;
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(1) == 1);
 }
 
 /*
@@ -3845,17 +3793,12 @@
 @seealso{isscalar, isvector, iscell, isstruct, issparse, isa}\n\
 @end deftypefn")
 {
-  octave_value retval = false;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = (sz.length () == 2) && (sz(0) >= 0) && (sz(1) >= 0);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(0) >= 0 && sz(1) >= 0);
 }
 
 /*
@@ -3893,17 +3836,12 @@
 @seealso{isscalar, isvector, ismatrix, size}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && sz(0) == sz(1);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(0) == sz(1));
 }
 
 /*
@@ -5076,33 +5014,24 @@
       dt = oct_data_conv::string_to_data_type (nm);
     }
 
-  switch (nargin)
+  if (nargin > 2)
+    print_usage ();
+
+  if (nargin == 0)
+    retval = identity_matrix (1, 1, dt);
+  else if (nargin == 1)
     {
-    case 0:
-      retval = identity_matrix (1, 1, dt);
-      break;
-
-    case 1:
-      {
-        octave_idx_type nr, nc;
-        get_dimensions (args(0), "eye", nr, nc);
-
-        retval = identity_matrix (nr, nc, dt);
-      }
-      break;
-
-    case 2:
-      {
-        octave_idx_type nr, nc;
-        get_dimensions (args(0), args(1), "eye", nr, nc);
-
-        retval = identity_matrix (nr, nc, dt);
-      }
-      break;
-
-    default:
-      print_usage ();
-      break;
+      octave_idx_type nr, nc;
+      get_dimensions (args(0), "eye", nr, nc);
+
+      retval = identity_matrix (nr, nc, dt);
+    }
+  else
+    {
+      octave_idx_type nr, nc;
+      get_dimensions (args(0), args(1), "eye", nr, nc);
+
+      retval = identity_matrix (nr, nc, dt);
     }
 
   return retval;
@@ -5195,10 +5124,7 @@
   octave_idx_type npoints = 100;
 
   if (nargin != 2 && nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (nargin == 3)
     {
@@ -5350,8 +5276,12 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
+  if (nargin < 2)
+    print_usage ();
+
   if (nargin == 2)
     {
       Array<double> vec = args(1).vector_value ();
@@ -5372,7 +5302,7 @@
           retval = retval.resize (dv, true);
         }
     }
-  else if (nargin > 2)
+  else
     {
       dim_vector dv;
       dv.resize (nargin - 1);
@@ -5382,8 +5312,6 @@
       retval = args(0);
       retval = retval.resize (dv, true);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -5428,6 +5356,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2)
+    print_usage ();
+
   dim_vector new_dims;
 
   if (nargin == 2)
@@ -5453,7 +5384,7 @@
             new_dims(i) = new_size(i);
         }
     }
-  else if (nargin > 2)
+  else
     {
       new_dims = dim_vector::alloc (nargin-1);
       int empty_dim = -1;
@@ -5504,11 +5435,6 @@
             }
         }
     }
-  else
-    {
-      print_usage ();
-      return retval;
-    }
 
   retval = args(0).reshape (new_dims);
 
@@ -5615,14 +5541,10 @@
 @seealso{reshape}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).squeeze ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).squeeze ());
 }
 
 DEFUN (full, args, ,
@@ -5633,14 +5555,10 @@
 @seealso{sparse, issparse}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).full_value ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).full_value ());
 }
 
 // Compute various norms of the vector X.
@@ -5709,78 +5627,80 @@
 
   int nargin = args.length ();
 
-  if (nargin >= 1 && nargin <= 3)
+  if (nargin < 1 && nargin > 3)
+    print_usage ();
+
+  octave_value x_arg = args(0);
+
+  if (x_arg.ndims () == 2)
     {
-      octave_value x_arg = args(0);
-
-      if (x_arg.ndims () == 2)
+      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);
+
+      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
-    print_usage ();
+    error ("norm: only valid for 2-D objects");
 
   return retval;
 }
@@ -5859,13 +5779,10 @@
 unary_op_defun_body (octave_value::unary_op op,
                      const octave_value_list& args)
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = do_unary_op (op, args(0));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return do_unary_op (op, args(0));
 }
 
 DEFUN (not, args, ,
@@ -5968,14 +5885,10 @@
 binary_op_defun_body (octave_value::binary_op op,
                       const octave_value_list& args)
 {
-  octave_value retval;
-
-  if (args.length () == 2)
-    retval = do_binary_op (op, args(0), args(1));
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  return do_binary_op (op, args(0), args(1));
 }
 
 static octave_value
@@ -5984,24 +5897,22 @@
                             const octave_value_list& args)
 {
   octave_value retval;
+
   int nargin = args.length ();
 
-  switch (nargin)
+  if (nargin == 0)
+    print_usage ();
+
+  if (nargin == 1)
+    retval = args(0);
+  else if (nargin == 2)
+    retval = do_binary_op (op, args(0), args(1));
+  else
     {
-    case 0:
-      print_usage ();
-      break;
-    case 1:
-      retval = args(0);
-      break;
-    case 2:
       retval = do_binary_op (op, args(0), args(1));
-      break;
-    default:
-      retval = do_binary_op (op, args(0), args(1));
+
       for (int i = 2; i < nargin; i++)
         retval.assign (aop, args(i));
-      break;
     }
 
   return retval;
@@ -6279,25 +6190,14 @@
 or @w{@code{base : increment : limit}}.\n\
 @end deftypefn")
 {
-  octave_value retval;
   int nargin = args.length ();
 
-  switch (nargin)
-    {
-    case 2:
-      retval = do_colon_op (args(0), args(1));
-      break;
-
-    case 3:
-      retval = do_colon_op (args(0), args(1), args (2));
-      break;
-
-    default:
-      print_usage ();
-      break;
-    }
-
-  return retval;
+  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));
 }
 
 static double tic_toc_timestamp = -1.0;
@@ -6389,36 +6289,34 @@
 
   if (nargin > 1)
     print_usage ();
+
+  if (nargin == 1)
+    {
+      octave_uint64 id = args(0).xuint64_scalar_value ("toc: invalid ID");
+
+      uint64_t val = id.value ();
+
+      start_time
+        = (static_cast<double> (val / CLOCKS_PER_SEC)
+           + static_cast<double> (val % CLOCKS_PER_SEC)
+           / CLOCKS_PER_SEC);
+
+      // FIXME: should we also check to see whether the start
+      // time is after the beginning of this Octave session?
+    }
+
+  if (start_time < 0)
+    error ("toc called before timer set");
   else
     {
-      if (nargin == 1)
-        {
-          octave_uint64 id = args(0).xuint64_scalar_value ("toc: invalid ID");
-
-          uint64_t val = id.value ();
-
-          start_time
-            = (static_cast<double> (val / CLOCKS_PER_SEC)
-               + static_cast<double> (val % CLOCKS_PER_SEC)
-               / CLOCKS_PER_SEC);
-
-          // FIXME: should we also check to see whether the start
-          // time is after the beginning of this Octave session?
-        }
-
-      if (start_time < 0)
-        error ("toc called before timer set");
+      octave_time now;
+
+      double tmp = now.double_value () - start_time;
+
+      if (nargout > 0)
+        retval = tmp;
       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 " << tmp << " seconds.\n";
     }
 
   return retval;
@@ -6579,10 +6477,7 @@
   sortmode smode = ASCENDING;
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   bool return_idx = nargout > 1;
 
@@ -6599,10 +6494,7 @@
           else if (mode == "descend")
             smode = DESCENDING;
           else
-            {
-              error ("sort: MODE must be either \"ascend\" or \"descend\"");
-              return retval;
-            }
+            error ("sort: MODE must be either \"ascend\" or \"descend\"");
         }
       else
         dim = args(1).nint_value () - 1;
@@ -6611,10 +6503,7 @@
   if (nargin > 2)
     {
       if (args(1).is_string ())
-        {
-          print_usage ();
-          return retval;
-        }
+        error ("sort: DIM must be a valid dimension");
 
       std::string mode = args(2).xstring_value ("sort: MODE must be a string");
 
@@ -6623,10 +6512,7 @@
       else if (mode == "descend")
         smode = DESCENDING;
       else
-        {
-          error ("sort: MODE must be either \"ascend\" or \"descend\"");
-          return retval;
-        }
+        error ("sort: MODE must be either \"ascend\" or \"descend\"");
     }
 
   const dim_vector dv = arg.dims ();
@@ -6638,10 +6524,7 @@
   else
     {
       if (dim < 0)
-        {
-          error ("sort: DIM must be a valid dimension");
-          return retval;
-        }
+        error ("sort: DIM must be a valid dimension");
     }
 
   if (return_idx)
@@ -6851,11 +6734,11 @@
   int nargin = args.length ();
   sortmode smode = ASCENDING;
 
-  if (nargin < 1 || nargin > 2 || (nargin == 2 && ! args(1).is_string ()))
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  if (nargin == 2 && ! args(1).is_string ())
+    error ("__sort_rows_idx__: second argument must be a string");
 
   if (nargin > 1)
     {
@@ -6934,10 +6817,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   bool by_rows = false;
 
@@ -6985,32 +6865,44 @@
 %! um = [3, 1; 2, 4];
 %! sv = [1, 2, 3, 4];
 %! uv = [2, 1, 4, 3];
+
 %!assert (issorted (sm, "rows"))
-%!assert (!issorted (um, "rows"))
+%!assert (! issorted (um, "rows"))
 %!assert (issorted (sv))
-%!assert (!issorted (uv))
+%!assert (! issorted (uv))
 %!assert (issorted (sv'))
-%!assert (!issorted (uv'))
+%!assert (! issorted (uv'))
 %!assert (issorted (sm, "rows", "ascending"))
-%!assert (!issorted (um, "rows", "ascending"))
+%!assert (! issorted (um, "rows", "ascending"))
 %!assert (issorted (sv, "ascending"))
-%!assert (!issorted (uv, "ascending"))
+%!assert (! issorted (uv, "ascending"))
 %!assert (issorted (sv', "ascending"))
-%!assert (!issorted (uv', "ascending"))
-%!assert (!issorted (sm, "rows", "descending"))
+%!assert (! issorted (uv', "ascending"))
+%!assert (! issorted (sm, "rows", "descending"))
 %!assert (issorted (flipud (sm), "rows", "descending"))
-%!assert (!issorted (sv, "descending"))
+%!assert (! issorted (sv, "descending"))
 %!assert (issorted (fliplr (sv), "descending"))
-%!assert (!issorted (sv', "descending"))
+%!assert (! issorted (sv', "descending"))
 %!assert (issorted (fliplr (sv)', "descending"))
-%!assert (!issorted (um, "rows", "either"))
-%!assert (!issorted (uv, "either"))
+%!assert (! issorted (um, "rows", "either"))
+%!assert (! issorted (uv, "either"))
 %!assert (issorted (sm, "rows", "either"))
 %!assert (issorted (flipud (sm), "rows", "either"))
 %!assert (issorted (sv, "either"))
 %!assert (issorted (fliplr (sv), "either"))
 %!assert (issorted (sv', "either"))
 %!assert (issorted (fliplr (sv)', "either"))
+
+%!error <needs a vector> issorted ([])
+
+## Test input validation
+%!error issorted () 
+%!error issorted (1,2,3,4) 
+%!error <second argument must be a string> issorted (1, 2)
+%!error <second argument must be a string> issorted (1, {"rows"})
+%!error <sparse matrices not yet supported> issorted (sparse ([1 2 3]), "rows")
+%!error <A must be a 2-dimensional object> issorted (rand (2,2,2), "rows")
+%!error <needs a vector> issorted (ones (2,2))
 */
 
 DEFUN (nth_element, args, ,
@@ -7038,69 +6930,68 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  octave_value argx = args(0);
+
+  int dim = -1;
+  if (nargin == 3)
     {
-      octave_value argx = args(0);
-
-      int dim = -1;
-      if (nargin == 3)
-        {
-          dim = args(2).int_value (true) - 1;
-          if (dim < 0)
-            error ("nth_element: DIM must be a valid dimension");
-        }
+      dim = args(2).int_value (true) - 1;
       if (dim < 0)
-        dim = argx.dims ().first_non_singleton ();
-
-      try
+        error ("nth_element: DIM must be a valid dimension");
+    }
+  if (dim < 0)
+    dim = argx.dims ().first_non_singleton ();
+
+  try
+    {
+      idx_vector n = args(1).index_vector ();
+
+      switch (argx.builtin_type ())
         {
-          idx_vector n = args(1).index_vector ();
-
-          switch (argx.builtin_type ())
-            {
-            case btyp_double:
-              retval = argx.array_value ().nth_element (n, dim);
-              break;
-            case btyp_float:
-              retval = argx.float_array_value ().nth_element (n, dim);
-              break;
-            case btyp_complex:
-              retval = argx.complex_array_value ().nth_element (n, dim);
-              break;
-            case btyp_float_complex:
-              retval = argx.float_complex_array_value ().nth_element (n, dim);
-              break;
+        case btyp_double:
+          retval = argx.array_value ().nth_element (n, dim);
+          break;
+        case btyp_float:
+          retval = argx.float_array_value ().nth_element (n, dim);
+          break;
+        case btyp_complex:
+          retval = argx.complex_array_value ().nth_element (n, dim);
+          break;
+        case btyp_float_complex:
+          retval = argx.float_complex_array_value ().nth_element (n, dim);
+          break;
 #define MAKE_INT_BRANCH(X) \
-            case btyp_ ## X: \
-              retval = argx.X ## _array_value ().nth_element (n, dim); \
-              break;
-
-            MAKE_INT_BRANCH (int8);
-            MAKE_INT_BRANCH (int16);
-            MAKE_INT_BRANCH (int32);
-            MAKE_INT_BRANCH (int64);
-            MAKE_INT_BRANCH (uint8);
-            MAKE_INT_BRANCH (uint16);
-            MAKE_INT_BRANCH (uint32);
-            MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    retval = argx.X ## _array_value ().nth_element (n, dim); \
+    break;
+
+          MAKE_INT_BRANCH (int8);
+          MAKE_INT_BRANCH (int16);
+          MAKE_INT_BRANCH (int32);
+          MAKE_INT_BRANCH (int64);
+          MAKE_INT_BRANCH (uint8);
+          MAKE_INT_BRANCH (uint16);
+          MAKE_INT_BRANCH (uint32);
+          MAKE_INT_BRANCH (uint64);
 #undef MAKE_INT_BRANCH
-            default:
-              if (argx.is_cellstr ())
-                retval = argx.cellstr_value ().nth_element (n, dim);
-              else
-                gripe_wrong_type_arg ("nth_element", argx);
-            }
-        }
-      catch (const index_exception& e)
-        {
-          index_error ("nth_element: invalid N value %s. %s",
-                       e.idx (), e.details ());
+        default:
+          if (argx.is_cellstr ())
+            retval = argx.cellstr_value ().nth_element (n, dim);
+          else
+            gripe_wrong_type_arg ("nth_element", argx);
         }
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("nth_element: invalid N value %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7135,54 +7026,57 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
-  if (nargin >= 2 && nargin <= 3 && args(0).is_numeric_type ())
+
+  if (nargin < 2 && nargin > 3)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    error ("__accumarray_sum__: first argument must be numeric");
+
+  try
     {
-      try
+      idx_vector idx = args(0).index_vector ();
+      octave_idx_type n = -1;
+      if (nargin == 3)
+        n = args(2).idx_type_value (true);
+
+      octave_value vals = args(1);
+
+      if (vals.is_range ())
         {
-          idx_vector idx = args(0).index_vector ();
-          octave_idx_type n = -1;
-          if (nargin == 3)
-            n = args(2).idx_type_value (true);
-
-          octave_value vals = args(1);
-
-          if (vals.is_range ())
-            {
-              Range r = vals.range_value ();
-              if (r.inc () == 0)
-                vals = r.base ();
-            }
-
-          if (vals.is_single_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumarray_sum (idx,
-                                            vals.float_complex_array_value (),
-                                            n);
-              else
-                retval = do_accumarray_sum (idx, vals.float_array_value (), n);
-            }
-          else if (vals.is_numeric_type () || vals.is_bool_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumarray_sum (idx,
-                                            vals.complex_array_value (),
-                                            n);
-              else
-                retval = do_accumarray_sum (idx, vals.array_value (), n);
-            }
+          Range r = vals.range_value ();
+          if (r.inc () == 0)
+            vals = r.base ();
+        }
+
+      if (vals.is_single_type ())
+        {
+          if (vals.is_complex_type ())
+            retval = do_accumarray_sum (idx,
+                                        vals.float_complex_array_value (),
+                                        n);
           else
-            gripe_wrong_type_arg ("accumarray", vals);
+            retval = do_accumarray_sum (idx, vals.float_array_value (), n);
         }
-      catch (const index_exception& e)
+      else if (vals.is_numeric_type () || vals.is_bool_type ())
         {
-          index_error ("__accumarray_sum__: invalid IDX %s. %s",
-                       e.idx (), e.details ());
+          if (vals.is_complex_type ())
+            retval = do_accumarray_sum (idx,
+                                        vals.complex_array_value (),
+                                        n);
+          else
+            retval = do_accumarray_sum (idx, vals.array_value (), n);
         }
+      else
+        gripe_wrong_type_arg ("accumarray", vals);
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("__accumarray_sum__: invalid IDX %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7221,72 +7115,80 @@
                           bool ismin)
 {
   octave_value retval;
+
   int nargin = args.length ();
-  if (nargin >= 3 && nargin <= 4 && args(0).is_numeric_type ())
+
+  if (nargin < 3 && nargin > 4)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    error ("accumarray: first argument must be numeric");
+
+  try
     {
-      try
+      idx_vector idx = args(0).index_vector ();
+      octave_idx_type n = -1;
+      if (nargin == 4)
+        n = args(3).idx_type_value (true);
+
+      octave_value vals = args(1);
+      octave_value zero = args(2);
+
+      switch (vals.builtin_type ())
         {
-          idx_vector idx = args(0).index_vector ();
-          octave_idx_type n = -1;
-          if (nargin == 4)
-            n = args(3).idx_type_value (true);
-
-          octave_value vals = args(1);
-          octave_value zero = args(2);
-
-          switch (vals.builtin_type ())
-            {
-            case btyp_double:
-              retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
-                                             zero.double_value ());
-              break;
-            case btyp_float:
-              retval = do_accumarray_minmax (idx, vals.float_array_value (), n,
-                                             ismin, zero.float_value ());
-              break;
-            case btyp_complex:
-              retval = do_accumarray_minmax (idx, vals.complex_array_value (),
-                                             n, ismin, zero.complex_value ());
-              break;
-            case btyp_float_complex:
-              retval = do_accumarray_minmax (idx,
-                                             vals.float_complex_array_value (),
-                                             n, ismin,
-                                             zero.float_complex_value ());
-              break;
+        case btyp_double:
+          retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
+                                         zero.double_value ());
+          break;
+
+        case btyp_float:
+          retval = do_accumarray_minmax (idx, vals.float_array_value (), n,
+                                         ismin, zero.float_value ());
+          break;
+
+        case btyp_complex:
+          retval = do_accumarray_minmax (idx, vals.complex_array_value (),
+                                         n, ismin, zero.complex_value ());
+          break;
+
+        case btyp_float_complex:
+          retval = do_accumarray_minmax (idx,
+                                         vals.float_complex_array_value (),
+                                         n, ismin,
+                                         zero.float_complex_value ());
+          break;
+
 #define MAKE_INT_BRANCH(X) \
-              case btyp_ ## X: \
-                retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
-                                               n, ismin, \
-                                               zero.X ## _scalar_value ()); \
-                break;
-
-              MAKE_INT_BRANCH (int8);
-              MAKE_INT_BRANCH (int16);
-              MAKE_INT_BRANCH (int32);
-              MAKE_INT_BRANCH (int64);
-              MAKE_INT_BRANCH (uint8);
-              MAKE_INT_BRANCH (uint16);
-              MAKE_INT_BRANCH (uint32);
-              MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
+                                   n, ismin, zero.X ## _scalar_value ()); \
+            break;
+
+          MAKE_INT_BRANCH (int8);
+          MAKE_INT_BRANCH (int16);
+          MAKE_INT_BRANCH (int32);
+          MAKE_INT_BRANCH (int64);
+          MAKE_INT_BRANCH (uint8);
+          MAKE_INT_BRANCH (uint16);
+          MAKE_INT_BRANCH (uint32);
+          MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
-            case btyp_bool:
-              retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
-                                             zero.bool_value ());
-              break;
-            default:
-              gripe_wrong_type_arg ("accumarray", vals);
-            }
+
+        case btyp_bool:
+          retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
+                                         zero.bool_value ());
+          break;
+
+        default:
+          gripe_wrong_type_arg ("accumarray", vals);
         }
-      catch (const index_exception& e)
-        {
-          index_error ("do_accumarray_minmax_fun: invalid index %s. %s",
-                       e.idx (), e.details ());
-        }
-
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("do_accumarray_minmax_fun: invalid index %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7347,51 +7249,54 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
-  if (nargin >= 2 && nargin <= 4 && args(0).is_numeric_type ())
+
+  if (nargin < 2 && nargin > 4)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    error ("__accumdim_sum__: first argument must be numeric");
+
+  try
     {
-      try
+      idx_vector idx = args(0).index_vector ();
+      int dim = -1;
+      if (nargin >= 3)
+        dim = args(2).int_value () - 1;
+
+      octave_idx_type n = -1;
+      if (nargin == 4)
+        n = args(3).idx_type_value (true);
+
+      octave_value vals = args(1);
+
+      if (vals.is_single_type ())
         {
-          idx_vector idx = args(0).index_vector ();
-          int dim = -1;
-          if (nargin >= 3)
-            dim = args(2).int_value () - 1;
-
-          octave_idx_type n = -1;
-          if (nargin == 4)
-            n = args(3).idx_type_value (true);
-
-          octave_value vals = args(1);
-
-          if (vals.is_single_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumdim_sum (idx,
-                                          vals.float_complex_array_value (),
-                                          dim, n);
-              else
-                retval = do_accumdim_sum (idx, vals.float_array_value (),
-                                          dim, n);
-            }
-          else if (vals.is_numeric_type () || vals.is_bool_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumdim_sum (idx, vals.complex_array_value (),
-                                          dim, n);
-              else
-                retval = do_accumdim_sum (idx, vals.array_value (), dim, n);
-            }
+          if (vals.is_complex_type ())
+            retval = do_accumdim_sum (idx,
+                                      vals.float_complex_array_value (),
+                                      dim, n);
           else
-            gripe_wrong_type_arg ("accumdim", vals);
+            retval = do_accumdim_sum (idx, vals.float_array_value (),
+                                      dim, n);
         }
-      catch (const index_exception& e)
+      else if (vals.is_numeric_type () || vals.is_bool_type ())
         {
-          index_error ("__accumdim_sum__: invalid IDX %s. %s",
-                       e.idx (), e.details ());
+          if (vals.is_complex_type ())
+            retval = do_accumdim_sum (idx, vals.complex_array_value (),
+                                      dim, n);
+          else
+            retval = do_accumdim_sum (idx, vals.array_value (), dim, n);
         }
+      else
+        gripe_wrong_type_arg ("accumdim", vals);
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("__accumdim_sum__: invalid IDX %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7492,74 +7397,76 @@
 @seealso{logical, diff}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value retval;
 
-  if (nargin == 3 && (args(0).is_bool_type () || args(0).is_numeric_type ()))
+  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 mask_val = args(0);
+
+  if (mask_val.is_scalar_type ())
+    retval = mask_val.is_true () ? args(1) : args(2);
+  else
     {
-      octave_value mask_val = args(0);
-
-      if (mask_val.is_scalar_type ())
-        retval = mask_val.is_true () ? args(1) : args(2);
-      else
+      boolNDArray mask = mask_val.bool_array_value ();
+
+      octave_value tval = args(1);
+      octave_value fval = args(2);
+
+      if (tval.is_double_type () && fval.is_double_type ())
+        {
+          if (tval.is_complex_type () || fval.is_complex_type ())
+            retval = do_merge (mask,
+                               tval.complex_array_value (),
+                               fval.complex_array_value ());
+          else
+            retval = do_merge (mask,
+                               tval.array_value (),
+                               fval.array_value ());
+        }
+      else if (tval.is_single_type () && fval.is_single_type ())
         {
-          boolNDArray mask = mask_val.bool_array_value ();
-          octave_value tval = args(1);
-          octave_value fval = args(2);
-          if (tval.is_double_type () && fval.is_double_type ())
-            {
-              if (tval.is_complex_type () || fval.is_complex_type ())
-                retval = do_merge (mask,
-                                   tval.complex_array_value (),
-                                   fval.complex_array_value ());
-              else
-                retval = do_merge (mask,
-                                   tval.array_value (),
-                                   fval.array_value ());
-            }
-          else if (tval.is_single_type () && fval.is_single_type ())
-            {
-              if (tval.is_complex_type () || fval.is_complex_type ())
-                retval = do_merge (mask,
-                                   tval.float_complex_array_value (),
-                                   fval.float_complex_array_value ());
-              else
-                retval = do_merge (mask,
-                                   tval.float_array_value (),
-                                   fval.float_array_value ());
-            }
-          else if (tval.is_string () && fval.is_string ())
-            {
-              bool sq_string = tval.is_sq_string () || fval.is_sq_string ();
-              retval = octave_value (do_merge (mask,
-                                               tval.char_array_value (),
-                                               fval.char_array_value ()),
-                                     sq_string ? '\'' : '"');
-            }
-          else if (tval.is_cell () && fval.is_cell ())
-            {
-              retval = do_merge (mask,
-                                 tval.cell_value (),
-                                 fval.cell_value ());
-            }
-
-          MAKE_INT_BRANCH (int8)
-          MAKE_INT_BRANCH (int16)
-          MAKE_INT_BRANCH (int32)
-          MAKE_INT_BRANCH (int64)
-          MAKE_INT_BRANCH (uint8)
-          MAKE_INT_BRANCH (uint16)
-          MAKE_INT_BRANCH (uint32)
-          MAKE_INT_BRANCH (uint64)
-
+          if (tval.is_complex_type () || fval.is_complex_type ())
+            retval = do_merge (mask,
+                               tval.float_complex_array_value (),
+                               fval.float_complex_array_value ());
           else
-            error ("merge: cannot merge %s with %s with array mask",
-                   tval.class_name ().c_str (),
-                   fval.class_name ().c_str ());
+            retval = do_merge (mask,
+                               tval.float_array_value (),
+                               fval.float_array_value ());
+        }
+      else if (tval.is_string () && fval.is_string ())
+        {
+          bool sq_string = tval.is_sq_string () || fval.is_sq_string ();
+          retval = octave_value (do_merge (mask,
+                                           tval.char_array_value (),
+                                           fval.char_array_value ()),
+                                 sq_string ? '\'' : '"');
         }
+      else if (tval.is_cell () && fval.is_cell ())
+        {
+          retval = do_merge (mask,
+                             tval.cell_value (),
+                             fval.cell_value ());
+        }
+
+        MAKE_INT_BRANCH (int8)
+        MAKE_INT_BRANCH (int16)
+        MAKE_INT_BRANCH (int32)
+        MAKE_INT_BRANCH (int64)
+        MAKE_INT_BRANCH (uint8)
+        MAKE_INT_BRANCH (uint16)
+        MAKE_INT_BRANCH (uint32)
+        MAKE_INT_BRANCH (uint64)
+
+      else
+        error ("merge: cannot merge %s with %s with array mask",
+               tval.class_name ().c_str (),
+               fval.class_name ().c_str ());
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -7724,12 +7631,14 @@
 @seealso{sort, merge}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
-  else if (! (args(0).is_numeric_type () || args(0).is_bool_type ()))
+
+  if (! (args(0).is_numeric_type () || args(0).is_bool_type ()))
     error ("diff: X must be numeric or logical");
 
   int dim = -1;
--- a/libinterp/corefcn/debug.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/debug.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1149,6 +1149,9 @@
 
   // dbstack accepts up to 2 arguments.
 
+  if (len > 2)
+    print_usage ();
+
   if (len == 1 || len == 2)
     {
       int n = 0;
@@ -1178,8 +1181,6 @@
       if (n > 0)
         nskip = n;
     }
-  else if (len)
-    print_usage ();
 
   if (nargout == 0)
     {
@@ -1387,7 +1388,8 @@
 
       if (nargin > 1)
         print_usage ();
-      else if (nargin == 1)
+
+      if (nargin == 1)
         {
           std::string arg = args(0).xstring_value ("dbstep: input argument must be a string");
 
@@ -1441,14 +1443,12 @@
 {
   if (Vdebugging)
     {
-      if (args.length () == 0)
-        {
-          Vdebugging = false;
+      if (args.length () != 0)
+        print_usage ();
 
-          tree_evaluator::reset_debug_state ();
-        }
-      else
-        print_usage ();
+      Vdebugging = false;
+
+      tree_evaluator::reset_debug_state ();
     }
   else
     error ("dbcont: can only be called in debug mode");
@@ -1466,16 +1466,14 @@
 {
   if (Vdebugging)
     {
-      if (args.length () == 0)
-        {
-          Vdebugging = false;
+      if (args.length () != 0)
+        print_usage ();
 
-          tree_evaluator::reset_debug_state ();
+      Vdebugging = false;
 
-          octave_throw_interrupt_exception ();
-        }
-      else
-        print_usage ();
+      tree_evaluator::reset_debug_state ();
+
+      octave_throw_interrupt_exception ();
     }
   else
     error ("dbquit: can only be called in debug mode");
@@ -1490,14 +1488,10 @@
 @seealso{dbwhere, dbstack, dbstatus}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = Vdebugging;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (Vdebugging);
 }
 
 DEFUN (__db_next_breakpoint_quiet__, args, ,
@@ -1513,17 +1507,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 0 || nargin == 1)
-    {
-      bool state = true;
+  if (nargin > 1)
+    print_usage ();
+
+  bool state = true;
 
-      if (nargin == 1)
-        state = args(0).bool_value ();
+  if (nargin == 1)
+    state = args(0).bool_value ();
 
-      tree_evaluator::quiet_breakpoint_flag = state;
-    }
-  else
-    print_usage ();
+  tree_evaluator::quiet_breakpoint_flag = state;
 
   return retval;
 }
--- a/libinterp/corefcn/defaults.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/defaults.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -584,14 +584,10 @@
 @seealso{EXEC_PATH, IMAGE_PATH}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = Voctave_home;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (Voctave_home);
 }
 
 /*
@@ -606,16 +602,10 @@
 @seealso{ver, version}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = OCTAVE_VERSION;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (OCTAVE_VERSION);
 }
 
 /*
--- a/libinterp/corefcn/det.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/det.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -69,10 +69,7 @@
   int nargin = args.length ();
 
   if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
--- a/libinterp/corefcn/dirfns.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/dirfns.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -178,29 +178,25 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 1)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = -1.0;
   retval(0) = Cell ();
 
-  if (args.length () == 1)
-    {
-      std::string dirname = args(0).xstring_value ("readdir: DIR must be a string");
+  std::string dirname = args(0).xstring_value ("readdir: DIR must be a string");
 
-      dir_entry dir (dirname);
+  dir_entry dir (dirname);
 
-      if (dir)
-        {
-          string_vector dirlist = dir.read ();
-          retval(1) = 0.0;
-          retval(0) = Cell (dirlist.sort ());
-        }
-      else
-        {
-          retval(2) = dir.error ();
-        }
+  if (dir)
+    {
+      string_vector dirlist = dir.read ();
+      retval(1) = 0.0;
+      retval(0) = Cell (dirlist.sort ());
     }
   else
-    print_usage ();
+    retval(2) = dir.error ();
 
   return retval;
 }
@@ -230,12 +226,15 @@
 {
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = std::string ();
   retval(0) = false;
 
-  int nargin = args.length ();
-
   std::string dirname;
 
   if (nargin == 2)
@@ -248,38 +247,33 @@
   else if (nargin == 1)
     dirname = args(0).xstring_value ("mkdir: DIR must be a string");
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string msg;
+  std::string msg;
+
+  dirname = file_ops::tilde_expand (dirname);
 
-      dirname = file_ops::tilde_expand (dirname);
+  file_stat fs (dirname);
 
-      file_stat fs (dirname);
+  if (fs && fs.is_dir ())
+    {
+      // For compatibility with Matlab, we return true when the
+      // directory already exists.
 
-      if (fs && fs.is_dir ())
+      retval(2) = "mkdir";
+      retval(1) = "directory exists";
+      retval(0) = true;
+    }
+  else
+    {
+      int status = octave_mkdir (dirname, 0777, msg);
+
+      if (status < 0)
         {
-          // For compatibility with Matlab, we return true when the
-          // directory already exists.
-
           retval(2) = "mkdir";
-          retval(1) = "directory exists";
-          retval(0) = true;
+          retval(1) = msg;
         }
       else
-        {
-          int status = octave_mkdir (dirname, 0777, msg);
-
-          if (status < 0)
-            {
-              retval(2) = "mkdir";
-              retval(1) = msg;
-            }
-          else
-            retval(0) = true;
-        }
+        retval(0) = true;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -304,54 +298,52 @@
 {
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = std::string ();
   retval(0) = false;
 
-  int nargin = args.length ();
+  std::string dirname = args(0).xstring_value ("rmdir: DIR must be a string");
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string dirname = args(0).xstring_value ("rmdir: DIR must be a string");
+  std::string fulldir = file_ops::tilde_expand (dirname);
+  int status = -1;
+  std::string msg;
 
-      std::string fulldir = file_ops::tilde_expand (dirname);
-      int status = -1;
-      std::string msg;
+  if (nargin == 2)
+    {
+      if (args(1).string_value () == "s")
+        {
+          bool doit = true;
 
-      if (nargin == 2)
-        {
-          if (args(1).string_value () == "s")
+          if (interactive && ! forced_interactive
+              && Vconfirm_recursive_rmdir)
             {
-              bool doit = true;
-
-              if (interactive && ! forced_interactive
-                  && Vconfirm_recursive_rmdir)
-                {
-                  std::string prompt
-                    = "remove entire contents of " + fulldir + "? ";
+              std::string prompt
+                = "remove entire contents of " + fulldir + "? ";
 
-                  doit = octave_yes_or_no (prompt);
-                }
+              doit = octave_yes_or_no (prompt);
+            }
 
-              if (doit)
-                status = octave_recursive_rmdir (fulldir, msg);
-            }
-          else
-            error ("rmdir: second argument must be \"s\" for recursive removal");
+          if (doit)
+            status = octave_recursive_rmdir (fulldir, msg);
         }
       else
-        status = octave_rmdir (fulldir, msg);
-
-      if (status < 0)
-        {
-          retval(2) = "rmdir";
-          retval(1) = msg;
-        }
-      else
-        retval(0) = true;
+        error ("rmdir: second argument must be \"s\" for recursive removal");
     }
   else
-    print_usage ();
+    status = octave_rmdir (fulldir, msg);
+
+  if (status < 0)
+    {
+      retval(2) = "rmdir";
+      retval(1) = msg;
+    }
+  else
+    retval(0) = true;
 
   return retval;
 }
@@ -370,25 +362,23 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 2)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1.0;
 
-  if (args.length () == 2)
-    {
-      std::string from = args(0).xstring_value ("link: OLD must be a string");
-      std::string to = args(1).xstring_value ("link: NEW must be a string");
+  std::string from = args(0).xstring_value ("link: OLD must be a string");
+  std::string to = args(1).xstring_value ("link: NEW must be a string");
 
-      std::string msg;
+  std::string msg;
 
-      int status = octave_link (from, to, msg);
-
-      if (status < 0)
-        retval(1) = msg;
+  int status = octave_link (from, to, msg);
 
-      retval(0) = status;
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(1) = msg;
+
+  retval(0) = status;
 
   return retval;
 }
@@ -407,25 +397,23 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 2)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1.0;
 
-  if (args.length () == 2)
-    {
-      std::string from = args(0).xstring_value ("symlink: OLD must be a string");
-      std::string to = args(1).xstring_value ("symlink: NEW must be a string");
+  std::string from = args(0).xstring_value ("symlink: OLD must be a string");
+  std::string to = args(1).xstring_value ("symlink: NEW must be a string");
 
-      std::string msg;
+  std::string msg;
 
-      int status = octave_symlink (from, to, msg);
-
-      if (status < 0)
-        retval(1) = msg;
+  int status = octave_symlink (from, to, msg);
 
-      retval(0) = status;
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(1) = msg;
+
+  retval(0) = status;
 
   return retval;
 }
@@ -445,27 +433,25 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 1)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = -1.0;
   retval(0) = std::string ();
 
-  if (args.length () == 1)
-    {
-      std::string symlink = args(0).xstring_value ("readlink: SYMLINK must be a string");
+  std::string symlink = args(0).xstring_value ("readlink: SYMLINK must be a string");
 
-      std::string result;
-      std::string msg;
-
-      int status = octave_readlink (symlink, result, msg);
+  std::string result;
+  std::string msg;
 
-      if (status < 0)
-        retval(2) = msg;
+  int status = octave_readlink (symlink, result, msg);
 
-      retval(1) = status;
-      retval(0) = result;
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(2) = msg;
+
+  retval(1) = status;
+  retval(0) = result;
 
   return retval;
 }
@@ -484,25 +470,23 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 2)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1.0;
 
-  if (args.length () == 2)
-    {
-      std::string from = args(0).xstring_value ("rename: OLD must be a string");
-      std::string to = args(1).xstring_value ("rename: NEW must be a string");
+  std::string from = args(0).xstring_value ("rename: OLD must be a string");
+  std::string to = args(1).xstring_value ("rename: NEW must be a string");
 
-      std::string msg;
+  std::string msg;
 
-      int status = octave_rename (from, to, msg);
-
-      if (status < 0)
-        retval(1) = msg;
+  int status = octave_rename (from, to, msg);
 
-      retval(0) = status;
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(1) = msg;
+
+  retval(0) = status;
 
   return retval;
 }
@@ -558,20 +542,14 @@
 @seealso{ls, dir, readdir, what}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      string_vector pat = args(0).xall_strings ("glob: PATTERN must be a string");
-
-      glob_match pattern (file_ops::tilde_expand (pat));
-
-      retval = Cell (pattern.glob ());
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  string_vector pat = args(0).xall_strings ("glob: PATTERN must be a string");
+
+  glob_match pattern (file_ops::tilde_expand (pat));
+
+  return octave_value (Cell (pattern.glob ()));
 }
 
 /*
@@ -625,19 +603,15 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      string_vector pat = args(0).all_strings ();
-      string_vector str = args(1).all_strings ();
-
-      glob_match pattern (file_ops::tilde_expand (pat));
-
-      retval = pattern.match (str);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  string_vector pat = args(0).all_strings ();
+  string_vector str = args(1).all_strings ();
+
+  glob_match pattern (file_ops::tilde_expand (pat));
+
+  return octave_value (pattern.match (str));
 }
 
 DEFUN (filesep, args, ,
@@ -655,9 +629,13 @@
 {
   octave_value retval;
 
-  if (args.length () == 0)
+  int nargin = args.length ();
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 0)
     retval = file_ops::dir_sep_str ();
-  else if (args.length () == 1)
+  else
     {
       std::string s = args(0).xstring_value ("filesep: argument must be a string");
       if (s == "all")
@@ -665,8 +643,6 @@
       else
         error ("filesep: argument must be \"all\"");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -683,6 +659,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargout > 0 || nargin == 0)
     retval = dir_path::path_sep_str ();
 
@@ -705,8 +684,6 @@
           break;
         }
     }
-  else if (nargin > 1)
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/dlmread.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/dlmread.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -203,10 +203,7 @@
     }
 
   if (nargin < 1 || nargin > 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::istream *input = 0;
   std::ifstream input_file;
--- a/libinterp/corefcn/dot.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/dot.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -126,10 +126,7 @@
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value argx = args(0);
   octave_value argy = args(1);
@@ -300,10 +297,7 @@
   int nargin = args.length ();
 
   if (nargin != 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value argx = args(0);
   octave_value argy = args(1);
--- a/libinterp/corefcn/eig.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/eig.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -55,10 +55,7 @@
   int nargin = args.length ();
 
   if (nargin > 2 || nargin == 0 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg_a, arg_b;
 
--- a/libinterp/corefcn/ellipj.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/ellipj.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -73,10 +73,7 @@
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value u_arg = args(0);
   octave_value m_arg = args(1);
--- a/libinterp/corefcn/error.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/error.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -892,133 +892,133 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
   if (nargin != 1)
     print_usage ();
-  else
-    {
-      const octave_scalar_map err = args(0).scalar_map_value ();
+
+  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"))
+    {
+      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;
 
-          std::string file;
-          std::string nm;
-          int l = -1;
-          int c = -1;
+      octave_map err_stack = initialize_last_error_stack ();
+
+      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.numel () > 0)
-                {
-                  if (err_stack.contains ("file"))
-                    file = err_stack.contents ("file")(0).string_value ();
+              if (err_stack.contains ("line"))
+                l = err_stack.contents ("line")(0).nint_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.
+      char *tmp_msg = strsave (msg.c_str ());
+      if (tmp_msg[len-1] == '\n')
+        {
+          if (len > 1)
+            {
+              tmp_msg[len - 1] = '\0';
+              rethrow_error (id.c_str (), "%s\n", tmp_msg);
             }
+        }
+      else
+        rethrow_error (id.c_str (), "%s", tmp_msg);
+      delete [] tmp_msg;
 
-          // Ugh.
-          char *tmp_msg = strsave (msg.c_str ());
-          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[len - 1] = '\0';
-                  rethrow_error (id.c_str (), "%s\n", tmp_msg);
-                }
-            }
-          else
-            rethrow_error (id.c_str (), "%s", tmp_msg);
-          delete [] tmp_msg;
-
-          // 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'");
     }
+  else
+    error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
+
   return retval;
 }
 
@@ -1169,50 +1169,48 @@
 
   if (nargin == 0)
     print_usage ();
-  else
-    {
-      bool have_fmt = false;
+
+  bool have_fmt = false;
 
-      if (nargin == 1 && args(0).is_map ())
-        {
-          // empty struct is not an error.  return and resume calling function.
-          if (args(0).is_empty ())
-            return retval;
+  if (nargin == 1 && args(0).is_map ())
+    {
+      // empty struct is not an error.  return and resume calling function.
+      if (args(0).is_empty ())
+        return retval;
 
-          octave_value_list tmp;
+      octave_value_list tmp;
 
-          octave_scalar_map m = args(0).scalar_map_value ();
+      octave_scalar_map m = args(0).scalar_map_value ();
 
-          // empty struct is not an error.  return and resume calling function.
-          if (m.nfields () == 0)
-            return retval;
+      // empty struct is not an error.  return and resume calling function.
+      if (m.nfields () == 0)
+        return retval;
 
-          if (m.contains ("message"))
-            {
-              octave_value c = m.getfield ("message");
+      if (m.contains ("message"))
+        {
+          octave_value c = m.getfield ("message");
 
-              if (c.is_string ())
-                nargs(0) = c.string_value ();
-            }
+          if (c.is_string ())
+            nargs(0) = c.string_value ();
+        }
 
-          if (m.contains ("identifier"))
-            {
-              octave_value c = m.getfield ("identifier");
+      if (m.contains ("identifier"))
+        {
+          octave_value c = m.getfield ("identifier");
 
-              if (c.is_string ())
-                id = c.string_value ();
-            }
+          if (c.is_string ())
+            id = c.string_value ();
+        }
 
-          // FIXME: also need to handle "stack" field in error structure,
-          //        but that will require some more significant surgery on
-          //        handle_message, error_with_id, etc.
-        }
-      else
-        have_fmt = maybe_extract_message_id ("error", args, nargs, id);
+      // FIXME: also need to handle "stack" field in error structure,
+      //        but that will require some more significant surgery on
+      //        handle_message, error_with_id, etc.
+    }
+  else
+    have_fmt = maybe_extract_message_id ("error", args, nargs, id);
 
-      handle_message (error_with_id, id.c_str (), "unspecified error",
-                      nargs, have_fmt);
-    }
+  handle_message (error_with_id, id.c_str (), "unspecified error",
+                  nargs, have_fmt);
 
   return retval;
 }
@@ -1835,121 +1833,116 @@
 @seealso{lasterr, error, lastwarn}\n\
 @end deftypefn")
 {
-  octave_value retval;
   int nargin = args.length ();
 
-  if (nargin < 2)
-    {
-      octave_scalar_map err;
+  if (nargin > 1)
+    print_usage ();
 
-      err.assign ("message", Vlast_error_message);
-      err.assign ("identifier", Vlast_error_id);
+  octave_scalar_map err;
 
-      err.assign ("stack", octave_value (Vlast_error_stack));
+  err.assign ("message", Vlast_error_message);
+  err.assign ("identifier", Vlast_error_id);
 
-      if (nargin == 1)
+  err.assign ("stack", octave_value (Vlast_error_stack));
+
+  if (nargin == 1)
+    {
+      if (args(0).is_string ())
         {
-          if (args(0).is_string ())
+          if (args(0).string_value () == "reset")
             {
-              if (args(0).string_value () == "reset")
-                {
-                  Vlast_error_message = std::string ();
-                  Vlast_error_id = std::string ();
+              Vlast_error_message = std::string ();
+              Vlast_error_id = std::string ();
 
-                  Vlast_error_stack = initialize_last_error_stack ();
-                }
-              else
-                error ("lasterror: unrecognized string argument");
+              Vlast_error_stack = initialize_last_error_stack ();
             }
-          else if (args(0).is_map ())
+          else
+            error ("lasterror: unrecognized string argument");
+        }
+      else if (args(0).is_map ())
+        {
+          octave_scalar_map new_err = args(0).scalar_map_value ();
+          octave_scalar_map new_err_stack;
+          std::string new_error_message;
+          std::string new_error_id;
+          std::string new_error_file;
+          std::string new_error_name;
+          int new_error_line = -1;
+          int new_error_column = -1;
+
+          if (new_err.contains ("message"))
             {
-              octave_scalar_map new_err = args(0).scalar_map_value ();
-              octave_scalar_map new_err_stack;
-              std::string new_error_message;
-              std::string new_error_id;
-              std::string new_error_file;
-              std::string new_error_name;
-              int new_error_line = -1;
-              int new_error_column = -1;
+              const std::string tmp =
+                new_err.getfield ("message").string_value ();
+              new_error_message = tmp;
+            }
 
-              if (new_err.contains ("message"))
+          if (new_err.contains ("identifier"))
+            {
+              const std::string tmp =
+                new_err.getfield ("identifier").string_value ();
+              new_error_id = tmp;
+            }
+
+          if (new_err.contains ("stack"))
+            {
+              new_err_stack =
+                new_err.getfield ("stack").scalar_map_value ();
+
+              if (new_err_stack.contains ("file"))
                 {
                   const std::string tmp =
-                    new_err.getfield ("message").string_value ();
-                  new_error_message = tmp;
-                }
-
-              if (new_err.contains ("identifier"))
-                {
-                  const std::string tmp =
-                    new_err.getfield ("identifier").string_value ();
-                  new_error_id = tmp;
+                    new_err_stack.getfield ("file").string_value ();
+                  new_error_file = tmp;
                 }
 
-              if (new_err.contains ("stack"))
+              if (new_err_stack.contains ("name"))
                 {
-                  new_err_stack =
-                    new_err.getfield ("stack").scalar_map_value ();
-
-                  if (new_err_stack.contains ("file"))
-                    {
-                      const std::string tmp =
-                        new_err_stack.getfield ("file").string_value ();
-                      new_error_file = tmp;
-                    }
+                  const std::string tmp =
+                    new_err_stack.getfield ("name").string_value ();
+                  new_error_name = tmp;
+                }
 
-                  if (new_err_stack.contains ("name"))
-                    {
-                      const std::string tmp =
-                        new_err_stack.getfield ("name").string_value ();
-                      new_error_name = tmp;
-                    }
-
-                  if (new_err_stack.contains ("line"))
-                    {
-                      const int tmp =
-                        new_err_stack.getfield ("line").nint_value ();
-                      new_error_line = tmp;
-                    }
-
-                  if (new_err_stack.contains ("column"))
-                    {
-                      const int tmp =
-                        new_err_stack.getfield ("column").nint_value ();
-                      new_error_column = tmp;
-                    }
+              if (new_err_stack.contains ("line"))
+                {
+                  const int tmp =
+                    new_err_stack.getfield ("line").nint_value ();
+                  new_error_line = tmp;
                 }
 
-              Vlast_error_message = new_error_message;
-              Vlast_error_id = new_error_id;
-
-              if (new_err.contains ("stack"))
+              if (new_err_stack.contains ("column"))
                 {
-                  new_err_stack.setfield ("file", new_error_file);
-                  new_err_stack.setfield ("name", new_error_name);
-                  new_err_stack.setfield ("line", new_error_line);
-                  new_err_stack.setfield ("column", new_error_column);
-                  Vlast_error_stack = new_err_stack;
-                }
-              else
-                {
-                  // No stack field.  Fill it in with backtrace info.
-                  octave_idx_type curr_frame = -1;
-
-                  Vlast_error_stack
-                    = octave_call_stack::backtrace (0, curr_frame);
+                  const int tmp =
+                    new_err_stack.getfield ("column").nint_value ();
+                  new_error_column = tmp;
                 }
             }
-          else
-            error ("lasterror: argument must be a structure or a string");
-        }
+
+          Vlast_error_message = new_error_message;
+          Vlast_error_id = new_error_id;
 
-      retval = err;
+          if (new_err.contains ("stack"))
+            {
+              new_err_stack.setfield ("file", new_error_file);
+              new_err_stack.setfield ("name", new_error_name);
+              new_err_stack.setfield ("line", new_error_line);
+              new_err_stack.setfield ("column", new_error_column);
+              Vlast_error_stack = new_err_stack;
+            }
+          else
+            {
+              // No stack field.  Fill it in with backtrace info.
+              octave_idx_type curr_frame = -1;
+
+              Vlast_error_stack
+                = octave_call_stack::backtrace (0, curr_frame);
+            }
+        }
+      else
+        error ("lasterror: argument must be a structure or a string");
     }
-  else
-    print_usage ();
 
-  return retval;
+  return octave_value (err);
 }
 
 DEFUN (lasterr, args, nargout,
@@ -1972,27 +1965,25 @@
 
   int argc = args.length () + 1;
 
-  if (argc < 4)
-    {
-      string_vector argv = args.make_argv ("lasterr");
+  if (argc > 3)
+    print_usage ();
 
-      std::string prev_error_id = Vlast_error_id;
-      std::string prev_error_message = Vlast_error_message;
+  string_vector argv = args.make_argv ("lasterr");
 
-      if (argc > 2)
-        Vlast_error_id = argv(2);
+  std::string prev_error_id = Vlast_error_id;
+  std::string prev_error_message = Vlast_error_message;
 
-      if (argc > 1)
-        Vlast_error_message = argv(1);
+  if (argc > 2)
+    Vlast_error_id = argv(2);
+
+  if (argc > 1)
+    Vlast_error_message = argv(1);
 
-      if (argc == 1 || nargout > 0)
-        {
-          retval(1) = prev_error_id;
-          retval(0) = prev_error_message;
-        }
+  if (argc == 1 || nargout > 0)
+    {
+      retval(1) = prev_error_id;
+      retval(0) = prev_error_message;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2017,27 +2008,25 @@
 
   int argc = args.length () + 1;
 
-  if (argc < 4)
-    {
-      string_vector argv = args.make_argv ("lastwarn");
+  if (argc > 3)
+    print_usage ();
 
-      std::string prev_warning_id = Vlast_warning_id;
-      std::string prev_warning_message = Vlast_warning_message;
+  string_vector argv = args.make_argv ("lastwarn");
 
-      if (argc > 2)
-        Vlast_warning_id = argv(2);
+  std::string prev_warning_id = Vlast_warning_id;
+  std::string prev_warning_message = Vlast_warning_message;
 
-      if (argc > 1)
-        Vlast_warning_message = argv(1);
+  if (argc > 2)
+    Vlast_warning_id = argv(2);
+
+  if (argc > 1)
+    Vlast_warning_message = argv(1);
 
-      if (argc == 1 || nargout > 0)
-        {
-          retval(1) = prev_warning_id;
-          retval(0) = prev_warning_message;
-        }
+  if (argc == 1 || nargout > 0)
+    {
+      retval(1) = prev_warning_id;
+      retval(0) = prev_warning_message;
     }
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/fft.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/fft.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -47,10 +47,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
--- a/libinterp/corefcn/fft2.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/fft2.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -49,10 +49,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
--- a/libinterp/corefcn/fftn.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/fftn.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -48,10 +48,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
--- a/libinterp/corefcn/file-io.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/file-io.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -244,16 +244,10 @@
 @seealso{fopen, fflush, freport}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    retval = octave_stream_list::remove (args(0), "fclose");
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_stream_list::remove (args(0), "fclose"));
 }
 
 DEFUN (fclear, args, ,
@@ -266,18 +260,14 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      int fid = octave_stream_list::get_file_number (args(0));
+  if (args.length () != 1)
+    print_usage ();
 
-      octave_stream os = octave_stream_list::lookup (fid, "fclear");
+  int fid = octave_stream_list::get_file_number (args(0));
 
-      os.clearerr ();
-    }
-  else
-    print_usage ();
+  octave_stream os = octave_stream_list::lookup (fid, "fclear");
+
+  os.clearerr ();
 
   return retval;
 }
@@ -299,29 +289,25 @@
 {
   octave_value retval = -1;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
-    {
-      // FIXME: any way to avoid special case for stdout?
-
-      int fid = octave_stream_list::get_file_number (args(0));
+  // FIXME: any way to avoid special case for stdout?
 
-      if (fid == 1)
-        {
-          flush_octave_stdout ();
+  int fid = octave_stream_list::get_file_number (args(0));
 
-          retval = 0;
-        }
-      else
-        {
-          octave_stream os = octave_stream_list::lookup (fid, "fflush");
+  if (fid == 1)
+    {
+      flush_octave_stdout ();
 
-          retval = os.flush ();
-        }
+      retval = 0;
     }
   else
-    print_usage ();
+    {
+      octave_stream os = octave_stream_list::lookup (fid, "fflush");
+
+      retval = os.flush ();
+    }
 
   return retval;
 }
@@ -348,29 +334,27 @@
 
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(1) = 0;
   retval(0) = -1;
 
-  int nargin = args.length ();
+  octave_stream os = octave_stream_list::lookup (args(0), who);
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
+  octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
 
-      octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
-
-      bool err = false;
+  bool err = false;
 
-      std::string tmp = os.getl (len_arg, err, who);
+  std::string tmp = os.getl (len_arg, err, who);
 
-      if (! err)
-        {
-          retval(1) = tmp.length ();
-          retval(0) = tmp;
-        }
+  if (! err)
+    {
+      retval(1) = tmp.length ();
+      retval(0) = tmp;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -397,29 +381,27 @@
 
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(1) = 0.0;
   retval(0) = -1.0;
 
-  int nargin = args.length ();
+  octave_stream os = octave_stream_list::lookup (args(0), who);
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
+  octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
 
-      octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
-
-      bool err = false;
+  bool err = false;
 
-      std::string tmp = os.gets (len_arg, err, who);
+  std::string tmp = os.gets (len_arg, err, who);
 
-      if (! err)
-        {
-          retval(1) = tmp.length ();
-          retval(0) = tmp;
-        }
+  if (! err)
+    {
+      retval(1) = tmp.length ();
+      retval(0) = tmp;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -449,21 +431,19 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
+  octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      bool err = false;
+  octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
 
-      off_t tmp = os.skipl (count_arg, err, who);
+  bool err = false;
 
-      if (! err)
-        retval = tmp;
-    }
-  else
-    print_usage ();
+  off_t tmp = os.skipl (count_arg, err, who);
+
+  if (! err)
+    retval = tmp;
 
   return retval;
 }
@@ -755,18 +735,14 @@
 {
   octave_value retval;
 
+  if (args.length () != 1)
+    print_usage ();
+
   int result = -1;
 
-  int nargin = args.length ();
+  octave_stream os = octave_stream_list::lookup (args(0), "frewind");
 
-  if (nargin == 1)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "frewind");
-
-      result = os.rewind ();
-    }
-  else
-    print_usage ();
+  result = os.rewind ();
 
   if (nargout > 0)
     retval = result;
@@ -797,17 +773,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "fseek");
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  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);
-    }
-  else
-    print_usage ();
+  retval = os.seek (args(1), origin_arg);
 
   return retval;
 }
@@ -822,16 +796,12 @@
 {
   octave_value retval = -1;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "ftell");
+  octave_stream os = octave_stream_list::lookup (args(0), "ftell");
 
-      retval = os.tell ();
-    }
-  else
-    print_usage ();
+  retval = os.tell ();
 
   return retval;
 }
@@ -863,40 +833,38 @@
 
   int nargin = args.length ();
 
-  if (nargin > 1 || (nargin > 0 && args(0).is_string ()))
+  if (! (nargin > 1 || (nargin > 0 && args(0).is_string ())))
+    print_usage ();
+
+  octave_stream os;
+  int fmt_n = 0;
+
+  if (args(0).is_string ())
     {
-      octave_stream os;
-      int fmt_n = 0;
+      os = octave_stream_list::lookup (1, who);
+    }
+  else
+    {
+      fmt_n = 1;
+      os = octave_stream_list::lookup (args(0), who);
+    }
 
-      if (args(0).is_string ())
+  if (args(fmt_n).is_string ())
+    {
+      octave_value_list tmp_args;
+
+      if (nargin > 1 + fmt_n)
         {
-          os = octave_stream_list::lookup (1, who);
-        }
-      else
-        {
-          fmt_n = 1;
-          os = octave_stream_list::lookup (args(0), who);
+          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);
         }
 
-      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
-        error ("%s: format TEMPLATE must be a string", who.c_str ());
+      result = os.printf (args(fmt_n), tmp_args, who);
     }
   else
-    print_usage ();
+    error ("%s: format TEMPLATE must be a string", who.c_str ());
 
   if (nargout > 0)
     retval = result;
@@ -930,27 +898,25 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  if (args(0).is_string ())
     {
-      if (args(0).is_string ())
-        {
-          octave_value_list tmp_args;
+      octave_value_list tmp_args;
 
-          if (nargin > 1)
-            {
-              tmp_args.resize (nargin-1, octave_value ());
+      if (nargin > 1)
+        {
+          tmp_args.resize (nargin-1, octave_value ());
 
-              for (int i = 1; i < nargin; i++)
-                tmp_args(i-1) = args(i);
-            }
+          for (int i = 1; i < nargin; i++)
+            tmp_args(i-1) = args(i);
+        }
 
-          result = stdout_stream.printf (args(0), tmp_args, who);
-        }
-      else
-        error ("%s: format TEMPLATE must be a string", who.c_str ());
+      result = stdout_stream.printf (args(0), tmp_args, who);
     }
   else
-    print_usage ();
+    error ("%s: format TEMPLATE must be a string", who.c_str ());
 
   if (nargout > 0)
     retval = result;
@@ -974,20 +940,12 @@
 {
   static std::string who = "fputs";
 
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
-
-      retval = os.puts (args(1), who);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  octave_stream os = octave_stream_list::lookup (args(0), who);
+
+  return octave_value (os.puts (args(1), who));
 }
 
 DEFUN (puts, args, ,
@@ -1005,14 +963,10 @@
 {
   static std::string who = "puts";
 
-  octave_value retval = -1;
-
-  if (args.length () == 1)
-    retval = stdout_stream.puts (args(0), who);
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (stdout_stream.puts (args(0), who));
 }
 
 DEFUN (sprintf, args, ,
@@ -1037,50 +991,48 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      retval(2) = -1.0;
-      retval(1) = "unknown error";
-      retval(0) = "";
+  if (nargin == 0)
+    print_usage ();
 
-      octave_ostrstream *ostr = new octave_ostrstream ();
+  retval(2) = -1.0;
+  retval(1) = "unknown error";
+  retval(0) = "";
 
-      octave_stream os (ostr);
+  octave_ostrstream *ostr = new octave_ostrstream ();
+
+  octave_stream os (ostr);
 
-      if (os.is_valid ())
-        {
-          octave_value fmt_arg = args(0);
-
-          if (fmt_arg.is_string ())
-            {
-              octave_value_list tmp_args;
+  if (os.is_valid ())
+    {
+      octave_value fmt_arg = args(0);
 
-              if (nargin > 1)
-                {
-                  tmp_args.resize (nargin-1, octave_value ());
+      if (fmt_arg.is_string ())
+        {
+          octave_value_list tmp_args;
 
-                  for (int i = 1; i < nargin; i++)
-                    tmp_args(i-1) = args(i);
-                }
+          if (nargin > 1)
+            {
+              tmp_args.resize (nargin-1, octave_value ());
 
-              retval(2) = os.printf (fmt_arg, tmp_args, who);
-              retval(1) = os.error ();
+              for (int i = 1; i < nargin; i++)
+                tmp_args(i-1) = args(i);
+            }
 
-              std::string result = ostr->str ();
-              char type = fmt_arg.is_sq_string () ? '\'' : '"';
+          retval(2) = os.printf (fmt_arg, tmp_args, who);
+          retval(1) = os.error ();
 
-              retval(0) = (result.empty ()
-                           ? octave_value (charMatrix (1, 0), type)
-                           : octave_value (result, type));
-            }
-          else
-            error ("%s: format TEMPLATE must be a string", who.c_str ());
+          std::string result = ostr->str ();
+          char type = fmt_arg.is_sq_string () ? '\'' : '"';
+
+          retval(0) = (result.empty ()
+                       ? octave_value (charMatrix (1, 0), type)
+                       : octave_value (result, type));
         }
       else
-        error ("%s: unable to create output buffer", who.c_str ());
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
-    print_usage ();
+    error ("%s: unable to create output buffer", who.c_str ());
 
   return retval;
 }
@@ -1141,6 +1093,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
   if (nargin == 3 && args(2).is_string ())
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
@@ -1156,30 +1111,25 @@
       retval(1) = 0.0;
       retval(0) = Matrix ();
 
-      if (nargin == 2 || nargin == 3)
-        {
-          octave_stream os = octave_stream_list::lookup (args(0), who);
+      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 ())
+        {
+          octave_idx_type count = 0;
 
-              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);
+          Array<double> size = (nargin == 3)
+            ? args(2).vector_value ()
+            : Array<double> (dim_vector (1, 1),
+                             lo_ieee_inf_value ());
 
-              retval(2) = os.error ();
-              retval(1) = count;
-              retval(0) = tmp;
-            }
-          else
-            error ("%s: format must be a string", who.c_str ());
+          octave_value tmp = os.scanf (args(1), size, count, who);
+
+          retval(2) = os.error ();
+          retval(1) = count;
+          retval(0) = tmp;
         }
       else
-        print_usage ();
+        error ("%s: format must be a string", who.c_str ());
     }
 
   return retval;
@@ -1221,6 +1171,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
   if (nargin == 3 && args(2).is_string ())
     {
       std::string data = get_sscanf_data (args(0));
@@ -1239,50 +1192,45 @@
     }
   else
     {
-      if (nargin == 2 || nargin == 3)
-        {
-          retval(3) = -1.0;
-          retval(2) = "unknown error";
-          retval(1) = 0.0;
-          retval(0) = Matrix ();
+      retval(3) = -1.0;
+      retval(2) = "unknown error";
+      retval(1) = 0.0;
+      retval(0) = Matrix ();
+
+      std::string data = get_sscanf_data (args(0));
 
-          std::string data = get_sscanf_data (args(0));
-
-          octave_stream os = octave_istrstream::create (data);
+      octave_stream os = octave_istrstream::create (data);
 
-          if (os.is_valid ())
+      if (os.is_valid ())
+        {
+          if (args(1).is_string ())
             {
-              if (args(1).is_string ())
-                {
-                  octave_idx_type count = 0;
+              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);
 
-                  // FIXME: is this the right thing to do?
-                  // Extract error message first, because getting
-                  // position will clear it.
-                  std::string errmsg = os.error ();
+              // FIXME: is this the right thing to do?
+              // Extract error message first, because getting
+              // position will clear it.
+              std::string errmsg = os.error ();
 
-                  retval(3) = (os.eof () ? data.length () : os.tell ()) + 1;
-                  retval(2) = errmsg;
-                  retval(1) = count;
-                  retval(0) = tmp;
-                }
-              else
-                error ("%s: format TEMPLATE must be a string",
-                       who.c_str ());
+              retval(3) = (os.eof () ? data.length () : os.tell ()) + 1;
+              retval(2) = errmsg;
+              retval(1) = count;
+              retval(0) = tmp;
             }
           else
-            error ("%s: unable to create temporary input buffer",
-                   who.c_str  ());
+            error ("%s: format TEMPLATE must be a string",
+                   who.c_str ());
         }
       else
-        print_usage ();
+        error ("%s: unable to create temporary input buffer",
+               who.c_str  ());
     }
 
   return retval;
@@ -1529,46 +1477,44 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0 && nargin < 6)
-    {
-      retval(1) = -1.0;
-      retval(0) = Matrix ();
+  if (nargin < 1 || nargin > 5)
+    print_usage ();
 
-      octave_stream os = octave_stream_list::lookup (args(0), "fread");
+  retval(1) = -1.0;
+  retval(0) = Matrix ();
+
+  octave_stream os = octave_stream_list::lookup (args(0), "fread");
 
-      octave_value size = lo_ieee_inf_value ();
-      octave_value prec = "uchar";
-      octave_value skip = 0;
-      octave_value arch = "unknown";
+  octave_value size = lo_ieee_inf_value ();
+  octave_value prec = "uchar";
+  octave_value skip = 0;
+  octave_value arch = "unknown";
 
-      int idx = 1;
+  int idx = 1;
 
-      if (nargin > idx && ! args(idx).is_string ())
-        size = args(idx++);
-
-      if (nargin > idx)
-        prec = args(idx++);
+  if (nargin > idx && ! args(idx).is_string ())
+    size = args(idx++);
 
-      if (nargin > idx)
-        skip = args(idx++);
+  if (nargin > idx)
+    prec = args(idx++);
+
+  if (nargin > idx)
+    skip = args(idx++);
 
-      if (nargin > idx)
-        arch = args(idx++);
-      else if (skip.is_string ())
-        {
-          arch = skip;
-          skip = 0;
-        }
+  if (nargin > idx)
+    arch = args(idx++);
+  else if (skip.is_string ())
+    {
+      arch = skip;
+      skip = 0;
+    }
 
-      octave_idx_type count = -1;
-
-      octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+  octave_idx_type count = -1;
 
-      retval(1) = count;
-      retval(0) = tmp;
-    }
-  else
-    print_usage ();
+  octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+
+  retval(1) = count;
+  retval(0) = tmp;
 
   return retval;
 }
@@ -1633,44 +1579,36 @@
 @seealso{fread, fputs, fprintf, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin > 1 && nargin < 6)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "fwrite");
-
-      octave_value prec = "uchar";
-      octave_value skip = 0;
-      octave_value arch = "unknown";
-
-      int idx = 1;
-
-      octave_value data = args(idx++);
-
-      if (nargin > idx)
-        prec = args(idx++);
-
-      if (nargin > idx)
-        skip = args(idx++);
-
-      if (nargin > idx)
-        arch = args(idx++);
-      else if (skip.is_string ())
-        {
-          arch = skip;
-          skip = 0;
-        }
-
-      double status = do_fwrite (os, data, prec, skip, arch);
-
-      retval = status;
-    }
-  else
+  if (nargin < 2 || nargin > 5)
     print_usage ();
 
-  return retval;
+  octave_stream os = octave_stream_list::lookup (args(0), "fwrite");
+
+  octave_value prec = "uchar";
+  octave_value skip = 0;
+  octave_value arch = "unknown";
+
+  int idx = 1;
+
+  octave_value data = args(idx++);
+
+  if (nargin > idx)
+    prec = args(idx++);
+
+  if (nargin > idx)
+    skip = args(idx++);
+
+  if (nargin > idx)
+    arch = args(idx++);
+  else if (skip.is_string ())
+    {
+      arch = skip;
+      skip = 0;
+    }
+
+  return octave_value (do_fwrite (os, data, prec, skip, arch));
 }
 
 DEFUNX ("feof", Ffeof, args, ,
@@ -1685,20 +1623,12 @@
 @seealso{fread, frewind, fseek, fclear, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "feof");
-
-      retval = os.eof () ? 1.0 : 0.0;
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  octave_stream os = octave_stream_list::lookup (args(0), "feof");
+
+  return octave_value (os.eof () ? 1.0 : 0.0);
 }
 
 DEFUNX ("ferror", Fferror, args, ,
@@ -1726,28 +1656,26 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "ferror");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      bool clear = false;
+  octave_stream os = octave_stream_list::lookup (args(0), "ferror");
 
-      if (nargin == 2)
-        {
-          std::string opt = args(1).string_value ();
+  bool clear = false;
 
-          clear = (opt == "clear");
-        }
+  if (nargin == 2)
+    {
+      std::string opt = args(1).string_value ();
 
-      int error_number = 0;
+      clear = (opt == "clear");
+    }
 
-      std::string error_message = os.error (clear, error_number);
+  int error_number = 0;
 
-      retval(1) = error_number;
-      retval(0) = error_message;
-    }
-  else
-    print_usage ();
+  std::string error_message = os.error (clear, error_number);
+
+  retval(1) = error_number;
+  retval(0) = error_message;
 
   return retval;
 }
@@ -1792,30 +1720,26 @@
 {
   octave_value retval = -1;
 
-  int nargin = args.length ();
+  if (args.length () != 2)
+    print_usage ();
 
-  if (nargin == 2)
-    {
-      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");
-
-      if (mode == "r")
-        {
-          octave_stream ips = octave_iprocstream::create (name);
+  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");
 
-          retval = octave_stream_list::insert (ips);
-        }
-      else if (mode == "w")
-        {
-          octave_stream ops = octave_oprocstream::create (name);
+  if (mode == "r")
+    {
+      octave_stream ips = octave_iprocstream::create (name);
 
-          retval = octave_stream_list::insert (ops);
-        }
-      else
-        error ("popen: invalid MODE specified");
+      retval = octave_stream_list::insert (ips);
+    }
+  else if (mode == "w")
+    {
+      octave_stream ops = octave_oprocstream::create (name);
+
+      retval = octave_stream_list::insert (ops);
     }
   else
-    print_usage ();
+    error ("popen: invalid MODE specified");
 
   return retval;
 }
@@ -1829,16 +1753,10 @@
 @seealso{fclose, popen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    retval = octave_stream_list::remove (args(0), "pclose");
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_stream_list::remove (args(0), "pclose"));
 }
 
 DEFUN (tempname, args, ,
@@ -1863,26 +1781,22 @@
 {
   octave_value retval;
 
-  int len = args.length ();
-
-  if (len < 3)
-    {
-      std::string dir;
-
-      if (len > 0)
-        dir = args(0).xstring_value ("tempname: DIR must be a string");
+  int nargin = args.length ();
 
-      std::string pfx ("oct-");
-
-      if (len > 1)
-        pfx = args(1).xstring_value ("tempname: PREFIX must be a string");
-
-      retval = octave_tempnam (dir, pfx);
-    }
-  else
+  if (nargin > 2)
     print_usage ();
 
-  return retval;
+  std::string dir;
+
+  if (nargin > 0)
+    dir = args(0).xstring_value ("tempname: DIR must be a string");
+
+  std::string pfx ("oct-");
+
+  if (nargin > 1)
+    pfx = args(1).xstring_value ("tempname: PREFIX must be a string");
+
+  return octave_value (octave_tempnam (dir, pfx));
 }
 
 /*
@@ -1950,37 +1864,33 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 0)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1;
 
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    {
-      FILE *fid = gnulib::tmpfile ();
+  FILE *fid = gnulib::tmpfile ();
 
-      if (fid)
-        {
-          std::string nm;
+  if (fid)
+    {
+      std::string nm;
 
-          std::ios::openmode md = fopen_mode_to_ios_mode ("w+b");
+      std::ios::openmode md = fopen_mode_to_ios_mode ("w+b");
 
-          octave_stream s = octave_stdiostream::create (nm, fid, md);
-
-          if (s)
-            retval(0) = octave_stream_list::insert (s);
-          else
-            error ("tmpfile: failed to create octave_stdiostream object");
+      octave_stream s = octave_stdiostream::create (nm, fid, md);
 
-        }
+      if (s)
+        retval(0) = octave_stream_list::insert (s);
       else
-        {
-          retval(1) = gnulib::strerror (errno);
-          retval(0) = -1;
-        }
+        error ("tmpfile: failed to create octave_stdiostream object");
+
     }
   else
-    print_usage ();
+    {
+      retval(1) = gnulib::strerror (errno);
+      retval(0) = -1;
+    }
 
   return retval;
 }
@@ -2010,60 +1920,58 @@
 {
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = std::string ();
   retval(0) = -1;
 
-  int nargin = args.length ();
+  std::string tmpl8 = args(0).xstring_value ("mkstemp: TEMPLATE argument must be a string");
+
+  OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1);
+  strcpy (tmp, tmpl8.c_str ());
+
+  int fd = gnulib::mkostemp (tmp, O_BINARY);
 
-  if (nargin == 1 || nargin == 2)
+  if (fd < 0)
     {
-      std::string tmpl8 = args(0).xstring_value ("mkstemp: TEMPLATE argument must be a string");
+      retval(2) = gnulib::strerror (errno);
+      retval(0) = fd;
+    }
+  else
+    {
+      const char *fopen_mode = "w+b";
+
+      FILE *fid = fdopen (fd, fopen_mode);
 
-      OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1);
-      strcpy (tmp, tmpl8.c_str ());
+      if (fid)
+        {
+          std::string nm = tmp;
 
-      int fd = gnulib::mkostemp (tmp, O_BINARY);
+          std::ios::openmode md = fopen_mode_to_ios_mode (fopen_mode);
+
+          octave_stream s = octave_stdiostream::create (nm, fid, md);
 
-      if (fd < 0)
-        {
-          retval(2) = gnulib::strerror (errno);
-          retval(0) = fd;
+          if (s)
+            {
+              retval(1) = nm;
+              retval(0) = octave_stream_list::insert (s);
+
+              if (nargin == 2 && args(1).is_true ())
+                mark_for_deletion (nm);
+            }
+          else
+            error ("mkstemp: failed to create octave_stdiostream object");
         }
       else
         {
-          const char *fopen_mode = "w+b";
-
-          FILE *fid = fdopen (fd, fopen_mode);
-
-          if (fid)
-            {
-              std::string nm = tmp;
-
-              std::ios::openmode md = fopen_mode_to_ios_mode (fopen_mode);
-
-              octave_stream s = octave_stdiostream::create (nm, fid, md);
-
-              if (s)
-                {
-                  retval(1) = nm;
-                  retval(0) = octave_stream_list::insert (s);
-
-                  if (nargin == 2 && args(1).is_true ())
-                    mark_for_deletion (nm);
-                }
-              else
-                error ("mkstemp: failed to create octave_stdiostream object");
-            }
-          else
-            {
-              retval(2) = gnulib::strerror (errno);
-              retval(0) = -1;
-            }
+          retval(2) = gnulib::strerror (errno);
+          retval(0) = -1;
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2121,24 +2029,22 @@
 
   int status = 0;
 
-  if (args.length () == 1)
-    {
-      int mask = args(0).xint_value ("umask: MASK must be an integer");
+  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);
-
-          status = convert (octave_umask (oct_mask), 10, 8);
-        }
+  if (mask < 0)
+    {
+      status = -1;
+      error ("umask: MASK must be a positive integer value");
     }
   else
-    print_usage ();
+    {
+      int oct_mask = convert (mask, 8, 10);
+
+      status = convert (octave_umask (oct_mask), 10, 8);
+    }
 
   if (status >= 0)
     retval(0) = status;
@@ -2149,16 +2055,10 @@
 static octave_value
 const_value (const char *, const octave_value_list& args, int val)
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = val;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (val);
 }
 
 DEFUNX ("P_tmpdir", FP_tmpdir, args, ,
@@ -2174,16 +2074,10 @@
 @seealso{tempdir, tempname, mkstemp, tmpfile}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = get_P_tmpdir ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (get_P_tmpdir ());
 }
 
 // NOTE: the values of SEEK_SET, SEEK_CUR, and SEEK_END have to be
@@ -2239,16 +2133,10 @@
 const_value (const char *, const octave_value_list& args,
              const octave_value& val)
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = val;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (val);
 }
 
 DEFUNX ("stdin", Fstdin, args, ,
--- a/libinterp/corefcn/filter.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/filter.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -397,10 +397,7 @@
   int nargin  = args.length ();
 
   if (nargin < 3 || nargin > 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   const char *a_b_errmsg = "filter: A and B must be vectors";
   const char *x_si_errmsg = "filter: X and SI must be arrays";
--- a/libinterp/corefcn/find.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/find.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -388,10 +388,7 @@
   int nargin = args.length ();
 
   if (nargin > 3 || nargin < 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Setup the default options.
   octave_idx_type n_to_find = -1;
--- a/libinterp/corefcn/gammainc.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/gammainc.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -83,6 +83,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
   if (nargin == 3)
     {
       std::string s = args(2).xstring_value ("gammainc: third argument must be \"lower\" or \"upper\"");
@@ -95,9 +98,6 @@
         error ("gammainc: third argument must be \"lower\" or \"upper\"");
     }
 
-  if (nargin < 2 || nargin > 3)
-    print_usage ();
-
   octave_value x_arg = args(0);
   octave_value a_arg = args(1);
 
--- a/libinterp/corefcn/gcd.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/gcd.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -476,33 +476,31 @@
 
   int nargin = args.length ();
 
-  if (nargin > 1)
+  if (nargin < 2)
+    print_usage ();
+
+  if (nargout > 1)
     {
-      if (nargout > 1)
-        {
-          retval.resize (nargin + 1);
-
-          retval(0) = do_extended_gcd (args(0), args(1), retval(1), retval(2));
+      retval.resize (nargin + 1);
 
-          for (int j = 2; j < nargin; j++)
-            {
-              octave_value x;
-              retval(0) = do_extended_gcd (retval(0), args(j),
-                                           x, retval(j+1));
-              for (int i = 0; i < j; i++)
-                retval(i+1).assign (octave_value::op_el_mul_eq, x);
-            }
-        }
-      else
+      retval(0) = do_extended_gcd (args(0), args(1), retval(1), retval(2));
+
+      for (int j = 2; j < nargin; j++)
         {
-          retval(0) = do_simple_gcd (args(0), args(1));
-
-          for (int j = 2; j < nargin; j++)
-            retval(0) = do_simple_gcd (retval(0), args(j));
+          octave_value x;
+          retval(0) = do_extended_gcd (retval(0), args(j),
+                                       x, retval(j+1));
+          for (int i = 0; i < j; i++)
+            retval(i+1).assign (octave_value::op_el_mul_eq, x);
         }
     }
   else
-    print_usage ();
+    {
+      retval(0) = do_simple_gcd (args(0), args(1));
+
+      for (int j = 2; j < nargin; j++)
+        retval(0) = do_simple_gcd (retval(0), args(j));
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/getgrent.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/getgrent.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -73,20 +73,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_group::getgrent may set msg.
+  octave_value val = mk_gr_map (octave_group::getgrent (msg));
 
-      retval(1) = msg;
-      retval(0) = mk_gr_map (octave_group::getgrent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -103,29 +99,26 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
+  double dval = args(0).double_value ();
 
-  if (nargin == 1)
+  if (D_NINT (dval) == dval)
     {
-      double dval = args(0).double_value ();
+      gid_t gid = static_cast<gid_t> (dval);
 
-      if (D_NINT (dval) == dval)
-        {
-          gid_t gid = static_cast<gid_t> (dval);
+      std::string msg;
 
-          std::string msg;
+      // octave_group::getgrgid may set msg.
+      octave_value val = mk_gr_map (octave_group::getgrgid (gid, msg));
 
-          retval(1) = msg;
-          retval(0) = mk_gr_map (octave_group::getgrgid (gid, msg));
-        }
-      else
-        error ("getgrgid: GID must be an integer");
+      retval(1) = msg;
+      retval(0) = val;
     }
+
   else
-    print_usage ();
+    error ("getgrgid: GID must be an integer");
 
   return retval;
 }
@@ -142,22 +135,18 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string s = args(0).string_value ();
 
-  if (nargin == 1)
-    {
-      std::string s = args(0).string_value ();
-
-      std::string msg;
+  std::string msg;
 
-      retval(1) = msg;
-      retval(0) = mk_gr_map (octave_group::getgrnam (s.c_str (), msg));
-    }
-  else
-    print_usage ();
+  // octave_group::getgrnam may set msg.
+  octave_value val = mk_gr_map (octave_group::getgrnam (s.c_str (), msg));
+
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -171,20 +160,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_group::setgrent may set msg.
+  int status = octave_group::setgrent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_group::setgrent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
@@ -198,20 +183,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_group::endgrent may set msg.
+  int status = octave_group::endgrent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_group::endgrent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
--- a/libinterp/corefcn/getpwent.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/getpwent.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -77,20 +77,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_passwd::getpwent may set msg.
+  octave_value val = mk_pw_map (octave_passwd::getpwent (msg));
 
-      retval(1) = msg;
-      retval(0) = mk_pw_map (octave_passwd::getpwent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -107,29 +103,25 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      double dval = args(0).double_value ();
+  double dval = args(0).double_value ();
 
-      if (D_NINT (dval) == dval)
-        {
-          uid_t uid = static_cast<uid_t> (dval);
+  if (D_NINT (dval) == dval)
+    {
+      uid_t uid = static_cast<uid_t> (dval);
 
-          std::string msg;
+      std::string msg;
 
-          retval(1) = msg;
-          retval(0) = mk_pw_map (octave_passwd::getpwuid (uid, msg));
-        }
-      else
-        error ("getpwuid: UID must be an integer");
+      // octave_passwd::getpwuid may set msg.
+      octave_value val = mk_pw_map (octave_passwd::getpwuid (uid, msg));
+
+      retval(1) = msg;
+      retval(0) = val;
     }
   else
-    print_usage ();
+    error ("getpwuid: UID must be an integer");
 
   return retval;
 }
@@ -146,22 +138,18 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0.0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string s = args(0).string_value ();
 
-  if (nargin == 1)
-    {
-      std::string s = args(0).string_value ();
-
-      std::string msg;
+  std::string msg;
 
-      retval(1) = msg;
-      retval(0) = mk_pw_map (octave_passwd::getpwnam (s, msg));
-    }
-  else
-    print_usage ();
+  // octave_passwd::getpwnam may set msg.
+  octave_value val = mk_pw_map (octave_passwd::getpwnam (s, msg));
+
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -175,20 +163,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_passwd::setpwent may set msg.
+  int status = octave_passwd::setpwent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_passwd::setpwent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
@@ -202,20 +186,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_passwd::endpwent may set msg.
+  int status = octave_passwd::endpwent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_passwd::endpwent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
--- a/libinterp/corefcn/givens.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/givens.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -79,96 +79,91 @@
   int nargin = args.length ();
 
   if (nargin != 2 || nargout > 2)
+    print_usage ();
+
+  if (args(0).is_single_type () || args(1).is_single_type ())
     {
-      print_usage ();
-      return retval;
-    }
-  else
-    {
-      if (args(0).is_single_type () || args(1).is_single_type ())
+      if (args(0).is_complex_type () || args(1).is_complex_type ())
         {
-          if (args(0).is_complex_type () || args(1).is_complex_type ())
-            {
-              FloatComplex cx = args(0).float_complex_value ();
-              FloatComplex cy = args(1).float_complex_value ();
-
-              FloatComplexMatrix result = Givens (cx, cy);
+          FloatComplex cx = args(0).float_complex_value ();
+          FloatComplex cy = args(1).float_complex_value ();
 
-              switch (nargout)
-                {
-                case 0:
-                case 1:
-                  retval(0) = result;
-                  break;
+          FloatComplexMatrix result = Givens (cx, cy);
 
-                case 2:
-                  retval(1) = result (0, 1);
-                  retval(0) = result (0, 0);
-                  break;
-                }
-            }
-          else
+          switch (nargout)
             {
-              float x = args(0).float_value ();
-              float y = args(1).float_value ();
-
-              FloatMatrix result = Givens (x, y);
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
 
-              switch (nargout)
-                {
-                case 0:
-                case 1:
-                  retval(0) = result;
-                  break;
-
-                case 2:
-                  retval(1) = result (0, 1);
-                  retval(0) = result (0, 0);
-                  break;
-                }
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
             }
         }
       else
         {
-          if (args(0).is_complex_type () || args(1).is_complex_type ())
-            {
-              Complex cx = args(0).complex_value ();
-              Complex cy = args(1).complex_value ();
+          float x = args(0).float_value ();
+          float y = args(1).float_value ();
 
-              ComplexMatrix result = Givens (cx, cy);
+          FloatMatrix result = Givens (x, y);
 
-              switch (nargout)
-                {
-                case 0:
-                case 1:
-                  retval(0) = result;
-                  break;
+          switch (nargout)
+            {
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
 
-                case 2:
-                  retval(1) = result (0, 1);
-                  retval(0) = result (0, 0);
-                  break;
-                }
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
             }
-          else
+        }
+    }
+  else
+    {
+      if (args(0).is_complex_type () || args(1).is_complex_type ())
+        {
+          Complex cx = args(0).complex_value ();
+          Complex cy = args(1).complex_value ();
+
+          ComplexMatrix result = Givens (cx, cy);
+
+          switch (nargout)
             {
-              double x = args(0).double_value ();
-              double y = args(1).double_value ();
-
-              Matrix result = Givens (x, y);
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
 
-              switch (nargout)
-                {
-                case 0:
-                case 1:
-                  retval(0) = result;
-                  break;
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
+            }
+        }
+      else
+        {
+          double x = args(0).double_value ();
+          double y = args(1).double_value ();
 
-                case 2:
-                  retval(1) = result (0, 1);
-                  retval(0) = result (0, 0);
-                  break;
-                }
+          Matrix result = Givens (x, y);
+
+          switch (nargout)
+            {
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
+
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
             }
         }
     }
--- a/libinterp/corefcn/graphics.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/graphics.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -9588,14 +9588,10 @@
 {
   gh_manager::auto_lock guard;
 
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = is_handle (args(0));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (is_handle (args(0)));
 }
 
 static bool
@@ -9638,14 +9634,10 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = is_handle_visible (args(0));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (is_handle_visible (args(0)));
 }
 
 DEFUN (reset, args, ,
@@ -9667,17 +9659,15 @@
 
   if (nargin != 1)
     print_usage ();
-  else
-    {
-      // get vector of graphics handles
-      ColumnVector hcv = args(0).xvector_value ("reset: H must be a graphics handle");
-
-      // loop over graphics objects
-      for (octave_idx_type n = 0; n < hcv.numel (); n++)
-        gh_manager::get_object (hcv(n)).reset_default_properties ();
-
-      Fdrawnow ();
-    }
+
+  // get vector of graphics handles
+  ColumnVector hcv = args(0).xvector_value ("reset: H must be a graphics handle");
+
+  // loop over graphics objects
+  for (octave_idx_type n = 0; n < hcv.numel (); n++)
+    gh_manager::get_object (hcv(n)).reset_default_properties ();
+
+  Fdrawnow ();
 
   return octave_value ();
 }
@@ -9876,105 +9866,103 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      // get vector of graphics handles
-      ColumnVector hcv = args(0).xvector_value ("set: H must be a graphics handle");
-
-      bool request_drawnow = false;
-
-      // loop over graphics objects
-      for (octave_idx_type n = 0; n < hcv.numel (); n++)
-        {
-          graphics_object go = gh_manager::get_object (hcv(n));
-
-          if (go)
-            {
-              if (nargin == 3
-                  && args(1).is_cellstr () && args(2).is_cell ())
+  if (nargin == 0)
+    print_usage ();
+
+  // get vector of graphics handles
+  ColumnVector hcv = args(0).xvector_value ("set: H must be a graphics handle");
+
+  bool request_drawnow = false;
+
+  // loop over graphics objects
+  for (octave_idx_type n = 0; n < hcv.numel (); n++)
+    {
+      graphics_object go = gh_manager::get_object (hcv(n));
+
+      if (go)
+        {
+          if (nargin == 3
+              && args(1).is_cellstr () && args(2).is_cell ())
+            {
+              if (args(2).cell_value ().rows () == 1)
+                {
+                  go.set (args(1).cellstr_value (),
+                          args(2).cell_value (), 0);
+                }
+              else if (hcv.numel () == args(2).cell_value ().rows ())
                 {
-                  if (args(2).cell_value ().rows () == 1)
-                    {
-                      go.set (args(1).cellstr_value (),
-                              args(2).cell_value (), 0);
-                    }
-                  else if (hcv.numel () == args(2).cell_value ().rows ())
-                    {
-                      go.set (args(1).cellstr_value (),
-                              args(2).cell_value (), n);
-                    }
+                  go.set (args(1).cellstr_value (),
+                          args(2).cell_value (), n);
+                }
+              else
+                {
+                  error ("set: number of graphics handles must match number of value rows (%d != %d)",
+                         hcv.numel (), args(2).cell_value ().rows ());
+                  break;
+
+                }
+            }
+          else if (nargin == 2 && args(1).is_map ())
+            {
+              go.set (args(1).map_value ());
+            }
+          else if (nargin == 2 && args(1).is_string ())
+            {
+              std::string property = args(1).string_value ();
+
+              octave_map pmap = go.values_as_struct ();
+
+              if (go.has_readonly_property (property))
+                if (nargout != 0)
+                  retval = Matrix ();
+                else
+                  octave_stdout << "set: " << property
+                                <<" is read-only" << std::endl;
+              else if (pmap.isfield (property))
+                {
+                  if (nargout != 0)
+                    retval = pmap.getfield (property)(0);
                   else
                     {
-                      error ("set: number of graphics handles must match number of value rows (%d != %d)",
-                             hcv.numel (), args(2).cell_value ().rows ());
-                      break;
-
-                    }
-                }
-              else if (nargin == 2 && args(1).is_map ())
-                {
-                  go.set (args(1).map_value ());
-                }
-              else if (nargin == 2 && args(1).is_string ())
-                {
-                  std::string property = args(1).string_value ();
-
-                  octave_map pmap = go.values_as_struct ();
-
-                  if (go.has_readonly_property (property))
-                    if (nargout != 0)
-                      retval = Matrix ();
-                    else
-                      octave_stdout << "set: " << property
-                                    <<" is read-only" << std::endl;
-                  else if (pmap.isfield (property))
-                    {
-                      if (nargout != 0)
-                        retval = pmap.getfield (property)(0);
-                      else
-                        {
-                          std::string s = go.value_as_string (property);
-
-                          octave_stdout << s;
-                        }
-                    }
-                  else
-                    {
-                      error ("set: unknown property");
-                      break;
-                    }
-                }
-              else if (nargin == 1)
-                {
-                  if (nargout != 0)
-                    retval = go.values_as_struct ();
-                  else
-                    {
-                      std::string s = go.values_as_string ();
+                      std::string s = go.value_as_string (property);
 
                       octave_stdout << s;
                     }
                 }
               else
                 {
-                  go.set (args.splice (0, 1));
-                  request_drawnow = true;
+                  error ("set: unknown property");
+                  break;
+                }
+            }
+          else if (nargin == 1)
+            {
+              if (nargout != 0)
+                retval = go.values_as_struct ();
+              else
+                {
+                  std::string s = go.values_as_string ();
+
+                  octave_stdout << s;
                 }
             }
           else
             {
-              error ("set: invalid handle (= %g)", hcv(n));
-              break;
-            }
-
-          request_drawnow = true;
-        }
-
-      if (request_drawnow)
-        Vdrawnow_requested = true;
-    }
-  else
-    print_usage ();
+              go.set (args.splice (0, 1));
+              request_drawnow = true;
+            }
+        }
+      else
+        {
+          error ("set: invalid handle (= %g)", hcv(n));
+          break;
+        }
+
+      request_drawnow = true;
+    }
+
+  if (request_drawnow)
+    Vdrawnow_requested = true;
 
   return retval;
 }
@@ -10018,113 +10006,111 @@
 
   bool use_cell_format = false;
 
-  if (nargin == 1 || nargin == 2)
-    {
-      if (args(0).is_empty ())
-        {
-          retval = Matrix ();
-          return retval;
-        }
-
-      ColumnVector hcv = args(0).xvector_value ("get: H must be a graphics handle");
-
-      octave_idx_type len = hcv.numel ();
-
-      if (nargin == 1 && len > 1)
-        {
-          std::string typ0 = get_graphics_object_type (hcv(0));
-
-          for (octave_idx_type n = 1; n < len; n++)
-            {
-              std::string typ = get_graphics_object_type (hcv(n));
-
-              if (typ != typ0)
-                {
-                  error ("get: vector of handles must all have the same type");
-                  break;
-                }
-            }
-        }
-
-      if (nargin > 1 && args(1).is_cellstr ())
-        {
-          Array<std::string> plist = args(1).cellstr_value ();
-
-          octave_idx_type plen = plist.numel ();
-
-          use_cell_format = true;
-
-          vals.resize (dim_vector (len, plen));
-
-          for (octave_idx_type n = 0; n < len; n++)
-            {
-              graphics_object go = gh_manager::get_object (hcv(n));
-
-              if (go)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  if (args(0).is_empty ())
+    {
+      retval = Matrix ();
+      return retval;
+    }
+
+  ColumnVector hcv = args(0).xvector_value ("get: H must be a graphics handle");
+
+  octave_idx_type hcv_len = hcv.numel ();
+
+  if (nargin == 1 && hcv_len > 1)
+    {
+      std::string typ0 = get_graphics_object_type (hcv(0));
+
+      for (octave_idx_type n = 1; n < hcv_len; n++)
+        {
+          std::string typ = get_graphics_object_type (hcv(n));
+
+          if (typ != typ0)
+            {
+              error ("get: vector of handles must all have the same type");
+              break;
+            }
+        }
+    }
+
+  if (nargin > 1 && args(1).is_cellstr ())
+    {
+      Array<std::string> plist = args(1).cellstr_value ();
+
+      octave_idx_type plen = plist.numel ();
+
+      use_cell_format = true;
+
+      vals.resize (dim_vector (hcv_len, plen));
+
+      for (octave_idx_type n = 0; n < hcv_len; n++)
+        {
+          graphics_object go = gh_manager::get_object (hcv(n));
+
+          if (go)
+            {
+              for (octave_idx_type m = 0; m < plen; m++)
                 {
-                  for (octave_idx_type m = 0; m < plen; m++)
-                    {
-                      caseless_str property = plist(m);
-
-                      vals(n, m) = go.get (property);
-                    }
-                }
-              else
-                {
-                  error ("get: invalid handle (= %g)", hcv(n));
-                  break;
+                  caseless_str property = plist(m);
+
+                  vals(n, m) = go.get (property);
                 }
             }
-        }
-      else
-        {
-          caseless_str property;
-
-          if (nargin > 1)
-            property = args(1).xstring_value ("get: second argument must be property name or cell array of property names");
-
-          vals.resize (dim_vector (len, 1));
-
-          for (octave_idx_type n = 0; n < len; n++)
-            {
-              graphics_object go = gh_manager::get_object (hcv(n));
-
-              if (go)
-                {
-                  if (nargin == 1)
-                    vals(n) = go.get ();
-                  else
-                    vals(n) = go.get (property);
-                }
+          else
+            {
+              error ("get: invalid handle (= %g)", hcv(n));
+              break;
+            }
+        }
+    }
+  else
+    {
+      caseless_str property;
+
+      if (nargin > 1)
+        property = args(1).xstring_value ("get: second argument must be property name or cell array of property names");
+
+      vals.resize (dim_vector (hcv_len, 1));
+
+      for (octave_idx_type n = 0; n < hcv_len; n++)
+        {
+          graphics_object go = gh_manager::get_object (hcv(n));
+
+          if (go)
+            {
+              if (nargin == 1)
+                vals(n) = go.get ();
               else
-                {
-                  error ("get: invalid handle (= %g)", hcv(n));
-                  break;
-                }
-            }
-        }
-    }
-  else
-    print_usage ();
+                vals(n) = go.get (property);
+            }
+          else
+            {
+              error ("get: invalid handle (= %g)", hcv(n));
+              break;
+            }
+        }
+    }
 
   if (use_cell_format)
     retval = vals;
   else
     {
-      octave_idx_type len = vals.numel ();
-
-      if (len == 0)
+      octave_idx_type vals_len = vals.numel ();
+
+      if (vals_len == 0)
         retval = Matrix ();
-      else if (len == 1)
+      else if (vals_len == 1)
         retval = vals(0);
-      else if (len > 1 && nargin == 1)
-        {
-          OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len);
-
-          for (octave_idx_type n = 0; n < len; n++)
+      else if (vals_len > 1 && nargin == 1)
+        {
+          OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, vals_len);
+
+          for (octave_idx_type n = 0; n < vals_len; n++)
             tmp[n] = vals(n).scalar_map_value ();
 
-          retval = octave_map::cat (0, len, tmp);
+          retval = octave_map::cat (0, vals_len, tmp);
         }
       else
         retval = vals;
@@ -10155,35 +10141,33 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      ColumnVector hcv = args(0).xvector_value ("get: H must be a graphics handle");
-
-      octave_idx_type len = hcv.numel ();
-
-      vals.resize (dim_vector (len, 1));
-
-      for (octave_idx_type n = 0; n < len; n++)
-        {
-          graphics_object go = gh_manager::get_object (hcv(n));
-
-          if (go)
-            vals(n) = go.get (true);
-          else
-            {
-              error ("get: invalid handle (= %g)", hcv(n));
-              break;
-            }
-        }
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
-  octave_idx_type len = vals.numel ();
-
-  if (len > 1)
+  ColumnVector hcv = args(0).xvector_value ("get: H must be a graphics handle");
+
+  octave_idx_type hcv_len = hcv.numel ();
+
+  vals.resize (dim_vector (hcv_len, 1));
+
+  for (octave_idx_type n = 0; n < hcv_len; n++)
+    {
+      graphics_object go = gh_manager::get_object (hcv(n));
+
+      if (go)
+        vals(n) = go.get (true);
+      else
+        {
+          error ("get: invalid handle (= %g)", hcv(n));
+          break;
+        }
+    }
+
+  octave_idx_type vals_len = vals.numel ();
+
+  if (vals_len > 1)
     retval = vals;
-  else if (len == 1)
+  else if (vals_len == 1)
     retval = vals(0);
 
   return retval;
@@ -10266,83 +10250,81 @@
 
   octave_value retval;
 
-  if (args.length () > 0)
-    {
-      double val = args(0).xdouble_value ("__go_figure__: figure number must be a double value");
-
-      if (is_figure (val))
-        {
-          graphics_handle h = gh_manager::lookup (val);
-
-          xset (h, args.splice (0, 1));
+  if (args.length () == 0)
+    print_usage ();
+
+  double val = args(0).xdouble_value ("__go_figure__: figure number must be a double value");
+
+  if (is_figure (val))
+    {
+      graphics_handle h = gh_manager::lookup (val);
+
+      xset (h, args.splice (0, 1));
+
+      retval = h.value ();
+    }
+  else
+    {
+      bool int_fig_handle = true;
+
+      octave_value_list xargs = args.splice (0, 1);
+
+      graphics_handle h = octave_NaN;
+
+      if (xisnan (val))
+        {
+          caseless_str pname ("integerhandle");
+
+          for (int i = 0; i < xargs.length (); i++)
+            {
+              if (xargs(i).is_string ()
+                  && pname.compare (xargs(i).string_value ()))
+                {
+                  if (i < (xargs.length () - 1))
+                    {
+                      std::string pval = xargs(i+1).string_value ();
+
+                      caseless_str on ("on");
+                      int_fig_handle = on.compare (pval);
+                      xargs = xargs.splice (i, 2);
+
+                      break;
+                    }
+                }
+            }
+
+          h = gh_manager::make_graphics_handle ("figure", 0,
+                                                int_fig_handle,
+                                                false, false);
+
+          if (! int_fig_handle)
+            {
+              // We need to initialize the integerhandle property
+              // without calling the set_integerhandle method,
+              // because doing that will generate a new handle value...
+
+              graphics_object go = gh_manager::get_object (h);
+              go.get_properties ().init_integerhandle ("off");
+            }
+        }
+      else if (val > 0 && D_NINT (val) == val)
+        h = gh_manager::make_figure_handle (val, false);
+
+      if (h.ok ())
+        {
+          adopt (0, h);
+
+          gh_manager::push_figure (h);
+
+          xset (h, xargs);
+          xcreatefcn (h);
+          xinitialize (h);
 
           retval = h.value ();
         }
       else
-        {
-          bool int_fig_handle = true;
-
-          octave_value_list xargs = args.splice (0, 1);
-
-          graphics_handle h = octave_NaN;
-
-          if (xisnan (val))
-            {
-              caseless_str pname ("integerhandle");
-
-              for (int i = 0; i < xargs.length (); i++)
-                {
-                  if (xargs(i).is_string ()
-                      && pname.compare (xargs(i).string_value ()))
-                    {
-                      if (i < (xargs.length () - 1))
-                        {
-                          std::string pval = xargs(i+1).string_value ();
-
-                          caseless_str on ("on");
-                          int_fig_handle = on.compare (pval);
-                          xargs = xargs.splice (i, 2);
-
-                          break;
-                        }
-                    }
-                }
-
-              h = gh_manager::make_graphics_handle ("figure", 0,
-                                                    int_fig_handle,
-                                                    false, false);
-
-              if (! int_fig_handle)
-                {
-                  // We need to initialize the integerhandle property
-                  // without calling the set_integerhandle method,
-                  // because doing that will generate a new handle value...
-
-                  graphics_object go = gh_manager::get_object (h);
-                  go.get_properties ().init_integerhandle ("off");
-                }
-            }
-          else if (val > 0 && D_NINT (val) == val)
-            h = gh_manager::make_figure_handle (val, false);
-
-          if (h.ok ())
-            {
-              adopt (0, h);
-
-              gh_manager::push_figure (h);
-
-              xset (h, xargs);
-              xcreatefcn (h);
-              xinitialize (h);
-
-              retval = h.value ();
-            }
-          else
-            error ("__go_figure__: failed to create figure handle");
-        }
-    }
-  else
-    print_usage ();
+        error ("__go_figure__: failed to create figure handle");
+    }
 
   return retval;
 }
@@ -10350,14 +10332,10 @@
 #define GO_BODY(TYPE) \
   gh_manager::auto_lock guard; \
  \
-  octave_value retval; \
- \
-  if (args.length () > 0) \
-    retval = make_graphics_object (#TYPE, false, args);  \
-  else \
+  if (args.length () == 0) \
     print_usage (); \
  \
-  return retval
+  return octave_value (make_graphics_object (#TYPE, false, args)); \
 
 int
 calc_dimensions (const graphics_object& go)
@@ -10403,20 +10381,14 @@
 {
   gh_manager::auto_lock guard;
 
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      double h = args(0).xdouble_value ("__calc_dimensions__: first argument must be a graphics handle");
-
-      retval = calc_dimensions (gh_manager::get_object (h));
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  double h = args(0).xdouble_value ("__calc_dimensions__: first argument must be a graphics handle");
+
+  return octave_value (calc_dimensions (gh_manager::get_object (h)));
 }
 
 DEFUN (__go_axes__, args, ,
@@ -10555,30 +10527,28 @@
 
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      graphics_handle h = octave_NaN;
-
-      const NDArray vals = args(0).xarray_value ("delete: invalid graphics object");
-
-      // Check all the handles to delete are valid first, as callbacks
-      // might delete one of the handles we later want to delete
-      for (octave_idx_type i = 0; i < vals.numel (); i++)
-        {
-          h = gh_manager::lookup (vals(i));
-
-          if (! h.ok ())
-            {
-              error ("delete: invalid graphics object (= %g)", vals(i));
-              break;
-            }
-        }
-
-      delete_graphics_objects (vals);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  graphics_handle h = octave_NaN;
+
+  const NDArray vals = args(0).xarray_value ("delete: invalid graphics object");
+
+  // Check all the handles to delete are valid first, as callbacks
+  // might delete one of the handles we later want to delete
+  for (octave_idx_type i = 0; i < vals.numel (); i++)
+    {
+      h = gh_manager::lookup (vals(i));
+
+      if (! h.ok ())
+        {
+          error ("delete: invalid graphics object (= %g)", vals(i));
+          break;
+        }
+    }
+
+  delete_graphics_objects (vals);
+
   return retval;
 }
 
@@ -10599,30 +10569,28 @@
   if (nargin == 2)
     mode = args(1).string_value ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      graphics_handle h = octave_NaN;
-
-      double val = args(0).xdouble_value ("__go_axes_init__: invalid graphics object");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  graphics_handle h = octave_NaN;
+
+  double val = args(0).xdouble_value ("__go_axes_init__: invalid graphics object");
+
+  h = gh_manager::lookup (val);
+
+  if (h.ok ())
+    {
+      graphics_object go = gh_manager::get_object (h);
+
+      go.set_defaults (mode);
 
       h = gh_manager::lookup (val);
-
-      if (h.ok ())
-        {
-          graphics_object go = gh_manager::get_object (h);
-
-          go.set_defaults (mode);
-
-          h = gh_manager::lookup (val);
-          if (! h.ok ())
-            error ("__go_axes_init__: axis deleted during initialization (= %g)",
-                   val);
-        }
-      else
-        error ("__go_axes_init__: invalid graphics object (= %g)", val);
-    }
-  else
-    print_usage ();
+      if (! h.ok ())
+        error ("__go_axes_init__: axis deleted during initialization (= %g)",
+               val);
+    }
+  else
+    error ("__go_axes_init__: invalid graphics object (= %g)", val);
 
   return retval;
 }
@@ -10670,27 +10638,24 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      double val = args(0).xdouble_value ("__go_execute_callback__: invalid graphics object");
-
-      graphics_handle h = gh_manager::lookup (val);
-
-      if (h.ok ())
-        {
-          std::string name = args(1).xstring_value ("__go_execute_callback__: invalid callback name");
-
-          if (nargin == 2)
-            gh_manager::execute_callback (h, name);
-          else
-            gh_manager::execute_callback (h, name, args(2));
-        }
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  double val = args(0).xdouble_value ("__go_execute_callback__: invalid graphics object");
+
+  graphics_handle h = gh_manager::lookup (val);
+
+  if (h.ok ())
+    {
+      std::string name = args(1).xstring_value ("__go_execute_callback__: invalid callback name");
+
+      if (nargin == 2)
+        gh_manager::execute_callback (h, name);
       else
-        error ("__go_execute_callback__: invalid graphics object (= %g)",
-               val);
-    }
-  else
-    print_usage ();
+        gh_manager::execute_callback (h, name, args(2));
+    }
+  else
+    error ("__go_execute_callback__: invalid graphics object (= %g)", val);
 
   return retval;
 }
@@ -10705,27 +10670,25 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      double h = args(0).xdouble_value ("__image_pixel_size__: argument is not a handle");
-
-      graphics_object go = gh_manager::get_object (h);
-      if (go && go.isa ("image"))
-        {
-          image::properties& ip =
-            dynamic_cast<image::properties&> (go.get_properties ());
-
-          Matrix dp = Matrix (1, 2);
-          dp(0) = ip.pixel_xsize ();
-          dp(1) = ip.pixel_ysize ();
-          retval = dp;
-        }
-      else
-        error ("__image_pixel_size__: object is not an image");
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
+  double h = args(0).xdouble_value ("__image_pixel_size__: argument is not a handle");
+
+  graphics_object go = gh_manager::get_object (h);
+  if (go && go.isa ("image"))
+    {
+      image::properties& ip =
+        dynamic_cast<image::properties&> (go.get_properties ());
+
+      Matrix dp = Matrix (1, 2);
+      dp(0) = ip.pixel_xsize ();
+      dp(1) = ip.pixel_ysize ();
+      retval = dp;
+    }
+  else
+    error ("__image_pixel_size__: object is not an image");
+
   return retval;
 }
 
@@ -10842,15 +10805,13 @@
 
   gh_manager::auto_lock guard;
 
-  if (args.length () == 1)
-    {
-      std::string name = args(0).xstring_value ("register_graphics_toolkit: TOOLKIT must be a string");
-
-      gtk_manager::register_toolkit (name);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  std::string name = args(0).xstring_value ("register_graphics_toolkit: TOOLKIT must be a string");
+
+  gtk_manager::register_toolkit (name);
+
   return retval;
 }
 
@@ -10887,11 +10848,14 @@
 
   octave_value retval;
 
+  if (args.length () > 4)
+    print_usage ();
+
   gh_manager::lock ();
 
   unwind_protect frame;
+
   frame.protect_var (Vdrawnow_requested, false);
-
   frame.protect_var (drawnow_executing);
 
   if (++drawnow_executing <= 1)
@@ -11037,8 +11001,6 @@
           else
             error ("drawnow: nothing to draw");
         }
-      else
-        print_usage ();
     }
 
   gh_manager::unlock ();
@@ -11085,33 +11047,31 @@
 
   octave_value retval;
 
-  if (args.length () >= 3 && args.length () <= 4)
-    {
-      double h = args(0).xdouble_value ("addlistener: invalid handle H");
-
-      std::string pname = args(1).xstring_value ("addlistener: PROP must be a string");
-
-      graphics_handle gh = gh_manager::lookup (h);
-
-      if (gh.ok ())
-        {
-          graphics_object go = gh_manager::get_object (gh);
-
-          go.add_property_listener (pname, args(2), POSTSET);
-
-          if (args.length () == 4)
-            {
-              caseless_str persistent = args(3).string_value ();
-              if (persistent.compare ("persistent"))
-                go.add_property_listener (pname, args(2), PERSISTENT);
-            }
-        }
-      else
-        error ("addlistener: invalid graphics object (= %g)", h);
-    }
-  else
+  if (args.length () < 3 || args.length () > 4)
     print_usage ();
 
+  double h = args(0).xdouble_value ("addlistener: invalid handle H");
+
+  std::string pname = args(1).xstring_value ("addlistener: PROP must be a string");
+
+  graphics_handle gh = gh_manager::lookup (h);
+
+  if (gh.ok ())
+    {
+      graphics_object go = gh_manager::get_object (gh);
+
+      go.add_property_listener (pname, args(2), POSTSET);
+
+      if (args.length () == 4)
+        {
+          caseless_str persistent = args(3).string_value ();
+          if (persistent.compare ("persistent"))
+            go.add_property_listener (pname, args(2), PERSISTENT);
+        }
+    }
+  else
+    error ("addlistener: invalid graphics object (= %g)", h);
+
   return retval;
 }
 
@@ -11147,39 +11107,37 @@
 
   octave_value retval;
 
-  if (args.length () == 3 || args.length () == 2)
-    {
-      double h = args(0).xdouble_value ("dellistener: invalid handle");
-
-      std::string pname = args(1).xstring_value ("dellistener: PROP must be a string");
-
-      graphics_handle gh = gh_manager::lookup (h);
-
-      if (gh.ok ())
-        {
-          graphics_object go = gh_manager::get_object (gh);
-
-          if (args.length () == 2)
-            go.delete_property_listener (pname, octave_value (), POSTSET);
+  if (args.length () < 2 || args.length () > 3)
+    print_usage ();
+
+  double h = args(0).xdouble_value ("dellistener: invalid handle");
+
+  std::string pname = args(1).xstring_value ("dellistener: PROP must be a string");
+
+  graphics_handle gh = gh_manager::lookup (h);
+
+  if (gh.ok ())
+    {
+      graphics_object go = gh_manager::get_object (gh);
+
+      if (args.length () == 2)
+        go.delete_property_listener (pname, octave_value (), POSTSET);
+      else
+        {
+          if (args(2).is_string ()
+              && args(2).string_value () == "persistent")
+            {
+              go.delete_property_listener (pname, octave_value (),
+                                           PERSISTENT);
+              go.delete_property_listener (pname, octave_value (),
+                                           POSTSET);
+            }
           else
-            {
-              if (args(2).is_string ()
-                  && args(2).string_value () == "persistent")
-                {
-                  go.delete_property_listener (pname, octave_value (),
-                                               PERSISTENT);
-                  go.delete_property_listener (pname, octave_value (),
-                                               POSTSET);
-                }
-              else
-                go.delete_property_listener (pname, args(2), POSTSET);
-            }
-        }
-      else
-        error ("dellistener: invalid graphics object (= %g)", h);
-    }
-  else
-    print_usage ();
+            go.delete_property_listener (pname, args(2), POSTSET);
+        }
+    }
+  else
+    error ("dellistener: invalid graphics object (= %g)", h);
 
   return retval;
 }
@@ -11260,36 +11218,34 @@
 
   octave_value retval;
 
-  if (args.length () >= 3)
-    {
-      std::string name = args(0).xstring_value ("addproperty: NAME must be a string");
-
-      double h = args(1).xdouble_value ("addproperty: invalid handle H");
-
-      graphics_handle gh = gh_manager::lookup (h);
-
-      if (gh.ok ())
-        {
-          graphics_object go = gh_manager::get_object (gh);
-
-          std::string type = args(2).xstring_value ("addproperty: TYPE must be a string");
-
-          if (! go.get_properties ().has_property (name))
-            {
-              property p = property::create (name, gh, type,
-                                             args.splice (0, 3));
-
-              go.get_properties ().insert_property (name, p);
-            }
-          else
-            error ("addproperty: a '%s' property already exists in the graphics object",
-                   name.c_str ());
+  if (args.length () < 3)
+    print_usage ();
+
+  std::string name = args(0).xstring_value ("addproperty: NAME must be a string");
+
+  double h = args(1).xdouble_value ("addproperty: invalid handle H");
+
+  graphics_handle gh = gh_manager::lookup (h);
+
+  if (gh.ok ())
+    {
+      graphics_object go = gh_manager::get_object (gh);
+
+      std::string type = args(2).xstring_value ("addproperty: TYPE must be a string");
+
+      if (! go.get_properties ().has_property (name))
+        {
+          property p = property::create (name, gh, type,
+                                         args.splice (0, 3));
+
+          go.get_properties ().insert_property (name, p);
         }
       else
-        error ("addproperty: invalid graphics object (= %g)", h);
-    }
-  else
-    print_usage ();
+        error ("addproperty: a '%s' property already exists in the graphics object",
+               name.c_str ());
+    }
+  else
+    error ("addproperty: invalid graphics object (= %g)", h);
 
   return retval;
 }
@@ -11484,203 +11440,201 @@
 @seealso{waitforbuttonpress, isequal}\n\
 @end deftypefn")
 {
-  if (args.length () > 0)
-    {
-      double h = args(0).xdouble_value ("waitfor: invalid handle value");
-
-      caseless_str pname;
-
-      unwind_protect frame;
-
-      static uint32_t id_counter = 0;
-      uint32_t id = 0;
-
-      int max_arg_index = 0;
-      int timeout_index = -1;
-
-      int timeout = 0;
-
-      if (args.length () > 1)
-        {
-          pname = args(1).xstring_value ("waitfor: PROP must be a string");
-
-          if (! pname.empty () && ! pname.compare ("timeout"))
-            {
-              if (pname.compare ("\\timeout"))
-                pname = "timeout";
-
-              static octave_value wf_listener;
-
-              if (! wf_listener.is_defined ())
-                wf_listener =
-                  octave_value (new octave_builtin (waitfor_listener,
-                                                    "waitfor_listener"));
-
-              max_arg_index++;
-              if (args.length () > 2)
+  if (args.length () == 0)
+    print_usage ();
+
+  double h = args(0).xdouble_value ("waitfor: invalid handle value");
+
+  caseless_str pname;
+
+  unwind_protect frame;
+
+  static uint32_t id_counter = 0;
+  uint32_t id = 0;
+
+  int max_arg_index = 0;
+  int timeout_index = -1;
+
+  int timeout = 0;
+
+  if (args.length () > 1)
+    {
+      pname = args(1).xstring_value ("waitfor: PROP must be a string");
+
+      if (! pname.empty () && ! pname.compare ("timeout"))
+        {
+          if (pname.compare ("\\timeout"))
+            pname = "timeout";
+
+          static octave_value wf_listener;
+
+          if (! wf_listener.is_defined ())
+            wf_listener =
+              octave_value (new octave_builtin (waitfor_listener,
+                                                "waitfor_listener"));
+
+          max_arg_index++;
+          if (args.length () > 2)
+            {
+              if (args(2).is_string ())
                 {
-                  if (args(2).is_string ())
-                    {
-                      caseless_str s = args(2).string_value ();
-
-                      if (s.compare ("timeout"))
-                        timeout_index = 2;
-                      else
-                        max_arg_index++;
-                    }
+                  caseless_str s = args(2).string_value ();
+
+                  if (s.compare ("timeout"))
+                    timeout_index = 2;
                   else
                     max_arg_index++;
                 }
-
-              Cell listener (1, max_arg_index >= 2 ? 5 : 4);
-
-              id = id_counter++;
-              frame.add_fcn (cleanup_waitfor_id, id);
-              waitfor_results[id] = false;
-
-              listener(0) = wf_listener;
-              listener(1) = octave_uint32 (id);
-              listener(2) = h;
-              listener(3) = pname;
-
-              if (max_arg_index >= 2)
-                listener(4) = args(2);
-
-              octave_value ov_listener (listener);
-
-              gh_manager::auto_lock guard;
-
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
+              else
+                max_arg_index++;
+            }
+
+          Cell listener (1, max_arg_index >= 2 ? 5 : 4);
+
+          id = id_counter++;
+          frame.add_fcn (cleanup_waitfor_id, id);
+          waitfor_results[id] = false;
+
+          listener(0) = wf_listener;
+          listener(1) = octave_uint32 (id);
+          listener(2) = h;
+          listener(3) = pname;
+
+          if (max_arg_index >= 2)
+            listener(4) = args(2);
+
+          octave_value ov_listener (listener);
+
+          gh_manager::auto_lock guard;
+
+          graphics_handle gh = gh_manager::lookup (h);
+
+          if (gh.ok ())
+            {
+              graphics_object go = gh_manager::get_object (gh);
+
+              if (max_arg_index >= 2
+                  && compare_property_values (go.get (pname),
+                                              args(2)))
+                waitfor_results[id] = true;
+              else
                 {
-                  graphics_object go = gh_manager::get_object (gh);
-
-                  if (max_arg_index >= 2
-                      && compare_property_values (go.get (pname),
-                                                  args(2)))
-                    waitfor_results[id] = true;
-                  else
+
+                  frame.add_fcn (cleanup_waitfor_postset_listener,
+                                 ov_listener);
+                  go.add_property_listener (pname, ov_listener,
+                                            POSTSET);
+                  go.add_property_listener (pname, ov_listener,
+                                            PERSISTENT);
+
+                  if (go.get_properties ()
+                      .has_dynamic_property (pname))
                     {
-
-                      frame.add_fcn (cleanup_waitfor_postset_listener,
-                                     ov_listener);
-                      go.add_property_listener (pname, ov_listener,
-                                                POSTSET);
-                      go.add_property_listener (pname, ov_listener,
-                                                PERSISTENT);
-
-                      if (go.get_properties ()
-                          .has_dynamic_property (pname))
-                        {
-                          static octave_value wf_del_listener;
-
-                          if (! wf_del_listener.is_defined ())
-                            wf_del_listener =
-                              octave_value (new octave_builtin
-                                            (waitfor_del_listener,
-                                             "waitfor_del_listener"));
-
-                          Cell del_listener (1, 4);
-
-                          del_listener(0) = wf_del_listener;
-                          del_listener(1) = octave_uint32 (id);
-                          del_listener(2) = h;
-                          del_listener(3) = pname;
-
-                          octave_value ov_del_listener (del_listener);
-
-                          frame.add_fcn (cleanup_waitfor_predelete_listener,
-                                         ov_del_listener);
-                          go.add_property_listener (pname, ov_del_listener,
-                                                    PREDELETE);
-                        }
+                      static octave_value wf_del_listener;
+
+                      if (! wf_del_listener.is_defined ())
+                        wf_del_listener =
+                          octave_value (new octave_builtin
+                                        (waitfor_del_listener,
+                                         "waitfor_del_listener"));
+
+                      Cell del_listener (1, 4);
+
+                      del_listener(0) = wf_del_listener;
+                      del_listener(1) = octave_uint32 (id);
+                      del_listener(2) = h;
+                      del_listener(3) = pname;
+
+                      octave_value ov_del_listener (del_listener);
+
+                      frame.add_fcn (cleanup_waitfor_predelete_listener,
+                                     ov_del_listener);
+                      go.add_property_listener (pname, ov_del_listener,
+                                                PREDELETE);
                     }
                 }
             }
-          else if (pname.empty ())
-            error ("waitfor: PROP must be a non-empty string");
-        }
-
-      if (timeout_index < 0 && args.length () > (max_arg_index + 1))
-        {
-          caseless_str s = args(max_arg_index + 1).xstring_value ("waitfor: invalid parameter, expected 'timeout'");
-
-          if (s.compare ("timeout"))
-            timeout_index = max_arg_index + 1;
-          else
-            error ("waitfor: invalid parameter '%s'", s.c_str ());
-        }
-
-      if (timeout_index >= 0)
-        {
-          if (args.length () > (timeout_index + 1))
-            {
-              timeout = static_cast<int>
-                (args(timeout_index + 1).xscalar_value ("waitfor: TIMEOUT must be a scalar >= 1"));
-
-              if (timeout < 1)
-                {
-                  warning ("waitfor: TIMEOUT value must be >= 1, using 1 instead");
-                  timeout = 1;
-                }
+        }
+      else if (pname.empty ())
+        error ("waitfor: PROP must be a non-empty string");
+    }
+
+  if (timeout_index < 0 && args.length () > (max_arg_index + 1))
+    {
+      caseless_str s = args(max_arg_index + 1).xstring_value ("waitfor: invalid parameter, expected 'timeout'");
+
+      if (s.compare ("timeout"))
+        timeout_index = max_arg_index + 1;
+      else
+        error ("waitfor: invalid parameter '%s'", s.c_str ());
+    }
+
+  if (timeout_index >= 0)
+    {
+      if (args.length () > (timeout_index + 1))
+        {
+          timeout = static_cast<int>
+            (args(timeout_index + 1).xscalar_value ("waitfor: TIMEOUT must be a scalar >= 1"));
+
+          if (timeout < 1)
+            {
+              warning ("waitfor: TIMEOUT value must be >= 1, using 1 instead");
+              timeout = 1;
+            }
+        }
+      else
+        error ("waitfor: missing TIMEOUT value");
+    }
+
+  // FIXME: There is still a "hole" in the following loop. The code
+  //        assumes that an object handle is unique, which is a fair
+  //        assumption, except for figures.  If a figure is destroyed
+  //        then recreated with the same figure ID, within the same
+  //        run of event hooks, then the figure destruction won't be
+  //        caught and the loop will not stop.  This is an unlikely
+  //        possibility in practice, though.
+  //
+  //        Using deletefcn callback is also unreliable as it could be
+  //        modified during a callback execution and the waitfor loop
+  //        would not stop.
+  //
+  //        The only "good" implementation would require object
+  //        listeners, similar to property listeners.
+
+  time_t start = 0;
+
+  if (timeout > 0)
+    start = time (0);
+
+  while (true)
+    {
+      if (true)
+        {
+          gh_manager::auto_lock guard;
+
+          graphics_handle gh = gh_manager::lookup (h);
+
+          if (gh.ok ())
+            {
+              if (! pname.empty () && waitfor_results[id])
+                break;
             }
           else
-            error ("waitfor: missing TIMEOUT value");
-        }
-
-      // FIXME: There is still a "hole" in the following loop. The code
-      //        assumes that an object handle is unique, which is a fair
-      //        assumption, except for figures.  If a figure is destroyed
-      //        then recreated with the same figure ID, within the same
-      //        run of event hooks, then the figure destruction won't be
-      //        caught and the loop will not stop.  This is an unlikely
-      //        possibility in practice, though.
-      //
-      //        Using deletefcn callback is also unreliable as it could be
-      //        modified during a callback execution and the waitfor loop
-      //        would not stop.
-      //
-      //        The only "good" implementation would require object
-      //        listeners, similar to property listeners.
-
-      time_t start = 0;
+            break;
+        }
+
+      octave_usleep (100000);
+
+      OCTAVE_QUIT;
+
+      command_editor::run_event_hooks ();
 
       if (timeout > 0)
-        start = time (0);
-
-      while (true)
-        {
-          if (true)
-            {
-              gh_manager::auto_lock guard;
-
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
-                {
-                  if (! pname.empty () && waitfor_results[id])
-                    break;
-                }
-              else
-                break;
-            }
-
-          octave_usleep (100000);
-
-          OCTAVE_QUIT;
-
-          command_editor::run_event_hooks ();
-
-          if (timeout > 0)
-            {
-              if (start + timeout < time (0))
-                break;
-            }
-        }
-    }
-  else
-    print_usage ();
+        {
+          if (start + timeout < time (0))
+            break;
+        }
+    }
 
   return octave_value ();
 }
@@ -11698,10 +11652,7 @@
   int nargin = args.length ();
 
   if (nargin != 2 && nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   double h = args(0).double_value ();
 
--- a/libinterp/corefcn/help.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/help.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1091,20 +1091,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string");
+  if (args.length () != 1)
+    print_usage ();
 
-      std::string text;
-      std::string format;
+  const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string");
 
-      do_get_help_text (name, text, format);
+  std::string text;
+  std::string format;
 
-      retval(1) = format;
-      retval(0) = text;
-    }
-  else
-    print_usage ();
+  do_get_help_text (name, text, format);
+
+  retval(1) = format;
+  retval(0) = text;
 
   return retval;
 }
@@ -1156,20 +1154,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      const std::string fname = args(0).xstring_value ("get_help_text_from_file: NAME must be a string");
+  if (args.length () != 1)
+    print_usage ();
 
-      std::string text;
-      std::string format;
+  const std::string fname = args(0).xstring_value ("get_help_text_from_file: NAME must be a string");
 
-      do_get_help_text_from_file (fname, text, format);
+  std::string text;
+  std::string format;
 
-      retval(1) = format;
-      retval(0) = text;
-    }
-  else
-    print_usage ();
+  do_get_help_text_from_file (fname, text, format);
+
+  retval(1) = format;
+  retval(0) = text;
 
   return retval;
 }
@@ -1288,43 +1284,37 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   string_vector argv = args.make_argv ("which");
 
   int argc = argv.numel ();
 
-  if (argc > 1)
-    {
-      octave_map m (dim_vector (1, argc-1));
-
-      Cell names (1, argc-1);
-      Cell files (1, argc-1);
-      Cell types (1, argc-1);
-
-      for (int i = 1; i < argc; i++)
-        {
-          std::string name = argv[i];
-
-          std::string type;
-
-          std::string file = do_which (name, type);
-
-          names(i-1) = name;
-          files(i-1) = file;
-          types(i-1) = type;
-        }
-
-      m.assign ("name", names);
-      m.assign ("file", files);
-      m.assign ("type", types);
-
-      retval = m;
-    }
-  else
+  if (argc < 2)
     print_usage ();
 
-  return retval;
+  octave_map m (dim_vector (1, argc-1));
+
+  Cell names (1, argc-1);
+  Cell files (1, argc-1);
+  Cell types (1, argc-1);
+
+  for (int i = 1; i < argc; i++)
+    {
+      std::string name = argv[i];
+
+      std::string type;
+
+      std::string file = do_which (name, type);
+
+      names(i-1) = name;
+      files(i-1) = file;
+      types(i-1) = type;
+    }
+
+  m.assign ("name", names);
+  m.assign ("file", files);
+  m.assign ("type", types);
+
+  return octave_value (m);
 }
 
 // FIXME: Are we sure this function always does the right thing?
--- a/libinterp/corefcn/hess.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/hess.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -69,10 +69,7 @@
   int nargin = args.length ();
 
   if (nargin != 1 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
--- a/libinterp/corefcn/hex2num.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/hex2num.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -65,12 +65,13 @@
 @seealso{num2hex, hex2dec, dec2hex}\n\
 @end deftypefn")
 {
+  octave_value retval;
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
-  else if (nargin == 2 && ! args(1).is_string ())
+
+  if (nargin == 2 && ! args(1).is_string ())
     error ("hex2num: CLASS must be a string");
   else
     {
@@ -218,12 +219,13 @@
 @seealso{hex2num, hex2dec, dec2hex}\n\
 @end deftypefn")
 {
+  octave_value retval;
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin != 1)
     print_usage ();
-  else if (args(0).is_single_type ())
+
+  if (args(0).is_single_type ())
     {
       const FloatColumnVector v (args(0).float_vector_value ());
 
--- a/libinterp/corefcn/input.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/input.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -804,16 +804,12 @@
 @seealso{yes_or_no, kbhit, pause, menu, listdlg}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    retval = get_user_input (args, std::max (nargout, 1));
-  else
+  if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  return retval;
+  return get_user_input (args, std::max (nargout, 1));
 }
 
 bool
@@ -850,23 +846,17 @@
 @seealso{input}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 0 || nargin == 1)
-    {
-      std::string prompt;
-
-      if (nargin == 1)
-        prompt = args(0).xstring_value ("yes_or_no: PROMPT must be a string");
-
-      retval = octave_yes_or_no (prompt);
-    }
-  else
+  if (nargin > 1)
     print_usage ();
 
-  return retval;
+  std::string prompt;
+
+  if (nargin == 1)
+    prompt = args(0).xstring_value ("yes_or_no: PROMPT must be a string");
+
+  return octave_value (octave_yes_or_no (prompt));
 }
 
 octave_value
@@ -929,25 +919,23 @@
 
   int nargin = args.length ();
 
-  if (nargin == 0 || nargin == 1)
-    {
-      unwind_protect frame;
+  if (nargin > 1)
+    print_usage ();
 
-      frame.add_fcn (octave_call_stack::restore_frame,
-                     octave_call_stack::current_frame ());
+  unwind_protect frame;
 
-      // Skip the frame assigned to the keyboard function.
-      octave_call_stack::goto_frame_relative (0);
+  frame.add_fcn (octave_call_stack::restore_frame,
+                 octave_call_stack::current_frame ());
 
-      tree_evaluator::debug_mode = true;
-      tree_evaluator::quiet_breakpoint_flag = false;
-
-      tree_evaluator::current_frame = octave_call_stack::current_frame ();
+  // Skip the frame assigned to the keyboard function.
+  octave_call_stack::goto_frame_relative (0);
 
-      do_keyboard (args);
-    }
-  else
-    print_usage ();
+  tree_evaluator::debug_mode = true;
+  tree_evaluator::quiet_breakpoint_flag = false;
+
+  tree_evaluator::current_frame = octave_call_stack::current_frame ();
+
+  do_keyboard (args);
 
   return retval;
 }
@@ -1109,60 +1097,58 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      std::string hint = args(0).string_value ();
+  if (nargin != 1)
+    print_usage ();
 
-      int n = 32;
+  std::string hint = args(0).string_value ();
 
-      string_vector list (n);
+  int n = 32;
+
+  string_vector list (n);
 
-      int k = 0;
+  int k = 0;
 
-      for (;;)
+  for (;;)
+    {
+      std::string cmd = generate_completion (hint, k);
+
+      if (! cmd.empty ())
         {
-          std::string cmd = generate_completion (hint, k);
-
-          if (! cmd.empty ())
+          if (k == n)
             {
-              if (k == n)
-                {
-                  n *= 2;
-                  list.resize (n);
-                }
-
-              list[k++] = cmd;
+              n *= 2;
+              list.resize (n);
             }
-          else
-            {
-              list.resize (k);
-              break;
-            }
-        }
 
-      if (nargout > 0)
-        {
-          if (! list.empty ())
-            retval = list;
-          else
-            retval = "";
+          list[k++] = cmd;
         }
       else
         {
-          // We don't use string_vector::list_in_columns here
-          // because it will be easier for Emacs if the names
-          // appear in a single column.
-
-          int len = list.numel ();
+          list.resize (k);
+          break;
+        }
+    }
 
-          for (int i = 0; i < len; i++)
-            octave_stdout << list[i] << "\n";
-        }
-
-      octave_completion_matches_called = true;
+  if (nargout > 0)
+    {
+      if (! list.empty ())
+        retval = list;
+      else
+        retval = "";
     }
   else
-    print_usage ();
+    {
+      // We don't use string_vector::list_in_columns here
+      // because it will be easier for Emacs if the names
+      // appear in a single column.
+
+      int len = list.numel ();
+
+      for (int i = 0; i < len; i++)
+        octave_stdout << list[i] << "\n";
+    }
+
+  octave_completion_matches_called = true;
 
   return retval;
 }
@@ -1199,16 +1185,17 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     command_editor::read_init_file ();
-  else if (nargin == 1)
+  else
     {
       std::string file = args(0).string_value ();
 
       command_editor::read_init_file (file);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1225,11 +1212,11 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 0)
-    command_editor::re_read_init_file ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
+  command_editor::re_read_init_file ();
+
   return retval;
 }
 
@@ -1264,30 +1251,24 @@
 @seealso{remove_input_event_hook}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_value user_data;
-
-      if (nargin == 2)
-        user_data = args(1);
-
-      hook_function hook_fcn (args(0), user_data);
-
-      if (input_event_hook_functions.empty ())
-        command_editor::add_event_hook (internal_input_event_hook_fcn);
-
-      input_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
-
-      retval = hook_fcn.id ();
-    }
-  else
+  if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  return retval;
+  octave_value user_data;
+
+  if (nargin == 2)
+    user_data = args(1);
+
+  hook_function hook_fcn (args(0), user_data);
+
+  if (input_event_hook_functions.empty ())
+    command_editor::add_event_hook (internal_input_event_hook_fcn);
+
+  input_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
+
+  return octave_value (hook_fcn.id ());
 }
 
 DEFUN (remove_input_event_hook, args, ,
@@ -1304,26 +1285,24 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string hook_fcn_id = args(0).string_value ("remove_input_event_hook: argument not valid as a hook function name or id");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      bool warn = (nargin < 2);
+  std::string hook_fcn_id = args(0).string_value ("remove_input_event_hook: argument not valid as a hook function name or id");
 
-      hook_function_list::iterator p
-        = input_event_hook_functions.find (hook_fcn_id);
+  bool warn = (nargin < 2);
 
-      if (p != input_event_hook_functions.end ())
-        input_event_hook_functions.erase (p);
-      else if (warn)
-        warning ("remove_input_event_hook: %s not found in list",
-                 hook_fcn_id.c_str ());
+  hook_function_list::iterator p
+    = input_event_hook_functions.find (hook_fcn_id);
 
-      if (input_event_hook_functions.empty ())
-        command_editor::remove_event_hook (internal_input_event_hook_fcn);
-    }
-  else
-    print_usage ();
+  if (p != input_event_hook_functions.end ())
+    input_event_hook_functions.erase (p);
+  else if (warn)
+    warning ("remove_input_event_hook: %s not found in list",
+             hook_fcn_id.c_str ());
+
+  if (input_event_hook_functions.empty ())
+    command_editor::remove_event_hook (internal_input_event_hook_fcn);
 
   return retval;
 }
@@ -1475,12 +1454,13 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     Vdrawnow_requested = true;
-  else if (nargin == 1)
+  else
     Vdrawnow_requested = args(0).bool_value ();
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1495,12 +1475,13 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     retval = Vgud_mode;
-  else if (nargin == 1)
+  else
     Vgud_mode = args(0).bool_value ();
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/inv.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/inv.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -63,10 +63,7 @@
   int nargin = args.length ();
 
   if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
--- a/libinterp/corefcn/kron.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/kron.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -268,17 +268,17 @@
 
   int nargin = args.length ();
 
-  if (nargin >= 2)
-    {
-      octave_value a = args(0);
-      octave_value b = args(1);
-      retval = dispatch_kron (a, b);
-      for (octave_idx_type i = 2; i < nargin; i++)
-        retval = dispatch_kron (retval, args(i));
-    }
-  else
+  if (nargin < 2)
     print_usage ();
 
+  octave_value a = args(0);
+  octave_value b = args(1);
+
+  retval = dispatch_kron (a, b);
+
+  for (octave_idx_type i = 2; i < nargin; i++)
+    retval = dispatch_kron (retval, args(i));
+
   return retval;
 }
 
--- a/libinterp/corefcn/load-path.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/load-path.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -2249,13 +2249,16 @@
 
   octave_idx_type nargin = args.length ();
 
+  if (nargin == 0)
+    print_usage ();
+
   if (nargin == 1)
     {
       std::string dirname = args(0).xstring_value ("genpath: DIR must be a string");
 
       retval = genpath (dirname);
     }
-  else if (nargin > 1)
+  else
     {
       std::string dirname = args(0).xstring_value ("genpath: all arguments must be strings");
 
@@ -2266,8 +2269,6 @@
 
       retval = genpath (dirname, skip);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2419,76 +2420,74 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  bool append = false;
+
+  octave_value option_arg = args(nargin-1);
+
+  if (option_arg.is_string ())
     {
-      bool append = false;
-
-      octave_value option_arg = args(nargin-1);
-
-      if (option_arg.is_string ())
+      std::string option = option_arg.string_value ();
+
+      if (option == "-end")
         {
-          std::string option = option_arg.string_value ();
-
-          if (option == "-end")
-            {
-              append = true;
-              nargin--;
-            }
-          else if (option == "-begin")
-            nargin--;
+          append = true;
+          nargin--;
         }
-      else if (option_arg.is_numeric_type ())
+      else if (option == "-begin")
+        nargin--;
+    }
+  else if (option_arg.is_numeric_type ())
+    {
+      int val = option_arg.xint_value ("addpath: OPTION must be '-begin'/0 or '-end'/1");
+
+      if (val == 0)
+        nargin--;
+      else if (val == 1)
         {
-          int val = option_arg.xint_value ("addpath: OPTION must be '-begin'/0 or '-end'/1");
-
-          if (val == 0)
-            nargin--;
-          else if (val == 1)
-            {
-              append = true;
-              nargin--;
-            }
-          else
-            {
-              error ("addpath: OPTION must be '-begin'/0 or '-end'/1");
-              return retval;
-            }
+          append = true;
+          nargin--;
         }
-
-      bool need_to_update = false;
-
-      for (int i = 0; i < nargin; i++)
+      else
         {
-          std::string arg = args(i).xstring_value ("addpath: all arguments must be strings");
-
-          std::list<std::string> dir_elts = split_path (arg);
-
-          if (! append)
-            std::reverse (dir_elts.begin (), dir_elts.end ());
-
-          for (std::list<std::string>::const_iterator p = dir_elts.begin ();
-               p != dir_elts.end ();
-               p++)
-            {
-              std::string dir = *p;
-
-              //dir = regexprep (dir_elts{j}, '//+', "/");
-              //dir = regexprep (dir, '/$', "");
-
-              if (append)
-                load_path::append (dir, true);
-              else
-                load_path::prepend (dir, true);
-
-              need_to_update = true;
-            }
+          error ("addpath: OPTION must be '-begin'/0 or '-end'/1");
+          return retval;
         }
-
-      if (need_to_update)
-        rehash_internal ();
     }
-  else
-    print_usage ();
+
+  bool need_to_update = false;
+
+  for (int i = 0; i < nargin; i++)
+    {
+      std::string arg = args(i).xstring_value ("addpath: all arguments must be strings");
+
+      std::list<std::string> dir_elts = split_path (arg);
+
+      if (! append)
+        std::reverse (dir_elts.begin (), dir_elts.end ());
+
+      for (std::list<std::string>::const_iterator p = dir_elts.begin ();
+           p != dir_elts.end ();
+           p++)
+        {
+          std::string dir = *p;
+
+          //dir = regexprep (dir_elts{j}, '//+', "/");
+          //dir = regexprep (dir, '/$', "");
+
+          if (append)
+            load_path::append (dir, true);
+          else
+            load_path::prepend (dir, true);
+
+          need_to_update = true;
+        }
+    }
+
+  if (need_to_update)
+    rehash_internal ();
 
   return retval;
 }
@@ -2507,7 +2506,7 @@
 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\
 @end deftypefn")
 {
-  // Originally by Etienne Grossmann. Heavily modified and translated
+  // Originally written by Etienne Grossmann.  Heavily modified and translated
   // to C++ by jwe.
 
   octave_value retval;
@@ -2517,36 +2516,34 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  bool need_to_update = false;
+
+  for (int i = 0; i < nargin; i++)
     {
-      bool need_to_update = false;
-
-      for (int i = 0; i < nargin; i++)
+      std::string arg = args(i).xstring_value ("rmpath: all arguments must be strings");
+      std::list<std::string> dir_elts = split_path (arg);
+
+      for (std::list<std::string>::const_iterator p = dir_elts.begin ();
+           p != dir_elts.end ();
+           p++)
         {
-          std::string arg = args(i).xstring_value ("rmpath: all arguments must be strings");
-          std::list<std::string> dir_elts = split_path (arg);
-
-          for (std::list<std::string>::const_iterator p = dir_elts.begin ();
-               p != dir_elts.end ();
-               p++)
-            {
-              std::string dir = *p;
-
-              //dir = regexprep (dir_elts{j}, '//+', "/");
-              //dir = regexprep (dir, '/$', "");
-
-              if (! load_path::remove (dir))
-                warning ("rmpath: %s: not found", dir.c_str ());
-              else
-                need_to_update = true;
-            }
+          std::string dir = *p;
+
+          //dir = regexprep (dir_elts{j}, '//+', "/");
+          //dir = regexprep (dir, '/$', "");
+
+          if (! load_path::remove (dir))
+            warning ("rmpath: %s: not found", dir.c_str ());
+          else
+            need_to_update = true;
         }
-
-      if (need_to_update)
-        rehash_internal ();
     }
-  else
-    print_usage ();
+
+  if (need_to_update)
+    rehash_internal ();
 
   return retval;
 }
--- a/libinterp/corefcn/load-save.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/load-save.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -715,12 +715,9 @@
   if (orig_fname == "")
     {
       if (i == argc)
-        {
-          print_usage ();
-          return retval;
-        }
-      else
-        orig_fname = argv[i];
+        print_usage ();
+
+      orig_fname = argv[i];
     }
   else
     i--;
@@ -1620,10 +1617,7 @@
   int i = 0;
 
   if (i == argc)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (save_as_floats && format == LS_TEXT)
     {
@@ -1660,10 +1654,7 @@
   // Guard against things like 'save a*', which are probably mistakes...
 
   else if (i == argc - 1 && glob_pattern_p (argv[i]))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
   else
     {
       std::string fname = file_ops::tilde_expand (argv[i]);
--- a/libinterp/corefcn/lookup.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/lookup.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -243,10 +243,7 @@
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3 || (nargin == 3 && ! args(2).is_string ()))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value table = args(0);
   octave_value y = args(1);
@@ -285,7 +282,6 @@
 
   if (num_case)
     {
-
       // In the case of a complex array, absolute values will be used for
       // compatibility (though it's not too meaningful).
 
@@ -321,7 +317,6 @@
                                     y.array_value (),
                                     left_inf, right_inf,
                                     match_idx, match_bool);
-
     }
   else if (str_case)
     {
--- a/libinterp/corefcn/lsode.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/lsode.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -276,171 +276,169 @@
 
   int nargin = args.length ();
 
-  if (nargin > 2 && nargin < 5 && nargout < 4)
+  if (nargin < 3 || nargin > 4 || nargout > 3)
+    print_usage ();
+
+  std::string fcn_name, fname, jac_name, jname;
+  lsode_fcn = 0;
+  lsode_jac = 0;
+
+  octave_value f_arg = args(0);
+
+  if (f_arg.is_cell ())
     {
-      std::string fcn_name, fname, jac_name, jname;
-      lsode_fcn = 0;
-      lsode_jac = 0;
-
-      octave_value f_arg = args(0);
+      Cell c = f_arg.cell_value ();
+      if (c.numel () == 1)
+        f_arg = c(0);
+      else if (c.numel () == 2)
+        {
+          if (c(0).is_function_handle () || c(0).is_inline_function ())
+            lsode_fcn = c(0).function_value ();
+          else
+            {
+              fcn_name = unique_symbol_name ("__lsode_fcn__");
+              fname = "function y = ";
+              fname.append (fcn_name);
+              fname.append (" (x, t) y = ");
+              lsode_fcn = extract_function (c(0), "lsode", fcn_name, fname,
+                                            "; endfunction");
+            }
 
-      if (f_arg.is_cell ())
+          if (lsode_fcn)
+            {
+              if (c(1).is_function_handle () || c(1).is_inline_function ())
+                lsode_jac = c(1).function_value ();
+              else
+                {
+                  jac_name = unique_symbol_name ("__lsode_jac__");
+                  jname = "function jac = ";
+                  jname.append (jac_name);
+                  jname.append (" (x, t) jac = ");
+                  lsode_jac = extract_function (c(1), "lsode", jac_name,
+                                                jname, "; endfunction");
+
+                  if (!lsode_jac)
+                    {
+                      if (fcn_name.length ())
+                        clear_function (fcn_name);
+                      lsode_fcn = 0;
+                    }
+                }
+            }
+        }
+      else
+        error ("lsode: incorrect number of elements in cell array");
+    }
+
+  if (!lsode_fcn && ! f_arg.is_cell ())
+    {
+      if (f_arg.is_function_handle () || f_arg.is_inline_function ())
+        lsode_fcn = f_arg.function_value ();
+      else
         {
-          Cell c = f_arg.cell_value ();
-          if (c.numel () == 1)
-            f_arg = c(0);
-          else if (c.numel () == 2)
+          switch (f_arg.rows ())
             {
-              if (c(0).is_function_handle () || c(0).is_inline_function ())
-                lsode_fcn = c(0).function_value ();
-              else
+            case 1:
+              do
                 {
                   fcn_name = unique_symbol_name ("__lsode_fcn__");
                   fname = "function y = ";
                   fname.append (fcn_name);
                   fname.append (" (x, t) y = ");
-                  lsode_fcn = extract_function (c(0), "lsode", fcn_name, fname,
-                                                "; endfunction");
+                  lsode_fcn = extract_function (f_arg, "lsode", fcn_name,
+                                                fname, "; endfunction");
                 }
+              while (0);
+              break;
 
-              if (lsode_fcn)
-                {
-                  if (c(1).is_function_handle () || c(1).is_inline_function ())
-                    lsode_jac = c(1).function_value ();
-                  else
-                    {
-                      jac_name = unique_symbol_name ("__lsode_jac__");
-                      jname = "function jac = ";
-                      jname.append (jac_name);
-                      jname.append (" (x, t) jac = ");
-                      lsode_jac = extract_function (c(1), "lsode", jac_name,
-                                                    jname, "; endfunction");
-
-                      if (!lsode_jac)
-                        {
-                          if (fcn_name.length ())
-                            clear_function (fcn_name);
-                          lsode_fcn = 0;
-                        }
-                    }
-                }
-            }
-          else
-            error ("lsode: incorrect number of elements in cell array");
-        }
+            case 2:
+              {
+                string_vector tmp = f_arg.all_strings ();
 
-      if (!lsode_fcn && ! f_arg.is_cell ())
-        {
-          if (f_arg.is_function_handle () || f_arg.is_inline_function ())
-            lsode_fcn = f_arg.function_value ();
-          else
-            {
-              switch (f_arg.rows ())
-                {
-                case 1:
-                  do
-                    {
-                      fcn_name = unique_symbol_name ("__lsode_fcn__");
-                      fname = "function y = ";
-                      fname.append (fcn_name);
-                      fname.append (" (x, t) y = ");
-                      lsode_fcn = extract_function (f_arg, "lsode", fcn_name,
-                                                    fname, "; endfunction");
-                    }
-                  while (0);
-                  break;
+                fcn_name = unique_symbol_name ("__lsode_fcn__");
+                fname = "function y = ";
+                fname.append (fcn_name);
+                fname.append (" (x, t) y = ");
+                lsode_fcn = extract_function (tmp(0), "lsode", fcn_name,
+                                              fname, "; endfunction");
 
-                case 2:
+                if (lsode_fcn)
                   {
-                    string_vector tmp = f_arg.all_strings ();
+                    jac_name = unique_symbol_name ("__lsode_jac__");
+                    jname = "function jac = ";
+                    jname.append (jac_name);
+                    jname.append (" (x, t) jac = ");
+                    lsode_jac = extract_function (tmp(1), "lsode",
+                                                  jac_name, jname,
+                                                  "; endfunction");
 
-                    fcn_name = unique_symbol_name ("__lsode_fcn__");
-                    fname = "function y = ";
-                    fname.append (fcn_name);
-                    fname.append (" (x, t) y = ");
-                    lsode_fcn = extract_function (tmp(0), "lsode", fcn_name,
-                                                  fname, "; endfunction");
-
-                    if (lsode_fcn)
+                    if (!lsode_jac)
                       {
-                        jac_name = unique_symbol_name ("__lsode_jac__");
-                        jname = "function jac = ";
-                        jname.append (jac_name);
-                        jname.append (" (x, t) jac = ");
-                        lsode_jac = extract_function (tmp(1), "lsode",
-                                                      jac_name, jname,
-                                                      "; endfunction");
-
-                        if (!lsode_jac)
-                          {
-                            if (fcn_name.length ())
-                              clear_function (fcn_name);
-                            lsode_fcn = 0;
-                          }
+                        if (fcn_name.length ())
+                          clear_function (fcn_name);
+                        lsode_fcn = 0;
                       }
                   }
-                  break;
+              }
+              break;
 
-                default:
-                  error ("lsode: first arg should be a string or 2-element string array");
-                }
+            default:
+              error ("lsode: first arg should be a string or 2-element string array");
             }
         }
+    }
 
-      if (! lsode_fcn)
-        error ("lsode: FCN argument is not a valid function name or handle");
+  if (! lsode_fcn)
+    error ("lsode: FCN argument is not a valid function name or handle");
 
-      ColumnVector state = args(1).xvector_value ("lsode: initial state X_0 must be a vector");
-      ColumnVector out_times = args(2).xvector_value ("lsode: output time variable T must be a vector");
+  ColumnVector state = args(1).xvector_value ("lsode: initial state X_0 must be a vector");
+  ColumnVector out_times = args(2).xvector_value ("lsode: output time variable T must be a vector");
 
-      ColumnVector crit_times;
+  ColumnVector crit_times;
 
-      int crit_times_set = 0;
-      if (nargin > 3)
-        {
-          crit_times = args(3).xvector_value ("lsode: list of critical times T_CRIT must be a vector");
+  int crit_times_set = 0;
+  if (nargin > 3)
+    {
+      crit_times = args(3).xvector_value ("lsode: list of critical times T_CRIT must be a vector");
 
-          crit_times_set = 1;
-        }
+      crit_times_set = 1;
+    }
 
-      double tzero = out_times (0);
+  double tzero = out_times (0);
 
-      ODEFunc func (lsode_user_function);
-      if (lsode_jac)
-        func.set_jacobian_function (lsode_user_jacobian);
+  ODEFunc func (lsode_user_function);
+  if (lsode_jac)
+    func.set_jacobian_function (lsode_user_jacobian);
 
-      LSODE ode (state, tzero, func);
-
-      ode.set_options (lsode_opts);
+  LSODE ode (state, tzero, func);
 
-      Matrix output;
-      if (crit_times_set)
-        output = ode.integrate (out_times, crit_times);
-      else
-        output = ode.integrate (out_times);
+  ode.set_options (lsode_opts);
 
-      if (fcn_name.length ())
-        clear_function (fcn_name);
-      if (jac_name.length ())
-        clear_function (jac_name);
+  Matrix output;
+  if (crit_times_set)
+    output = ode.integrate (out_times, crit_times);
+  else
+    output = ode.integrate (out_times);
 
-      std::string msg = ode.error_message ();
+  if (fcn_name.length ())
+    clear_function (fcn_name);
+  if (jac_name.length ())
+    clear_function (jac_name);
 
-      retval(2) = msg;
-      retval(1) = static_cast<double> (ode.integration_state ());
+  std::string msg = ode.error_message ();
+
+  retval(2) = msg;
+  retval(1) = static_cast<double> (ode.integration_state ());
 
-      if (ode.integration_ok ())
-        retval(0) = output;
-      else
-        {
-          retval(0) = Matrix ();
+  if (ode.integration_ok ())
+    retval(0) = output;
+  else
+    {
+      retval(0) = Matrix ();
 
-          if (nargout < 2)
-            error ("lsode: %s", msg.c_str ());
-        }
+      if (nargout < 2)
+        error ("lsode: %s", msg.c_str ());
     }
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/lu.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/lu.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -145,15 +145,12 @@
   octave_value_list retval;
   int nargin = args.length ();
   bool issparse = (nargin > 0 && args(0).is_sparse_type ());
-  bool scale = (nargout  == 5);
 
   if (nargin < 1 || (issparse && (nargin > 3 || nargout > 5))
-      || (!issparse && (nargin > 2 || nargout > 3)))
-    {
-      print_usage ();
-      return retval;
-    }
+      || (! issparse && (nargin > 2 || nargout > 3)))
+    print_usage ();
 
+  bool scale = (nargout == 5);
   bool vecout = false;
   Matrix thres;
 
@@ -629,16 +626,13 @@
 @seealso{lu, cholupdate, qrupdate}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
   octave_idx_type nargin = args.length ();
-  octave_value_list retval;
-
-  bool pivoted = nargin == 5;
 
   if (nargin != 4 && nargin != 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
+
+  bool pivoted = (nargin == 5);
 
   octave_value argl = args(0);
   octave_value argu = args(1);
--- a/libinterp/corefcn/luinc.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/luinc.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -101,241 +101,237 @@
   int nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin == 0)
+  if (nargin < 2 || nargin > 3)
     print_usage ();
-  else if (nargin < 2 || nargin > 3)
-    error ("luinc: incorrect number of arguments");
-  else
-    {
-      bool zero_level = false;
-      bool milu = false;
-      bool udiag = false;
-      Matrix thresh;
-      double droptol = -1.;
-      bool vecout = false;
+
+  bool zero_level = false;
+  bool milu = false;
+  bool udiag = false;
+  Matrix thresh;
+  double droptol = -1.;
+  bool vecout = false;
 
-      if (args(1).is_string ())
-        {
-          if (args(1).string_value () == "0")
-            zero_level = true;
-          else
-            error ("luinc: unrecognized string argument");
-        }
-      else if (args(1).is_map ())
-        {
-          octave_scalar_map map = args(1).xscalar_map_value ("luinc: OPTS must be a scalar structure");
-
-          octave_value tmp;
-
-          tmp = map.getfield ("droptol");
-          if (tmp.is_defined ())
-            droptol = tmp.double_value ();
-
-          tmp = map.getfield ("milu");
-          if (tmp.is_defined ())
-            {
-              double val = tmp.double_value ();
+  if (args(1).is_string ())
+    {
+      if (args(1).string_value () == "0")
+        zero_level = true;
+      else
+        error ("luinc: unrecognized string argument");
+    }
+  else if (args(1).is_map ())
+    {
+      octave_scalar_map map = args(1).xscalar_map_value ("luinc: OPTS must be a scalar structure");
 
-              milu = (val == 0. ? false : true);
-            }
-
-          tmp = map.getfield ("udiag");
-          if (tmp.is_defined ())
-            {
-              double val = tmp.double_value ();
+      octave_value tmp;
 
-              udiag = (val == 0. ? false : true);
-            }
-
-          tmp = map.getfield ("thresh");
-          if (tmp.is_defined ())
-            {
-              thresh = tmp.matrix_value ();
+      tmp = map.getfield ("droptol");
+      if (tmp.is_defined ())
+        droptol = tmp.double_value ();
 
-              if (thresh.numel () == 1)
-                {
-                  thresh.resize (1,2);
-                  thresh(1) = thresh(0);
-                }
-              else if (thresh.numel () != 2)
-                {
-                  error ("luinc: THRESH must be a 1 or 2-element vector");
-                  return retval;
-                }
-            }
+      tmp = map.getfield ("milu");
+      if (tmp.is_defined ())
+        {
+          double val = tmp.double_value ();
+
+          milu = (val == 0. ? false : true);
         }
-      else
-        droptol = args(1).double_value ();
 
-      if (nargin == 3)
+      tmp = map.getfield ("udiag");
+      if (tmp.is_defined ())
         {
-          std::string tmp = args(2).string_value ();
+          double val = tmp.double_value ();
 
-          if (tmp.compare ("vector") == 0)
-            vecout = true;
-          else
-            error ("luinc: unrecognized string argument");
+          udiag = (val == 0. ? false : true);
         }
 
-      // FIXME: Add code for zero-level factorization
-      if (zero_level)
-        error ("luinc: zero-level factorization not implemented");
-
-      if (args(0).type_name () == "sparse matrix")
+      tmp = map.getfield ("thresh");
+      if (tmp.is_defined ())
         {
-          SparseMatrix sm = args(0).sparse_matrix_value ();
-          octave_idx_type sm_nr = sm.rows ();
-          octave_idx_type sm_nc = sm.cols ();
-          ColumnVector Qinit (sm_nc);
-
-          for (octave_idx_type i = 0; i < sm_nc; i++)
-            Qinit (i) = i;
-
-          switch (nargout)
-            {
-            case 0:
-            case 1:
-            case 2:
-              {
-                SparseLU fact (sm, Qinit, thresh, false, true, droptol,
-                               milu, udiag);
-
-                SparseMatrix P = fact.Pr ();
-                SparseMatrix L = P.transpose () * fact.L ();
-
-                retval(1)
-                  = octave_value (fact.U (), MatrixType (MatrixType::Upper));
-
-                retval(0)
-                  = octave_value (L, MatrixType (MatrixType::Permuted_Lower,
-                                                 sm_nr, fact.row_perm ()));
-              }
-              break;
+          thresh = tmp.matrix_value ();
 
-            case 3:
-              {
-                SparseLU fact (sm, Qinit, thresh, false, true, droptol,
-                               milu, udiag);
-
-                if (vecout)
-                  retval(2) = fact.Pr_vec ();
-                else
-                  retval(2) = fact.Pr_mat ();
-
-                retval(1)
-                  = octave_value (fact.U (), MatrixType (MatrixType::Upper));
-
-                retval(0)
-                  = octave_value (fact.L (), MatrixType (MatrixType::Lower));
-              }
-              break;
-
-            case 4:
-            default:
-              {
-                SparseLU fact (sm, Qinit, thresh, false, false, droptol,
-                               milu, udiag);
-
-                if (vecout)
-                  {
-                    retval(3) = fact.Pc_vec ();
-                    retval(2) = fact.Pr_vec ();
-                  }
-                else
-                  {
-                    retval(3) = fact.Pc_mat ();
-                    retval(2) = fact.Pr_mat ();
-                  }
-
-                retval(1)
-                  = octave_value (fact.U (), MatrixType (MatrixType::Upper));
-
-                retval(0)
-                  = octave_value (fact.L (), MatrixType (MatrixType::Lower));
-              }
-              break;
+          if (thresh.numel () == 1)
+            {
+              thresh.resize (1,2);
+              thresh(1) = thresh(0);
+            }
+          else if (thresh.numel () != 2)
+            {
+              error ("luinc: THRESH must be a 1 or 2-element vector");
+              return retval;
             }
         }
-      else if (args(0).type_name () == "sparse complex matrix")
+    }
+  else
+    droptol = args(1).double_value ();
+
+  if (nargin == 3)
+    {
+      std::string tmp = args(2).string_value ();
+
+      if (tmp.compare ("vector") == 0)
+        vecout = true;
+      else
+        error ("luinc: unrecognized string argument");
+    }
+
+  // FIXME: Add code for zero-level factorization
+  if (zero_level)
+    error ("luinc: zero-level factorization not implemented");
+
+  if (args(0).type_name () == "sparse matrix")
+    {
+      SparseMatrix sm = args(0).sparse_matrix_value ();
+      octave_idx_type sm_nr = sm.rows ();
+      octave_idx_type sm_nc = sm.cols ();
+      ColumnVector Qinit (sm_nc);
+
+      for (octave_idx_type i = 0; i < sm_nc; i++)
+        Qinit (i) = i;
+
+      switch (nargout)
         {
-          SparseComplexMatrix sm =
-            args(0).sparse_complex_matrix_value ();
-          octave_idx_type sm_nr = sm.rows ();
-          octave_idx_type sm_nc = sm.cols ();
-          ColumnVector Qinit (sm_nc);
+        case 0:
+        case 1:
+        case 2:
+          {
+            SparseLU fact (sm, Qinit, thresh, false, true, droptol,
+                           milu, udiag);
+
+            SparseMatrix P = fact.Pr ();
+            SparseMatrix L = P.transpose () * fact.L ();
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+
+            retval(0)
+              = octave_value (L, MatrixType (MatrixType::Permuted_Lower,
+                                             sm_nr, fact.row_perm ()));
+          }
+          break;
+
+        case 3:
+          {
+            SparseLU fact (sm, Qinit, thresh, false, true, droptol,
+                           milu, udiag);
 
-          for (octave_idx_type i = 0; i < sm_nc; i++)
-            Qinit (i) = i;
+            if (vecout)
+              retval(2) = fact.Pr_vec ();
+            else
+              retval(2) = fact.Pr_mat ();
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
+
+        case 4:
+        default:
+          {
+            SparseLU fact (sm, Qinit, thresh, false, false, droptol,
+                           milu, udiag);
 
-          switch (nargout)
-            {
-            case 0:
-            case 1:
-            case 2:
+            if (vecout)
+              {
+                retval(3) = fact.Pc_vec ();
+                retval(2) = fact.Pr_vec ();
+              }
+            else
               {
-                SparseComplexLU fact (sm, Qinit, thresh, false, true,
-                                      droptol, milu, udiag);
+                retval(3) = fact.Pc_mat ();
+                retval(2) = fact.Pr_mat ();
+              }
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
+        }
+    }
+  else if (args(0).type_name () == "sparse complex matrix")
+    {
+      SparseComplexMatrix sm =
+        args(0).sparse_complex_matrix_value ();
+      octave_idx_type sm_nr = sm.rows ();
+      octave_idx_type sm_nc = sm.cols ();
+      ColumnVector Qinit (sm_nc);
+
+      for (octave_idx_type i = 0; i < sm_nc; i++)
+        Qinit (i) = i;
+
+      switch (nargout)
+        {
+        case 0:
+        case 1:
+        case 2:
+          {
+            SparseComplexLU fact (sm, Qinit, thresh, false, true,
+                                  droptol, milu, udiag);
 
 
-                SparseMatrix P = fact.Pr ();
-                SparseComplexMatrix L = P.transpose () * fact.L ();
+            SparseMatrix P = fact.Pr ();
+            SparseComplexMatrix L = P.transpose () * fact.L ();
 
-                retval(1)
-                  = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
 
-                retval(0)
-                  = octave_value (L, MatrixType (MatrixType::Permuted_Lower,
-                                                 sm_nr, fact.row_perm ()));
-              }
-              break;
+            retval(0)
+              = octave_value (L, MatrixType (MatrixType::Permuted_Lower,
+                                             sm_nr, fact.row_perm ()));
+          }
+          break;
 
-            case 3:
-              {
-                SparseComplexLU fact (sm, Qinit, thresh, false, true,
-                                      droptol, milu, udiag);
+        case 3:
+          {
+            SparseComplexLU fact (sm, Qinit, thresh, false, true,
+                                  droptol, milu, udiag);
 
-                if (vecout)
-                  retval(2) = fact.Pr_vec ();
-                else
-                  retval(2) = fact.Pr_mat ();
+            if (vecout)
+              retval(2) = fact.Pr_vec ();
+            else
+              retval(2) = fact.Pr_mat ();
 
-                retval(1)
-                  = octave_value (fact.U (), MatrixType (MatrixType::Upper));
-
-                retval(0)
-                  = octave_value (fact.L (), MatrixType (MatrixType::Lower));
-              }
-              break;
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
 
-            case 4:
-            default:
-              {
-                SparseComplexLU fact (sm, Qinit, thresh, false, false,
-                                      droptol, milu, udiag);
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
+
+        case 4:
+        default:
+          {
+            SparseComplexLU fact (sm, Qinit, thresh, false, false,
+                                  droptol, milu, udiag);
 
-                if (vecout)
-                  {
-                    retval(3) = fact.Pc_vec ();
-                    retval(2) = fact.Pr_vec ();
-                  }
-                else
-                  {
-                    retval(3) = fact.Pc_mat ();
-                    retval(2) = fact.Pr_mat ();
-                  }
+            if (vecout)
+              {
+                retval(3) = fact.Pc_vec ();
+                retval(2) = fact.Pr_vec ();
+              }
+            else
+              {
+                retval(3) = fact.Pc_mat ();
+                retval(2) = fact.Pr_mat ();
+              }
 
-                retval(1)
-                  = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
 
-                retval(0)
-                  = octave_value (fact.L (), MatrixType (MatrixType::Lower));
-              }
-              break;
-            }
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
         }
-      else
-        error ("luinc: matrix A must be sparse");
     }
+  else
+    error ("luinc: matrix A must be sparse");
 
   return retval;
 }
--- a/libinterp/corefcn/mappers.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/mappers.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -60,13 +60,10 @@
 @seealso{arg}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).abs ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).abs ());
 }
 
 /*
@@ -93,13 +90,10 @@
 @seealso{cos, acosd}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).acos ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).acos ());
 }
 
 /*
@@ -142,13 +136,10 @@
 @seealso{cosh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).acosh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).acosh ());
 }
 
 /*
@@ -184,13 +175,10 @@
 @seealso{arg}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).arg ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).arg ());
 }
 
 DEFUN (arg, args, ,
@@ -219,13 +207,10 @@
 @seealso{abs}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).arg ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).arg ());
 }
 
 /*
@@ -258,13 +243,10 @@
 @seealso{sin, asind}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).asin ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).asin ());
 }
 
 /*
@@ -306,13 +288,10 @@
 @seealso{sinh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).asinh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).asinh ());
 }
 
 /*
@@ -337,13 +316,10 @@
 @seealso{tan, atand}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).atan ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).atan ());
 }
 
 /*
@@ -372,13 +348,10 @@
 @seealso{tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).atanh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).atanh ());
 }
 
 /*
@@ -406,13 +379,10 @@
 @seealso{nthroot}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).cbrt ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).cbrt ());
 }
 
 /*
@@ -448,13 +418,10 @@
 @seealso{floor, round, fix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).ceil ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).ceil ());
 }
 
 /*
@@ -489,13 +456,10 @@
 @seealso{real, imag}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).conj ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).conj ());
 }
 
 /*
@@ -522,13 +486,10 @@
 @seealso{acos, cosd, cosh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).cos ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).cos ());
 }
 
 /*
@@ -559,13 +520,10 @@
 @seealso{acosh, sinh, tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).cosh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).cosh ());
 }
 
 /*
@@ -610,13 +568,10 @@
 @seealso{erfc, erfcx, erfi, dawson, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erf ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erf ());
 }
 
 /*
@@ -668,13 +623,10 @@
 @seealso{erf, erfc, erfcx, erfi, dawson, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfinv ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfinv ());
 }
 
 /*
@@ -708,13 +660,10 @@
 @seealso{erfc, erf, erfcx, erfi, dawson, erfinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfcinv ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfcinv ());
 }
 
 /*
@@ -750,13 +699,10 @@
 @seealso{erfcinv, erfcx, erfi, dawson, erf, erfinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfc ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfc ());
 }
 
 /*
@@ -789,13 +735,10 @@
 @seealso{erfc, erf, erfi, dawson, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfcx ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfcx ());
 }
 
 /*
@@ -834,13 +777,10 @@
 @seealso{erfc, erf, erfcx, dawson, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfi ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfi ());
 }
 
 /*
@@ -874,13 +814,10 @@
 @seealso{erfc, erf, erfcx, erfi, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).dawson ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).dawson ());
 }
 
 /*
@@ -911,13 +848,10 @@
 @seealso{log}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).exp ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).exp ());
 }
 
 /*
@@ -947,13 +881,10 @@
 @seealso{exp}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).expm1 ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).expm1 ());
 }
 
 /*
@@ -983,13 +914,10 @@
 @seealso{isinf, isnan, isna}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).finite ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).finite ());
 }
 
 /*
@@ -1022,13 +950,10 @@
 @seealso{ceil, floor, round}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).fix ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).fix ());
 }
 
 /*
@@ -1058,13 +983,10 @@
 @seealso{ceil, round, fix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).floor ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).floor ());
 }
 
 /*
@@ -1110,13 +1032,10 @@
 @seealso{gammainc, gammaln, factorial}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).gamma ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).gamma ());
 }
 
 /*
@@ -1156,13 +1075,10 @@
 @seealso{real, conj}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).imag ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).imag ());
 }
 
 /*
@@ -1190,13 +1106,10 @@
 @seealso{isalpha, isdigit, ispunct, isspace, iscntrl}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisalnum ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisalnum ());
 }
 
 /*
@@ -1222,13 +1135,10 @@
 @seealso{isdigit, ispunct, isspace, iscntrl, isalnum, islower, isupper}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisalpha ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisalpha ());
 }
 
 /*
@@ -1251,13 +1161,10 @@
 not.\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisascii ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisascii ());
 }
 
 /*
@@ -1278,13 +1185,10 @@
 @seealso{ispunct, isspace, isalpha, isdigit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xiscntrl ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xiscntrl ());
 }
 
 /*
@@ -1307,13 +1211,10 @@
 @seealso{isxdigit, isalpha, isletter, ispunct, isspace, iscntrl}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisdigit ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisdigit ());
 }
 
 /*
@@ -1344,13 +1245,10 @@
 @seealso{isfinite, isnan, isna}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).isinf ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).isinf ());
 }
 
 /*
@@ -1379,13 +1277,10 @@
 @seealso{isprint}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisgraph ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisgraph ());
 }
 
 /*
@@ -1407,13 +1302,10 @@
 @seealso{isupper, isalpha, isletter, isalnum}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xislower ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xislower ());
 }
 
 /*
@@ -1444,13 +1336,10 @@
 @seealso{isnan, isinf, isfinite}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).isna ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).isna ());
 }
 
 /*
@@ -1487,13 +1376,10 @@
 @seealso{isna, isinf, isfinite}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).isnan ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).isnan ());
 }
 
 /*
@@ -1522,13 +1408,10 @@
 @seealso{isgraph}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisprint ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisprint ());
 }
 
 /*
@@ -1550,13 +1433,10 @@
 @seealso{isalpha, isdigit, isspace, iscntrl}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xispunct ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xispunct ());
 }
 
 /*
@@ -1582,13 +1462,10 @@
 @seealso{iscntrl, ispunct, isalpha, isdigit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisspace ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisspace ());
 }
 
 /*
@@ -1610,13 +1487,10 @@
 @seealso{islower, isalpha, isletter, isalnum}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisupper ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisupper ());
 }
 
 /*
@@ -1638,13 +1512,10 @@
 @seealso{isdigit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisxdigit ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisxdigit ());
 }
 
 /*
@@ -1668,13 +1539,10 @@
 @seealso{gamma, gammainc}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).lgamma ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).lgamma ());
 }
 
 /*
@@ -1722,13 +1590,10 @@
 @seealso{exp, log1p, log2, log10, logspace}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).log ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).log ());
 }
 
 /*
@@ -1749,13 +1614,10 @@
 @seealso{log, log2, logspace, exp}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).log10 ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).log10 ());
 }
 
 /*
@@ -1780,13 +1642,10 @@
 @seealso{log, exp, expm1}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).log1p ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).log1p ());
 }
 
 /*
@@ -1804,13 +1663,10 @@
 @seealso{imag, conj}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).real ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).real ());
 }
 
 /*
@@ -1846,13 +1702,10 @@
 @seealso{ceil, floor, fix, roundb}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).round ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).round ());
 }
 
 /*
@@ -1887,13 +1740,10 @@
 @seealso{round}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).roundb ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).roundb ());
 }
 
 /*
@@ -1950,13 +1800,10 @@
 @seealso{signbit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).signum ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).signum ());
 }
 
 /*
@@ -1990,16 +1837,12 @@
 @seealso{sign}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    {
-      retval = args(0).xsignbit ();
-      retval = (retval != 0);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  octave_value tmp = args(0).xsignbit ();
+
+  return octave_value (tmp != 0);
 }
 
 /*
@@ -2024,13 +1867,10 @@
 @seealso{asin, sind, sinh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).sin ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).sin ());
 }
 
 /*
@@ -2059,13 +1899,10 @@
 @seealso{asinh, cosh, tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).sinh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).sinh ());
 }
 
 /*
@@ -2094,13 +1931,10 @@
 @seealso{realsqrt, nthroot}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).sqrt ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).sqrt ());
 }
 
 /*
@@ -2125,13 +1959,10 @@
 @seealso{atan, tand, tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).tan ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).tan ());
 }
 
 /*
@@ -2160,13 +1991,10 @@
 @seealso{atanh, sinh, cosh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).tanh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).tanh ());
 }
 
 /*
@@ -2201,13 +2029,10 @@
 @seealso{char}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xtoascii ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xtoascii ());
 }
 
 /*
@@ -2241,13 +2066,10 @@
 @seealso{toupper}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xtolower ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xtolower ());
 }
 
 DEFALIAS (lower, tolower);
@@ -2303,13 +2125,10 @@
 @seealso{tolower}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xtoupper ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xtoupper ());
 }
 
 DEFALIAS (upper, toupper);
--- a/libinterp/corefcn/matrix_type.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/matrix_type.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -119,336 +119,332 @@
 @code{matrix_type} will return the correct classification of the matrix.\n\
 @end deftypefn")
 {
+  octave_value retval;
   int nargin = args.length ();
-  octave_value retval;
+
+  if (nargin == 0 || nargin > 4)
+    print_usage ();
+
+  bool autocomp = true;
+  if (nargin == 2 && args(1).is_string ()
+      && args(1).string_value () == "nocompute")
+    {
+      nargin = 1;
+      autocomp = false;
+    }
+
+  if (args(0).is_scalar_type ())
+    {
+      if (nargin == 1)
+        retval = octave_value ("Diagonal");
+      else
+        retval = args(0);
+    }
+  else if (args(0).is_sparse_type ())
+    {
+      if (nargin == 1)
+        {
+          MatrixType mattyp;
+
+          if (args(0).is_complex_type ())
+            {
+              mattyp = args(0).matrix_type ();
+
+              if (mattyp.is_unknown () && autocomp)
+                {
+                  SparseComplexMatrix m =
+                    args(0).sparse_complex_matrix_value ();
+
+                  mattyp = MatrixType (m);
+                  args(0).matrix_type (mattyp);
+                }
+            }
+          else
+            {
+              mattyp = args(0).matrix_type ();
+
+              if (mattyp.is_unknown () && autocomp)
+                {
+                  SparseMatrix m = args(0).sparse_matrix_value ();
+
+                  mattyp = MatrixType (m);
+                  args(0).matrix_type (mattyp);
+                }
+            }
+
+          int typ = mattyp.type ();
 
-  if (nargin == 0)
-    print_usage ();
-  else if (nargin > 4)
-    error ("matrix_type: incorrect number of arguments");
+          if (typ == MatrixType::Diagonal)
+            retval = octave_value ("Diagonal");
+          else if (typ == MatrixType::Permuted_Diagonal)
+            retval = octave_value ("Permuted Diagonal");
+          else if (typ == MatrixType::Upper)
+            retval = octave_value ("Upper");
+          else if (typ == MatrixType::Permuted_Upper)
+            retval = octave_value ("Permuted Upper");
+          else if (typ == MatrixType::Lower)
+            retval = octave_value ("Lower");
+          else if (typ == MatrixType::Permuted_Lower)
+            retval = octave_value ("Permuted Lower");
+          else if (typ == MatrixType::Banded)
+            retval = octave_value ("Banded");
+          else if (typ == MatrixType::Banded_Hermitian)
+            retval = octave_value ("Banded Positive Definite");
+          else if (typ == MatrixType::Tridiagonal)
+            retval = octave_value ("Tridiagonal");
+          else if (typ == MatrixType::Tridiagonal_Hermitian)
+            retval = octave_value ("Tridiagonal Positive Definite");
+          else if (typ == MatrixType::Hermitian)
+            retval = octave_value ("Positive Definite");
+          else if (typ == MatrixType::Rectangular)
+            {
+              if (args(0).rows () == args(0).columns ())
+                retval = octave_value ("Singular");
+              else
+                retval = octave_value ("Rectangular");
+            }
+          else if (typ == MatrixType::Full)
+            retval = octave_value ("Full");
+          else
+            retval = octave_value ("Unknown");
+        }
+      else
+        {
+          // Ok, we're changing the matrix type
+
+          std::string str_typ = args(1).xstring_value ("matrix_type: TYPE must be a string");
+
+          // FIXME: why do I have to explicitly call the constructor?
+          MatrixType mattyp = MatrixType ();
+
+          octave_idx_type nl = 0;
+          octave_idx_type nu = 0;
+
+          // Use STL function to convert to lower case
+          std::transform (str_typ.begin (), str_typ.end (),
+                          str_typ.begin (), tolower);
+
+          if (str_typ == "diagonal")
+            mattyp.mark_as_diagonal ();
+          if (str_typ == "permuted diagonal")
+            mattyp.mark_as_permuted_diagonal ();
+          else if (str_typ == "upper")
+            mattyp.mark_as_upper_triangular ();
+          else if (str_typ == "lower")
+            mattyp.mark_as_lower_triangular ();
+          else if (str_typ == "banded"
+                   || str_typ == "banded positive definite")
+            {
+              if (nargin != 4)
+                error ("matrix_type: banded matrix type requires 4 arguments");
+              else
+                {
+                  nl = args(2).xnint_value ("matrix_type: band size NL, NU must be integers");
+                  nu = args(3).xnint_value ("matrix_type: band size NL, NU must be integers");
+
+                  if (nl == 1 && nu == 1)
+                    mattyp.mark_as_tridiagonal ();
+                  else
+                    mattyp.mark_as_banded (nu, nl);
+
+                  if (str_typ == "banded positive definite")
+                    mattyp.mark_as_symmetric ();
+                }
+            }
+          else if (str_typ == "positive definite")
+            {
+              mattyp.mark_as_full ();
+              mattyp.mark_as_symmetric ();
+            }
+          else if (str_typ == "singular")
+            mattyp.mark_as_rectangular ();
+          else if (str_typ == "full")
+            mattyp.mark_as_full ();
+          else if (str_typ == "unknown")
+            mattyp.invalidate_type ();
+          else
+            error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
+
+          if (nargin == 3
+              && (str_typ == "upper" || str_typ == "lower"))
+            {
+              const ColumnVector perm = args(2).vector_value ("matrix_type: Invalid permutation vector PERM");
+
+              octave_idx_type len = perm.numel ();
+              dim_vector dv = args(0).dims ();
+
+              if (len != dv(0))
+                error ("matrix_type: Invalid permutation vector PERM");
+              else
+                {
+                  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
+
+                  for (octave_idx_type i = 0; i < len; i++)
+                    p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
+
+                  mattyp.mark_as_permuted (len, p);
+                }
+            }
+          else if (nargin != 2
+                   && str_typ != "banded positive definite"
+                   && str_typ != "banded")
+            error ("matrix_type: Invalid number of arguments");
+
+          // Set the matrix type
+          if (args(0).is_complex_type ())
+            retval = octave_value (args(0).sparse_complex_matrix_value (),
+                                   mattyp);
+          else
+            retval = octave_value (args(0).sparse_matrix_value (),
+                                   mattyp);
+        }
+    }
   else
     {
-      bool autocomp = true;
-      if (nargin == 2 && args(1).is_string ()
-          && args(1).string_value () == "nocompute")
-        {
-          nargin = 1;
-          autocomp = false;
-        }
-
-      if (args(0).is_scalar_type ())
+      if (nargin == 1)
         {
-          if (nargin == 1)
-            retval = octave_value ("Diagonal");
-          else
-            retval = args(0);
-        }
-      else if (args(0).is_sparse_type ())
-        {
-          if (nargin == 1)
+          MatrixType mattyp;
+
+          if (args(0).is_complex_type ())
             {
-              MatrixType mattyp;
+              mattyp = args(0).matrix_type ();
 
-              if (args(0).is_complex_type ())
+              if (mattyp.is_unknown () && autocomp)
                 {
-                  mattyp = args(0).matrix_type ();
-
-                  if (mattyp.is_unknown () && autocomp)
+                  if (args(0).is_single_type ())
                     {
-                      SparseComplexMatrix m =
-                        args(0).sparse_complex_matrix_value ();
+                      FloatComplexMatrix m;
+                      m = args(0).float_complex_matrix_value ();
 
                       mattyp = MatrixType (m);
                       args(0).matrix_type (mattyp);
                     }
-                }
-              else
-                {
-                  mattyp = args(0).matrix_type ();
-
-                  if (mattyp.is_unknown () && autocomp)
+                  else
                     {
-                      SparseMatrix m = args(0).sparse_matrix_value ();
+                      ComplexMatrix m = args(0).complex_matrix_value ();
 
                       mattyp = MatrixType (m);
                       args(0).matrix_type (mattyp);
                     }
                 }
-
-              int typ = mattyp.type ();
-
-              if (typ == MatrixType::Diagonal)
-                retval = octave_value ("Diagonal");
-              else if (typ == MatrixType::Permuted_Diagonal)
-                retval = octave_value ("Permuted Diagonal");
-              else if (typ == MatrixType::Upper)
-                retval = octave_value ("Upper");
-              else if (typ == MatrixType::Permuted_Upper)
-                retval = octave_value ("Permuted Upper");
-              else if (typ == MatrixType::Lower)
-                retval = octave_value ("Lower");
-              else if (typ == MatrixType::Permuted_Lower)
-                retval = octave_value ("Permuted Lower");
-              else if (typ == MatrixType::Banded)
-                retval = octave_value ("Banded");
-              else if (typ == MatrixType::Banded_Hermitian)
-                retval = octave_value ("Banded Positive Definite");
-              else if (typ == MatrixType::Tridiagonal)
-                retval = octave_value ("Tridiagonal");
-              else if (typ == MatrixType::Tridiagonal_Hermitian)
-                retval = octave_value ("Tridiagonal Positive Definite");
-              else if (typ == MatrixType::Hermitian)
-                retval = octave_value ("Positive Definite");
-              else if (typ == MatrixType::Rectangular)
-                {
-                  if (args(0).rows () == args(0).columns ())
-                    retval = octave_value ("Singular");
-                  else
-                    retval = octave_value ("Rectangular");
-                }
-              else if (typ == MatrixType::Full)
-                retval = octave_value ("Full");
-              else
-                retval = octave_value ("Unknown");
             }
           else
             {
-              // Ok, we're changing the matrix type
-
-              std::string str_typ = args(1).xstring_value ("matrix_type: TYPE must be a string");
-
-              // FIXME: why do I have to explicitly call the constructor?
-              MatrixType mattyp = MatrixType ();
-
-              octave_idx_type nl = 0;
-              octave_idx_type nu = 0;
-
-              // Use STL function to convert to lower case
-              std::transform (str_typ.begin (), str_typ.end (),
-                              str_typ.begin (), tolower);
+              mattyp = args(0).matrix_type ();
 
-              if (str_typ == "diagonal")
-                mattyp.mark_as_diagonal ();
-              if (str_typ == "permuted diagonal")
-                mattyp.mark_as_permuted_diagonal ();
-              else if (str_typ == "upper")
-                mattyp.mark_as_upper_triangular ();
-              else if (str_typ == "lower")
-                mattyp.mark_as_lower_triangular ();
-              else if (str_typ == "banded"
-                       || str_typ == "banded positive definite")
+              if (mattyp.is_unknown () && autocomp)
                 {
-                  if (nargin != 4)
-                    error ("matrix_type: banded matrix type requires 4 arguments");
+                  if (args(0).is_single_type ())
+                    {
+                      FloatMatrix m = args(0).float_matrix_value ();
+
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
+                    }
                   else
                     {
-                      nl = args(2).xnint_value ("matrix_type: band size NL, NU must be integers");
-                      nu = args(3).xnint_value ("matrix_type: band size NL, NU must be integers");
+                      Matrix m = args(0).matrix_value ();
 
-                      if (nl == 1 && nu == 1)
-                        mattyp.mark_as_tridiagonal ();
-                      else
-                        mattyp.mark_as_banded (nu, nl);
-
-                      if (str_typ == "banded positive definite")
-                        mattyp.mark_as_symmetric ();
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
                     }
                 }
-              else if (str_typ == "positive definite")
-                {
-                  mattyp.mark_as_full ();
-                  mattyp.mark_as_symmetric ();
-                }
-              else if (str_typ == "singular")
-                mattyp.mark_as_rectangular ();
-              else if (str_typ == "full")
-                mattyp.mark_as_full ();
-              else if (str_typ == "unknown")
-                mattyp.invalidate_type ();
-              else
-                error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
+            }
 
-              if (nargin == 3
-                  && (str_typ == "upper" || str_typ == "lower"))
-                {
-                  const ColumnVector perm = args(2).vector_value ("matrix_type: Invalid permutation vector PERM");
-
-                  octave_idx_type len = perm.numel ();
-                  dim_vector dv = args(0).dims ();
+          int typ = mattyp.type ();
 
-                  if (len != dv(0))
-                    error ("matrix_type: Invalid permutation vector PERM");
-                  else
-                    {
-                      OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
-
-                      for (octave_idx_type i = 0; i < len; i++)
-                        p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
-
-                      mattyp.mark_as_permuted (len, p);
-                    }
-                }
-              else if (nargin != 2
-                       && str_typ != "banded positive definite"
-                       && str_typ != "banded")
-                error ("matrix_type: Invalid number of arguments");
-
-              // Set the matrix type
-              if (args(0).is_complex_type ())
-                retval = octave_value (args(0).sparse_complex_matrix_value (),
-                                       mattyp);
+          if (typ == MatrixType::Upper)
+            retval = octave_value ("Upper");
+          else if (typ == MatrixType::Permuted_Upper)
+            retval = octave_value ("Permuted Upper");
+          else if (typ == MatrixType::Lower)
+            retval = octave_value ("Lower");
+          else if (typ == MatrixType::Permuted_Lower)
+            retval = octave_value ("Permuted Lower");
+          else if (typ == MatrixType::Hermitian)
+            retval = octave_value ("Positive Definite");
+          else if (typ == MatrixType::Rectangular)
+            {
+              if (args(0).rows () == args(0).columns ())
+                retval = octave_value ("Singular");
               else
-                retval = octave_value (args(0).sparse_matrix_value (),
-                                       mattyp);
+                retval = octave_value ("Rectangular");
             }
+          else if (typ == MatrixType::Full)
+            retval = octave_value ("Full");
+          else
+            retval = octave_value ("Unknown");
         }
       else
         {
-          if (nargin == 1)
-            {
-              MatrixType mattyp;
+          // Ok, we're changing the matrix type
+
+          std::string str_typ = args(1).xstring_value ("matrix_type: TYPE must be a string");
 
-              if (args(0).is_complex_type ())
-                {
-                  mattyp = args(0).matrix_type ();
+          // FIXME: why do I have to explicitly call the constructor?
+          MatrixType mattyp = MatrixType (MatrixType::Unknown, true);
+
+          // Use STL function to convert to lower case
+          std::transform (str_typ.begin (), str_typ.end (),
+                          str_typ.begin (), tolower);
 
-                  if (mattyp.is_unknown () && autocomp)
-                    {
-                      if (args(0).is_single_type ())
-                        {
-                          FloatComplexMatrix m;
-                          m = args(0).float_complex_matrix_value ();
+          if (str_typ == "upper")
+            mattyp.mark_as_upper_triangular ();
+          else if (str_typ == "lower")
+            mattyp.mark_as_lower_triangular ();
+          else if (str_typ == "positive definite")
+            {
+              mattyp.mark_as_full ();
+              mattyp.mark_as_symmetric ();
+            }
+          else if (str_typ == "singular")
+            mattyp.mark_as_rectangular ();
+          else if (str_typ == "full")
+            mattyp.mark_as_full ();
+          else if (str_typ == "unknown")
+            mattyp.invalidate_type ();
+          else
+            error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
 
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
-                      else
-                        {
-                          ComplexMatrix m = args(0).complex_matrix_value ();
+          if (nargin == 3 && (str_typ == "upper" || str_typ == "lower"))
+            {
+              const ColumnVector perm = args(2).vector_value ("matrix_type: Invalid permutation vector PERM");
 
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
-                    }
-                }
+              octave_idx_type len = perm.numel ();
+              dim_vector dv = args(0).dims ();
+
+              if (len != dv(0))
+                error ("matrix_type: Invalid permutation vector PERM");
               else
                 {
-                  mattyp = args(0).matrix_type ();
-
-                  if (mattyp.is_unknown () && autocomp)
-                    {
-                      if (args(0).is_single_type ())
-                        {
-                          FloatMatrix m = args(0).float_matrix_value ();
+                  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
 
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
-                      else
-                        {
-                          Matrix m = args(0).matrix_value ();
-
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
-                    }
-                }
+                  for (octave_idx_type i = 0; i < len; i++)
+                    p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
 
-              int typ = mattyp.type ();
+                  mattyp.mark_as_permuted (len, p);
+                }
+            }
+          else if (nargin != 2)
+            error ("matrix_type: Invalid number of arguments");
 
-              if (typ == MatrixType::Upper)
-                retval = octave_value ("Upper");
-              else if (typ == MatrixType::Permuted_Upper)
-                retval = octave_value ("Permuted Upper");
-              else if (typ == MatrixType::Lower)
-                retval = octave_value ("Lower");
-              else if (typ == MatrixType::Permuted_Lower)
-                retval = octave_value ("Permuted Lower");
-              else if (typ == MatrixType::Hermitian)
-                retval = octave_value ("Positive Definite");
-              else if (typ == MatrixType::Rectangular)
-                {
-                  if (args(0).rows () == args(0).columns ())
-                    retval = octave_value ("Singular");
-                  else
-                    retval = octave_value ("Rectangular");
-                }
-              else if (typ == MatrixType::Full)
-                retval = octave_value ("Full");
+          // Set the matrix type
+          if (args(0).is_single_type ())
+            {
+              if (args(0).is_complex_type ())
+                retval = octave_value (args(0).float_complex_matrix_value (),
+                                       mattyp);
               else
-                retval = octave_value ("Unknown");
+                retval = octave_value (args(0).float_matrix_value (),
+                                       mattyp);
             }
           else
             {
-              // Ok, we're changing the matrix type
-
-              std::string str_typ = args(1).xstring_value ("matrix_type: TYPE must be a string");
-
-              // FIXME: why do I have to explicitly call the constructor?
-              MatrixType mattyp = MatrixType (MatrixType::Unknown, true);
-
-              // Use STL function to convert to lower case
-              std::transform (str_typ.begin (), str_typ.end (),
-                              str_typ.begin (), tolower);
-
-              if (str_typ == "upper")
-                mattyp.mark_as_upper_triangular ();
-              else if (str_typ == "lower")
-                mattyp.mark_as_lower_triangular ();
-              else if (str_typ == "positive definite")
-                {
-                  mattyp.mark_as_full ();
-                  mattyp.mark_as_symmetric ();
-                }
-              else if (str_typ == "singular")
-                mattyp.mark_as_rectangular ();
-              else if (str_typ == "full")
-                mattyp.mark_as_full ();
-              else if (str_typ == "unknown")
-                mattyp.invalidate_type ();
+              if (args(0).is_complex_type ())
+                retval = octave_value (args(0).complex_matrix_value (),
+                                       mattyp);
               else
-                error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
-
-              if (nargin == 3 && (str_typ == "upper" || str_typ == "lower"))
-                {
-                  const ColumnVector perm = args(2).vector_value ("matrix_type: Invalid permutation vector PERM");
-
-                  octave_idx_type len = perm.numel ();
-                  dim_vector dv = args(0).dims ();
-
-                  if (len != dv(0))
-                    error ("matrix_type: Invalid permutation vector PERM");
-                  else
-                    {
-                      OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
-
-                      for (octave_idx_type i = 0; i < len; i++)
-                        p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
-
-                      mattyp.mark_as_permuted (len, p);
-                    }
-                }
-              else if (nargin != 2)
-                error ("matrix_type: Invalid number of arguments");
-
-              // Set the matrix type
-              if (args(0).is_single_type ())
-                {
-                  if (args(0).is_complex_type ())
-                    retval = octave_value (args(0).float_complex_matrix_value (),
-                                           mattyp);
-                  else
-                    retval = octave_value (args(0).float_matrix_value (),
-                                           mattyp);
-                }
-              else
-                {
-                  if (args(0).is_complex_type ())
-                    retval = octave_value (args(0).complex_matrix_value (),
-                                           mattyp);
-                  else
-                    retval = octave_value (args(0).matrix_value (), mattyp);
-                }
+                retval = octave_value (args(0).matrix_value (), mattyp);
             }
         }
     }
--- a/libinterp/corefcn/max.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/max.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -233,6 +233,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+  
   if (nargin == 3 || nargin == 1)
     {
       octave_value arg = args(0);
@@ -284,8 +287,10 @@
                                                        ismin);
             else
               retval = do_minmax_red_op<NDArray> (arg, nargout, dim, ismin);
-            break;
+
           }
+          break;
+
         case btyp_complex:
           {
             if (arg.is_sparse_type ())
@@ -294,22 +299,27 @@
             else
               retval = do_minmax_red_op<ComplexNDArray> (arg, nargout, dim,
                                                          ismin);
-            break;
           }
+          break;
+
         case btyp_float:
           retval = do_minmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
           break;
+
         case btyp_float_complex:
           retval = do_minmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
                                                           ismin);
           break;
+
         case btyp_char:
           retval = do_minmax_red_op<charNDArray> (arg, nargout, dim, ismin);
           break;
-#define MAKE_INT_BRANCH(X) \
+
+#define MAKE_INT_BRANCH(X)                      \
         case btyp_ ## X: \
           retval = do_minmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
           break;
+
         MAKE_INT_BRANCH (int8);
         MAKE_INT_BRANCH (int16);
         MAKE_INT_BRANCH (int32);
@@ -318,15 +328,18 @@
         MAKE_INT_BRANCH (uint16);
         MAKE_INT_BRANCH (uint32);
         MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
+
         case btyp_bool:
           retval = do_minmax_red_op<boolNDArray> (arg, nargout, dim, ismin);
           break;
+
         default:
           gripe_wrong_type_arg (func, arg);
         }
     }
-  else if (nargin == 2)
+  else
     {
       octave_value argx = args(0);
       octave_value argy = args(1);
@@ -353,8 +366,9 @@
               retval = do_minmax_bin_op<SparseMatrix> (argx, argy, ismin);
             else
               retval = do_minmax_bin_op<NDArray> (argx, argy, ismin);
-            break;
           }
+          break;
+
         case btyp_complex:
           {
             if ((argx.is_sparse_type ()
@@ -364,21 +378,26 @@
                                                               ismin);
             else
               retval = do_minmax_bin_op<ComplexNDArray> (argx, argy, ismin);
-            break;
           }
+          break;
+
         case btyp_float:
           retval = do_minmax_bin_op<FloatNDArray> (argx, argy, ismin);
           break;
+
         case btyp_float_complex:
           retval = do_minmax_bin_op<FloatComplexNDArray> (argx, argy, ismin);
           break;
+
         case btyp_char:
           retval = do_minmax_bin_op<charNDArray> (argx, argy, ismin);
           break;
+
 #define MAKE_INT_BRANCH(X) \
         case btyp_ ## X: \
           retval = do_minmax_bin_op<X ## NDArray> (argx, argy, ismin); \
           break;
+
         MAKE_INT_BRANCH (int8);
         MAKE_INT_BRANCH (int16);
         MAKE_INT_BRANCH (int32);
@@ -387,7 +406,9 @@
         MAKE_INT_BRANCH (uint16);
         MAKE_INT_BRANCH (uint32);
         MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
+
         /*
         FIXME: This is what should happen when boolNDArray has max()
         case btyp_bool:
@@ -404,8 +425,6 @@
         retval(0) = retval(0).bool_array_value ();
 
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -895,65 +914,71 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_value arg = args(0);
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value (true) - 1;
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-          if (dim < 0)
-            {
-              error ("%s: DIM must be a valid dimension", func);
-              return retval;
-            }
-        }
+  octave_value arg = args(0);
+  int dim = -1;
+  if (nargin == 2)
+    {
+      dim = args(1).int_value (true) - 1;
 
-      switch (arg.builtin_type ())
+      if (dim < 0)
         {
-        case btyp_double:
-          retval = do_cumminmax_red_op<NDArray> (arg, nargout, dim, ismin);
-          break;
-        case btyp_complex:
-          retval = do_cumminmax_red_op<ComplexNDArray> (arg, nargout, dim,
-                                                        ismin);
-          break;
-        case btyp_float:
-          retval = do_cumminmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
-          break;
-        case btyp_float_complex:
-          retval = do_cumminmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
-                                                             ismin);
-          break;
-#define MAKE_INT_BRANCH(X) \
-        case btyp_ ## X: \
-          retval = do_cumminmax_red_op<X ## NDArray> (arg, nargout, dim, \
-                                                      ismin); \
-          break;
-        MAKE_INT_BRANCH (int8);
-        MAKE_INT_BRANCH (int16);
-        MAKE_INT_BRANCH (int32);
-        MAKE_INT_BRANCH (int64);
-        MAKE_INT_BRANCH (uint8);
-        MAKE_INT_BRANCH (uint16);
-        MAKE_INT_BRANCH (uint32);
-        MAKE_INT_BRANCH (uint64);
-#undef MAKE_INT_BRANCH
-        case btyp_bool:
-          {
-            retval = do_cumminmax_red_op<int8NDArray> (arg, nargout, dim,
-                                                       ismin);
-            if (retval.length () > 0)
-              retval(0) = retval(0).bool_array_value ();
-            break;
-          }
-        default:
-          gripe_wrong_type_arg (func, arg);
+          error ("%s: DIM must be a valid dimension", func);
+          return retval;
         }
     }
-  else
-    print_usage ();
+
+  switch (arg.builtin_type ())
+    {
+    case btyp_double:
+      retval = do_cumminmax_red_op<NDArray> (arg, nargout, dim, ismin);
+      break;
+
+    case btyp_complex:
+      retval = do_cumminmax_red_op<ComplexNDArray> (arg, nargout, dim,
+                                                    ismin);
+      break;
+
+    case btyp_float:
+      retval = do_cumminmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
+      break;
+
+    case btyp_float_complex:
+      retval = do_cumminmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
+                                                         ismin);
+      break;
+
+#define MAKE_INT_BRANCH(X) \
+      case btyp_ ## X: \
+        retval = do_cumminmax_red_op<X ## NDArray> (arg, nargout, dim, \
+                                                    ismin); \
+        break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
+#undef MAKE_INT_BRANCH
+
+    case btyp_bool:
+      {
+        retval = do_cumminmax_red_op<int8NDArray> (arg, nargout, dim,
+                                                   ismin);
+        if (retval.length () > 0)
+          retval(0) = retval(0).bool_array_value ();
+      }
+      break;
+
+    default:
+      gripe_wrong_type_arg (func, arg);
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/md5sum.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/md5sum.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -51,24 +51,22 @@
 
   if (nargin != 1 && nargin != 2)
     print_usage ();
+
+  bool have_str = false;
+  std::string str = args(0).string_value ();
+
+  if (nargin == 2)
+    have_str = args(1).bool_value ();
+
+  if (have_str)
+    retval = oct_md5 (str);
   else
     {
-      bool have_str = false;
-      std::string str = args(0).string_value ();
-
-      if (nargin == 2)
-        have_str = args(1).bool_value ();
+      std::string fname = file_ops::tilde_expand (str);
 
-      if (have_str)
-        retval = oct_md5 (str);
-      else
-        {
-          std::string fname = file_ops::tilde_expand (str);
+      fname = find_data_file_in_load_path ("md5sum", fname);
 
-          fname = find_data_file_in_load_path ("md5sum", fname);
-
-          retval = oct_md5_file (fname);
-        }
+      retval = oct_md5_file (fname);
     }
 
   return retval;
--- a/libinterp/corefcn/mgorth.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/mgorth.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -72,10 +72,7 @@
   int nargin = args.length ();
 
   if (nargin != 2 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg_x = args(0);
   octave_value arg_v = args(1);
--- a/libinterp/corefcn/nproc.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/nproc.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -54,10 +54,7 @@
   int nargin = args.length ();
 
   if ((nargin != 0 && nargin != 1) || (nargout != 0 && nargout != 1))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   nproc_query query = NPROC_CURRENT;
   if (nargin == 1)
--- a/libinterp/corefcn/ordschur.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/ordschur.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -111,10 +111,7 @@
   octave_value_list retval;
 
   if (nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   const Array<octave_idx_type> sel = args(2).octave_idx_type_vector_value ("ordschur: SELECT must be an array of integers");
 
--- a/libinterp/corefcn/pager.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/pager.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -543,44 +543,39 @@
 
   int argc = args.length () + 1;
 
+  if (argc < 1 || argc > 2)
+    print_usage ();
+
   string_vector argv = args.make_argv ("diary");
 
   if (diary_file.empty ())
     diary_file = "diary";
 
-  switch (argc)
+  if (argc == 1)
     {
-    case 1:
       write_to_diary_file = ! write_to_diary_file;
       open_diary_file ();
-      break;
-
-    case 2:
-      {
-        std::string arg = argv[1];
+    }
+  else
+    {
+      std::string arg = argv[1];
 
-        if (arg == "on")
-          {
-            write_to_diary_file = true;
-            open_diary_file ();
-          }
-        else if (arg == "off")
-          {
-            close_diary_file ();
-            write_to_diary_file = false;
-          }
-        else
-          {
-            diary_file = arg;
-            write_to_diary_file = true;
-            open_diary_file ();
-          }
-      }
-      break;
-
-    default:
-      print_usage ();
-      break;
+      if (arg == "on")
+        {
+          write_to_diary_file = true;
+          open_diary_file ();
+        }
+      else if (arg == "off")
+        {
+          close_diary_file ();
+          write_to_diary_file = false;
+        }
+      else
+        {
+          diary_file = arg;
+          write_to_diary_file = true;
+          open_diary_file ();
+        }
     }
 
   return retval;
@@ -621,6 +616,9 @@
 
   int argc = args.length () + 1;
 
+  if (argc < 1 || argc > 2)
+    print_usage ();
+
   string_vector argv = args.make_argv ("more");
 
   if (argc == 2)
@@ -634,10 +632,8 @@
       else
         error ("more: unrecognized argument '%s'", arg.c_str ());
     }
-  else if (argc == 1)
+  else
     Vpage_screen_output = ! Vpage_screen_output;
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/pinv.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/pinv.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -59,10 +59,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
--- a/libinterp/corefcn/pr-output.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/pr-output.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -3431,55 +3431,53 @@
 
   if (nargin < 1 || nargin > 2 || nargout > 1)
     print_usage ();
-  else
+
+  unwind_protect frame;
+
+  frame.protect_var (rat_string_len);
+
+  rat_string_len = 9;
+
+  if (nargin == 2)
+    rat_string_len = args(1).nint_value ();
+
+  octave_value arg = args(0);
+
+  if (arg.is_numeric_type ())
     {
-      unwind_protect frame;
-
-      frame.protect_var (rat_string_len);
-
-      rat_string_len = 9;
-
-      if (nargin == 2)
-        rat_string_len = args(1).nint_value ();
-
-      octave_value arg = args(0);
-
-      if (arg.is_numeric_type ())
+      frame.protect_var (rat_format);
+
+      rat_format = true;
+
+      std::ostringstream buf;
+      arg.print (buf);
+      std::string s = buf.str ();
+
+      std::list<std::string> lst;
+
+      size_t n = 0;
+      size_t s_len = s.length ();
+
+      while (n < s_len)
         {
-          frame.protect_var (rat_format);
-
-          rat_format = true;
-
-          std::ostringstream buf;
-          arg.print (buf);
-          std::string s = buf.str ();
-
-          std::list<std::string> lst;
-
-          size_t n = 0;
-          size_t s_len = s.length ();
-
-          while (n < s_len)
+          size_t m = s.find ('\n',  n);
+
+          if (m == std::string::npos)
+            {
+              lst.push_back (s.substr (n));
+              break;
+            }
+          else
             {
-              size_t m = s.find ('\n',  n);
-
-              if (m == std::string::npos)
-                {
-                  lst.push_back (s.substr (n));
-                  break;
-                }
-              else
-                {
-                  lst.push_back (s.substr (n, m - n));
-                  n = m + 1;
-                }
+              lst.push_back (s.substr (n, m - n));
+              n = m + 1;
             }
-
-          retval = string_vector (lst);
         }
-      else
-        error ("rats: X must be numeric");
+
+      retval = string_vector (lst);
     }
+  else
+    error ("rats: X must be numeric");
 
   return retval;
 }
@@ -3512,21 +3510,19 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 && nargout < 2)
+  if (nargin != 1 || nargout > 1)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  if (nargout == 0)
+    arg.print (octave_stdout);
+  else
     {
-      octave_value arg = args(0);
-
-      if (nargout == 0)
-        arg.print (octave_stdout);
-      else
-        {
-          std::ostringstream buf;
-          arg.print (buf);
-          retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\'');
-        }
+      std::ostringstream buf;
+      arg.print (buf);
+      retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\'');
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -3556,23 +3552,21 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2)
-    {
-      int fid = octave_stream_list::get_file_number (args(0));
-
-      octave_stream os = octave_stream_list::lookup (fid, "fdisp");
-
-      std::ostream *osp = os.output_stream ();
-
-      octave_value arg = args(1);
-
-      if (osp)
-        arg.print (*osp);
-      else
-        error ("fdisp: stream FID not open for writing");
-    }
+  if (nargin != 2)
+    print_usage ();
+
+  int fid = octave_stream_list::get_file_number (args(0));
+
+  octave_stream os = octave_stream_list::lookup (fid, "fdisp");
+
+  std::ostream *osp = os.output_stream ();
+
+  octave_value arg = args(1);
+
+  if (osp)
+    arg.print (*osp);
   else
-    print_usage ();
+    error ("fdisp: stream FID not open for writing");
 
   return retval;
 }
--- a/libinterp/corefcn/profiler.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/profiler.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -401,23 +401,15 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  int nargin = args.length ();
 
-  const int nargin = args.length ();
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin > 0)
-    {
-      if (nargin > 1)
-        {
-          print_usage ();
-          return retval;
-        }
+    profiler.set_active (args(0).bool_value ());
 
-      profiler.set_active (args(0).bool_value ());
-    }
-
-  retval(0) = profiler.is_active ();
-
-  return retval;
+  return octave_value (profiler.is_active ());
 }
 
 // Clear all collected profiling data.
--- a/libinterp/corefcn/psi.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/psi.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -69,10 +69,7 @@
 
   const octave_idx_type nargin = args.length ();
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   const octave_value oct_z = (nargin == 1) ? args(0) : args(1);
   const octave_idx_type k = (nargin == 1) ? 0 : args(0).idx_type_value ("psi: K must be an integer");
--- a/libinterp/corefcn/quad.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/quad.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -196,221 +196,219 @@
 
   int nargin = args.length ();
 
-  if (nargin > 2 && nargin < 6 && nargout < 5)
+  if (nargin < 3 || nargin > 5 || nargout > 4)
+    print_usage ();
+
+  if (args(0).is_function_handle () || args(0).is_inline_function ())
+    quad_fcn = args(0).function_value ();
+  else
     {
-      if (args(0).is_function_handle () || args(0).is_inline_function ())
-        quad_fcn = args(0).function_value ();
-      else
+      fcn_name = unique_symbol_name ("__quad_fcn__");
+      std::string fname = "function y = ";
+      fname.append (fcn_name);
+      fname.append ("(x) y = ");
+      quad_fcn = extract_function (args(0), "quad", fcn_name, fname,
+                                   "; endfunction");
+      frame.add_fcn (clear_function, fcn_name);
+    }
+
+  if (! quad_fcn)
+    error ("quad: FCN argument is not a valid function name or handle");
+
+  if (args(1).is_single_type () || args(2).is_single_type ())
+    {
+      float a = args(1).xfloat_value ("quad: lower limit of integration A must be a scalar");
+      float b = args(2).xfloat_value ("quad: upper limit of integration B must be a scalar");
+
+      int indefinite = 0;
+      FloatIndefQuad::IntegralType indef_type
+        = FloatIndefQuad::doubly_infinite;
+      float bound = 0.0;
+      if (xisinf (a) && xisinf (b))
         {
-          fcn_name = unique_symbol_name ("__quad_fcn__");
-          std::string fname = "function y = ";
-          fname.append (fcn_name);
-          fname.append ("(x) y = ");
-          quad_fcn = extract_function (args(0), "quad", fcn_name, fname,
-                                       "; endfunction");
-          frame.add_fcn (clear_function, fcn_name);
+          indefinite = 1;
+          indef_type = FloatIndefQuad::doubly_infinite;
+        }
+      else if (xisinf (a))
+        {
+          indefinite = 1;
+          bound = b;
+          indef_type = FloatIndefQuad::neg_inf_to_bound;
+        }
+      else if (xisinf (b))
+        {
+          indefinite = 1;
+          bound = a;
+          indef_type = FloatIndefQuad::bound_to_inf;
         }
 
-      if (! quad_fcn)
-        error ("quad: FCN argument is not a valid function name or handle");
-
-      if (args(1).is_single_type () || args(2).is_single_type ())
-        {
-          float a = args(1).xfloat_value ("quad: lower limit of integration A must be a scalar");
-          float b = args(2).xfloat_value ("quad: upper limit of integration B must be a scalar");
+      octave_idx_type ier = 0;
+      octave_idx_type nfun = 0;
+      float abserr = 0.0;
+      float val = 0.0;
+      bool have_sing = false;
+      FloatColumnVector sing;
+      FloatColumnVector tol;
 
-          int indefinite = 0;
-          FloatIndefQuad::IntegralType indef_type
-            = FloatIndefQuad::doubly_infinite;
-          float bound = 0.0;
-          if (xisinf (a) && xisinf (b))
-            {
-              indefinite = 1;
-              indef_type = FloatIndefQuad::doubly_infinite;
-            }
-          else if (xisinf (a))
-            {
-              indefinite = 1;
-              bound = b;
-              indef_type = FloatIndefQuad::neg_inf_to_bound;
-            }
-          else if (xisinf (b))
-            {
-              indefinite = 1;
-              bound = a;
-              indef_type = FloatIndefQuad::bound_to_inf;
-            }
-
-          octave_idx_type ier = 0;
-          octave_idx_type nfun = 0;
-          float abserr = 0.0;
-          float val = 0.0;
-          bool have_sing = false;
-          FloatColumnVector sing;
-          FloatColumnVector tol;
-
-          switch (nargin)
-            {
-            case 5:
-              if (indefinite)
-                error ("quad: singularities not allowed on infinite intervals");
+      switch (nargin)
+        {
+        case 5:
+          if (indefinite)
+            error ("quad: singularities not allowed on infinite intervals");
 
-              have_sing = true;
-
-              sing = args(4).xfloat_vector_value ("quad: fifth argument SING must be a vector vector of singularities");
-
-            case 4:
-              tol = args(3).xfloat_vector_value ("quad: TOL must be a 1 or 2-element vector");
+          have_sing = true;
 
-              switch (tol.numel ())
-                {
-                case 2:
-                  quad_opts.set_single_precision_relative_tolerance (tol (1));
+          sing = args(4).xfloat_vector_value ("quad: fifth argument SING must be a vector vector of singularities");
 
-                case 1:
-                  quad_opts.set_single_precision_absolute_tolerance (tol (0));
-                  break;
-
-                default:
-                  error ("quad: TOL must be a 1 or 2-element vector");
-                }
+        case 4:
+          tol = args(3).xfloat_vector_value ("quad: TOL must be a 1 or 2-element vector");
 
-            case 3:
-              if (indefinite)
-                {
-                  FloatIndefQuad iq (quad_float_user_function, bound,
-                                     indef_type);
-                  iq.set_options (quad_opts);
-                  val = iq.float_integrate (ier, nfun, abserr);
-                }
-              else
-                {
-                  if (have_sing)
-                    {
-                      FloatDefQuad dq (quad_float_user_function, a, b, sing);
-                      dq.set_options (quad_opts);
-                      val = dq.float_integrate (ier, nfun, abserr);
-                    }
-                  else
-                    {
-                      FloatDefQuad dq (quad_float_user_function, a, b);
-                      dq.set_options (quad_opts);
-                      val = dq.float_integrate (ier, nfun, abserr);
-                    }
-                }
+          switch (tol.numel ())
+            {
+            case 2:
+              quad_opts.set_single_precision_relative_tolerance (tol (1));
+
+            case 1:
+              quad_opts.set_single_precision_absolute_tolerance (tol (0));
               break;
 
             default:
-              panic_impossible ();
-              break;
-            }
-
-          retval(3) = abserr;
-          retval(2) = nfun;
-          retval(1) = ier;
-          retval(0) = val;
-
-        }
-      else
-        {
-          double a = args(1).xdouble_value ("quad: lower limit of integration A must be a scalar");
-          double b = args(2).xdouble_value ("quad: upper limit of integration B must be a scalar");
-
-          int indefinite = 0;
-          IndefQuad::IntegralType indef_type = IndefQuad::doubly_infinite;
-          double bound = 0.0;
-          if (xisinf (a) && xisinf (b))
-            {
-              indefinite = 1;
-              indef_type = IndefQuad::doubly_infinite;
-            }
-          else if (xisinf (a))
-            {
-              indefinite = 1;
-              bound = b;
-              indef_type = IndefQuad::neg_inf_to_bound;
-            }
-          else if (xisinf (b))
-            {
-              indefinite = 1;
-              bound = a;
-              indef_type = IndefQuad::bound_to_inf;
+              error ("quad: TOL must be a 1 or 2-element vector");
             }
 
-          octave_idx_type ier = 0;
-          octave_idx_type nfun = 0;
-          double abserr = 0.0;
-          double val = 0.0;
-          bool have_sing = false;
-          ColumnVector sing;
-          ColumnVector tol;
-
-          switch (nargin)
+        case 3:
+          if (indefinite)
             {
-            case 5:
-              if (indefinite)
-                error ("quad: singularities not allowed on infinite intervals");
-
-              have_sing = true;
-
-              sing = args(4).vector_value ("quad: fifth argument SING must be a vector vector of singularities");
-
-            case 4:
-              tol = args(3).xvector_value ("quad: TOL must be a 1 or 2-element vector");
-
-              switch (tol.numel ())
+              FloatIndefQuad iq (quad_float_user_function, bound,
+                                 indef_type);
+              iq.set_options (quad_opts);
+              val = iq.float_integrate (ier, nfun, abserr);
+            }
+          else
+            {
+              if (have_sing)
                 {
-                case 2:
-                  quad_opts.set_relative_tolerance (tol (1));
-
-                case 1:
-                  quad_opts.set_absolute_tolerance (tol (0));
-                  break;
-
-                default:
-                  error ("quad: TOL must be a 1 or 2-element vector");
-                }
-
-            case 3:
-              if (indefinite)
-                {
-                  IndefQuad iq (quad_user_function, bound, indef_type);
-                  iq.set_options (quad_opts);
-                  val = iq.integrate (ier, nfun, abserr);
+                  FloatDefQuad dq (quad_float_user_function, a, b, sing);
+                  dq.set_options (quad_opts);
+                  val = dq.float_integrate (ier, nfun, abserr);
                 }
               else
                 {
-                  if (have_sing)
-                    {
-                      DefQuad dq (quad_user_function, a, b, sing);
-                      dq.set_options (quad_opts);
-                      val = dq.integrate (ier, nfun, abserr);
-                    }
-                  else
-                    {
-                      DefQuad dq (quad_user_function, a, b);
-                      dq.set_options (quad_opts);
-                      val = dq.integrate (ier, nfun, abserr);
-                    }
+                  FloatDefQuad dq (quad_float_user_function, a, b);
+                  dq.set_options (quad_opts);
+                  val = dq.float_integrate (ier, nfun, abserr);
                 }
+            }
+          break;
+
+        default:
+          panic_impossible ();
+          break;
+        }
+
+      retval(3) = abserr;
+      retval(2) = nfun;
+      retval(1) = ier;
+      retval(0) = val;
+
+    }
+  else
+    {
+      double a = args(1).xdouble_value ("quad: lower limit of integration A must be a scalar");
+      double b = args(2).xdouble_value ("quad: upper limit of integration B must be a scalar");
+
+      int indefinite = 0;
+      IndefQuad::IntegralType indef_type = IndefQuad::doubly_infinite;
+      double bound = 0.0;
+      if (xisinf (a) && xisinf (b))
+        {
+          indefinite = 1;
+          indef_type = IndefQuad::doubly_infinite;
+        }
+      else if (xisinf (a))
+        {
+          indefinite = 1;
+          bound = b;
+          indef_type = IndefQuad::neg_inf_to_bound;
+        }
+      else if (xisinf (b))
+        {
+          indefinite = 1;
+          bound = a;
+          indef_type = IndefQuad::bound_to_inf;
+        }
+
+      octave_idx_type ier = 0;
+      octave_idx_type nfun = 0;
+      double abserr = 0.0;
+      double val = 0.0;
+      bool have_sing = false;
+      ColumnVector sing;
+      ColumnVector tol;
+
+      switch (nargin)
+        {
+        case 5:
+          if (indefinite)
+            error ("quad: singularities not allowed on infinite intervals");
+
+          have_sing = true;
+
+          sing = args(4).vector_value ("quad: fifth argument SING must be a vector vector of singularities");
+
+        case 4:
+          tol = args(3).xvector_value ("quad: TOL must be a 1 or 2-element vector");
+
+          switch (tol.numel ())
+            {
+            case 2:
+              quad_opts.set_relative_tolerance (tol (1));
+
+            case 1:
+              quad_opts.set_absolute_tolerance (tol (0));
               break;
 
             default:
-              panic_impossible ();
-              break;
+              error ("quad: TOL must be a 1 or 2-element vector");
             }
 
-          retval(3) = abserr;
-          retval(2) = nfun;
-          retval(1) = ier;
-          retval(0) = val;
+        case 3:
+          if (indefinite)
+            {
+              IndefQuad iq (quad_user_function, bound, indef_type);
+              iq.set_options (quad_opts);
+              val = iq.integrate (ier, nfun, abserr);
+            }
+          else
+            {
+              if (have_sing)
+                {
+                  DefQuad dq (quad_user_function, a, b, sing);
+                  dq.set_options (quad_opts);
+                  val = dq.integrate (ier, nfun, abserr);
+                }
+              else
+                {
+                  DefQuad dq (quad_user_function, a, b);
+                  dq.set_options (quad_opts);
+                  val = dq.integrate (ier, nfun, abserr);
+                }
+            }
+          break;
+
+        default:
+          panic_impossible ();
+          break;
         }
 
-      if (fcn_name.length ())
-        clear_function (fcn_name);
+      retval(3) = abserr;
+      retval(2) = nfun;
+      retval(1) = ier;
+      retval(0) = val;
     }
-  else
-    print_usage ();
+
+  if (fcn_name.length ())
+    clear_function (fcn_name);
 
   return retval;
 }
--- a/libinterp/corefcn/quadcc.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/quadcc.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1588,10 +1588,7 @@
 
   /* Parse the input arguments. */
   if (nargin < 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (args(0).is_function_handle () || args(0).is_inline_function ())
     fcn = args(0).function_value ();
--- a/libinterp/corefcn/qz.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/qz.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -383,15 +383,10 @@
 #endif
 
   if (nargin < 2 || nargin > 3 || nargout > 7)
-    {
-      print_usage ();
-      return retval;
-    }
-  else if (nargin == 3 && (nargout < 3 || nargout > 4))
-    {
-      error ("qz: invalid number of output arguments for form [3] call");
-      return retval;
-    }
+    print_usage ();
+
+  if (nargin == 3 && (nargout < 3 || nargout > 4))
+    error ("qz: invalid number of output arguments for form [3] call");
 
 #ifdef DEBUG
   std::cout << "qz: determine ordering option" << std::endl;
--- a/libinterp/corefcn/rand.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/rand.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1130,6 +1130,7 @@
 @seealso{perms}\n\
 @end deftypefn")
 {
+  octave_value retval;
 
 #ifdef USE_UNORDERED_MAP_WITH_TR1
 using std::tr1::unordered_map;
@@ -1138,105 +1139,94 @@
 #endif
 
   int nargin = args.length ();
-  octave_value retval;
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_idx_type n, m;
+  octave_idx_type n = args(0).idx_type_value (true);
+  octave_idx_type m = (nargin == 2) ? args(1).idx_type_value (true) : n;
 
-      n = args(0).idx_type_value (true);
+  if (m < 0 || n < 0)
+    error ("randperm: M and N must be non-negative");
 
-      if (nargin == 2)
-        m = args(1).idx_type_value (true);
-      else
-        m = n;
+  if (m > n)
+    error ("randperm: M must be less than or equal to N");
 
-      if (m < 0 || n < 0)
-        error ("randperm: M and N must be non-negative");
+  // Quick and dirty heuristic to decide if we allocate or not the
+  // whole vector for tracking the truncated shuffle.
+  bool short_shuffle = m < n/5;
+
+  // Generate random numbers.
+  NDArray r = octave_rand::nd_array (dim_vector (1, m));
+  double *rvec = r.fortran_vec ();
 
-      if (m > n)
-        error ("randperm: M must be less than or equal to N");
-
-      // Quick and dirty heuristic to decide if we allocate or not the
-      // whole vector for tracking the truncated shuffle.
-      bool short_shuffle = m < n/5;
+  octave_idx_type idx_len = short_shuffle ? m : n;
+  Array<octave_idx_type> idx;
+  try
+    {
+      idx = Array<octave_idx_type> (dim_vector (1, idx_len));
+    }
+  catch (const std::bad_alloc&)
+    {
+      // Looks like n is too big and short_shuffle is false.
+      // Let's try again, but this time with the alternative.
+      idx_len = m;
+      short_shuffle = true;
+      idx = Array<octave_idx_type> (dim_vector (1, idx_len));
+    }
 
-      // Generate random numbers.
-      NDArray r = octave_rand::nd_array (dim_vector (1, m));
-      double *rvec = r.fortran_vec ();
+  octave_idx_type *ivec = idx.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < idx_len; i++)
+    ivec[i] = i;
 
-      octave_idx_type idx_len = short_shuffle ? m : n;
-      Array<octave_idx_type> idx;
-      try
-        {
-          idx = Array<octave_idx_type> (dim_vector (1, idx_len));
-        }
-      catch (const std::bad_alloc&)
+  if (short_shuffle)
+    {
+      unordered_map<octave_idx_type, octave_idx_type> map (m);
+
+      // Perform the Knuth shuffle only keeping track of moved
+      // entries in the map
+      for (octave_idx_type i = 0; i < m; i++)
         {
-          // Looks like n is too big and short_shuffle is false.
-          // Let's try again, but this time with the alternative.
-          idx_len = m;
-          short_shuffle = true;
-          idx = Array<octave_idx_type> (dim_vector (1, idx_len));
-        }
-
-      octave_idx_type *ivec = idx.fortran_vec ();
-
-      for (octave_idx_type i = 0; i < idx_len; i++)
-        ivec[i] = i;
-
-      if (short_shuffle)
-        {
-          unordered_map<octave_idx_type, octave_idx_type> map (m);
+          octave_idx_type k = i +
+            gnulib::floor (rvec[i] * (n - i));
 
-          // Perform the Knuth shuffle only keeping track of moved
-          // entries in the map
-          for (octave_idx_type i = 0; i < m; i++)
+          // For shuffling first m entries, no need to use extra
+          // storage
+          if (k < m)
             {
-              octave_idx_type k = i +
-                gnulib::floor (rvec[i] * (n - i));
+              std::swap (ivec[i], ivec[k]);
+            }
+          else
+            {
+              if (map.find (k) == map.end ())
+                map[k] = k;
 
-              // For shuffling first m entries, no need to use extra
-              // storage
-              if (k < m)
-                {
-                  std::swap (ivec[i], ivec[k]);
-                }
-              else
-                {
-                  if (map.find (k) == map.end ())
-                    map[k] = k;
-
-                  std::swap (ivec[i], map[k]);
-                }
+              std::swap (ivec[i], map[k]);
             }
         }
-      else
-        {
-
-          // Perform the Knuth shuffle of the first m entries
-          for (octave_idx_type i = 0; i < m; i++)
-            {
-              octave_idx_type k = i +
-                gnulib::floor (rvec[i] * (n - i));
-              std::swap (ivec[i], ivec[k]);
-            }
-        }
-
-      // Convert to doubles, reusing r.
-      for (octave_idx_type i = 0; i < m; i++)
-        rvec[i] = ivec[i] + 1;
-
-      if (m < n)
-        idx.resize (dim_vector (1, m));
-
-      // Now create an array object with a cached idx_vector.
-      retval = new octave_matrix (r, idx_vector (idx));
     }
   else
-    print_usage ();
+    {
 
-  return retval;
+      // Perform the Knuth shuffle of the first m entries
+      for (octave_idx_type i = 0; i < m; i++)
+        {
+          octave_idx_type k = i +
+            gnulib::floor (rvec[i] * (n - i));
+          std::swap (ivec[i], ivec[k]);
+        }
+    }
+
+  // Convert to doubles, reusing r.
+  for (octave_idx_type i = 0; i < m; i++)
+    rvec[i] = ivec[i] + 1;
+
+  if (m < n)
+    idx.resize (dim_vector (1, m));
+
+  // Now create an array object with a cached idx_vector.
+  return octave_value (new octave_matrix (r, idx_vector (idx)));
 }
 
 /*
--- a/libinterp/corefcn/rcond.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/rcond.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -51,7 +51,8 @@
 
   if (nargin != 1)
     print_usage ();
-  else if (args(0).is_sparse_type ())
+
+  if (args(0).is_sparse_type ())
     error ("rcond: for sparse matrices use 'rcond (full (a))' or 'condest (a)' instead");
   else if (args(0).is_single_type ())
     {
--- a/libinterp/corefcn/regexp.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/regexp.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -861,7 +861,8 @@
 
   if (nargin < 2)
     print_usage ();
-  else if (args(0).is_cell () || args(1).is_cell ())
+
+  if (args(0).is_cell () || args(1).is_cell ())
     retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexp");
   else
     retval = octregexp (args, nargout, "regexp");
@@ -1156,7 +1157,8 @@
 
   if (nargin < 2)
     print_usage ();
-  else if (args(0).is_cell () || args(1).is_cell ())
+
+  if (args(0).is_cell () || args(1).is_cell ())
     retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexpi", true);
   else
     retval = octregexp (args, nargout, "regexpi", true);
@@ -1388,10 +1390,7 @@
   int nargin = args.length ();
 
   if (nargin < 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (args(0).is_cell () || args(1).is_cell () || args(2).is_cell ())
     {
--- a/libinterp/corefcn/schur.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/schur.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -133,10 +133,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -297,41 +294,39 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 2 && nargout <= 2)
+  if (args.length () != 2 || nargout > 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("rsf2csf", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("rsf2csf", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("rsf2csf: UR and TR must be real matrices");
+  else
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("rsf2csf", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("rsf2csf", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("rsf2csf: UR and TR must be real matrices");
+
+      if (args(0).is_single_type () || args(1).is_single_type ())
+        {
+          FloatMatrix u = args(0).float_matrix_value ();
+          FloatMatrix t = args(1).float_matrix_value ();
+
+          FloatComplexSCHUR cs (FloatSCHUR (t, u));
+
+          retval(1) = cs.schur_matrix ();
+          retval(0) = cs.unitary_matrix ();
+        }
       else
         {
-
-          if (args(0).is_single_type () || args(1).is_single_type ())
-            {
-              FloatMatrix u = args(0).float_matrix_value ();
-              FloatMatrix t = args(1).float_matrix_value ();
-
-              FloatComplexSCHUR cs (FloatSCHUR (t, u));
+          Matrix u = args(0).matrix_value ();
+          Matrix t = args(1).matrix_value ();
 
-              retval(1) = cs.schur_matrix ();
-              retval(0) = cs.unitary_matrix ();
-            }
-          else
-            {
-              Matrix u = args(0).matrix_value ();
-              Matrix t = args(1).matrix_value ();
+          ComplexSCHUR cs (SCHUR (t, u));
 
-              ComplexSCHUR cs (SCHUR (t, u));
-
-              retval(1) = cs.schur_matrix ();
-              retval(0) = cs.unitary_matrix ();
-            }
+          retval(1) = cs.schur_matrix ();
+          retval(0) = cs.unitary_matrix ();
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/sighandlers.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/sighandlers.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1052,18 +1052,12 @@
 Return a structure containing Unix signal names and their defined values.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    {
-      static octave_scalar_map m = make_sig_struct ();
-
-      retval = m;
-    }
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  static octave_scalar_map m = make_sig_struct ();
+
+  return octave_value (m);
 }
 
 /*
--- a/libinterp/corefcn/sparse.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/sparse.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -49,12 +49,9 @@
 @end deftypefn")
 {
   if (args.length () != 1)
-    {
-      print_usage ();
-      return octave_value ();
-    }
-  else
-    return octave_value (args(0).is_sparse_type ());
+    print_usage ();
+
+  return octave_value (args(0).is_sparse_type ());
 }
 
 DEFUN (sparse, args, ,
@@ -128,6 +125,9 @@
   octave_value retval;
   int nargin = args.length ();
 
+  if (nargin == 0 || nargin > 6)
+    print_usage ();
+
   // Temporarily disable sparse_auto_mutate if set (it's obsolete anyway).
   unwind_protect frame;
   frame.protect_var (Vsparse_auto_mutate);
@@ -188,8 +188,6 @@
           if (m < 0 || n < 0)
             error ("sparse: dimensions must be non-negative");
         }
-      else if (nargin != 3)
-        print_usage ();
 
       int k = 0;    // index we're checking when index_vector throws
       try
@@ -260,24 +258,23 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      octave_idx_type m = args(0).idx_type_value ();
-      octave_idx_type n = args(1).idx_type_value ();
-      octave_idx_type nz = 0;
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  octave_idx_type m = args(0).idx_type_value ();
+  octave_idx_type n = args(1).idx_type_value ();
+  octave_idx_type nz = 0;
 
-      if (nargin == 3)
-        nz = args(2).idx_type_value ();
+  if (nargin == 3)
+    nz = args(2).idx_type_value ();
 
-      if (m >= 0 && n >= 0 && nz >= 0)
-        retval = SparseMatrix (dim_vector (m, n), nz);
-      else
-        error ("spalloc: M,N,NZ must be non-negative");
-    }
+  if (m >= 0 && n >= 0 && nz >= 0)
+    retval = SparseMatrix (dim_vector (m, n), nz);
   else
-    print_usage ();
+    error ("spalloc: M,N,NZ must be non-negative");
 
   return retval;
 }
--- a/libinterp/corefcn/sqrtm.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/sqrtm.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -217,10 +217,7 @@
   int nargin = args.length ();
 
   if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -228,10 +225,7 @@
   octave_idx_type nc = arg.columns ();
 
   if (n != nc || arg.ndims () > 2)
-    {
-      gripe_square_matrix_required ("sqrtm");
-      return retval;
-    }
+    gripe_square_matrix_required ("sqrtm");
 
   if (nargout > 1)
     {
--- a/libinterp/corefcn/str2double.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/str2double.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -345,7 +345,8 @@
 
   if (args.length () != 1)
     print_usage ();
-  else if (args(0).is_string ())
+
+  if (args(0).is_string ())
     {
       if (args(0).rows () == 0 || args(0).columns () == 0)
         {
@@ -377,7 +378,6 @@
   else
     retval = Matrix (1, 1, octave_NaN);
 
-
   return retval;
 }
 
--- a/libinterp/corefcn/strfind.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/strfind.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -193,81 +193,82 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
+
+  if (nargin != 4 && nargin != 2)
+    print_usage ();
+
   bool overlaps = true;
 
-  if (nargin == 4 && args(2).is_string () && args(3).is_scalar_type ())
+  if (nargin == 4)
     {
-      std::string opt = args(2).string_value ();
-      if (opt == "overlaps")
+      if (args(2).is_string () && args(3).is_scalar_type ())
         {
-          overlaps = args(3).bool_value ();
-          nargin = 2;
+          std::string opt = args(2).string_value ();
+
+          if (opt == "overlaps")
+            overlaps = args(3).bool_value ();
+          else
+            error ("strfind: unknown option: %s", opt.c_str ());
         }
       else
-        {
-          error ("strfind: unknown option: %s", opt.c_str ());
-          return retval;
-        }
+        error ("strfind: invalid optional arguments");
     }
 
-  if (nargin == 2)
+  octave_value argstr = args(0);
+  octave_value argpat = args(1);
+
+  if (argpat.is_string ())
     {
-      octave_value argstr = args(0);
-      octave_value argpat = args(1);
-      if (argpat.is_string ())
-        {
-          Array<char> needle = argpat.char_array_value ();
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
-          qs_preprocess (needle, table);
+      Array<char> needle = argpat.char_array_value ();
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
+      qs_preprocess (needle, table);
 
-          if (argstr.is_string ())
-            if (argpat.is_empty ())
-              // Return a null matrix for null pattern for MW compatibility
-              retval = Matrix ();
-            else
-              retval = octave_value (qs_search (needle,
-                                                argstr.char_array_value (),
-                                                table, overlaps),
-                                     true, true);
-          else if (argstr.is_cell ())
+      if (argstr.is_string ())
+        if (argpat.is_empty ())
+          // Return a null matrix for null pattern for MW compatibility
+          retval = Matrix ();
+        else
+          retval = octave_value (qs_search (needle,
+                                            argstr.char_array_value (),
+                                            table, overlaps),
+                                 true, true);
+      else if (argstr.is_cell ())
+        {
+          const Cell argsc = argstr.cell_value ();
+          Cell retc (argsc.dims ());
+          octave_idx_type ns = argsc.numel ();
+
+          for (octave_idx_type i = 0; i < ns; i++)
             {
-              const Cell argsc = argstr.cell_value ();
-              Cell retc (argsc.dims ());
-              octave_idx_type ns = argsc.numel ();
-
-              for (octave_idx_type i = 0; i < ns; i++)
+              octave_value argse = argsc(i);
+              if (argse.is_string ())
                 {
-                  octave_value argse = argsc(i);
-                  if (argse.is_string ())
-                    {
-                      if (argpat.is_empty ())
-                        retc(i) = Matrix ();
-                      else
-                        retc(i) = octave_value (qs_search (needle,
-                                                     argse.char_array_value (),
-                                                     table, overlaps),
-                                                true, true);
-                    }
+                  if (argpat.is_empty ())
+                    retc(i) = Matrix ();
                   else
-                    {
-                      error ("strfind: each element of CELLSTR must be a string");
-                      break;
-                    }
+                    retc(i) = octave_value (qs_search (needle,
+                                                       argse.char_array_value (),
+                                                       table, overlaps),
+                                            true, true);
                 }
-
-              retval = retc;
+              else
+                {
+                  error ("strfind: each element of CELLSTR must be a string");
+                  break;
+                }
             }
-          else
-            error ("strfind: first argument must be a string or cell array of strings");
+
+          retval = retc;
         }
-      else if (argpat.is_cell ())
-        retval = do_simple_cellfun (Fstrfind, "strfind", args);
       else
-        error ("strfind: PATTERN must be a string or cell array of strings");
+        error ("strfind: first argument must be a string or cell array of strings");
     }
+  else if (argpat.is_cell ())
+    retval = do_simple_cellfun (Fstrfind, "strfind", args);
   else
-    print_usage ();
+    error ("strfind: PATTERN must be a string or cell array of strings");
 
   return retval;
 }
@@ -386,71 +387,71 @@
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length ();
+
   bool overlaps = true;
 
-  if (nargin == 5 && args(3).is_string () && args(4).is_scalar_type ())
+  int nargin = args.length ();
+
+  if (nargin != 3 && nargin != 5)
+    print_usage ();
+
+  if (nargin == 5)
     {
-      std::string opt = args(3).string_value ();
-      if (opt == "overlaps")
+      if (args(3).is_string () && args(4).is_scalar_type ())
         {
-          overlaps = args(4).bool_value ();
-          nargin = 3;
+          std::string opt = args(3).string_value ();
+          if (opt == "overlaps")
+            overlaps = args(4).bool_value ();
+          else
+            error ("strrep: unknown option: %s", opt.c_str ());
         }
       else
-        {
-          error ("strrep: unknown option: %s", opt.c_str ());
-          return retval;
-        }
+        error ("strrep: invalid optional arguments");
     }
 
-  if (nargin == 3)
+  octave_value argstr = args(0);
+  octave_value argpat = args(1);
+  octave_value argrep = args(2);
+
+  if (argpat.is_string () && argrep.is_string ())
     {
-      octave_value argstr = args(0);
-      octave_value argpat = args(1);
-      octave_value argrep = args(2);
-      if (argpat.is_string () && argrep.is_string ())
-        {
-          const Array<char> pat = argpat.char_array_value ();
-          const Array<char> rep = argrep.char_array_value ();
+      const Array<char> pat = argpat.char_array_value ();
+      const Array<char> rep = argrep.char_array_value ();
+
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
+      qs_preprocess (pat, table);
 
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
-          qs_preprocess (pat, table);
+      if (argstr.is_string ())
+        retval = qs_replace (argstr.char_array_value (), pat, rep,
+                             table, overlaps);
+      else if (argstr.is_cell ())
+        {
+          const Cell argsc = argstr.cell_value ();
+          Cell retc (argsc.dims ());
+          octave_idx_type ns = argsc.numel ();
 
-          if (argstr.is_string ())
-            retval = qs_replace (argstr.char_array_value (), pat, rep,
-                                 table, overlaps);
-          else if (argstr.is_cell ())
+          for (octave_idx_type i = 0; i < ns; i++)
             {
-              const Cell argsc = argstr.cell_value ();
-              Cell retc (argsc.dims ());
-              octave_idx_type ns = argsc.numel ();
-
-              for (octave_idx_type i = 0; i < ns; i++)
+              octave_value argse = argsc(i);
+              if (argse.is_string ())
+                retc(i) = qs_replace (argse.char_array_value (), pat, rep,
+                                      table, overlaps);
+              else
                 {
-                  octave_value argse = argsc(i);
-                  if (argse.is_string ())
-                    retc(i) = qs_replace (argse.char_array_value (), pat, rep,
-                                          table, overlaps);
-                  else
-                    {
-                      error ("strrep: each element of S must be a string");
-                      break;
-                    }
+                  error ("strrep: each element of S must be a string");
+                  break;
                 }
+            }
 
-              retval = retc;
-            }
-          else
-            error ("strrep: S must be a string or cell array of strings");
+          retval = retc;
         }
-      else if (argpat.is_cell () || argrep.is_cell ())
-        retval = do_simple_cellfun (Fstrrep, "strrep", args);
       else
-        error ("strrep: PTN and REP arguments must be strings or cell arrays of strings");
+        error ("strrep: S must be a string or cell array of strings");
     }
+  else if (argpat.is_cell () || argrep.is_cell ())
+    retval = do_simple_cellfun (Fstrrep, "strrep", args);
   else
-    print_usage ();
+    error ("strrep: PTN and REP arguments must be strings or cell arrays of strings");
 
   return retval;
 }
--- a/libinterp/corefcn/strfns.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/strfns.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -289,16 +289,10 @@
 @seealso{isfloat, isinteger, islogical, isnumeric, iscellstr, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 && args(0).is_defined ())
-    retval = args(0).is_string ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_string ());
 }
 
 /*
@@ -561,17 +555,11 @@
 @seealso{strcmpi, strncmp, strncmpi}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 2)
-    {
-      retval = do_strcmp_fun (args(0), args(1), 0,
-                              "strcmp", strcmp_array_op, strcmp_str_op);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  return octave_value (do_strcmp_fun (args(0), args(1), 0, "strcmp",
+                                      strcmp_array_op, strcmp_str_op));
 }
 
 /*
@@ -679,20 +667,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 3)
-    {
-      octave_idx_type n = args(2).idx_type_value ();
+  if (args.length () != 3)
+    print_usage ();
+
+  octave_idx_type n = args(2).idx_type_value ();
 
-      if (n > 0)
-        {
-          retval = do_strcmp_fun (args(0), args(1), n, "strncmp",
-                                  strncmp_array_op, strncmp_str_op);
-        }
-      else
-        error ("strncmp: N must be greater than 0");
-    }
+  if (n > 0)
+    retval = do_strcmp_fun (args(0), args(1), n, "strncmp",
+                            strncmp_array_op, strncmp_str_op);
   else
-    print_usage ();
+    error ("strncmp: N must be greater than 0");
 
   return retval;
 }
@@ -714,7 +698,9 @@
 struct icmp_char_eq : public std::binary_function<char, char, bool>
 {
   bool operator () (char x, char y) const
-  { return std::toupper (x) == std::toupper (y); }
+  {
+    return std::toupper (x) == std::toupper (y);
+  }
 };
 
 // strcmpi is equivalent to strcmp in that it checks all dims.
@@ -758,15 +744,11 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      retval = do_strcmp_fun (args(0), args(1), 0,
-                              "strcmpi", strcmpi_array_op, strcmpi_str_op);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  return octave_value (do_strcmp_fun (args(0), args(1), 0, "strcmpi",
+                                      strcmpi_array_op, strcmpi_str_op));
 }
 
 /*
@@ -819,20 +801,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 3)
-    {
-      octave_idx_type n = args(2).idx_type_value ();
+  if (args.length () != 3)
+    print_usage ();
+
+  octave_idx_type n = args(2).idx_type_value ();
 
-      if (n > 0)
-        {
-          retval = do_strcmp_fun (args(0), args(1), n, "strncmpi",
-                                  strncmpi_array_op, strncmpi_str_op);
-        }
-      else
-        error ("strncmpi: N must be greater than 0");
-    }
+  if (n > 0)
+    retval = do_strcmp_fun (args(0), args(1), n, "strncmpi",
+                            strncmpi_array_op, strncmpi_str_op);
   else
-    print_usage ();
+    error ("strncmpi: N must be greater than 0");
 
   return retval;
 }
@@ -882,10 +860,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   string_vector s = args(0).xall_strings ("list_in_columns: ARG must be a cellstr or char array");
 
--- a/libinterp/corefcn/sub2ind.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/sub2ind.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -83,43 +83,38 @@
 @end deftypefn")
 {
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 2)
     print_usage ();
-  else
-    {
-      dim_vector dv = get_dim_vector (args(0), "sub2ind");
-      Array<idx_vector> idxa (dim_vector (nargin-1, 1));
+
+  dim_vector dv = get_dim_vector (args(0), "sub2ind");
+  Array<idx_vector> idxa (dim_vector (nargin-1, 1));
 
-      dv = dv.redim (nargin - 1);
-      for (int j = 0; j < nargin - 1; j++)
+  dv = dv.redim (nargin - 1);
+  for (int j = 0; j < nargin - 1; j++)
+    {
+      if (args(j+1).is_numeric_type ())
         {
-          if (args(j+1).is_numeric_type ())
+          try
             {
-              try
-                {
-                  idxa(j) = args(j+1).index_vector ();
+              idxa(j) = args(j+1).index_vector ();
 
-                  if (j > 0 && args(j+1).dims () != args(1).dims ())
-                    error ("sub2ind: all subscripts must be of the same size");
-                }
-              catch (index_exception& e)
-                {
-                  e.set_pos_if_unset (nargin-1, j+1);
-                  e.set_var ();
-                  std::string msg = e.message ();
-                  error_with_id (e.err_id (), msg.c_str ());
-                }
+              if (j > 0 && args(j+1).dims () != args(1).dims ())
+                error ("sub2ind: all subscripts must be of the same size");
             }
-          else
-            error ("sub2ind: subscripts must be numeric");
+          catch (index_exception& e)
+            {
+              e.set_pos_if_unset (nargin-1, j+1);
+              e.set_var ();
+              std::string msg = e.message ();
+              error_with_id (e.err_id (), msg.c_str ());
+            }
         }
-
-      retval = sub2ind (dv, idxa);
+      else
+        error ("sub2ind: subscripts must be numeric");
     }
 
-  return retval;
+  return octave_value (sub2ind (dv, idxa));
 }
 
 /*
@@ -186,30 +181,29 @@
 @seealso{sub2ind}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
+
   int nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin != 2)
     print_usage ();
-  else
-    {
-      dim_vector dv = get_dim_vector (args(0), "ind2sub");
+
+  dim_vector dv = get_dim_vector (args(0), "ind2sub");
 
-      try
-        {
-          idx_vector idx = args(1).index_vector ();
+  try
+    {
+      idx_vector idx = args(1).index_vector ();
 
-          if (nargout > dv.length ())
-            dv = dv.redim (nargout);
+      if (nargout > dv.length ())
+        dv = dv.redim (nargout);
 
-          retval = Array<octave_value> (ind2sub (dv, idx));
-        }
-      catch (const index_exception& e)
-        {
-          std::string idx = e.idx ();
-          std::string msg = e.details ();
-          error ("ind2sub: Invalid index %s. %s", idx.c_str (), msg.c_str ());
-        }
+      retval = Array<octave_value> (ind2sub (dv, idx));
+    }
+  catch (const index_exception& e)
+    {
+      std::string idx = e.idx ();
+      std::string msg = e.details ();
+      error ("ind2sub: Invalid index %s. %s", idx.c_str (), msg.c_str ());
     }
 
   return retval;
--- a/libinterp/corefcn/sylvester.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/sylvester.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -65,10 +65,7 @@
   int nargin = args.length ();
 
   if (nargin != 3 || nargout > 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg_a = args(0);
   octave_value arg_b = args(1);
--- a/libinterp/corefcn/symtab.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/symtab.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1668,6 +1668,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargout > 0 || nargin == 0)
     {
       switch (Vignore_function_time_stamp)
@@ -1699,8 +1702,6 @@
       else
         error ("ignore_function_time_stamp: argument must be one of \"all\", \"system\", or \"none\"");
     }
-  else if (nargin > 1)
-    print_usage ();
 
   return retval;
 }
@@ -1752,6 +1753,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     {
       symbol_table::dump_functions (octave_stdout);
@@ -1764,7 +1768,7 @@
            p != lst.end (); p++)
         symbol_table::dump (octave_stdout, *p);
     }
-  else if (nargin == 1)
+  else
     {
       octave_value arg = args(0);
 
@@ -1800,8 +1804,6 @@
           symbol_table::dump (octave_stdout, s);
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1814,27 +1816,25 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      std::string name = args(0).xstring_value ("__get_cmd_line_function_text__: first argument must be function name");
+  if (args.length () != 1)
+    print_usage ();
 
-      octave_value ov = symbol_table::find_cmdline_function (name);
+  std::string name = args(0).xstring_value ("__get_cmd_line_function_text__: first argument must be function name");
 
-      octave_user_function *f = ov.user_function_value ();
+  octave_value ov = symbol_table::find_cmdline_function (name);
+
+  octave_user_function *f = ov.user_function_value ();
 
-      if (f)
-        {
-          std::ostringstream buf;
-
-          tree_print_code tpc (buf);
+  if (f)
+    {
+      std::ostringstream buf;
 
-          f->accept (tpc);
+      tree_print_code tpc (buf);
 
-          retval = buf.str ();
-        }
+      f->accept (tpc);
+
+      retval = buf.str ();
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1847,14 +1847,12 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      std::string name = args(0).xstring_value ("set_variable: variable NAME must be a string");
+  if (args.length () != 2)
+    print_usage ();
 
-      symbol_table::assign (name, args(1));
-    }
-  else
-    print_usage ();
+  std::string name = args(0).xstring_value ("set_variable: variable NAME must be a string");
+
+  symbol_table::assign (name, args(1));
 
   return retval;
 }
@@ -1863,18 +1861,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      std::string name = args(0).xstring_value ("variable_value: variable NAME must be a string");
+  if (args.length () != 1)
+    print_usage ();
 
-      retval = symbol_table::varval (name);
+  std::string name = args(0).xstring_value ("variable_value: variable NAME must be a string");
 
-      if (retval.is_undefined ())
-        error ("variable_value: '%s' is not a variable in the current scope",
-               name.c_str ());
-    }
-  else
-    print_usage ();
+  retval = symbol_table::varval (name);
+
+  if (retval.is_undefined ())
+    error ("variable_value: '%s' is not a variable in the current scope",
+           name.c_str ());
 
   return retval;
 }
--- a/libinterp/corefcn/syscalls.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/syscalls.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -127,29 +127,27 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2)
-    {
-      octave_stream old_stream
-        = octave_stream_list::lookup (args(0), "dup2");
+  if (nargin != 2)
+    print_usage ();
 
-      octave_stream new_stream
-        = octave_stream_list::lookup (args(1), "dup2");
+  octave_stream old_stream
+    = octave_stream_list::lookup (args(0), "dup2");
 
-      int i_old = old_stream.file_number ();
-      int i_new = new_stream.file_number ();
+  octave_stream new_stream
+    = octave_stream_list::lookup (args(1), "dup2");
 
-      if (i_old >= 0 && i_new >= 0)
-        {
-          std::string msg;
-
-          int status = octave_syscalls::dup2 (i_old, i_new, msg);
+  int i_old = old_stream.file_number ();
+  int i_new = new_stream.file_number ();
 
-          retval(1) = msg;
-          retval(0) = status;
-        }
+  if (i_old >= 0 && i_new >= 0)
+    {
+      std::string msg;
+
+      int status = octave_syscalls::dup2 (i_old, i_new, msg);
+
+      retval(1) = msg;
+      retval(0) = status;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -182,46 +180,44 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string exec_file = args(0).xstring_value ("exec: FILE must be a string");
-
-      string_vector exec_args;
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      if (nargin == 2)
-        {
-          string_vector tmp = args(1).xall_strings ("exec: all arguments must be strings");
+  std::string exec_file = args(0).xstring_value ("exec: FILE must be a string");
 
-          int len = tmp.numel ();
-
-          exec_args.resize (len + 1);
-
-          exec_args[0] = exec_file;
+  string_vector exec_args;
 
-          for (int i = 0; i < len; i++)
-            exec_args[i+1] = tmp[i];
-        }
-      else
-        {
-          exec_args.resize (1);
+  if (nargin == 2)
+    {
+      string_vector tmp = args(1).xall_strings ("exec: all arguments must be strings");
 
-          exec_args[0] = exec_file;
-        }
+      int len = tmp.numel ();
 
-      octave_history_write_timestamp ();
-
-      if (! command_history::ignoring_entries ())
-        command_history::clean_up_and_save ();
+      exec_args.resize (len + 1);
 
-      std::string msg;
+      exec_args[0] = exec_file;
 
-      int status = octave_syscalls::execvp (exec_file, exec_args, msg);
-
-      retval(1) = msg;
-      retval(0) = status;
+      for (int i = 0; i < len; i++)
+        exec_args[i+1] = tmp[i];
     }
   else
-    print_usage ();
+    {
+      exec_args.resize (1);
+
+      exec_args[0] = exec_file;
+    }
+
+  octave_history_write_timestamp ();
+
+  if (! command_history::ignoring_entries ())
+    command_history::clean_up_and_save ();
+
+  std::string msg;
+
+  int status = octave_syscalls::execvp (exec_file, exec_args, msg);
+
+  retval(1) = msg;
+  retval(0) = status;
 
   return retval;
 }
@@ -281,66 +277,64 @@
 
   int nargin = args.length ();
 
-  if (nargin >= 1 && nargin <= 3)
-    {
-      std::string exec_file = args(0).xstring_value ("popen2: COMMAND argument must be a string");
-
-      string_vector arg_list;
-
-      if (nargin >= 2)
-        {
-          string_vector tmp = args(1).xall_strings ("popen2: all arguments must be strings");
-
-          int len = tmp.numel ();
-
-          arg_list.resize (len + 1);
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
 
-          arg_list[0] = exec_file;
+  std::string exec_file = args(0).xstring_value ("popen2: COMMAND argument must be a string");
 
-          for (int i = 0; i < len; i++)
-            arg_list[i+1] = tmp[i];
-        }
-      else
-        {
-          arg_list.resize (1);
-
-          arg_list[0] = exec_file;
-        }
-
-      bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
+  string_vector arg_list;
 
-      int fildes[2];
-      std::string msg;
-      pid_t pid;
+  if (nargin >= 2)
+    {
+      string_vector tmp = args(1).xall_strings ("popen2: all arguments must be strings");
 
-      pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode,
-                                     fildes, msg, interactive);
-      if (pid >= 0)
-        {
-          FILE *ifile = fdopen (fildes[1], "r");
-          FILE *ofile = fdopen (fildes[0], "w");
-
-          std::string nm;
+      int len = tmp.numel ();
 
-          octave_stream is = octave_stdiostream::create (exec_file + "-in",
-                                                         ifile,
-                                                         std::ios::in);
-
-          octave_stream os = octave_stdiostream::create (exec_file + "-out",
-                                                         ofile,
-                                                         std::ios::out);
+      arg_list.resize (len + 1);
 
-          Cell file_ids (1, 2);
+      arg_list[0] = exec_file;
 
-          retval(2) = pid;
-          retval(1) = octave_stream_list::insert (is);
-          retval(0) = octave_stream_list::insert (os);
-        }
-      else
-        error (msg.c_str ());
+      for (int i = 0; i < len; i++)
+        arg_list[i+1] = tmp[i];
     }
   else
-    print_usage ();
+    {
+      arg_list.resize (1);
+
+      arg_list[0] = exec_file;
+    }
+
+  bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
+
+  int fildes[2];
+  std::string msg;
+  pid_t pid;
+
+  pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode,
+                                 fildes, msg, interactive);
+  if (pid >= 0)
+    {
+      FILE *ifile = fdopen (fildes[1], "r");
+      FILE *ofile = fdopen (fildes[0], "w");
+
+      std::string nm;
+
+      octave_stream is = octave_stdiostream::create (exec_file + "-in",
+                                                     ifile,
+                                                     std::ios::in);
+
+      octave_stream os = octave_stdiostream::create (exec_file + "-out",
+                                                     ofile,
+                                                     std::ios::out);
+
+      Cell file_ids (1, 2);
+
+      retval(2) = pid;
+      retval(1) = octave_stream_list::insert (is);
+      retval(0) = octave_stream_list::insert (os);
+    }
+  else
+    error (msg.c_str ());
 
   return retval;
 }
@@ -479,30 +473,28 @@
 
   int nargin = args.length ();
 
-  if (nargin == 3)
-    {
-      octave_stream strm = octave_stream_list::lookup (args(0), "fcntl");
+  if (nargin != 3)
+    print_usage ();
+
+  octave_stream strm = octave_stream_list::lookup (args(0), "fcntl");
 
-      int fid = strm.file_number ();
+  int fid = strm.file_number ();
 
-      int req = args(1).int_value (true);
-      int arg = args(2).int_value (true);
+  int req = args(1).int_value (true);
+  int arg = args(2).int_value (true);
 
-      // FIXME: Need better checking here?
-      if (fid < 0)
-        error ("fcntl: invalid file id");
-      else
-        {
-          std::string msg;
+  // FIXME: Need better checking here?
+  if (fid < 0)
+    error ("fcntl: invalid file id");
+  else
+    {
+      std::string msg;
 
-          int status = octave_fcntl (fid, req, arg, msg);
+      int status = octave_fcntl (fid, req, arg, msg);
 
-          retval(1) = msg;
-          retval(0) = status;
-        }
+      retval(1) = msg;
+      retval(0) = status;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -537,17 +529,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  if (nargin != 0)
+    print_usage ();
 
-      pid_t pid = octave_syscalls::fork (msg);
+  std::string msg;
 
-      retval(1) = msg;
-      retval(0) = pid;
-    }
-  else
-    print_usage ();
+  pid_t pid = octave_syscalls::fork (msg);
+
+  retval(1) = msg;
+  retval(0) = pid;
 
   return retval;
 }
@@ -565,15 +555,13 @@
 
   int nargin = args.length ();
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  if (nargin != 0)
+    print_usage ();
 
-      retval(1) = msg;
-      retval(0) = octave_syscalls::getpgrp (msg);
-    }
-  else
-    print_usage ();
+  std::string msg;
+
+  retval(1) = msg;
+  retval(0) = octave_syscalls::getpgrp (msg);
 
   return retval;
 }
@@ -585,16 +573,12 @@
 @seealso{getppid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getpid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getpid ());
 }
 
 DEFUNX ("getppid", Fgetppid, args, ,
@@ -604,16 +588,12 @@
 @seealso{getpid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getppid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getppid ());
 }
 
 DEFUNX ("getegid", Fgetegid, args, ,
@@ -623,16 +603,12 @@
 @seealso{getgid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getegid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getegid ());
 }
 
 DEFUNX ("getgid", Fgetgid, args, ,
@@ -642,16 +618,12 @@
 @seealso{getegid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getgid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getgid ());
 }
 
 DEFUNX ("geteuid", Fgeteuid, args, ,
--- a/libinterp/corefcn/sysdep.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/sysdep.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -193,27 +193,25 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      std::string file = args(0).xstring_value ("__open_with_system_app__: argument must be a filename");
+  if (args.length () != 1)
+    print_usage ();
+
+  std::string file = args(0).xstring_value ("__open_with_system_app__: argument must be a filename");
 
 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-      HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
-                                       SW_SHOWNORMAL);
+  HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
+                                   SW_SHOWNORMAL);
 
-      // ShellExecute returns a value greater than 32 if successful.
-      retval = (reinterpret_cast<ptrdiff_t> (status) > 32);
+  // ShellExecute returns a value greater than 32 if successful.
+  retval = (reinterpret_cast<ptrdiff_t> (status) > 32);
 #else
-      octave_value_list tmp
-        = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null",
-                        false, "async"),
-                   1);
+  octave_value_list tmp
+    = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null",
+                    false, "async"),
+               1);
 
-      retval = (tmp(0).double_value () == 0);
+  retval = (tmp(0).double_value () == 0);
 #endif
-    }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -614,20 +612,14 @@
 @seealso{setenv, unsetenv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      std::string name = args(0).string_value ();
-
-      retval = octave_env::getenv (name);
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  std::string name = args(0).string_value ();
+
+  return octave_value (octave_env::getenv (name));
 }
 
 /*
@@ -650,18 +642,16 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 1)
-    {
-      std::string var = args(0).xstring_value ("setenv: VAR must be a string");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  std::string var = args(0).xstring_value ("setenv: VAR must be a string");
 
-      std::string val = (nargin == 2
-                         ? args(1).xstring_value ("setenv: VALUE must be a string")
-                         : std::string ());
+  std::string val = (nargin == 2
+                     ? args(1).xstring_value ("setenv: VALUE must be a string")
+                     : std::string ());
 
-      octave_env::putenv (var, val);
-    }
-  else
-    print_usage ();
+  octave_env::putenv (var, val);
 
   return retval;
 }
@@ -686,20 +676,14 @@
 @seealso{setenv, getenv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      std::string tmp = args(0).string_value ();
-
-      retval = gnulib::unsetenv (tmp.c_str ());
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  std::string tmp = args(0).string_value ();
+
+  return octave_value (gnulib::unsetenv (tmp.c_str ()));
 }
 
 /*
@@ -785,11 +769,8 @@
 
   int nargin = args.length ();
 
-  if (! (nargin == 0 || nargin == 1))
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
 
   if (nargin == 1)
     {
@@ -836,20 +817,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      double dval = args(0).double_value ();
+  if (args.length () != 1)
+    print_usage ();
+
+  double dval = args(0).double_value ();
 
-      if (xisnan (dval))
-        warning ("sleep: NaN is an invalid delay");
-      else
-        {
-          Fdrawnow ();
-          octave_sleep (dval);
-        }
+  if (xisnan (dval))
+    warning ("sleep: NaN is an invalid delay");
+  else
+    {
+      Fdrawnow ();
+      octave_sleep (dval);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -876,24 +855,22 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      double dval = args(0).double_value ();
+  if (args.length () != 1)
+    print_usage ();
+
+  double dval = args(0).double_value ();
 
-      if (xisnan (dval))
-        warning ("usleep: NaN is an invalid delay");
-      else
-        {
-          Fdrawnow ();
+  if (xisnan (dval))
+    warning ("usleep: NaN is an invalid delay");
+  else
+    {
+      Fdrawnow ();
 
-          int delay = NINT (dval);
+      int delay = NINT (dval);
 
-          if (delay > 0)
-            octave_usleep (delay);
-        }
+      if (delay > 0)
+        octave_usleep (delay);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -975,21 +952,19 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      octave_value arg = args(0);
+  if (nargin != 1)
+    print_usage ();
 
-      string_vector sv = arg.xall_strings ("tilde_expand: argument must be char or cellstr object");
+  octave_value arg = args(0);
 
-      sv = file_ops::tilde_expand (sv);
+  string_vector sv = arg.xall_strings ("tilde_expand: argument must be char or cellstr object");
 
-      if (arg.is_cellstr ())
-        retval = Cell (arg.dims (), sv);
-      else
-        retval = sv;
-    }
+  sv = file_ops::tilde_expand (sv);
+
+  if (arg.is_cellstr ())
+    retval = Cell (arg.dims (), sv);
   else
-    print_usage ();
+    retval = sv;
 
   return retval;
 }
--- a/libinterp/corefcn/time.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/time.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -114,14 +114,10 @@
 @seealso{strftime, strptime, localtime, gmtime, mktime, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = octave_time ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_time ());
 }
 
 /*
@@ -160,18 +156,12 @@
 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      double tmp = args(0).double_value ();
-
-      retval = octave_value (mk_tm_map (octave_gmtime (tmp)));
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  double tmp = args(0).double_value ();
+
+  return octave_value (mk_tm_map (octave_gmtime (tmp)));
 }
 
 /*
@@ -221,18 +211,12 @@
 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      double tmp = args(0).double_value ();
-
-      retval = octave_value (mk_tm_map (octave_localtime (tmp)));
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  double tmp = args(0).double_value ();
+
+  return octave_value (mk_tm_map (octave_localtime (tmp)));
 }
 
 /*
@@ -271,20 +255,14 @@
 @seealso{strftime, strptime, localtime, gmtime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      octave_scalar_map map = args(0).xscalar_map_value ("mktime: TM_STRUCT argument must be a structure");
-
-      octave_base_tm tm = extract_tm (map, "mktime");
-
-      retval = octave_time (tm);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  octave_scalar_map map = args(0).xscalar_map_value ("mktime: TM_STRUCT argument must be a structure");
+
+  octave_base_tm tm = extract_tm (map, "mktime");
+
+  return octave_value (octave_time (tm));
 }
 
 /*
@@ -464,20 +442,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      std::string fmt = args(0).xstring_value ("strftime: FMT must be a string");
-
-      octave_scalar_map map = args(1).xscalar_map_value ("strftime: TM_STRUCT must be a structure");
-
-      octave_base_tm tm = extract_tm (map, "strftime");
-
-      retval = tm.strftime (fmt);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  std::string fmt = args(0).xstring_value ("strftime: FMT must be a string");
+
+  octave_scalar_map map = args(1).xscalar_map_value ("strftime: TM_STRUCT must be a structure");
+
+  octave_base_tm tm = extract_tm (map, "strftime");
+
+  return octave_value (tm.strftime (fmt));
 }
 
 /*
@@ -507,19 +481,17 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 2)
-    {
-      std::string str = args(0).xstring_value ("strptime: argument STR must be a string");
+  if (args.length () != 2)
+    print_usage ();
 
-      std::string fmt = args(1).xstring_value ("strptime: FMT must be a string");
+  std::string str = args(0).xstring_value ("strptime: argument STR must be a string");
 
-      octave_strptime t (str, fmt);
+  std::string fmt = args(1).xstring_value ("strptime: FMT must be a string");
 
-      retval(1) = t.characters_converted ();
-      retval(0) = octave_value (mk_tm_map (t));
-    }
-  else
-    print_usage ();
+  octave_strptime t (str, fmt);
+
+  retval(1) = t.characters_converted ();
+  retval(0) = octave_value (mk_tm_map (t));
 
   return retval;
 }
--- a/libinterp/corefcn/toplev.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/toplev.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1029,112 +1029,110 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0 && nargin < 4)
-    {
-      bool return_output = (nargin == 1 && nargout > 1);
+  if (nargin == 0 || nargin > 3)
+    print_usage ();
 
-      system_exec_type type = et_sync;
+  bool return_output = (nargin == 1 && nargout > 1);
 
-      if (nargin == 3)
-        {
-          std::string type_str = args(2).xstring_value ("system: TYPE must be a string");
+  system_exec_type type = et_sync;
 
-          if (type_str == "sync")
-            type = et_sync;
-          else if (type_str == "async")
-            type = et_async;
-          else
-            {
-              error ("system: TYPE must be \"sync\" or \"async\"");
-              return retval;
-            }
-        }
+  if (nargin == 3)
+    {
+      std::string type_str = args(2).xstring_value ("system: TYPE must be a string");
 
-      if (nargin > 1)
+      if (type_str == "sync")
+        type = et_sync;
+      else if (type_str == "async")
+        type = et_async;
+      else
         {
-          try
-            {
-              return_output = args(1).is_true ();
-            }
-          catch (octave_execution_exception& e)
-            {
-              error (e, "system: RETURN_OUTPUT must be boolean value true or false");
-            }
-        }
-
-      if (return_output && type == et_async)
-        {
-          error ("system: can't return output from commands run asynchronously");
+          error ("system: TYPE must be \"sync\" or \"async\"");
           return retval;
         }
+    }
 
-      std::string cmd_str = args(0).xstring_value ("system: first argument must be a string");
+  if (nargin > 1)
+    {
+      try
+        {
+          return_output = args(1).is_true ();
+        }
+      catch (octave_execution_exception& e)
+        {
+          error (e, "system: RETURN_OUTPUT must be boolean value true or false");
+        }
+    }
+
+  if (return_output && type == et_async)
+    {
+      error ("system: can't return output from commands run asynchronously");
+      return retval;
+    }
+
+  std::string cmd_str = args(0).xstring_value ("system: first argument must be a string");
 
 #if defined (__WIN32__) && ! defined (__CYGWIN__)
-      // Work around weird double-quote handling on Windows systems.
-      if (type == et_sync)
-        cmd_str = "\"" + cmd_str + "\"";
+  // Work around weird double-quote handling on Windows systems.
+  if (type == et_sync)
+    cmd_str = "\"" + cmd_str + "\"";
 #endif
 
-      if (type == et_async)
-        {
-          // FIXME: maybe this should go in sysdep.cc?
+  if (type == et_async)
+    {
+      // FIXME: maybe this should go in sysdep.cc?
 #ifdef HAVE_FORK
-          pid_t pid = fork ();
+      pid_t pid = fork ();
 
-          if (pid < 0)
-            error ("system: fork failed -- can't create child process");
-          else if (pid == 0)
-            {
-              // FIXME: should probably replace this
-              // call with something portable.
+      if (pid < 0)
+        error ("system: fork failed -- can't create child process");
+      else if (pid == 0)
+        {
+          // FIXME: should probably replace this
+          // call with something portable.
 
-              execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
-                     static_cast<void *> (0));
+          execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
+                 static_cast<void *> (0));
 
-              panic_impossible ();
-            }
-          else
-            retval(0) = pid;
+          panic_impossible ();
+        }
+      else
+        retval(0) = pid;
 #elif defined (__WIN32__)
-          STARTUPINFO si;
-          PROCESS_INFORMATION pi;
-          ZeroMemory (&si, sizeof (si));
-          ZeroMemory (&pi, sizeof (pi));
-          OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1);
-          strcpy (xcmd_str, cmd_str.c_str ());
+      STARTUPINFO si;
+      PROCESS_INFORMATION pi;
+      ZeroMemory (&si, sizeof (si));
+      ZeroMemory (&pi, sizeof (pi));
+      OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1);
+      strcpy (xcmd_str, cmd_str.c_str ());
 
-          if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
-            error ("system: CreateProcess failed -- can't create child process");
-          else
-            {
-              retval(0) = pi.dwProcessId;
-              CloseHandle (pi.hProcess);
-              CloseHandle (pi.hThread);
-            }
-#else
-          error ("system: asynchronous system calls are not supported");
-#endif
-        }
-      else if (return_output)
-        retval = run_command_and_return_output (cmd_str);
+      if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
+        error ("system: CreateProcess failed -- can't create child process");
       else
         {
-          int status = system (cmd_str.c_str ());
-
-          // The value in status is as returned by waitpid.  If
-          // the process exited normally, extract the actual exit
-          // status of the command.  Otherwise, return 127 as a
-          // failure code.
+          retval(0) = pi.dwProcessId;
+          CloseHandle (pi.hProcess);
+          CloseHandle (pi.hThread);
+        }
+#else
+      error ("system: asynchronous system calls are not supported");
+#endif
+    }
+  else if (return_output)
+    retval = run_command_and_return_output (cmd_str);
+  else
+    {
+      int status = system (cmd_str.c_str ());
 
-          if (octave_wait::ifexited (status))
-            status = octave_wait::exitstatus (status);
+      // The value in status is as returned by waitpid.  If
+      // the process exited normally, extract the actual exit
+      // status of the command.  Otherwise, return 127 as a
+      // failure code.
 
-          retval(0) = status;
-        }
+      if (octave_wait::ifexited (status))
+        status = octave_wait::exitstatus (status);
+
+      retval(0) = status;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1221,27 +1219,24 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      bool add_mode = true;
+  std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string");
 
-      if (nargin == 2)
-        add_mode = args(1).xbool_value ("atexit: FLAG argument must be a logical value");
+  bool add_mode = (nargin == 2)
+    ? args(1).xbool_value ("atexit: FLAG argument must be a logical value")
+    : true;
 
-      if (add_mode)
-        octave_add_atexit_function (arg);
-      else
-        {
-          bool found = octave_remove_atexit_function (arg);
+  if (add_mode)
+    octave_add_atexit_function (arg);
+  else
+    {
+      bool found = octave_remove_atexit_function (arg);
 
-          if (nargout > 0)
-            retval(0) = found;
-        }
+      if (nargout > 0)
+        retval(0) = found;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1521,6 +1516,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       std::string arg = args(0).string_value ();
@@ -1537,10 +1535,8 @@
       else
         error ("octave_config_info: invalid parameter '%s'", arg.c_str ());
     }
-  else if (nargin == 0)
+  else
     retval = m;
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/tril.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/tril.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -189,145 +189,150 @@
 do_trilu (const std::string& name,
           const octave_value_list& args)
 {
-  bool lower = name == "tril";
+  bool lower = (name == "tril");
 
   octave_value retval;
   int nargin = args.length ();
   octave_idx_type k = 0;
   bool pack = false;
+
   if (nargin >= 2 && args(nargin-1).is_string ())
     {
       pack = args(nargin-1).string_value () == "pack";
       nargin--;
     }
 
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   if (nargin == 2)
     k = args(1).int_value (true);
 
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
+  octave_value arg = args(0);
+
+  dim_vector dims = arg.dims ();
+  if (dims.length () != 2)
+    error ("%s: need a 2-D matrix", name.c_str ());
+  else if (k < -dims(0) || k > dims(1))
+    error ("%s: requested diagonal out of range", name.c_str ());
   else
     {
-      octave_value arg = args(0);
-
-      dim_vector dims = arg.dims ();
-      if (dims.length () != 2)
-        error ("%s: need a 2-D matrix", name.c_str ());
-      else if (k < -dims(0) || k > dims(1))
-        error ("%s: requested diagonal out of range", name.c_str ());
-      else
+      switch (arg.builtin_type ())
         {
-          switch (arg.builtin_type ())
-            {
-            case btyp_double:
-              if (arg.is_sparse_type ())
-                retval = do_trilu (arg.sparse_matrix_value (), k, lower, pack);
-              else
-                retval = do_trilu (arg.array_value (), k, lower, pack);
-              break;
-            case btyp_complex:
-              if (arg.is_sparse_type ())
-                retval = do_trilu (arg.sparse_complex_matrix_value (), k, lower,
-                                   pack);
-              else
-                retval = do_trilu (arg.complex_array_value (), k, lower, pack);
-              break;
-            case btyp_bool:
-              if (arg.is_sparse_type ())
-                retval = do_trilu (arg.sparse_bool_matrix_value (), k, lower,
-                                   pack);
-              else
-                retval = do_trilu (arg.bool_array_value (), k, lower, pack);
-              break;
-#define ARRAYCASE(TYP) \
-            case btyp_ ## TYP: \
-              retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
-              break
-            ARRAYCASE (float);
-            ARRAYCASE (float_complex);
-            ARRAYCASE (int8);
-            ARRAYCASE (int16);
-            ARRAYCASE (int32);
-            ARRAYCASE (int64);
-            ARRAYCASE (uint8);
-            ARRAYCASE (uint16);
-            ARRAYCASE (uint32);
-            ARRAYCASE (uint64);
-            ARRAYCASE (char);
+        case btyp_double:
+          if (arg.is_sparse_type ())
+            retval = do_trilu (arg.sparse_matrix_value (), k, lower, pack);
+          else
+            retval = do_trilu (arg.array_value (), k, lower, pack);
+          break;
+
+        case btyp_complex:
+          if (arg.is_sparse_type ())
+            retval = do_trilu (arg.sparse_complex_matrix_value (), k, lower,
+                               pack);
+          else
+            retval = do_trilu (arg.complex_array_value (), k, lower, pack);
+          break;
+
+        case btyp_bool:
+          if (arg.is_sparse_type ())
+            retval = do_trilu (arg.sparse_bool_matrix_value (), k, lower,
+                               pack);
+          else
+            retval = do_trilu (arg.bool_array_value (), k, lower, pack);
+          break;
+
+#define ARRAYCASE(TYP)       \
+          case btyp_ ## TYP: \
+            retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
+            break
+
+          ARRAYCASE (float);
+          ARRAYCASE (float_complex);
+          ARRAYCASE (int8);
+          ARRAYCASE (int16);
+          ARRAYCASE (int32);
+          ARRAYCASE (int64);
+          ARRAYCASE (uint8);
+          ARRAYCASE (uint16);
+          ARRAYCASE (uint32);
+          ARRAYCASE (uint64);
+          ARRAYCASE (char);
+
 #undef ARRAYCASE
-            default:
-              {
-                // Generic code that works on octave-values, that is slow
-                // but will also work on arbitrary user types
+
+        default:
+          {
+            // Generic code that works on octave-values, that is slow
+            // but will also work on arbitrary user types
 
-                if (pack) // FIXME
-                  {
-                    error ("%s: \"pack\" not implemented for class %s",
-                           name.c_str (), arg.class_name ().c_str ());
-                    return octave_value ();
-                  }
+            if (pack) // FIXME
+              {
+                error ("%s: \"pack\" not implemented for class %s",
+                       name.c_str (), arg.class_name ().c_str ());
+                return octave_value ();
+              }
 
-                octave_value tmp = arg;
-                if (arg.numel () == 0)
-                  return arg;
+            octave_value tmp = arg;
+            if (arg.numel () == 0)
+              return arg;
 
-                octave_idx_type nr = dims(0);
-                octave_idx_type nc = dims(1);
+            octave_idx_type nr = dims(0);
+            octave_idx_type nc = dims(1);
 
-                // The sole purpose of the below is to force the correct
-                // matrix size. This would not be necessary if the
-                // octave_value resize function allowed a fill_value.
-                // It also allows odd attributes in some user types
-                // to be handled. With a fill_value ot should be replaced
-                // with
-                //
-                // octave_value_list ov_idx;
-                // tmp = tmp.resize(dim_vector (0,0)).resize (dims, fill_value);
+            // The sole purpose of the below is to force the correct
+            // matrix size. This would not be necessary if the
+            // octave_value resize function allowed a fill_value.
+            // It also allows odd attributes in some user types
+            // to be handled. With a fill_value ot should be replaced
+            // with
+            //
+            // octave_value_list ov_idx;
+            // tmp = tmp.resize(dim_vector (0,0)).resize (dims, fill_value);
 
-                octave_value_list ov_idx;
-                std::list<octave_value_list> idx_tmp;
-                ov_idx(1) = static_cast<double> (nc+1);
-                ov_idx(0) = Range (1, nr);
-                idx_tmp.push_back (ov_idx);
-                ov_idx(1) = static_cast<double> (nc);
-                tmp = tmp.resize (dim_vector (0,0));
-                tmp = tmp.subsasgn ("(",idx_tmp, arg.do_index_op (ov_idx));
-                tmp = tmp.resize (dims);
-
-                if (lower)
-                  {
-                    octave_idx_type st = nc < nr + k ? nc : nr + k;
+            octave_value_list ov_idx;
+            std::list<octave_value_list> idx_tmp;
+            ov_idx(1) = static_cast<double> (nc+1);
+            ov_idx(0) = Range (1, nr);
+            idx_tmp.push_back (ov_idx);
+            ov_idx(1) = static_cast<double> (nc);
+            tmp = tmp.resize (dim_vector (0,0));
+            tmp = tmp.subsasgn ("(",idx_tmp, arg.do_index_op (ov_idx));
+            tmp = tmp.resize (dims);
 
-                    for (octave_idx_type j = 1; j <= st; j++)
-                      {
-                        octave_idx_type nr_limit = 1 > j - k ? 1 : j - k;
-                        ov_idx(1) = static_cast<double> (j);
-                        ov_idx(0) = Range (nr_limit, nr);
-                        std::list<octave_value_list> idx;
-                        idx.push_back (ov_idx);
+            if (lower)
+              {
+                octave_idx_type st = nc < nr + k ? nc : nr + k;
 
-                        tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
-                      }
-                  }
-                else
+                for (octave_idx_type j = 1; j <= st; j++)
                   {
-                    octave_idx_type st = k + 1 > 1 ? k + 1 : 1;
+                    octave_idx_type nr_limit = 1 > j - k ? 1 : j - k;
+                    ov_idx(1) = static_cast<double> (j);
+                    ov_idx(0) = Range (nr_limit, nr);
+                    std::list<octave_value_list> idx;
+                    idx.push_back (ov_idx);
 
-                    for (octave_idx_type j = st; j <= nc; j++)
-                      {
-                        octave_idx_type nr_limit = nr < j - k ? nr : j - k;
-                        ov_idx(1) = static_cast<double> (j);
-                        ov_idx(0) = Range (1, nr_limit);
-                        std::list<octave_value_list> idx;
-                        idx.push_back (ov_idx);
+                    tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
+                  }
+              }
+            else
+              {
+                octave_idx_type st = k + 1 > 1 ? k + 1 : 1;
 
-                        tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
-                      }
-                  }
+                for (octave_idx_type j = st; j <= nc; j++)
+                  {
+                    octave_idx_type nr_limit = nr < j - k ? nr : j - k;
+                    ov_idx(1) = static_cast<double> (j);
+                    ov_idx(0) = Range (1, nr_limit);
+                    std::list<octave_value_list> idx;
+                    idx.push_back (ov_idx);
 
-                retval = tmp;
+                    tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
+                  }
               }
-            }
+
+            retval = tmp;
+          }
         }
     }
 
--- a/libinterp/corefcn/tsearch.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/tsearch.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -70,15 +70,14 @@
 @seealso{delaunay, delaunayn}\n\
 @end deftypefn")
 {
-  const double eps=1.0e-12;
+  octave_value_list retval;
 
-  octave_value_list retval;
+  const double eps = 1.0e-12;
+
   const int nargin = args.length ();
+
   if (nargin != 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   const ColumnVector x (args(0).vector_value ());
   const ColumnVector y (args(1).vector_value ());
--- a/libinterp/corefcn/typecast.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/typecast.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -145,119 +145,117 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      unwind_protect frame;
-      const void *data = 0;
-      octave_idx_type byte_size = 0;
-      dim_vector old_dims;
+  if (args.length () != 2)
+    print_usage ();
+
+  unwind_protect frame;
+  const void *data = 0;
+  octave_idx_type byte_size = 0;
+  dim_vector old_dims;
+
+  octave_value array = args(0);
 
-      octave_value array = args(0);
-
-      if (array.is_bool_type ())
-        get_data_and_bytesize (array.bool_array_value (), data, byte_size,
+  if (array.is_bool_type ())
+    get_data_and_bytesize (array.bool_array_value (), data, byte_size,
+                           old_dims, frame);
+  else if (array.is_string ())
+    get_data_and_bytesize (array.char_array_value (), data, byte_size,
+                           old_dims, frame);
+  else if (array.is_integer_type ())
+    {
+      if (array.is_int8_type ())
+        get_data_and_bytesize (array.int8_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_int16_type ())
+        get_data_and_bytesize (array.int16_array_value (), data, byte_size,
                                old_dims, frame);
-      else if (array.is_string ())
-        get_data_and_bytesize (array.char_array_value (), data, byte_size,
+      else if (array.is_int32_type ())
+        get_data_and_bytesize (array.int32_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_int64_type ())
+        get_data_and_bytesize (array.int64_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint8_type ())
+        get_data_and_bytesize (array.uint8_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint16_type ())
+        get_data_and_bytesize (array.uint16_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint32_type ())
+        get_data_and_bytesize (array.uint32_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint64_type ())
+        get_data_and_bytesize (array.uint64_array_value (), data, byte_size,
                                old_dims, frame);
-      else if (array.is_integer_type ())
-        {
-          if (array.is_int8_type ())
-            get_data_and_bytesize (array.int8_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_int16_type ())
-            get_data_and_bytesize (array.int16_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_int32_type ())
-            get_data_and_bytesize (array.int32_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_int64_type ())
-            get_data_and_bytesize (array.int64_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint8_type ())
-            get_data_and_bytesize (array.uint8_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint16_type ())
-            get_data_and_bytesize (array.uint16_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint32_type ())
-            get_data_and_bytesize (array.uint32_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint64_type ())
-            get_data_and_bytesize (array.uint64_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else
-            assert (0);
-        }
-      else if (array.is_complex_type ())
-        {
-          if (array.is_single_type ())
-            get_data_and_bytesize (array.float_complex_array_value (), data,
-                                   byte_size, old_dims, frame);
-          else
-            get_data_and_bytesize (array.complex_array_value (), data,
-                                   byte_size, old_dims, frame);
-        }
-      else if (array.is_real_type ())
-        {
-          if (array.is_single_type ())
-            get_data_and_bytesize (array.float_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else
-            get_data_and_bytesize (array.array_value (), data, byte_size,
-                                   old_dims, frame); }
+      else
+        assert (0);
+    }
+  else if (array.is_complex_type ())
+    {
+      if (array.is_single_type ())
+        get_data_and_bytesize (array.float_complex_array_value (), data,
+                               byte_size, old_dims, frame);
+      else
+        get_data_and_bytesize (array.complex_array_value (), data,
+                               byte_size, old_dims, frame);
+    }
+  else if (array.is_real_type ())
+    {
+      if (array.is_single_type ())
+        get_data_and_bytesize (array.float_array_value (), data, byte_size,
+                               old_dims, frame);
       else
-        error ("typecast: invalid input class: %s",
-                                                array.class_name ().c_str ());
+        get_data_and_bytesize (array.array_value (), data, byte_size,
+                               old_dims, frame); }
+  else
+    error ("typecast: invalid input class: %s",
+           array.class_name ().c_str ());
 
-      std::string numclass = args(1).string_value ();
+  std::string numclass = args(1).string_value ();
 
-      if (numclass.size () == 0)
-        ;
-      else if (numclass == "char")
-        retval = octave_value (reinterpret_copy<charNDArray>
-                   (data, byte_size, old_dims), array.is_dq_string () ? '"'
-                                                                      : '\'');
-      else if (numclass[0] == 'i')
-        {
-          if (numclass == "int8")
-            retval = reinterpret_copy<int8NDArray> (data, byte_size, old_dims);
-          else if (numclass == "int16")
-            retval = reinterpret_copy<int16NDArray> (data, byte_size, old_dims);
-          else if (numclass == "int32")
-            retval = reinterpret_copy<int32NDArray> (data, byte_size, old_dims);
-          else if (numclass == "int64")
-            retval = reinterpret_copy<int64NDArray> (data, byte_size, old_dims);
-        }
-      else if (numclass[0] == 'u')
-        {
-          if (numclass == "uint8")
-            retval = reinterpret_copy<uint8NDArray> (data, byte_size, old_dims);
-          else if (numclass == "uint16")
-            retval = reinterpret_copy<uint16NDArray> (data, byte_size,
-                                                      old_dims);
-          else if (numclass == "uint32")
-            retval = reinterpret_copy<uint32NDArray> (data, byte_size,
-                                                      old_dims);
-          else if (numclass == "uint64")
-            retval = reinterpret_copy<uint64NDArray> (data, byte_size,
-                                                      old_dims);
-        }
-      else if (numclass == "single")
-        retval = reinterpret_copy<FloatNDArray> (data, byte_size, old_dims);
-      else if (numclass == "double")
-        retval = reinterpret_copy<NDArray> (data, byte_size, old_dims);
-      else if (numclass == "single complex")
-        retval = reinterpret_copy<FloatComplexNDArray> (data, byte_size,
-                                                        old_dims);
-      else if (numclass == "double complex")
-        retval = reinterpret_copy<ComplexNDArray> (data, byte_size, old_dims);
+  if (numclass.size () == 0)
+    ;
+  else if (numclass == "char")
+    retval = octave_value (reinterpret_copy<charNDArray>
+                           (data, byte_size, old_dims), array.is_dq_string () ? '"'
+                           : '\'');
+  else if (numclass[0] == 'i')
+    {
+      if (numclass == "int8")
+        retval = reinterpret_copy<int8NDArray> (data, byte_size, old_dims);
+      else if (numclass == "int16")
+        retval = reinterpret_copy<int16NDArray> (data, byte_size, old_dims);
+      else if (numclass == "int32")
+        retval = reinterpret_copy<int32NDArray> (data, byte_size, old_dims);
+      else if (numclass == "int64")
+        retval = reinterpret_copy<int64NDArray> (data, byte_size, old_dims);
+    }
+  else if (numclass[0] == 'u')
+    {
+      if (numclass == "uint8")
+        retval = reinterpret_copy<uint8NDArray> (data, byte_size, old_dims);
+      else if (numclass == "uint16")
+        retval = reinterpret_copy<uint16NDArray> (data, byte_size,
+                                                  old_dims);
+      else if (numclass == "uint32")
+        retval = reinterpret_copy<uint32NDArray> (data, byte_size,
+                                                  old_dims);
+      else if (numclass == "uint64")
+        retval = reinterpret_copy<uint64NDArray> (data, byte_size,
+                                                  old_dims);
+    }
+  else if (numclass == "single")
+    retval = reinterpret_copy<FloatNDArray> (data, byte_size, old_dims);
+  else if (numclass == "double")
+    retval = reinterpret_copy<NDArray> (data, byte_size, old_dims);
+  else if (numclass == "single complex")
+    retval = reinterpret_copy<FloatComplexNDArray> (data, byte_size,
+                                                    old_dims);
+  else if (numclass == "double complex")
+    retval = reinterpret_copy<ComplexNDArray> (data, byte_size, old_dims);
 
-      if (retval.is_undefined ())
-        error ("typecast: cannot convert to %s class", numclass.c_str ());
-    }
-  else
-    print_usage ();
+  if (retval.is_undefined ())
+    error ("typecast: cannot convert to %s class", numclass.c_str ());
 
   return retval;
 }
@@ -339,52 +337,51 @@
 
   if (args.length () != 2)
     print_usage ();
-  else if (! args(0).is_bool_type ())
+
+  if (! args(0).is_bool_type ())
     error ("bitpack: X must be a logical array");
-  else
-    {
-      boolNDArray bitp = args(0).bool_array_value ();
 
-      std::string numclass = args(1).string_value ();
+  boolNDArray bitp = args(0).bool_array_value ();
+
+  std::string numclass = args(1).string_value ();
 
-      if (numclass.size () == 0)
-        ;
-      else if (numclass == "char")
-        retval = octave_value (do_bitpack<charNDArray> (bitp), '\'');
-      else if (numclass[0] == 'i')
-        {
-          if (numclass == "int8")
-            retval = do_bitpack<int8NDArray> (bitp);
-          else if (numclass == "int16")
-            retval = do_bitpack<int16NDArray> (bitp);
-          else if (numclass == "int32")
-            retval = do_bitpack<int32NDArray> (bitp);
-          else if (numclass == "int64")
-            retval = do_bitpack<int64NDArray> (bitp);
-        }
-      else if (numclass[0] == 'u')
-        {
-          if (numclass == "uint8")
-            retval = do_bitpack<uint8NDArray> (bitp);
-          else if (numclass == "uint16")
-            retval = do_bitpack<uint16NDArray> (bitp);
-          else if (numclass == "uint32")
-            retval = do_bitpack<uint32NDArray> (bitp);
-          else if (numclass == "uint64")
-            retval = do_bitpack<uint64NDArray> (bitp);
-        }
-      else if (numclass == "single")
-        retval = do_bitpack<FloatNDArray> (bitp);
-      else if (numclass == "double")
-        retval = do_bitpack<NDArray> (bitp);
-      else if (numclass == "single complex")
-        retval = do_bitpack<FloatComplexNDArray> (bitp);
-      else if (numclass == "double complex")
-        retval = do_bitpack<ComplexNDArray> (bitp);
+  if (numclass.size () == 0)
+    ;
+  else if (numclass == "char")
+    retval = octave_value (do_bitpack<charNDArray> (bitp), '\'');
+  else if (numclass[0] == 'i')
+    {
+      if (numclass == "int8")
+        retval = do_bitpack<int8NDArray> (bitp);
+      else if (numclass == "int16")
+        retval = do_bitpack<int16NDArray> (bitp);
+      else if (numclass == "int32")
+        retval = do_bitpack<int32NDArray> (bitp);
+      else if (numclass == "int64")
+        retval = do_bitpack<int64NDArray> (bitp);
+    }
+  else if (numclass[0] == 'u')
+    {
+      if (numclass == "uint8")
+        retval = do_bitpack<uint8NDArray> (bitp);
+      else if (numclass == "uint16")
+        retval = do_bitpack<uint16NDArray> (bitp);
+      else if (numclass == "uint32")
+        retval = do_bitpack<uint32NDArray> (bitp);
+      else if (numclass == "uint64")
+        retval = do_bitpack<uint64NDArray> (bitp);
+    }
+  else if (numclass == "single")
+    retval = do_bitpack<FloatNDArray> (bitp);
+  else if (numclass == "double")
+    retval = do_bitpack<NDArray> (bitp);
+  else if (numclass == "single complex")
+    retval = do_bitpack<FloatComplexNDArray> (bitp);
+  else if (numclass == "double complex")
+    retval = do_bitpack<ComplexNDArray> (bitp);
 
-      if (retval.is_undefined ())
-        error ("bitpack: cannot pack to %s class", numclass.c_str ());
-    }
+  if (retval.is_undefined ())
+    error ("bitpack: cannot pack to %s class", numclass.c_str ());
 
   return retval;
 }
@@ -447,54 +444,54 @@
 {
   octave_value retval;
 
-  if (args.length () == 1
-      && (args(0).is_numeric_type () || args(0).is_string ()))
-    {
-      octave_value array = args(0);
+  if (args.length () != 1)
+    print_usage ();
+  
+  if (! (args(0).is_numeric_type () || args(0).is_string ()))
+    error ("bitunpack: argument must be a number or a string");
+
+  octave_value array = args(0);
 
-      if (array.is_string ())
-        retval = do_bitunpack (array.char_array_value ());
-      else if (array.is_integer_type ())
-        {
-          if (array.is_int8_type ())
-            retval = do_bitunpack (array.int8_array_value ());
-          else if (array.is_int16_type ())
-            retval = do_bitunpack (array.int16_array_value ());
-          else if (array.is_int32_type ())
-            retval = do_bitunpack (array.int32_array_value ());
-          else if (array.is_int64_type ())
-            retval = do_bitunpack (array.int64_array_value ());
-          else if (array.is_uint8_type ())
-            retval = do_bitunpack (array.uint8_array_value ());
-          else if (array.is_uint16_type ())
-            retval = do_bitunpack (array.uint16_array_value ());
-          else if (array.is_uint32_type ())
-            retval = do_bitunpack (array.uint32_array_value ());
-          else if (array.is_uint64_type ())
-            retval = do_bitunpack (array.uint64_array_value ());
-          else
-            assert (0);
-        }
-      else if (array.is_complex_type ())
-        {
-          if (array.is_single_type ())
-            retval = do_bitunpack (array.float_complex_array_value ());
-          else
-            retval = do_bitunpack (array.complex_array_value ());
-        }
-      else if (array.is_real_type ())
-        {
-          if (array.is_single_type ())
-            retval = do_bitunpack (array.float_array_value ());
-          else
-            retval = do_bitunpack (array.array_value ());
-        }
+  if (array.is_string ())
+    retval = do_bitunpack (array.char_array_value ());
+  else if (array.is_integer_type ())
+    {
+      if (array.is_int8_type ())
+        retval = do_bitunpack (array.int8_array_value ());
+      else if (array.is_int16_type ())
+        retval = do_bitunpack (array.int16_array_value ());
+      else if (array.is_int32_type ())
+        retval = do_bitunpack (array.int32_array_value ());
+      else if (array.is_int64_type ())
+        retval = do_bitunpack (array.int64_array_value ());
+      else if (array.is_uint8_type ())
+        retval = do_bitunpack (array.uint8_array_value ());
+      else if (array.is_uint16_type ())
+        retval = do_bitunpack (array.uint16_array_value ());
+      else if (array.is_uint32_type ())
+        retval = do_bitunpack (array.uint32_array_value ());
+      else if (array.is_uint64_type ())
+        retval = do_bitunpack (array.uint64_array_value ());
       else
-        error ("bitunpack: invalid input class: %s",
-                                                 array.class_name ().c_str ());
+        assert (0);
+    }
+  else if (array.is_complex_type ())
+    {
+      if (array.is_single_type ())
+        retval = do_bitunpack (array.float_complex_array_value ());
+      else
+        retval = do_bitunpack (array.complex_array_value ());
+    }
+  else if (array.is_real_type ())
+    {
+      if (array.is_single_type ())
+        retval = do_bitunpack (array.float_array_value ());
+      else
+        retval = do_bitunpack (array.array_value ());
     }
   else
-    print_usage ();
+    error ("bitunpack: invalid input class: %s",
+           array.class_name ().c_str ());
 
   return retval;
 }
--- a/libinterp/corefcn/urlwrite.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/urlwrite.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -340,10 +340,7 @@
 
   // verify arguments
   if (nargin != 2 && nargin != 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::string url = args(0).xstring_value ("urlwrite: URL must be a string");
 
@@ -477,10 +474,7 @@
 
   // verify arguments
   if (nargin != 1 && nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::string url = args(0).xstring_value ("urlread: URL must be a string");
 
@@ -538,35 +532,25 @@
 Undocumented internal function\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
-  std::string host;
-  std::string user = "anonymous";
-  std::string passwd = "";
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
-  else
-    {
-      host = args(0).xstring_value ("__ftp__: HOST must be a string");
+    print_usage ();
+
+  std::string host = args(0).xstring_value ("__ftp__: HOST must be a string");
 
-      if (nargin > 1)
-        user = args(1).xstring_value ("__ftp__: USER must be a string");
+  std::string user = (nargin > 1)
+    ? args(1).xstring_value ("__ftp__: USER must be a string")
+    : std::string ("anonymous");
 
-      if (nargin > 2)
-        passwd = args(2).xstring_value ("__ftp__: PASSWD must be a string");
+  std::string passwd = (nargin > 2)
+    ? args(2).xstring_value ("__ftp__: PASSWD must be a string")
+    : std::string ();
 
-      curl_handle ch
-        = ch_manager::make_curl_handle (host, user, passwd, octave_stdout);
+  curl_handle ch
+    = ch_manager::make_curl_handle (host, user, passwd, octave_stdout);
 
-      retval = ch.value ();
-    }
-
-  return retval;
+  return octave_value (ch.value ());
 }
 
 DEFUN (__ftp_pwd__, args, ,
--- a/libinterp/corefcn/utils.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/utils.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -105,9 +105,11 @@
 
   if (nargin != 1)
     print_usage ();
-  else if (args(0).is_string ())
+
+  if (args(0).is_string ())
     {
       std::string varname = args(0).string_value ();
+
       retval = valid_identifier (varname) && ! is_keyword (varname);
     }
 
@@ -312,31 +314,29 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  string_vector names = args(0).xall_strings ("file_in_loadpath: FILE argument must be a string");
+
+  if (names.numel () > 0)
     {
-      string_vector names = args(0).xall_strings ("file_in_loadpath: FILE argument must be a string");
-
-      if (names.numel () > 0)
+      if (nargin == 1)
+        retval =
+          octave_env::make_absolute (load_path::find_first_of (names));
+      else if (nargin == 2)
         {
-          if (nargin == 1)
-            retval =
-              octave_env::make_absolute (load_path::find_first_of (names));
-          else if (nargin == 2)
-            {
-              std::string opt = args(1).xstring_value ("file_in_loadpath: optional second argument must be a string");
+          std::string opt = args(1).xstring_value ("file_in_loadpath: optional second argument must be a string");
 
-              if (opt == "all")
-                retval = Cell (make_absolute
-                               (load_path::find_all_first_of (names)));
-              else
-                error ("file_in_loadpath: \"all\" is only valid second argument");
-            }
+          if (opt == "all")
+            retval = Cell (make_absolute
+                           (load_path::find_all_first_of (names)));
+          else
+            error ("file_in_loadpath: \"all\" is only valid second argument");
         }
-      else
-        error ("file_in_loadpath: FILE argument must not be empty");
     }
   else
-    print_usage ();
+    error ("file_in_loadpath: FILE argument must not be empty");
 
   return retval;
 }
@@ -391,32 +391,30 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      std::string path = args(0).xstring_value ("file_in_path: PATH must be a string");
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  std::string path = args(0).xstring_value ("file_in_path: PATH must be a string");
 
-      string_vector names = args(1).xall_strings ("file_in_path: FILE argument must be a string");
+  string_vector names = args(1).xall_strings ("file_in_path: FILE argument must be a string");
 
-      if (names.numel () > 0)
+  if (names.numel () > 0)
+    {
+      if (nargin == 2)
+        retval = search_path_for_file (path, names);
+      else if (nargin == 3)
         {
-          if (nargin == 2)
-            retval = search_path_for_file (path, names);
-          else if (nargin == 3)
-            {
-              std::string opt = args(2).xstring_value ("file_in_path: optional third argument must be a string");
+          std::string opt = args(2).xstring_value ("file_in_path: optional third argument must be a string");
 
-              if (opt == "all")
-                retval = Cell (make_absolute
-                               (search_path_for_all_files (path, names)));
-              else
-                error ("file_in_path: \"all\" is only valid third argument");
-            }
+          if (opt == "all")
+            retval = Cell (make_absolute
+                           (search_path_for_all_files (path, names)));
+          else
+            error ("file_in_path: \"all\" is only valid third argument");
         }
-      else
-        error ("file_in_path: FILE argument must not be empty");
     }
   else
-    print_usage ();
+    error ("file_in_path: FILE argument must not be empty");
 
   return retval;
 }
@@ -750,20 +748,14 @@
 @seealso{undo_string_escapes}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      std::string str = args(0).xstring_value ("do_string_escapes: STRING argument must be of type string");
-
-      retval = do_string_escapes (str);
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  std::string str = args(0).xstring_value ("do_string_escapes: STRING argument must be of type string");
+
+  return octave_value (do_string_escapes (str));
 }
 
 /*
@@ -893,20 +885,14 @@
 @seealso{do_string_escapes}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      std::string str = args(0).xstring_value ("undo_string_escapes: S argument must be a string");
-
-      retval = undo_string_escapes (str);
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  std::string str = args(0).xstring_value ("undo_string_escapes: S argument must be a string");
+
+  return octave_value (undo_string_escapes (str));
 }
 
 /*
@@ -940,12 +926,12 @@
 {
   octave_value retval = false;
 
-  if (args.length () == 1)
-    retval = (args(0).is_string ()
-              && octave_env::absolute_pathname (args(0).string_value ()));
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  retval = (args(0).is_string ()
+            && octave_env::absolute_pathname (args(0).string_value ()));
+
   return retval;
 }
 
@@ -965,12 +951,12 @@
 {
   octave_value retval = false;
 
-  if (args.length () == 1)
-    retval = (args(0).is_string ()
-              && octave_env::rooted_relative_pathname (args(0).string_value ()));
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  retval = (args(0).is_string ()
+            && octave_env::rooted_relative_pathname (args(0).string_value ()));
+
   return retval;
 }
 
@@ -991,18 +977,12 @@
 @seealso{canonicalize_file_name, is_absolute_filename, is_rooted_relative_filename, isdir}\n\
 @end deftypefn")
 {
-  octave_value retval = std::string ();
-
-  if (args.length () == 1)
-    {
-      std::string nm = args(0).xstring_value ("make_absolute_filename: FILE argument must be a filename");
-
-      retval = octave_env::make_absolute (nm);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string nm = args(0).xstring_value ("make_absolute_filename: FILE argument must be a filename");
+
+  return octave_value (octave_env::make_absolute (nm));
 }
 
 /*
@@ -1033,19 +1013,17 @@
 
   int nargin = args.length ();
 
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   std::string dir;
 
-  if (nargin == 1 || nargin == 2)
-    {
-      dir = args(0).xstring_value ("dir_in_loadpath: DIR must be a directory name");
+  dir = args(0).xstring_value ("dir_in_loadpath: DIR must be a directory name");
 
-      if (nargin == 1)
-        retval = load_path::find_dir (dir);
-      else if (nargin == 2)
-        retval = Cell (load_path::find_matching_dirs (dir));
-    }
-  else
-    print_usage ();
+  if (nargin == 1)
+    retval = load_path::find_dir (dir);
+  else if (nargin == 2)
+    retval = Cell (load_path::find_matching_dirs (dir));
 
   return retval;
 }
@@ -1084,6 +1062,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       if (args(0).is_string ())
@@ -1099,10 +1080,8 @@
           retval = octave_errno::set (val);
         }
     }
-  else if (nargin == 0)
+  else
     retval = octave_errno::get ();
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1129,14 +1108,10 @@
 @seealso{errno}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = octave_errno::list ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_errno::list ());
 }
 
 /*
@@ -1426,13 +1401,16 @@
 @end deftypefn")
 {
   octave_value retval;
+
+  octave_idx_type n = 0;
+
   int nargin = args.length ();
-  octave_idx_type n = 0;
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
   if (nargin == 2)
     n = args(1).idx_type_value ();
-  else if (nargin != 1)
-    print_usage ();
 
   unwind_protect frame;
 
--- a/libinterp/corefcn/variables.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/corefcn/variables.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -331,10 +331,7 @@
   int nargin = args.length ();
 
   if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (! args(0).is_string ())
     {
@@ -595,24 +592,22 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  std::string name = args(0).xstring_value ("exist: NAME must be a string");
+
+  if (nargin == 2)
     {
-      std::string name = args(0).xstring_value ("exist: NAME must be a string");
-
-      if (nargin == 2)
-        {
-          std::string type = args(1).xstring_value ("exist: TYPE must be a string");
-
-          if (type == "class")
-            warning ("exist: \"class\" type argument is not implemented");
-
-          retval = symbol_exist (name, type);
-        }
-      else
-        retval = symbol_exist (name);
+      std::string type = args(1).xstring_value ("exist: TYPE must be a string");
+
+      if (type == "class")
+        warning ("exist: \"class\" type argument is not implemented");
+
+      retval = symbol_exist (name, type);
     }
   else
-    print_usage ();
+    retval = symbol_exist (name);
 
   return retval;
 }
@@ -951,6 +946,7 @@
     nchoices++;
 
   int nargin = args.length ();
+
   assert (var < nchoices);
 
   if (nargout > 0 || nargin == 0)
@@ -1846,18 +1842,14 @@
 {
   octave_value retval;
 
-  if (nargout < 2)
-    {
-      int argc = args.length () + 1;
-
-      string_vector argv = args.make_argv ("who");
-
-      retval = do_who (argc, argv, nargout == 1);
-    }
-  else
+  if (nargout > 1)
     print_usage ();
 
-  return retval;
+  int argc = args.length () + 1;
+
+  string_vector argv = args.make_argv ("who");
+
+  return do_who (argc, argv, nargout == 1);
 }
 
 DEFUN (whos, args, nargout,
@@ -1926,18 +1918,14 @@
 {
   octave_value retval;
 
-  if (nargout < 2)
-    {
-      int argc = args.length () + 1;
-
-      string_vector argv = args.make_argv ("whos");
-
-      retval = do_who (argc, argv, nargout == 1, true);
-    }
-  else
+  if (nargout > 1)
     print_usage ();
 
-  return retval;
+  int argc = args.length () + 1;
+
+  string_vector argv = args.make_argv ("whos");
+
+  return do_who (argc, argv, nargout == 1, true);
 }
 
 // Defining variables.
@@ -2028,17 +2016,15 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 0)
-    {
-      octave_function *fcn = octave_call_stack::caller ();
-
-      if (fcn)
-        fcn->lock ();
-      else
-        error ("mlock: invalid use outside a function");
-    }
+  if (args.length () != 0)
+    print_usage ();
+
+  octave_function *fcn = octave_call_stack::caller ();
+
+  if (fcn)
+    fcn->lock ();
   else
-    print_usage ();
+    error ("mlock: invalid use outside a function");
 
   return retval;
 }
@@ -2055,13 +2041,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
+  int nargin = args.length ();
+
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
     {
       std::string name = args(0).xstring_value ("munlock: FCN must be a string");
 
       munlock (name);
     }
-  else if (args.length () == 0)
+  else
     {
       octave_function *fcn = octave_call_stack::caller ();
 
@@ -2070,8 +2061,6 @@
       else
         error ("munlock: invalid use outside a function");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2089,13 +2078,18 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
+  int nargin = args.length ();
+
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
     {
       std::string name = args(0).xstring_value ("mislocked: FCN must be a string");
 
       retval = mislocked (name);
     }
-  else if (args.length () == 0)
+  else
     {
       octave_function *fcn = octave_call_stack::caller ();
 
@@ -2104,8 +2098,6 @@
       else
         error ("mislocked: invalid use outside a function");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2326,10 +2318,7 @@
   do \
     { \
       if (cond) \
-        { \
-          print_usage (); \
-          return retval; \
-        } \
+        print_usage (); \
     } \
   while (0)
 
@@ -2664,16 +2653,12 @@
 Return the value of the variable @var{name} directly from the symbol table.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 1)
     print_usage ();
 
   std::string name = args(0).xstring_value ("__varval__: first argument must be a variable name");
 
-  retval = symbol_table::varval (args(0).string_value ());
-
-  return retval;
+  return symbol_table::varval (args(0).string_value ());
 }
 
 static std::string Vmissing_component_hook;
--- a/libinterp/dldfcn/__glpk__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/dldfcn/__glpk__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -341,14 +341,14 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  // The list of values to return.  See the declaration in oct-obj.h
   octave_value_list retval;
 
 #if defined (HAVE_GLPK)
 
-  int nrhs = args.length ();
+  int nargin = args.length ();
 
-  if (nrhs != 9)
+  // FIXME: Should we even need checking for an internal function?
+  if (nargin != 9)
     print_usage ();
 
   //-- 1nd Input. A column array containing the objective function
--- a/libinterp/dldfcn/__magick_read__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/dldfcn/__magick_read__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1584,6 +1584,7 @@
 @end deftypefn")
 {
   octave_value retval;
+
 #ifndef HAVE_MAGICK
   gripe_disabled_feature ("imfinfo", "Image IO");
 #else
@@ -2254,6 +2255,7 @@
 @end deftypefn")
 {
   octave_value retval;
+
 #ifndef HAVE_MAGICK
   gripe_disabled_feature ("imformats", "Image IO");
 #else
--- a/libinterp/dldfcn/__osmesa_print__.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/dldfcn/__osmesa_print__.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -95,7 +95,7 @@
 
   int nargin = args.length ();
 
-  if (! (nargin == 1 || nargin == 3))
+  if (nargin != 1 && nargin != 3)
     print_usage ();
 
   if (nargin == 3)
--- a/libinterp/dldfcn/audiodevinfo.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/dldfcn/audiodevinfo.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -2350,7 +2350,7 @@
   audiorecorder *recorder = get_recorder (args(0));
 
   if (! recorder)
-      print_usage ();
+    print_usage ();
 
   if (args.length () == 1)
     recorder->record ();
--- a/libinterp/dldfcn/chol.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/dldfcn/chol.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -783,9 +783,9 @@
 @seealso{chol, cholupdate, choldelete, cholshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
+  octave_value_list retval;
 
-  octave_value_list retval;
+  octave_idx_type nargin = args.length ();
 
   if (nargin != 3)
     print_usage ();
@@ -1030,9 +1030,9 @@
 @seealso{chol, cholupdate, cholinsert, cholshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
+  octave_value_list retval;
 
-  octave_value_list retval;
+  octave_idx_type nargin = args.length ();
 
   if (nargin != 2)
     print_usage ();
@@ -1164,9 +1164,9 @@
 @seealso{chol, cholupdate, cholinsert, choldelete}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
+  octave_value_list retval;
 
-  octave_value_list retval;
+  octave_idx_type nargin = args.length ();
 
   if (nargin != 3)
     print_usage ();
--- a/libinterp/dldfcn/dmperm.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/dldfcn/dmperm.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -153,8 +153,8 @@
 @seealso{colamd, ccolamd}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
   int nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin != 1)
     print_usage ();
@@ -199,8 +199,8 @@
 @seealso{dmperm}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
   int nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin != 1)
     print_usage ();
--- a/libinterp/dldfcn/qr.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/dldfcn/qr.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -756,8 +756,9 @@
 @seealso{qr, qrinsert, qrdelete, qrshift}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
+
   octave_idx_type nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin != 4)
     print_usage ();
@@ -941,8 +942,9 @@
 @seealso{qr, qrupdate, qrdelete, qrshift}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
+
   octave_idx_type nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin < 4 || nargin > 5)
     print_usage ();
@@ -1157,8 +1159,8 @@
 @seealso{qr, qrupdate, qrinsert, qrshift}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
   octave_idx_type nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin < 3 || nargin > 4)
     print_usage ();
@@ -1406,8 +1408,8 @@
 @seealso{qr, qrupdate, qrinsert, qrdelete}\n\
 @end deftypefn")
 {
+  octave_value_list retval;
   octave_idx_type nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin != 4)
     print_usage ();
--- a/libinterp/octave-value/ov-bool-mat.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-bool-mat.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -572,25 +572,24 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  if (arg.is_bool_type ())
+    retval = arg;
+  else if (arg.is_numeric_type ())
     {
-      octave_value arg = args(0);
-      if (arg.is_bool_type ())
-        retval = arg;
-      else if (arg.is_numeric_type ())
-        {
-          if (arg.is_sparse_type ())
-            retval = arg.sparse_bool_matrix_value ();
-          else if (arg.is_scalar_type ())
-            retval = arg.bool_value ();
-          else
-            retval = arg.bool_array_value ();
-        }
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_bool_matrix_value ();
+      else if (arg.is_scalar_type ())
+        retval = arg.bool_value ();
       else
-        gripe_wrong_type_arg ("logical", arg);
+        retval = arg.bool_array_value ();
     }
   else
-    print_usage ();
+    gripe_wrong_type_arg ("logical", arg);
 
   return retval;
 }
--- a/libinterp/octave-value/ov-cell.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-cell.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1237,14 +1237,10 @@
 @seealso{ismatrix, isstruct, iscellstr, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_cell ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_cell ());
 }
 
 DEFUN (cell, args, ,
@@ -1306,14 +1302,10 @@
 @seealso{ischar}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_cellstr ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_cellstr ());
 }
 
 // Note that since Fcellstr calls Fiscellstr, we need to have
@@ -1336,23 +1328,21 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      octave_value_list tmp = Fiscellstr (args, 1);
+  if (args.length () != 1)
+    print_usage ();
+
+  octave_value_list tmp = Fiscellstr (args, 1);
 
-      if (tmp(0).is_true ())
-        retval = args(0);
-      else
-        {
-          string_vector s = args(0).xall_strings ("cellstr: argument STRING must be a 2-D character array");
+  if (tmp(0).is_true ())
+    retval = args(0);
+  else
+    {
+      string_vector s = args(0).xall_strings ("cellstr: argument STRING must be a 2-D character array");
 
-          retval = (s.is_empty ()
-                    ? Cell (octave_value (std::string ()))
-                    : Cell (s, true));
-        }
+      retval = (s.is_empty ()
+                ? Cell (octave_value (std::string ()))
+                : Cell (s, true));
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1392,49 +1382,43 @@
 @seealso{cell2struct, fieldnames}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      const octave_map m = args(0).xmap_value ("struct2cell: argument S must be a structure");
-
-      const dim_vector m_dv = m.dims ();
-
-      octave_idx_type num_fields = m.nfields ();
-
-      // The resulting dim_vector should have dimensions:
-      // [numel(fields) size(struct)]
-      // except if the struct is a column vector.
-
-      dim_vector result_dv;
-      if (m_dv(m_dv.length () - 1) == 1)
-        result_dv.resize (m_dv.length ());
-      else
-        result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
-
-      result_dv(0) = num_fields;
-
-      for (int i = 1; i < result_dv.length (); i++)
-        result_dv(i) = m_dv(i-1);
-
-      NoAlias<Cell> c (result_dv);
-
-      octave_idx_type n_elts = m.numel ();
-
-      // Fill c in one sweep. Note that thanks to octave_map structure,
-      // we don't need a key lookup at all.
-      for (octave_idx_type j = 0; j < n_elts; j++)
-        for (octave_idx_type i = 0; i < num_fields; i++)
-          c(i,j) = m.contents(i)(j);
-
-      retval = c;
-    }
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  const octave_map m = args(0).xmap_value ("struct2cell: argument S must be a structure");
+
+  const dim_vector m_dv = m.dims ();
+
+  octave_idx_type num_fields = m.nfields ();
+
+  // The resulting dim_vector should have dimensions:
+  // [numel(fields) size(struct)]
+  // except if the struct is a column vector.
+
+  dim_vector result_dv;
+  if (m_dv(m_dv.length () - 1) == 1)
+    result_dv.resize (m_dv.length ());
+  else
+    result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
+
+  result_dv(0) = num_fields;
+
+  for (int i = 1; i < result_dv.length (); i++)
+    result_dv(i) = m_dv(i-1);
+
+  NoAlias<Cell> c (result_dv);
+
+  octave_idx_type n_elts = m.numel ();
+
+  // Fill c in one sweep. Note that thanks to octave_map structure,
+  // we don't need a key lookup at all.
+  for (octave_idx_type j = 0; j < n_elts; j++)
+    for (octave_idx_type i = 0; i < num_fields; i++)
+      c(i,j) = m.contents(i)(j);
+
+  return octave_value (c);
 }
 
 /*
--- a/libinterp/octave-value/ov-class.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-class.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1776,7 +1776,8 @@
 
   if (nargin == 0)
     print_usage ();
-  else if (nargin == 1)
+
+  if (nargin == 1)
     // Called for class of object
     retval = args(0).class_name ();
   else
@@ -1866,10 +1867,7 @@
   octave_value retval;
 
   if (args.length () != 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value obj = args(0);  // not const because of find_parent_class ()
   std::string obj_cls = obj.class_name ();
@@ -1957,15 +1955,13 @@
 {
   octave_value retval = Cell ();
 
-  if (args.length () == 1)
-    {
-      octave_value arg = args(0);
+  if (args.length () != 1)
+    print_usage ();
 
-      if (arg.is_object ())
-        retval = Cell (arg.parent_class_names ());
-    }
-  else
-    print_usage ();
+  octave_value arg = args(0);
+
+  if (arg.is_object ())
+    retval = Cell (arg.parent_class_names ());
 
   return retval;
 }
@@ -1977,14 +1973,10 @@
 @seealso{class, typeinfo, isa, ismethod, isprop}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_object ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_object ());
 }
 
 DEFUN (ismethod, args, ,
@@ -1998,28 +1990,26 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      octave_value arg = args(0);
+  if (args.length () != 2)
+    print_usage ();
 
-      std::string class_name;
+  octave_value arg = args(0);
+
+  std::string class_name;
 
-      if (arg.is_object ())
-        class_name = arg.class_name ();
-      else if (arg.is_string ())
-        class_name = arg.string_value ();
-      else
-        error ("ismethod: first argument must be object or class name");
+  if (arg.is_object ())
+    class_name = arg.class_name ();
+  else if (arg.is_string ())
+    class_name = arg.string_value ();
+  else
+    error ("ismethod: first argument must be object or class name");
 
-      std::string method = args(1).string_value ();
+  std::string method = args(1).string_value ();
 
-      if (load_path::find_method (class_name, method) != std::string ())
-        retval = true;
-      else
-        retval = false;
-    }
+  if (load_path::find_method (class_name, method) != std::string ())
+    retval = true;
   else
-    print_usage ();
+    retval = false;
 
   return retval;
 }
--- a/libinterp/octave-value/ov-classdef.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-classdef.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -3808,16 +3808,12 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      std::string cname = args(0).xstring_value ("PACKAGE_NAME must be a string");
-
-      retval = to_ov (lookup_package (cname));
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string cname = args(0).xstring_value ("PACKAGE_NAME must be a string");
+
+  return to_ov (lookup_package (cname));
 }
 
 DEFUN (__superclass_reference__, args, /* nargout */,
@@ -3843,16 +3839,12 @@
             << std::endl;
 #endif
 
-  if (args.length () == 1)
-    {
-      std::string cls = args(0).xstring_value ("CLASS_NAME must be a string");
-
-      retval = to_ov (lookup_class (cls));
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string cls = args(0).xstring_value ("CLASS_NAME must be a string");
+
+  return to_ov (lookup_class (cls));
 }
 
 DEFUN (metaclass, args, /* nargout */,
@@ -3863,16 +3855,12 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      cdef_object obj = to_cdef (args(0));
-
-      retval = to_ov (obj.get_class ());
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  cdef_object obj = to_cdef (args(0));
+
+  return to_ov (obj.get_class ());
 }
 
 /*
--- a/libinterp/octave-value/ov-fcn-handle.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1716,86 +1716,84 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      octave_fcn_handle *fh = args(0).fcn_handle_value ("functions: FCN_HANDLE argument must be a function handle object");
-
-      octave_function *fcn = fh ? fh->function_value () : 0;
-
-      if (fcn)
-        {
-          octave_scalar_map m;
-
-          std::string fh_nm = fh->fcn_name ();
+  if (args.length () != 1)
+    print_usage ();
 
-          if (fh_nm == octave_fcn_handle::anonymous)
-            {
-              std::ostringstream buf;
-              fh->print_raw (buf);
-              m.setfield ("function", buf.str ());
+  octave_fcn_handle *fh = args(0).fcn_handle_value ("functions: FCN_HANDLE argument must be a function handle object");
 
-              m.setfield ("type", "anonymous");
-            }
-          else
-            {
-              m.setfield ("function", fh_nm);
+  octave_function *fcn = fh ? fh->function_value () : 0;
 
-              if (fcn->is_subfunction ())
-                {
-                  m.setfield ("type", "subfunction");
-                  Cell parentage (dim_vector (1, 2));
-                  parentage.elem (0) = fh_nm;
-                  parentage.elem (1) = fcn->parent_fcn_name ();
-                  m.setfield ("parentage", octave_value (parentage));
-                }
-              else if (fcn->is_private_function ())
-                m.setfield ("type", "private");
-              else if (fh->is_overloaded ())
-                m.setfield ("type", "overloaded");
-              else
-                m.setfield ("type", "simple");
-            }
+  if (fcn)
+    {
+      octave_scalar_map m;
 
-          std::string nm = fcn->fcn_file_name ();
-
-          if (fh_nm == octave_fcn_handle::anonymous)
-            {
-              m.setfield ("file", nm);
-
-              octave_user_function *fu = fh->user_function_value ();
+      std::string fh_nm = fh->fcn_name ();
 
-              std::list<symbol_table::symbol_record> vars
-                = symbol_table::all_variables (fu->scope (), 0);
-
-              size_t varlen = vars.size ();
+      if (fh_nm == octave_fcn_handle::anonymous)
+        {
+          std::ostringstream buf;
+          fh->print_raw (buf);
+          m.setfield ("function", buf.str ());
 
-              if (varlen > 0)
-                {
-                  octave_scalar_map ws;
-                  for (std::list<symbol_table::symbol_record>::const_iterator
-                         p = vars.begin (); p != vars.end (); p++)
-                    {
-                      ws.assign (p->name (), p->varval (0));
-                    }
-
-                  m.setfield ("workspace", ws);
-                }
-            }
-          else if (fcn->is_user_function () || fcn->is_user_script ())
-            {
-              octave_function *fu = fh->function_value ();
-              m.setfield ("file", fu->fcn_file_name ());
-            }
-          else
-            m.setfield ("file", "");
-
-          retval = m;
+          m.setfield ("type", "anonymous");
         }
       else
-        error ("functions: FCN_HANDLE is not a valid function handle object");
+        {
+          m.setfield ("function", fh_nm);
+
+          if (fcn->is_subfunction ())
+            {
+              m.setfield ("type", "subfunction");
+              Cell parentage (dim_vector (1, 2));
+              parentage.elem (0) = fh_nm;
+              parentage.elem (1) = fcn->parent_fcn_name ();
+              m.setfield ("parentage", octave_value (parentage));
+            }
+          else if (fcn->is_private_function ())
+            m.setfield ("type", "private");
+          else if (fh->is_overloaded ())
+            m.setfield ("type", "overloaded");
+          else
+            m.setfield ("type", "simple");
+        }
+
+      std::string nm = fcn->fcn_file_name ();
+
+      if (fh_nm == octave_fcn_handle::anonymous)
+        {
+          m.setfield ("file", nm);
+
+          octave_user_function *fu = fh->user_function_value ();
+
+          std::list<symbol_table::symbol_record> vars
+            = symbol_table::all_variables (fu->scope (), 0);
+
+          size_t varlen = vars.size ();
+
+          if (varlen > 0)
+            {
+              octave_scalar_map ws;
+              for (std::list<symbol_table::symbol_record>::const_iterator
+                     p = vars.begin (); p != vars.end (); p++)
+                {
+                  ws.assign (p->name (), p->varval (0));
+                }
+
+              m.setfield ("workspace", ws);
+            }
+        }
+      else if (fcn->is_user_function () || fcn->is_user_script ())
+        {
+          octave_function *fu = fh->function_value ();
+          m.setfield ("file", fu->fcn_file_name ());
+        }
+      else
+        m.setfield ("file", "");
+
+      retval = m;
     }
   else
-    print_usage ();
+    error ("functions: FCN_HANDLE is not a valid function handle object");
 
   return retval;
 }
@@ -1810,30 +1808,28 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      octave_fcn_handle *fh = args(0).fcn_handle_value ("func2str: FCN_HANDLE argument must be a function handle object");
+  if (args.length () != 1)
+    print_usage ();
 
-      if (fh)
-        {
-          std::string fh_nm = fh->fcn_name ();
+  octave_fcn_handle *fh = args(0).fcn_handle_value ("func2str: FCN_HANDLE argument must be a function handle object");
 
-          if (fh_nm == octave_fcn_handle::anonymous)
-            {
-              std::ostringstream buf;
+  if (fh)
+    {
+      std::string fh_nm = fh->fcn_name ();
 
-              fh->print_raw (buf);
+      if (fh_nm == octave_fcn_handle::anonymous)
+        {
+          std::ostringstream buf;
 
-              retval = buf.str ();
-            }
-          else
-            retval = fh_nm;
+          fh->print_raw (buf);
+
+          retval = buf.str ();
         }
       else
-        error ("func2str: FCN_HANDLE must be a valid function handle");
+        retval = fh_nm;
     }
   else
-    print_usage ();
+    error ("func2str: FCN_HANDLE must be a valid function handle");
 
   return retval;
 }
@@ -1852,24 +1848,22 @@
   octave_value retval;
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string nm = args(0).xstring_value ("str2func: FCN_NAME must be a string");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  std::string nm = args(0).xstring_value ("str2func: FCN_NAME must be a string");
 
-      if (nm[0] == '@')
-        {
-          int parse_status;
-          octave_value anon_fcn_handle =
-            eval_string (nm, true, parse_status);
+  if (nm[0] == '@')
+    {
+      int parse_status;
+      octave_value anon_fcn_handle =
+        eval_string (nm, true, parse_status);
 
-          if (parse_status == 0)
-            retval = anon_fcn_handle;
-        }
-      else
-        retval = make_fcn_handle (nm, nargin != 2);
+      if (parse_status == 0)
+        retval = anon_fcn_handle;
     }
   else
-    print_usage ();
+    retval = make_fcn_handle (nm, nargin != 2);
 
   return retval;
 }
@@ -1913,16 +1907,12 @@
 @seealso{isa, typeinfo, class, functions}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1)
-    retval = args(0).is_function_handle ();
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_function_handle ());
 }
 
 /*
--- a/libinterp/octave-value/ov-fcn-inline.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-fcn-inline.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -679,149 +679,145 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      std::string fun = args(0).xstring_value ("inline: STR argument must be a string");
+  if (nargin == 0)
+    print_usage ();
+
+  std::string fun = args(0).xstring_value ("inline: STR argument must be a string");
+
+  string_vector fargs;
 
-      string_vector fargs;
+  if (nargin == 1)
+    {
+      bool is_arg = false;
+      bool in_string = false;
+      std::string tmp_arg;
+      size_t i = 0;
+      size_t fun_length = fun.length ();
 
-      if (nargin == 1)
+      while (i < fun_length)
         {
-          bool is_arg = false;
-          bool in_string = false;
-          std::string tmp_arg;
-          size_t i = 0;
-          size_t fun_length = fun.length ();
+          bool terminate_arg = false;
+          char c = fun[i++];
 
-          while (i < fun_length)
+          if (in_string)
             {
-              bool terminate_arg = false;
-              char c = fun[i++];
+              if (c == '\'' || c == '\"')
+                in_string = false;
+            }
+          else if (c == '\'' || c == '\"')
+            {
+              in_string = true;
+              if (is_arg)
+                terminate_arg = true;
+            }
+          else if (! isalpha (c) && c != '_')
+            if (! is_arg)
+              continue;
+            else if (isdigit (c))
+              tmp_arg.append (1, c);
+            else
+              {
+                // Before we do anything remove trailing whitespaces.
+                while (i < fun_length && isspace (c))
+                  c = fun[i++];
 
-              if (in_string)
-                {
-                  if (c == '\'' || c == '\"')
-                    in_string = false;
-                }
-              else if (c == '\'' || c == '\"')
-                {
-                  in_string = true;
-                  if (is_arg)
-                    terminate_arg = true;
-                }
-              else if (! isalpha (c) && c != '_')
-                if (! is_arg)
-                  continue;
-                else if (isdigit (c))
-                  tmp_arg.append (1, c);
+                // Do we have a variable or a function?
+                if (c != '(')
+                  terminate_arg = true;
                 else
                   {
-                    // Before we do anything remove trailing whitespaces.
-                    while (i < fun_length && isspace (c))
-                      c = fun[i++];
-
-                    // Do we have a variable or a function?
-                    if (c != '(')
-                      terminate_arg = true;
-                    else
-                      {
-                        tmp_arg = std::string ();
-                        is_arg = false;
-                      }
+                    tmp_arg = std::string ();
+                    is_arg = false;
                   }
-              else if (! is_arg)
-                {
-                  if (c == 'e' || c == 'E')
-                    {
-                      // possible number in exponent form, not arg
-                      if (isdigit (fun[i])
-                          || fun[i] == '-' || fun[i] == '+')
-                        continue;
-                    }
-                  is_arg = true;
-                  tmp_arg.append (1, c);
-                }
-              else
-                {
-                  tmp_arg.append (1, c);
-                }
-
-              if (terminate_arg || (i == fun_length && is_arg))
+              }
+          else if (! is_arg)
+            {
+              if (c == 'e' || c == 'E')
                 {
-                  bool have_arg = false;
-
-                  for (int j = 0; j < fargs.numel (); j++)
-                    if (tmp_arg == fargs (j))
-                      {
-                        have_arg = true;
-                        break;
-                      }
-
-                  if (! have_arg && tmp_arg != "i" && tmp_arg != "j"
-                      && tmp_arg != "NaN" && tmp_arg != "nan"
-                      && tmp_arg != "Inf" && tmp_arg != "inf"
-                      && tmp_arg != "NA" && tmp_arg != "pi"
-                      && tmp_arg != "e" && tmp_arg != "eps")
-                    fargs.append (tmp_arg);
-
-                  tmp_arg = std::string ();
-                  is_arg = false;
+                  // possible number in exponent form, not arg
+                  if (isdigit (fun[i])
+                      || fun[i] == '-' || fun[i] == '+')
+                    continue;
                 }
-            }
-
-          // Sort the arguments into ascii order.
-          fargs.sort ();
-
-          if (fargs.numel () == 0)
-            fargs.append (std::string ("x"));
-
-        }
-      else if (nargin == 2 && args(1).is_numeric_type ())
-        {
-          if (! args(1).is_scalar_type ())
-            {
-              error ("inline: N must be an integer");
-              return retval;
-            }
-
-          int n = args(1).int_value ("inline: N must be an integer");
-
-          if (n >= 0)
-            {
-              fargs.resize (n+1);
-
-              fargs(0) = "x";
-
-              for (int i = 1; i < n+1; i++)
-                {
-                  std::ostringstream buf;
-                  buf << "P" << i;
-                  fargs(i) = buf.str ();
-                }
+              is_arg = true;
+              tmp_arg.append (1, c);
             }
           else
             {
-              error ("inline: N must be a positive integer or zero");
-              return retval;
+              tmp_arg.append (1, c);
+            }
+
+          if (terminate_arg || (i == fun_length && is_arg))
+            {
+              bool have_arg = false;
+
+              for (int j = 0; j < fargs.numel (); j++)
+                if (tmp_arg == fargs (j))
+                  {
+                    have_arg = true;
+                    break;
+                  }
+
+              if (! have_arg && tmp_arg != "i" && tmp_arg != "j"
+                  && tmp_arg != "NaN" && tmp_arg != "nan"
+                  && tmp_arg != "Inf" && tmp_arg != "inf"
+                  && tmp_arg != "NA" && tmp_arg != "pi"
+                  && tmp_arg != "e" && tmp_arg != "eps")
+                fargs.append (tmp_arg);
+
+              tmp_arg = std::string ();
+              is_arg = false;
+            }
+        }
+
+      // Sort the arguments into ascii order.
+      fargs.sort ();
+
+      if (fargs.numel () == 0)
+        fargs.append (std::string ("x"));
+
+    }
+  else if (nargin == 2 && args(1).is_numeric_type ())
+    {
+      if (! args(1).is_scalar_type ())
+        {
+          error ("inline: N must be an integer");
+          return retval;
+        }
+
+      int n = args(1).int_value ("inline: N must be an integer");
+
+      if (n >= 0)
+        {
+          fargs.resize (n+1);
+
+          fargs(0) = "x";
+
+          for (int i = 1; i < n+1; i++)
+            {
+              std::ostringstream buf;
+              buf << "P" << i;
+              fargs(i) = buf.str ();
             }
         }
       else
         {
-          fargs.resize (nargin - 1);
-
-          for (int i = 1; i < nargin; i++)
-            {
-              std::string s = args(i).xstring_value ("inline: additional arguments must be strings");
-              fargs(i-1) = s;
-            }
+          error ("inline: N must be a positive integer or zero");
+          return retval;
         }
-
-      retval = octave_value (new octave_fcn_inline (fun, fargs));
     }
   else
-    print_usage ();
+    {
+      fargs.resize (nargin - 1);
 
-  return retval;
+      for (int i = 1; i < nargin; i++)
+        {
+          std::string s = args(i).xstring_value ("inline: additional arguments must be strings");
+          fargs(i-1) = s;
+        }
+    }
+
+  return octave_value (new octave_fcn_inline (fun, fargs));
 }
 
 /*
@@ -855,17 +851,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      octave_fcn_inline* fn = args(0).fcn_inline_value (true);
+  if (nargin != 1)
+    print_usage ();
+
+  octave_fcn_inline* fn = args(0).fcn_inline_value (true);
 
-      if (fn)
-        retval = octave_value (fn->fcn_text ());
-      else
-        error ("formula: FUN must be an inline function");
-    }
+  if (fn)
+    retval = octave_value (fn->fcn_text ());
   else
-    print_usage ();
+    error ("formula: FUN must be an inline function");
 
   return retval;
 }
@@ -892,26 +886,24 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      octave_fcn_inline *fn = args(0).fcn_inline_value (true);
+  if (nargin != 1)
+    print_usage ();
 
-      if (fn)
-        {
-          string_vector t1 = fn->fcn_arg_names ();
+  octave_fcn_inline *fn = args(0).fcn_inline_value (true);
 
-          Cell t2 (dim_vector (t1.numel (), 1));
-
-          for (int i = 0; i < t1.numel (); i++)
-            t2(i) = t1(i);
+  if (fn)
+    {
+      string_vector t1 = fn->fcn_arg_names ();
 
-          retval = t2;
-        }
-      else
-        error ("argnames: FUN must be an inline function");
+      Cell t2 (dim_vector (t1.numel (), 1));
+
+      for (int i = 0; i < t1.numel (); i++)
+        t2(i) = t1(i);
+
+      retval = t2;
     }
   else
-    print_usage ();
+    error ("argnames: FUN must be an inline function");
 
   return retval;
 }
@@ -951,57 +943,55 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      std::string old_func;
-      octave_fcn_inline* old = 0;
-      bool func_is_string = true;
+  if (nargin != 1)
+    print_usage ();
 
-      if (args(0).is_string ())
-        old_func = args(0).string_value ();
-      else
-        {
-          old = args(0).fcn_inline_value (true);
-          func_is_string = false;
+  std::string old_func;
+  octave_fcn_inline* old = 0;
+  bool func_is_string = true;
 
-          if (old)
-            old_func = old->fcn_text ();
-          else
-            error ("vectorize: FUN must be a string or inline function");
-        }
+  if (args(0).is_string ())
+    old_func = args(0).string_value ();
+  else
+    {
+      old = args(0).fcn_inline_value (true);
+      func_is_string = false;
 
-      std::string new_func;
-      size_t i = 0;
+      if (old)
+        old_func = old->fcn_text ();
+      else
+        error ("vectorize: FUN must be a string or inline function");
+    }
 
-      while (i < old_func.length ())
-        {
-          std::string t1 = old_func.substr (i, 1);
+  std::string new_func;
+  size_t i = 0;
 
-          if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^")
-            {
-              if (i && old_func.substr (i-1, 1) != ".")
-                new_func.append (".");
+  while (i < old_func.length ())
+    {
+      std::string t1 = old_func.substr (i, 1);
 
-              // Special case for ** operator.
-              if (t1 == "*" && i < (old_func.length () - 1)
-                  && old_func.substr (i+1, 1) == "*")
-                {
-                  new_func.append ("*");
-                  i++;
-                }
+      if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^")
+        {
+          if (i && old_func.substr (i-1, 1) != ".")
+            new_func.append (".");
+
+          // Special case for ** operator.
+          if (t1 == "*" && i < (old_func.length () - 1)
+              && old_func.substr (i+1, 1) == "*")
+            {
+              new_func.append ("*");
+              i++;
             }
-          new_func.append (t1);
-          i++;
         }
+      new_func.append (t1);
+      i++;
+    }
 
-      if (func_is_string)
-        retval = octave_value (new_func);
-      else
-        retval = octave_value (new octave_fcn_inline
-                               (new_func, old->fcn_arg_names ()));
-    }
+  if (func_is_string)
+    retval = octave_value (new_func);
   else
-    print_usage ();
+    retval = octave_value (new octave_fcn_inline
+                           (new_func, old->fcn_arg_names ()));
 
   return retval;
 }
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -864,38 +864,36 @@
   // inside their own scopes, and we don't declare retval here to
   // avoid a shadowed declaration warning.
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  if (args(0).is_diag_matrix ())
     {
-      if (args(0).is_diag_matrix ())
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_diag_matrix,
-                                      octave_float_complex);
-            }
-          else
-            {
-              OCTAVE_TYPE_CONV_BODY3 (single, octave_float_diag_matrix,
-                                      octave_float_scalar);
-            }
-        }
-      else if (args(0).is_sparse_type ())
-        {
-          error ("single: sparse type does not support single precision");
-        }
-      else if (args(0).is_complex_type ())
-        {
-          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_matrix,
+          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_diag_matrix,
                                   octave_float_complex);
         }
       else
         {
-          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_matrix,
+          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_diag_matrix,
                                   octave_float_scalar);
         }
     }
+  else if (args(0).is_sparse_type ())
+    {
+      error ("single: sparse type does not support single precision");
+    }
+  else if (args(0).is_complex_type ())
+    {
+      OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_matrix,
+                              octave_float_complex);
+    }
   else
-    print_usage ();
+    {
+      OCTAVE_TYPE_CONV_BODY3 (single, octave_float_matrix,
+                              octave_float_scalar);
+    }
 
   return octave_value ();
 }
--- a/libinterp/octave-value/ov-java.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-java.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -2131,35 +2131,36 @@
 @seealso{javaMethod, javaArray}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
   JNIEnv *current_env = octave_java::thread_jni_env ();
 
-  if (args.length () > 0)
+  if (args.length () == 0)
+    print_usage ();
+
+  if (args(0).is_string ())
     {
-      if (args(0).is_string ())
-        {
-          std::string classname = args(0).string_value ();
-
-          octave_value_list tmp;
-          for (int i=1; i<args.length (); i++)
-            tmp(i-1) = args(i);
-          retval = octave_java::do_javaObject (current_env, classname, tmp);
-        }
-      else
-        error ("javaObject: CLASSNAME must be a string");
+      std::string classname = args(0).string_value ();
+
+      octave_value_list tmp;
+      for (int i=1; i<args.length (); i++)
+        tmp(i-1) = args(i);
+      retval = octave_java::do_javaObject (current_env, classname, tmp);
     }
   else
-    print_usage ();
+    error ("javaObject: CLASSNAME must be a string");
+
+#else
+
+  error ("javaObject: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("javaObject: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 /*
@@ -2196,47 +2197,48 @@
 @seealso{methods, javaObject}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
   JNIEnv *current_env = octave_java::thread_jni_env ();
 
-  if (args.length () > 1)
+  if (args.length () < 2)
+    print_usage ();
+
+  if (args(0).is_string ())
     {
-      if (args(0).is_string ())
+      std::string methodname = args(0).string_value ();
+
+      octave_value_list tmp;
+      for (int i=2; i<args.length (); i++)
+        tmp(i-2) = args(i);
+
+      if (args(1).is_java ())
         {
-          std::string methodname = args(0).string_value ();
-
-          octave_value_list tmp;
-          for (int i=2; i<args.length (); i++)
-            tmp(i-2) = args(i);
-
-          if (args(1).is_java ())
-            {
-              octave_java *jobj = TO_JAVA (args(1));
-              retval = jobj->do_javaMethod (current_env, methodname, tmp);
-            }
-          else if (args(1).is_string ())
-            {
-              std::string cls = args(1).string_value ();
-              retval = octave_java::do_javaMethod (current_env, cls, methodname, tmp);
-            }
-          else
-            error ("javaMethod: OBJ must be a Java object or a string");
+          octave_java *jobj = TO_JAVA (args(1));
+          retval = jobj->do_javaMethod (current_env, methodname, tmp);
+        }
+      else if (args(1).is_string ())
+        {
+          std::string cls = args(1).string_value ();
+          retval = octave_java::do_javaMethod (current_env, cls, methodname, tmp);
         }
       else
-        error ("javaMethod: METHODNAME must be a string");
+        error ("javaMethod: OBJ must be a Java object or a string");
     }
   else
-    print_usage ();
+    error ("javaMethod: METHODNAME must be a string");
+
+#else
+
+  error ("javaMethod: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("javaMethod: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 /*
@@ -2268,43 +2270,44 @@
 @seealso{__java_set__, javaMethod, javaObject}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
   JNIEnv *current_env = octave_java::thread_jni_env ();
 
-  if (args.length () == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  if (args(1).is_string ())
     {
-      if (args(1).is_string ())
+      std::string name = args(1).string_value ();
+
+      if (args(0).is_java ())
         {
-          std::string name = args(1).string_value ();
-
-          if (args(0).is_java ())
-            {
-              octave_java *jobj = TO_JAVA (args(0));
-              retval = jobj->do_java_get (current_env, name);
-            }
-          else if (args(0).is_string ())
-            {
-              std::string cls = args(0).string_value ();
-              retval = octave_java::do_java_get (current_env, cls, name);
-            }
-          else
-            error ("__java_get__: OBJ must be a Java object or a string");
+          octave_java *jobj = TO_JAVA (args(0));
+          retval = jobj->do_java_get (current_env, name);
+        }
+      else if (args(0).is_string ())
+        {
+          std::string cls = args(0).string_value ();
+          retval = octave_java::do_java_get (current_env, cls, name);
         }
       else
-        error ("__java_get__: NAME must be a string");
+        error ("__java_get__: OBJ must be a Java object or a string");
     }
   else
-    print_usage ();
+    error ("__java_get__: NAME must be a string");
+
+#else
+
+  error ("__java_get__: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("__java_get__: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 DEFUN (__java_set__, args, ,
@@ -2330,43 +2333,44 @@
 @seealso{__java_get__, javaMethod, javaObject}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
   JNIEnv *current_env = octave_java::thread_jni_env ();
 
-  if (args.length () == 3)
+  if (args.length () != 3)
+    print_usage ();
+
+  if (args(1).is_string ())
     {
-      if (args(1).is_string ())
+      std::string name = args(1).string_value ();
+
+      if (args(0).is_java ())
         {
-          std::string name = args(1).string_value ();
-
-          if (args(0).is_java ())
-            {
-              octave_java *jobj = TO_JAVA (args(0));
-              retval = jobj->do_java_set (current_env, name, args(2));
-            }
-          else if (args(0).is_string ())
-            {
-              std::string cls = args(0).string_value ();
-              retval = octave_java::do_java_set (current_env, cls, name, args(2));
-            }
-          else
-            error ("__java_set__: OBJ must be a Java object or a string");
+          octave_java *jobj = TO_JAVA (args(0));
+          retval = jobj->do_java_set (current_env, name, args(2));
+        }
+      else if (args(0).is_string ())
+        {
+          std::string cls = args(0).string_value ();
+          retval = octave_java::do_java_set (current_env, cls, name, args(2));
         }
       else
-        error ("__java_set__: NAME must be a string");
+        error ("__java_set__: OBJ must be a Java object or a string");
     }
   else
-    print_usage ();
+    error ("__java_set__: NAME must be a string");
+
+#else
+
+  error ("__java_set__: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("__java_set__: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 DEFUN (java2mat, args, ,
@@ -2375,31 +2379,32 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
+  octave_value_list retval;
+
 #ifdef HAVE_JAVA
-  octave_value_list retval;
 
   initialize_java ();
 
   JNIEnv *current_env = octave_java::thread_jni_env ();
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  if (args(0).is_java ())
     {
-      if (args(0).is_java ())
-        {
-          octave_java *jobj = TO_JAVA (args(0));
-          retval(0) = box_more (current_env, jobj->to_java (), 0);
-        }
-      else
-        retval(0) = args(0);
+      octave_java *jobj = TO_JAVA (args(0));
+      retval(0) = box_more (current_env, jobj->to_java (), 0);
     }
   else
-    print_usage ();
+    retval(0) = args(0);
+
+#else
+
+  error ("java2mat: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("java2mat: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 DEFUN (java_matrix_autoconversion, args, nargout,
@@ -2418,12 +2423,18 @@
 @seealso{java_unsigned_autoconversion, debug_java}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  return SET_INTERNAL_VARIABLE (java_matrix_autoconversion);
+
+  retval = SET_INTERNAL_VARIABLE (java_matrix_autoconversion);
 #else
+
   error ("java_matrix_autoconversion: Octave was not compiled with Java interface");
-  return octave_value ();
+
 #endif
+
+  return retval;
 }
 
 DEFUN (java_unsigned_autoconversion, args, nargout,
@@ -2483,14 +2494,10 @@
 @seealso{class, typeinfo, isa, javaObject}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 1)
     print_usage ();
-  else
-    retval = args(0).is_java ();
-
-  return retval;
+
+  return octave_value (args(0).is_java ());
 }
 
 /*
--- a/libinterp/octave-value/ov-null-mat.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-null-mat.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -114,16 +114,12 @@
 @seealso{isempty, isindex}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_defined ())
-    retval = args(0).is_null_value ();
-  else
+  if (nargin != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_null_value ());
 }
 
 /*
--- a/libinterp/octave-value/ov-oncleanup.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-oncleanup.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -186,14 +186,10 @@
 For similar functionality @xref{The unwind_protect Statement}.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = octave_value (new octave_oncleanup (args(0)));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (new octave_oncleanup (args(0)));
 }
 
 /*
--- a/libinterp/octave-value/ov-re-mat.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-re-mat.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -987,50 +987,48 @@
   // inside their own scopes, and we don't declare retval here to
   // avoid a shadowed declaration warning.
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  if (args(0).is_perm_matrix ())
     {
-      if (args(0).is_perm_matrix ())
-        {
-          OCTAVE_TYPE_CONV_BODY3 (double, octave_perm_matrix, octave_scalar);
-        }
-      else if (args(0).is_diag_matrix ())
+      OCTAVE_TYPE_CONV_BODY3 (double, octave_perm_matrix, octave_scalar);
+    }
+  else if (args(0).is_diag_matrix ())
+    {
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_diag_matrix,
-                                      octave_complex);
-            }
-          else
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_diag_matrix,
-                                      octave_scalar);
-            }
-        }
-      else if (args(0).is_sparse_type ())
-        {
-          if (args(0).is_complex_type ())
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_complex_matrix,
-                                      octave_complex);
-            }
-          else
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_matrix,
-                                      octave_scalar);
-            }
-        }
-      else if (args(0).is_complex_type ())
-        {
-          OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_matrix,
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_diag_matrix,
                                   octave_complex);
         }
       else
         {
-          OCTAVE_TYPE_CONV_BODY3 (double, octave_matrix, octave_scalar);
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_diag_matrix,
+                                  octave_scalar);
         }
     }
+  else if (args(0).is_sparse_type ())
+    {
+      if (args(0).is_complex_type ())
+        {
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_complex_matrix,
+                                  octave_complex);
+        }
+      else
+        {
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_matrix,
+                                  octave_scalar);
+        }
+    }
+  else if (args(0).is_complex_type ())
+    {
+      OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_matrix,
+                              octave_complex);
+    }
   else
-    print_usage ();
+    {
+      OCTAVE_TYPE_CONV_BODY3 (double, octave_matrix, octave_scalar);
+    }
 
   return octave_value ();
 }
--- a/libinterp/octave-value/ov-struct.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-struct.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -1851,14 +1851,10 @@
 @seealso{ismatrix, iscell, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_map ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_map ());
 }
 
 DEFUN (__fieldnames__, args, ,
@@ -1904,47 +1900,45 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2)
+  if (nargin != 2)
+    print_usage ();
+
+  retval = false;
+
+  if (args(0).is_map ())
     {
-      retval = false;
-
-      if (args(0).is_map ())
+      octave_map m = args(0).map_value ();
+
+      // FIXME: should this work for all types that can do
+      // structure reference operations?
+
+      if (args(1).is_string ())
         {
-          octave_map m = args(0).map_value ();
-
-          // FIXME: should this work for all types that can do
-          // structure reference operations?
-
-          if (args(1).is_string ())
-            {
-              std::string key = args(1).string_value ();
-
-              retval = m.isfield (key);
-            }
-          else if (args(1).is_cell ())
+          std::string key = args(1).string_value ();
+
+          retval = m.isfield (key);
+        }
+      else if (args(1).is_cell ())
+        {
+          Cell c = args(1).cell_value ();
+          boolNDArray bm (c.dims ());
+          octave_idx_type n = bm.numel ();
+
+          for (octave_idx_type i = 0; i < n; i++)
             {
-              Cell c = args(1).cell_value ();
-              boolNDArray bm (c.dims ());
-              octave_idx_type n = bm.numel ();
-
-              for (octave_idx_type i = 0; i < n; i++)
+              if (c(i).is_string ())
                 {
-                  if (c(i).is_string ())
-                    {
-                      std::string key = c(i).string_value ();
-
-                      bm(i) = m.isfield (key);
-                    }
-                  else
-                    bm(i) = false;
+                  std::string key = c(i).string_value ();
+
+                  bm(i) = m.isfield (key);
                 }
-
-              retval = bm;
+              else
+                bm(i) = false;
             }
+
+          retval = bm;
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1960,12 +1954,13 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_map ())
-    {
-      retval = static_cast<double> (args(0).nfields ());
-    }
+  if (nargin != 1)
+    print_usage ();
+
+  if (args(0).is_map ())
+    retval = static_cast<double> (args(0).nfields ());
   else
-    print_usage ();
+    error ("numfields: argument must be a struct");
 
   return retval;
 }
@@ -2014,83 +2009,81 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  if (! args(0).is_cell ())
+    {
+      error ("cell2struct: argument CELL must be of type cell");
+      return retval;
+    }
+
+  if (! (args(1).is_cellstr () || args(1).is_char_matrix ()))
     {
-      if (! args(0).is_cell ())
-        {
-          error ("cell2struct: argument CELL must be of type cell");
-          return retval;
-        }
-
-      if (! (args(1).is_cellstr () || args(1).is_char_matrix ()))
+      error ("cell2struct: FIELDS must be a cell array of strings or a character matrix");
+      return retval;
+    }
+
+  const Cell vals = args(0).cell_value ();
+  const Array<std::string> fields = args(1).cellstr_value ();
+
+  octave_idx_type ext = 0;
+
+  int dim = 0;
+
+  if (nargin == 3)
+    {
+      if (args(2).is_real_scalar ())
+        dim = nargin == 2 ? 0 : args(2).int_value () - 1;
+      else
         {
-          error ("cell2struct: FIELDS must be a cell array of strings or a character matrix");
-          return retval;
-        }
-
-      const Cell vals = args(0).cell_value ();
-      const Array<std::string> fields = args(1).cellstr_value ();
-
-      octave_idx_type ext = 0;
-
-      int dim = 0;
-
-      if (nargin == 3)
-        {
-          if (args(2).is_real_scalar ())
-            dim = nargin == 2 ? 0 : args(2).int_value () - 1;
-          else
-            {
-              error ("cell2struct: DIM must be a real scalar");
-              return retval;
-            }
-        }
-
-      if (dim < 0)
-        {
-          error ("cell2struct: DIM must be a valid dimension");
+          error ("cell2struct: DIM must be a real scalar");
           return retval;
         }
-
-      ext = vals.ndims () > dim ? vals.dims ()(dim) : 1;
-
-      if (ext != fields.numel ())
-        {
-          error ("cell2struct: number of FIELDS does not match dimension");
-          return retval;
-        }
-
-      int nd = std::max (dim+1, vals.ndims ());
-      // result dimensions.
-      dim_vector rdv = vals.dims ().redim (nd);
-
-      assert (ext == rdv(dim));
-      if (nd == 2)
-        {
-          rdv(0) = rdv(1-dim);
-          rdv(1) = 1;
-        }
-      else
-        {
-          for (int i =  dim + 1; i < nd; i++)
-            rdv(i-1) = rdv(i);
-
-          rdv.resize (nd-1);
-        }
-
-      octave_map map (rdv);
-      Array<idx_vector> ia (dim_vector (nd, 1), idx_vector::colon);
-
-      for (octave_idx_type i = 0; i < ext; i++)
-        {
-          ia(dim) = i;
-          map.setfield (fields(i), vals.index (ia).reshape (rdv));
-        }
-
-      retval = map;
+    }
+
+  if (dim < 0)
+    {
+      error ("cell2struct: DIM must be a valid dimension");
+      return retval;
+    }
+
+  ext = vals.ndims () > dim ? vals.dims ()(dim) : 1;
+
+  if (ext != fields.numel ())
+    {
+      error ("cell2struct: number of FIELDS does not match dimension");
+      return retval;
+    }
+
+  int nd = std::max (dim+1, vals.ndims ());
+  // result dimensions.
+  dim_vector rdv = vals.dims ().redim (nd);
+
+  assert (ext == rdv(dim));
+  if (nd == 2)
+    {
+      rdv(0) = rdv(1-dim);
+      rdv(1) = 1;
     }
   else
-    print_usage ();
+    {
+      for (int i =  dim + 1; i < nd; i++)
+        rdv(i-1) = rdv(i);
+
+      rdv.resize (nd-1);
+    }
+
+  octave_map map (rdv);
+  Array<idx_vector> ia (dim_vector (nd, 1), idx_vector::colon);
+
+  for (octave_idx_type i = 0; i < ext; i++)
+    {
+      ia(dim) = i;
+      map.setfield (fields(i), vals.index (ia).reshape (rdv));
+    }
+
+  retval = map;
 
   return retval;
 }
@@ -2111,9 +2104,10 @@
 %!assert (cell2struct ({}, {"f"}, 3), struct ("f", {}));
 */
 
-
-// So we can call Fcellstr directly.
-extern octave_value_list Fcellstr (const octave_value_list& args, int);
+// FIXME: we should be including builtin-defun-decls.h but doing that
+// currently exposes a problem with dependencies in the the build system.
+extern OCTINTERP_API octave_value_list
+Fcellstr (const octave_value_list& = octave_value_list (), int = 0);
 
 DEFUN (rmfield, args, ,
        "-*- texinfo -*-\n\
@@ -2131,33 +2125,26 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2)
+  if (nargin != 2)
+    print_usage ();
+
+  octave_map m = args(0).xmap_value ("rmfield: first argument must be a struct");
+
+  octave_value_list fval = Fcellstr (args(1), 1);
+
+  Cell fcell = fval(0).cell_value ();
+
+  for (int i = 0; i < fcell.numel (); i++)
     {
-      octave_map m = args(0).map_value ();
-
-      octave_value_list fval = Fcellstr (args(1), 1);
-
-      Cell fcell = fval(0).cell_value ();
-
-      for (int i = 0; i < fcell.numel (); i++)
-        {
-          std::string key = fcell(i).string_value ();
-
-          if (m.isfield (key))
-            m.rmfield (key);
-          else
-            {
-              error ("rmfield: structure does not contain field %s",
-                     key.c_str ());
-
-              break;
-            }
-        }
-
-      retval = m;
+      std::string key = fcell(i).string_value ();
+
+      if (m.isfield (key))
+        m.rmfield (key);
+      else
+        error ("rmfield: structure does not contain field %s", key.c_str ());
     }
-  else
-    print_usage ();
+
+  retval = m;
 
   return retval;
 }
--- a/libinterp/octave-value/ov-type-conv.h	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-type-conv.h	Sun Dec 06 09:14:55 2015 +0100
@@ -80,26 +80,24 @@
  \
   int nargin = args.length (); \
  \
-  if (nargin == 1) \
-    { \
-      const octave_value arg = args(0); \
+  if (nargin != 1) \
+    print_usage (); \
  \
-      int t_result = MATRIX_RESULT_T::static_type_id (); \
+  const octave_value arg = args(0); \
+ \
+  int t_result = MATRIX_RESULT_T::static_type_id (); \
  \
-      retval = octave_type_conv_body (arg, #NAME, t_result); \
-      if (retval.is_undefined ()) \
-        { \
-          std::string arg_tname = arg.type_name (); \
+  retval = octave_type_conv_body (arg, #NAME, t_result); \
+  if (retval.is_undefined ()) \
+    { \
+      std::string arg_tname = arg.type_name (); \
  \
-          std::string result_tname = arg.numel () == 1 \
-            ? SCALAR_RESULT_T::static_type_name () \
-            : MATRIX_RESULT_T::static_type_name (); \
+      std::string result_tname = arg.numel () == 1 \
+        ? SCALAR_RESULT_T::static_type_name () \
+        : MATRIX_RESULT_T::static_type_name (); \
  \
-          gripe_invalid_conversion (arg_tname, result_tname); \
-        } \
+      gripe_invalid_conversion (arg_tname, result_tname); \
     } \
-  else \
-    print_usage (); \
  \
   return retval
 
--- a/libinterp/octave-value/ov-typeinfo.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-typeinfo.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -625,12 +625,13 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     retval = Cell (octave_value_typeinfo::installed_type_names ());
-  else if (nargin == 1)
+  else
     retval = args(0).type_name ();
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/octave-value/ov-usr-fcn.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -831,6 +831,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       octave_value func = args(0);
@@ -869,15 +872,13 @@
       else
         error ("nargin: FCN must be a string or function handle");
     }
-  else if (nargin == 0)
+  else
     {
       retval = symbol_table::varval (".nargin.");
 
       if (retval.is_undefined ())
         retval = 0;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -941,6 +942,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       octave_value func = args(0);
@@ -1000,7 +1004,7 @@
       else
         error ("nargout: FCN must be a string or function handle");
     }
-  else if (nargin == 0)
+  else
     {
       if (! symbol_table::at_top_level ())
         {
@@ -1012,8 +1016,6 @@
       else
         error ("nargout: invalid call at top level");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1078,41 +1080,39 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      if (! symbol_table::at_top_level ())
-        {
-          int nargout1 = symbol_table::varval (".nargout.").int_value ();
+  if (nargin != 1)
+    print_usage ();
 
-          Matrix ignored;
-          octave_value tmp = symbol_table::varval (".ignored.");
-          if (tmp.is_defined ())
-            ignored = tmp.matrix_value ();
+  if (! symbol_table::at_top_level ())
+    {
+      int nargout1 = symbol_table::varval (".nargout.").int_value ();
 
-          if (args(0).is_scalar_type ())
-            {
-              double k = args(0).double_value ();
+      Matrix ignored;
+      octave_value tmp = symbol_table::varval (".ignored.");
+      if (tmp.is_defined ())
+        ignored = tmp.matrix_value ();
 
-              retval = isargout1 (nargout1, ignored, k);
-            }
-          else if (args(0).is_numeric_type ())
-            {
-              const NDArray ka = args(0).array_value ();
+      if (args(0).is_scalar_type ())
+        {
+          double k = args(0).double_value ();
 
-              boolNDArray r (ka.dims ());
-              for (octave_idx_type i = 0; i < ka.numel (); i++)
-                r(i) = isargout1 (nargout1, ignored, ka(i));
+          retval = isargout1 (nargout1, ignored, k);
+        }
+      else if (args(0).is_numeric_type ())
+        {
+          const NDArray ka = args(0).array_value ();
 
-              retval = r;
-            }
-          else
-            gripe_wrong_type_arg ("isargout", args(0));
+          boolNDArray r (ka.dims ());
+          for (octave_idx_type i = 0; i < ka.numel (); i++)
+            r(i) = isargout1 (nargout1, ignored, ka(i));
+
+          retval = r;
         }
       else
-        error ("isargout: invalid call at top level");
+        gripe_wrong_type_arg ("isargout", args(0));
     }
   else
-    print_usage ();
+    error ("isargout: invalid call at top level");
 
   return retval;
 }
--- a/libinterp/octave-value/ov.cc	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/octave-value/ov.cc	Sun Dec 06 09:14:55 2015 +0100
@@ -2927,14 +2927,10 @@
 @seealso{whos}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).byte_size ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).byte_size ());
 }
 
 /*
@@ -3048,22 +3044,20 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 2)
-    {
-      std::string type;
-      std::list<octave_value_list> idx;
-
-      decode_subscripts ("subsref", args(1), type, idx);
-
-      octave_value arg0 = args(0);
-
-      if (type.empty ())
-        retval = arg0;
-      else
-        retval = arg0.subsref (type, idx, nargout);
-    }
+  if (args.length () != 2)
+    print_usage ();
+
+  std::string type;
+  std::list<octave_value_list> idx;
+
+  decode_subscripts ("subsref", args(1), type, idx);
+
+  octave_value arg0 = args(0);
+
+  if (type.empty ())
+    retval = arg0;
   else
-    print_usage ();
+    retval = arg0.subsref (type, idx, nargout);
 
   return retval;
 }
@@ -3103,30 +3097,28 @@
 {
   octave_value retval;
 
-  if (args.length () == 3)
+  if (args.length () != 3)
+    print_usage ();
+
+  std::string type;
+  std::list<octave_value_list> idx;
+
+  decode_subscripts ("subsasgn", args(1), type, idx);
+
+  if (type.empty ())
     {
-      std::string type;
-      std::list<octave_value_list> idx;
-
-      decode_subscripts ("subsasgn", args(1), type, idx);
-
-      if (type.empty ())
-        {
-          // Regularize a null matrix if stored into a variable.
-
-          retval = args(2).storable_value ();
-        }
-      else
-        {
-          octave_value arg0 = args(0);
-
-          arg0.make_unique ();
-
-          retval= arg0.subsasgn (type, idx, args(2));
-        }
+      // Regularize a null matrix if stored into a variable.
+
+      retval = args(2).storable_value ();
     }
   else
-    print_usage ();
+    {
+      octave_value arg0 = args(0);
+
+      arg0.make_unique ();
+
+      retval= arg0.subsasgn (type, idx, args(2));
+    }
 
   return retval;
 }
@@ -3205,14 +3197,10 @@
 @seealso{is_dq_string, ischar}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_sq_string ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_sq_string ());
 }
 
 /*
@@ -3232,14 +3220,10 @@
 @seealso{is_sq_string, ischar}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_dq_string ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_dq_string ());
 }
 
 /*
--- a/libinterp/parse-tree/lex.ll	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/parse-tree/lex.ll	Sun Dec 06 09:14:55 2015 +0100
@@ -24,7 +24,7 @@
 We are using the pure parser interface and the reentrant lexer
 interface but the Octave parser and lexer are NOT properly
 reentrant because both still use many global variables.  It should be
-safe to create a parser object and call it while anotehr parser
+safe to create a parser object and call it while another parser
 object is active (to parse a callback function while the main
 interactive parser is waiting for input, for example) if you take
 care to properly save and restore (typically with an unwind_protect
@@ -1912,13 +1912,14 @@
 {
   octave_value retval;
 
-  int argc = args.length () + 1;
-
-  string_vector argv = args.make_argv ("iskeyword");
-
-  if (argc == 1)
+  int nargin = args.length ();
+
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 0)
     {
-      // Neither set and get are keywords.  See the note in the
+      // Neither set nor get are keywords.  See the note in the
       // is_keyword function for additional details.
 
       string_vector lst (TOTAL_KEYWORDS);
@@ -1927,22 +1928,21 @@
 
       for (int i = 0; i < TOTAL_KEYWORDS; i++)
         {
-          std::string tmp = wordlist[i].name;
-
-          if (! (tmp == "set" || tmp == "get"))
-            lst[j++] = tmp;
+          std::string kword = wordlist[i].name;
+
+          if (kword != "set" && kword != "get")
+            lst[j++] = kword;
         }
 
       lst.resize (j);
 
       retval = Cell (lst.sort ());
     }
-  else if (argc == 2)
+  else
     {
-      retval = is_keyword (argv[1]);
+      std::string name = args(0).xstring_value ("iskeyword: NAME must be a string");
+      retval = is_keyword (name);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1952,6 +1952,11 @@
 %!assert (iskeyword ("for"))
 %!assert (iskeyword ("fort"), false)
 %!assert (iskeyword ("fft"), false)
+%!assert (iskeyword ("get"), false)
+%!assert (iskeyword ("set"), false)
+
+%!error iskeyword ("A", "B")
+%!error <NAME must be a string> iskeyword (1)
 
 */
 
--- a/libinterp/parse-tree/oct-parse.in.yy	Fri Dec 04 22:05:07 2015 +0100
+++ b/libinterp/parse-tree/oct-parse.in.yy	Sun Dec 06 09:14:55 2015 +0100
@@ -4355,6 +4355,9 @@
 
   int nargin = args.length ();
 
+  if (nargin == 1 || nargin > 3)
+    print_usage ();
+
   if (nargin == 0)
     {
       Cell func_names (dim_vector (autoload_map.size (), 1));
@@ -4377,7 +4380,7 @@
 
       retval = m;
     }
-  else if (nargin == 2 || nargin == 3)
+  else
     {
       string_vector argv = args.make_argv ("autoload");
 
@@ -4425,8 +4428,6 @@
           autoload_map.erase (argv[1]);
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -4554,10 +4555,7 @@
   int nargin = args.length ();
 
   if (nargin > 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::string arg;
 
@@ -4611,20 +4609,18 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string file_name = args(0).xstring_value ("source: expecting filename as argument");
-
-      std::string context;
-
-      if (nargin == 2)
-        context = args(1).xstring_value ("source: expecting context to be character string");
-
-      source_file (file_name, context);
-    }
-  else
+  if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  std::string file_name = args(0).xstring_value ("source: expecting filename as argument");
+
+  std::string context;
+
+  if (nargin == 2)
+    context = args(1).xstring_value ("source: expecting context to be character string");
+
+  source_file (file_name, context);
+
   return retval;
 }
 
@@ -4755,16 +4751,12 @@
 instead.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
-  if (nargin > 0)
-    retval = feval (args, nargout);
-  else
+  if (nargin == 0)
     print_usage ();
 
-  return retval;
+  return feval (args, nargout);
 }
 
 DEFUN (builtin, args, nargout,
@@ -4797,19 +4789,17 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      const std::string name (args(0).xstring_value ("builtin: function name (F) must be a string"));
-
-      octave_value fcn = symbol_table::builtin_find (name);
-
-      if (fcn.is_defined ())
-        retval = feval (fcn.function_value (), args.splice (0, 1), nargout);
-      else
-        error ("builtin: lookup for symbol '%s' failed", name.c_str ());
-    }
+  if (nargin == 0)
+    print_usage ();
+
+  const std::string name (args(0).xstring_value ("builtin: function name (F) must be a string"));
+
+  octave_value fcn = symbol_table::builtin_find (name);
+
+  if (fcn.is_defined ())
+    retval = feval (fcn.function_value (), args.splice (0, 1), nargout);
   else
-    print_usage ();
+    error ("builtin: lookup for symbol '%s' failed", name.c_str ());
 
   return retval;
 }
@@ -4957,58 +4947,56 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  unwind_protect frame;
+
+  if (nargin > 1)
+    {
+      frame.protect_var (buffer_error_messages);
+      buffer_error_messages++;
+    }
+
+  int parse_status = 0;
+
+  bool execution_error = false;
+
+  octave_value_list tmp;
+
+  try
     {
-      unwind_protect frame;
-
-      if (nargin > 1)
-        {
-          frame.protect_var (buffer_error_messages);
-          buffer_error_messages++;
-        }
-
-      int parse_status = 0;
-
-      bool execution_error = false;
-
-      octave_value_list tmp;
-
-      try
-        {
-          tmp = eval_string (args(0), nargout > 0, parse_status, nargout);
-        }
-      catch (const octave_execution_exception&)
-        {
-          recover_from_exception ();
-
-          execution_error = true;
-        }
-
-      if (nargin > 1 && (parse_status != 0 || execution_error))
-        {
-          // Set up for letting the user print any messages from
-          // errors that occurred in the first part of this eval().
-
-          buffer_error_messages--;
-
-          tmp = eval_string (args(1), nargout > 0, parse_status, nargout);
-
-          if (nargout > 0)
-            retval = tmp;
-        }
-      else
-        {
-          if (nargout > 0)
-            retval = tmp;
-
-          // FIXME: we should really be rethrowing whatever exception occurred,
-          // not just throwing an execution exception.
-          if (execution_error)
-            octave_throw_execution_exception ();
-        }
+      tmp = eval_string (args(0), nargout > 0, parse_status, nargout);
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
+
+      execution_error = true;
+    }
+
+  if (nargin > 1 && (parse_status != 0 || execution_error))
+    {
+      // Set up for letting the user print any messages from
+      // errors that occurred in the first part of this eval().
+
+      buffer_error_messages--;
+
+      tmp = eval_string (args(1), nargout > 0, parse_status, nargout);
+
+      if (nargout > 0)
+        retval = tmp;
     }
   else
-    print_usage ();
+    {
+      if (nargout > 0)
+        retval = tmp;
+
+      // FIXME: we should really be rethrowing whatever exception occurred,
+      // not just throwing an execution exception.
+      if (execution_error)
+        octave_throw_execution_exception ();
+    }
 
   return retval;
 }
@@ -5063,30 +5051,28 @@
 
   int nargin = args.length ();
 
-  if (nargin == 3)
-    {
-      std::string context = args(0).xstring_value ("assignin: CONTEXT must be a string");
-
-      unwind_protect frame;
-
-      if (context == "caller")
-        octave_call_stack::goto_caller_frame ();
-      else if (context == "base")
-        octave_call_stack::goto_base_frame ();
-      else
-        error ("assignin: CONTEXT must be \"caller\" or \"base\"");
-
-      frame.add_fcn (octave_call_stack::pop);
-
-      std::string nm = args(1).xstring_value ("assignin: VARNAME must be a string");
-
-      if (valid_identifier (nm))
-        symbol_table::assign (nm, args(2));
-      else
-        error ("assignin: invalid variable name in argument VARNAME");
-    }
+  if (nargin != 3)
+    print_usage ();
+
+  std::string context = args(0).xstring_value ("assignin: CONTEXT must be a string");
+
+  unwind_protect frame;
+
+  if (context == "caller")
+    octave_call_stack::goto_caller_frame ();
+  else if (context == "base")
+    octave_call_stack::goto_base_frame ();
   else
-    print_usage ();
+    error ("assignin: CONTEXT must be \"caller\" or \"base\"");
+
+  frame.add_fcn (octave_call_stack::pop);
+
+  std::string nm = args(1).xstring_value ("assignin: VARNAME must be a string");
+
+  if (valid_identifier (nm))
+    symbol_table::assign (nm, args(2));
+  else
+    error ("assignin: invalid variable name in argument VARNAME");
 
   return retval;
 }
@@ -5104,71 +5090,69 @@
 
   int nargin = args.length ();
 
-  if (nargin > 1)
+  if (nargin < 2)
+    print_usage ();
+
+  std::string context = args(0).xstring_value ("evalin: CONTEXT must be a string");
+
+  unwind_protect frame;
+
+  if (context == "caller")
+    octave_call_stack::goto_caller_frame ();
+  else if (context == "base")
+    octave_call_stack::goto_base_frame ();
+  else
+    error ("evalin: CONTEXT must be \"caller\" or \"base\"");
+
+  frame.add_fcn (octave_call_stack::pop);
+
+  if (nargin > 2)
     {
-      std::string context = args(0).xstring_value ("evalin: CONTEXT must be a string");
-
-      unwind_protect frame;
-
-      if (context == "caller")
-        octave_call_stack::goto_caller_frame ();
-      else if (context == "base")
-        octave_call_stack::goto_base_frame ();
-      else
-        error ("evalin: CONTEXT must be \"caller\" or \"base\"");
-
-      frame.add_fcn (octave_call_stack::pop);
-
-      if (nargin > 2)
-        {
-          frame.protect_var (buffer_error_messages);
-          buffer_error_messages++;
-        }
-
-      int parse_status = 0;
-
-      bool execution_error = false;
-
-      octave_value_list tmp;
-
-      try
-        {
-          tmp = eval_string (args(1), nargout > 0,
-                             parse_status, nargout);
-        }
-      catch (const octave_execution_exception&)
-        {
-          recover_from_exception ();
-
-          execution_error = true;
-        }
-
-      if (nargin > 2 && (parse_status != 0 || execution_error))
-        {
-          // Set up for letting the user print any messages from
-          // errors that occurred in the first part of this eval().
-
-          buffer_error_messages--;
-
-          tmp = eval_string (args(2), nargout > 0,
-                             parse_status, nargout);
-
-          retval = (nargout > 0) ? tmp : octave_value_list ();
-        }
-      else
-        {
-          if (nargout > 0)
-            retval = tmp;
-
-          // FIXME: we should really be rethrowing whatever
-          // exception occurred, not just throwing an
-          // execution exception.
-          if (execution_error)
-            octave_throw_execution_exception ();
-        }
+      frame.protect_var (buffer_error_messages);
+      buffer_error_messages++;
+    }
+
+  int parse_status = 0;
+
+  bool execution_error = false;
+
+  octave_value_list tmp;
+
+  try
+    {
+      tmp = eval_string (args(1), nargout > 0,
+                         parse_status, nargout);
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
+
+      execution_error = true;
+    }
+
+  if (nargin > 2 && (parse_status != 0 || execution_error))
+    {
+      // Set up for letting the user print any messages from
+      // errors that occurred in the first part of this eval().
+
+      buffer_error_messages--;
+
+      tmp = eval_string (args(2), nargout > 0,
+                         parse_status, nargout);
+
+      retval = (nargout > 0) ? tmp : octave_value_list ();
     }
   else
-    print_usage ();
+    {
+      if (nargout > 0)
+        retval = tmp;
+
+      // FIXME: we should really be rethrowing whatever
+      // exception occurred, not just throwing an
+      // execution exception.
+      if (execution_error)
+        octave_throw_execution_exception ();
+    }
 
   return retval;
 }
@@ -5204,38 +5188,36 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  std::string file = args(0).xstring_value ("__parse_file__: expecting filename as argument");
+
+  std::string full_file = octave_env::make_absolute (file);
+
+  size_t file_len = file.length ();
+
+  if ((file_len > 4 && file.substr (file_len-4) == ".oct")
+      || (file_len > 4 && file.substr (file_len-4) == ".mex")
+      || (file_len > 2 && file.substr (file_len-2) == ".m"))
     {
-      std::string file = args(0).xstring_value ("__parse_file__: expecting filename as argument");
-
-      std::string full_file = octave_env::make_absolute (file);
-
-      size_t file_len = file.length ();
-
-      if ((file_len > 4 && file.substr (file_len-4) == ".oct")
-          || (file_len > 4 && file.substr (file_len-4) == ".mex")
-          || (file_len > 2 && file.substr (file_len-2) == ".m"))
-        {
-          file = octave_env::base_pathname (file);
-          file = file.substr (0, file.find_last_of ('.'));
-
-          size_t pos = file.find_last_of (file_ops::dir_sep_str ());
-          if (pos != std::string::npos)
-            file = file.substr (pos+1);
-        }
-
-      if (nargin == 2)
-        octave_stdout << "parsing " << full_file << std::endl;
-
-      octave_function *fcn = parse_fcn_file (full_file, file, "", "",
-                                             true, false, false,
-                                             false, "__parse_file__");
-
-      if (fcn)
-        delete fcn;
+      file = octave_env::base_pathname (file);
+      file = file.substr (0, file.find_last_of ('.'));
+
+      size_t pos = file.find_last_of (file_ops::dir_sep_str ());
+      if (pos != std::string::npos)
+        file = file.substr (pos+1);
     }
-  else
-    print_usage ();
+
+  if (nargin == 2)
+    octave_stdout << "parsing " << full_file << std::endl;
+
+  octave_function *fcn = parse_fcn_file (full_file, file, "", "",
+                                         true, false, false,
+                                         false, "__parse_file__");
+
+  if (fcn)
+    delete fcn;
 
   return retval;
 }
--- a/scripts/statistics/base/mode.m	Fri Dec 04 22:05:07 2015 +0100
+++ b/scripts/statistics/base/mode.m	Sun Dec 06 09:14:55 2015 +0100
@@ -111,11 +111,12 @@
 %! assert (c, {[1;2;3;4;5];[2];[2;3];[2];[1;2;3;4;5]});
 %!test
 %! a = sprandn (32, 32, 0.05);
+%! sp0 = sparse (0);
 %! [m, f, c] = mode (a);
 %! [m2, f2, c2] = mode (full (a));
 %! assert (m, sparse (m2));
 %! assert (f, sparse (f2));
-%! c_exp(1:length (a)) = { sparse (0) };
+%! c_exp(1:length (a)) = { sp0 };
 %! assert (c ,c_exp);
 %! assert (c2,c_exp );