changeset 20651:c1d94e5cd5ea

catch index_exception by const reference where possible * data.cc, sub2ind.cc, toplev.cc, utils.cc, ov-base-mat.cc, lo-array-gripes.cc: Catch index_exception by const reference where possible.
author John W. Eaton <jwe@octave.org>
date Wed, 21 Oct 2015 15:23:08 -0400
parents a6a452346c42
children 7a8096f8df5d
files libinterp/corefcn/data.cc libinterp/corefcn/sub2ind.cc libinterp/corefcn/toplev.cc libinterp/corefcn/utils.cc libinterp/octave-value/ov-base-mat.cc liboctave/util/lo-array-gripes.cc
diffstat 6 files changed, 19 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc	Wed Oct 21 13:58:08 2015 -0400
+++ b/libinterp/corefcn/data.cc	Wed Oct 21 15:23:08 2015 -0400
@@ -7132,9 +7132,10 @@
                 gripe_wrong_type_arg ("nth_element", argx);
             }
         }
-      catch (index_exception& e)
+      catch (const index_exception& e)
         {
-          error ("nth_element: invalid N value %s. %s", e.idx (), e.explain ());
+          error ("nth_element: invalid N value %s. %s",
+                 e.idx (), e.explain ());
         }
     }
   else
@@ -7213,10 +7214,10 @@
           else
             gripe_wrong_type_arg ("accumarray", vals);
         }
-      catch (index_exception& e)
+      catch (const index_exception& e)
         {
           error ("__accumarray_sum__: invalid IDX %s. %s",
-                 e.idx(), e.explain ());
+                 e.idx (), e.explain ());
         }
     }
   else
@@ -7316,10 +7317,10 @@
               gripe_wrong_type_arg ("accumarray", vals);
             }
         }
-      catch (index_exception& e)
+      catch (const index_exception& e)
         {
           error ("do_accumarray_minmax_fun: invalid index %s. %s",
-                                        e.idx (), e.explain ());
+                 e.idx (), e.explain ());
         }
 
     }
@@ -7422,9 +7423,10 @@
           else
             gripe_wrong_type_arg ("accumdim", vals);
         }
-      catch (index_exception& e)
+      catch (const index_exception& e)
         {
-          error ("__accumdim_sum__: invalid IDX %s. %s", e.idx(), e.explain ());
+          error ("__accumdim_sum__: invalid IDX %s. %s",
+                 e.idx (), e.explain ());
         }
     }
   else
--- a/libinterp/corefcn/sub2ind.cc	Wed Oct 21 13:58:08 2015 -0400
+++ b/libinterp/corefcn/sub2ind.cc	Wed Oct 21 15:23:08 2015 -0400
@@ -203,7 +203,7 @@
           
           retval = Array<octave_value> (ind2sub (dv, idx));
         }
-      catch (index_exception& e)
+      catch (const index_exception& e)
         {
           error ("ind2sub: Invalid index %s. %s", e.idx (), e.explain ());
         }
--- a/libinterp/corefcn/toplev.cc	Wed Oct 21 13:58:08 2015 -0400
+++ b/libinterp/corefcn/toplev.cc	Wed Oct 21 15:23:08 2015 -0400
@@ -658,7 +658,7 @@
           if (quitting_gracefully)
             return exit_status;
         }
-      catch (index_exception& e)
+      catch (const index_exception& e)
         {
           recover_from_exception ();
           std::cerr << "error: unhandled index exception: "
--- a/libinterp/corefcn/utils.cc	Wed Oct 21 13:58:08 2015 -0400
+++ b/libinterp/corefcn/utils.cc	Wed Oct 21 15:23:08 2015 -0400
@@ -1282,10 +1282,10 @@
 
                   retval *= jdx.length (dv(i));
                 }
-              catch (index_exception& e)
+              catch (const index_exception& e)
                 {
                   error ("dims_to_numel: Invalid IDX %s. %s",
-                                                        e.idx (), e.explain ());
+                         e.idx (), e.explain ());
                 }
             }
         }
--- a/libinterp/octave-value/ov-base-mat.cc	Wed Oct 21 13:58:08 2015 -0400
+++ b/libinterp/octave-value/ov-base-mat.cc	Wed Oct 21 15:23:08 2015 -0400
@@ -263,9 +263,9 @@
             break;
         }
     }
-  catch (index_exception& e)
+  catch (const index_exception& e)
     {
-      gripe_invalid_index (e.idx(), n_idx, k+1);
+      gripe_invalid_index (e.idx (), n_idx, k+1);
     }
 
   // Clear cache.
@@ -369,7 +369,7 @@
     }
   catch (const index_exception& e)
     {
-      gripe_invalid_index (e.idx(), n_idx, k+1);
+      gripe_invalid_index (e.idx (), n_idx, k+1);
      }
 
   // Clear cache.
--- a/liboctave/util/lo-array-gripes.cc	Wed Oct 21 13:58:08 2015 -0400
+++ b/liboctave/util/lo-array-gripes.cc	Wed Oct 21 15:23:08 2015 -0400
@@ -260,7 +260,7 @@
   const char* explain (void) const
   {
     static std::string expl;    // should probably be member variable, but
-                                // then explain() can't be const.
+                                // then explain can't be const.
 
     if (nd >= size.length ())   // if not an index slice
       {
@@ -308,7 +308,7 @@
     out_of_range e (buf, nd, dim);
 
     e.set_extent (ext);
-    dim_vector d (1,1,1,1,1,1,1);   // make explain() give extent not size
+    dim_vector d (1,1,1,1,1,1,1);   // make explain give extent not size
     e.set_size (d);
     throw e;
 }