changeset 20590:1a0a433c8263

eliminate more simple uses of error_state * dirfns.cc, oct-map.cc, oct-stream.cc, regexp.cc, ov-base-mat.cc, ov-cell.cc, pt-idx.cc, pt-mat.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Mon, 05 Oct 2015 21:13:12 -0400
parents b10432a40432
children 0650b8431037
files libinterp/corefcn/dirfns.cc libinterp/corefcn/oct-map.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/regexp.cc libinterp/octave-value/ov-base-mat.cc libinterp/octave-value/ov-cell.cc libinterp/parse-tree/pt-idx.cc libinterp/parse-tree/pt-mat.cc
diffstat 8 files changed, 671 insertions(+), 905 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/dirfns.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/corefcn/dirfns.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -128,9 +128,6 @@
 
   string_vector argv = args.make_argv ("cd");
 
-  if (error_state)
-    return retval;
-
   if (nargout > 0)
     retval = octave_value (octave_env::get_current_directory ());
 
--- a/libinterp/corefcn/oct-map.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/corefcn/oct-map.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -914,8 +914,7 @@
           {
             idx_vector i = idx(0).index_vector ();
 
-            if (! error_state)
-              retval = index (i, resize_ok);
+            retval = index (i, resize_ok);
           }
           break;
 
@@ -923,13 +922,10 @@
           {
             idx_vector i = idx(0).index_vector ();
 
-            if (! error_state)
-              {
-                k = 1;
-                idx_vector j = idx(1).index_vector ();
+            k = 1;
+            idx_vector j = idx(1).index_vector ();
 
-                retval = index (i, j, resize_ok);
-              }
+            retval = index (i, j, resize_ok);
           }
           break;
 
@@ -938,15 +934,9 @@
             Array<idx_vector> ia (dim_vector (n_idx, 1));
 
             for (k = 0; k < n_idx; k++)
-              {
-                ia(k) = idx(k).index_vector ();
+              ia(k) = idx(k).index_vector ();
 
-                if (error_state)
-                  break;
-              }
-
-            if (! error_state)
-              retval = index (ia, resize_ok);
+            retval = index (ia, resize_ok);
           }
           break;
         }
@@ -1124,8 +1114,7 @@
           {
             idx_vector i = idx(0).index_vector ();
 
-            if (! error_state)
-              assign (i, rhs);
+            assign (i, rhs);
           }
           break;
 
@@ -1133,13 +1122,10 @@
           {
             idx_vector i = idx(0).index_vector ();
 
-            if (! error_state)
-              {
-                k = 1;
-                idx_vector j = idx(1).index_vector ();
+            k = 1;
+            idx_vector j = idx(1).index_vector ();
 
-                assign (i, j, rhs);
-              }
+            assign (i, j, rhs);
           }
           break;
 
@@ -1148,15 +1134,9 @@
             Array<idx_vector> ia (dim_vector (n_idx, 1));
 
             for (k = 0; k < n_idx; k++)
-              {
-                ia(k) = idx(k).index_vector ();
+              ia(k) = idx(k).index_vector ();
 
-                if (error_state)
-                  break;
-              }
-
-            if (! error_state)
-              assign (ia, rhs);
+            assign (ia, rhs);
           }
           break;
         }
@@ -1182,7 +1162,7 @@
 
   ref.assign (idx, rhs);
 
-  if (! error_state && ref.dims () != dimensions)
+  if (ref.dims () != dimensions)
     {
       dimensions = ref.dims ();
 
@@ -1196,7 +1176,7 @@
       optimize_dimensions ();
     }
 
-  if (! error_state && &ref == &tmp)
+  if (&ref == &tmp)
     setfield (k, tmp);
 }
 
@@ -1286,13 +1266,9 @@
           e.set_pos_if_unset (n_idx, i+1);
           throw;
         }
-
-      if (error_state)
-        break;
     }
 
-  if (! error_state)
-    delete_elements (ia);
+  delete_elements (ia);
 }
 
 /*
--- a/libinterp/corefcn/oct-stream.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/corefcn/oct-stream.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -145,13 +145,10 @@
   else
     ::error ("%s: invalid size specification", who.c_str ());
 
-  if (! error_state)
-    {
-      nr = get_size (dnr, who);
-
-      if (! error_state && dnc >= 0.0)
-        nc = get_size (dnc, who);
-    }
+  nr = get_size (dnr, who);
+
+  if (dnc >= 0.0)
+    nc = get_size (dnc, who);
 }
 
 scanf_format_list::scanf_format_list (const std::string& s)
@@ -1919,9 +1916,8 @@
 
           get_size (size, nr, nc, one_elt_size_spec, who);
 
-          if (! error_state)
-            retval = do_scanf (fmt_list, nr, nc, one_elt_size_spec,
-                               conversion_count, who);
+          retval = do_scanf (fmt_list, nr, nc, one_elt_size_spec,
+                             conversion_count, who);
         }
     }
   else
@@ -2361,17 +2357,14 @@
 
   octave_value val = get_next_value ();
 
+  double dval = val.double_value (true);
+
   if (! error_state)
     {
-      double dval = val.double_value (true);
-
-      if (! error_state)
-        {
-          if (D_NINT (dval) == dval)
-            retval = NINT (dval);
-          else
-            curr_state = conversion_error;
-        }
+      if (D_NINT (dval) == dval)
+        retval = NINT (dval);
+      else
+        curr_state = conversion_error;
     }
 
   return retval;
@@ -2587,9 +2580,8 @@
 
               double dval = val.double_value (true);
 
-              if (! error_state)
-                retval += do_printf_conv (os, tfmt.c_str (), nsa,
-                                          sa_1, sa_2, dval, who);
+              retval += do_printf_conv (os, tfmt.c_str (), nsa,
+                                        sa_1, sa_2, dval, who);
             }
           break;
 
@@ -2611,9 +2603,8 @@
 
               double dval = val.double_value (true);
 
-              if (! error_state)
-                retval += do_printf_conv (os, tfmt.c_str (), nsa,
-                                          sa_1, sa_2, dval, who);
+              retval += do_printf_conv (os, tfmt.c_str (), nsa,
+                                        sa_1, sa_2, dval, who);
             }
           break;
 
@@ -2622,8 +2613,7 @@
           {
             double dval = val.double_value (true);
 
-            if (! error_state)
-              retval += do_printf_conv (os, fmt, nsa, sa_1, sa_2, dval, who);
+            retval += do_printf_conv (os, fmt, nsa, sa_1, sa_2, dval, who);
           }
           break;
 
@@ -2657,9 +2647,6 @@
 
       printf_value_cache val_cache (args, who);
 
-      if (error_state)
-        return retval;
-
       for (;;)
         {
           octave_quit ();
@@ -2917,8 +2904,7 @@
         }
     }
 
-  if (! error_state)
-    retval = getl (max_len, err, who);
+  retval = getl (max_len, err, who);
 
   return retval;
 }
@@ -2957,8 +2943,7 @@
         }
     }
 
-  if (! error_state)
-    retval = gets (max_len, err, who);
+  retval = gets (max_len, err, who);
 
   return retval;
 }
@@ -3002,8 +2987,7 @@
         }
     }
 
-  if (! error_state)
-    retval = skipl (count, err, who);
+  retval = skipl (count, err, who);
 
   return retval;
 }
@@ -3398,7 +3382,6 @@
 
       if (! error_state)
         {
-
           octave_idx_type elts_to_read;
 
           if (one_elt_size_spec)
@@ -4313,8 +4296,7 @@
 
   int i = get_file_number (fid);
 
-  if (! error_state)
-    retval = do_lookup (i, who);
+  retval = do_lookup (i, who);
 
   return retval;
 }
@@ -4370,8 +4352,7 @@
     {
       int i = get_file_number (fid);
 
-      if (! error_state)
-        retval = do_remove (i, who);
+      retval = do_remove (i, who);
     }
 
   return retval;
--- a/libinterp/corefcn/regexp.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/corefcn/regexp.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -343,12 +343,9 @@
 
   // Make sure we have string, pattern
   const std::string buffer = args(0).string_value ();
-  if (error_state)
-    return retval;
 
   std::string pattern = args(1).string_value ();
-  if (error_state)
-    return retval;
+
   // Matlab compatibility.
   if (args(1).is_sq_string ())
     pattern = do_regexp_ptn_string_escapes (pattern);
@@ -357,8 +354,6 @@
   options.case_insensitive (case_insensitive);
   bool extra_options = false;
   parse_options (options, args, who, 2, extra_options);
-  if (error_state)
-    return retval;
 
   regexp::match_data rx_lst = regexp_match (pattern, buffer, options, who);
 
@@ -366,175 +361,172 @@
 
   size_t sz = rx_lst.size ();
 
-  if (! error_state)
-    {
-      // Converted the linked list in the correct form for the return values
-
-      octave_idx_type i = 0;
-      octave_scalar_map nmap;
+  // Converted the linked list in the correct form for the return values
 
-      retval.resize (7);
-
-      if (sz == 1)
-        {
-          string_vector named_tokens = rx_lst.begin ()->named_tokens ();
-
-          for (int j = 0; j < named_pats.numel (); j++)
-            nmap.assign (named_pats(j), named_tokens(j));
+  octave_idx_type i = 0;
+  octave_scalar_map nmap;
 
-          retval(5) = nmap;
-        }
-      else
-        {
-          for (int j = 0; j < named_pats.numel (); j++)
-            {
-              Cell tmp (dim_vector (1, sz));
+  retval.resize (7);
 
-              i = 0;
-              for (regexp::match_data::const_iterator p = rx_lst.begin ();
-                   p != rx_lst.end (); p++)
-                {
-                  string_vector named_tokens = p->named_tokens ();
-
-                  tmp(i++) = named_tokens(j);
-                }
-
-              nmap.assign (named_pats(j), octave_value (tmp));
-            }
+  if (sz == 1)
+    {
+      string_vector named_tokens = rx_lst.begin ()->named_tokens ();
 
-          retval(5) = nmap;
-        }
-
-      if (options.once ())
-        {
-          regexp::match_data::const_iterator p = rx_lst.begin ();
-
-          retval(4) = sz ? p->tokens () : Cell ();
-          retval(3) = sz ? p->match_string () : std::string ();
-          retval(2) = sz ? p->token_extents () : Matrix ();
-
-          if (sz)
-            {
-              double start = p->start ();
-              double end = p->end ();
-
-              Cell split (dim_vector (1, 2));
-              split(0) = buffer.substr (0, start-1);
-              split(1) = buffer.substr (end);
+      for (int j = 0; j < named_pats.numel (); j++)
+        nmap.assign (named_pats(j), named_tokens(j));
 
-              retval(6) = split;
-              retval(1) = end;
-              retval(0) = start;
-            }
-          else
-            {
-              retval(6) = buffer;
-              retval(1) = Matrix ();
-              retval(0) = Matrix ();
-            }
-        }
-      else
+      retval(5) = nmap;
+    }
+  else
+    {
+      for (int j = 0; j < named_pats.numel (); j++)
         {
-          Cell tokens (dim_vector (1, sz));
-          Cell match_string (dim_vector (1, sz));
-          Cell token_extents (dim_vector (1, sz));
-          NDArray end (dim_vector (1, sz));
-          NDArray start (dim_vector (1, sz));
-          Cell split (dim_vector (1, sz+1));
-          size_t sp_start = 0;
+          Cell tmp (dim_vector (1, sz));
 
           i = 0;
           for (regexp::match_data::const_iterator p = rx_lst.begin ();
                p != rx_lst.end (); p++)
             {
-              double s = p->start ();
-              double e = p->end ();
+              string_vector named_tokens = p->named_tokens ();
 
-              string_vector tmp = p->tokens ();
-              tokens(i) = Cell (dim_vector (1, tmp.numel ()), tmp);
-              match_string(i) = p->match_string ();
-              token_extents(i) = p->token_extents ();
-              end(i) = e;
-              start(i) = s;
-              split(i) = buffer.substr (sp_start, s-sp_start-1);
-              sp_start = e;
-              i++;
+              tmp(i++) = named_tokens(j);
             }
 
-          split(i) = buffer.substr (sp_start);
+          nmap.assign (named_pats(j), octave_value (tmp));
+        }
+
+      retval(5) = nmap;
+    }
+
+  if (options.once ())
+    {
+      regexp::match_data::const_iterator p = rx_lst.begin ();
+
+      retval(4) = sz ? p->tokens () : Cell ();
+      retval(3) = sz ? p->match_string () : std::string ();
+      retval(2) = sz ? p->token_extents () : Matrix ();
+
+      if (sz)
+        {
+          double start = p->start ();
+          double end = p->end ();
+
+          Cell split (dim_vector (1, 2));
+          split(0) = buffer.substr (0, start-1);
+          split(1) = buffer.substr (end);
 
           retval(6) = split;
-          retval(4) = tokens;
-          retval(3) = match_string;
-          retval(2) = token_extents;
           retval(1) = end;
           retval(0) = start;
         }
-
-      // Alter the order of the output arguments
+      else
+        {
+          retval(6) = buffer;
+          retval(1) = Matrix ();
+          retval(0) = Matrix ();
+        }
+    }
+  else
+    {
+      Cell tokens (dim_vector (1, sz));
+      Cell match_string (dim_vector (1, sz));
+      Cell token_extents (dim_vector (1, sz));
+      NDArray end (dim_vector (1, sz));
+      NDArray start (dim_vector (1, sz));
+      Cell split (dim_vector (1, sz+1));
+      size_t sp_start = 0;
 
-      if (extra_options)
+      i = 0;
+      for (regexp::match_data::const_iterator p = rx_lst.begin ();
+           p != rx_lst.end (); p++)
         {
-          int n = 0;
-          octave_value_list new_retval;
-          new_retval.resize (nargout);
+          double s = p->start ();
+          double e = p->end ();
 
-          OCTAVE_LOCAL_BUFFER (int, arg_used, 6);
-          for (int j = 0; j < 6; j++)
-            arg_used[j] = false;
+          string_vector tmp = p->tokens ();
+          tokens(i) = Cell (dim_vector (1, tmp.numel ()), tmp);
+          match_string(i) = p->match_string ();
+          token_extents(i) = p->token_extents ();
+          end(i) = e;
+          start(i) = s;
+          split(i) = buffer.substr (sp_start, s-sp_start-1);
+          sp_start = e;
+          i++;
+        }
+
+      split(i) = buffer.substr (sp_start);
 
-          for (int j = 2; j < nargin; j++)
-            {
-              int k = 0;
-              std::string str = args(j).string_value ();
-              std::transform (str.begin (), str.end (), str.begin (), tolower);
+      retval(6) = split;
+      retval(4) = tokens;
+      retval(3) = match_string;
+      retval(2) = token_extents;
+      retval(1) = end;
+      retval(0) = start;
+    }
+
+  // Alter the order of the output arguments
+
+  if (extra_options)
+    {
+      int n = 0;
+      octave_value_list new_retval;
+      new_retval.resize (nargout);
 
-              if (str.find ("once", 0) == 0
-                  || str.find ("stringanchors", 0) == 0
-                  || str.find ("lineanchors", 0) == 0
-                  || str.find ("matchcase", 0) == 0
-                  || str.find ("ignorecase", 0) == 0
-                  || str.find ("dotall", 0) == 0
-                  || str.find ("dotexceptnewline", 0) == 0
-                  || str.find ("literalspacing", 0) == 0
-                  || str.find ("freespacing", 0) == 0
-                  || str.find ("noemptymatch", 0) == 0
-                  || str.find ("emptymatch", 0) == 0)
-                continue;
-              else if (str.find ("start", 0) == 0)
-                k = 0;
-              else if (str.find ("end", 0) == 0)
-                k = 1;
-              else if (str.find ("tokenextents", 0) == 0)
-                k = 2;
-              else if (str.find ("match", 0) == 0)
-                k = 3;
-              else if (str.find ("tokens", 0) == 0)
-                k = 4;
-              else if (str.find ("names", 0) == 0)
-                k = 5;
-              else if (str.find ("split", 0) == 0)
-                k = 6;
+      OCTAVE_LOCAL_BUFFER (int, arg_used, 6);
+      for (int j = 0; j < 6; j++)
+        arg_used[j] = false;
+
+      for (int j = 2; j < nargin; j++)
+        {
+          int k = 0;
+          std::string str = args(j).string_value ();
+          std::transform (str.begin (), str.end (), str.begin (), tolower);
 
-              new_retval(n++) = retval(k);
-              arg_used[k] = true;
+          if (str.find ("once", 0) == 0
+              || str.find ("stringanchors", 0) == 0
+              || str.find ("lineanchors", 0) == 0
+              || str.find ("matchcase", 0) == 0
+              || str.find ("ignorecase", 0) == 0
+              || str.find ("dotall", 0) == 0
+              || str.find ("dotexceptnewline", 0) == 0
+              || str.find ("literalspacing", 0) == 0
+              || str.find ("freespacing", 0) == 0
+              || str.find ("noemptymatch", 0) == 0
+              || str.find ("emptymatch", 0) == 0)
+            continue;
+          else if (str.find ("start", 0) == 0)
+            k = 0;
+          else if (str.find ("end", 0) == 0)
+            k = 1;
+          else if (str.find ("tokenextents", 0) == 0)
+            k = 2;
+          else if (str.find ("match", 0) == 0)
+            k = 3;
+          else if (str.find ("tokens", 0) == 0)
+            k = 4;
+          else if (str.find ("names", 0) == 0)
+            k = 5;
+          else if (str.find ("split", 0) == 0)
+            k = 6;
 
-              if (n == nargout)
-                break;
-            }
+          new_retval(n++) = retval(k);
+          arg_used[k] = true;
 
-          // Fill in the rest of the arguments
-          if (n < nargout)
+          if (n == nargout)
+            break;
+        }
+
+      // Fill in the rest of the arguments
+      if (n < nargout)
+        {
+          for (int j = 0; j < 6; j++)
             {
-              for (int j = 0; j < 6; j++)
-                {
-                  if (! arg_used[j])
-                    new_retval(n++) = retval(j);
-                }
+              if (! arg_used[j])
+                new_retval(n++) = retval(j);
             }
+        }
 
-          retval = new_retval;
-        }
+      retval = new_retval;
     }
 
   return retval;
@@ -568,9 +560,6 @@
                   octave_value_list tmp = octregexp (new_args, nargout, who,
                                                      case_insensitive);
 
-                  if (error_state)
-                    break;
-
                   for (int j = 0; j < nargout; j++)
                     newretval[j](i) = tmp(j);
                 }
@@ -588,9 +577,6 @@
                   octave_value_list tmp = octregexp (new_args, nargout, who,
                                                      case_insensitive);
 
-                  if (error_state)
-                    break;
-
                   for (int j = 0; j < nargout; j++)
                     newretval[j](i) = tmp(j);
                 }
@@ -613,9 +599,6 @@
                       octave_value_list tmp = octregexp (new_args, nargout, who,
                                                          case_insensitive);
 
-                      if (error_state)
-                        break;
-
                       for (int j = 0; j < nargout; j++)
                         newretval[j](i) = tmp(j);
                     }
@@ -635,17 +618,13 @@
               octave_value_list tmp = octregexp (new_args, nargout, who,
                                                  case_insensitive);
 
-              if (error_state)
-                break;
-
               for (int j = 0; j < nargout; j++)
                 newretval[j](i) = tmp(j);
             }
         }
 
-      if (!error_state)
-        for (int j = 0; j < nargout; j++)
-          retval(j) = octave_value (newretval[j]);
+      for (int j = 0; j < nargout; j++)
+        retval(j) = octave_value (newretval[j]);
     }
   else if (args(1).is_cell ())
     {
@@ -662,18 +641,12 @@
           octave_value_list tmp = octregexp (new_args, nargout, who,
                                              case_insensitive);
 
-          if (error_state)
-            break;
-
           for (int j = 0; j < nargout; j++)
             newretval[j](i) = tmp(j);
         }
 
-      if (!error_state)
-        {
-          for (int j = 0; j < nargout; j++)
-            retval(j) = octave_value (newretval[j]);
-        }
+      for (int j = 0; j < nargout; j++)
+        retval(j) = octave_value (newretval[j]);
     }
   else
     retval = octregexp (args, nargout, who, case_insensitive);
@@ -1340,19 +1313,15 @@
 
   // Make sure we have string, pattern, replacement
   const std::string buffer = args(0).string_value ();
-  if (error_state)
-    return retval;
 
   std::string pattern = args(1).string_value ();
-  if (error_state)
-    return retval;
+
   // Matlab compatibility.
   if (args(1).is_sq_string ())
     pattern = do_regexp_ptn_string_escapes (pattern);
 
   std::string replacement = args(2).string_value ();
-  if (error_state)
-    return retval;
+
   // Matlab compatibility.
   if (args(2).is_sq_string ())
     replacement = do_regexp_rep_string_escapes (replacement);
@@ -1377,8 +1346,6 @@
   regexp::opts options;
   bool extra_args = false;
   parse_options (options, regexpargs, who, 0, extra_args);
-  if (error_state)
-    return retval;
 
   return regexp_replace (pattern, buffer, replacement, options, who);
 }
@@ -1465,41 +1432,31 @@
       else if (rep.numel () != 1)
         dv1 = rep.dims ();
 
-      if (!error_state)
-        {
-          Cell ret (dv0);
-          octave_value_list new_args = args;
-
-          for (octave_idx_type i = 0; i < dv0.numel (); i++)
-            {
-              new_args(0) = str(i);
-              if (pat.numel () == 1)
-                new_args(1) = pat(0);
-              if (rep.numel () == 1)
-                new_args(2) = rep(0);
+      Cell ret (dv0);
+      octave_value_list new_args = args;
 
-              for (octave_idx_type j = 0; j < dv1.numel (); j++)
-                {
-                  if (pat.numel () != 1)
-                    new_args(1) = pat(j);
-                  if (rep.numel () != 1)
-                    new_args(2) = rep(j);
-                  new_args(0) = octregexprep (new_args, "regexprep");
+      for (octave_idx_type i = 0; i < dv0.numel (); i++)
+        {
+          new_args(0) = str(i);
+          if (pat.numel () == 1)
+            new_args(1) = pat(0);
+          if (rep.numel () == 1)
+            new_args(2) = rep(0);
 
-                  if (error_state)
-                    break;
-                }
-
-              if (error_state)
-                break;
-
-              ret(i) = new_args(0);
+          for (octave_idx_type j = 0; j < dv1.numel (); j++)
+            {
+              if (pat.numel () != 1)
+                new_args(1) = pat(j);
+              if (rep.numel () != 1)
+                new_args(2) = rep(j);
+              new_args(0) = octregexprep (new_args, "regexprep");
             }
 
-          if (!error_state)
-            retval = args(0).is_cell () ? octave_value (ret)
-                                        : octave_value (ret(0));
+          ret(i) = new_args(0);
         }
+
+      retval = args(0).is_cell () ? octave_value (ret)
+        : octave_value (ret(0));
     }
   else
     retval = octregexprep (args, "regexprep");
--- a/libinterp/octave-value/ov-base-mat.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/octave-value/ov-base-mat.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -158,14 +158,11 @@
           {
             idx_vector i = idx (0).index_vector ();
 
-            if (! error_state)
-              {
-                // optimize single scalar index.
-                if (! resize_ok && i.is_scalar ())
-                  retval = cmatrix.checkelem (i(0));
-                else
-                  retval = MT (matrix.index (i, resize_ok));
-              }
+            // optimize single scalar index.
+            if (! resize_ok && i.is_scalar ())
+              retval = cmatrix.checkelem (i(0));
+            else
+              retval = MT (matrix.index (i, resize_ok));
           }
           break;
 
@@ -173,20 +170,14 @@
           {
             idx_vector i = idx (0).index_vector ();
 
-            if (! error_state)
-              {
-                k=1;
-                idx_vector j = idx (1).index_vector ();
+            k=1;
+            idx_vector j = idx (1).index_vector ();
 
-                if (! error_state)
-                  {
-                    // optimize two scalar indices.
-                    if (! resize_ok && i.is_scalar () && j.is_scalar ())
-                      retval = cmatrix.checkelem (i(0), j(0));
-                    else
-                      retval = MT (matrix.index (i, j, resize_ok));
-                  }
-              }
+            // optimize two scalar indices.
+            if (! resize_ok && i.is_scalar () && j.is_scalar ())
+              retval = cmatrix.checkelem (i(0), j(0));
+            else
+              retval = MT (matrix.index (i, j, resize_ok));
           }
           break;
 
@@ -200,19 +191,13 @@
               {
                 idx_vec(k) = idx(k).index_vector ();
 
-                if (error_state)
-                  break;
-
                 scalar_opt = (scalar_opt && idx_vec(k).is_scalar ());
               }
 
-            if (! error_state)
-              {
-                if (scalar_opt)
-                  retval = cmatrix.checkelem (conv_to_int_array (idx_vec));
-                else
-                  retval = MT (matrix.index (idx_vec, resize_ok));
-              }
+            if (scalar_opt)
+              retval = cmatrix.checkelem (conv_to_int_array (idx_vec));
+            else
+              retval = MT (matrix.index (idx_vec, resize_ok));
           }
           break;
         }
@@ -249,10 +234,9 @@
 
           case 1:
             {
-                  idx_vector i = idx (0).index_vector ();
+              idx_vector i = idx (0).index_vector ();
 
-                  if (! error_state)
-                    matrix.assign (i, rhs);
+              matrix.assign (i, rhs);
             }
             break;
 
@@ -260,14 +244,10 @@
             {
               idx_vector i = idx (0).index_vector ();
 
-              if (! error_state)
-                {
-                  k = 1;
-                  idx_vector j = idx (1).index_vector ();
+              k = 1;
+              idx_vector j = idx (1).index_vector ();
 
-                  if (! error_state)
-                    matrix.assign (i, j, rhs);
-                }
+              matrix.assign (i, j, rhs);
             }
             break;
 
@@ -276,15 +256,9 @@
               Array<idx_vector> idx_vec (dim_vector (n_idx, 1));
 
               for (k = 0; k < n_idx; k++)
-                {
-                  idx_vec(k) = idx(k).index_vector ();
+                idx_vec(k) = idx(k).index_vector ();
 
-                  if (error_state)
-                    break;
-                }
-
-              if (! error_state)
-                matrix.assign (idx_vec, rhs);
+              matrix.assign (idx_vec, rhs);
             }
             break;
         }
@@ -336,14 +310,11 @@
           {
             idx_vector i = idx (0).index_vector ();
 
-            if (! error_state)
-              {
-                // optimize single scalar index.
-                if (i.is_scalar () && i(0) < matrix.numel ())
-                  matrix(i(0)) = rhs;
-                else
-                  matrix.assign (i, mrhs);
-              }
+            // optimize single scalar index.
+            if (i.is_scalar () && i(0) < matrix.numel ())
+              matrix(i(0)) = rhs;
+            else
+              matrix.assign (i, mrhs);
           }
           break;
 
@@ -351,21 +322,15 @@
           {
             idx_vector i = idx (0).index_vector ();
 
-            if (! error_state)
-              {
-                k = 1;
-                idx_vector j = idx (1).index_vector ();
+            k = 1;
+            idx_vector j = idx (1).index_vector ();
 
-                if (! error_state)
-                  {
-                    // optimize two scalar indices.
-                    if (i.is_scalar () && j.is_scalar () && nd == 2
-                        && i(0) < matrix.rows () && j(0) < matrix.columns ())
-                      matrix(i(0), j(0)) = rhs;
-                    else
-                      matrix.assign (i, j, mrhs);
-                  }
-              }
+            // optimize two scalar indices.
+            if (i.is_scalar () && j.is_scalar () && nd == 2
+                && i(0) < matrix.rows () && j(0) < matrix.columns ())
+              matrix(i(0), j(0)) = rhs;
+            else
+              matrix.assign (i, j, mrhs);
           }
           break;
 
@@ -379,31 +344,25 @@
               {
                 idx_vec(k) = idx(k).index_vector ();
 
-                if (error_state)
-                  break;
-
                 scalar_opt = (scalar_opt && idx_vec(k).is_scalar ()
                               && idx_vec(k)(0) < dv(k));
               }
 
-            if (! error_state)
+            if (scalar_opt)
               {
-                if (scalar_opt)
+                // optimize all scalar indices. Don't construct
+                // an index array, but rather calc a scalar index directly.
+                octave_idx_type n = 1;
+                octave_idx_type j = 0;
+                for (octave_idx_type i = 0; i < n_idx; i++)
                   {
-                    // optimize all scalar indices. Don't construct
-                    // an index array, but rather calc a scalar index directly.
-                    octave_idx_type n = 1;
-                    octave_idx_type j = 0;
-                    for (octave_idx_type i = 0; i < n_idx; i++)
-                      {
-                        j += idx_vec(i)(0) * n;
-                        n *= dv (i);
-                      }
-                    matrix(j) = rhs;
+                    j += idx_vec(i)(0) * n;
+                    n *= dv (i);
                   }
-                else
-                  matrix.assign (idx_vec, mrhs);
+                matrix(j) = rhs;
               }
+            else
+              matrix.assign (idx_vec, mrhs);
           }
           break;
         }
--- a/libinterp/octave-value/ov-cell.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/octave-value/ov-cell.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -152,15 +152,12 @@
       {
         octave_value tmp = do_index_op (idx.front ());
 
-        if (! error_state)
-          {
-            Cell tcell = tmp.cell_value ();
+        Cell tcell = tmp.cell_value ();
 
-            if (tcell.numel () == 1)
-              retval(0) = tcell(0,0);
-            else
-              retval = octave_value (octave_value_list (tcell), true);
-          }
+        if (tcell.numel () == 1)
+          retval(0) = tcell(0,0);
+        else
+          retval = octave_value (octave_value_list (tcell), true);
       }
       break;
 
@@ -204,15 +201,12 @@
       {
         octave_value tmp = do_index_op (idx.front (), auto_add);
 
-        if (! error_state)
-          {
-            const Cell tcell = tmp.cell_value ();
+        const Cell tcell = tmp.cell_value ();
 
-            if (tcell.numel () == 1)
-              retval = tcell(0,0);
-            else
-              retval = octave_value (octave_value_list (tcell), true);
-          }
+        if (tcell.numel () == 1)
+          retval = tcell(0,0);
+        else
+          retval = octave_value (octave_value_list (tcell), true);
       }
       break;
 
@@ -280,16 +274,13 @@
                 if (! tmp.is_defined ())
                   tmp = octave_value::empty_conv (type.substr (1), rhs);
 
-                if (! error_state)
-                  {
-                    std::list<octave_value_list> next_idx (idx);
+                std::list<octave_value_list> next_idx (idx);
+
+                next_idx.erase (next_idx.begin ());
 
-                    next_idx.erase (next_idx.begin ());
+                tmp.make_unique ();
 
-                    tmp.make_unique ();
-
-                    t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
-                  }
+                t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
               }
           }
           break;
@@ -299,34 +290,30 @@
             matrix.make_unique ();
             Cell tmpc = matrix.index (idx.front (), true);
 
-            if (! error_state)
-              {
-                std::list<octave_value_list> next_idx (idx);
+            std::list<octave_value_list> next_idx (idx);
+
+            next_idx.erase (next_idx.begin ());
+
+            std::string next_type = type.substr (1);
 
-                next_idx.erase (next_idx.begin ());
+            if (tmpc.numel () == 1)
+              {
+                octave_value tmp = tmpc(0);
+                tmpc = Cell ();
 
-                std::string next_type = type.substr (1);
-
-                if (tmpc.numel () == 1)
+                if (! tmp.is_defined () || tmp.is_zero_by_zero ())
                   {
-                    octave_value tmp = tmpc(0);
-                    tmpc = Cell ();
-
-                    if (! tmp.is_defined () || tmp.is_zero_by_zero ())
-                      {
-                        tmp = octave_value::empty_conv (type.substr (1), rhs);
-                        tmp.make_unique (); // probably a no-op.
-                      }
-                    else
-                      // optimization: ignore copy still stored inside array.
-                      tmp.make_unique (1);
-
-                    if (! error_state)
-                      t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
+                    tmp = octave_value::empty_conv (type.substr (1), rhs);
+                    tmp.make_unique (); // probably a no-op.
                   }
                 else
-                  gripe_indexed_cs_list ();
+                  // optimization: ignore copy still stored inside array.
+                  tmp.make_unique (1);
+
+                t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
               }
+            else
+              gripe_indexed_cs_list ();
           }
           break;
 
@@ -349,93 +336,90 @@
         }
     }
 
-  if (! error_state)
+  switch (type[0])
     {
-      switch (type[0])
-        {
-        case '(':
-          {
-            octave_value_list i = idx.front ();
+    case '(':
+      {
+        octave_value_list i = idx.front ();
 
-            if (t_rhs.is_cell ())
-              octave_base_matrix<Cell>::assign (i, t_rhs.cell_value ());
-            else if (t_rhs.is_null_value ())
-              octave_base_matrix<Cell>::delete_elements (i);
-            else
-              octave_base_matrix<Cell>::assign (i, Cell (t_rhs));
+        if (t_rhs.is_cell ())
+          octave_base_matrix<Cell>::assign (i, t_rhs.cell_value ());
+        else if (t_rhs.is_null_value ())
+          octave_base_matrix<Cell>::delete_elements (i);
+        else
+          octave_base_matrix<Cell>::assign (i, Cell (t_rhs));
 
-            if (! error_state)
-              {
-                count++;
-                retval = octave_value (this);
-              }
-            else
-              gripe_failed_assignment ();
-          }
-          break;
-
-        case '{':
+        if (! error_state)
           {
-            octave_value_list idxf = idx.front ();
+            count++;
+            retval = octave_value (this);
+          }
+        else
+          gripe_failed_assignment ();
+      }
+      break;
 
-            if (t_rhs.is_cs_list ())
-              {
-                Cell tmp_cell = Cell (t_rhs.list_value ());
+    case '{':
+      {
+        octave_value_list idxf = idx.front ();
 
-                // Inquire the proper shape of the RHS.
+        if (t_rhs.is_cs_list ())
+          {
+            Cell tmp_cell = Cell (t_rhs.list_value ());
+
+            // Inquire the proper shape of the RHS.
 
-                dim_vector didx = dims ().redim (idxf.length ());
-                for (octave_idx_type k = 0; k < idxf.length (); k++)
-                  if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel ();
+            dim_vector didx = dims ().redim (idxf.length ());
+            for (octave_idx_type k = 0; k < idxf.length (); k++)
+              if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel ();
 
-                if (didx.numel () == tmp_cell.numel ())
-                  tmp_cell = tmp_cell.reshape (didx);
+            if (didx.numel () == tmp_cell.numel ())
+              tmp_cell = tmp_cell.reshape (didx);
 
 
-                octave_base_matrix<Cell>::assign (idxf, tmp_cell);
-              }
-            else if (idxf.all_scalars ()
-                     || do_index_op (idxf, true).numel () == 1)
-              // Regularize a null matrix if stored into a cell.
-              octave_base_matrix<Cell>::assign (idxf,
-                                                Cell (t_rhs.storable_value ()));
-            else if (! error_state)
-              gripe_nonbraced_cs_list_assignment ();
+            octave_base_matrix<Cell>::assign (idxf, tmp_cell);
+          }
+        else if (idxf.all_scalars ()
+                 || do_index_op (idxf, true).numel () == 1)
+          // Regularize a null matrix if stored into a cell.
+          octave_base_matrix<Cell>::assign (idxf,
+                                            Cell (t_rhs.storable_value ()));
+        else
+          gripe_nonbraced_cs_list_assignment ();
 
-            if (! error_state)
-              {
-                count++;
-                retval = octave_value (this);
-              }
-            else
-              gripe_failed_assignment ();
-          }
-          break;
-
-        case '.':
+        if (! error_state)
           {
-            if (is_empty ())
-              {
-                // Allow conversion of empty cell array to some other
-                // type in cases like
-                //
-                //  x = {}; x.f = rhs
-
-                octave_value tmp = octave_value::empty_conv (type, rhs);
+            count++;
+            retval = octave_value (this);
+          }
+        else
+          gripe_failed_assignment ();
+      }
+      break;
 
-                return tmp.subsasgn (type, idx, rhs);
-              }
-            else
-              {
-                std::string nm = type_name ();
-                error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
-              }
+    case '.':
+      {
+        if (is_empty ())
+          {
+            // Allow conversion of empty cell array to some other
+            // type in cases like
+            //
+            //  x = {}; x.f = rhs
+
+            octave_value tmp = octave_value::empty_conv (type, rhs);
+
+            return tmp.subsasgn (type, idx, rhs);
           }
-          break;
+        else
+          {
+            std::string nm = type_name ();
+            error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
+          }
+      }
+      break;
 
-        default:
-          panic_impossible ();
-        }
+    default:
+      panic_impossible ();
     }
 
   return retval;
@@ -614,9 +598,6 @@
     {
       string_vector s = matrix(i).all_strings ();
 
-      if (error_state)
-        return retval;
-
       octave_idx_type s_len = s.numel ();
 
       n_elts += s_len ? s_len : 1;
@@ -1341,15 +1322,11 @@
       break;
     }
 
-  if (! error_state)
-    {
-      dims.chop_trailing_singletons ();
+  dims.chop_trailing_singletons ();
 
-      check_dimensions (dims, "cell");
+  check_dimensions (dims, "cell");
 
-      if (! error_state)
-        retval = Cell (dims, Matrix ());
-    }
+  retval = Cell (dims, Matrix ());
 
   return retval;
 }
--- a/libinterp/parse-tree/pt-idx.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/parse-tree/pt-idx.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -157,19 +157,16 @@
   if (args)
     arg_values = args->convert_to_const_vector ();
 
-  if (! error_state)
-    {
-      int n = arg_values.length ();
+  int n = arg_values.length ();
 
-      if (n > 0)
-        {
-          arg_values.stash_name_tags (arg_nm);
+  if (n > 0)
+    {
+      arg_values.stash_name_tags (arg_nm);
 
-          retval.resize (dim_vector (1, n));
+      retval.resize (dim_vector (1, n));
 
-          for (int i = 0; i < n; i++)
-            retval(0,i) = arg_values(i);
-        }
+      for (int i = 0; i < n; i++)
+        retval(0,i) = arg_values(i);
     }
 
   return retval;
@@ -189,13 +186,10 @@
         retval = args->convert_to_const_vector (object);
     }
 
-  if (! error_state)
-    {
-      octave_idx_type n = retval.length ();
+  octave_idx_type n = retval.length ();
 
-      if (n > 0)
-        retval.stash_name_tags (arg_nm);
-    }
+  if (n > 0)
+    retval.stash_name_tags (arg_nm);
 
   return retval;
 }
@@ -215,13 +209,10 @@
         {
           octave_value t = df->rvalue1 ();
 
-          if (! error_state)
-            {
-              if (t.is_string () && t.rows () == 1)
-                fn = t.string_value ();
-              else
-                error ("dynamic structure field names must be strings");
-            }
+          if (t.is_string () && t.rows () == 1)
+            fn = t.string_value ();
+          else
+            error ("dynamic structure field names must be strings");
         }
       else
         panic_impossible ();
@@ -264,9 +255,6 @@
           panic_impossible ();
         }
 
-      if (error_state)
-        return m;
-
       p_args++;
       p_arg_nm++;
       p_dyn_field++;
@@ -304,9 +292,6 @@
 {
   octave_value_list retval;
 
-  if (error_state)
-    return retval;
-
   octave_value first_expr_val;
 
   octave_value_list first_args;
@@ -330,156 +315,140 @@
               first_args = al -> convert_to_const_vector ();
               first_args.stash_name_tags (anm);
 
-              if (! error_state)
-                first_expr_val = id->do_lookup  (first_args);
+              first_expr_val = id->do_lookup  (first_args);
             }
         }
     }
 
-  if (! error_state)
-    {
-      if (first_expr_val.is_undefined ())
-        first_expr_val = expr->rvalue1 ();
+  if (first_expr_val.is_undefined ())
+    first_expr_val = expr->rvalue1 ();
+
+  octave_value tmp = first_expr_val;
+  octave_idx_type tmpi = 0;
+
+  std::list<octave_value_list> idx;
+
+  int n = args.size ();
 
-      octave_value tmp = first_expr_val;
-      octave_idx_type tmpi = 0;
+  std::list<tree_argument_list *>::iterator p_args = args.begin ();
+  std::list<string_vector>::iterator p_arg_nm = arg_nm.begin ();
+  std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin ();
 
-      std::list<octave_value_list> idx;
-
-      int n = args.size ();
+  for (int i = 0; i < n; i++)
+    {
+      if (i > 0)
+        {
+          tree_argument_list *al = *p_args;
 
-      std::list<tree_argument_list *>::iterator p_args = args.begin ();
-      std::list<string_vector>::iterator p_arg_nm = arg_nm.begin ();
-      std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin ();
+          // In Matlab, () can only be followed by . In Octave, we do not
+          // enforce this for rvalue expressions, but we'll split the
+          // evaluation at this point. This will, hopefully, allow Octave's
+          // looser rules apply smoothly for Matlab overloaded subsref
+          // codes.
+          bool force_split = type[i-1] == '(' && type[i] != '.';
 
-      for (int i = 0; i < n; i++)
-        {
-          if (i > 0)
+          if (force_split || (al && al->has_magic_end ()))
             {
-              tree_argument_list *al = *p_args;
+              // (we have force_split, or) we have an expression like
+              //
+              //   x{end}.a(end)
+              //
+              // and we are looking at the argument list that
+              // contains the second (or third, etc.) "end" token,
+              // so we must evaluate everything up to the point of
+              // that argument list so we can pass the appropriate
+              // value to the built-in end function.
 
-              // In Matlab, () can only be followed by . In Octave, we do not
-              // enforce this for rvalue expressions, but we'll split the
-              // evaluation at this point. This will, hopefully, allow Octave's
-              // looser rules apply smoothly for Matlab overloaded subsref
-              // codes.
-              bool force_split = type[i-1] == '(' && type[i] != '.';
-
-              if (force_split || (al && al->has_magic_end ()))
+              try
                 {
-                  // (we have force_split, or) we have an expression like
-                  //
-                  //   x{end}.a(end)
-                  //
-                  // and we are looking at the argument list that
-                  // contains the second (or third, etc.) "end" token,
-                  // so we must evaluate everything up to the point of
-                  // that argument list so we can pass the appropriate
-                  // value to the built-in end function.
+                  octave_value_list tmp_list
+                    =tmp.subsref (type.substr (tmpi, i-tmpi), idx, nargout);
 
-                  try
-                    {
-                      octave_value_list tmp_list
-                        =tmp.subsref (type.substr (tmpi, i-tmpi), idx, nargout);
+                  tmp = tmp_list.length () ? tmp_list(0) : octave_value ();
+                  tmpi = i;
+                  idx.clear ();
 
-                      tmp = tmp_list.length () ? tmp_list(0) : octave_value ();
-                      tmpi = i;
-                      idx.clear ();
-
-                      if (tmp.is_cs_list ())
-                        gripe_indexed_cs_list ();
+                  if (tmp.is_cs_list ())
+                    gripe_indexed_cs_list ();
 
-                      if (error_state)
-                        break;
-
-                      if (tmp.is_function ())
-                        {
-                          octave_function *fcn = tmp.function_value (true);
-
-                          if (fcn && ! fcn->is_postfix_index_handled (type[i]))
-                            {
-                              octave_value_list empty_args;
+                  if (tmp.is_function ())
+                    {
+                      octave_function *fcn = tmp.function_value (true);
 
-                              tmp_list = tmp.do_multi_index_op (1, empty_args);
-                              tmp = (tmp_list.length ()
-                                     ? tmp_list(0) : octave_value ());
+                      if (fcn && ! fcn->is_postfix_index_handled (type[i]))
+                        {
+                          octave_value_list empty_args;
 
-                              if (tmp.is_cs_list ())
-                                gripe_indexed_cs_list ();
+                          tmp_list = tmp.do_multi_index_op (1, empty_args);
+                          tmp = (tmp_list.length ()
+                                 ? tmp_list(0) : octave_value ());
 
-                              if (error_state)
-                                break;
-                            }
+                          if (tmp.is_cs_list ())
+                            gripe_indexed_cs_list ();
                         }
                     }
-                  catch (index_exception& e)  // problems with index range, type etc.
-                    {
-                      final_index_error (e, expr);
-                    }
+                }
+              catch (index_exception& e)  // problems with index range, type etc.
+                {
+                  final_index_error (e, expr);
                 }
             }
-
-          switch (type[i])
-            {
-            case '(':
-              if (have_args)
-                {
-                  idx.push_back (first_args);
-                  have_args = false;
-                }
-              else
-                idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
-              break;
+        }
 
-            case '{':
-              idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
-              break;
-
-            case '.':
-              idx.push_back (octave_value (get_struct_index (p_arg_nm,
-                                                             p_dyn_field)));
-              break;
+      switch (type[i])
+        {
+        case '(':
+          if (have_args)
+            {
+              idx.push_back (first_args);
+              have_args = false;
+            }
+          else
+            idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
+          break;
 
-            default:
-              panic_impossible ();
-            }
+        case '{':
+          idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
+          break;
 
-          if (error_state)
-            break;
+        case '.':
+          idx.push_back (octave_value (get_struct_index (p_arg_nm,
+                                                         p_dyn_field)));
+          break;
 
-          p_args++;
-          p_arg_nm++;
-          p_dyn_field++;
+        default:
+          panic_impossible ();
         }
 
-      if (! error_state)
-        {
-          try
-            {
-              retval = tmp.subsref (type.substr (tmpi, n - tmpi), idx, nargout,
-                                    lvalue_list);
-            }
-          catch (index_exception& e)    // problems with range, invalid index type etc.
-            {
-              final_index_error (e, expr);
-            }
+      p_args++;
+      p_arg_nm++;
+      p_dyn_field++;
+    }
 
-          octave_value val = retval.length () ? retval(0) : octave_value ();
+  try
+    {
+      retval = tmp.subsref (type.substr (tmpi, n - tmpi), idx, nargout,
+                            lvalue_list);
+    }
+  catch (index_exception& e)    // problems with range, invalid index type etc.
+    {
+      final_index_error (e, expr);
+    }
 
-          if (! error_state && val.is_function ())
-            {
-              octave_function *fcn = val.function_value (true);
+  octave_value val = retval.length () ? retval(0) : octave_value ();
+
+  if (val.is_function ())
+    {
+      octave_function *fcn = val.function_value (true);
 
-              if (fcn)
-                {
-                  octave_value_list empty_args;
+      if (fcn)
+        {
+          octave_value_list empty_args;
 
-                  retval = (lvalue_list
-                            ? val.do_multi_index_op (nargout, empty_args,
-                                                     lvalue_list)
-                            : val.do_multi_index_op (nargout, empty_args));
-                }
-            }
+          retval = (lvalue_list
+                    ? val.do_multi_index_op (nargout, empty_args,
+                                             lvalue_list)
+                    : val.do_multi_index_op (nargout, empty_args));
         }
     }
 
@@ -515,158 +484,139 @@
 
   retval = expr->lvalue ();
 
-  if (! error_state)
-    {
-      octave_value tmp = retval.value ();
+  octave_value tmp = retval.value ();
+
+  octave_idx_type tmpi = 0;
+  std::list<octave_value_list> tmpidx;
 
-      octave_idx_type tmpi = 0;
-      std::list<octave_value_list> tmpidx;
-
-      for (int i = 0; i < n; i++)
+  for (int i = 0; i < n; i++)
+    {
+      if (retval.numel () != 1)
+        gripe_indexed_cs_list ();
+      else if (tmpi < i)
         {
-          if (retval.numel () != 1)
-            gripe_indexed_cs_list ();
-          else if (tmpi < i)
+          try
             {
-              try
-                {
-                  tmp = tmp.subsref (type.substr (tmpi, i-tmpi), tmpidx, true);
-                }
-              catch (index_exception& e)  // problems with range, invalid type etc.
-                {
-                  final_index_error (e, expr);
-                }
-              tmpidx.clear ();
+              tmp = tmp.subsref (type.substr (tmpi, i-tmpi), tmpidx, true);
+            }
+          catch (index_exception& e)  // problems with range, invalid type etc.
+            {
+              final_index_error (e, expr);
             }
+          tmpidx.clear ();
+        }
 
-          if (error_state)
-            break;
+      switch (type[i])
+        {
+        case '(':
+          {
+            octave_value_list tidx
+              = make_value_list (*p_args, *p_arg_nm, &tmp, false);
+
+            idx.push_back (tidx);
 
-          switch (type[i])
-            {
-            case '(':
+            if (i < n - 1)
               {
-                octave_value_list tidx
-                  = make_value_list (*p_args, *p_arg_nm, &tmp, false);
-
-                idx.push_back (tidx);
-
-                if (i < n - 1)
+                if (type[i+1] == '.')
                   {
-                    if (type[i+1] == '.')
-                      {
-                        tmpidx.push_back (tidx);
-                        tmpi = i+1;
-                      }
-                    else
-                      error ("() must be followed by . or close the index chain");
+                    tmpidx.push_back (tidx);
+                    tmpi = i+1;
                   }
+                else
+                  error ("() must be followed by . or close the index chain");
               }
-              break;
+          }
+          break;
+
+        case '{':
+          {
+            octave_value_list tidx
+              = make_value_list (*p_args, *p_arg_nm, &tmp, false);
 
-            case '{':
+            if (tmp.is_undefined ())
+              {
+                if (tidx.has_magic_colon ())
+                  gripe_invalid_inquiry_subscript ();
+                else
+                  tmp = Cell ();
+              }
+            else if (tmp.is_zero_by_zero ()
+                     && (tmp.is_matrix_type () || tmp.is_string ()))
               {
-                octave_value_list tidx
-                  = make_value_list (*p_args, *p_arg_nm, &tmp, false);
+                tmp = Cell ();
+              }
+
+            retval.numel (tmp.numel (tidx));
+
+            idx.push_back (tidx);
+            tmpidx.push_back (tidx);
+            tmpi = i;
+          }
+          break;
 
+        case '.':
+          {
+            octave_value tidx = get_struct_index (p_arg_nm, p_dyn_field);
+
+            bool autoconv = (tmp.is_zero_by_zero ()
+                             && (tmp.is_matrix_type () || tmp.is_string ()
+                                 || tmp.is_cell ()));
+
+            if (i > 0 && type[i-1] == '(')
+              {
+                octave_value_list pidx = idx.back ();
+
+                // Use octave_map, not octave_scalar_map so that the
+                // dimensions are 0x0, not 1x1.
                 if (tmp.is_undefined ())
                   {
-                    if (tidx.has_magic_colon ())
+                    if (pidx.has_magic_colon ())
                       gripe_invalid_inquiry_subscript ();
                     else
-                      tmp = Cell ();
+                      tmp = octave_map ();
                   }
-                else if (tmp.is_zero_by_zero ()
-                         && (tmp.is_matrix_type () || tmp.is_string ()))
-                  {
-                    tmp = Cell ();
-                  }
-
-                retval.numel (tmp.numel (tidx));
+                else if (autoconv)
+                  tmp = octave_map ();
 
-                if (error_state)
-                  break;
-
-                idx.push_back (tidx);
-                tmpidx.push_back (tidx);
-                tmpi = i;
-              }
-              break;
-
-            case '.':
-              {
-                octave_value tidx = get_struct_index (p_arg_nm, p_dyn_field);
-                if (error_state)
-                  break;
+                retval.numel (tmp.numel (pidx));
 
-                bool autoconv = (tmp.is_zero_by_zero ()
-                                 && (tmp.is_matrix_type () || tmp.is_string ()
-                                     || tmp.is_cell ()));
-
-                if (i > 0 && type[i-1] == '(')
+                tmpi = i-1;
+                tmpidx.push_back (tidx);
+              }
+            else
+              {
+                if (tmp.is_undefined () || autoconv)
                   {
-                    octave_value_list pidx = idx.back ();
-
-                    // Use octave_map, not octave_scalar_map so that the
-                    // dimensions are 0x0, not 1x1.
-                    if (tmp.is_undefined ())
-                      {
-                        if (pidx.has_magic_colon ())
-                          gripe_invalid_inquiry_subscript ();
-                        else
-                          tmp = octave_map ();
-                      }
-                    else if (autoconv)
-                      tmp = octave_map ();
-
-                    retval.numel (tmp.numel (pidx));
-
-                    tmpi = i-1;
-                    tmpidx.push_back (tidx);
+                    tmpi = i+1;
+                    tmp = octave_value ();
                   }
                 else
                   {
-                    if (tmp.is_undefined () || autoconv)
-                      {
-                        tmpi = i+1;
-                        tmp = octave_value ();
-                      }
-                    else
-                      {
-                        retval.numel (tmp.numel (octave_value_list ()));
+                    retval.numel (tmp.numel (octave_value_list ()));
 
-                        tmpi = i;
-                        tmpidx.push_back (tidx);
-                      }
+                    tmpi = i;
+                    tmpidx.push_back (tidx);
                   }
-
-                if (error_state)
-                  break;
+              }
 
-                idx.push_back (tidx);
-              }
-              break;
-
-            default:
-              panic_impossible ();
-            }
+            idx.push_back (tidx);
+          }
+          break;
 
-          if (idx.back ().empty ())
-            error ("invalid empty index list");
-
-          if (error_state)
-            break;
-
-          p_args++;
-          p_arg_nm++;
-          p_dyn_field++;
+        default:
+          panic_impossible ();
         }
 
-      if (! error_state)
-        retval.set_index (type, idx);
+      if (idx.back ().empty ())
+        error ("invalid empty index list");
 
+      p_args++;
+      p_arg_nm++;
+      p_dyn_field++;
     }
 
+  retval.set_index (type, idx);
+
   return retval;
 }
 
--- a/libinterp/parse-tree/pt-mat.cc	Mon Oct 05 20:37:19 2015 -0400
+++ b/libinterp/parse-tree/pt-mat.cc	Mon Oct 05 21:13:12 2015 -0400
@@ -360,9 +360,9 @@
 
       octave_value tmp = elt->rvalue1 ();
 
-      if (error_state || tmp.is_undefined ())
+      if (tmp.is_undefined ())
         {
-          ok = ! error_state;
+          ok = true;
           return;
         }
       else
@@ -388,35 +388,32 @@
 
   first_elem = true;
 
-  if (! error_state)
+  for (iterator p = begin (); p != end (); p++)
     {
-      for (iterator p = begin (); p != end (); p++)
-        {
-          octave_quit ();
+      octave_quit ();
+
+      octave_value val = *p;
 
-          octave_value val = *p;
+      dim_vector this_elt_dv = val.dims ();
 
-          dim_vector this_elt_dv = val.dims ();
+      if (! this_elt_dv.zero_by_zero ())
+        {
+          all_mt = false;
 
-          if (! this_elt_dv.zero_by_zero ())
+          if (first_elem)
             {
-              all_mt = false;
-
-              if (first_elem)
-                {
-                  first_elem = false;
-                  dv = this_elt_dv;
-                }
-              else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1)))
-                {
-                  eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
-                  break;
-                }
+              first_elem = false;
+              dv = this_elt_dv;
+            }
+          else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1)))
+            {
+              eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
+              break;
             }
         }
     }
 
-  ok = ! error_state;
+  ok = true;
 }
 
 void
@@ -606,60 +603,57 @@
         break;
     }
 
-  if (! error_state)
+  if (any_cell && ! any_class && ! first_elem_is_struct)
     {
-      if (any_cell && ! any_class && ! first_elem_is_struct)
-        {
-          for (iterator q = begin (); q != end (); q++)
-            {
-              octave_quit ();
-
-              q->cellify ();
-            }
-        }
-
-      first_elem = true;
-
       for (iterator q = begin (); q != end (); q++)
         {
           octave_quit ();
 
-          tm_row_const elt = *q;
-
-          octave_idx_type this_elt_nr = elt.rows ();
-          octave_idx_type this_elt_nc = elt.cols ();
-
-          std::string this_elt_class_nm = elt.class_name ();
-          class_nm = get_concat_class (class_nm, this_elt_class_nm);
-
-          dim_vector this_elt_dv = elt.dims ();
-
-          all_mt = false;
-
-          if (first_elem)
-            {
-              first_elem = false;
-
-              dv = this_elt_dv;
-            }
-          else if (all_str && dv.length () == 2
-                   && this_elt_dv.length () == 2)
-            {
-              // FIXME: this is Octave's specialty. Character matrices allow
-              // rows of unequal length.
-              if (this_elt_nc > cols ())
-                dv(1) = this_elt_nc;
-              dv(0) += this_elt_nr;
-            }
-          else if ((!any_class) && (!dv.hvcat (this_elt_dv, 0)))
-            {
-              eval_error ("vertical dimensions mismatch", dv, this_elt_dv);
-              return;
-            }
+          q->cellify ();
         }
     }
 
-  ok = ! error_state;
+  first_elem = true;
+
+  for (iterator q = begin (); q != end (); q++)
+    {
+      octave_quit ();
+
+      tm_row_const elt = *q;
+
+      octave_idx_type this_elt_nr = elt.rows ();
+      octave_idx_type this_elt_nc = elt.cols ();
+
+      std::string this_elt_class_nm = elt.class_name ();
+      class_nm = get_concat_class (class_nm, this_elt_class_nm);
+
+      dim_vector this_elt_dv = elt.dims ();
+
+      all_mt = false;
+
+      if (first_elem)
+        {
+          first_elem = false;
+
+          dv = this_elt_dv;
+        }
+      else if (all_str && dv.length () == 2
+               && this_elt_dv.length () == 2)
+        {
+          // FIXME: this is Octave's specialty. Character matrices allow
+          // rows of unequal length.
+          if (this_elt_nc > cols ())
+            dv(1) = this_elt_nc;
+          dv(0) += this_elt_nr;
+        }
+      else if ((!any_class) && (!dv.hvcat (this_elt_dv, 0)))
+        {
+          eval_error ("vertical dimensions mismatch", dv, this_elt_dv);
+          return;
+        }
+    }
+
+  ok = true;
 }
 
 octave_value_list
@@ -707,20 +701,13 @@
           TYPE ra = octave_value_extract<TYPE> (*q);
 
           // Skip empty arrays to allow looser rules.
-          if (! error_state)
-            {
-              if (! ra.is_empty ())
-                {
-                  result.insert (ra, r, c);
 
-                  if (! error_state)
-                    c += ra.columns ();
-                  else
-                    return;
-                }
+          if (! ra.is_empty ())
+            {
+              result.insert (ra, r, c);
+
+              c += ra.columns ();
             }
-          else
-            return;
         }
 
       r += row.rows ();
@@ -752,8 +739,7 @@
           result.clear (dv);
           assert (static_cast<size_t> (result.numel ()) == row.length ());
           octave_idx_type i = 0;
-          for (tm_row_const::iterator q = row.begin ();
-               q != row.end () && ! error_state; q++)
+          for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
             result(i++) = octave_value_extract<T> (*q);
 
           return;
@@ -763,9 +749,7 @@
       octave_idx_type i = 0;
       OCTAVE_LOCAL_BUFFER (Array<T>, array_list, ncols);
 
-      for (tm_row_const::iterator q = row.begin ();
-           q != row.end () && ! error_state;
-           q++)
+      for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
         {
           octave_quit ();
 
@@ -773,8 +757,7 @@
           i++;
         }
 
-      if (! error_state)
-        result = Array<T>::cat (-2, ncols, array_list);
+      result = Array<T>::cat (-2, ncols, array_list);
     }
   else
     {
@@ -808,9 +791,7 @@
       octave_idx_type i = 0;
       OCTAVE_LOCAL_BUFFER (Sparse<T>, sparse_list, ncols);
 
-      for (tm_row_const::iterator q = row.begin ();
-           q != row.end () && ! error_state;
-           q++)
+      for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
         {
           octave_quit ();
 
@@ -848,9 +829,7 @@
       octave_idx_type i = 0;
       OCTAVE_LOCAL_BUFFER (MAP, map_list, ncols);
 
-      for (tm_row_const::iterator q = row.begin ();
-           q != row.end () && ! error_state;
-           q++)
+      for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
         {
           octave_quit ();
 
@@ -921,13 +900,10 @@
         }
     }
 
-  if (! error_state)
-    {
-      if (rows.length () == 1)
-        retval = rows(0);
-      else
-        retval = do_class_concat (rows, "vertcat", 0);
-    }
+  if (rows.length () == 1)
+    retval = rows(0);
+  else
+    retval = do_class_concat (rows, "vertcat", 0);
 
   return retval;
 }
@@ -1095,53 +1071,46 @@
                 ctmp = ctmp.resize (dim_vector (0,0)).resize (dv);
             }
 
-          if (! error_state)
-            {
-              // Now, extract the values from the individual elements and
-              // insert them in the result matrix.
+          // Now, extract the values from the individual elements and
+          // insert them in the result matrix.
+
+          int dv_len = dv.length ();
+          octave_idx_type ntmp = dv_len > 1 ? dv_len : 2;
+          Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0);
 
-              int dv_len = dv.length ();
-              octave_idx_type ntmp = dv_len > 1 ? dv_len : 2;
-              Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0);
+          for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
+            {
+              octave_quit ();
 
-              for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
+              tm_row_const row = *p;
+
+              for (tm_row_const::iterator q = row.begin ();
+                   q != row.end ();
+                   q++)
                 {
                   octave_quit ();
 
-                  tm_row_const row = *p;
-
-                  for (tm_row_const::iterator q = row.begin ();
-                       q != row.end ();
-                       q++)
-                    {
-                      octave_quit ();
-
-                      octave_value elt = *q;
+                  octave_value elt = *q;
 
-                      if (elt.is_empty ())
-                        continue;
-
-                      ctmp = do_cat_op (ctmp, elt, ra_idx);
+                  if (elt.is_empty ())
+                    continue;
 
-                      if (error_state)
-                        goto done;
+                  ctmp = do_cat_op (ctmp, elt, ra_idx);
 
-                      ra_idx (1) += elt.columns ();
-                    }
-
-                  ra_idx (0) += row.rows ();
-                  ra_idx (1) = 0;
+                  ra_idx (1) += elt.columns ();
                 }
 
-              retval = ctmp;
+              ra_idx (0) += row.rows ();
+              ra_idx (1) = 0;
+            }
 
-              if (frc_str_conv && ! retval.is_string ())
-                retval = retval.convert_to_str ();
-            }
+          retval = ctmp;
+
+          if (frc_str_conv && ! retval.is_string ())
+            retval = retval.convert_to_str ();
         }
     }
 
-done:
   return retval;
 }