changeset 33250:40fde86be9b0

replace calls to error_* with corresponding panic_* functions in libinterp Affected files: __isprimelarge__.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, graphics.cc, kron.cc, mex.cc, oct-map.cc, oct-stream.cc, pr-output.cc, schur.cc, variables.cc, and ops.h.
author John W. Eaton <jwe@octave.org>
date Mon, 25 Mar 2024 00:42:04 -0400
parents 06a308cae32c
children 93b856b2d87e
files libinterp/corefcn/__isprimelarge__.cc libinterp/corefcn/cellfun.cc libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/data.cc libinterp/corefcn/graphics.cc libinterp/corefcn/kron.cc libinterp/corefcn/mex.cc libinterp/corefcn/oct-map.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/pr-output.cc libinterp/corefcn/schur.cc libinterp/corefcn/variables.cc libinterp/operators/ops.h
diffstat 15 files changed, 37 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__isprimelarge__.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/__isprimelarge__.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -242,7 +242,7 @@
 
       if (g > 1)  // found GCD ==> exit loop properly
         {
-          error_unless (n % g == 0);  // theoretical possibility of GCD error
+          panic_unless (n % g == 0);  // theoretical possibility of GCD error
           return g;
         }
     }
--- a/libinterp/corefcn/cellfun.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/cellfun.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -1990,8 +1990,9 @@
 do_mat2cell_2d (const Array2D& a, const Array<octave_idx_type> *d, int nd)
 {
   Cell retval;
-  error_unless (nd == 1 || nd == 2);
-  error_unless (a.ndims () == 2);
+
+  panic_unless (nd == 1 || nd == 2);
+  panic_unless (a.ndims () == 2);
 
   if (mat2cell_mismatch (a.dims (), d, nd))
     return retval;
@@ -2047,7 +2048,8 @@
 do_mat2cell_nd (const ArrayND& a, const Array<octave_idx_type> *d, int nd)
 {
   Cell retval;
-  error_unless (nd >= 1);
+
+  panic_unless (nd >= 1);
 
   if (mat2cell_mismatch (a.dims (), d, nd))
     return retval;
@@ -2129,7 +2131,8 @@
 do_mat2cell (octave_value& a, const Array<octave_idx_type> *d, int nd)
 {
   Cell retval;
-  error_unless (nd >= 1);
+
+  panic_unless (nd >= 1);
 
   if (mat2cell_mismatch (a.dims (), d, nd))
     return retval;
--- a/libinterp/corefcn/daspk.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/daspk.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -68,7 +68,7 @@
 {
   ColumnVector retval;
 
-  error_unless (x.numel () == xdot.numel ());
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -119,7 +119,7 @@
 {
   Matrix retval;
 
-  error_unless (x.numel () == xdot.numel ());
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
--- a/libinterp/corefcn/dasrt.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/dasrt.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -69,7 +69,7 @@
 {
   ColumnVector retval;
 
-  error_unless (x.numel () == xdot.numel ());
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -159,7 +159,7 @@
 {
   Matrix retval;
 
-  error_unless (x.numel () == xdot.numel ());
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
--- a/libinterp/corefcn/dassl.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/dassl.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -67,7 +67,7 @@
 {
   ColumnVector retval;
 
-  error_unless (x.numel () == xdot.numel ());
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -118,7 +118,7 @@
 {
   Matrix retval;
 
-  error_unless (x.numel () == xdot.numel ());
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
--- a/libinterp/corefcn/data.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/data.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -8154,7 +8154,7 @@
           idx_vector col1 (':'), col2 (':'), sl1 (1, k), sl2 (0, k-1);
           retval = SparseT (retval.index (col1, sl1))
                    - SparseT (retval.index (col2, sl2));
-          error_unless (retval.columns () == k-1);
+          panic_unless (retval.columns () == k-1);
           order--;
           k--;
         }
@@ -8167,7 +8167,7 @@
           idx_vector col1 (':'), col2 (':'), sl1 (1, k), sl2 (0, k-1);
           retval = SparseT (retval.index (sl1, col1))
                    - SparseT (retval.index (sl2, col2));
-          error_unless (retval.rows () == k-1);
+          panic_unless (retval.rows () == k-1);
           order--;
           k--;
         }
--- a/libinterp/corefcn/graphics.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/graphics.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -5310,10 +5310,10 @@
   // Including ones we do don't implement?
 
   // FIXME: This function is probably never called without mode == "reset".
-  //        Verify this is the case with error_unless() (1/6/2017).
+  //        Verify this is the case with panic_unless() (1/6/2017).
   //        If there are reports of problems then figure out what code is
   //        calling it with the mode set to something else.
-  error_unless (mode == "reset");
+  panic_unless (mode == "reset");
 
   Matrix tlim (1, 2, 0.0);
   tlim(1) = 1;
--- a/libinterp/corefcn/kron.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/kron.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -55,8 +55,8 @@
 static MArray<T>
 kron (const MArray<R>& a, const MArray<T>& b)
 {
-  error_unless (a.ndims () == 2);
-  error_unless (b.ndims () == 2);
+  panic_unless (a.ndims () == 2);
+  panic_unless (b.ndims () == 2);
 
   octave_idx_type nra = a.rows ();
   octave_idx_type nrb = b.rows ();
@@ -86,7 +86,7 @@
 static MArray<T>
 kron (const MDiagArray2<R>& a, const MArray<T>& b)
 {
-  error_unless (b.ndims () == 2);
+  panic_unless (b.ndims () == 2);
 
   octave_idx_type nra = a.rows ();
   octave_idx_type nrb = b.rows ();
--- a/libinterp/corefcn/mex.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/mex.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -467,7 +467,8 @@
     mxArray *retval = m_val.as_mxArray (m_interleaved);
 
     // RETVAL is assumed to be an mxArray_matlab object.  Should we
-    // error_unless that condition here?
+    // panic_unless that condition here or just check and throw an
+    // error?
 
     if (retval)
       {
--- a/libinterp/corefcn/oct-map.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/oct-map.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -612,7 +612,7 @@
   for (octave_idx_type j = 0; j < nf; j++)
     {
       retval.m_vals.push_back (Cell (rd));
-      error_unless (retval.m_vals[j].numel () == n);
+      panic_unless (retval.m_vals[j].numel () == n);
       for (octave_idx_type i = 0; i < n; i++)
         retval.m_vals[j].xelem (i) = map_list[i].m_vals[j];
     }
@@ -1033,7 +1033,7 @@
           error (ee, "incompatible fields in struct assignment");
         }
 
-      error_unless (rhs1.m_keys.is_same (m_keys));
+      panic_unless (rhs1.m_keys.is_same (m_keys));
       assign (i, rhs1);
     }
 }
@@ -1081,7 +1081,7 @@
           error (ee, "incompatible fields in struct assignment");
         }
 
-      error_unless (rhs1.m_keys.is_same (m_keys));
+      panic_unless (rhs1.m_keys.is_same (m_keys));
       assign (i, j, rhs1);
     }
 }
@@ -1129,7 +1129,7 @@
           error (ee, "incompatible fields in struct assignment");
         }
 
-      error_unless (rhs1.m_keys.is_same (m_keys));
+      panic_unless (rhs1.m_keys.is_same (m_keys));
       assign (ia, rhs1);
     }
 }
--- a/libinterp/corefcn/oct-stream.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/oct-stream.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -6678,7 +6678,7 @@
   std::ptrdiff_t input_buf_size
     = static_cast<std::ptrdiff_t> (input_buf_elts) * input_elt_size;
 
-  error_if (input_buf_size < 0);
+  panic_if (input_buf_size < 0);
 
   // Must also work and return correct type object for 0 elements to read.
   std::istream *isp = input_stream ();
--- a/libinterp/corefcn/pr-output.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/pr-output.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -300,7 +300,7 @@
 pr_max_internal (const MArray<T>& m)
 {
   // We expect a 2-d array.
-  error_unless (m.ndims () == 2);
+  panic_unless (m.ndims () == 2);
 
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.columns ();
@@ -680,7 +680,8 @@
 static inline float_display_format
 make_matrix_format (const MT& m)
 {
-  error_unless (m.ndims () == 2);
+  // We expect a 2-d array.
+  panic_unless (m.ndims () == 2);
 
   if (free_format)
     return float_display_format ();
@@ -1569,7 +1570,7 @@
 print_empty_matrix (std::ostream& os, octave_idx_type nr, octave_idx_type nc,
                     bool pr_as_read_syntax)
 {
-  error_unless (nr == 0 || nc == 0);
+  panic_unless (nr == 0 || nc == 0);
 
   if (pr_as_read_syntax)
     {
@@ -1591,7 +1592,7 @@
 print_empty_nd_array (std::ostream& os, const dim_vector& dims,
                       bool pr_as_read_syntax)
 {
-  error_unless (dims.any_zero ());
+  panic_unless (dims.any_zero ());
 
   if (pr_as_read_syntax)
     os << "zeros (" << dims.str (',') << ')';
--- a/libinterp/corefcn/schur.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/schur.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -46,7 +46,7 @@
   octave_value retval = a;
 
   octave_idx_type n = a.rows ();
-  error_unless (a.columns () == n);
+  panic_unless (a.columns () == n);
 
   const typename Matrix::element_type zero = typename Matrix::element_type ();
 
--- a/libinterp/corefcn/variables.cc	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/corefcn/variables.cc	Mon Mar 25 00:42:04 2024 -0400
@@ -768,7 +768,7 @@
 
   int nargin = args.length ();
 
-  error_unless (var < nchoices);
+  panic_unless (var < nchoices);
 
   if (nargout > 0 || nargin == 0)
     retval = choices[var];
--- a/libinterp/operators/ops.h	Sun Mar 24 18:12:06 2024 -0400
+++ b/libinterp/operators/ops.h	Mon Mar 25 00:42:04 2024 -0400
@@ -147,7 +147,7 @@
     OCTAVE_CAST_BASE_VALUE (CONCAT2 (octave_, t1)&, v1, a1);            \
     OCTAVE_CAST_BASE_VALUE (const CONCAT2 (octave_, t2)&, v2, a2);      \
                                                                         \
-    error_unless (idx.empty ());                                        \
+    panic_unless (idx.empty ());                                        \
     v1.matrix_ref () op v2.CONCAT2 (f, _value) ();                      \
                                                                         \
     return octave_value ();                                             \
@@ -162,7 +162,7 @@
     OCTAVE_CAST_BASE_VALUE (CONCAT2 (octave_, t1)&, v1, a1);            \
     OCTAVE_CAST_BASE_VALUE (const CONCAT2 (octave_, t2)&, v2, a2);      \
                                                                         \
-    error_unless (idx.empty ());                                        \
+    panic_unless (idx.empty ());                                        \
     fnop (v1.matrix_ref (), v2.CONCAT2 (f, _value) ());                 \
                                                                         \
     return octave_value ();                                             \