changeset 20803:c22206c1a88f

eliminate return statements after calls to print_usage * __ilu__.cc, besselj.cc, conv2.cc, error.cc, getgrent.cc, getpwent.cc, help.cc, load-path.cc, sparse.cc: Eliminate return statements after calls to print_usage. * mode.m: Fix test.
author John W. Eaton <jwe@octave.org>
date Fri, 04 Dec 2015 14:06:41 -0500
parents 8bb38ba1bad6
children a6eaedd8bd75
files libinterp/corefcn/__ilu__.cc libinterp/corefcn/besselj.cc libinterp/corefcn/conv2.cc libinterp/corefcn/error.cc libinterp/corefcn/getgrent.cc libinterp/corefcn/getpwent.cc libinterp/corefcn/help.cc libinterp/corefcn/load-path.cc libinterp/corefcn/sparse.cc scripts/statistics/base/mode.m
diffstat 10 files changed, 680 insertions(+), 775 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__ilu__.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/__ilu__.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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)
@@ -958,10 +952,7 @@
   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/besselj.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/besselj.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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/conv2.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/conv2.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -71,29 +71,24 @@
   bool separable = false;
   convn_type ct;
 
-  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 ())
@@ -324,11 +312,9 @@
   convn_type ct;
 
   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/error.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/error.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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/getgrent.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/getgrent.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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 12:03:44 2015 -0500
+++ b/libinterp/corefcn/getpwent.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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/help.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/help.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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/load-path.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/load-path.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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;
 }
@@ -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/sparse.cc	Fri Dec 04 12:03:44 2015 -0500
+++ b/libinterp/corefcn/sparse.cc	Fri Dec 04 14:06:41 2015 -0500
@@ -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/scripts/statistics/base/mode.m	Fri Dec 04 12:03:44 2015 -0500
+++ b/scripts/statistics/base/mode.m	Fri Dec 04 14:06:41 2015 -0500
@@ -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 );