# HG changeset patch # User Arun Giridhar # Date 1713032928 14400 # Node ID a258493e726a570a10caef1a1667289ab0b113fc # Parent ee94862503e2cca3287b7ea2db6c723df57ebce7 Backed out changeset c714266d9f0d diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/cellfun.cc --- a/libinterp/corefcn/cellfun.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/cellfun.cc Sat Apr 13 14:28:48 2024 -0400 @@ -1991,8 +1991,8 @@ { Cell retval; - if ((nd != 1 && nd != 2) || a.ndims () != 2) - error ("do_mat2cell_2d: A must be two-dimensional, and ND must be 1 or 2"); + panic_unless (nd == 1 || nd == 2); + panic_unless (a.ndims () == 2); if (mat2cell_mismatch (a.dims (), d, nd)) return retval; @@ -2049,8 +2049,7 @@ { Cell retval; - if (nd < 1) - error ("do_mat2cell_nd: ND must be at least 1"); + panic_unless (nd >= 1); if (mat2cell_mismatch (a.dims (), d, nd)) return retval; @@ -2133,8 +2132,7 @@ { Cell retval; - if (nd < 1) - error ("do_mat2cell: ND must be at least 1"); + panic_unless (nd >= 1); if (mat2cell_mismatch (a.dims (), d, nd)) return retval; diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/daspk.cc --- a/libinterp/corefcn/daspk.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/daspk.cc Sat Apr 13 14:28:48 2024 -0400 @@ -68,8 +68,7 @@ { ColumnVector retval; - if (x.numel () != xdot.numel ()) - error ("daspk_user_function: X and XDOT must have the same number of elements"); + panic_unless (x.numel () == xdot.numel ()); octave_value_list args; @@ -120,8 +119,7 @@ { Matrix retval; - if (x.numel () != xdot.numel ()) - error ("daspk_user_jacobian: X and XDOT must have the same number of elements"); + panic_unless (x.numel () == xdot.numel ()); octave_value_list args; diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/dasrt.cc --- a/libinterp/corefcn/dasrt.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/dasrt.cc Sat Apr 13 14:28:48 2024 -0400 @@ -69,8 +69,7 @@ { ColumnVector retval; - if (x.numel () != xdot.numel ()) - error ("dasrt_user_f: X and XDOT must have the same number of elements"); + panic_unless (x.numel () == xdot.numel ()); octave_value_list args; @@ -160,8 +159,7 @@ { Matrix retval; - if (x.numel () != xdot.numel ()) - error ("dasrt_user_j: X and XDOT must have the same number of elements"); + panic_unless (x.numel () == xdot.numel ()); octave_value_list args; diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/dassl.cc --- a/libinterp/corefcn/dassl.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/dassl.cc Sat Apr 13 14:28:48 2024 -0400 @@ -67,8 +67,7 @@ { ColumnVector retval; - if (x.numel () != xdot.numel ()) - error ("dassl_user_function: X and XDOT must have the same number of elements"); + panic_unless (x.numel () == xdot.numel ()); octave_value_list args; @@ -119,8 +118,7 @@ { Matrix retval; - if (x.numel () != xdot.numel ()) - error ("dassl_user_jacobian: X and XDOT must have the same number of elements"); + panic_unless (x.numel () == xdot.numel ()); octave_value_list args; diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/kron.cc --- a/libinterp/corefcn/kron.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/kron.cc Sat Apr 13 14:28:48 2024 -0400 @@ -55,8 +55,8 @@ static MArray kron (const MArray& a, const MArray& b) { - if (a.ndims () != 2 || b.ndims () != 2) - error ("kron: A and B must both be two-dimensional"); + panic_unless (a.ndims () == 2); + panic_unless (b.ndims () == 2); octave_idx_type nra = a.rows (); octave_idx_type nrb = b.rows (); @@ -86,8 +86,7 @@ static MArray kron (const MDiagArray2& a, const MArray& b) { - if (b.ndims () != 2) - error ("kron: B must be two-dimensional"); + panic_unless (b.ndims () == 2); octave_idx_type nra = a.rows (); octave_idx_type nrb = b.rows (); diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/pr-output.cc Sat Apr 13 14:28:48 2024 -0400 @@ -300,8 +300,7 @@ pr_max_internal (const MArray& m) { // We expect a 2-d array. - if (m.ndims () != 2) - error ("pr_max_internal: M must be two-dimensional"); + panic_unless (m.ndims () == 2); octave_idx_type nr = m.rows (); octave_idx_type nc = m.columns (); @@ -682,8 +681,7 @@ make_matrix_format (const MT& m) { // We expect a 2-d array. - if (m.ndims () != 2) - error ("make_matrix_format: M must be two-dimensional"); + panic_unless (m.ndims () == 2); if (free_format) return float_display_format (); @@ -1572,8 +1570,7 @@ print_empty_matrix (std::ostream& os, octave_idx_type nr, octave_idx_type nc, bool pr_as_read_syntax) { - if (nr && nc) - error ("print_empty_matrix: at least one of NR and NC must be zero"); + panic_unless (nr == 0 || nc == 0); if (pr_as_read_syntax) { @@ -1595,8 +1592,7 @@ print_empty_nd_array (std::ostream& os, const dim_vector& dims, bool pr_as_read_syntax) { - if (! dims.any_zero ()) - error ("print_empty_nd_array: at least one of DIMS must be zero"); + panic_unless (dims.any_zero ()); if (pr_as_read_syntax) os << "zeros (" << dims.str (',') << ')'; diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/schur.cc --- a/libinterp/corefcn/schur.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/schur.cc Sat Apr 13 14:28:48 2024 -0400 @@ -46,9 +46,7 @@ octave_value retval = a; octave_idx_type n = a.rows (); - - if (a.columns () != n) - error ("mark_upper_triangular: A must be a square matrix"); + panic_unless (a.columns () == n); const typename Matrix::element_type zero = typename Matrix::element_type (); diff -r ee94862503e2 -r a258493e726a libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Sat Apr 13 14:23:04 2024 +0200 +++ b/libinterp/corefcn/variables.cc Sat Apr 13 14:28:48 2024 -0400 @@ -768,8 +768,7 @@ int nargin = args.length (); - if (var >= nchoices) - error ("set_internal_variable: VAR too large for CHOICES"); + panic_unless (var < nchoices); if (nargout > 0 || nargin == 0) retval = choices[var];