changeset 20800:fb128aafc322

eliminate return statements after calls to print_usage * syscalls.cc, time.cc, tril.cc, typecast.cc, utils.cc: Eliminate return statements after calls to print_usage.
author John W. Eaton <jwe@octave.org>
date Thu, 03 Dec 2015 18:33:00 -0500
parents c349d4c91ce2
children a542a9bf177e
files libinterp/corefcn/syscalls.cc libinterp/corefcn/time.cc libinterp/corefcn/tril.cc libinterp/corefcn/typecast.cc libinterp/corefcn/utils.cc
diffstat 5 files changed, 539 insertions(+), 616 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/syscalls.cc	Thu Dec 03 16:40:05 2015 -0500
+++ b/libinterp/corefcn/syscalls.cc	Thu Dec 03 18:33:00 2015 -0500
@@ -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/time.cc	Thu Dec 03 16:40:05 2015 -0500
+++ b/libinterp/corefcn/time.cc	Thu Dec 03 18:33:00 2015 -0500
@@ -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/tril.cc	Thu Dec 03 16:40:05 2015 -0500
+++ b/libinterp/corefcn/tril.cc	Thu Dec 03 18:33:00 2015 -0500
@@ -206,128 +206,132 @@
 
   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/typecast.cc	Thu Dec 03 16:40:05 2015 -0500
+++ b/libinterp/corefcn/typecast.cc	Thu Dec 03 18:33:00 2015 -0500
@@ -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/utils.cc	Thu Dec 03 16:40:05 2015 -0500
+++ b/libinterp/corefcn/utils.cc	Thu Dec 03 18:33:00 2015 -0500
@@ -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));
 }
 
 /*
@@ -1035,17 +1015,15 @@
 
   std::string dir;
 
-  if (nargin == 1 || nargin == 2)
-    {
-      dir = args(0).xstring_value ("dir_in_loadpath: DIR must be a directory name");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  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;