# HG changeset patch # User John W. Eaton # Date 1444087776 14400 # Node ID f90c8372b7bab3bff3a6908cf43976eefdbf93cb # Parent b7ac1e94266ecc1902f072c09e18846b06e557e5 eliminate many more simple uses of error_state * Cell.cc, __ichol__.cc, __ilu__.cc, balance.cc, bsxfun.cc, colloc.cc, det.cc, dlmread.cc, dynamic-ld.cc, eig.cc, fft.cc, fft2.cc, fftn.cc, gcd.cc, getgrent.cc, getpwent.cc, givens.cc, hess.cc, input.cc, levenshtein.cc, load-path.cc, lookup.cc, ls-mat-ascii.cc, ls-mat4.cc, lsode.cc, lu.cc, max.cc, md5sum.cc, mex.cc, pager.cc, pinv.cc, pr-output.cc, qz.cc, schur.cc, sparse.cc, sqrtm.cc, str2double.cc, strfns.cc, sub2ind.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc, amd.cc, audiodevinfo.cc, dmperm.cc, fftw.cc, symrcm.cc, ov-base-diag.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-sparse.cc, ov-builtin.cc, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-lazy-idx.cc, ov-mex-fcn.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, op-bm-b.cc, op-bm-bm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-str-m.cc, op-str-s.cc, oct-parse.in.yy, pt-cbinop.cc, pt-colon.cc, pt-decl.cc, pt-exp.cc, pt-id.cc, pt-misc.cc, pt-select.cc, pt-unop.cc: Eliminate simple uses of error_state. diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/Cell.cc --- a/libinterp/corefcn/Cell.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/Cell.cc Mon Oct 05 19:29:36 2015 -0400 @@ -180,8 +180,7 @@ { idx_vector i = idx_arg(0).index_vector (); - if (! error_state) - retval = Array::index (i, resize_ok, Matrix ()); + retval = Array::index (i, resize_ok, Matrix ()); } break; @@ -189,14 +188,11 @@ { idx_vector i = idx_arg(0).index_vector (); + k = 1; + idx_vector j = idx_arg(1).index_vector (); + if (! error_state) - { - k = 1; - idx_vector j = idx_arg(1).index_vector (); - - if (! error_state) - retval = Array::index (i, j, resize_ok, Matrix ()); - } + retval = Array::index (i, j, resize_ok, Matrix ()); } break; @@ -205,14 +201,9 @@ Array iv (dim_vector (n, 1)); for (k = 0; k < n; k++) - { - iv(k) = idx_arg(k).index_vector (); + iv(k) = idx_arg(k).index_vector (); - if (error_state) - break; - } - if (!error_state) - retval = Array::index (iv, resize_ok, Matrix ()); + retval = Array::index (iv, resize_ok, Matrix ()); } break; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/__ichol__.cc --- a/libinterp/corefcn/__ichol__.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/__ichol__.cc Mon Oct 05 19:29:36 2015 -0400 @@ -221,8 +221,8 @@ sm = feval ("tril", param_list)(0).sparse_matrix_value (); ichol_0 (sm, michol); - if (! error_state) - retval(0) = sm; + + retval(0) = sm; } else { @@ -231,8 +231,8 @@ sm = feval ("tril", param_list)(0).sparse_complex_matrix_value (); ichol_0 (sm, michol); - if (! error_state) - retval(0) = sm; + + retval(0) = sm; } return retval; @@ -428,17 +428,16 @@ } } - if (! error_state) + // Build the output matrices + L = octave_matrix_t (n, n, total_len); + + for (i = 0; i <= n; i++) + L.cidx (i) = cidx_l[i]; + + for (i = 0; i < total_len; i++) { - // Build the output matrices - L = octave_matrix_t (n, n, total_len); - for (i = 0; i <= n; i++) - L.cidx (i) = cidx_l[i]; - for (i = 0; i < total_len; i++) - { - L.ridx (i) = ridx_l[i]; - L.data (i) = data_l[i]; - } + L.ridx (i) = ridx_l[i]; + L.data (i) = data_l[i]; } } @@ -486,8 +485,8 @@ ichol_t (sm_l, L, cols_norm.fortran_vec (), droptol, michol); - if (! error_state) - retval(0) = L; + + retval(0) = L; } else { @@ -505,8 +504,8 @@ Complex, ichol_mult_complex, ichol_checkpivot_complex> (sm_l, L, cols_norm.fortran_vec (), Complex (droptol), michol); - if (! error_state) - retval(0) = L; + + retval(0) = L; } return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/__ilu__.cc --- a/libinterp/corefcn/__ilu__.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/__ilu__.cc Mon Oct 05 19:29:36 2015 -0400 @@ -153,34 +153,28 @@ { SparseMatrix sm = args(0).sparse_matrix_value (); ilu_0 (sm, milu); - if (!error_state) - { - param_list.append (sm); - retval(1) = feval ("triu", param_list)(0).sparse_matrix_value (); - SparseMatrix eye = - feval ("speye", octave_value_list ( - octave_value (sm.cols ())))(0).sparse_matrix_value (); - param_list.append (-1); - retval(0) = eye + - feval ("tril", param_list)(0).sparse_matrix_value (); - } + + param_list.append (sm); + retval(1) = feval ("triu", param_list)(0).sparse_matrix_value (); + SparseMatrix eye = + feval ("speye", octave_value_list (octave_value (sm.cols ())))(0).sparse_matrix_value (); + param_list.append (-1); + retval(0) = eye + + feval ("tril", param_list)(0).sparse_matrix_value (); } else { SparseComplexMatrix sm = args(0).sparse_complex_matrix_value (); ilu_0 (sm, milu); - if (! error_state) - { - param_list.append (sm); - retval(1) = - feval ("triu", param_list)(0).sparse_complex_matrix_value (); - SparseComplexMatrix eye = - feval ("speye", octave_value_list ( - octave_value (sm.cols ())))(0).sparse_complex_matrix_value (); - param_list.append (-1); - retval(0) = - eye + feval ("tril", param_list)(0).sparse_complex_matrix_value (); - } + + param_list.append (sm); + retval(1) = + feval ("triu", param_list)(0).sparse_complex_matrix_value (); + SparseComplexMatrix eye = + feval ("speye", octave_value_list (octave_value (sm.cols ())))(0).sparse_complex_matrix_value (); + param_list.append (-1); + retval(0) = + eye + feval ("tril", param_list)(0).sparse_complex_matrix_value (); } return retval; @@ -446,27 +440,29 @@ } } - if (! error_state) + // Build the output matrices + L = octave_matrix_t (n, n, total_len_l); + U = octave_matrix_t (n, n, total_len_u); + + for (i = 0; i <= n; i++) + L.cidx (i) = cidx_l[i]; + + for (i = 0; i < total_len_l; i++) { - // Build the output matrices - L = octave_matrix_t (n, n, total_len_l); - U = octave_matrix_t (n, n, total_len_u); - for (i = 0; i <= n; i++) - L.cidx (i) = cidx_l[i]; - for (i = 0; i < total_len_l; i++) - { - L.ridx (i) = ridx_l[i]; - L.data (i) = data_l[i]; - } - for (i = 0; i <= n; i++) - U.cidx (i) = cidx_u[i]; - for (i = 0; i < total_len_u; i++) - { - U.ridx (i) = ridx_u[i]; - U.data (i) = data_u[i]; - } - U = U.transpose (); + L.ridx (i) = ridx_l[i]; + L.data (i) = data_l[i]; } + + for (i = 0; i <= n; i++) + U.cidx (i) = cidx_u[i]; + + for (i = 0; i < total_len_u; i++) + { + U.ridx (i) = ridx_u[i]; + U.data (i) = data_u[i]; + } + + U = U.transpose (); } DEFUN (__iluc__, args, nargout, @@ -515,14 +511,11 @@ cols_norm.fortran_vec (), rows_norm.fortran_vec (), droptol, milu); - if (! error_state) - { - param_list.append (octave_value (L.cols ())); - SparseMatrix eye = - feval ("speye", param_list)(0).sparse_matrix_value (); - retval(1) = U; - retval(0) = L + eye; - } + param_list.append (octave_value (L.cols ())); + SparseMatrix eye = + feval ("speye", param_list)(0).sparse_matrix_value (); + retval(1) = U; + retval(0) = L + eye; } else { @@ -543,14 +536,12 @@ ilu_crout < SparseComplexMatrix, Complex > (sm_l, sm_u, L, U, cols_norm.fortran_vec () , rows_norm.fortran_vec (), Complex (droptol), milu); - if (! error_state) - { - param_list.append (octave_value (L.cols ())); - SparseComplexMatrix eye = - feval ("speye", param_list)(0).sparse_complex_matrix_value (); - retval(1) = U; - retval(0) = L + eye; - } + + param_list.append (octave_value (L.cols ())); + SparseComplexMatrix eye = + feval ("speye", param_list)(0).sparse_complex_matrix_value (); + retval(1) = U; + retval(0) = L + eye; } return retval; @@ -873,81 +864,78 @@ iw_u.clear (); } - if (! error_state) + octave_matrix_t *L_ptr; + octave_matrix_t *U_ptr; + octave_matrix_t diag (n, n, n); + + // L and U are interchanged if milu = 'row'. It is a matter + // of nomenclature to re-use code with both IKJ and JKI + // versions of the algorithm. + if (opt == ROW) { - octave_matrix_t *L_ptr; - octave_matrix_t *U_ptr; - octave_matrix_t diag (n, n, n); + L_ptr = &U; + U_ptr = &L; + L = octave_matrix_t (n, n, total_len_u - n); + U = octave_matrix_t (n, n, total_len_l); + } + else + { + L_ptr = &L; + U_ptr = &U; + L = octave_matrix_t (n, n, total_len_l); + U = octave_matrix_t (n, n, total_len_u); + } - // L and U are interchanged if milu = 'row'. It is a matter - // of nomenclature to re-use code with both IKJ and JKI - // versions of the algorithm. + for (i = 0; i <= n; i++) + { + L_ptr->cidx (i) = cidx_l[i]; + U_ptr->cidx (i) = cidx_u[i]; if (opt == ROW) - { - L_ptr = &U; - U_ptr = &L; - L = octave_matrix_t (n, n, total_len_u - n); - U = octave_matrix_t (n, n, total_len_l); - } - else - { - L_ptr = &L; - U_ptr = &U; - L = octave_matrix_t (n, n, total_len_l); - U = octave_matrix_t (n, n, total_len_u); - } + U_ptr->cidx (i) -= i; + } - for (i = 0; i <= n; i++) - { - L_ptr->cidx (i) = cidx_l[i]; - U_ptr->cidx (i) = cidx_u[i]; - if (opt == ROW) - U_ptr->cidx (i) -= i; - } - - for (i = 0; i < n; i++) - { - if (opt == ROW) - diag.elem (i,i) = data_u[uptr[i]]; - j = cidx_l[i]; + for (i = 0; i < n; i++) + { + if (opt == ROW) + diag.elem (i,i) = data_u[uptr[i]]; + j = cidx_l[i]; - while (j < cidx_l[i+1]) + while (j < cidx_l[i+1]) + { + L_ptr->ridx (j) = ridx_l[j]; + L_ptr->data (j) = data_l[j]; + j++; + } + j = cidx_u[i]; + + while (j < cidx_u[i+1]) + { + c = j; + if (opt == ROW) { - L_ptr->ridx (j) = ridx_l[j]; - L_ptr->data (j) = data_l[j]; - j++; - } - j = cidx_u[i]; - - while (j < cidx_u[i+1]) - { - c = j; - if (opt == ROW) + // The diagonal is removed from L if milu = 'row'. + // That is because is convenient to have it inside + // the L part to carry out the process. + if (ridx_u[j] == i) { - // The diagonal is removed from L if milu = 'row'. - // That is because is convenient to have it inside - // the L part to carry out the process. - if (ridx_u[j] == i) - { - j++; - continue; - } - else - c -= i; + j++; + continue; } - U_ptr->data (c) = data_u[j]; - U_ptr->ridx (c) = ridx_u[j]; - j++; + else + c -= i; } + U_ptr->data (c) = data_u[j]; + U_ptr->ridx (c) = ridx_u[j]; + j++; } + } - if (opt == ROW) - { - U = U.transpose (); - // The diagonal, conveniently permuted is added to U - U += diag.index (idx_vector::colon, perm_vec); - L = L.transpose (); - } + if (opt == ROW) + { + U = U.transpose (); + // The diagonal, conveniently permuted is added to U + U += diag.index (idx_vector::colon, perm_vec); + L = L.transpose (); } } @@ -1010,35 +998,32 @@ ilu_tp (sm, L, U, nnz_u, nnz_l, rc_norm.fortran_vec (), perm, droptol, thresh, milu, udiag); - if (! error_state) + param_list.append (octave_value (L.cols ())); + SparseMatrix eye = + feval ("speye", param_list)(0).sparse_matrix_value (); + if (milu == "row") { - param_list.append (octave_value (L.cols ())); - SparseMatrix eye = - feval ("speye", param_list)(0).sparse_matrix_value (); - if (milu == "row") + if (nargout == 3) { - if (nargout == 3) - { - retval(2) = eye.index (idx_vector::colon, perm); - retval(1) = U.index (idx_vector::colon, perm); - } - else if (nargout == 2) - retval(1) = U; - retval(0) = L + eye; + retval(2) = eye.index (idx_vector::colon, perm); + retval(1) = U.index (idx_vector::colon, perm); + } + else if (nargout == 2) + retval(1) = U; + retval(0) = L + eye; + } + else + { + if (nargout == 3) + { + retval(2) = eye.index (perm, idx_vector::colon); + retval(1) = U; + retval(0) = L.index (perm, idx_vector::colon) + eye; } else { - if (nargout == 3) - { - retval(2) = eye.index (perm, idx_vector::colon); - retval(1) = U; - retval(0) = L.index (perm, idx_vector::colon) + eye; - } - else - { - retval(1) = U; - retval(0) = L + eye.index (perm, idx_vector::colon); - } + retval(1) = U; + retval(0) = L + eye.index (perm, idx_vector::colon); } } } @@ -1065,35 +1050,32 @@ (sm, L, U, nnz_u, nnz_l, rc_norm.fortran_vec (), perm, Complex (droptol), Complex (thresh), milu, udiag); - if (! error_state) + param_list.append (octave_value (L.cols ())); + SparseComplexMatrix eye = + feval ("speye", param_list)(0).sparse_complex_matrix_value (); + if (milu == "row") { - param_list.append (octave_value (L.cols ())); - SparseComplexMatrix eye = - feval ("speye", param_list)(0).sparse_complex_matrix_value (); - if (milu == "row") + if (nargout == 3) { - if (nargout == 3) - { - retval(2) = eye.index (idx_vector::colon, perm); - retval(1) = U.index (idx_vector::colon, perm); - } - else if (nargout == 2) - retval(1) = U; - retval(0) = L + eye; + retval(2) = eye.index (idx_vector::colon, perm); + retval(1) = U.index (idx_vector::colon, perm); + } + else if (nargout == 2) + retval(1) = U; + retval(0) = L + eye; + } + else + { + if (nargout == 3) + { + retval(2) = eye.index (perm, idx_vector::colon); + retval(1) = U; + retval(0) = L.index (perm, idx_vector::colon) + eye; } else { - if (nargout == 3) - { - retval(2) = eye.index (perm, idx_vector::colon); - retval(1) = U; - retval(0) = L.index (perm, idx_vector::colon) + eye; - } - else - { - retval(1) = U; - retval(0) = L + eye.index (perm, idx_vector::colon); - } + retval(1) = U; + retval(0) = L + eye.index (perm, idx_vector::colon); } } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/balance.cc --- a/libinterp/corefcn/balance.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/balance.cc Mon Oct 05 19:29:36 2015 -0400 @@ -140,9 +140,6 @@ aa = args(0).matrix_value (); } - if (error_state) - return retval; - // Treat AEP/GEP cases. if (AEPcase) { diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/bsxfun.cc --- a/libinterp/corefcn/bsxfun.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/bsxfun.cc Mon Oct 05 19:29:36 2015 -0400 @@ -374,7 +374,7 @@ } } - if (! error_state && retval.empty ()) + if (retval.empty ()) { dim_vector dva = A.dims (); octave_idx_type nda = dva.length (); @@ -397,271 +397,262 @@ break; } - if (!error_state) - { - // Find the size of the output - dim_vector dvc; - dvc.resize (nd); + // Find the size of the output + dim_vector dvc; + dvc.resize (nd); - for (octave_idx_type i = 0; i < nd; i++) - dvc(i) = (dva(i) < 1 ? dva(i) - : (dvb(i) < 1 ? dvb(i) - : (dva(i) > dvb(i) - ? dva(i) : dvb(i)))); + for (octave_idx_type i = 0; i < nd; i++) + dvc(i) = (dva(i) < 1 ? dva(i) + : (dvb(i) < 1 ? dvb(i) + : (dva(i) > dvb(i) + ? dva(i) : dvb(i)))); - if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1) - { - octave_value_list inputs; - inputs (0) = A; - inputs (1) = B; - retval = func.do_multi_index_op (1, inputs); - } - else if (dvc.numel () < 1) - { - octave_value_list inputs; - inputs (0) = A.resize (dvc); - inputs (1) = B.resize (dvc); - retval = func.do_multi_index_op (1, inputs); - } - else - { - octave_idx_type ncount = 1; - for (octave_idx_type i = 1; i < nd; i++) - ncount *= dvc(i); + if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1) + { + octave_value_list inputs; + inputs (0) = A; + inputs (1) = B; + retval = func.do_multi_index_op (1, inputs); + } + else if (dvc.numel () < 1) + { + octave_value_list inputs; + inputs (0) = A.resize (dvc); + inputs (1) = B.resize (dvc); + retval = func.do_multi_index_op (1, inputs); + } + else + { + octave_idx_type ncount = 1; + for (octave_idx_type i = 1; i < nd; i++) + ncount *= dvc(i); #define BSXDEF(T) \ - T result_ ## T; \ - bool have_ ## T = false; + T result_ ## T; \ + bool have_ ## T = false; - BSXDEF(NDArray); - BSXDEF(ComplexNDArray); - BSXDEF(FloatNDArray); - BSXDEF(FloatComplexNDArray); - BSXDEF(boolNDArray); - BSXDEF(int8NDArray); - BSXDEF(int16NDArray); - BSXDEF(int32NDArray); - BSXDEF(int64NDArray); - BSXDEF(uint8NDArray); - BSXDEF(uint16NDArray); - BSXDEF(uint32NDArray); - BSXDEF(uint64NDArray); + BSXDEF(NDArray); + BSXDEF(ComplexNDArray); + BSXDEF(FloatNDArray); + BSXDEF(FloatComplexNDArray); + BSXDEF(boolNDArray); + BSXDEF(int8NDArray); + BSXDEF(int16NDArray); + BSXDEF(int32NDArray); + BSXDEF(int64NDArray); + BSXDEF(uint8NDArray); + BSXDEF(uint16NDArray); + BSXDEF(uint32NDArray); + BSXDEF(uint64NDArray); - octave_value Ac ; - octave_value_list idxA; - octave_value Bc; - octave_value_list idxB; - octave_value C; - octave_value_list inputs; - Array ra_idx (dim_vector (dvc.length (), 1), 0); + octave_value Ac ; + octave_value_list idxA; + octave_value Bc; + octave_value_list idxB; + octave_value C; + octave_value_list inputs; + Array ra_idx (dim_vector (dvc.length (), 1), 0); - for (octave_idx_type i = 0; i < ncount; i++) - { - if (maybe_update_column (Ac, A, dva, dvc, i, idxA)) - inputs (0) = Ac; + for (octave_idx_type i = 0; i < ncount; i++) + { + if (maybe_update_column (Ac, A, dva, dvc, i, idxA)) + inputs (0) = Ac; - if (maybe_update_column (Bc, B, dvb, dvc, i, idxB)) - inputs (1) = Bc; + if (maybe_update_column (Bc, B, dvb, dvc, i, idxB)) + inputs (1) = Bc; - octave_value_list tmp = func.do_multi_index_op (1, - inputs); - - if (error_state) - break; + octave_value_list tmp = func.do_multi_index_op (1, + inputs); #define BSXINIT(T, CLS, EXTRACTOR) \ - (result_type == CLS) \ - { \ - have_ ## T = true; \ - result_ ## T = \ - tmp (0). EXTRACTOR ## _array_value (); \ - result_ ## T .resize (dvc); \ - } + (result_type == CLS) \ + { \ + have_ ## T = true; \ + result_ ## T = tmp (0). EXTRACTOR ## _array_value (); \ + result_ ## T .resize (dvc); \ + } - if (i == 0) + if (i == 0) + { + if (! tmp(0).is_sparse_type ()) { - if (! tmp(0).is_sparse_type ()) + std::string result_type = tmp(0).class_name (); + if (result_type == "double") { - std::string result_type = tmp(0).class_name (); - if (result_type == "double") + if (tmp(0).is_real_type ()) { - if (tmp(0).is_real_type ()) - { - have_NDArray = true; - result_NDArray = tmp(0).array_value (); - result_NDArray.resize (dvc); - } - else - { - have_ComplexNDArray = true; - result_ComplexNDArray = - tmp(0).complex_array_value (); - result_ComplexNDArray.resize (dvc); - } + have_NDArray = true; + result_NDArray = tmp(0).array_value (); + result_NDArray.resize (dvc); } - else if (result_type == "single") + else { - if (tmp(0).is_real_type ()) - { - have_FloatNDArray = true; - result_FloatNDArray - = tmp(0).float_array_value (); - result_FloatNDArray.resize (dvc); - } - else - { - have_ComplexNDArray = true; - result_ComplexNDArray = - tmp(0).complex_array_value (); - result_ComplexNDArray.resize (dvc); - } + have_ComplexNDArray = true; + result_ComplexNDArray = + tmp(0).complex_array_value (); + result_ComplexNDArray.resize (dvc); } - else if BSXINIT(boolNDArray, "logical", bool) - else if BSXINIT(int8NDArray, "int8", int8) - else if BSXINIT(int16NDArray, "int16", int16) - else if BSXINIT(int32NDArray, "int32", int32) - else if BSXINIT(int64NDArray, "int64", int64) - else if BSXINIT(uint8NDArray, "uint8", uint8) - else if BSXINIT(uint16NDArray, "uint16", uint16) - else if BSXINIT(uint32NDArray, "uint32", uint32) - else if BSXINIT(uint64NDArray, "uint64", uint64) + } + else if (result_type == "single") + { + if (tmp(0).is_real_type ()) + { + have_FloatNDArray = true; + result_FloatNDArray + = tmp(0).float_array_value (); + result_FloatNDArray.resize (dvc); + } else { - C = tmp (0); - C = C.resize (dvc); + have_ComplexNDArray = true; + result_ComplexNDArray = + tmp(0).complex_array_value (); + result_ComplexNDArray.resize (dvc); } } + else if BSXINIT(boolNDArray, "logical", bool) + else if BSXINIT(int8NDArray, "int8", int8) + else if BSXINIT(int16NDArray, "int16", int16) + else if BSXINIT(int32NDArray, "int32", int32) + else if BSXINIT(int64NDArray, "int64", int64) + else if BSXINIT(uint8NDArray, "uint8", uint8) + else if BSXINIT(uint16NDArray, "uint16", uint16) + else if BSXINIT(uint32NDArray, "uint32", uint32) + else if BSXINIT(uint64NDArray, "uint64", uint64) + else + { + C = tmp (0); + C = C.resize (dvc); + } } - else + } + else + { + update_index (ra_idx, dvc, i); + + if (have_FloatNDArray + || have_FloatComplexNDArray) { - update_index (ra_idx, dvc, i); - - if (have_FloatNDArray - || have_FloatComplexNDArray) + if (! tmp(0).is_float_type ()) { - if (! tmp(0).is_float_type ()) - { - if (have_FloatNDArray) - { - have_FloatNDArray = false; - C = result_FloatNDArray; - } - else - { - have_FloatComplexNDArray = false; - C = result_FloatComplexNDArray; - } - C = do_cat_op (C, tmp(0), ra_idx); - } - else if (tmp(0).is_double_type ()) + if (have_FloatNDArray) { - if (tmp(0).is_complex_type () - && have_FloatNDArray) - { - result_ComplexNDArray = - ComplexNDArray (result_FloatNDArray); - result_ComplexNDArray.insert - (tmp(0).complex_array_value (), ra_idx); - have_FloatComplexNDArray = false; - have_ComplexNDArray = true; - } - else - { - result_NDArray = - NDArray (result_FloatNDArray); - result_NDArray.insert - (tmp(0).array_value (), ra_idx); - have_FloatNDArray = false; - have_NDArray = true; - } + have_FloatNDArray = false; + C = result_FloatNDArray; } - else if (tmp(0).is_real_type ()) - result_FloatNDArray.insert - (tmp(0).float_array_value (), ra_idx); else { - result_FloatComplexNDArray = - FloatComplexNDArray (result_FloatNDArray); - result_FloatComplexNDArray.insert - (tmp(0).float_complex_array_value (), - ra_idx); + have_FloatComplexNDArray = false; + C = result_FloatComplexNDArray; + } + C = do_cat_op (C, tmp(0), ra_idx); + } + else if (tmp(0).is_double_type ()) + { + if (tmp(0).is_complex_type () + && have_FloatNDArray) + { + result_ComplexNDArray = + ComplexNDArray (result_FloatNDArray); + result_ComplexNDArray.insert + (tmp(0).complex_array_value (), ra_idx); + have_FloatComplexNDArray = false; + have_ComplexNDArray = true; + } + else + { + result_NDArray = + NDArray (result_FloatNDArray); + result_NDArray.insert + (tmp(0).array_value (), ra_idx); have_FloatNDArray = false; - have_FloatComplexNDArray = true; + have_NDArray = true; } } - else if (have_NDArray) + else if (tmp(0).is_real_type ()) + result_FloatNDArray.insert + (tmp(0).float_array_value (), ra_idx); + else + { + result_FloatComplexNDArray = + FloatComplexNDArray (result_FloatNDArray); + result_FloatComplexNDArray.insert + (tmp(0).float_complex_array_value (), + ra_idx); + have_FloatNDArray = false; + have_FloatComplexNDArray = true; + } + } + else if (have_NDArray) + { + if (! tmp(0).is_float_type ()) { - if (! tmp(0).is_float_type ()) - { - have_NDArray = false; - C = result_NDArray; - C = do_cat_op (C, tmp(0), ra_idx); - } - else if (tmp(0).is_real_type ()) - result_NDArray.insert (tmp(0).array_value (), - ra_idx); - else - { - result_ComplexNDArray = - ComplexNDArray (result_NDArray); - result_ComplexNDArray.insert - (tmp(0).complex_array_value (), ra_idx); - have_NDArray = false; - have_ComplexNDArray = true; - } + have_NDArray = false; + C = result_NDArray; + C = do_cat_op (C, tmp(0), ra_idx); } + else if (tmp(0).is_real_type ()) + result_NDArray.insert (tmp(0).array_value (), + ra_idx); + else + { + result_ComplexNDArray = + ComplexNDArray (result_NDArray); + result_ComplexNDArray.insert + (tmp(0).complex_array_value (), ra_idx); + have_NDArray = false; + have_ComplexNDArray = true; + } + } #define BSXLOOP(T, CLS, EXTRACTOR) \ - (have_ ## T) \ - { \ - if (tmp (0).class_name () != CLS) \ - { \ - have_ ## T = false; \ - C = result_ ## T; \ - C = do_cat_op (C, tmp (0), ra_idx); \ - } \ - else \ - result_ ## T .insert \ - (tmp(0). EXTRACTOR ## _array_value (), \ - ra_idx); \ - } + (have_ ## T) \ + { \ + if (tmp (0).class_name () != CLS) \ + { \ + have_ ## T = false; \ + C = result_ ## T; \ + C = do_cat_op (C, tmp (0), ra_idx); \ + } \ + else \ + result_ ## T .insert (tmp(0). EXTRACTOR ## _array_value (), ra_idx); \ + } - else if BSXLOOP(ComplexNDArray, "double", complex) - else if BSXLOOP(boolNDArray, "logical", bool) - else if BSXLOOP(int8NDArray, "int8", int8) - else if BSXLOOP(int16NDArray, "int16", int16) - else if BSXLOOP(int32NDArray, "int32", int32) - else if BSXLOOP(int64NDArray, "int64", int64) - else if BSXLOOP(uint8NDArray, "uint8", uint8) - else if BSXLOOP(uint16NDArray, "uint16", uint16) - else if BSXLOOP(uint32NDArray, "uint32", uint32) - else if BSXLOOP(uint64NDArray, "uint64", uint64) - else - C = do_cat_op (C, tmp(0), ra_idx); - } + else if BSXLOOP(ComplexNDArray, "double", complex) + else if BSXLOOP(boolNDArray, "logical", bool) + else if BSXLOOP(int8NDArray, "int8", int8) + else if BSXLOOP(int16NDArray, "int16", int16) + else if BSXLOOP(int32NDArray, "int32", int32) + else if BSXLOOP(int64NDArray, "int64", int64) + else if BSXLOOP(uint8NDArray, "uint8", uint8) + else if BSXLOOP(uint16NDArray, "uint16", uint16) + else if BSXLOOP(uint32NDArray, "uint32", uint32) + else if BSXLOOP(uint64NDArray, "uint64", uint64) + else + C = do_cat_op (C, tmp(0), ra_idx); } + } #define BSXEND(T) \ - (have_ ## T) \ - retval(0) = result_ ## T; + (have_ ## T) \ + retval(0) = result_ ## T; - if BSXEND(NDArray) - else if BSXEND(ComplexNDArray) - else if BSXEND(FloatNDArray) - else if BSXEND(FloatComplexNDArray) - else if BSXEND(boolNDArray) - else if BSXEND(int8NDArray) - else if BSXEND(int16NDArray) - else if BSXEND(int32NDArray) - else if BSXEND(int64NDArray) - else if BSXEND(uint8NDArray) - else if BSXEND(uint16NDArray) - else if BSXEND(uint32NDArray) - else if BSXEND(uint64NDArray) - else - retval(0) = C; - } + if BSXEND(NDArray) + else if BSXEND(ComplexNDArray) + else if BSXEND(FloatNDArray) + else if BSXEND(FloatComplexNDArray) + else if BSXEND(boolNDArray) + else if BSXEND(int8NDArray) + else if BSXEND(int16NDArray) + else if BSXEND(int32NDArray) + else if BSXEND(int64NDArray) + else if BSXEND(uint8NDArray) + else if BSXEND(uint16NDArray) + else if BSXEND(uint32NDArray) + else if BSXEND(uint64NDArray) + else + retval(0) = C; } } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/colloc.cc --- a/libinterp/corefcn/colloc.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/colloc.cc Mon Oct 05 19:29:36 2015 -0400 @@ -61,9 +61,6 @@ double tmp = args(0).double_value (); - if (error_state) - return retval; - if (xisnan (tmp)) { error ("colloc: N cannot be NaN"); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/det.cc --- a/libinterp/corefcn/det.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/det.cc Mon Oct 05 19:29:36 2015 -0400 @@ -151,15 +151,14 @@ // Always compute rcond, so we can detect numerically // singular matrices. FloatMatrix m = arg.float_matrix_value (); - if (! error_state) - { - MAYBE_CAST (rep, octave_float_matrix); - MatrixType mtype = rep ? rep -> matrix_type () : MatrixType (); - FloatDET det = m.determinant (mtype, info, rcond); - retval(1) = rcond; - retval(0) = info == -1 ? 0.0f : det.value (); - if (rep) rep->matrix_type (mtype); - } + + MAYBE_CAST (rep, octave_float_matrix); + MatrixType mtype = rep ? rep -> matrix_type () : MatrixType (); + FloatDET det = m.determinant (mtype, info, rcond); + retval(1) = rcond; + retval(0) = info == -1 ? 0.0f : det.value (); + if (rep) + rep->matrix_type (mtype); } else if (arg.is_complex_type ()) { @@ -168,15 +167,14 @@ // Always compute rcond, so we can detect numerically // singular matrices. FloatComplexMatrix m = arg.float_complex_matrix_value (); - if (! error_state) - { - MAYBE_CAST (rep, octave_float_complex_matrix); - MatrixType mtype = rep ? rep -> matrix_type () : MatrixType (); - FloatComplexDET det = m.determinant (mtype, info, rcond); - retval(1) = rcond; - retval(0) = info == -1 ? FloatComplex (0.0) : det.value (); - if (rep) rep->matrix_type (mtype); - } + + MAYBE_CAST (rep, octave_float_complex_matrix); + MatrixType mtype = rep ? rep -> matrix_type () : MatrixType (); + FloatComplexDET det = m.determinant (mtype, info, rcond); + retval(1) = rcond; + retval(0) = info == -1 ? FloatComplex (0.0) : det.value (); + if (rep) + rep->matrix_type (mtype); } } else @@ -190,26 +188,23 @@ if (arg.is_sparse_type ()) { SparseMatrix m = arg.sparse_matrix_value (); - if (! error_state) - { - DET det = m.determinant (info, rcond); - retval(1) = rcond; - retval(0) = info == -1 ? 0.0 : det.value (); - } + + DET det = m.determinant (info, rcond); + retval(1) = rcond; + retval(0) = info == -1 ? 0.0 : det.value (); } else { Matrix m = arg.matrix_value (); - if (! error_state) - { - MAYBE_CAST (rep, octave_matrix); - MatrixType mtype = rep ? rep -> matrix_type () - : MatrixType (); - DET det = m.determinant (mtype, info, rcond); - retval(1) = rcond; - retval(0) = info == -1 ? 0.0 : det.value (); - if (rep) rep->matrix_type (mtype); - } + + MAYBE_CAST (rep, octave_matrix); + MatrixType mtype = rep ? rep -> matrix_type () + : MatrixType (); + DET det = m.determinant (mtype, info, rcond); + retval(1) = rcond; + retval(0) = info == -1 ? 0.0 : det.value (); + if (rep) + rep->matrix_type (mtype); } } else if (arg.is_complex_type ()) @@ -221,26 +216,23 @@ if (arg.is_sparse_type ()) { SparseComplexMatrix m = arg.sparse_complex_matrix_value (); - if (! error_state) - { - ComplexDET det = m.determinant (info, rcond); - retval(1) = rcond; - retval(0) = info == -1 ? Complex (0.0) : det.value (); - } + + ComplexDET det = m.determinant (info, rcond); + retval(1) = rcond; + retval(0) = info == -1 ? Complex (0.0) : det.value (); } else { ComplexMatrix m = arg.complex_matrix_value (); - if (! error_state) - { - MAYBE_CAST (rep, octave_complex_matrix); - MatrixType mtype = rep ? rep -> matrix_type () - : MatrixType (); - ComplexDET det = m.determinant (mtype, info, rcond); - retval(1) = rcond; - retval(0) = info == -1 ? Complex (0.0) : det.value (); - if (rep) rep->matrix_type (mtype); - } + + MAYBE_CAST (rep, octave_complex_matrix); + MatrixType mtype = rep ? rep -> matrix_type () + : MatrixType (); + ComplexDET det = m.determinant (mtype, info, rcond); + retval(1) = rcond; + retval(0) = info == -1 ? Complex (0.0) : det.value (); + if (rep) + rep->matrix_type (mtype); } } else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/dlmread.cc --- a/libinterp/corefcn/dlmread.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/dlmread.cc Mon Oct 05 19:29:36 2015 -0400 @@ -198,8 +198,7 @@ && args(nargin-2).string_value () == "emptyvalue") { empty_value = args(nargin-1).double_value (); - if (error_state) - return retval; + nargin -= 2; } @@ -233,9 +232,6 @@ { octave_stream is = octave_stream_list::lookup (args(0), "dlmread"); - if (error_state) - return retval; - input = is.input_stream (); if (! input) @@ -258,9 +254,6 @@ sep = do_string_escapes (args(1).string_value ()); else sep = args(1).string_value (); - - if (error_state) - return retval; } // Take a subset if a range was given. @@ -279,181 +272,92 @@ { r0 = args(2).idx_type_value (); c0 = args(3).idx_type_value (); - - if (error_state) - return retval; } if (r0 < 0 || c0 < 0) error ("dlmread: left & top must be positive"); } - if (!error_state) - { - octave_idx_type i = 0; - octave_idx_type j = 0; - octave_idx_type r = 1; - octave_idx_type c = 1; - octave_idx_type rmax = 0; - octave_idx_type cmax = 0; + octave_idx_type i = 0; + octave_idx_type j = 0; + octave_idx_type r = 1; + octave_idx_type c = 1; + octave_idx_type rmax = 0; + octave_idx_type cmax = 0; - Matrix rdata; - ComplexMatrix cdata; + Matrix rdata; + ComplexMatrix cdata; + + bool iscmplx = false; + bool sepflag = false; + + std::string line; - bool iscmplx = false; - bool sepflag = false; + // Skip the r0 leading lines as these might be a header. + for (octave_idx_type m = 0; m < r0; m++) + getline (*input, line); + r1 -= r0; - std::string line; + std::istringstream tmp_stream; - // Skip the r0 leading lines as these might be a header. - for (octave_idx_type m = 0; m < r0; m++) - getline (*input, line); - r1 -= r0; + // Read in the data one field at a time, growing the data matrix + // as needed. + while (getline (*input, line)) + { + // Skip blank lines for compatibility. + if (line.find_first_not_of (" \t") == std::string::npos) + continue; - std::istringstream tmp_stream; - - // Read in the data one field at a time, growing the data matrix - // as needed. - while (getline (*input, line)) + // To be compatible with matlab, blank separator should + // correspond to whitespace as delimter. + if (!sep.length ()) { - // Skip blank lines for compatibility. - if (line.find_first_not_of (" \t") == std::string::npos) - continue; + size_t n = line.find_first_of (",:; \t", + line.find_first_of ("0123456789")); + if (n == std::string::npos) + { + sep = " \t"; + sepflag = true; + } + else + { + char ch = line.at (n); - // To be compatible with matlab, blank separator should - // correspond to whitespace as delimter. - if (!sep.length ()) - { - size_t n = line.find_first_of (",:; \t", - line.find_first_of ("0123456789")); - if (n == std::string::npos) + switch (line.at (n)) { - sep = " \t"; + case ' ': + case '\t': sepflag = true; - } - else - { - char ch = line.at (n); + sep = " \t"; + break; - switch (line.at (n)) - { - case ' ': - case '\t': - sepflag = true; - sep = " \t"; - break; - - default: - sep = ch; - break; - } + default: + sep = ch; + break; } } - - if (cmax == 0) - { - // Try to estimate the number of columns. Skip leading - // whitespace. - size_t pos1 = line.find_first_not_of (" \t"); - do - { - size_t pos2 = line.find_first_of (sep, pos1); - - if (sepflag && pos2 != std::string::npos) - // Treat consecutive separators as one. - { - pos2 = line.find_first_not_of (sep, pos2); - if (pos2 != std::string::npos) - pos2 -= 1; - else - pos2 = line.length () - 1; - } + } - cmax++; - - if (pos2 != std::string::npos) - pos1 = pos2 + 1; - else - pos1 = std::string::npos; - - } - while (pos1 != std::string::npos); - - if (iscmplx) - cdata.resize (rmax, cmax); - else - rdata.resize (rmax, cmax); - } - - r = (r > i + 1 ? r : i + 1); - j = 0; - // Skip leading whitespace. + if (cmax == 0) + { + // Try to estimate the number of columns. Skip leading + // whitespace. size_t pos1 = line.find_first_not_of (" \t"); do { - octave_quit (); - size_t pos2 = line.find_first_of (sep, pos1); - std::string str = line.substr (pos1, pos2 - pos1); if (sepflag && pos2 != std::string::npos) // Treat consecutive separators as one. - pos2 = line.find_first_not_of (sep, pos2) - 1; - - c = (c > j + 1 ? c : j + 1); - if (r > rmax || c > cmax) { - // Use resize_and_fill for the case of not-equal - // length rows. - rmax = 2*r; - cmax = c; - if (iscmplx) - cdata.resize (rmax, cmax); + pos2 = line.find_first_not_of (sep, pos2); + if (pos2 != std::string::npos) + pos2 -= 1; else - rdata.resize (rmax, cmax); + pos2 = line.length () - 1; } - tmp_stream.str (str); - tmp_stream.clear (); - - double x = octave_read_double (tmp_stream); - if (tmp_stream) - { - if (tmp_stream.eof ()) - { - if (iscmplx) - cdata(i,j++) = x; - else - rdata(i,j++) = x; - } - else if (std::toupper (tmp_stream.peek ()) == 'I') - { - // This is to allow pure imaginary numbers. - if (iscmplx) - cdata(i,j++) = x; - else - rdata(i,j++) = x; - } - else - { - double y = octave_read_double (tmp_stream); - - if (!iscmplx && y != 0.) - { - iscmplx = true; - cdata = ComplexMatrix (rdata); - } - - if (iscmplx) - cdata(i,j++) = Complex (x, y); - else - rdata(i,j++) = x; - } - } - else if (iscmplx) - cdata(i,j++) = empty_value; - else - rdata(i,j++) = empty_value; + cmax++; if (pos2 != std::string::npos) pos1 = pos2 + 1; @@ -463,32 +367,115 @@ } while (pos1 != std::string::npos); - if (i == r1) - break; - - i++; + if (iscmplx) + cdata.resize (rmax, cmax); + else + rdata.resize (rmax, cmax); } - if (r1 >= r) - r1 = r - 1; - if (c1 >= c) - c1 = c - 1; - - // Now take the subset of the matrix if there are any values. - if (i > 0 || j > 0) + r = (r > i + 1 ? r : i + 1); + j = 0; + // Skip leading whitespace. + size_t pos1 = line.find_first_not_of (" \t"); + do { - if (iscmplx) - cdata = cdata.extract (0, c0, r1, c1); - else - rdata = rdata.extract (0, c0, r1, c1); - } + octave_quit (); + + size_t pos2 = line.find_first_of (sep, pos1); + std::string str = line.substr (pos1, pos2 - pos1); + + if (sepflag && pos2 != std::string::npos) + // Treat consecutive separators as one. + pos2 = line.find_first_not_of (sep, pos2) - 1; + + c = (c > j + 1 ? c : j + 1); + if (r > rmax || c > cmax) + { + // Use resize_and_fill for the case of not-equal + // length rows. + rmax = 2*r; + cmax = c; + if (iscmplx) + cdata.resize (rmax, cmax); + else + rdata.resize (rmax, cmax); + } + + tmp_stream.str (str); + tmp_stream.clear (); + + double x = octave_read_double (tmp_stream); + if (tmp_stream) + { + if (tmp_stream.eof ()) + { + if (iscmplx) + cdata(i,j++) = x; + else + rdata(i,j++) = x; + } + else if (std::toupper (tmp_stream.peek ()) == 'I') + { + // This is to allow pure imaginary numbers. + if (iscmplx) + cdata(i,j++) = x; + else + rdata(i,j++) = x; + } + else + { + double y = octave_read_double (tmp_stream); + if (!iscmplx && y != 0.) + { + iscmplx = true; + cdata = ComplexMatrix (rdata); + } + + if (iscmplx) + cdata(i,j++) = Complex (x, y); + else + rdata(i,j++) = x; + } + } + else if (iscmplx) + cdata(i,j++) = empty_value; + else + rdata(i,j++) = empty_value; + + if (pos2 != std::string::npos) + pos1 = pos2 + 1; + else + pos1 = std::string::npos; + + } + while (pos1 != std::string::npos); + + if (i == r1) + break; + + i++; + } + + if (r1 >= r) + r1 = r - 1; + if (c1 >= c) + c1 = c - 1; + + // Now take the subset of the matrix if there are any values. + if (i > 0 || j > 0) + { if (iscmplx) - retval(0) = cdata; + cdata = cdata.extract (0, c0, r1, c1); else - retval(0) = rdata; + rdata = rdata.extract (0, c0, r1, c1); } + if (iscmplx) + retval(0) = cdata; + else + retval(0) = rdata; + return retval; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/dynamic-ld.cc --- a/libinterp/corefcn/dynamic-ld.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/dynamic-ld.cc Mon Oct 05 19:29:36 2015 -0400 @@ -269,39 +269,36 @@ { oct_file.open (file_name); - if (! error_state && oct_file) + if (oct_file) octave_shlib_list::append (oct_file); } - if (! error_state) + if (oct_file) { - if (oct_file) - { - void *function = oct_file.search (fcn_name, name_mangler); + void *function = oct_file.search (fcn_name, name_mangler); - if (! function) - { - // FIXME: can we determine this C mangling scheme - // automatically at run time or configure time? + if (! function) + { + // FIXME: can we determine this C mangling scheme + // automatically at run time or configure time? - function = oct_file.search (fcn_name, name_uscore_mangler); - } + function = oct_file.search (fcn_name, name_uscore_mangler); + } - if (function) - { - octave_dld_fcn_getter f - = FCN_PTR_CAST (octave_dld_fcn_getter, function); + if (function) + { + octave_dld_fcn_getter f + = FCN_PTR_CAST (octave_dld_fcn_getter, function); - retval = f (oct_file, relative); + retval = f (oct_file, relative); - if (! retval) - error ("failed to install .oct file function '%s'", - fcn_name.c_str ()); - } + if (! retval) + error ("failed to install .oct file function '%s'", + fcn_name.c_str ()); } - else - error ("%s is not a valid shared library", file_name.c_str ()); } + else + error ("%s is not a valid shared library", file_name.c_str ()); return retval; } @@ -328,46 +325,43 @@ { mex_file.open (file_name); - if (! error_state && mex_file) + if (mex_file) octave_shlib_list::append (mex_file); } - if (! error_state) + if (mex_file) { - if (mex_file) + void *function = 0; + + bool have_fmex = false; + + function = mex_file.search (fcn_name, mex_mangler); + + if (! function) { - void *function = 0; + // FIXME: can we determine this C mangling scheme + // automatically at run time or configure time? - bool have_fmex = false; - - function = mex_file.search (fcn_name, mex_mangler); + function = mex_file.search (fcn_name, mex_uscore_mangler); if (! function) { - // FIXME: can we determine this C mangling scheme - // automatically at run time or configure time? + function = mex_file.search (fcn_name, mex_f77_mangler); - function = mex_file.search (fcn_name, mex_uscore_mangler); - - if (! function) - { - function = mex_file.search (fcn_name, mex_f77_mangler); + if (function) + have_fmex = true; + } + } - if (function) - have_fmex = true; - } - } - - if (function) - retval = new octave_mex_function (function, have_fmex, - mex_file, fcn_name); - else - error ("failed to install .mex file function '%s'", - fcn_name.c_str ()); - } + if (function) + retval = new octave_mex_function (function, have_fmex, + mex_file, fcn_name); else - error ("%s is not a valid shared library", file_name.c_str ()); + error ("failed to install .mex file function '%s'", + fcn_name.c_str ()); } + else + error ("%s is not a valid shared library", file_name.c_str ()); return retval; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/eig.cc --- a/libinterp/corefcn/eig.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/eig.cc Mon Oct 05 19:29:36 2015 -0400 @@ -127,19 +127,13 @@ { ftmp_a = arg_a.float_matrix_value (); - if (error_state) - return retval; - else - result = FloatEIG (ftmp_a, nargout > 1); + result = FloatEIG (ftmp_a, nargout > 1); } else { fctmp_a = arg_a.float_complex_matrix_value (); - if (error_state) - return retval; - else - result = FloatEIG (fctmp_a, nargout > 1); + result = FloatEIG (fctmp_a, nargout > 1); } } else if (nargin == 2) @@ -149,38 +143,29 @@ ftmp_a = arg_a.float_matrix_value (); ftmp_b = arg_b.float_matrix_value (); - if (error_state) - return retval; - else - result = FloatEIG (ftmp_a, ftmp_b, nargout > 1); + result = FloatEIG (ftmp_a, ftmp_b, nargout > 1); } else { fctmp_a = arg_a.float_complex_matrix_value (); fctmp_b = arg_b.float_complex_matrix_value (); - if (error_state) - return retval; - else - result = FloatEIG (fctmp_a, fctmp_b, nargout > 1); + result = FloatEIG (fctmp_a, fctmp_b, nargout > 1); } } - if (! error_state) + if (nargout == 0 || nargout == 1) + { + retval(0) = result.eigenvalues (); + } + else { - if (nargout == 0 || nargout == 1) - { - retval(0) = result.eigenvalues (); - } - else - { - // Blame it on Matlab. + // Blame it on Matlab. - FloatComplexDiagMatrix d (result.eigenvalues ()); + FloatComplexDiagMatrix d (result.eigenvalues ()); - retval(1) = d; - retval(0) = result.eigenvectors (); - } + retval(1) = d; + retval(0) = result.eigenvectors (); } } else @@ -193,19 +178,13 @@ { tmp_a = arg_a.matrix_value (); - if (error_state) - return retval; - else - result = EIG (tmp_a, nargout > 1); + result = EIG (tmp_a, nargout > 1); } else { ctmp_a = arg_a.complex_matrix_value (); - if (error_state) - return retval; - else - result = EIG (ctmp_a, nargout > 1); + result = EIG (ctmp_a, nargout > 1); } } else if (nargin == 2) @@ -215,38 +194,29 @@ tmp_a = arg_a.matrix_value (); tmp_b = arg_b.matrix_value (); - if (error_state) - return retval; - else - result = EIG (tmp_a, tmp_b, nargout > 1); + result = EIG (tmp_a, tmp_b, nargout > 1); } else { ctmp_a = arg_a.complex_matrix_value (); ctmp_b = arg_b.complex_matrix_value (); - if (error_state) - return retval; - else - result = EIG (ctmp_a, ctmp_b, nargout > 1); + result = EIG (ctmp_a, ctmp_b, nargout > 1); } } - if (! error_state) + if (nargout == 0 || nargout == 1) + { + retval(0) = result.eigenvalues (); + } + else { - if (nargout == 0 || nargout == 1) - { - retval(0) = result.eigenvalues (); - } - else - { - // Blame it on Matlab. + // Blame it on Matlab. - ComplexDiagMatrix d (result.eigenvalues ()); + ComplexDiagMatrix d (result.eigenvalues ()); - retval(1) = d; - retval(0) = result.eigenvectors (); - } + retval(1) = d; + retval(0) = result.eigenvectors (); } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/fft.cc --- a/libinterp/corefcn/fft.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/fft.cc Mon Oct 05 19:29:36 2015 -0400 @@ -74,9 +74,6 @@ } } - if (error_state) - return retval; - if (nargin > 2) { double dval = args(2).double_value (); @@ -90,9 +87,6 @@ dim = NINT (dval) - 1; } - if (error_state) - return retval; - for (octave_idx_type i = 0; i < dims.length (); i++) if (dims(i) < 0) return retval; @@ -130,21 +124,15 @@ { FloatNDArray nda = arg.float_array_value (); - if (! error_state) - { - nda.resize (dims, 0.0); - retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim)); - } + nda.resize (dims, 0.0); + retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim)); } else { FloatComplexNDArray cnda = arg.float_complex_array_value (); - if (! error_state) - { - cnda.resize (dims, 0.0); - retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim)); - } + cnda.resize (dims, 0.0); + retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim)); } } else @@ -153,26 +141,18 @@ { NDArray nda = arg.array_value (); - if (! error_state) - { - nda.resize (dims, 0.0); - retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim)); - } + nda.resize (dims, 0.0); + retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim)); } else if (arg.is_complex_type ()) { ComplexNDArray cnda = arg.complex_array_value (); - if (! error_state) - { - cnda.resize (dims, 0.0); - retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim)); - } + cnda.resize (dims, 0.0); + retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim)); } else - { - gripe_wrong_type_arg (fcn, arg); - } + gripe_wrong_type_arg (fcn, arg); } return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/fft2.cc --- a/libinterp/corefcn/fft2.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/fft2.cc Mon Oct 05 19:29:36 2015 -0400 @@ -71,9 +71,6 @@ } } - if (error_state) - return retval; - octave_idx_type n_cols = -1; if (nargin > 2) { @@ -88,9 +85,6 @@ } } - if (error_state) - return retval; - for (int i = 0; i < dims.length (); i++) if (dims(i) < 0) return retval; @@ -119,21 +113,15 @@ { FloatNDArray nda = arg.float_array_value (); - if (! error_state) - { - nda.resize (dims, 0.0); - retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ()); - } + nda.resize (dims, 0.0); + retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ()); } else { FloatComplexNDArray cnda = arg.float_complex_array_value (); - if (! error_state) - { - cnda.resize (dims, 0.0); - retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ()); - } + cnda.resize (dims, 0.0); + retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ()); } } else @@ -142,26 +130,18 @@ { NDArray nda = arg.array_value (); - if (! error_state) - { - nda.resize (dims, 0.0); - retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ()); - } + nda.resize (dims, 0.0); + retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ()); } else if (arg.is_complex_type ()) { ComplexNDArray cnda = arg.complex_array_value (); - if (! error_state) - { - cnda.resize (dims, 0.0); - retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ()); - } + cnda.resize (dims, 0.0); + retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ()); } else - { - gripe_wrong_type_arg (fcn, arg); - } + gripe_wrong_type_arg (fcn, arg); } return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/fftn.cc --- a/libinterp/corefcn/fftn.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/fftn.cc Mon Oct 05 19:29:36 2015 -0400 @@ -85,9 +85,6 @@ } } - if (error_state) - return retval; - if (dims.all_zero ()) { if (arg.is_single_type ()) @@ -102,21 +99,15 @@ { FloatNDArray nda = arg.float_array_value (); - if (! error_state) - { - nda.resize (dims, 0.0); - retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ()); - } + nda.resize (dims, 0.0); + retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ()); } else { FloatComplexNDArray cnda = arg.float_complex_array_value (); - if (! error_state) - { - cnda.resize (dims, 0.0); - retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ()); - } + cnda.resize (dims, 0.0); + retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ()); } } else @@ -125,26 +116,18 @@ { NDArray nda = arg.array_value (); - if (! error_state) - { - nda.resize (dims, 0.0); - retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ()); - } + nda.resize (dims, 0.0); + retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ()); } else if (arg.is_complex_type ()) { ComplexNDArray cnda = arg.complex_array_value (); - if (! error_state) - { - cnda.resize (dims, 0.0); - retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ()); - } + cnda.resize (dims, 0.0); + retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ()); } else - { - gripe_wrong_type_arg (fcn, arg); - } + gripe_wrong_type_arg (fcn, arg); } return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/gcd.cc --- a/libinterp/corefcn/gcd.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/gcd.cc Mon Oct 05 19:29:36 2015 -0400 @@ -420,7 +420,7 @@ } // For consistency. - if (! error_state && a.is_sparse_type () && b.is_sparse_type ()) + if (a.is_sparse_type () && b.is_sparse_type ()) { retval = retval.sparse_matrix_value (); x = x.sparse_matrix_value (); @@ -495,9 +495,6 @@ x, retval(j+1)); for (int i = 0; i < j; i++) retval(i+1).assign (octave_value::op_el_mul_eq, x); - - if (error_state) - break; } } else @@ -505,12 +502,7 @@ retval(0) = do_simple_gcd (args(0), args(1)); for (int j = 2; j < nargin; j++) - { - retval(0) = do_simple_gcd (retval(0), args(j)); - - if (error_state) - break; - } + retval(0) = do_simple_gcd (retval(0), args(j)); } } else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/getgrent.cc --- a/libinterp/corefcn/getgrent.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/getgrent.cc Mon Oct 05 19:29:36 2015 -0400 @@ -112,20 +112,17 @@ { double dval = args(0).double_value (); - if (! error_state) + if (D_NINT (dval) == dval) { - if (D_NINT (dval) == dval) - { - gid_t gid = static_cast (dval); + gid_t gid = static_cast (dval); + + std::string msg; - std::string msg; - - retval(1) = msg; - retval(0) = mk_gr_map (octave_group::getgrgid (gid, msg)); - } - else - error ("getgrgid: GID must be an integer"); + retval(1) = msg; + retval(0) = mk_gr_map (octave_group::getgrgid (gid, msg)); } + else + error ("getgrgid: GID must be an integer"); } else print_usage (); @@ -154,13 +151,10 @@ { std::string s = args(0).string_value (); - if (! error_state) - { - std::string msg; + std::string msg; - retval(1) = msg; - retval(0) = mk_gr_map (octave_group::getgrnam (s.c_str (), msg)); - } + retval(1) = msg; + retval(0) = mk_gr_map (octave_group::getgrnam (s.c_str (), msg)); } else print_usage (); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/getpwent.cc --- a/libinterp/corefcn/getpwent.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/getpwent.cc Mon Oct 05 19:29:36 2015 -0400 @@ -116,20 +116,17 @@ { double dval = args(0).double_value (); - if (! error_state) + if (D_NINT (dval) == dval) { - if (D_NINT (dval) == dval) - { - uid_t uid = static_cast (dval); + uid_t uid = static_cast (dval); + + std::string msg; - std::string msg; - - retval(1) = msg; - retval(0) = mk_pw_map (octave_passwd::getpwuid (uid, msg)); - } - else - error ("getpwuid: UID must be an integer"); + retval(1) = msg; + retval(0) = mk_pw_map (octave_passwd::getpwuid (uid, msg)); } + else + error ("getpwuid: UID must be an integer"); } else print_usage (); @@ -158,13 +155,10 @@ { std::string s = args(0).string_value (); - if (! error_state) - { - std::string msg; + std::string msg; - retval(1) = msg; - retval(0) = mk_pw_map (octave_passwd::getpwnam (s, msg)); - } + retval(1) = msg; + retval(0) = mk_pw_map (octave_passwd::getpwnam (s, msg)); } else print_usage (); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/givens.cc --- a/libinterp/corefcn/givens.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/givens.cc Mon Oct 05 19:29:36 2015 -0400 @@ -92,25 +92,19 @@ FloatComplex cx = args(0).float_complex_value (); FloatComplex cy = args(1).float_complex_value (); - if (! error_state) - { - FloatComplexMatrix result = Givens (cx, cy); + FloatComplexMatrix result = Givens (cx, cy); - if (! error_state) - { - switch (nargout) - { - case 0: - case 1: - retval(0) = result; - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = result; + break; - case 2: - retval(1) = result (0, 1); - retval(0) = result (0, 0); - break; - } - } + case 2: + retval(1) = result (0, 1); + retval(0) = result (0, 0); + break; } } else @@ -118,25 +112,19 @@ float x = args(0).float_value (); float y = args(1).float_value (); - if (! error_state) - { - FloatMatrix result = Givens (x, y); + FloatMatrix result = Givens (x, y); - if (! error_state) - { - switch (nargout) - { - case 0: - case 1: - retval(0) = result; - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = result; + break; - case 2: - retval(1) = result (0, 1); - retval(0) = result (0, 0); - break; - } - } + case 2: + retval(1) = result (0, 1); + retval(0) = result (0, 0); + break; } } } @@ -147,25 +135,19 @@ Complex cx = args(0).complex_value (); Complex cy = args(1).complex_value (); - if (! error_state) - { - ComplexMatrix result = Givens (cx, cy); + ComplexMatrix result = Givens (cx, cy); - if (! error_state) - { - switch (nargout) - { - case 0: - case 1: - retval(0) = result; - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = result; + break; - case 2: - retval(1) = result (0, 1); - retval(0) = result (0, 0); - break; - } - } + case 2: + retval(1) = result (0, 1); + retval(0) = result (0, 0); + break; } } else @@ -173,25 +155,19 @@ double x = args(0).double_value (); double y = args(1).double_value (); - if (! error_state) - { - Matrix result = Givens (x, y); + Matrix result = Givens (x, y); - if (! error_state) - { - switch (nargout) - { - case 0: - case 1: - retval(0) = result; - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = result; + break; - case 2: - retval(1) = result (0, 1); - retval(0) = result (0, 0); - break; - } - } + case 2: + retval(1) = result (0, 1); + retval(0) = result (0, 0); + break; } } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/hess.cc --- a/libinterp/corefcn/hess.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/hess.cc Mon Oct 05 19:29:36 2015 -0400 @@ -98,34 +98,28 @@ { FloatMatrix tmp = arg.float_matrix_value (); - if (! error_state) - { - FloatHESS result (tmp); + FloatHESS result (tmp); - if (nargout <= 1) - retval(0) = result.hess_matrix (); - else - { - retval(1) = result.hess_matrix (); - retval(0) = result.unitary_hess_matrix (); - } + if (nargout <= 1) + retval(0) = result.hess_matrix (); + else + { + retval(1) = result.hess_matrix (); + retval(0) = result.unitary_hess_matrix (); } } else if (arg.is_complex_type ()) { FloatComplexMatrix ctmp = arg.float_complex_matrix_value (); - if (! error_state) - { - FloatComplexHESS result (ctmp); + FloatComplexHESS result (ctmp); - if (nargout <= 1) - retval(0) = result.hess_matrix (); - else - { - retval(1) = result.hess_matrix (); - retval(0) = result.unitary_hess_matrix (); - } + if (nargout <= 1) + retval(0) = result.hess_matrix (); + else + { + retval(1) = result.hess_matrix (); + retval(0) = result.unitary_hess_matrix (); } } } @@ -135,34 +129,28 @@ { Matrix tmp = arg.matrix_value (); - if (! error_state) - { - HESS result (tmp); + HESS result (tmp); - if (nargout <= 1) - retval(0) = result.hess_matrix (); - else - { - retval(1) = result.hess_matrix (); - retval(0) = result.unitary_hess_matrix (); - } + if (nargout <= 1) + retval(0) = result.hess_matrix (); + else + { + retval(1) = result.hess_matrix (); + retval(0) = result.unitary_hess_matrix (); } } else if (arg.is_complex_type ()) { ComplexMatrix ctmp = arg.complex_matrix_value (); - if (! error_state) - { - ComplexHESS result (ctmp); + ComplexHESS result (ctmp); - if (nargout <= 1) - retval(0) = result.hess_matrix (); - else - { - retval(1) = result.hess_matrix (); - retval(0) = result.unitary_hess_matrix (); - } + if (nargout <= 1) + retval(0) = result.hess_matrix (); + else + { + retval(1) = result.hess_matrix (); + retval(0) = result.unitary_hess_matrix (); } } else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/input.cc Mon Oct 05 19:29:36 2015 -0400 @@ -707,7 +707,7 @@ std::string input_buf = interactive_input (prompt.c_str (), eof); - if (! (error_state || input_buf.empty ())) + if (! input_buf.empty ()) { size_t len = input_buf.length (); @@ -888,8 +888,7 @@ if (nargin > 0) prompt = args(0).string_value (); - if (! error_state) - get_debug_input (prompt); + get_debug_input (prompt); return retval; } @@ -976,9 +975,6 @@ string_vector argv = args.make_argv ("echo"); - if (error_state) - return retval; - switch (argc) { case 1: @@ -1103,56 +1099,53 @@ { std::string hint = args(0).string_value (); - if (! error_state) - { - int n = 32; + int n = 32; - string_vector list (n); + string_vector list (n); + + int k = 0; - int k = 0; + for (;;) + { + std::string cmd = generate_completion (hint, k); - for (;;) + if (! cmd.empty ()) { - std::string cmd = generate_completion (hint, k); - - if (! cmd.empty ()) + if (k == n) { - if (k == n) - { - n *= 2; - list.resize (n); - } - - list[k++] = cmd; + n *= 2; + list.resize (n); } - else - { - list.resize (k); - break; - } - } - if (nargout > 0) - { - if (! list.empty ()) - retval = list; - else - retval = ""; + list[k++] = cmd; } else { - // We don't use string_vector::list_in_columns here - // because it will be easier for Emacs if the names - // appear in a single column. - - int len = list.numel (); + list.resize (k); + break; + } + } - for (int i = 0; i < len; i++) - octave_stdout << list[i] << "\n"; - } + if (nargout > 0) + { + if (! list.empty ()) + retval = list; + else + retval = ""; + } + else + { + // We don't use string_vector::list_in_columns here + // because it will be easier for Emacs if the names + // appear in a single column. - octave_completion_matches_called = true; + int len = list.numel (); + + for (int i = 0; i < len; i++) + octave_stdout << list[i] << "\n"; } + + octave_completion_matches_called = true; } else print_usage (); @@ -1198,8 +1191,7 @@ { std::string file = args(0).string_value (); - if (! error_state) - command_editor::read_init_file (file); + command_editor::read_init_file (file); } else print_usage (); @@ -1549,7 +1541,7 @@ octave_value retval = SET_INTERNAL_VARIABLE (filemarker); // The character passed must not be a legal character for a function name - if (! error_state && (::isalnum (Vfilemarker) || Vfilemarker == '_')) + if (::isalnum (Vfilemarker) || Vfilemarker == '_') { Vfilemarker = tmp; error ("filemarker: character can not be a valid character for a function name"); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/levenshtein.cc --- a/libinterp/corefcn/levenshtein.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/levenshtein.cc Mon Oct 05 19:29:36 2015 -0400 @@ -71,39 +71,39 @@ s2len = s2.numel (), ii, jj; - if (! error_state) + Array + dist (dim_vector (s1len + 1, s2len + 1), 0); + + for (ii = 1; ii <= s1len; ii++) + dist.xelem (ii, 0) = ii; + + for (jj = 1; jj <= s2len; jj++) + dist.xelem (0, jj) = jj; + + for (jj = 1; jj <= s2len; jj++) { - Array - dist (dim_vector (s1len + 1, s2len + 1), 0); - for (ii = 1; ii <= s1len; ii++) - dist.xelem (ii, 0) = ii; + if (s1_p[ii-1] == s2_p[jj-1]) + dist.xelem (ii, jj) = dist.xelem (ii-1, jj-1); + else + dist.xelem (ii, jj) = + MIN3(dist.xelem (ii-1, jj) + 1, + dist.xelem (ii, jj-1) + 1, + dist.xelem (ii-1, jj-1) + 1); - for (jj = 1; jj <= s2len; jj++) - dist.xelem (0, jj) = jj; - - for (jj = 1; jj <= s2len; jj++) + if (dist(MIN2(jj, s1len), jj) > ub) { - for (ii = 1; ii <= s1len; ii++) - if (s1_p[ii-1] == s2_p[jj-1]) - dist.xelem (ii, jj) = dist.xelem (ii-1, jj-1); - else - dist.xelem (ii, jj) = - MIN3(dist.xelem (ii-1, jj) + 1, - dist.xelem (ii, jj-1) + 1, - dist.xelem (ii-1, jj-1) + 1); + retval(0) = std::numeric_limits::max (); + if (nargout == 2) + retval(1) = Matrix (); + return retval; + } + } - if (dist(MIN2(jj, s1len), jj) > ub) - { - retval(0) = std::numeric_limits::max (); - if (nargout == 2) - retval(1) = Matrix (); - return retval; - } - } - retval(0) = dist.xelem (s1len, s2len); - if (nargout == 2) - retval(1) = dist; - } + retval(0) = dist.xelem (s1len, s2len); + + if (nargout == 2) + retval(1) = dist; + return retval; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/load-path.cc --- a/libinterp/corefcn/load-path.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/load-path.cc Mon Oct 05 19:29:36 2015 -0400 @@ -766,18 +766,15 @@ { dir_info di (dir); - if (! error_state) - { - if (at_end) - dir_info_list.push_back (di); - else - dir_info_list.push_front (di); - - add (di, at_end); - - if (add_hook) - add_hook (dir); - } + if (at_end) + dir_info_list.push_back (di); + else + dir_info_list.push_front (di); + + add (di, at_end); + + if (add_hook) + add_hook (dir); } else if (warn) warning ("addpath: %s: not a directory", dir_arg.c_str ()); @@ -2256,12 +2253,7 @@ string_vector skip (nargin - 1); for (octave_idx_type i = 1; i < nargin; i++) - { - skip[i-1] = args(i).string_value (); - - if (error_state) - break; - } + skip[i-1] = args(i).string_value (); if (! error_state) retval = genpath (dirname, skip); @@ -2362,33 +2354,30 @@ string_vector argv = args.make_argv ("path"); - if (! error_state) + if (argc > 1) { - if (argc > 1) - { - std::string path = argv[1]; - - for (int i = 2; i < argc; i++) - path += dir_path::path_sep_str () + argv[i]; - - load_path::set (path, true); - - rehash_internal (); - } - - if (nargout > 0) - retval = load_path::path (); - else if (argc == 1 && nargout == 0) - { - octave_stdout << - "\nOctave's search path contains the following directories:\n\n"; - - string_vector dirs = load_path::dirs (); - - dirs.list_in_columns (octave_stdout); - - octave_stdout << "\n"; - } + std::string path = argv[1]; + + for (int i = 2; i < argc; i++) + path += dir_path::path_sep_str () + argv[i]; + + load_path::set (path, true); + + rehash_internal (); + } + + if (nargout > 0) + retval = load_path::path (); + else if (argc == 1 && nargout == 0) + { + octave_stdout << + "\nOctave's search path contains the following directories:\n\n"; + + string_vector dirs = load_path::dirs (); + + dirs.list_in_columns (octave_stdout); + + octave_stdout << "\n"; } return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/lookup.cc --- a/libinterp/corefcn/lookup.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/lookup.cc Mon Oct 05 19:29:36 2015 -0400 @@ -283,9 +283,6 @@ else if (str_case && (left_inf || right_inf)) error ("lookup: l, r are not recognized for string lookups"); - if (error_state) - return retval; - if (num_case) { diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/ls-mat-ascii.cc --- a/libinterp/corefcn/ls-mat-ascii.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/ls-mat-ascii.cc Mon Oct 05 19:29:36 2015 -0400 @@ -119,7 +119,7 @@ nr = 0; nc = 0; - while (is && ! error_state) + while (is) { octave_quit (); @@ -270,7 +270,7 @@ octave_quit (); - if (! error_state && nr > 0 && nc > 0) + if (nr > 0 && nc > 0) { Matrix tmp (nr, nc); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/ls-mat4.cc --- a/libinterp/corefcn/ls-mat4.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/ls-mat4.cc Mon Oct 05 19:29:36 2015 -0400 @@ -373,7 +373,7 @@ read_mat_binary_data (is, re.fortran_vec (), prec, dlen, swap, flt_fmt); - if (! is || error_state) + if (! is) { error ("load: reading matrix data for '%s'", name); goto data_read_error; @@ -386,7 +386,7 @@ read_mat_binary_data (is, im.fortran_vec (), prec, dlen, swap, flt_fmt); - if (! is || error_state) + if (! is) { error ("load: reading imaginary matrix data for '%s'", name); goto data_read_error; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/lsode.cc --- a/libinterp/corefcn/lsode.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/lsode.cc Mon Oct 05 19:29:36 2015 -0400 @@ -367,31 +367,28 @@ { string_vector tmp = f_arg.all_strings (); - if (! error_state) + fcn_name = unique_symbol_name ("__lsode_fcn__"); + fname = "function y = "; + fname.append (fcn_name); + fname.append (" (x, t) y = "); + lsode_fcn = extract_function (tmp(0), "lsode", fcn_name, + fname, "; endfunction"); + + if (lsode_fcn) { - fcn_name = unique_symbol_name ("__lsode_fcn__"); - fname = "function y = "; - fname.append (fcn_name); - fname.append (" (x, t) y = "); - lsode_fcn = extract_function (tmp(0), "lsode", fcn_name, - fname, "; endfunction"); + jac_name = unique_symbol_name ("__lsode_jac__"); + jname = "function jac = "; + jname.append (jac_name); + jname.append (" (x, t) jac = "); + lsode_jac = extract_function (tmp(1), "lsode", + jac_name, jname, + "; endfunction"); - if (lsode_fcn) + if (!lsode_jac) { - jac_name = unique_symbol_name ("__lsode_jac__"); - jname = "function jac = "; - jname.append (jac_name); - jname.append (" (x, t) jac = "); - lsode_jac = extract_function (tmp(1), "lsode", - jac_name, jname, - "; endfunction"); - - if (!lsode_jac) - { - if (fcn_name.length ()) - clear_function (fcn_name); - lsode_fcn = 0; - } + if (fcn_name.length ()) + clear_function (fcn_name); + lsode_fcn = 0; } } } @@ -451,22 +448,19 @@ if (jac_name.length ()) clear_function (jac_name); - if (! error_state) - { - std::string msg = ode.error_message (); + std::string msg = ode.error_message (); - retval(2) = msg; - retval(1) = static_cast (ode.integration_state ()); + retval(2) = msg; + retval(1) = static_cast (ode.integration_state ()); - if (ode.integration_ok ()) - retval(0) = output; - else - { - retval(0) = Matrix (); + if (ode.integration_ok ()) + retval(0) = output; + else + { + retval(0) = Matrix (); - if (nargout < 2) - error ("lsode: %s", msg.c_str ()); - } + if (nargout < 2) + error ("lsode: %s", msg.c_str ()); } } else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/lu.cc --- a/libinterp/corefcn/lu.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/lu.cc Mon Oct 05 19:29:36 2015 -0400 @@ -158,7 +158,7 @@ Matrix thres; int n = 1; - while (n < nargin && ! error_state) + while (n < nargin) { if (args(n).is_string ()) { @@ -173,21 +173,18 @@ { Matrix tmp = args(n++).matrix_value (); - if (! error_state) + if (!issparse) + error ("lu: can not define pivoting threshold THRES for full matrices"); + else if (tmp.numel () == 1) { - if (!issparse) - error ("lu: can not define pivoting threshold THRES for full matrices"); - else if (tmp.numel () == 1) - { - thres.resize (1,2); - thres(0) = tmp(0); - thres(1) = tmp(0); - } - else if (tmp.numel () == 2) - thres = tmp; - else - error ("lu: expecting 2-element vector for THRES"); + thres.resize (1,2); + thres(0) = tmp(0); + thres(1) = tmp(0); } + else if (tmp.numel () == 2) + thres = tmp; + else + error ("lu: expecting 2-element vector for THRES"); } } @@ -360,76 +357,70 @@ { FloatMatrix m = arg.float_matrix_value (); - if (! error_state) - { - FloatLU fact (m); + FloatLU fact (m); - switch (nargout) - { - case 0: - case 1: - retval(0) = fact.Y (); - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = fact.Y (); + break; - case 2: - { - PermMatrix P = fact.P (); - FloatMatrix L = P.transpose () * fact.L (); - retval(1) = get_lu_u (fact); - retval(0) = L; - } - break; + case 2: + { + PermMatrix P = fact.P (); + FloatMatrix L = P.transpose () * fact.L (); + retval(1) = get_lu_u (fact); + retval(0) = L; + } + break; - case 3: - default: - { - if (vecout) - retval(2) = fact.P_vec (); - else - retval(2) = fact.P (); - retval(1) = get_lu_u (fact); - retval(0) = get_lu_l (fact); - } - break; - } + case 3: + default: + { + if (vecout) + retval(2) = fact.P_vec (); + else + retval(2) = fact.P (); + retval(1) = get_lu_u (fact); + retval(0) = get_lu_l (fact); + } + break; } } else { Matrix m = arg.matrix_value (); - if (! error_state) - { - LU fact (m); + LU fact (m); - switch (nargout) - { - case 0: - case 1: - retval(0) = fact.Y (); - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = fact.Y (); + break; - case 2: - { - PermMatrix P = fact.P (); - Matrix L = P.transpose () * fact.L (); - retval(1) = get_lu_u (fact); - retval(0) = L; - } - break; + case 2: + { + PermMatrix P = fact.P (); + Matrix L = P.transpose () * fact.L (); + retval(1) = get_lu_u (fact); + retval(0) = L; + } + break; - case 3: - default: - { - if (vecout) - retval(2) = fact.P_vec (); - else - retval(2) = fact.P (); - retval(1) = get_lu_u (fact); - retval(0) = get_lu_l (fact); - } - break; - } + case 3: + default: + { + if (vecout) + retval(2) = fact.P_vec (); + else + retval(2) = fact.P (); + retval(1) = get_lu_u (fact); + retval(0) = get_lu_l (fact); + } + break; } } } @@ -439,76 +430,70 @@ { FloatComplexMatrix m = arg.float_complex_matrix_value (); - if (! error_state) - { - FloatComplexLU fact (m); + FloatComplexLU fact (m); - switch (nargout) - { - case 0: - case 1: - retval(0) = fact.Y (); - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = fact.Y (); + break; - case 2: - { - PermMatrix P = fact.P (); - FloatComplexMatrix L = P.transpose () * fact.L (); - retval(1) = get_lu_u (fact); - retval(0) = L; - } - break; + case 2: + { + PermMatrix P = fact.P (); + FloatComplexMatrix L = P.transpose () * fact.L (); + retval(1) = get_lu_u (fact); + retval(0) = L; + } + break; - case 3: - default: - { - if (vecout) - retval(2) = fact.P_vec (); - else - retval(2) = fact.P (); - retval(1) = get_lu_u (fact); - retval(0) = get_lu_l (fact); - } - break; - } + case 3: + default: + { + if (vecout) + retval(2) = fact.P_vec (); + else + retval(2) = fact.P (); + retval(1) = get_lu_u (fact); + retval(0) = get_lu_l (fact); + } + break; } } else { ComplexMatrix m = arg.complex_matrix_value (); - if (! error_state) - { - ComplexLU fact (m); + ComplexLU fact (m); - switch (nargout) - { - case 0: - case 1: - retval(0) = fact.Y (); - break; + switch (nargout) + { + case 0: + case 1: + retval(0) = fact.Y (); + break; - case 2: - { - PermMatrix P = fact.P (); - ComplexMatrix L = P.transpose () * fact.L (); - retval(1) = get_lu_u (fact); - retval(0) = L; - } - break; + case 2: + { + PermMatrix P = fact.P (); + ComplexMatrix L = P.transpose () * fact.L (); + retval(1) = get_lu_u (fact); + retval(0) = L; + } + break; - case 3: - default: - { - if (vecout) - retval(2) = fact.P_vec (); - else - retval(2) = fact.P (); - retval(1) = get_lu_u (fact); - retval(0) = get_lu_l (fact); - } - break; - } + case 3: + default: + { + if (vecout) + retval(2) = fact.P_vec (); + else + retval(2) = fact.P (); + retval(1) = get_lu_u (fact); + retval(0) = get_lu_l (fact); + } + break; } } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/max.cc --- a/libinterp/corefcn/max.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/max.cc Mon Oct 05 19:29:36 2015 -0400 @@ -49,9 +49,6 @@ octave_value_list retval; ArrayType array = octave_value_extract (arg); - if (error_state) - return retval; - if (nargout == 2) { retval.resize (2); @@ -90,9 +87,6 @@ octave_value_list retval; charNDArray array = octave_value_extract (arg); - if (error_state) - return retval; - if (nargout == 2) { retval.resize (2); @@ -139,8 +133,8 @@ { // any/all don't have indexed versions, so do it via a conversion. retval = do_minmax_red_op (arg, nargout, dim, ismin); - if (! error_state) - retval(0) = retval(0).bool_array_value (); + + retval(0) = retval(0).bool_array_value (); } return retval; @@ -160,9 +154,7 @@ ScalarType x = octave_value_extract (argx); ArrayType y = octave_value_extract (argy); - if (error_state) - ; - else if (ismin) + if (ismin) retval = min (x, y); else retval = max (x, y); @@ -172,9 +164,7 @@ ArrayType x = octave_value_extract (argx); ScalarType y = octave_value_extract (argy); - if (error_state) - ; - else if (ismin) + if (ismin) retval = min (x, y); else retval = max (x, y); @@ -184,9 +174,7 @@ ArrayType x = octave_value_extract (argx); ArrayType y = octave_value_extract (argy); - if (error_state) - ; - else if (ismin) + if (ismin) retval = min (x, y); else retval = max (x, y); @@ -213,9 +201,7 @@ charNDArray x = octave_value_extract (argx); charNDArray y = octave_value_extract (argy); - if (error_state) - ; - else if (ismin) + if (ismin) { if (x.numel () == 1) retval = NDArray (min (x(0), y)); @@ -876,9 +862,6 @@ octave_value_list retval; ArrayType array = octave_value_extract (arg); - if (error_state) - return retval; - if (nargout == 2) { retval.resize (2); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/md5sum.cc --- a/libinterp/corefcn/md5sum.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/md5sum.cc Mon Oct 05 19:29:36 2015 -0400 @@ -59,18 +59,15 @@ if (nargin == 2) have_str = args(1).bool_value (); - if (!error_state) + if (have_str) + retval = oct_md5 (str); + else { - if (have_str) - retval = oct_md5 (str); - else - { - std::string fname = file_ops::tilde_expand (str); + std::string fname = file_ops::tilde_expand (str); - fname = find_data_file_in_load_path ("md5sum", fname); + fname = find_data_file_in_load_path ("md5sum", fname); - retval = oct_md5_file (fname); - } + retval = oct_md5_file (fname); } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/mex.cc --- a/libinterp/corefcn/mex.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/mex.cc Mon Oct 05 19:29:36 2015 -0400 @@ -3060,20 +3060,17 @@ octave_value_list retval; - if (! error_state) + if (nargout == 0 && argout[0]) { - if (nargout == 0 && argout[0]) - { - // We have something for ans. - nargout = 1; - } - - retval.resize (nargout); - - for (int i = 0; i < nargout; i++) - retval(i) = mxArray::as_octave_value (argout[i]); + // We have something for ans. + nargout = 1; } + retval.resize (nargout); + + for (int i = 0; i < nargout; i++) + retval(i) = mxArray::as_octave_value (argout[i]); + // Clean up mex resources. frame.run (); @@ -3287,9 +3284,6 @@ { octave_call_stack::goto_base_frame (); - if (error_state) - return retval; - frame.add_fcn (octave_call_stack::pop); } @@ -3350,9 +3344,6 @@ { octave_call_stack::goto_base_frame (); - if (error_state) - return 1; - frame.add_fcn (octave_call_stack::pop); } @@ -3396,10 +3387,12 @@ mexGet (double handle, const char *property) { mxArray *m = 0; + octave_value ret = get_property_from_handle (handle, property, "mexGet"); - if (!error_state && ret.is_defined ()) + if (ret.is_defined ()) m = ret.as_mxArray (); + return m; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/pager.cc --- a/libinterp/corefcn/pager.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/pager.cc Mon Oct 05 19:29:36 2015 -0400 @@ -545,9 +545,6 @@ string_vector argv = args.make_argv ("diary"); - if (error_state) - return retval; - if (diary_file.empty ()) diary_file = "diary"; @@ -626,9 +623,6 @@ string_vector argv = args.make_argv ("more"); - if (error_state) - return retval; - if (argc == 2) { std::string arg = argv[1]; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/pinv.cc --- a/libinterp/corefcn/pinv.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/pinv.cc Mon Oct 05 19:29:36 2015 -0400 @@ -83,9 +83,6 @@ if (nargin == 2) tol = args(1).float_value (); - if (error_state) - return retval; - if (tol < 0.0) { error ("pinv: TOL must be greater than zero"); @@ -103,9 +100,6 @@ if (nargin == 2) tol = args(1).double_value (); - if (error_state) - return retval; - if (tol < 0.0) { error ("pinv: TOL must be greater than zero"); @@ -128,9 +122,6 @@ if (nargin == 2) tol = args(1).float_value (); - if (error_state) - return retval; - if (tol < 0.0) { error ("pinv: TOL must be greater than zero"); @@ -141,20 +132,16 @@ { FloatMatrix m = arg.float_matrix_value (); - if (! error_state) - retval = m.pseudo_inverse (tol); + retval = m.pseudo_inverse (tol); } else if (arg.is_complex_type ()) { FloatComplexMatrix m = arg.float_complex_matrix_value (); - if (! error_state) - retval = m.pseudo_inverse (tol); + retval = m.pseudo_inverse (tol); } else - { - gripe_wrong_type_arg ("pinv", arg); - } + gripe_wrong_type_arg ("pinv", arg); } else { @@ -162,9 +149,6 @@ if (nargin == 2) tol = args(1).double_value (); - if (error_state) - return retval; - if (tol < 0.0) { error ("pinv: TOL must be greater than zero"); @@ -175,20 +159,16 @@ { Matrix m = arg.matrix_value (); - if (! error_state) - retval = m.pseudo_inverse (tol); + retval = m.pseudo_inverse (tol); } else if (arg.is_complex_type ()) { ComplexMatrix m = arg.complex_matrix_value (); - if (! error_state) - retval = m.pseudo_inverse (tol); + retval = m.pseudo_inverse (tol); } else - { - gripe_wrong_type_arg ("pinv", arg); - } + gripe_wrong_type_arg ("pinv", arg); } return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/pr-output.cc Mon Oct 05 19:29:36 2015 -0400 @@ -3442,46 +3442,43 @@ if (nargin == 2) rat_string_len = args(1).nint_value (); - if (! error_state) + octave_value arg = args(0); + + if (arg.is_numeric_type ()) { - octave_value arg = args(0); - - if (arg.is_numeric_type ()) + frame.protect_var (rat_format); + + rat_format = true; + + std::ostringstream buf; + arg.print (buf); + std::string s = buf.str (); + + std::list lst; + + size_t n = 0; + size_t s_len = s.length (); + + while (n < s_len) { - frame.protect_var (rat_format); - - rat_format = true; - - std::ostringstream buf; - arg.print (buf); - std::string s = buf.str (); - - std::list lst; - - size_t n = 0; - size_t s_len = s.length (); - - while (n < s_len) + size_t m = s.find ('\n', n); + + if (m == std::string::npos) + { + lst.push_back (s.substr (n)); + break; + } + else { - size_t m = s.find ('\n', n); - - if (m == std::string::npos) - { - lst.push_back (s.substr (n)); - break; - } - else - { - lst.push_back (s.substr (n, m - n)); - n = m + 1; - } + lst.push_back (s.substr (n, m - n)); + n = m + 1; } - - retval = string_vector (lst); } - else - error ("rats: X must be numeric"); + + retval = string_vector (lst); } + else + error ("rats: X must be numeric"); } return retval; @@ -3565,17 +3562,14 @@ octave_stream os = octave_stream_list::lookup (fid, "fdisp"); - if (! error_state) - { - std::ostream *osp = os.output_stream (); - - octave_value arg = args(1); - - if (osp) - arg.print (*osp); - else - error ("fdisp: stream FID not open for writing"); - } + std::ostream *osp = os.output_stream (); + + octave_value arg = args(1); + + if (osp) + arg.print (*osp); + else + error ("fdisp: stream FID not open for writing"); } else print_usage (); @@ -4069,9 +4063,6 @@ string_vector argv = args.make_argv ("format"); - if (error_state) - return retval; - set_format_style (argc, argv); return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/qz.cc --- a/libinterp/corefcn/qz.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/qz.cc Mon Oct 05 19:29:36 2015 -0400 @@ -495,9 +495,6 @@ else aa = args(0).matrix_value (); - if (error_state) - return retval; - #ifdef DEBUG std::cout << "qz: check argument 2" << std::endl; #endif @@ -517,9 +514,6 @@ else bb = args(1).matrix_value (); - if (error_state) - return retval; - // Both matrices loaded, now let's check what kind of arithmetic: // declared volatile to avoid compiler warnings about long jumps, // vforks. diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/schur.cc --- a/libinterp/corefcn/schur.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/schur.cc Mon Oct 05 19:29:36 2015 -0400 @@ -194,39 +194,32 @@ { FloatMatrix tmp = arg.float_matrix_value (); - if (! error_state) + if (nargout == 0 || nargout == 1) { - if (nargout == 0 || nargout == 1) - { - FloatSCHUR result (tmp, ord, false); - retval(0) = result.schur_matrix (); - } - else - { - FloatSCHUR result (tmp, ord, true); - retval(1) = result.schur_matrix (); - retval(0) = result.unitary_matrix (); - } + FloatSCHUR result (tmp, ord, false); + retval(0) = result.schur_matrix (); + } + else + { + FloatSCHUR result (tmp, ord, true); + retval(1) = result.schur_matrix (); + retval(0) = result.unitary_matrix (); } } else { FloatComplexMatrix ctmp = arg.float_complex_matrix_value (); - if (! error_state) + if (nargout == 0 || nargout == 1) { - - if (nargout == 0 || nargout == 1) - { - FloatComplexSCHUR result (ctmp, ord, false); - retval(0) = mark_upper_triangular (result.schur_matrix ()); - } - else - { - FloatComplexSCHUR result (ctmp, ord, true); - retval(1) = mark_upper_triangular (result.schur_matrix ()); - retval(0) = result.unitary_matrix (); - } + FloatComplexSCHUR result (ctmp, ord, false); + retval(0) = mark_upper_triangular (result.schur_matrix ()); + } + else + { + FloatComplexSCHUR result (ctmp, ord, true); + retval(1) = mark_upper_triangular (result.schur_matrix ()); + retval(0) = result.unitary_matrix (); } } } @@ -236,39 +229,32 @@ { Matrix tmp = arg.matrix_value (); - if (! error_state) + if (nargout == 0 || nargout == 1) { - if (nargout == 0 || nargout == 1) - { - SCHUR result (tmp, ord, false); - retval(0) = result.schur_matrix (); - } - else - { - SCHUR result (tmp, ord, true); - retval(1) = result.schur_matrix (); - retval(0) = result.unitary_matrix (); - } + SCHUR result (tmp, ord, false); + retval(0) = result.schur_matrix (); + } + else + { + SCHUR result (tmp, ord, true); + retval(1) = result.schur_matrix (); + retval(0) = result.unitary_matrix (); } } else { ComplexMatrix ctmp = arg.complex_matrix_value (); - if (! error_state) + if (nargout == 0 || nargout == 1) { - - if (nargout == 0 || nargout == 1) - { - ComplexSCHUR result (ctmp, ord, false); - retval(0) = mark_upper_triangular (result.schur_matrix ()); - } - else - { - ComplexSCHUR result (ctmp, ord, true); - retval(1) = mark_upper_triangular (result.schur_matrix ()); - retval(0) = result.unitary_matrix (); - } + ComplexSCHUR result (ctmp, ord, false); + retval(0) = mark_upper_triangular (result.schur_matrix ()); + } + else + { + ComplexSCHUR result (ctmp, ord, true); + retval(1) = mark_upper_triangular (result.schur_matrix ()); + retval(0) = result.unitary_matrix (); } } } @@ -334,25 +320,21 @@ { FloatMatrix u = args(0).float_matrix_value (); FloatMatrix t = args(1).float_matrix_value (); - if (! error_state) - { - FloatComplexSCHUR cs (FloatSCHUR (t, u)); + + FloatComplexSCHUR cs (FloatSCHUR (t, u)); - retval(1) = cs.schur_matrix (); - retval(0) = cs.unitary_matrix (); - } + retval(1) = cs.schur_matrix (); + retval(0) = cs.unitary_matrix (); } else { Matrix u = args(0).matrix_value (); Matrix t = args(1).matrix_value (); - if (! error_state) - { - ComplexSCHUR cs (SCHUR (t, u)); + + ComplexSCHUR cs (SCHUR (t, u)); - retval(1) = cs.schur_matrix (); - retval(0) = cs.unitary_matrix (); - } + retval(1) = cs.schur_matrix (); + retval(0) = cs.unitary_matrix (); } } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/sparse.cc --- a/libinterp/corefcn/sparse.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/sparse.cc Mon Oct 05 19:29:36 2015 -0400 @@ -152,13 +152,10 @@ get_dimensions (args(0), args(1), "sparse", m, n); - if (! error_state) - { - if (m >= 0 && n >= 0) - retval = SparseMatrix (m, n); - else - error ("sparse: dimensions must be non-negative"); - } + if (m >= 0 && n >= 0) + retval = SparseMatrix (m, n); + else + error ("sparse: dimensions must be non-negative"); } else if (nargin >= 3) { @@ -176,55 +173,48 @@ nargin -= 1; } - if (! error_state) + octave_idx_type m, n, nzmax; + m = n = nzmax = -1; + if (nargin == 6) { - octave_idx_type m, n, nzmax; - m = n = nzmax = -1; - if (nargin == 6) - { - nzmax = args(5).idx_type_value (); - nargin --; - } + nzmax = args(5).idx_type_value (); + nargin --; + } - if (nargin == 5) - { - get_dimensions (args(3), args(4), "sparse", m, n); + if (nargin == 5) + { + get_dimensions (args(3), args(4), "sparse", m, n); - if (! error_state && (m < 0 || n < 0)) - error ("sparse: dimensions must be non-negative"); - } - else if (nargin != 3) - print_usage (); + if (! error_state && (m < 0 || n < 0)) + error ("sparse: dimensions must be non-negative"); + } + else if (nargin != 3) + print_usage (); - if (! error_state) - { - int k = 0; // index we're checking when index_vector throws - try - { - idx_vector i = args(0).index_vector (); - k = 1; - idx_vector j = args(1).index_vector (); + int k = 0; // index we're checking when index_vector throws + try + { + idx_vector i = args(0).index_vector (); + k = 1; + idx_vector j = args(1).index_vector (); - if (args(2).is_bool_type ()) - retval = SparseBoolMatrix (args(2).bool_array_value (), i,j, - m, n, summation, nzmax); - else if (args(2).is_complex_type ()) - retval = SparseComplexMatrix (args(2).complex_array_value(), - i, j, m, n, summation, nzmax); - else if (args(2).is_numeric_type ()) - retval = SparseMatrix (args(2).array_value (), i, j, - m, n, summation, nzmax); - else - gripe_wrong_type_arg ("sparse", args(2)); - } - catch (index_exception& e) - { - // Rethrow to allow more info to be reported later. - e.set_pos_if_unset (2, k+1); - throw; - } - } - + if (args(2).is_bool_type ()) + retval = SparseBoolMatrix (args(2).bool_array_value (), i,j, + m, n, summation, nzmax); + else if (args(2).is_complex_type ()) + retval = SparseComplexMatrix (args(2).complex_array_value(), + i, j, m, n, summation, nzmax); + else if (args(2).is_numeric_type ()) + retval = SparseMatrix (args(2).array_value (), i, j, + m, n, summation, nzmax); + else + gripe_wrong_type_arg ("sparse", args(2)); + } + catch (index_exception& e) + { + // Rethrow to allow more info to be reported later. + e.set_pos_if_unset (2, k+1); + throw; } } @@ -277,11 +267,11 @@ octave_idx_type m = args(0).idx_type_value (); octave_idx_type n = args(1).idx_type_value (); octave_idx_type nz = 0; + if (nargin == 3) nz = args(2).idx_type_value (); - if (error_state) - ; - else if (m >= 0 && n >= 0 && nz >= 0) + + if (m >= 0 && n >= 0 && nz >= 0) retval = SparseMatrix (dim_vector (m, n), nz); else error ("spalloc: M,N,NZ must be non-negative"); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/sqrtm.cc --- a/libinterp/corefcn/sqrtm.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/sqrtm.cc Mon Oct 05 19:29:36 2015 -0400 @@ -248,7 +248,7 @@ else if (arg.is_numeric_type ()) retval(0) = do_sqrtm (arg); - if (nargout > 1 && ! error_state) + if (nargout > 1) { // This corresponds to generic code // diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/str2double.cc --- a/libinterp/corefcn/str2double.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/str2double.cc Mon Oct 05 19:29:36 2015 -0400 @@ -358,24 +358,21 @@ else { const string_vector sv = args(0).all_strings (); - if (! error_state) - retval = sv.map (str2double1); + + retval = sv.map (str2double1); } } else if (args(0).is_cell ()) { const Cell cell = args(0).cell_value (); - if (! error_state) + ComplexNDArray output (cell.dims (), octave_NaN); + for (octave_idx_type i = 0; i < cell.numel (); i++) { - ComplexNDArray output (cell.dims (), octave_NaN); - for (octave_idx_type i = 0; i < cell.numel (); i++) - { - if (cell(i).is_string ()) - output(i) = str2double1 (cell(i).string_value ()); - } - retval = output; + if (cell(i).is_string ()) + output(i) = str2double1 (cell(i).string_value ()); } + retval = output; } else retval = Matrix (1, 1, octave_NaN); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/strfns.cc --- a/libinterp/corefcn/strfns.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/strfns.cc Mon Oct 05 19:29:36 2015 -0400 @@ -695,16 +695,13 @@ { octave_idx_type n = args(2).idx_type_value (); - if (! error_state) + if (n > 0) { - if (n > 0) - { - retval = do_strcmp_fun (args(0), args(1), n, "strncmp", - strncmp_array_op, strncmp_str_op); - } - else - error ("strncmp: N must be greater than 0"); + retval = do_strcmp_fun (args(0), args(1), n, "strncmp", + strncmp_array_op, strncmp_str_op); } + else + error ("strncmp: N must be greater than 0"); } else print_usage (); @@ -838,16 +835,13 @@ { octave_idx_type n = args(2).idx_type_value (); - if (! error_state) + if (n > 0) { - if (n > 0) - { - retval = do_strcmp_fun (args(0), args(1), n, "strncmpi", - strncmpi_array_op, strncmpi_str_op); - } - else - error ("strncmpi: N must be greater than 0"); + retval = do_strcmp_fun (args(0), args(1), n, "strncmpi", + strncmpi_array_op, strncmpi_str_op); } + else + error ("strncmpi: N must be greater than 0"); } else print_usage (); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/sub2ind.cc --- a/libinterp/corefcn/sub2ind.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/sub2ind.cc Mon Oct 05 19:29:36 2015 -0400 @@ -92,42 +92,31 @@ dim_vector dv = get_dim_vector (args(0), "sub2ind"); Array idxa (dim_vector (nargin-1, 1)); - if (! error_state) + dv = dv.redim (nargin - 1); + for (int j = 0; j < nargin - 1; j++) { - dv = dv.redim (nargin - 1); - for (int j = 0; j < nargin - 1; j++) + if (args(j+1).is_numeric_type ()) { - if (args(j+1).is_numeric_type ()) + try { - try - { - idxa(j) = args(j+1).index_vector (); - if (error_state) - break; - else if (j > 0 && args(j+1).dims () != args(1).dims ()) - error ("sub2ind: all subscripts must be of the same size"); - } - catch (index_exception& e) - { - e.set_pos_if_unset (nargin-1, j+1); - e.set_var (""); // no particular variable - (*current_liboctave_error_with_id_handler) - (e.id(), e.err()); - } + idxa(j) = args(j+1).index_vector (); + + if (j > 0 && args(j+1).dims () != args(1).dims ()) + error ("sub2ind: all subscripts must be of the same size"); } - else - error ("sub2ind: subscripts must be numeric"); - - if (error_state) - break; + catch (index_exception& e) + { + e.set_pos_if_unset (nargin-1, j+1); + e.set_var (""); // no particular variable + (*current_liboctave_error_with_id_handler) + (e.id(), e.err()); + } } + else + error ("sub2ind: subscripts must be numeric"); } - if (! error_state) - { - idx_vector idx = sub2ind (dv, idxa); - retval = idx; - } + retval = sub2ind (dv, idxa); } return retval; @@ -205,17 +194,15 @@ else { dim_vector dv = get_dim_vector (args(0), "ind2sub"); + try { idx_vector idx = args(1).index_vector (); - if (! error_state) - { - if (nargout > dv.length ()) - dv = dv.redim (nargout); - Array idxa = ind2sub (dv, idx); - retval = Array (idxa); - } + if (nargout > dv.length ()) + dv = dv.redim (nargout); + + retval = Array (ind2sub (dv, idx)); } catch (index_exception& e) { diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/sysdep.cc --- a/libinterp/corefcn/sysdep.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/sysdep.cc Mon Oct 05 19:29:36 2015 -0400 @@ -620,8 +620,7 @@ { std::string name = args(0).string_value (); - if (! error_state) - retval = octave_env::getenv (name); + retval = octave_env::getenv (name); } else print_usage (); @@ -700,11 +699,7 @@ { std::string tmp = args(0).string_value (); - if (! error_state) - { - int status = gnulib::unsetenv (tmp.c_str ()); - retval = status; - } + retval = gnulib::unsetenv (tmp.c_str ()); } else print_usage (); @@ -805,23 +800,20 @@ { double dval = args(0).double_value (); - if (! error_state) + if (! xisnan (dval)) { - if (! xisnan (dval)) - { - Fdrawnow (); + Fdrawnow (); - if (xisinf (dval)) - { - flush_octave_stdout (); - octave_kbhit (); - } - else - octave_sleep (dval); + if (xisinf (dval)) + { + flush_octave_stdout (); + octave_kbhit (); } else - warning ("pause: NaN is an invalid delay"); + octave_sleep (dval); } + else + warning ("pause: NaN is an invalid delay"); } else { @@ -853,15 +845,12 @@ { double dval = args(0).double_value (); - if (! error_state) + if (xisnan (dval)) + warning ("sleep: NaN is an invalid delay"); + else { - if (xisnan (dval)) - warning ("sleep: NaN is an invalid delay"); - else - { - Fdrawnow (); - octave_sleep (dval); - } + Fdrawnow (); + octave_sleep (dval); } } else @@ -896,19 +885,16 @@ { double dval = args(0).double_value (); - if (! error_state) + if (xisnan (dval)) + warning ("usleep: NaN is an invalid delay"); + else { - if (xisnan (dval)) - warning ("usleep: NaN is an invalid delay"); - else - { - Fdrawnow (); + Fdrawnow (); - int delay = NINT (dval); + int delay = NINT (dval); - if (delay > 0) - octave_usleep (delay); - } + if (delay > 0) + octave_usleep (delay); } } else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/time.cc --- a/libinterp/corefcn/time.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/time.cc Mon Oct 05 19:29:36 2015 -0400 @@ -166,8 +166,7 @@ { double tmp = args(0).double_value (); - if (! error_state) - retval = octave_value (mk_tm_map (octave_gmtime (tmp))); + retval = octave_value (mk_tm_map (octave_gmtime (tmp))); } else print_usage (); @@ -228,8 +227,7 @@ { double tmp = args(0).double_value (); - if (! error_state) - retval = octave_value (mk_tm_map (octave_localtime (tmp))); + retval = octave_value (mk_tm_map (octave_localtime (tmp))); } else print_usage (); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/toplev.cc Mon Oct 05 19:29:36 2015 -0400 @@ -1249,17 +1249,14 @@ error ("atexit: FLAG argument must be a logical value"); } - if (! error_state) + if (add_mode) + octave_add_atexit_function (arg); + else { - if (add_mode) - octave_add_atexit_function (arg); - else - { - bool found = octave_remove_atexit_function (arg); + bool found = octave_remove_atexit_function (arg); - if (nargout > 0) - retval(0) = found; - } + if (nargout > 0) + retval(0) = found; } } else @@ -1550,20 +1547,17 @@ { std::string arg = args(0).string_value (); - if (! error_state) + if (m.isfield (arg)) { - if (m.isfield (arg)) - { - Cell c = m.contents (arg); + Cell c = m.contents (arg); - if (c.is_empty ()) - error ("octave_config_info: no info for '%s'", arg.c_str ()); - else - retval = c(0); - } + if (c.is_empty ()) + error ("octave_config_info: no info for '%s'", arg.c_str ()); else - error ("octave_config_info: invalid parameter '%s'", arg.c_str ()); + retval = c(0); } + else + error ("octave_config_info: invalid parameter '%s'", arg.c_str ()); } else if (nargin == 0) retval = m; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/tril.cc --- a/libinterp/corefcn/tril.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/tril.cc Mon Oct 05 19:29:36 2015 -0400 @@ -202,12 +202,7 @@ } if (nargin == 2) - { - k = args(1).int_value (true); - - if (error_state) - return retval; - } + k = args(1).int_value (true); if (nargin < 1 || nargin > 2) print_usage (); @@ -312,9 +307,6 @@ idx.push_back (ov_idx); tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx)); - - if (error_state) - return retval; } } else @@ -330,9 +322,6 @@ idx.push_back (ov_idx); tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx)); - - if (error_state) - return retval; } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/tsearch.cc --- a/libinterp/corefcn/tsearch.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/tsearch.cc Mon Oct 05 19:29:36 2015 -0400 @@ -86,9 +86,6 @@ const ColumnVector xi (args(3).vector_value ()); const ColumnVector yi (args(4).vector_value ()); - if (error_state) - return retval; - const octave_idx_type nelem = elem.rows (); ColumnVector minx (nelem); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/corefcn/typecast.cc --- a/libinterp/corefcn/typecast.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/typecast.cc Mon Oct 05 19:29:36 2015 -0400 @@ -212,7 +212,7 @@ std::string numclass = args(1).string_value (); - if (error_state || numclass.size () == 0) + if (numclass.size () == 0) ; else if (numclass == "char") retval = octave_value (reinterpret_copy @@ -253,7 +253,7 @@ else if (numclass == "double complex") retval = reinterpret_copy (data, byte_size, old_dims); - if (! error_state && retval.is_undefined ()) + if (retval.is_undefined ()) error ("typecast: cannot convert to %s class", numclass.c_str ()); } else @@ -347,7 +347,7 @@ std::string numclass = args(1).string_value (); - if (error_state || numclass.size () == 0) + if (numclass.size () == 0) ; else if (numclass == "char") retval = octave_value (do_bitpack (bitp), '\''); @@ -382,7 +382,7 @@ else if (numclass == "double complex") retval = do_bitpack (bitp); - if (! error_state && retval.is_undefined ()) + if (retval.is_undefined ()) error ("bitpack: cannot pack to %s class", numclass.c_str ()); } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/__init_gnuplot__.cc --- a/libinterp/dldfcn/__init_gnuplot__.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/__init_gnuplot__.cc Mon Oct 05 19:29:36 2015 -0400 @@ -151,20 +151,17 @@ octave_value_list args; Matrix fids = pstream.matrix_value (); - if (! error_state) - { - Ffputs (ovl (fids(0), "\nquit;\n")); + Ffputs (ovl (fids(0), "\nquit;\n")); - Ffflush (ovl (fids(0))); - Fpclose (ovl (fids(0))); + Ffflush (ovl (fids(0))); + Fpclose (ovl (fids(0))); - if (fids.numel () > 1) - { - Fpclose (ovl (fids(1))); + if (fids.numel () > 1) + { + Fpclose (ovl (fids(1))); - if (fids.numel () > 2) - Fwaitpid (ovl (fids(2))); - } + if (fids.numel () > 2) + Fwaitpid (ovl (fids(2))); } } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/__magick_read__.cc --- a/libinterp/dldfcn/__magick_read__.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/__magick_read__.cc Mon Oct 05 19:29:36 2015 -0400 @@ -757,8 +757,6 @@ std::vector imvec; read_file (args(0).string_value (), imvec); - if (error_state) - return output; // Prepare an Array with the indexes for the requested frames. const octave_idx_type nFrames = imvec.size (); @@ -1514,8 +1512,7 @@ { std::vector ini_imvec; read_file (filename, ini_imvec); - if (error_state) - return retval; + if (ini_imvec.size () > 0) { ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ()); @@ -1567,8 +1564,6 @@ #undef COMPRESS_MAGICK_IMAGE_VECTOR write_file (filename, ext, imvec); - if (error_state) - return retval; #endif return retval; @@ -1831,8 +1826,7 @@ std::vector imvec; read_file (filename, imvec); - if (error_state) - return retval; + const octave_idx_type nFrames = imvec.size (); const std::string format = imvec[0].magick (); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/__osmesa_print__.cc --- a/libinterp/dldfcn/__osmesa_print__.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/__osmesa_print__.cc Mon Oct 05 19:29:36 2015 -0400 @@ -182,41 +182,38 @@ std::string file = args(1).string_value (); std::string term = args(2).string_value (); - if (! error_state) - { - size_t pos_p = file.find_first_of ("|"); - size_t pos_c = file.find_first_not_of ("| "); + size_t pos_p = file.find_first_of ("|"); + size_t pos_c = file.find_first_not_of ("| "); - if (pos_p == std::string::npos && pos_c == std::string::npos) - error ("__osmesa_print__: empty output ''"); - else if (pos_c == std::string::npos) - error ("__osmesa_print__: empty pipe '|'"); - else if (pos_p != std::string::npos && pos_p < pos_c) + if (pos_p == std::string::npos && pos_c == std::string::npos) + error ("__osmesa_print__: empty output ''"); + else if (pos_c == std::string::npos) + error ("__osmesa_print__: empty pipe '|'"); + else if (pos_p != std::string::npos && pos_p < pos_c) + { + // create process and pipe gl2ps output to it + std::string cmd = file.substr (pos_c); + gl2ps_print (fobj, cmd, term); + } + else + { + // write gl2ps output directly to file + FILE *filep = gnulib::fopen (file.substr (pos_c).c_str (), "w"); + + if (filep) { - // create process and pipe gl2ps output to it - std::string cmd = file.substr (pos_c); - gl2ps_print (fobj, cmd, term); + unwind_protect frame; + + frame.add_fcn (close_fcn, filep); + + glps_renderer rend (filep, term); + rend.draw (fobj, ""); + + // Make sure buffered commands are finished!!! + glFinish (); } else - { - // write gl2ps output directly to file - FILE *filep = gnulib::fopen (file.substr (pos_c).c_str (), "w"); - - if (filep) - { - unwind_protect frame; - - frame.add_fcn (close_fcn, filep); - - glps_renderer rend (filep, term); - rend.draw (fobj, ""); - - // Make sure buffered commands are finished!!! - glFinish (); - } - else - error ("__osmesa_print__: Couldn't create file \"%s\"", file.c_str ()); - } + error ("__osmesa_print__: Couldn't create file \"%s\"", file.c_str ()); } #endif } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/amd.cc --- a/libinterp/dldfcn/amd.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/amd.cc Mon Oct 05 19:29:36 2015 -0400 @@ -133,67 +133,66 @@ if (!error_state && n_row != n_col) error ("amd: matrix S must be square"); - if (!error_state) + OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL); + AMD_NAME (_defaults) (Control) ; + if (nargin > 1) { - OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL); - AMD_NAME (_defaults) (Control) ; - if (nargin > 1) - { - octave_scalar_map arg1 = args(1).scalar_map_value (); - - if (!error_state) - { - octave_value tmp; - - tmp = arg1.getfield ("dense"); - if (tmp.is_defined ()) - Control[AMD_DENSE] = tmp.double_value (); - - tmp = arg1.getfield ("aggressive"); - if (tmp.is_defined ()) - Control[AMD_AGGRESSIVE] = tmp.double_value (); - } - else - error ("amd: OPTS argument must be a scalar structure"); - } + octave_scalar_map arg1 = args(1).scalar_map_value (); if (!error_state) { - OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col); - Matrix xinfo (AMD_INFO, 1); - double *Info = xinfo.fortran_vec (); + octave_value tmp; + + tmp = arg1.getfield ("dense"); + if (tmp.is_defined ()) + Control[AMD_DENSE] = tmp.double_value (); - // FIXME: how can we manage the memory allocation of amd - // in a cleaner manner? - SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc); - SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free); - SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc); - SUITESPARSE_ASSIGN_FPTR (realloc_func, amd_realloc, realloc); - SUITESPARSE_ASSIGN_FPTR (printf_func, amd_printf, printf); + tmp = arg1.getfield ("aggressive"); + if (tmp.is_defined ()) + Control[AMD_AGGRESSIVE] = tmp.double_value (); + } + else + error ("amd: OPTS argument must be a scalar structure"); + } - octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P, - Control, Info); + if (!error_state) + { + OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col); + Matrix xinfo (AMD_INFO, 1); + double *Info = xinfo.fortran_vec (); - switch (result) - { - case AMD_OUT_OF_MEMORY: - error ("amd: out of memory"); - break; - case AMD_INVALID: - error ("amd: matrix S is corrupted"); - break; - default: - { - if (nargout > 1) - retval(1) = xinfo; + // FIXME: how can we manage the memory allocation of amd + // in a cleaner manner? + SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc); + SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free); + SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc); + SUITESPARSE_ASSIGN_FPTR (realloc_func, amd_realloc, realloc); + SUITESPARSE_ASSIGN_FPTR (printf_func, amd_printf, printf); + + octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P, + Control, Info); - Matrix Pout (1, n_col); - for (octave_idx_type i = 0; i < n_col; i++) - Pout.xelem (i) = P[i] + 1; + switch (result) + { + case AMD_OUT_OF_MEMORY: + error ("amd: out of memory"); + break; + + case AMD_INVALID: + error ("amd: matrix S is corrupted"); + break; - retval(0) = Pout; - } - } + default: + { + if (nargout > 1) + retval(1) = xinfo; + + Matrix Pout (1, n_col); + for (octave_idx_type i = 0; i < n_col; i++) + Pout.xelem (i) = P[i] + 1; + + retval(0) = Pout; + } } } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/audiodevinfo.cc --- a/libinterp/dldfcn/audiodevinfo.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/audiodevinfo.cc Mon Oct 05 19:29:36 2015 -0400 @@ -570,7 +570,7 @@ octave_value_list retval = feval (player->octave_callback_function, ovl (static_cast (frames)), 1); - if (error_state || retval.length () < 2) + if (retval.length () < 2) { error ("audio player callback function failed"); return paAbort; @@ -579,8 +579,8 @@ const Matrix sound = retval(0).matrix_value (); int return_status = retval(1).int_value (); - if (error_state || (frames - sound.rows () != 0) - || sound.columns () < 1 || sound.columns () > 2) + if (frames - sound.rows () != 0 || sound.columns () < 1 + || sound.columns () > 2) { error ("audio player callback function failed"); return paAbort; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/dmperm.cc --- a/libinterp/dldfcn/dmperm.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/dmperm.cc Mon Oct 05 19:29:36 2015 -0400 @@ -82,51 +82,49 @@ csm.i = cm.xridx (); } - if (!error_state) + if (nargout <= 1 || rank) { - if (nargout <= 1 || rank) - { #if defined(CS_VER) && (CS_VER >= 2) - octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm, 0); + octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm, 0); #else - octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm); + octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm); #endif - if (rank) - { - octave_idx_type r = 0; - for (octave_idx_type i = 0; i < nc; i++) - if (jmatch[nr+i] >= 0) - r++; - retval(0) = static_cast(r); - } - else - retval(0) = put_int (jmatch + nr, nc); - CXSPARSE_NAME (_free) (jmatch); + if (rank) + { + octave_idx_type r = 0; + for (octave_idx_type i = 0; i < nc; i++) + if (jmatch[nr+i] >= 0) + r++; + retval(0) = static_cast(r); } else - { + retval(0) = put_int (jmatch + nr, nc); + CXSPARSE_NAME (_free) (jmatch); + } + else + { #if defined(CS_VER) && (CS_VER >= 2) - CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm, 0); + CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm, 0); #else - CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm); + CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm); #endif - //retval(5) = put_int (dm->rr, 5); - //retval(4) = put_int (dm->cc, 5); + //retval(5) = put_int (dm->rr, 5); + //retval(4) = put_int (dm->cc, 5); #if defined(CS_VER) && (CS_VER >= 2) - retval(3) = put_int (dm->s, dm->nb+1); - retval(2) = put_int (dm->r, dm->nb+1); - retval(1) = put_int (dm->q, nc); - retval(0) = put_int (dm->p, nr); + retval(3) = put_int (dm->s, dm->nb+1); + retval(2) = put_int (dm->r, dm->nb+1); + retval(1) = put_int (dm->q, nc); + retval(0) = put_int (dm->p, nr); #else - retval(3) = put_int (dm->S, dm->nb+1); - retval(2) = put_int (dm->R, dm->nb+1); - retval(1) = put_int (dm->Q, nc); - retval(0) = put_int (dm->P, nr); + retval(3) = put_int (dm->S, dm->nb+1); + retval(2) = put_int (dm->R, dm->nb+1); + retval(1) = put_int (dm->Q, nc); + retval(0) = put_int (dm->P, nr); #endif - CXSPARSE_NAME (_dfree) (dm); - } + CXSPARSE_NAME (_dfree) (dm); } + return retval; } #endif diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/fftw.cc --- a/libinterp/dldfcn/fftw.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/fftw.cc Mon Oct 05 19:29:36 2015 -0400 @@ -157,60 +157,55 @@ std::transform (arg0.begin (), arg0.end (), arg0.begin (), tolower); std::string arg1 = args(1).string_value (); - if (!error_state) - { - std::transform (arg1.begin (), arg1.end (), - arg1.begin (), tolower); - octave_fftw_planner::FftwMethod meth - = octave_fftw_planner::UNKNOWN; - octave_float_fftw_planner::FftwMethod methf - = octave_float_fftw_planner::UNKNOWN; + + std::transform (arg1.begin (), arg1.end (), + arg1.begin (), tolower); + octave_fftw_planner::FftwMethod meth + = octave_fftw_planner::UNKNOWN; + octave_float_fftw_planner::FftwMethod methf + = octave_float_fftw_planner::UNKNOWN; - if (arg1 == "estimate") - { - meth = octave_fftw_planner::ESTIMATE; - methf = octave_float_fftw_planner::ESTIMATE; - } - else if (arg1 == "measure") - { - meth = octave_fftw_planner::MEASURE; - methf = octave_float_fftw_planner::MEASURE; - } - else if (arg1 == "patient") - { - meth = octave_fftw_planner::PATIENT; - methf = octave_float_fftw_planner::PATIENT; - } - else if (arg1 == "exhaustive") - { - meth = octave_fftw_planner::EXHAUSTIVE; - methf = octave_float_fftw_planner::EXHAUSTIVE; - } - else if (arg1 == "hybrid") - { - meth = octave_fftw_planner::HYBRID; - methf = octave_float_fftw_planner::HYBRID; - } - else - error ("fftw: unrecognized planner METHOD"); + if (arg1 == "estimate") + { + meth = octave_fftw_planner::ESTIMATE; + methf = octave_float_fftw_planner::ESTIMATE; + } + else if (arg1 == "measure") + { + meth = octave_fftw_planner::MEASURE; + methf = octave_float_fftw_planner::MEASURE; + } + else if (arg1 == "patient") + { + meth = octave_fftw_planner::PATIENT; + methf = octave_float_fftw_planner::PATIENT; + } + else if (arg1 == "exhaustive") + { + meth = octave_fftw_planner::EXHAUSTIVE; + methf = octave_float_fftw_planner::EXHAUSTIVE; + } + else if (arg1 == "hybrid") + { + meth = octave_fftw_planner::HYBRID; + methf = octave_float_fftw_planner::HYBRID; + } + else + error ("fftw: unrecognized planner METHOD"); - if (!error_state) - { - meth = octave_fftw_planner::method (meth); - octave_float_fftw_planner::method (methf); + meth = octave_fftw_planner::method (meth); + octave_float_fftw_planner::method (methf); - if (meth == octave_fftw_planner::MEASURE) - retval = octave_value ("measure"); - else if (meth == octave_fftw_planner::PATIENT) - retval = octave_value ("patient"); - else if (meth == octave_fftw_planner::EXHAUSTIVE) - retval = octave_value ("exhaustive"); - else if (meth == octave_fftw_planner::HYBRID) - retval = octave_value ("hybrid"); - else - retval = octave_value ("estimate"); - } - } + if (meth == octave_fftw_planner::MEASURE) + retval = octave_value ("measure"); + else if (meth == octave_fftw_planner::PATIENT) + retval = octave_value ("patient"); + else if (meth == octave_fftw_planner::EXHAUSTIVE) + retval = octave_value ("exhaustive"); + else if (meth == octave_fftw_planner::HYBRID) + retval = octave_value ("hybrid"); + else + retval = octave_value ("estimate"); } else error ("fftw: planner expects a string value as METHOD"); @@ -242,26 +237,28 @@ std::transform (arg0.begin (), arg0.end (), arg0.begin (), tolower); std::string arg1 = args(1).string_value (); - if (!error_state) - { - char *str = fftw_export_wisdom_to_string (); + + char *str = fftw_export_wisdom_to_string (); - if (arg1.length () < 1) - fftw_forget_wisdom (); - else if (! fftw_import_wisdom_from_string (arg1.c_str ())) - error ("fftw: could not import supplied WISDOM"); + if (arg1.length () < 1) + fftw_forget_wisdom (); + else if (! fftw_import_wisdom_from_string (arg1.c_str ())) + error ("fftw: could not import supplied WISDOM"); - if (!error_state) - retval = octave_value (std::string (str)); + retval = octave_value (std::string (str)); - free (str); - } + // FIXME: need to free string even if there is an + // exception. + free (str); } } else //dwisdom getter { char *str = fftw_export_wisdom_to_string (); retval = octave_value (std::string (str)); + + // FIXME: need to free string even if there is an + // exception. free (str); } } @@ -276,26 +273,28 @@ std::transform (arg0.begin (), arg0.end (), arg0.begin (), tolower); std::string arg1 = args(1).string_value (); - if (!error_state) - { - char *str = fftwf_export_wisdom_to_string (); + + char *str = fftwf_export_wisdom_to_string (); - if (arg1.length () < 1) - fftwf_forget_wisdom (); - else if (! fftwf_import_wisdom_from_string (arg1.c_str ())) - error ("fftw: could not import supplied WISDOM"); + if (arg1.length () < 1) + fftwf_forget_wisdom (); + else if (! fftwf_import_wisdom_from_string (arg1.c_str ())) + error ("fftw: could not import supplied WISDOM"); - if (!error_state) - retval = octave_value (std::string (str)); + retval = octave_value (std::string (str)); - free (str); - } + // FIXME: need to free string even if there is an + // exception. + free (str); } } else //swisdom getter { char *str = fftwf_export_wisdom_to_string (); retval = octave_value (std::string (str)); + + // FIXME: need to free string even if there is an + // exception. free (str); } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/dldfcn/symrcm.cc --- a/libinterp/dldfcn/symrcm.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/dldfcn/symrcm.cc Mon Oct 05 19:29:36 2015 -0400 @@ -469,9 +469,6 @@ ridx = Ac.xridx (); } - if (error_state) - return retval; - octave_idx_type nr = arg.rows (); octave_idx_type nc = arg.columns (); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-base-diag.cc --- a/libinterp/octave-value/ov-base-diag.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-base-diag.cc Mon Oct 05 19:29:36 2015 -0400 @@ -171,7 +171,7 @@ idx_vector i0 = jdx(0).index_vector (); k = 1; idx_vector i1 = jdx(1).index_vector (); - if (! error_state && i0(0) == i1(0) + if (i0(0) == i1(0) && i0(0) < matrix.rows () && i1(0) < matrix.cols () && chk_valid_scalar (rhs, val)) { @@ -190,7 +190,7 @@ } } - if (! error_state && ! retval.is_defined ()) + if (! retval.is_defined ()) retval = numeric_assign (type, idx, rhs); } else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-base-sparse.cc --- a/libinterp/octave-value/ov-base-sparse.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-base-sparse.cc Mon Oct 05 19:29:36 2015 -0400 @@ -73,8 +73,7 @@ { idx_vector i = idx (0).index_vector (); - if (! error_state) - retval = octave_value (matrix.index (i, resize_ok)); + retval = octave_value (matrix.index (i, resize_ok)); } break; @@ -82,14 +81,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) - retval = octave_value (matrix.index (i, j, resize_ok)); - } + retval = octave_value (matrix.index (i, j, resize_ok)); } break; default: @@ -202,8 +197,7 @@ { idx_vector i = idx (0).index_vector (); - if (! error_state) - matrix.assign (i, rhs); + matrix.assign (i, rhs); break; } @@ -212,14 +206,11 @@ { 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; } @@ -259,8 +250,7 @@ { idx_vector i = idx (0).index_vector (); - if (! error_state) - matrix.delete_elements (i); + matrix.delete_elements (i); break; } @@ -269,14 +259,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.delete_elements (i, j); - } + matrix.delete_elements (i, j); break; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-base.cc --- a/libinterp/octave-value/ov-base.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-base.cc Mon Oct 05 19:29:36 2015 -0400 @@ -658,8 +658,7 @@ octave_value tmp = convert_to_str (false, force); - if (! error_state) - retval = tmp.char_matrix_value (); + retval = tmp.char_matrix_value (); return retval; } @@ -894,8 +893,7 @@ octave_value tmp = convert_to_str (pad, true); - if (! error_state) - retval = tmp.all_strings (); + retval = tmp.all_strings (); return retval; } @@ -907,8 +905,7 @@ octave_value tmp = convert_to_str (force); - if (! error_state) - retval = tmp.string_value (); + retval = tmp.string_value (); return retval; } @@ -1350,7 +1347,7 @@ { f (*this, idx.front (), rhs.get_rep ()); - done = (! error_state); + done = true; } if (done) @@ -1378,7 +1375,7 @@ retval = val.subsasgn (type, idx, rhs); - done = (! error_state); + done = true; } else gripe_assign_conversion_failed (type_name (), @@ -1388,7 +1385,7 @@ gripe_indexed_assignment (type_name (), rhs.type_name ()); } - if (! (done || error_state)) + if (! done) { octave_value tmp_rhs; @@ -1450,7 +1447,7 @@ { retval = tmp_lhs.subsasgn (type, idx, tmp_rhs); - done = (! error_state); + done = true; } else gripe_no_conversion (octave_value::assign_op_as_string diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-bool-sparse.cc --- a/libinterp/octave-value/ov-bool-sparse.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-bool-sparse.cc Mon Oct 05 19:29:36 2015 -0400 @@ -319,7 +319,7 @@ m.ridx (i) = tmp; } - if (error_state || ! is) + if (! is) return false; OCTAVE_LOCAL_BUFFER (char, htmp, nz); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-builtin.cc --- a/libinterp/octave-value/ov-builtin.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-builtin.cc Mon Oct 05 19:29:36 2015 -0400 @@ -105,9 +105,6 @@ { octave_value_list retval; - if (error_state) - return retval; - if (args.has_magic_colon ()) error ("invalid use of colon in function argument list"); else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-complex.cc --- a/libinterp/octave-value/ov-complex.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-complex.cc Mon Oct 05 19:29:36 2015 -0400 @@ -301,7 +301,8 @@ Complex ctmp; read_doubles (is, reinterpret_cast (&ctmp), static_cast (tmp), 2, swap, fmt); - if (error_state || ! is) + + if (! is) return false; scalar = ctmp; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-cx-diag.cc --- a/libinterp/octave-value/ov-cx-diag.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-cx-diag.cc Mon Oct 05 19:29:36 2015 -0400 @@ -218,8 +218,10 @@ octave_idx_type len = m.length (); read_doubles (is, reinterpret_cast (im), static_cast (tmp), 2 * len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; return true; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-cx-mat.cc --- a/libinterp/octave-value/ov-cx-mat.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-cx-mat.cc Mon Oct 05 19:29:36 2015 -0400 @@ -537,8 +537,10 @@ Complex *im = m.fortran_vec (); read_doubles (is, reinterpret_cast (im), static_cast (tmp), 2 * dv.numel (), swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } else @@ -556,8 +558,10 @@ octave_idx_type len = nr * nc; read_doubles (is, reinterpret_cast (im), static_cast (tmp), 2*len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } return true; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-cx-sparse.cc --- a/libinterp/octave-value/ov-cx-sparse.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-cx-sparse.cc Mon Oct 05 19:29:36 2015 -0400 @@ -357,7 +357,7 @@ read_doubles (is, reinterpret_cast (m.data ()), static_cast (ctmp), 2 * nz, swap, fmt); - if (error_state || ! is) + if (! is) return false; if (! m.indices_ok ()) diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-fcn-handle.cc Mon Oct 05 19:29:36 2015 -0400 @@ -1159,22 +1159,19 @@ success = false; } - if (! error_state) + hdf5_callback_data dsub; + int current_item = 0; + for (octave_idx_type i = 0; i < len; i++) { - hdf5_callback_data dsub; - int current_item = 0; - for (octave_idx_type i = 0; i < len; i++) + if (H5Giterate (group_hid, "symbol table", ¤t_item, + hdf5_read_next_data, &dsub) <= 0) { - if (H5Giterate (group_hid, "symbol table", ¤t_item, - hdf5_read_next_data, &dsub) <= 0) - { - error ("load: failed to load anonymous function handle"); - success = false; - break; - } + error ("load: failed to load anonymous function handle"); + success = false; + break; + } - symbol_table::assign (dsub.name, dsub.tc, local_scope); - } + symbol_table::assign (dsub.name, dsub.tc, local_scope); } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-fcn-inline.cc --- a/libinterp/octave-value/ov-fcn-inline.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-fcn-inline.cc Mon Oct 05 19:29:36 2015 -0400 @@ -990,38 +990,35 @@ error ("vectorize: FUN must be a string or inline function"); } - if (! error_state) + std::string new_func; + size_t i = 0; + + while (i < old_func.length ()) { - std::string new_func; - size_t i = 0; + std::string t1 = old_func.substr (i, 1); - while (i < old_func.length ()) + if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^") { - std::string t1 = old_func.substr (i, 1); - - if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^") - { - if (i && old_func.substr (i-1, 1) != ".") - new_func.append ("."); + if (i && old_func.substr (i-1, 1) != ".") + new_func.append ("."); - // Special case for ** operator. - if (t1 == "*" && i < (old_func.length () - 1) - && old_func.substr (i+1, 1) == "*") - { - new_func.append ("*"); - i++; - } + // Special case for ** operator. + if (t1 == "*" && i < (old_func.length () - 1) + && old_func.substr (i+1, 1) == "*") + { + new_func.append ("*"); + i++; } - new_func.append (t1); - i++; } + new_func.append (t1); + i++; + } - if (func_is_string) - retval = octave_value (new_func); - else - retval = octave_value (new octave_fcn_inline - (new_func, old->fcn_arg_names ())); - } + if (func_is_string) + retval = octave_value (new_func); + else + retval = octave_value (new octave_fcn_inline + (new_func, old->fcn_arg_names ())); } else print_usage (); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-float.cc --- a/libinterp/octave-value/ov-float.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-float.cc Mon Oct 05 19:29:36 2015 -0400 @@ -177,7 +177,8 @@ float dtmp; read_floats (is, &dtmp, static_cast (tmp), 1, swap, fmt); - if (error_state || ! is) + + if (! is) return false; scalar = dtmp; @@ -357,7 +358,7 @@ case umap_xtoascii: { octave_value str_conv = convert_to_str (true, true); - return error_state ? octave_value () : str_conv.map (umap); + return str_conv.map (umap); } default: diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-flt-complex.cc --- a/libinterp/octave-value/ov-flt-complex.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-flt-complex.cc Mon Oct 05 19:29:36 2015 -0400 @@ -287,7 +287,8 @@ FloatComplex ctmp; read_floats (is, reinterpret_cast (&ctmp), static_cast (tmp), 2, swap, fmt); - if (error_state || ! is) + + if (! is) return false; scalar = ctmp; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-flt-cx-diag.cc --- a/libinterp/octave-value/ov-flt-cx-diag.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-flt-cx-diag.cc Mon Oct 05 19:29:36 2015 -0400 @@ -190,8 +190,10 @@ octave_idx_type len = m.length (); read_floats (is, reinterpret_cast (re), static_cast (tmp), 2 * len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; return true; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-flt-cx-mat.cc --- a/libinterp/octave-value/ov-flt-cx-mat.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-flt-cx-mat.cc Mon Oct 05 19:29:36 2015 -0400 @@ -499,8 +499,10 @@ FloatComplex *im = m.fortran_vec (); read_floats (is, reinterpret_cast (im), static_cast (tmp), 2 * dv.numel (), swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } else @@ -518,8 +520,10 @@ octave_idx_type len = nr * nc; read_floats (is, reinterpret_cast (im), static_cast (tmp), 2*len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } return true; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-flt-re-diag.cc --- a/libinterp/octave-value/ov-flt-re-diag.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-flt-re-diag.cc Mon Oct 05 19:29:36 2015 -0400 @@ -158,8 +158,10 @@ float *re = m.fortran_vec (); octave_idx_type len = m.length (); read_floats (is, re, static_cast (tmp), len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; return true; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-flt-re-mat.cc --- a/libinterp/octave-value/ov-flt-re-mat.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-flt-re-mat.cc Mon Oct 05 19:29:36 2015 -0400 @@ -527,8 +527,10 @@ float *re = m.fortran_vec (); read_floats (is, re, static_cast (tmp), dv.numel (), swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } else @@ -545,8 +547,10 @@ float *re = m.fortran_vec (); octave_idx_type len = nr * nc; read_floats (is, re, static_cast (tmp), len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } return true; @@ -841,7 +845,7 @@ case umap_xtoascii: { octave_value str_conv = convert_to_str (true, true); - return error_state ? octave_value () : str_conv.map (umap); + return str_conv.map (umap); } default: diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-lazy-idx.cc --- a/libinterp/octave-value/ov-lazy-idx.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-lazy-idx.cc Mon Oct 05 19:29:36 2015 -0400 @@ -175,7 +175,7 @@ else index = value.index_vector (); - return ! error_state; + return true; } @@ -199,5 +199,5 @@ else index = value.index_vector (); - return ! error_state; + return true; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-mex-fcn.cc --- a/libinterp/octave-value/ov-mex-fcn.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-mex-fcn.cc Mon Oct 05 19:29:36 2015 -0400 @@ -132,9 +132,6 @@ { octave_value_list retval; - if (error_state) - return retval; - if (args.has_magic_colon ()) error ("invalid use of colon in function argument list"); else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-perm.cc --- a/libinterp/octave-value/ov-perm.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-perm.cc Mon Oct 05 19:29:36 2015 -0400 @@ -94,7 +94,7 @@ // vectors. // Note that, for better consistency, eye(n)(:,:) still converts to a full // matrix. - if (! error_state && nidx == 2) + if (nidx == 2) { bool left = idx0.is_permutation (matrix.rows ()); bool right = idx1.is_permutation (matrix.cols ()); @@ -120,8 +120,7 @@ } } - // if error_state is set, we've already griped. - if (! error_state && ! retval.is_defined ()) + if (! retval.is_defined ()) { if (nidx == 2 && ! resize_ok && idx0.is_scalar () && idx1.is_scalar ()) retval = matrix.checkelem (idx0(0), idx1(0)); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-range.cc --- a/libinterp/octave-value/ov-range.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-range.cc Mon Oct 05 19:29:36 2015 -0400 @@ -133,13 +133,10 @@ { idx_vector i = idx(0).index_vector (); - if (! error_state) - { - if (i.is_scalar () && i(0) < range.numel ()) - retval = range.elem (i(0)); - else - retval = range.index (i); - } + if (i.is_scalar () && i(0) < range.numel ()) + retval = range.elem (i(0)); + else + retval = range.index (i); } catch (index_exception& e) { diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-re-diag.cc --- a/libinterp/octave-value/ov-re-diag.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-re-diag.cc Mon Oct 05 19:29:36 2015 -0400 @@ -99,26 +99,23 @@ k = 1; idx_vector idx1 = idx(1).index_vector (); - if (! error_state) + bool left = idx0.is_permutation (matrix.rows ()); + bool right = idx1.is_permutation (matrix.cols ()); + + if (left && right) { - bool left = idx0.is_permutation (matrix.rows ()); - bool right = idx1.is_permutation (matrix.cols ()); - + if (idx0.is_colon ()) left = false; + if (idx1.is_colon ()) right = false; if (left && right) + retval = PermMatrix (idx0, false) * PermMatrix (idx1, true); + else if (left) + retval = PermMatrix (idx0, false); + else if (right) + retval = PermMatrix (idx1, true); + else { - if (idx0.is_colon ()) left = false; - if (idx1.is_colon ()) right = false; - if (left && right) - retval = PermMatrix (idx0, false) * PermMatrix (idx1, true); - else if (left) - retval = PermMatrix (idx0, false); - else if (right) - retval = PermMatrix (idx1, true); - else - { - retval = this; - this->count++; - } + retval = this; + this->count++; } } } @@ -130,8 +127,7 @@ } } - // if error_state is set, we've already griped. - if (! error_state && retval.is_undefined ()) + if (retval.is_undefined ()) retval = octave_base_diag::do_index_op (idx, resize_ok); return retval; @@ -239,8 +235,10 @@ double *re = m.fortran_vec (); octave_idx_type len = m.length (); read_doubles (is, re, static_cast (tmp), len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; return true; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-re-mat.cc --- a/libinterp/octave-value/ov-re-mat.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-re-mat.cc Mon Oct 05 19:29:36 2015 -0400 @@ -639,8 +639,10 @@ double *re = m.fortran_vec (); read_doubles (is, re, static_cast (tmp), dv.numel (), swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } else @@ -657,8 +659,10 @@ double *re = m.fortran_vec (); octave_idx_type len = nr * nc; read_doubles (is, re, static_cast (tmp), len, swap, fmt); - if (error_state || ! is) + + if (! is) return false; + matrix = m; } return true; @@ -964,7 +968,7 @@ case umap_xtoascii: { octave_value str_conv = convert_to_str (true, true); - return error_state ? octave_value () : str_conv.map (umap); + return str_conv.map (umap); } default: diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-re-sparse.cc --- a/libinterp/octave-value/ov-re-sparse.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-re-sparse.cc Mon Oct 05 19:29:36 2015 -0400 @@ -387,7 +387,7 @@ read_doubles (is, m.xdata (), static_cast (ctmp), nz, swap, fmt); - if (error_state || ! is) + if (! is) return false; if (! m.indices_ok ()) diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-scalar.cc --- a/libinterp/octave-value/ov-scalar.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-scalar.cc Mon Oct 05 19:29:36 2015 -0400 @@ -192,7 +192,8 @@ double dtmp; read_doubles (is, &dtmp, static_cast (tmp), 1, swap, fmt); - if (error_state || ! is) + + if (! is) return false; scalar = dtmp; @@ -373,7 +374,7 @@ case umap_xtoascii: { octave_value str_conv = convert_to_str (true, true); - return error_state ? octave_value () : str_conv.map (umap); + return str_conv.map (umap); } default: diff -r b7ac1e94266e -r f90c8372b7ba libinterp/octave-value/ov-str-mat.cc --- a/libinterp/octave-value/ov-str-mat.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/octave-value/ov-str-mat.cc Mon Oct 05 19:29:36 2015 -0400 @@ -68,13 +68,10 @@ NDArray nda = v.array_value (true); - if (! error_state) - { - if (nda.numel () == 1) - retval = new octave_scalar (nda(0)); - else - retval = new octave_matrix (nda); - } + if (nda.numel () == 1) + retval = new octave_scalar (nda(0)); + else + retval = new octave_matrix (nda); return retval; } @@ -112,9 +109,8 @@ { idx_vector i = idx (0).index_vector (); - if (! error_state) - retval = octave_value (charNDArray (matrix.index (i, resize_ok)), - type); + retval = octave_value (charNDArray (matrix.index (i, resize_ok)), + type); } break; @@ -124,9 +120,8 @@ k = 1; idx_vector j = idx (1).index_vector (); - if (! error_state) - retval = octave_value (charNDArray (matrix.index (i, j, resize_ok)), - type); + retval = octave_value (charNDArray (matrix.index (i, j, resize_ok)), + type); } break; @@ -137,10 +132,9 @@ for (k = 0; k < len; k++) idx_vec(k) = idx(k).index_vector (); - if (! error_state) - retval = - octave_value (charNDArray (matrix.index (idx_vec, resize_ok)), - type); + retval = + octave_value (charNDArray (matrix.index (idx_vec, resize_ok)), + type); } break; } @@ -443,8 +437,7 @@ } } - if (! error_state) - matrix = chm; + matrix = chm; } else { @@ -555,8 +548,9 @@ char *tmp = m.fortran_vec (); is.read (tmp, dv.numel ()); - if (error_state || ! is) + if (! is) return false; + matrix = m; } else diff -r b7ac1e94266e -r f90c8372b7ba libinterp/operators/op-bm-b.cc --- a/libinterp/operators/op-bm-b.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/operators/op-bm-b.cc Mon Oct 05 19:29:36 2015 -0400 @@ -76,8 +76,7 @@ boolNDArray v2 = a2.bool_array_value (true); - if (! error_state) - v1.assign (idx, v2); + v1.assign (idx, v2); return octave_value (); } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/operators/op-bm-bm.cc --- a/libinterp/operators/op-bm-bm.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/operators/op-bm-bm.cc Mon Oct 05 19:29:36 2015 -0400 @@ -120,8 +120,7 @@ boolNDArray v2 = a2.bool_array_value (true); - if (! error_state) - v1.assign (idx, v2); + v1.assign (idx, v2); return octave_value (); } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/operators/op-sbm-b.cc --- a/libinterp/operators/op-sbm-b.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/operators/op-sbm-b.cc Mon Oct 05 19:29:36 2015 -0400 @@ -97,8 +97,7 @@ SparseBoolMatrix v2 (1, 1, a2.bool_value ()); - if (! error_state) - v1.assign (idx, v2); + v1.assign (idx, v2); return octave_value (); } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/operators/op-sbm-bm.cc --- a/libinterp/operators/op-sbm-bm.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/operators/op-sbm-bm.cc Mon Oct 05 19:29:36 2015 -0400 @@ -103,8 +103,7 @@ SparseBoolMatrix v2 (a2.bool_array_value ()); - if (! error_state) - v1.assign (idx, v2); + v1.assign (idx, v2); return octave_value (); } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/operators/op-str-m.cc --- a/libinterp/operators/op-str-m.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/operators/op-str-m.cc Mon Oct 05 19:29:36 2015 -0400 @@ -40,8 +40,7 @@ = v2.convert_to_str_internal (false, false, a1.is_sq_string () ? '\'' : '"'); - if (! error_state) - v1.assign (idx, tmp.char_array_value ()); + v1.assign (idx, tmp.char_array_value ()); return octave_value (); } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/operators/op-str-s.cc --- a/libinterp/operators/op-str-s.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/operators/op-str-s.cc Mon Oct 05 19:29:36 2015 -0400 @@ -40,8 +40,7 @@ = v2.convert_to_str_internal (false, false, a1.is_sq_string () ? '\'' : '"'); - if (! error_state) - v1.assign (idx, tmp.char_array_value ()); + v1.assign (idx, tmp.char_array_value ()); return octave_value (); } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/oct-parse.in.yy Mon Oct 05 19:29:36 2015 -0400 @@ -4487,12 +4487,12 @@ frame.add_fcn (octave_call_stack::pop); } - octave_function *fcn; + octave_function *fcn = 0; + try { - fcn = parse_fcn_file (file_full_name, file_name, - "", "", require_file, true, - false, false, warn_for); + fcn = parse_fcn_file (file_full_name, file_name, "", "", + require_file, true, false, false, warn_for); } catch (const octave_execution_exception&) { @@ -5090,22 +5090,19 @@ else error ("assignin: CONTEXT must be \"caller\" or \"base\""); + frame.add_fcn (octave_call_stack::pop); + + std::string nm = args(1).string_value (); + if (! error_state) { - frame.add_fcn (octave_call_stack::pop); - - std::string nm = args(1).string_value (); - - if (! error_state) - { - if (valid_identifier (nm)) - symbol_table::assign (nm, args(2)); - else - error ("assignin: invalid variable name in argument VARNAME"); - } + if (valid_identifier (nm)) + symbol_table::assign (nm, args(2)); else - error ("assignin: VARNAME must be a string"); + error ("assignin: invalid variable name in argument VARNAME"); } + else + error ("assignin: VARNAME must be a string"); } else error ("assignin: CONTEXT must be a string"); diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-cbinop.cc --- a/libinterp/parse-tree/pt-cbinop.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-cbinop.cc Mon Oct 05 19:29:36 2015 -0400 @@ -51,24 +51,16 @@ { octave_value retval; - if (error_state) - return retval; - if (op_lhs) { octave_value a = op_lhs->rvalue1 (); - if (! error_state && a.is_defined () && op_rhs) + if (a.is_defined () && op_rhs) { octave_value b = op_rhs->rvalue1 (); - if (! error_state && b.is_defined ()) - { - retval = ::do_binary_op (etype, a, b); - - if (error_state) - retval = octave_value (); - } + if (b.is_defined ()) + retval = ::do_binary_op (etype, a, b); } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-colon.cc --- a/libinterp/parse-tree/pt-colon.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-colon.cc Mon Oct 05 19:29:36 2015 -0400 @@ -85,7 +85,7 @@ { octave_value retval; - if (error_state || ! op_base || ! op_limit) + if (! op_base || ! op_limit) return retval; octave_value ov_base = op_base->rvalue1 (); @@ -121,20 +121,17 @@ tmp1(0) = ov_base; } - if (!error_state) + octave_value fcn = symbol_table::find_function ("colon", tmp1); + + if (fcn.is_defined ()) { - octave_value fcn = symbol_table::find_function ("colon", tmp1); + octave_value_list tmp2 = fcn.do_multi_index_op (1, tmp1); - if (fcn.is_defined ()) - { - octave_value_list tmp2 = fcn.do_multi_index_op (1, tmp1); - - if (! error_state) - retval = tmp2 (0); - } - else - error ("can not find overloaded colon function"); + if (! error_state) + retval = tmp2 (0); } + else + error ("can not find overloaded colon function"); } else { @@ -148,9 +145,8 @@ eval_error ("invalid increment value in colon expression"); } - if (! error_state) - retval = do_colon_op (ov_base, ov_increment, ov_limit, - is_for_cmd_expr ()); + retval = do_colon_op (ov_base, ov_increment, ov_limit, + is_for_cmd_expr ()); } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-decl.cc --- a/libinterp/parse-tree/pt-decl.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-decl.cc Mon Oct 05 19:29:36 2015 -0400 @@ -56,12 +56,9 @@ octave_value init_val = expr->rvalue1 (); - if (! error_state) - { - ult.assign (octave_value::op_asn_eq, init_val); + ult.assign (octave_value::op_asn_eq, init_val); - retval = true; - } + retval = true; } return retval; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-exp.cc --- a/libinterp/parse-tree/pt-exp.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-exp.cc Mon Oct 05 19:29:36 2015 -0400 @@ -42,14 +42,11 @@ octave_value t1 = rvalue1 (); - if (! error_state) - { - if (t1.is_defined ()) - return t1.is_true (); - else - error ("%s: undefined value used in conditional expression", - warn_for); - } + if (t1.is_defined ()) + return t1.is_true (); + else + error ("%s: undefined value used in conditional expression", + warn_for); return expr_value; } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-id.cc --- a/libinterp/parse-tree/pt-id.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-id.cc Mon Oct 05 19:29:36 2015 -0400 @@ -46,8 +46,6 @@ int c = column (); maybe_missing_function_hook (name ()); - if (error_state) - return; if (l == -1 && c == -1) error_with_id ("Octave:undefined-function", @@ -64,9 +62,6 @@ { octave_value_list retval; - if (error_state) - return retval; - octave_value val = sym->find (); if (val.is_defined ()) diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-misc.cc --- a/libinterp/parse-tree/pt-misc.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-misc.cc Mon Oct 05 19:29:36 2015 -0400 @@ -92,30 +92,27 @@ } } - if (! error_state) - { - std::string va_type = (type == in ? "varargin" : "varargout"); + std::string va_type = (type == in ? "varargin" : "varargout"); - size_t len = length (); + size_t len = length (); - if (len > 0) - { - tree_decl_elt *elt = back (); + if (len > 0) + { + tree_decl_elt *elt = back (); - tree_identifier *id = elt->ident (); + tree_identifier *id = elt->ident (); - if (id && id->name () == va_type) - { - if (len == 1) - mark_varargs_only (); - else - mark_varargs (); + if (id && id->name () == va_type) + { + if (len == 1) + mark_varargs_only (); + else + mark_varargs (); - iterator p = end (); - --p; - delete *p; - erase (p); - } + iterator p = end (); + --p; + delete *p; + erase (p); } } diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-select.cc --- a/libinterp/parse-tree/pt-select.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-select.cc Mon Oct 05 19:29:36 2015 -0400 @@ -123,7 +123,7 @@ { octave_value label_value = label->rvalue1 (); - if (! error_state && label_value.is_defined ()) + if (label_value.is_defined ()) { if (label_value.is_cell ()) { @@ -135,22 +135,13 @@ { bool match = val.is_equal (cell(i,j)); - if (error_state) - return false; - else if (match) + if (match) return true; } } } else - { - bool match = val.is_equal (label_value); - - if (error_state) - return false; - else - return match; - } + return val.is_equal (label_value); } return false; diff -r b7ac1e94266e -r f90c8372b7ba libinterp/parse-tree/pt-unop.cc --- a/libinterp/parse-tree/pt-unop.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/parse-tree/pt-unop.cc Mon Oct 05 19:29:36 2015 -0400 @@ -62,34 +62,27 @@ { octave_value retval; - if (error_state) - return retval; - if (op) { if (etype == octave_value::op_incr || etype == octave_value::op_decr) { octave_lvalue ref = op->lvalue (); - if (! error_state) - { - BEGIN_PROFILER_BLOCK (tree_prefix_expression) + BEGIN_PROFILER_BLOCK (tree_prefix_expression) - ref.do_unary_op (etype); + ref.do_unary_op (etype); - if (! error_state) - retval = ref.value (); + retval = ref.value (); - END_PROFILER_BLOCK - } + END_PROFILER_BLOCK } else { octave_value val = op->rvalue1 (); - if (! error_state && val.is_defined ()) + if (val.is_defined ()) { - BEGIN_PROFILER_BLOCK (tree_prefix_expression) + BEGIN_PROFILER_BLOCK (tree_prefix_expression) // Attempt to do the operation in-place if it is unshared // (a temporary expression). @@ -98,9 +91,6 @@ else retval = ::do_unary_op (etype, val); - if (error_state) - retval = octave_value (); - END_PROFILER_BLOCK } } @@ -149,39 +139,30 @@ { octave_value retval; - if (error_state) - return retval; - if (op) { if (etype == octave_value::op_incr || etype == octave_value::op_decr) { octave_lvalue ref = op->lvalue (); - if (! error_state) - { - retval = ref.value (); + retval = ref.value (); + + BEGIN_PROFILER_BLOCK (tree_postfix_expression) - BEGIN_PROFILER_BLOCK (tree_postfix_expression) + ref.do_unary_op (etype); - ref.do_unary_op (etype); - - END_PROFILER_BLOCK - } + END_PROFILER_BLOCK } else { octave_value val = op->rvalue1 (); - if (! error_state && val.is_defined ()) + if (val.is_defined ()) { BEGIN_PROFILER_BLOCK (tree_postfix_expression) retval = ::do_unary_op (etype, val); - if (error_state) - retval = octave_value (); - END_PROFILER_BLOCK } }