changeset 23448:e1c02e7126a9

avoid calling abort if possible; include cstdlib for declaration if needed * Sparse.cc, DASPK.cc, svd.cc, data-conv.cc, lo-utils.cc: Throw error instead of calling abort. * error.cc, lo-ieee.cc: Include cstdlib for abort declaration.
author John W. Eaton <jwe@octave.org>
date Thu, 27 Apr 2017 15:26:32 -0400
parents db1fdf4384dd
children c763214a8260
files libinterp/corefcn/error.cc liboctave/array/Sparse.cc liboctave/numeric/DASPK.cc liboctave/numeric/svd.cc liboctave/util/data-conv.cc liboctave/util/lo-ieee.cc liboctave/util/lo-utils.cc
diffstat 7 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc	Thu Apr 27 10:04:31 2017 -0700
+++ b/libinterp/corefcn/error.cc	Thu Apr 27 15:26:32 2017 -0400
@@ -25,6 +25,7 @@
 #endif
 
 #include <cstdarg>
+#include <cstdlib>
 #include <cstring>
 
 #include <iomanip>
--- a/liboctave/array/Sparse.cc	Thu Apr 27 10:04:31 2017 -0700
+++ b/liboctave/array/Sparse.cc	Thu Apr 27 15:26:32 2017 -0400
@@ -2250,7 +2250,8 @@
   else if (mode == DESCENDING)
     lsort.set_compare (sparse_descending_compare<T>);
   else
-    abort ();
+    (*current_liboctave_error_handler)
+      ("Sparse<T>::sort: invalid MODE");
 
   T *v = m.data ();
   octave_idx_type *mcidx = m.cidx ();
@@ -2319,7 +2320,8 @@
   else if (mode == DESCENDING)
     indexed_sort.set_compare (sparse_descending_compare<T>);
   else
-    abort ();
+    (*current_liboctave_error_handler)
+      ("Sparse<T>::sort: invalid MODE");
 
   T *v = m.data ();
   octave_idx_type *mcidx = m.cidx ();
--- a/liboctave/numeric/DASPK.cc	Thu Apr 27 10:04:31 2017 -0700
+++ b/liboctave/numeric/DASPK.cc	Thu Apr 27 15:26:32 2017 -0400
@@ -110,7 +110,7 @@
 {
   BEGIN_INTERRUPT_WITH_EXCEPTIONS;
 
-  abort ();
+  (*current_liboctave_error_handler) ("daspk: PSOL is not implemented");
 
   END_INTERRUPT_WITH_EXCEPTIONS;
 
@@ -360,7 +360,8 @@
                   else if (eiq == 1 || eiq == 3)
                     lid = 40 + n;
                   else
-                    abort ();
+                    (*current_liboctave_error_handler)
+                      ("daspk: invalid value for eiq: %d", eiq);
 
                   for (F77_INT i = 0; i < n; i++)
                     iwork(lid+i) = av(i) ? -1 : 1;
@@ -404,7 +405,8 @@
               else if (eiq == 1 || eiq == 3)
                 lid = 40 + n;
               else
-                abort ();
+                (*current_liboctave_error_handler)
+                  ("daspk: invalid value for eiq: %d", eiq);
 
               for (F77_INT i = 0; i < n; i++)
                 iwork(lid+i) = av(i) ? -1 : 1;
--- a/liboctave/numeric/svd.cc	Thu Apr 27 10:04:31 2017 -0700
+++ b/liboctave/numeric/svd.cc	Thu Apr 27 15:26:32 2017 -0400
@@ -387,7 +387,7 @@
                  work, lwork, iwork.data (), info);
         }
       else
-        abort ();
+        (*current_liboctave_error_handler) ("svd: unknown driver");
 
       if (! (jobv == 'N' || jobv == 'O'))
         right_sm = right_sm.hermitian ();
--- a/liboctave/util/data-conv.cc	Thu Apr 27 10:04:31 2017 -0700
+++ b/liboctave/util/data-conv.cc	Thu Apr 27 15:26:32 2017 -0400
@@ -272,7 +272,8 @@
 
     case oct_data_conv::dt_unknown:
     default:
-      abort ();
+      (*current_liboctave_error_handler)
+        ("oct_data_conv::data_type_size: unknown data type");
       break;
     }
 
--- a/liboctave/util/lo-ieee.cc	Thu Apr 27 10:04:31 2017 -0700
+++ b/liboctave/util/lo-ieee.cc	Thu Apr 27 15:26:32 2017 -0400
@@ -25,6 +25,7 @@
 #endif
 
 #include <cmath>
+#include <cstdlib>
 
 #include <limits>
 
@@ -267,9 +268,12 @@
           // experiment with building Octave on a system without IEEE
           // floating point should be capable of removing this check and
           // the configure test.
-          // FIXME: Should this be a warning so that abort is reached?
+          //
+          // If the the error handler returns, then we'll abort.
+
           (*current_liboctave_error_handler)
             ("lo_ieee_init: floating point format is not IEEE!  Maybe DLAMCH is miscompiled, or you are using some strange system without IEEE floating point math?");
+
           abort ();
         }
 
--- a/liboctave/util/lo-utils.cc	Thu Apr 27 10:04:31 2017 -0700
+++ b/liboctave/util/lo-utils.cc	Thu Apr 27 15:26:32 2017 -0400
@@ -248,7 +248,7 @@
       break;
 
     default:
-      abort ();
+      (*current_liboctave_error_handler) ("read_inf_nan_na: invalid character '%c'");
     }
 
   return val;