changeset 20593:c41595061186

eliminate more simple uses of error_state * betainc.cc, file-io.cc, ov-class.cc, ov-struct.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Mon, 05 Oct 2015 23:09:54 -0400
parents 56fee8f84fe7
children a05a0432dff4
files libinterp/corefcn/betainc.cc libinterp/corefcn/file-io.cc libinterp/octave-value/ov-class.cc libinterp/octave-value/ov-struct.cc
diffstat 4 files changed, 439 insertions(+), 675 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/betainc.cc	Mon Oct 05 22:47:42 2015 -0400
+++ b/libinterp/corefcn/betainc.cc	Mon Oct 05 23:09:54 2015 -0400
@@ -87,44 +87,34 @@
                 {
                   float a = a_arg.float_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+                      float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
               else
                 {
                   Array<float> a = a_arg.float_array_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+                      float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
             }
@@ -136,44 +126,34 @@
                 {
                   float a = a_arg.float_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+                      float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
               else
                 {
                   Array<float> a = a_arg.float_array_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+                      float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
             }
@@ -188,44 +168,34 @@
                 {
                   double a = a_arg.double_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
               else
                 {
                   Array<double> a = a_arg.array_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
             }
@@ -237,44 +207,34 @@
                 {
                   double a = a_arg.double_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
               else
                 {
                   Array<double> a = a_arg.array_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      retval = betainc (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
+                      retval = betainc (x, a, b);
                     }
                 }
             }
@@ -360,44 +320,34 @@
             {
               double a = a_arg.double_value ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
+                  retval = betaincinv (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
+                  retval = betaincinv (x, a, b);
                 }
             }
           else
             {
               Array<double> a = a_arg.array_value ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
+                  retval = betaincinv (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
+                  retval = betaincinv (x, a, b);
                 }
             }
         }
@@ -409,44 +359,34 @@
             {
               double a = a_arg.double_value ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
+                  retval = betaincinv (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
+                  retval = betaincinv (x, a, b);
                 }
             }
           else
             {
               Array<double> a = a_arg.array_value ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
+                  retval = betaincinv (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
+                  retval = betaincinv (x, a, b);
                 }
             }
         }
--- a/libinterp/corefcn/file-io.cc	Mon Oct 05 22:47:42 2015 -0400
+++ b/libinterp/corefcn/file-io.cc	Mon Oct 05 23:09:54 2015 -0400
@@ -182,17 +182,14 @@
 #endif
         }
 
-      if (! error_state)
-        {
-          // Use binary mode if 't' is not specified, but don't add
-          // 'b' if it is already present.
+      // Use binary mode if 't' is not specified, but don't add
+      // 'b' if it is already present.
 
-          size_t bpos = mode.find ('b');
-          size_t tpos = mode.find ('t');
+      size_t bpos = mode.find ('b');
+      size_t tpos = mode.find ('t');
 
-          if (bpos == std::string::npos && tpos == std::string::npos)
-            mode += 'b';
-        }
+      if (bpos == std::string::npos && tpos == std::string::npos)
+        mode += 'b';
     }
 }
 
@@ -201,37 +198,34 @@
 {
   std::ios::openmode retval = std::ios::in;
 
-  if (! error_state)
-    {
-      if (mode == "rt")
-        retval = std::ios::in;
-      else if (mode == "wt")
-        retval = std::ios::out | std::ios::trunc;
-      else if (mode == "at")
-        retval = std::ios::out | std::ios::app;
-      else if (mode == "r+t" || mode == "rt+")
-        retval = std::ios::in | std::ios::out;
-      else if (mode == "w+t" || mode == "wt+")
-        retval = std::ios::in | std::ios::out | std::ios::trunc;
-      else if (mode == "a+t" || mode == "at+")
-        retval = std::ios::in | std::ios::out | std::ios::app;
-      else if (mode == "rb" || mode == "r")
-        retval = std::ios::in | std::ios::binary;
-      else if (mode == "wb" || mode == "w")
-        retval = std::ios::out | std::ios::trunc | std::ios::binary;
-      else if (mode == "ab" || mode == "a")
-        retval = std::ios::out | std::ios::app | std::ios::binary;
-      else if (mode == "r+b" || mode == "rb+" || mode == "r+")
-        retval = std::ios::in | std::ios::out | std::ios::binary;
-      else if (mode == "w+b" || mode == "wb+" || mode == "w+")
-        retval = (std::ios::in | std::ios::out | std::ios::trunc
-                  | std::ios::binary);
-      else if (mode == "a+b" || mode == "ab+" || mode == "a+")
-        retval = (std::ios::in | std::ios::out | std::ios::app
-                  | std::ios::binary);
-      else
-        error ("invalid mode specified");
-    }
+  if (mode == "rt")
+    retval = std::ios::in;
+  else if (mode == "wt")
+    retval = std::ios::out | std::ios::trunc;
+  else if (mode == "at")
+    retval = std::ios::out | std::ios::app;
+  else if (mode == "r+t" || mode == "rt+")
+    retval = std::ios::in | std::ios::out;
+  else if (mode == "w+t" || mode == "wt+")
+    retval = std::ios::in | std::ios::out | std::ios::trunc;
+  else if (mode == "a+t" || mode == "at+")
+    retval = std::ios::in | std::ios::out | std::ios::app;
+  else if (mode == "rb" || mode == "r")
+    retval = std::ios::in | std::ios::binary;
+  else if (mode == "wb" || mode == "w")
+    retval = std::ios::out | std::ios::trunc | std::ios::binary;
+  else if (mode == "ab" || mode == "a")
+    retval = std::ios::out | std::ios::app | std::ios::binary;
+  else if (mode == "r+b" || mode == "rb+" || mode == "r+")
+    retval = std::ios::in | std::ios::out | std::ios::binary;
+  else if (mode == "w+b" || mode == "wb+" || mode == "w+")
+    retval = (std::ios::in | std::ios::out | std::ios::trunc
+              | std::ios::binary);
+  else if (mode == "a+b" || mode == "ab+" || mode == "a+")
+    retval = (std::ios::in | std::ios::out | std::ios::app
+              | std::ios::binary);
+  else
+    error ("invalid mode specified");
 
   return retval;
 }
@@ -283,8 +277,7 @@
 
       octave_stream os = octave_stream_list::lookup (fid, "fclear");
 
-      if (! error_state)
-        os.clearerr ();
+      os.clearerr ();
     }
   else
     print_usage ();
@@ -327,8 +320,7 @@
         {
           octave_stream os = octave_stream_list::lookup (fid, "fflush");
 
-          if (! error_state)
-            retval = os.flush ();
+          retval = os.flush ();
         }
     }
   else
@@ -368,19 +360,16 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
+      octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
 
-          bool err = false;
+      bool err = false;
 
-          std::string tmp = os.getl (len_arg, err, who);
+      std::string tmp = os.getl (len_arg, err, who);
 
-          if (! (error_state || err))
-            {
-              retval(1) = tmp.length ();
-              retval(0) = tmp;
-            }
+      if (! err)
+        {
+          retval(1) = tmp.length ();
+          retval(0) = tmp;
         }
     }
   else
@@ -420,19 +409,16 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
+      octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
 
-          bool err = false;
+      bool err = false;
 
-          std::string tmp = os.gets (len_arg, err, who);
+      std::string tmp = os.gets (len_arg, err, who);
 
-          if (! (error_state || err))
-            {
-              retval(1) = tmp.length ();
-              retval(0) = tmp;
-            }
+      if (! err)
+        {
+          retval(1) = tmp.length ();
+          retval(0) = tmp;
         }
     }
   else
@@ -470,17 +456,14 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
+      octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
 
-          bool err = false;
+      bool err = false;
 
-          off_t tmp = os.skipl (count_arg, err, who);
+      off_t tmp = os.skipl (count_arg, err, who);
 
-          if (! (error_state || err))
-            retval = tmp;
-        }
+      if (! err)
+        retval = tmp;
     }
   else
     print_usage ();
@@ -503,51 +486,45 @@
 
   std::ios::openmode md = fopen_mode_to_ios_mode (mode);
 
-  if (! error_state)
-    {
-      oct_mach_info::float_format flt_fmt =
-        oct_mach_info::string_to_float_format (arch);
+  oct_mach_info::float_format flt_fmt =
+    oct_mach_info::string_to_float_format (arch);
 
-      if (! error_state)
-        {
-          std::string fname = file_ops::tilde_expand (name);
+  std::string fname = file_ops::tilde_expand (name);
 
-          file_stat fs (fname);
+  file_stat fs (fname);
 
-          if (! (md & std::ios::out))
-            fname = find_data_file_in_load_path ("fopen", fname);
+  if (! (md & std::ios::out))
+    fname = find_data_file_in_load_path ("fopen", fname);
 
-          if (! fs.is_dir ())
-            {
+  if (! fs.is_dir ())
+    {
 #if defined (HAVE_ZLIB)
-              if (use_zlib)
-                {
-                  FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
+      if (use_zlib)
+        {
+          FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
 
-                  int fd = fileno (fptr);
+          int fd = fileno (fptr);
 
-                  gzFile gzf = ::gzdopen (fd, mode.c_str ());
+          gzFile gzf = ::gzdopen (fd, mode.c_str ());
 
-                  if (fptr)
-                    retval = octave_zstdiostream::create (fname, gzf, fd,
-                                                          md, flt_fmt);
-                  else
-                    retval.error (gnulib::strerror (errno));
-                }
-              else
+          if (fptr)
+            retval = octave_zstdiostream::create (fname, gzf, fd,
+                                                  md, flt_fmt);
+          else
+            retval.error (gnulib::strerror (errno));
+        }
+      else
 #endif
-                {
-                  FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
-
-                  retval = octave_stdiostream::create (fname, fptr, md,
-                                                       flt_fmt);
+        {
+          FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
 
-                  if (! fptr)
-                    retval.error (gnulib::strerror (errno));
-                }
+          retval = octave_stdiostream::create (fname, fptr, md,
+                                               flt_fmt);
 
-            }
+          if (! fptr)
+            retval.error (gnulib::strerror (errno));
         }
+
     }
 
   return retval;
@@ -710,12 +687,9 @@
         {
           string_vector tmp = octave_stream_list::get_info (args(0));
 
-          if (! error_state)
-            {
-              retval(2) = tmp(2);
-              retval(1) = tmp(1);
-              retval(0) = tmp(0);
-            }
+          retval(2) = tmp(2);
+          retval(1) = tmp(1);
+          retval(0) = tmp(0);
 
           return retval;
         }
@@ -733,7 +707,7 @@
 
       octave_stream os = do_stream_open (args(0), mode, arch, "fopen", fid);
 
-      if (os && ! error_state)
+      if (os)
         {
           retval(1) = "";
           retval(0) = octave_stream_list::insert (os);
@@ -809,8 +783,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "frewind");
 
-      if (! error_state)
-        result = os.rewind ();
+      result = os.rewind ();
     }
   else
     print_usage ();
@@ -848,13 +821,10 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "fseek");
 
-      if (! error_state)
-        {
-          octave_value origin_arg = (nargin == 3)
-                                    ? args(2) : octave_value (-1.0);
+      octave_value origin_arg = (nargin == 3)
+        ? args(2) : octave_value (-1.0);
 
-          retval = os.seek (args(1), origin_arg);
-        }
+      retval = os.seek (args(1), origin_arg);
     }
   else
     print_usage ();
@@ -878,8 +848,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "ftell");
 
-      if (! error_state)
-        retval = os.tell ();
+      retval = os.tell ();
     }
   else
     print_usage ();
@@ -929,25 +898,22 @@
           os = octave_stream_list::lookup (args(0), who);
         }
 
-      if (! error_state)
+      if (args(fmt_n).is_string ())
         {
-          if (args(fmt_n).is_string ())
+          octave_value_list tmp_args;
+
+          if (nargin > 1 + fmt_n)
             {
-              octave_value_list tmp_args;
-
-              if (nargin > 1 + fmt_n)
-                {
-                  tmp_args.resize (nargin-fmt_n-1, octave_value ());
+              tmp_args.resize (nargin-fmt_n-1, octave_value ());
 
-                  for (int i = fmt_n + 1; i < nargin; i++)
-                    tmp_args(i-fmt_n-1) = args(i);
-                }
+              for (int i = fmt_n + 1; i < nargin; i++)
+                tmp_args(i-fmt_n-1) = args(i);
+            }
 
-              result = os.printf (args(fmt_n), tmp_args, who);
-            }
-          else
-            error ("%s: format TEMPLATE must be a string", who.c_str ());
+          result = os.printf (args(fmt_n), tmp_args, who);
         }
+      else
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
     print_usage ();
@@ -1036,8 +1002,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        retval = os.puts (args(1), who);
+      retval = os.puts (args(1), who);
     }
   else
     print_usage ();
@@ -1200,13 +1165,10 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          if (args(1).is_string ())
-            retval = os.oscanf (args(1), who);
-          else
-            error ("%s: format TEMPLATE must be a string", who.c_str ());
-        }
+      if (args(1).is_string ())
+        retval = os.oscanf (args(1), who);
+      else
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
     {
@@ -1218,32 +1180,23 @@
         {
           octave_stream os = octave_stream_list::lookup (args(0), who);
 
-          if (! error_state)
+          if (args(1).is_string ())
             {
-              if (args(1).is_string ())
-                {
-                  octave_idx_type count = 0;
+              octave_idx_type count = 0;
 
-                  Array<double> size = (nargin == 3)
-                                       ? args(2).vector_value ()
-                                       : Array<double> (dim_vector (1, 1),
-                                                        lo_ieee_inf_value ());
+              Array<double> size = (nargin == 3)
+                ? args(2).vector_value ()
+                : Array<double> (dim_vector (1, 1),
+                                 lo_ieee_inf_value ());
 
-                  if (! error_state)
-                    {
-                      octave_value tmp = os.scanf (args(1), size, count, who);
+              octave_value tmp = os.scanf (args(1), size, count, who);
 
-                      if (! error_state)
-                        {
-                          retval(2) = os.error ();
-                          retval(1) = count;
-                          retval(0) = tmp;
-                        }
-                    }
-                }
-              else
-                error ("%s: format must be a string", who.c_str ());
+              retval(2) = os.error ();
+              retval(1) = count;
+              retval(0) = tmp;
             }
+          else
+            error ("%s: format must be a string", who.c_str ());
         }
       else
         print_usage ();
@@ -1320,45 +1273,38 @@
 
           std::string data = get_sscanf_data (args(0));
 
-          if (! error_state)
+          octave_stream os = octave_istrstream::create (data);
+
+          if (os.is_valid ())
             {
-              octave_stream os = octave_istrstream::create (data);
-
-              if (os.is_valid ())
+              if (args(1).is_string ())
                 {
-                  if (args(1).is_string ())
-                    {
-                      octave_idx_type count = 0;
-
-                      Array<double> size = (nargin == 3)
-                                           ? args(2).vector_value ()
-                                           : Array<double> (dim_vector (1, 1),
-                                                            lo_ieee_inf_value ());
-
-                      octave_value tmp = os.scanf (args(1), size, count, who);
+                  octave_idx_type count = 0;
 
-                      if (! error_state)
-                        {
-                          // FIXME: is this the right thing to do?
-                          // Extract error message first, because getting
-                          // position will clear it.
-                          std::string errmsg = os.error ();
+                  Array<double> size = (nargin == 3)
+                    ? args(2).vector_value ()
+                    : Array<double> (dim_vector (1, 1),
+                                     lo_ieee_inf_value ());
+
+                  octave_value tmp = os.scanf (args(1), size, count, who);
 
-                          retval(3)
-                            = (os.eof () ? data.length () : os.tell ()) + 1;
-                          retval(2) = errmsg;
-                          retval(1) = count;
-                          retval(0) = tmp;
-                        }
-                    }
-                  else
-                    error ("%s: format TEMPLATE must be a string",
-                           who.c_str ());
+                  // FIXME: is this the right thing to do?
+                  // Extract error message first, because getting
+                  // position will clear it.
+                  std::string errmsg = os.error ();
+
+                  retval(3) = (os.eof () ? data.length () : os.tell ()) + 1;
+                  retval(2) = errmsg;
+                  retval(1) = count;
+                  retval(0) = tmp;
                 }
               else
-                error ("%s: unable to create temporary input buffer",
-                       who.c_str  ());
+                error ("%s: format TEMPLATE must be a string",
+                       who.c_str ());
             }
+          else
+            error ("%s: unable to create temporary input buffer",
+                   who.c_str  ());
         }
       else
         print_usage ();
@@ -1425,9 +1371,8 @@
                       oct_mach_info::float_format flt_fmt
                         = oct_mach_info::string_to_float_format (arch);
 
-                      if (! error_state)
-                        retval = os.read (size, block_size, input_type,
-                                          output_type, skip, flt_fmt, count);
+                      retval = os.read (size, block_size, input_type,
+                                        output_type, skip, flt_fmt, count);
                     }
                   else
                     error ("fread: ARCH architecture type must be a string");
@@ -1629,39 +1574,36 @@
 
       octave_stream os = octave_stream_list::lookup (args(0), "fread");
 
-      if (! error_state)
-        {
-          octave_value size = lo_ieee_inf_value ();
-          octave_value prec = "uchar";
-          octave_value skip = 0;
-          octave_value arch = "unknown";
+      octave_value size = lo_ieee_inf_value ();
+      octave_value prec = "uchar";
+      octave_value skip = 0;
+      octave_value arch = "unknown";
 
-          int idx = 1;
+      int idx = 1;
 
-          if (nargin > idx && ! args(idx).is_string ())
-            size = args(idx++);
+      if (nargin > idx && ! args(idx).is_string ())
+        size = args(idx++);
 
-          if (nargin > idx)
-            prec = args(idx++);
+      if (nargin > idx)
+        prec = args(idx++);
 
-          if (nargin > idx)
-            skip = args(idx++);
+      if (nargin > idx)
+        skip = args(idx++);
 
-          if (nargin > idx)
-            arch = args(idx++);
-          else if (skip.is_string ())
-            {
-              arch = skip;
-              skip = 0;
-            }
+      if (nargin > idx)
+        arch = args(idx++);
+      else if (skip.is_string ())
+        {
+          arch = skip;
+          skip = 0;
+        }
 
-          octave_idx_type count = -1;
-
-          octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+      octave_idx_type count = -1;
 
-          retval(1) = count;
-          retval(0) = tmp;
-        }
+      octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+
+      retval(1) = count;
+      retval(0) = tmp;
     }
   else
     print_usage ();
@@ -1698,9 +1640,8 @@
                   oct_mach_info::float_format flt_fmt
                     = oct_mach_info::string_to_float_format (arch);
 
-                  if (! error_state)
-                    retval = os.write (data, block_size, output_type,
-                                       skip, flt_fmt);
+                  retval = os.write (data, block_size, output_type,
+                                     skip, flt_fmt);
                 }
               else
                 error ("fwrite: ARCH architecture type must be a string");
@@ -1747,34 +1688,31 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "fwrite");
 
-      if (! error_state)
-        {
-          octave_value prec = "uchar";
-          octave_value skip = 0;
-          octave_value arch = "unknown";
+      octave_value prec = "uchar";
+      octave_value skip = 0;
+      octave_value arch = "unknown";
 
-          int idx = 1;
+      int idx = 1;
 
-          octave_value data = args(idx++);
+      octave_value data = args(idx++);
 
-          if (nargin > idx)
-            prec = args(idx++);
+      if (nargin > idx)
+        prec = args(idx++);
 
-          if (nargin > idx)
-            skip = args(idx++);
+      if (nargin > idx)
+        skip = args(idx++);
 
-          if (nargin > idx)
-            arch = args(idx++);
-          else if (skip.is_string ())
-            {
-              arch = skip;
-              skip = 0;
-            }
+      if (nargin > idx)
+        arch = args(idx++);
+      else if (skip.is_string ())
+        {
+          arch = skip;
+          skip = 0;
+        }
 
-          double status = do_fwrite (os, data, prec, skip, arch);
+      double status = do_fwrite (os, data, prec, skip, arch);
 
-          retval = status;
-        }
+      retval = status;
     }
   else
     print_usage ();
@@ -1802,8 +1740,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "feof");
 
-      if (! error_state)
-        retval = os.eof () ? 1.0 : 0.0;
+      retval = os.eof () ? 1.0 : 0.0;
     }
   else
     print_usage ();
@@ -1840,27 +1777,21 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "ferror");
 
-      if (! error_state)
-        {
-          bool clear = false;
+      bool clear = false;
 
-          if (nargin == 2)
-            {
-              std::string opt = args(1).string_value ();
+      if (nargin == 2)
+        {
+          std::string opt = args(1).string_value ();
 
-              if (! error_state)
-                clear = (opt == "clear");
-              else
-                return retval;
-            }
+          clear = (opt == "clear");
+        }
+
+      int error_number = 0;
 
-          int error_number = 0;
-
-          std::string error_message = os.error (clear, error_number);
+      std::string error_message = os.error (clear, error_number);
 
-          retval(1) = error_number;
-          retval(0) = error_message;
-        }
+      retval(1) = error_number;
+      retval(0) = error_message;
     }
   else
     print_usage ();
@@ -2276,8 +2207,7 @@
             {
               int oct_mask = convert (mask, 8, 10);
 
-              if (! error_state)
-                status = convert (octave_umask (oct_mask), 10, 8);
+              status = convert (octave_umask (oct_mask), 10, 8);
             }
         }
       else
--- a/libinterp/octave-value/ov-class.cc	Mon Oct 05 22:47:42 2015 -0400
+++ b/libinterp/octave-value/ov-class.cc	Mon Oct 05 23:09:54 2015 -0400
@@ -203,8 +203,7 @@
         }
     }
 
-  if (! error_state)
-    symbol_table::add_to_parent_map (id, parent_list);
+  symbol_table::add_to_parent_map (id, parent_list);
 }
 
 octave_base_value *
@@ -402,18 +401,15 @@
 
                 Cell tmp = dotref (key_idx);
 
-                if (! error_state)
-                  {
-                    Cell t = tmp.index (idx.front ());
+                Cell t = tmp.index (idx.front ());
+
+                retval(0) = (t.numel () == 1) ? t(0)
+                  : octave_value (t, true);
 
-                    retval(0) = (t.numel () == 1) ? t(0)
-                                                   : octave_value (t, true);
+                // We handled two index elements, so tell
+                // next_subsref to skip both of them.
 
-                    // We handled two index elements, so tell
-                    // next_subsref to skip both of them.
-
-                    skip++;
-                  }
+                skip++;
               }
             else
               retval(0) = octave_value (map.index (idx.front ()),
@@ -457,9 +453,6 @@
 
           args(1) = make_idx_args (type, idx, "subsref");
 
-          if (error_state)
-            return octave_value_list ();
-
           count++;
           args(0) = octave_value (this);
 
@@ -569,10 +562,6 @@
             args(2) = rhs;
 
           args(1) = make_idx_args (type, idx, "subsasgn");
-
-          if (error_state)
-            return octave_value_list ();
-
           args(0) = obj;
 
           // Now comes the magic. Count copies with me:
@@ -628,6 +617,7 @@
       if (obvp)
         {
           obvp->subsasgn (type, idx, rhs);
+
           if (! error_state)
             {
               count++;
@@ -682,20 +672,17 @@
                         u = numeric_conv (map_elt, type.substr (2));
                       }
 
-                    if (! error_state)
-                      {
-                        std::list<octave_value_list> next_idx (idx);
+                    std::list<octave_value_list> next_idx (idx);
 
-                        // We handled two index elements, so subsasgn to
-                        // needs to skip both of them.
+                    // We handled two index elements, so subsasgn to
+                    // needs to skip both of them.
 
-                        next_idx.erase (next_idx.begin ());
-                        next_idx.erase (next_idx.begin ());
+                    next_idx.erase (next_idx.begin ());
+                    next_idx.erase (next_idx.begin ());
 
-                        u.make_unique ();
+                    u.make_unique ();
 
-                        t_rhs = u.subsasgn (type.substr (2), next_idx, rhs);
-                      }
+                    t_rhs = u.subsasgn (type.substr (2), next_idx, rhs);
                   }
                 else
                   gripe_invalid_index_for_assignment ();
@@ -728,27 +715,23 @@
               }
 
             // FIXME: better code reuse?
-            if (! error_state)
+            if (tmpc.numel () == 1)
               {
-                if (tmpc.numel () == 1)
-                  {
-                    octave_value& tmp = tmpc(0);
+                octave_value& tmp = tmpc(0);
 
-                    if (! tmp.is_defined () || tmp.is_zero_by_zero ())
-                      {
-                        tmp = octave_value::empty_conv (next_type, rhs);
-                        tmp.make_unique (); // probably a no-op.
-                      }
-                    else
-                      // optimization: ignore copy still stored inside our map.
-                      tmp.make_unique (1);
-
-                    if (! error_state)
-                      t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
+                if (! tmp.is_defined () || tmp.is_zero_by_zero ())
+                  {
+                    tmp = octave_value::empty_conv (next_type, rhs);
+                    tmp.make_unique (); // probably a no-op.
                   }
                 else
-                  gripe_indexed_cs_list ();
+                  // optimization: ignore copy still stored inside our map.
+                  tmp.make_unique (1);
+
+                t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
               }
+            else
+              gripe_indexed_cs_list ();
           }
           break;
 
@@ -899,18 +882,15 @@
 
       octave_value_list tmp = feval (meth.function_value (), args, 1);
 
-      if (!error_state && tmp.length () >= 1)
-        {
-          if (tmp(0).is_object ())
-            error ("subsindex function must return a valid index vector");
-          else
-            // Index vector returned by subsindex is zero based
-            // (why this inconsistency Mathworks?), and so we must
-            // add one to the value returned as the index_vector method
-            // expects it to be one based.
-            retval = do_binary_op (octave_value::op_add, tmp (0),
-                                   octave_value (1.0)).index_vector (require_integers);
-        }
+      if (tmp(0).is_object ())
+        error ("subsindex function must return a valid index vector");
+      else
+        // Index vector returned by subsindex is zero based
+        // (why this inconsistency Mathworks?), and so we must
+        // add one to the value returned as the index_vector method
+        // expects it to be one based.
+        retval = do_binary_op (octave_value::op_add, tmp (0),
+                               octave_value (1.0)).index_vector (require_integers);
     }
   else
     error ("no subsindex method defined for class %s",
@@ -1058,7 +1038,7 @@
 
       octave_value_list tmp = feval (meth.function_value (), args, 1);
 
-      if (!error_state && tmp.length () >= 1)
+      if (tmp.length () >= 1)
         {
           if (tmp(0).is_string ())
             retval = tmp(0).all_strings (pad);
@@ -1270,10 +1250,8 @@
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = feval ("saveobj", in, 1);
-      if (! error_state)
-        m = tmp(0).map_value ();
-      else
-        return false;
+
+      m = tmp(0).map_value ();
     }
   else
     m = map_value ();
@@ -1350,10 +1328,7 @@
                       octave_value in = new octave_class (*this);
                       octave_value_list tmp = feval ("loadobj", in, 1);
 
-                      if (! error_state)
-                        map = tmp(0).map_value ();
-                      else
-                        success = false;
+                      map = tmp(0).map_value ();
                     }
                 }
               else
@@ -1398,10 +1373,8 @@
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = feval ("saveobj", in, 1);
-      if (! error_state)
-        m = tmp(0).map_value ();
-      else
-        return false;
+
+      m = tmp(0).map_value ();
     }
   else
     m = map_value ();
@@ -1494,10 +1467,7 @@
               octave_value in = new octave_class (*this);
               octave_value_list tmp = feval ("loadobj", in, 1);
 
-              if (! error_state)
-                map = tmp(0).map_value ();
-              else
-                success = false;
+              map = tmp(0).map_value ();
             }
         }
       else
@@ -1569,10 +1539,8 @@
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = feval ("saveobj", in, 1);
-      if (! error_state)
-        m = tmp(0).map_value ();
-      else
-        goto error_cleanup;
+
+      m = tmp(0).map_value ();
     }
   else
     m = map_value ();
@@ -1740,13 +1708,8 @@
           octave_value in = new octave_class (*this);
           octave_value_list tmp = feval ("loadobj", in, 1);
 
-          if (! error_state)
-            {
-              map = tmp(0).map_value ();
-              retval = true;
-            }
-          else
-            retval = false;
+          map = tmp(0).map_value ();
+          retval = true;
         }
     }
 
@@ -1917,18 +1880,15 @@
                             = octave_value (new octave_class (m, id, parents));
                         }
 
-                      if (! error_state)
-                        {
-                          octave_class::exemplar_const_iterator it
-                            = octave_class::exemplar_map.find (id);
+                      octave_class::exemplar_const_iterator it
+                        = octave_class::exemplar_map.find (id);
 
-                          if (it == octave_class::exemplar_map.end ())
-                            octave_class::exemplar_map[id]
-                              = octave_class::exemplar_info (retval);
-                          else if (! it->second.compare (retval))
-                            error ("class: object of class '%s' does not match previously constructed objects",
-                                   id.c_str ());
-                        }
+                      if (it == octave_class::exemplar_map.end ())
+                        octave_class::exemplar_map[id]
+                          = octave_class::exemplar_info (retval);
+                      else if (! it->second.compare (retval))
+                        error ("class: object of class '%s' does not match previously constructed objects",
+                               id.c_str ());
                     }
                   else
                     error ("class: expecting structure S as first argument");
@@ -2137,18 +2097,12 @@
       else
         error ("ismethod: expecting object or class name as first argument");
 
-      if (! error_state)
-        {
-          std::string method = args(1).string_value ();
+      std::string method = args(1).string_value ();
 
-          if (! error_state)
-            {
-              if (load_path::find_method (class_name, method) != std::string ())
-                retval = true;
-              else
-                retval = false;
-            }
-        }
+      if (load_path::find_method (class_name, method) != std::string ())
+        retval = true;
+      else
+        retval = false;
     }
   else
     print_usage ();
@@ -2178,11 +2132,8 @@
   else if (arg.is_string ())
     class_name = arg.string_value ();
 
-  if (! error_state)
-    {
-      string_vector sv = load_path::methods (class_name);
-      retval = Cell (sv);
-    }
+  string_vector sv = load_path::methods (class_name);
+  retval = Cell (sv);
 
   return retval;
 }
--- a/libinterp/octave-value/ov-struct.cc	Mon Oct 05 22:47:42 2015 -0400
+++ b/libinterp/octave-value/ov-struct.cc	Mon Oct 05 23:09:54 2015 -0400
@@ -153,17 +153,14 @@
 
             const Cell tmp = dotref (key_idx);
 
-            if (! error_state)
-              {
-                const Cell t = tmp.index (idx.front ());
-
-                retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
-
-                // We handled two index elements, so tell
-                // next_subsref to skip both of them.
-
-                skip++;
-              }
+            const Cell t = tmp.index (idx.front ());
+
+            retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
+
+            // We handled two index elements, so tell
+            // next_subsref to skip both of them.
+
+            skip++;
           }
         else
           retval(0) = do_index_op (idx.front ());
@@ -219,17 +216,14 @@
 
             const Cell tmp = dotref (key_idx, auto_add);
 
-            if (! error_state)
-              {
-                const Cell t = tmp.index (idx.front (), auto_add);
-
-                retval = (t.numel () == 1) ? t(0) : octave_value (t, true);
-
-                // We handled two index elements, so tell
-                // next_subsref to skip both of them.
-
-                skip++;
-              }
+            const Cell t = tmp.index (idx.front (), auto_add);
+
+            retval = (t.numel () == 1) ? t(0) : octave_value (t, true);
+
+            // We handled two index elements, so tell
+            // next_subsref to skip both of them.
+
+            skip++;
           }
         else
           retval = do_index_op (idx.front (), auto_add);
@@ -324,9 +318,6 @@
 
                 maybe_warn_invalid_field_name (key, "subsasgn");
 
-                if (error_state)
-                  return retval;
-
                 std::list<octave_value_list> next_idx (idx);
 
                 // We handled two index elements, so subsasgn to
@@ -347,33 +338,28 @@
 
                 // FIXME: better code reuse?
                 //        cf. octave_cell::subsasgn and the case below.
-                if (! error_state)
+                if (tmpc.numel () == 1)
                   {
-                    if (tmpc.numel () == 1)
+                    octave_value& tmp = tmpc(0);
+
+                    bool orig_undefined = tmp.is_undefined ();
+
+                    if (orig_undefined || tmp.is_zero_by_zero ())
                       {
-                        octave_value& tmp = tmpc(0);
-
-                        bool orig_undefined = tmp.is_undefined ();
-
-                        if (orig_undefined || tmp.is_zero_by_zero ())
-                          {
-                            tmp = octave_value::empty_conv (next_type, rhs);
-                            tmp.make_unique (); // probably a no-op.
-                          }
-                        else
-                          // optimization: ignore the copy
-                          // still stored inside our map.
-                          tmp.make_unique (1);
-
-                        if (! error_state)
-                          t_rhs =
-                            (orig_undefined
-                               ? tmp.undef_subsasgn (next_type, next_idx, rhs)
-                               : tmp.subsasgn (next_type, next_idx, rhs));
+                        tmp = octave_value::empty_conv (next_type, rhs);
+                        tmp.make_unique (); // probably a no-op.
                       }
                     else
-                      gripe_indexed_cs_list ();
+                      // optimization: ignore the copy
+                      // still stored inside our map.
+                      tmp.make_unique (1);
+
+                      t_rhs =(orig_undefined
+                              ? tmp.undef_subsasgn (next_type, next_idx, rhs)
+                              : tmp.subsasgn (next_type, next_idx, rhs));
                   }
+                else
+                  gripe_indexed_cs_list ();
               }
             else
               gripe_invalid_index_for_assignment ();
@@ -390,9 +376,6 @@
 
             maybe_warn_invalid_field_name (key, "subsasgn");
 
-            if (error_state)
-              return retval;
-
             std::list<octave_value_list> next_idx (idx);
 
             next_idx.erase (next_idx.begin ());
@@ -408,32 +391,29 @@
               }
 
             // FIXME: better code reuse?
-            if (! error_state)
+
+            if (tmpc.numel () == 1)
               {
-                if (tmpc.numel () == 1)
+                octave_value& tmp = tmpc(0);
+
+                bool orig_undefined = tmp.is_undefined ();
+
+                if (orig_undefined || tmp.is_zero_by_zero ())
                   {
-                    octave_value& tmp = tmpc(0);
-
-                    bool orig_undefined = tmp.is_undefined ();
-
-                    if (orig_undefined || tmp.is_zero_by_zero ())
-                      {
-                        tmp = octave_value::empty_conv (next_type, rhs);
-                        tmp.make_unique (); // probably a no-op.
-                      }
-                    else
-                      // optimization: ignore the copy
-                      // still stored inside our map.
-                      tmp.make_unique (1);
-
-                    if (! error_state)
-                      t_rhs = (orig_undefined
-                               ? tmp.undef_subsasgn (next_type, next_idx, rhs)
-                               : tmp.subsasgn (next_type, next_idx, rhs));
+                    tmp = octave_value::empty_conv (next_type, rhs);
+                    tmp.make_unique (); // probably a no-op.
                   }
                 else
-                  gripe_indexed_cs_list ();
+                  // optimization: ignore the copy
+                  // still stored inside our map.
+                  tmp.make_unique (1);
+
+                t_rhs = (orig_undefined
+                         ? tmp.undef_subsasgn (next_type, next_idx, rhs)
+                         : tmp.subsasgn (next_type, next_idx, rhs));
               }
+            else
+              gripe_indexed_cs_list ();
           }
           break;
 
@@ -464,9 +444,6 @@
 
                 maybe_warn_invalid_field_name (key, "subsasgn");
 
-                if (error_state)
-                  return retval;
-
                 if (! error_state)
                   {
                     if (t_rhs.is_cs_list ())
@@ -572,9 +549,6 @@
 
             maybe_warn_invalid_field_name (key, "subsasgn");
 
-            if (error_state)
-              return retval;
-
             if (t_rhs.is_cs_list ())
               {
                 Cell tmp_cell = Cell (t_rhs.list_value ());
@@ -1156,9 +1130,6 @@
 
   maybe_warn_invalid_field_name (nm, "subsref");
 
-  if (error_state)
-    return retval;
-
   retval = map.getfield (nm);
 
   if (! auto_add && retval.is_undefined ())
@@ -1283,9 +1254,6 @@
 
       maybe_warn_invalid_field_name (key, "subsasgn");
 
-      if (error_state)
-        return retval;
-
       if (n > 1)
         {
           std::list<octave_value_list> next_idx (idx);
@@ -1302,24 +1270,20 @@
               tmp = map.contents (pkey);
             }
 
-          if (! error_state)
+          bool orig_undefined = tmp.is_undefined ();
+
+          if (orig_undefined || tmp.is_zero_by_zero ())
             {
-              bool orig_undefined = tmp.is_undefined ();
-
-              if (orig_undefined || tmp.is_zero_by_zero ())
-                {
-                  tmp = octave_value::empty_conv (next_type, rhs);
-                  tmp.make_unique (); // probably a no-op.
-                }
-              else
-                // optimization: ignore the copy still stored inside our map.
-                tmp.make_unique (1);
-
-              if (! error_state)
-                t_rhs = (orig_undefined
-                         ? tmp.undef_subsasgn (next_type, next_idx, rhs)
-                         : tmp.subsasgn (next_type, next_idx, rhs));
+              tmp = octave_value::empty_conv (next_type, rhs);
+              tmp.make_unique (); // probably a no-op.
             }
+          else
+            // optimization: ignore the copy still stored inside our map.
+            tmp.make_unique (1);
+
+          t_rhs = (orig_undefined
+                   ? tmp.undef_subsasgn (next_type, next_idx, rhs)
+                   : tmp.subsasgn (next_type, next_idx, rhs));
         }
 
       if (! error_state)
@@ -1925,14 +1889,8 @@
 
       std::string key (args(i).string_value ());
 
-      if (error_state)
-        return retval;
-
       maybe_warn_invalid_field_name (key, "struct");
 
-      if (error_state)
-        return retval;
-
       // Value may be v, { v }, or { v1, v2, ... }
       // In the first two cases, we need to create a cell array of
       // the appropriate dimensions filled with v.  In the last case,
@@ -1943,9 +1901,6 @@
         {
           const Cell c (args(i+1).cell_value ());
 
-          if (error_state)
-            return retval;
-
           if (scalar (c.dims ()))
             map.setfield (key, Cell (dims, c(0)));
           else
@@ -1953,9 +1908,6 @@
         }
       else
         map.setfield (key, Cell (dims, args(i+1)));
-
-      if (error_state)
-        return retval;
     }
 
   return octave_value (map);
@@ -2175,12 +2127,7 @@
       if (nargin == 3)
         {
           if (args(2).is_real_scalar ())
-            {
-              dim = nargin == 2 ? 0 : args(2).int_value () - 1;
-
-              if (error_state)
-                return retval;
-            }
+            dim = nargin == 2 ? 0 : args(2).int_value () - 1;
           else
             {
               error ("cell2struct: DIM must be a real scalar");
@@ -2279,28 +2226,24 @@
 
       octave_value_list fval = Fcellstr (args(1), 1);
 
-      if (! error_state)
+      Cell fcell = fval(0).cell_value ();
+
+      for (int i = 0; i < fcell.numel (); i++)
         {
-          Cell fcell = fval(0).cell_value ();
-
-          for (int i = 0; i < fcell.numel (); i++)
+          std::string key = fcell(i).string_value ();
+
+          if (m.isfield (key))
+            m.rmfield (key);
+          else
             {
-              std::string key = fcell(i).string_value ();
-
-              if (m.isfield (key))
-                m.rmfield (key);
-              else
-                {
-                  error ("rmfield: structure does not contain field %s",
-                         key.c_str ());
-
-                  break;
-                }
+              error ("rmfield: structure does not contain field %s",
+                     key.c_str ());
+
+              break;
             }
-
-          if (! error_state)
-            retval = m;
         }
+
+      retval = m;
     }
   else
     print_usage ();