# HG changeset patch # User John W. Eaton # Date 1449687643 18000 # Node ID 35241c4b696c3dc61409a2cc37190b3ba806ed38 # Parent ae0bd73671f35e31e1c00e78ac605fc88606fcb7 eliminate return statements after calls to error * Cell.cc, __ichol__.cc, __lin_interpn__.cc, __pchip_deriv__.cc, besselj.cc, cellfun.cc, colloc.cc, debug.cc, dlmread.cc, dynamic-ld.cc, filter.cc, find.cc, gl2ps-renderer.cc, load-path.cc, load-save.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-text.cc, luinc.cc, max.cc, nproc.cc, oct-hist.cc, oct-map.cc, oct-obj.cc, oct-stream.cc, ordschur.cc, pinv.cc, pr-output.cc, profiler.cc, psi.cc, quadcc.cc, qz.cc, rand.cc, strfind.cc, strfns.cc, sysdep.cc, toplev.cc, tril.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc: Eliminate return statements after calls to error. diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/Cell.cc --- a/libinterp/corefcn/Cell.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/Cell.cc Wed Dec 09 14:00:43 2015 -0500 @@ -294,15 +294,13 @@ { if (i < 0 || i >= cols ()) error ("invalid column selection"); - else - { - octave_idx_type nr = rows (); + + octave_idx_type nr = rows (); - retval.resize (dim_vector (nr, 1)); + retval.resize (dim_vector (nr, 1)); - for (octave_idx_type j = 0; j < nr; j++) - retval.xelem (j) = elem (j, i); - } + for (octave_idx_type j = 0; j < nr; j++) + retval.xelem (j) = elem (j, i); } else error ("Cell::column: requires 2-D cell array"); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/__ichol__.cc --- a/libinterp/corefcn/__ichol__.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/__ichol__.cc Wed Dec 09 14:00:43 2015 -0500 @@ -52,25 +52,18 @@ bool ichol_checkpivot_complex (Complex pivot) { if (pivot.imag () != 0) - { - error ("ichol: non-real pivot encountered. The matrix must be hermitian."); - return false; - } + error ("ichol: non-real pivot encountered. The matrix must be hermitian."); else if (pivot.real () < 0) - { - error ("ichol: negative pivot encountered"); - return false; - } + error ("ichol: negative pivot encountered"); + return true; } bool ichol_checkpivot_real (double pivot) { if (pivot < 0) - { - error ("ichol: negative pivot encountered"); - return false; - } + error ("ichol: negative pivot encountered"); + return true; } @@ -156,10 +149,7 @@ data[j1] += dropsums[k]; if (ridx[j1] != k) - { - error ("ichol: encountered a pivot equal to 0"); - break; - } + error ("ichol: encountered a pivot equal to 0"); if (! ichol_checkpivot (data[j1])) break; @@ -389,11 +379,9 @@ data_l[total_len] += col_drops[k]; if (data_l[total_len] == zero) - { - error ("ichol: encountered a pivot equal to 0"); - break; - } - else if (! ichol_checkpivot (data_l[total_len])) + error ("ichol: encountered a pivot equal to 0"); + + if (! ichol_checkpivot (data_l[total_len])) break; // Once elements are dropped and compensation of column sums are done, @@ -405,10 +393,8 @@ // Check if there are too many elements to be indexed with // octave_idx_type type due to fill-in during the process. if (total_len < 0) - { - error ("ichol: integer overflow. Too many fill-in elements in L"); - break; - } + error ("ichol: integer overflow. Too many fill-in elements in L"); + cidx_l[k+1] = cidx_l[k] - cidx_l[0] + w_len; // Update Llist and Lfirst with the k-column information. diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/__lin_interpn__.cc --- a/libinterp/corefcn/__lin_interpn__.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/__lin_interpn__.cc Wed Dec 09 14:00:43 2015 -0500 @@ -222,31 +222,23 @@ for (int i = 0; i < n; i++) { if (X[i].dims () != V.dims ()) - { - error ("interpn: incompatible size of argument number %d", i+1); - return retval; - } - else - { - M tmp = M (dim_vector (size[i], 1)); + error ("interpn: incompatible size of argument number %d", i+1); + + M tmp = M (dim_vector (size[i], 1)); - for (octave_idx_type j = 0; j < size[i]; j++) - tmp(j) = X[i](scale[i]*j); + for (octave_idx_type j = 0; j < size[i]; j++) + tmp(j) = X[i](scale[i]*j); - X[i] = tmp; - } + X[i] = tmp; } } for (int i = 0; i < n; i++) { if (! isvector (X[i]) && X[i].numel () != size[i]) - { - error ("interpn: incompatible size of argument number %d", i+1); - return retval; - } - else - x[i] = X[i].data (); + error ("interpn: incompatible size of argument number %d", i+1); + + x[i] = X[i].data (); } lin_interpn (n, size, scale, Ni, extrapval, x, v, y, vi); @@ -296,10 +288,7 @@ Y[i] = args(n+i+1).float_array_value (); if (Y[0].dims () != Y[i].dims ()) - { - error ("interpn: incompatible size of argument number %d", n+i+2); - return retval; - } + error ("interpn: incompatible size of argument number %d", n+i+2); } retval = lin_interpn (n, X, V, Y); @@ -317,10 +306,7 @@ Y[i] = args(n+i+1).array_value (); if (Y[0].dims () != Y[i].dims ()) - { - error ("interpn: incompatible size of argument number %d", n+i+2); - return retval; - } + error ("interpn: incompatible size of argument number %d", n+i+2); } retval = lin_interpn (n, X, V, Y); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/__pchip_deriv__.cc --- a/libinterp/corefcn/__pchip_deriv__.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/__pchip_deriv__.cc Wed Dec 09 14:00:43 2015 -0500 @@ -71,19 +71,13 @@ octave_idx_type nx = xvec.numel (); if (nx < 2) - { - error ("__pchip_deriv__: X must be at least of length 2"); - return retval; - } + error ("__pchip_deriv__: X must be at least of length 2"); octave_idx_type nyr = ymat.rows (); octave_idx_type nyc = ymat.columns (); if (nx != (rows ? nyc : nyr)) - { - error ("__pchip_deriv__: X and Y dimension mismatch"); - return retval; - } + error ("__pchip_deriv__: X and Y dimension mismatch"); FloatMatrix dmat (nyr, nyc); @@ -102,10 +96,7 @@ k++; if (ierr < 0) - { - error ("__pchip_deriv__: PCHIM failed with ierr = %i", ierr); - return retval; - } + error ("__pchip_deriv__: PCHIM failed with ierr = %i", ierr); } retval = dmat; @@ -118,19 +109,13 @@ octave_idx_type nx = xvec.numel (); if (nx < 2) - { - error ("__pchip_deriv__: X must be at least of length 2"); - return retval; - } + error ("__pchip_deriv__: X must be at least of length 2"); octave_idx_type nyr = ymat.rows (); octave_idx_type nyc = ymat.columns (); if (nx != (rows ? nyc : nyr)) - { - error ("__pchip_deriv__: X and Y dimension mismatch"); - return retval; - } + error ("__pchip_deriv__: X and Y dimension mismatch"); Matrix dmat (nyr, nyc); @@ -148,10 +133,7 @@ k++; if (ierr < 0) - { - error ("__pchip_deriv__: DPCHIM failed with ierr = %i", ierr); - return retval; - } + error ("__pchip_deriv__: DPCHIM failed with ierr = %i", ierr); } retval = dmat; diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/besselj.cc --- a/libinterp/corefcn/besselj.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/besselj.cc Wed Dec 09 14:00:43 2015 -0500 @@ -107,10 +107,7 @@ scaled = opt_arg.bool_value (); if (rpt_error) - { - error ("%s: OPT must be 0 (or false) or 1 (or true)", fn); - return retval; - } + error ("%s: OPT must be 0 (or false) or 1 (or true)", fn); } octave_value alpha_arg = args(0); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/cellfun.cc --- a/libinterp/corefcn/cellfun.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/cellfun.cc Wed Dec 09 14:00:43 2015 -0500 @@ -248,24 +248,14 @@ error_handler = symbol_table::find_function (err_name); if (error_handler.is_undefined ()) - { - error ("cellfun: invalid function NAME: %s", - err_name.c_str ()); - break; - } + error ("cellfun: invalid function NAME: %s", + err_name.c_str ()); } else - { - error ("cellfun: invalid value for 'ErrorHandler' function"); - break; - } + error ("cellfun: invalid value for 'ErrorHandler' function"); } else - { - error ("cellfun: unrecognized parameter %s", - arg.c_str ()); - break; - } + error ("cellfun: unrecognized parameter %s", arg.c_str ()); nargin -= 2; } @@ -536,10 +526,7 @@ for (int j = 0; j < nargin; j++) { if (! args(j+1).is_cell ()) - { - error ("cellfun: arguments must be cells"); - return octave_value_list (); - } + error ("cellfun: arguments must be cells"); inputs[j] = args(j+1).cell_value (); mask[j] = inputs[j].numel () != 1; @@ -556,10 +543,7 @@ for (int i = j+1; i < nargin; i++) { if (mask[i] && inputs[i].dims () != fdims) - { - error ("cellfun: dimensions mismatch"); - return octave_value_list (); - } + error ("cellfun: dimensions mismatch"); } break; } @@ -594,10 +578,7 @@ error_handler); if (nargout > 0 && tmp.length () < nargout) - { - error ("cellfun: function returned fewer than nargout values"); - return retval; - } + error ("cellfun: function returned fewer than nargout values"); if (nargout > 0 || (nargout == 0 @@ -619,10 +600,7 @@ if (val.numel () == 1) retv[j] = val.resize (fdims); else - { - error ("cellfun: all values must be scalars when UniformOutput = true"); - break; - } + error ("cellfun: all values must be scalars when UniformOutput = true"); } } } @@ -643,10 +621,7 @@ idx_type, idx_list, val); } else - { - error ("cellfun: all values must be scalars when UniformOutput = true"); - break; - } + error ("cellfun: all values must be scalars when UniformOutput = true"); } } } @@ -686,10 +661,7 @@ error_handler); if (nargout > 0 && tmp.length () < nargout) - { - error ("cellfun: function returned fewer than nargout values"); - return retval; - } + error ("cellfun: function returned fewer than nargout values"); if (nargout > 0 || (nargout == 0 @@ -1681,15 +1653,10 @@ { int k = dimv(i) - 1; if (k < 0) - { - error ("num2cell: dimension indices must be positive"); - return; - } - else if (i > 0 && k < dimv(i-1) - 1) - { - error ("num2cell: dimension indices must be strictly increasing"); - return; - } + error ("num2cell: dimension indices must be positive"); + + if (i > 0 && k < dimv(i-1) - 1) + error ("num2cell: dimension indices must be strictly increasing"); sing[k] = true; perm(i) = k; @@ -1799,9 +1766,7 @@ } } else - { - error ("num2cell (A, dim) not implemented for class objects"); - } + error ("num2cell (A, dim) not implemented for class objects"); return retval; } @@ -1927,11 +1892,7 @@ octave_idx_type r = i < dv.length () ? dv(i) : 1; if (s != r) - { - error ("mat2cell: mismatch on %d-th dimension (%d != %d)", - i+1, r, s); - return true; - } + error ("mat2cell: mismatch on %d-th dimension (%d != %d)", i+1, r, s); } return false; @@ -2193,10 +2154,7 @@ octave_value a = args(0); bool sparse = a.is_sparse_type (); if (sparse && nargin > 3) - { - error ("mat2cell: sparse arguments only support 2-D indexing"); - return retval; - } + error ("mat2cell: sparse arguments only support 2-D indexing"); switch (a.builtin_type ()) { @@ -2329,8 +2287,6 @@ @seealso{cell2mat, cellindexmat, cellfun}\n\ @end deftypefn") { - octave_value retval; - int nargin = args.length (); if (nargin < 3 || nargin > 4) @@ -2349,86 +2305,82 @@ if (lb.numel () != ub.numel ()) error ("cellslices: the lengths of LB and UB must match"); - else + + Cell retcell; + if (! x.is_sparse_type () && x.is_matrix_type ()) { - Cell retcell; - if (! x.is_sparse_type () && x.is_matrix_type ()) + // specialize for some dense arrays. + if (x.is_bool_type ()) + retcell = do_cellslices_nda (x.bool_array_value (), + lb, ub, dim); + else if (x.is_char_matrix ()) + retcell = do_cellslices_nda (x.char_array_value (), + lb, ub, dim); + else if (x.is_integer_type ()) { - // specialize for some dense arrays. - if (x.is_bool_type ()) - retcell = do_cellslices_nda (x.bool_array_value (), + if (x.is_int8_type ()) + retcell = do_cellslices_nda (x.int8_array_value (), lb, ub, dim); - else if (x.is_char_matrix ()) - retcell = do_cellslices_nda (x.char_array_value (), + else if (x.is_int16_type ()) + retcell = do_cellslices_nda (x.int16_array_value (), + lb, ub, dim); + else if (x.is_int32_type ()) + retcell = do_cellslices_nda (x.int32_array_value (), lb, ub, dim); - else if (x.is_integer_type ()) - { - if (x.is_int8_type ()) - retcell = do_cellslices_nda (x.int8_array_value (), - lb, ub, dim); - else if (x.is_int16_type ()) - retcell = do_cellslices_nda (x.int16_array_value (), - lb, ub, dim); - else if (x.is_int32_type ()) - retcell = do_cellslices_nda (x.int32_array_value (), - lb, ub, dim); - else if (x.is_int64_type ()) - retcell = do_cellslices_nda (x.int64_array_value (), - lb, ub, dim); - else if (x.is_uint8_type ()) - retcell = do_cellslices_nda (x.uint8_array_value (), - lb, ub, dim); - else if (x.is_uint16_type ()) - retcell = do_cellslices_nda (x.uint16_array_value (), - lb, ub, dim); - else if (x.is_uint32_type ()) - retcell = do_cellslices_nda (x.uint32_array_value (), - lb, ub, dim); - else if (x.is_uint64_type ()) - retcell = do_cellslices_nda (x.uint64_array_value (), - lb, ub, dim); - } - else if (x.is_complex_type ()) - { - if (x.is_single_type ()) - retcell = do_cellslices_nda (x.float_complex_array_value (), - lb, ub, dim); - else - retcell = do_cellslices_nda (x.complex_array_value (), - lb, ub, dim); - } + else if (x.is_int64_type ()) + retcell = do_cellslices_nda (x.int64_array_value (), + lb, ub, dim); + else if (x.is_uint8_type ()) + retcell = do_cellslices_nda (x.uint8_array_value (), + lb, ub, dim); + else if (x.is_uint16_type ()) + retcell = do_cellslices_nda (x.uint16_array_value (), + lb, ub, dim); + else if (x.is_uint32_type ()) + retcell = do_cellslices_nda (x.uint32_array_value (), + lb, ub, dim); + else if (x.is_uint64_type ()) + retcell = do_cellslices_nda (x.uint64_array_value (), + lb, ub, dim); + } + else if (x.is_complex_type ()) + { + if (x.is_single_type ()) + retcell = do_cellslices_nda (x.float_complex_array_value (), + lb, ub, dim); else - { - if (x.is_single_type ()) - retcell = do_cellslices_nda (x.float_array_value (), - lb, ub, dim); - else - retcell = do_cellslices_nda (x.array_value (), - lb, ub, dim); - } + retcell = do_cellslices_nda (x.complex_array_value (), + lb, ub, dim); } else { - // generic code. - octave_idx_type n = lb.numel (); - retcell = Cell (1, n); - const dim_vector dv = x.dims (); - int ndims = dv.length (); - if (dim < 0) - dim = dv.first_non_singleton (); - ndims = std::max (ndims, dim + 1); - octave_value_list idx (ndims, octave_value::magic_colon_t); - for (octave_idx_type i = 0; i < n; i++) - { - idx(dim) = Range (lb(i), ub(i)); - retcell(i) = x.do_index_op (idx); - } + if (x.is_single_type ()) + retcell = do_cellslices_nda (x.float_array_value (), + lb, ub, dim); + else + retcell = do_cellslices_nda (x.array_value (), + lb, ub, dim); } - - retval = retcell; + } + else + { + // generic code. + octave_idx_type n = lb.numel (); + retcell = Cell (1, n); + const dim_vector dv = x.dims (); + int ndims = dv.length (); + if (dim < 0) + dim = dv.first_non_singleton (); + ndims = std::max (ndims, dim + 1); + octave_value_list idx (ndims, octave_value::magic_colon_t); + for (octave_idx_type i = 0; i < n; i++) + { + idx(dim) = Range (lb(i), ub(i)); + retcell(i) = x.do_index_op (idx); + } } - return retval; + return octave_value (retcell); } /* diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/colloc.cc --- a/libinterp/corefcn/colloc.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/colloc.cc Wed Dec 09 14:00:43 2015 -0500 @@ -81,18 +81,12 @@ left = 1; } else - { - error ("colloc: string argument must be \"left\" or \"right\""); - return retval; - } + error ("colloc: string argument must be \"left\" or \"right\""); } ntot += left + right; if (ntot < 1) - { - error ("colloc: the total number of roots must be positive"); - return retval; - } + error ("colloc: the total number of roots must be positive"); CollocWt wts (ncol, left, right); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/debug.cc Wed Dec 09 14:00:43 2015 -0500 @@ -225,9 +225,7 @@ idx = 0; } else - { - error ("%s: no function specified", who); - } + error ("%s: no function specified", who); } } else if (args(0).is_map ()) @@ -235,7 +233,6 @@ // This is a problem because parse_dbfunction_params() // can only pass out a single function. error ("%s: struct input not implemented", who); - return; } else error ("%s: invalid parameter specified", who); @@ -278,10 +275,7 @@ } if (! instance) - { - error ("unable to create breakpoint table!"); - retval = false; - } + error ("unable to create breakpoint table!"); return retval; } @@ -733,10 +727,7 @@ std::string symbol_name; if (nargin != 0 && nargin != 1) - { - error ("dbstatus: only zero or one arguments accepted\n"); - return octave_value (); - } + error ("dbstatus: only zero or one arguments accepted\n"); if (nargin == 1) { @@ -961,10 +952,7 @@ end = atoi (end_str.c_str ()); if (std::min (start, end) <= 0) - { - error ("dbtype: start and end lines must be >= 1\n"); - break; - } + error ("dbtype: start and end lines must be >= 1\n"); if (start <= end) do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), @@ -990,10 +978,7 @@ else // (dbtype lineno) { if (line <= 0) - { - error ("dbtype: start and end lines must be >= 1\n"); - break; - } + error ("dbtype: start and end lines must be >= 1\n"); dbg_fcn = get_user_code (); @@ -1032,10 +1017,7 @@ } if (std::min (start, end) <= 0) - { - error ("dbtype: start and end lines must be >= 1\n"); - break; - } + error ("dbtype: start and end lines must be >= 1\n"); if (start <= end) do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/dlmread.cc --- a/libinterp/corefcn/dlmread.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/dlmread.cc Wed Dec 09 14:00:43 2015 -0500 @@ -218,12 +218,9 @@ input_file.open (tname.c_str (), std::ios::in); if (! input_file) - { - error ("dlmread: unable to open file '%s'", fname.c_str ()); - return retval; - } - else - input = &input_file; + error ("dlmread: unable to open file '%s'", fname.c_str ()); + + input = &input_file; } else if (args(0).is_scalar_type ()) { @@ -232,16 +229,10 @@ input = is.input_stream (); if (! input) - { - error ("dlmread: stream FILE not open for input"); - return retval; - } + error ("dlmread: stream FILE not open for input"); } else - { - error ("dlmread: FILE argument must be a string or file id"); - return retval; - } + error ("dlmread: FILE argument must be a string or file id"); // Set default separator. std::string sep; diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/dynamic-ld.cc --- a/libinterp/corefcn/dynamic-ld.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/dynamic-ld.cc Wed Dec 09 14:00:43 2015 -0500 @@ -159,11 +159,7 @@ } if (! instance) - { - error ("unable to create shared library list object!"); - - retval = false; - } + error ("unable to create shared library list object!"); return retval; } @@ -215,11 +211,8 @@ } if (! instance) - { - error ("unable to create dynamic loader object!"); + error ("unable to create dynamic loader object!"); - retval = false; - } return retval; } diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/filter.cc --- a/libinterp/corefcn/filter.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/filter.cc Wed Dec 09 14:00:43 2015 -0500 @@ -76,17 +76,11 @@ T norm = a (0); if (norm == static_cast (0.0)) - { - error ("filter: the first element of A must be nonzero"); - return y; - } + error ("filter: the first element of A must be nonzero"); dim_vector x_dims = x.dims (); if (dim < 0 || dim > x_dims.length ()) - { - error ("filter: DIM must be a valid dimension"); - return y; - } + error ("filter: DIM must be a valid dimension"); octave_idx_type x_len = x_dims(dim); @@ -94,32 +88,20 @@ octave_idx_type si_len = si_dims(0); if (si_len != ab_len - 1) - { - error ("filter: first dimension of SI must be of length max (length (a), length (b)) - 1"); - return y; - } + error ("filter: first dimension of SI must be of length max (length (a), length (b)) - 1"); if (si_dims.length () != x_dims.length ()) - { - error ("filter: dimensionality of SI and X must agree"); - return y; - } + error ("filter: dimensionality of SI and X must agree"); for (octave_idx_type i = 1; i < dim; i++) { if (si_dims(i) != x_dims(i-1)) - { - error ("filter: dimensionality of SI and X must agree"); - return y; - } + error ("filter: dimensionality of SI and X must agree"); } for (octave_idx_type i = dim+1; i < x_dims.length (); i++) { if (si_dims(i) != x_dims(i)) - { - error ("filter: dimensionality of SI and X must agree"); - return y; - } + error ("filter: dimensionality of SI and X must agree"); } if (x_len == 0) @@ -270,10 +252,7 @@ dim = 0; } else if (dim < 0 || dim > x_dims.length ()) - { - error ("filter: DIM must be a valid dimension"); - return MArray (); - } + error ("filter: DIM must be a valid dimension"); octave_idx_type a_len = a.numel (); octave_idx_type b_len = b.numel (); @@ -409,10 +388,7 @@ { dim = args(4).nint_value () - 1; if (dim < 0 || dim >= x_dims.length ()) - { - error ("filter: DIM must be a valid dimension"); - return retval; - } + error ("filter: DIM must be a valid dimension"); } else { diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/find.cc --- a/libinterp/corefcn/find.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/find.cc Wed Dec 09 14:00:43 2015 -0500 @@ -416,10 +416,7 @@ direction = -1; if (direction == 0) - { - error ("find: DIRECTION must be \"first\" or \"last\""); - return retval; - } + error ("find: DIRECTION must be \"first\" or \"last\""); } octave_value arg = args(0); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/gl2ps-renderer.cc --- a/libinterp/corefcn/gl2ps-renderer.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/gl2ps-renderer.cc Wed Dec 09 14:00:43 2015 -0500 @@ -67,10 +67,7 @@ else if (term.find ("tex") != std::string::npos) gl2ps_term = GL2PS_TEX; else - { - error ("gl2ps-renderer::draw: Unknown terminal %s", term.c_str ()); - return; - } + error ("gl2ps-renderer::draw: Unknown terminal %s", term.c_str ()); GLint gl2ps_text = 0; if (term.find ("notxt") != std::string::npos) @@ -131,7 +128,6 @@ { old_print_cmd.clear (); error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR"); - return; } old_print_cmd = print_cmd; @@ -148,7 +144,6 @@ { old_print_cmd.clear (); error ("gl2ps-renderer::draw: gl2psEndPage returned GL2PS_ERROR"); - return; } // Don't check state for GL2PS_UNINITIALIZED (should never happen) diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/load-path.cc --- a/libinterp/corefcn/load-path.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/load-path.cc Wed Dec 09 14:00:43 2015 -0500 @@ -335,11 +335,7 @@ } if (! instance) - { - error ("unable to create load path object!"); - - retval = false; - } + error ("unable to create load path object!"); return retval; } @@ -2451,10 +2447,7 @@ nargin--; } else - { - error ("addpath: OPTION must be '-begin'/0 or '-end'/1"); - return retval; - } + error ("addpath: OPTION must be '-begin'/0 or '-end'/1"); } bool need_to_update = false; diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/load-save.cc --- a/libinterp/corefcn/load-save.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/load-save.cc Wed Dec 09 14:00:43 2015 -0500 @@ -189,6 +189,7 @@ { if (! quiet) error ("load: unable to read read binary file"); + return -1; } @@ -697,7 +698,6 @@ format = LS_HDF5; #else /* ! HAVE_HDF5 */ error ("load: octave executable was not linked with HDF5 library"); - return retval; #endif /* ! HAVE_HDF5 */ } else if (argv[i] == "-import" || argv[i] == "-i") @@ -1274,27 +1274,18 @@ else if (argv[argv_idx] == "-struct") { if (++argv_idx >= argc) - { - error ("save: missing struct name"); - return; - } + error ("save: missing struct name"); std::string struct_name = argv[argv_idx]; if (! symbol_table::is_variable (struct_name)) - { - error ("save: no such variable: '%s'", struct_name.c_str ()); - return; - } + error ("save: no such variable: '%s'", struct_name.c_str ()); octave_value struct_var = symbol_table::varval (struct_name); if (! struct_var.is_map () || struct_var.numel () != 1) - { - error ("save: '%s' is not a scalar structure", - struct_name.c_str ()); - return; - } + error ("save: '%s' is not a scalar structure", struct_name.c_str ()); + octave_scalar_map struct_var_map = struct_var.scalar_map_value (); ++argv_idx; @@ -1620,10 +1611,7 @@ print_usage (); if (save_as_floats && format == LS_TEXT) - { - error ("save: cannot specify both -text and -float-binary"); - return retval; - } + error ("save: cannot specify both -text and -float-binary"); if (argv[i] == "-") { @@ -1682,10 +1670,7 @@ { // FIXME: It should be possible to append to HDF5 files. if (append) - { - error ("save: appending to HDF5 files is not implemented"); - return retval; - } + error ("save: appending to HDF5 files is not implemented"); bool write_header_info = ! (append && H5Fis_hdf5 (fname.c_str ()) > 0); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/ls-mat4.cc --- a/libinterp/corefcn/ls-mat4.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/ls-mat4.cc Wed Dec 09 14:00:43 2015 -0500 @@ -166,6 +166,7 @@ { if (! quiet) error ("load: can't read binary file"); + return -1; } @@ -277,16 +278,10 @@ flt_fmt = mopt_digit_to_float_format (mach); if (flt_fmt == oct_mach_info::flt_fmt_unknown) - { - error ("load: unrecognized binary format!"); - return retval; - } + error ("load: unrecognized binary format!"); if (imag && type == 1) - { - error ("load: encountered complex matrix with string flag set!"); - return retval; - } + error ("load: encountered complex matrix with string flag set!"); // LEN includes the terminating character, and the file is also // supposed to include it, but apparently not all files do. Either @@ -374,10 +369,7 @@ read_mat_binary_data (is, re.fortran_vec (), prec, dlen, swap, flt_fmt); if (! is) - { - error ("load: reading matrix data for '%s'", name); - goto data_read_error; - } + error ("load: reading matrix data for '%s'", name); if (imag) { @@ -387,10 +379,7 @@ flt_fmt); if (! is) - { - error ("load: reading imaginary matrix data for '%s'", name); - goto data_read_error; - } + error ("load: reading imaginary matrix data for '%s'", name); ComplexMatrix ctmp (nr, nc); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/ls-mat5.cc --- a/libinterp/corefcn/ls-mat5.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/ls-mat5.cc Wed Dec 09 14:00:43 2015 -0500 @@ -376,10 +376,7 @@ std::streampos tmp_pos; \ \ if (read_mat5_tag (is, swap, type, len, is_small_data_element)) \ - { \ - error ("load: reading matrix data for '%s'", retval.c_str ()); \ - goto data_read_error; \ - } \ + error ("load: reading matrix data for '%s'", retval.c_str ()); \ \ octave_idx_type n = re.numel (); \ tmp_pos = is.tellg (); \ @@ -387,10 +384,7 @@ static_cast (type)); \ \ if (! is) \ - { \ - error ("load: reading matrix data for '%s'", retval.c_str ()); \ - goto data_read_error; \ - } \ + error ("load: reading matrix data for '%s'", retval.c_str ()); \ \ is.seekg (tmp_pos + static_cast\ (READ_PAD (is_small_data_element, len))); \ @@ -401,22 +395,16 @@ NDArray im (dims); \ \ if (read_mat5_tag (is, swap, type, len, is_small_data_element)) \ - { \ - error ("load: reading matrix data for '%s'", \ - retval.c_str ()); \ - goto data_read_error; \ - } \ + error ("load: reading matrix data for '%s'", \ + retval.c_str ()); \ \ n = im.numel (); \ read_mat5_binary_data (is, im.fortran_vec (), n, swap, \ static_cast (type), flt_fmt); \ \ if (! is) \ - { \ - error ("load: reading imaginary matrix data for '%s'", \ - retval.c_str ()); \ - goto data_read_error; \ - } \ + error ("load: reading imaginary matrix data for '%s'", \ + retval.c_str ()); \ \ ComplexNDArray ctmp (dims); \ \ @@ -619,7 +607,6 @@ { pos = is.tellg (); error ("load: invalid element type = %d", type); - goto early_read_error; } if (element_length == 0) @@ -634,10 +621,7 @@ int32_t len; if (read_mat5_tag (is, swap, type, len, is_small_data_element) || type != miUINT32 || len != 8 || is_small_data_element) - { - error ("load: invalid array flags subelement"); - goto early_read_error; - } + error ("load: invalid array flags subelement"); int32_t flags; read_int (is, swap, flags); @@ -661,10 +645,7 @@ if (read_mat5_tag (is, swap, type, dim_len, is_small_data_element) || type != miINT32) - { - error ("load: invalid dimensions array subelement"); - goto early_read_error; - } + error ("load: invalid dimensions array subelement"); int ndims = dim_len / 4; if (ndims == 1) @@ -697,10 +678,7 @@ if (read_mat5_tag (is, swap, type, len, is_small_data_element) || ! INT8(type)) - { - error ("load: invalid array name subelement"); - goto early_read_error; - } + error ("load: invalid array name subelement"); { OCTAVE_LOCAL_BUFFER (char, name, len+1); @@ -738,10 +716,7 @@ = read_mat5_binary_element (is, filename, swap, global, tc2); if (! is) - { - error ("load: reading cell data for '%s'", nm.c_str ()); - goto data_read_error; - } + error ("load: reading cell data for '%s'", nm.c_str ()); cell_array(i) = tc2; } @@ -780,10 +755,7 @@ std::streampos tmp_pos; if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading sparse row data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading sparse row data for '%s'", retval.c_str ()); tmp_pos = is.tellg (); @@ -791,21 +763,15 @@ static_cast (type)); if (! is) - { - error ("load: reading sparse row data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading sparse row data for '%s'", retval.c_str ()); is.seekg (tmp_pos + static_cast (READ_PAD (is_small_data_element, len))); // col indices if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading sparse column data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading sparse column data for '%s'", + retval.c_str ()); tmp_pos = is.tellg (); @@ -813,22 +779,16 @@ static_cast (type)); if (! is) - { - error ("load: reading sparse column data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading sparse column data for '%s'", + retval.c_str ()); is.seekg (tmp_pos + static_cast (READ_PAD (is_small_data_element, len))); // real data subelement if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading sparse matrix data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading sparse matrix data for '%s'", + retval.c_str ()); octave_idx_type nnz = cidx[nc]; NDArray re; @@ -844,11 +804,8 @@ flt_fmt); if (! is) - { - error ("load: reading sparse matrix data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading sparse matrix data for '%s'", + retval.c_str ()); is.seekg (tmp_pos + static_cast (READ_PAD (is_small_data_element, len))); @@ -859,22 +816,16 @@ NDArray im (dim_vector (static_cast (nnz), 1)); if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading sparse matrix data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading sparse matrix data for '%s'", + retval.c_str ()); read_mat5_binary_data (is, im.fortran_vec (), nnz, swap, static_cast (type), flt_fmt); if (! is) - { - error ("load: reading imaginary sparse matrix data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading imaginary sparse matrix data for '%s'", + retval.c_str ()); for (octave_idx_type i = 0; i < nnz; i++) scm.xdata (i) = Complex (re (i), im (i)); @@ -1066,24 +1017,15 @@ if (fh) tc = new octave_fcn_handle (fh->fcn_val (), "@"); else - { - error ("load: failed to load anonymous function handle"); - goto skip_ahead; - } + error ("load: failed to load anonymous function handle"); } else - { - error ("load: failed to load anonymous function handle"); - goto skip_ahead; - } + error ("load: failed to load anonymous function handle"); frame.run (); } else - { - error ("load: invalid function handle type"); - goto skip_ahead; - } + error ("load: invalid function handle type"); } break; @@ -1099,10 +1041,7 @@ int32_t fn_len; if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element) || ! INT8(fn_type)) - { - error ("load: invalid field name subelement"); - goto data_read_error; - } + error ("load: invalid field name subelement"); OCTAVE_LOCAL_BUFFER (char, elname, fn_len + 1); @@ -1161,10 +1100,7 @@ if (read_mat5_tag (is, swap, type, len, is_small_data_element) || ! INT8(type)) - { - error ("load: invalid class name"); - goto skip_ahead; - } + error ("load: invalid class name"); { OCTAVE_LOCAL_BUFFER (char, name, len+1); @@ -1198,10 +1134,7 @@ // that eventually someone will recognize that's a waste of space. if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element) || fn_type != miINT32) - { - error ("load: invalid field name length subelement"); - goto data_read_error; - } + error ("load: invalid field name length subelement"); if (! is.read (reinterpret_cast (&field_name_length), fn_len)) goto data_read_error; @@ -1213,10 +1146,7 @@ // us how many fields there are. if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element) || ! INT8(fn_type)) - { - error ("load: invalid field name subelement"); - goto data_read_error; - } + error ("load: invalid field name subelement"); octave_idx_type n_fields = fn_len/field_name_length; @@ -1366,10 +1296,7 @@ std::streampos tmp_pos; if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading matrix data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading matrix data for '%s'", retval.c_str ()); octave_idx_type n = re.numel (); tmp_pos = is.tellg (); @@ -1378,10 +1305,7 @@ flt_fmt); if (! is) - { - error ("load: reading matrix data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading matrix data for '%s'", retval.c_str ()); is.seekg (tmp_pos + static_cast (READ_PAD (is_small_data_element, len))); @@ -1393,10 +1317,7 @@ FloatNDArray im (dims); if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading matrix data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading matrix data for '%s'", retval.c_str ()); n = im.numel (); read_mat5_binary_data (is, im.fortran_vec (), n, swap, @@ -1404,11 +1325,8 @@ flt_fmt); if (! is) - { - error ("load: reading imaginary matrix data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading imaginary matrix data for '%s'", + retval.c_str ()); FloatComplexNDArray ctmp (dims); @@ -1435,10 +1353,7 @@ std::streampos tmp_pos; if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading matrix data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading matrix data for '%s'", retval.c_str ()); octave_idx_type n = re.numel (); tmp_pos = is.tellg (); @@ -1447,10 +1362,7 @@ flt_fmt); if (! is) - { - error ("load: reading matrix data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading matrix data for '%s'", retval.c_str ()); is.seekg (tmp_pos + static_cast (READ_PAD (is_small_data_element, len))); @@ -1475,10 +1387,7 @@ NDArray im (dims); if (read_mat5_tag (is, swap, type, len, is_small_data_element)) - { - error ("load: reading matrix data for '%s'", retval.c_str ()); - goto data_read_error; - } + error ("load: reading matrix data for '%s'", retval.c_str ()); n = im.numel (); read_mat5_binary_data (is, im.fortran_vec (), n, swap, @@ -1486,11 +1395,8 @@ flt_fmt); if (! is) - { - error ("load: reading imaginary matrix data for '%s'", - retval.c_str ()); - goto data_read_error; - } + error ("load: reading imaginary matrix data for '%s'", + retval.c_str ()); ComplexNDArray ctmp (dims); @@ -1560,7 +1466,6 @@ return retval; data_read_error: -early_read_error: error ("load: trouble reading binary file '%s'", filename.c_str ()); return std::string (); @@ -2421,10 +2326,7 @@ os.write (out_buf, destLen); } else - { - error ("save: error compressing data element"); - ret = false; - } + error ("save: error compressing data element"); } return ret; diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/ls-oct-text.cc --- a/libinterp/corefcn/ls-oct-text.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/ls-oct-text.cc Wed Dec 09 14:00:43 2015 -0500 @@ -397,10 +397,7 @@ os.precision (old_precision); } else - { - error ("for now, I can only save real matrices in 3-D format"); - fail = true; - } + error ("for now, I can only save real matrices in 3-D format"); return (os && ! fail); } diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/luinc.cc --- a/libinterp/corefcn/luinc.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/luinc.cc Wed Dec 09 14:00:43 2015 -0500 @@ -155,10 +155,7 @@ thresh(1) = thresh(0); } else if (thresh.numel () != 2) - { - error ("luinc: THRESH must be a 1 or 2-element vector"); - return retval; - } + error ("luinc: THRESH must be a 1 or 2-element vector"); } } else diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/max.cc --- a/libinterp/corefcn/max.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/max.cc Wed Dec 09 14:00:43 2015 -0500 @@ -245,10 +245,7 @@ dim = args(2).int_value (true) - 1; if (dim < 0) - { - error ("%s: DIM must be a valid dimension", func); - return retval; - } + error ("%s: DIM must be a valid dimension", func); if (! args(1).is_empty ()) warning ("%s: second argument is ignored", func); @@ -924,10 +921,7 @@ dim = args(1).int_value (true) - 1; if (dim < 0) - { - error ("%s: DIM must be a valid dimension", func); - return retval; - } + error ("%s: DIM must be a valid dimension", func); } switch (arg.builtin_type ()) diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/nproc.cc --- a/libinterp/corefcn/nproc.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/nproc.cc Wed Dec 09 14:00:43 2015 -0500 @@ -70,10 +70,7 @@ else if (arg == "overridable") query = NPROC_CURRENT_OVERRIDABLE; else - { - error ("nproc: invalid value for QUERY"); - return retval; - } + error ("nproc: invalid value for QUERY"); } retval = num_processors (query); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/oct-hist.cc --- a/libinterp/corefcn/oct-hist.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/oct-hist.cc Wed Dec 09 14:00:43 2015 -0500 @@ -420,10 +420,7 @@ } if (hist_beg > hist_count || hist_end > hist_count) - { - error ("%s: history specification out of range", warn_for); - return retval; - } + error ("%s: history specification out of range", warn_for); if (hist_end < hist_beg) { @@ -436,11 +433,8 @@ std::fstream file (name.c_str (), std::ios::out); if (! file) - { - error ("%s: couldn't open temporary file '%s'", warn_for, - name.c_str ()); - return retval; - } + error ("%s: couldn't open temporary file '%s'", warn_for, + name.c_str ()); if (reverse) { @@ -490,10 +484,7 @@ // Check if text edition was successfull. Abort the operation // in case of failure. if (status != EXIT_SUCCESS) - { - error ("edit_history: text editor command failed"); - return; - } + error ("edit_history: text editor command failed"); // Write the commands to the history file since source_file // disables command line history while it executes. diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/oct-map.cc --- a/libinterp/corefcn/oct-map.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/oct-map.cc Wed Dec 09 14:00:43 2015 -0500 @@ -782,10 +782,7 @@ for (octave_idx_type i = 1; i < n; i++) { if (! dv.concat (map_list[i].dimensions, dim)) - { - error ("dimension mismatch in struct concatenation"); - return retval; - } + error ("dimension mismatch in struct concatenation"); } retval.dimensions = dv; @@ -1300,10 +1297,7 @@ const_iterator pb = rb.seek (key(pa)); if (pb == rb.end ()) - { - error ("field name mismatch in structure concatenation"); - break; - } + error ("field name mismatch in structure concatenation"); contents(pa).insert (rb.contents (pb), ra_idx); } @@ -1329,10 +1323,7 @@ for (octave_idx_type i = 0; i < nf; i++) { if (! xvals[i].optimize_dimensions (dimensions)) - { - error ("internal error: dimension mismatch across fields in struct"); - break; - } + error ("internal error: dimension mismatch across fields in struct"); } } diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/oct-obj.cc --- a/libinterp/corefcn/oct-obj.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/oct-obj.cc Wed Dec 09 14:00:43 2015 -0500 @@ -133,17 +133,11 @@ if (offset < 0 || offset >= len) { if (! (rep_length == 0 && offset == len)) - { - error ("octave_value_list::splice: invalid OFFSET"); - return retval; - } + error ("octave_value_list::splice: invalid OFFSET"); } if (rep_length < 0 || rep_length + offset > len) - { - error ("octave_value_list::splice: invalid LENGTH"); - return retval; - } + error ("octave_value_list::splice: invalid LENGTH"); octave_idx_type lst_len = lst.length (); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/oct-stream.cc Wed Dec 09 14:00:43 2015 -0500 @@ -939,12 +939,8 @@ std::string retval; if (interactive && file_number () == 0) - { - ::error ("%s: unable to read from stdin while running interactively", - who.c_str ()); - - return retval; - } + ::error ("%s: unable to read from stdin while running interactively", + who.c_str ()); err = false; @@ -2406,10 +2402,7 @@ size_t retval = 0; if (nsa > 2) - { - ::error ("%s: internal error handling format", who.c_str ()); - return retval; - } + ::error ("%s: internal error handling format", who.c_str ()); std::string flags = elt->flags; @@ -2615,8 +2608,7 @@ break; default: - error ("%s: invalid format specifier", - who.c_str ()); + error ("%s: invalid format specifier", who.c_str ()); return -1; break; } @@ -4128,11 +4120,7 @@ } if (! instance) - { - ::error ("unable to create stream list object!"); - - retval = false; - } + ::error ("unable to create stream list object!"); return retval; } diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/ordschur.cc --- a/libinterp/corefcn/ordschur.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/ordschur.cc Wed Dec 09 14:00:43 2015 -0500 @@ -119,15 +119,9 @@ const dim_vector dimU = args(0).dims (); const dim_vector dimS = args(1).dims (); if (n != dimU(0)) - { - error ("ordschur: SELECT must have same length as the sides of U and S"); - return retval; - } + error ("ordschur: SELECT must have same length as the sides of U and S"); else if (n != dimU(0) || n != dimS(0) || n != dimU(1) || n != dimS(1)) - { - error ("ordschur: U and S must be square and of equal sizes"); - return retval; - } + error ("ordschur: U and S must be square and of equal sizes"); const bool double_type = args(0).is_double_type () || args(1).is_double_type (); @@ -145,10 +139,8 @@ #define PREPARE_OUTPUT()\ if (info != 0) \ - { \ - error ("ordschur: trsen failed"); \ - return retval; \ - } \ + error ("ordschur: trsen failed"); \ + \ retval(0) = U; \ retval(1) = S; diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/pinv.cc --- a/libinterp/corefcn/pinv.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/pinv.cc Wed Dec 09 14:00:43 2015 -0500 @@ -81,10 +81,7 @@ tol = args(1).float_value (); if (tol < 0.0) - { - error ("pinv: TOL must be greater than zero"); - return retval; - } + error ("pinv: TOL must be greater than zero"); if (arg.is_real_type ()) retval = arg.float_diag_matrix_value ().pseudo_inverse (tol); @@ -98,10 +95,7 @@ tol = args(1).double_value (); if (tol < 0.0) - { - error ("pinv: TOL must be greater than zero"); - return retval; - } + error ("pinv: TOL must be greater than zero"); if (arg.is_real_type ()) retval = arg.diag_matrix_value ().pseudo_inverse (tol); @@ -120,10 +114,7 @@ tol = args(1).float_value (); if (tol < 0.0) - { - error ("pinv: TOL must be greater than zero"); - return retval; - } + error ("pinv: TOL must be greater than zero"); if (arg.is_real_type ()) { @@ -147,10 +138,7 @@ tol = args(1).double_value (); if (tol < 0.0) - { - error ("pinv: TOL must be greater than zero"); - return retval; - } + error ("pinv: TOL must be greater than zero"); if (arg.is_real_type ()) { diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/pr-output.cc Wed Dec 09 14:00:43 2015 -0500 @@ -3665,11 +3665,7 @@ print_eng = true; } else - { - error ("format: unrecognized option 'short %s'", - arg.c_str ()); - return; - } + error ("format: unrecognized option 'short %s'", arg.c_str ()); } else init_format_state (); @@ -3743,11 +3739,7 @@ print_eng = true; } else - { - error ("format: unrecognized option 'long %s'", - arg.c_str ()); - return; - } + error ("format: unrecognized option 'long %s'", arg.c_str ()); } else init_format_state (); @@ -3816,10 +3808,7 @@ if (arg.length () == 3) plus_format_chars = arg; else - { - error ("format: invalid option for plus format"); - return; - } + error ("format: invalid option for plus format"); } else plus_format_chars = "+- "; @@ -3858,10 +3847,7 @@ return; } else - { - error ("format: unrecognized format state '%s'", arg.c_str ()); - return; - } + error ("format: unrecognized format state '%s'", arg.c_str ()); } else { diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/profiler.cc --- a/libinterp/corefcn/profiler.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/profiler.cc Wed Dec 09 14:00:43 2015 -0500 @@ -265,10 +265,7 @@ profile_data_accumulator::reset (void) { if (is_active ()) - { - error ("Can't reset active profiler."); - return; - } + error ("Can't reset active profiler."); known_functions.clear (); fcn_index.clear (); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/psi.cc --- a/libinterp/corefcn/psi.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/psi.cc Wed Dec 09 14:00:43 2015 -0500 @@ -74,10 +74,7 @@ const octave_value oct_z = (nargin == 1) ? args(0) : args(1); const octave_idx_type k = (nargin == 1) ? 0 : args(0).idx_type_value ("psi: K must be an integer"); if (k < 0) - { - error ("psi: K must be non-negative"); - return retval; - } + error ("psi: K must be non-negative"); else if (k == 0) { #define FLOAT_BRANCH(T, A, M, E) \ @@ -85,13 +82,13 @@ { \ const A ## NDArray z = oct_z.M ## array_value (); \ A ## NDArray psi_z (z.dims ()); \ -\ + \ const E* zv = z.data (); \ E* psi_zv = psi_z.fortran_vec (); \ const octave_idx_type n = z.numel (); \ for (octave_idx_type i = 0; i < n; i++) \ *psi_zv++ = psi (*zv++); \ -\ + \ retval = psi_z; \ } @@ -100,18 +97,14 @@ FLOAT_BRANCH(double, Complex, complex_, Complex) else FLOAT_BRANCH(single, FloatComplex, float_complex_, FloatComplex) else - { - error ("psi: Z must be a floating point"); - } + error ("psi: Z must be a floating point"); } else { FLOAT_BRANCH(double, , , double) else FLOAT_BRANCH(single, Float, float_, float) else - { - error ("psi: Z must be a floating point"); - } + error ("psi: Z must be a floating point"); } #undef FLOAT_BRANCH @@ -119,27 +112,22 @@ else { if (! oct_z.is_real_type ()) - { - error ("psi: Z must be real value for polygamma (K > 0)"); - return retval; - } + error ("psi: Z must be real value for polygamma (K > 0)"); #define FLOAT_BRANCH(T, A, M, E) \ if (oct_z.is_ ## T ##_type ()) \ { \ const A ## NDArray z = oct_z.M ## array_value (); \ A ## NDArray psi_z (z.dims ()); \ -\ + \ const E* zv = z.data (); \ E* psi_zv = psi_z.fortran_vec (); \ const octave_idx_type n = z.numel (); \ for (octave_idx_type i = 0; i < n; i++) \ { \ if (*zv < 0) \ - { \ - error ("psi: Z must be non-negative for polygamma (K > 0)"); \ - return retval; \ - } \ + error ("psi: Z must be non-negative for polygamma (K > 0)"); \ + \ *psi_zv++ = psi (k, *zv++); \ } \ retval = psi_z; \ @@ -148,9 +136,7 @@ FLOAT_BRANCH(double, , , double) else FLOAT_BRANCH(single, Float, float_, float) else - { - error ("psi: Z must be a floating point for polygamma (K > 0)"); - } + error ("psi: Z must be a floating point for polygamma (K > 0)"); #undef FLOAT_BRANCH } diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/quadcc.cc --- a/libinterp/corefcn/quadcc.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/quadcc.cc Wed Dec 09 14:00:43 2015 -0500 @@ -1603,28 +1603,19 @@ } if (! args(1).is_real_scalar ()) - { - error ("quadcc: lower limit of integration (A) must be a single real scalar"); - return retval; - } + error ("quadcc: lower limit of integration (A) must be a single real scalar"); else a = args(1).double_value (); if (! args(2).is_real_scalar ()) - { - error ("quadcc: upper limit of integration (B) must be a single real scalar"); - return retval; - } + error ("quadcc: upper limit of integration (B) must be a single real scalar"); else b = args(2).double_value (); if (nargin < 4 || args(3).is_empty ()) tol = 1.0e-6; else if (! args(3).is_real_scalar () || args(3).double_value () <= 0) - { - error ("quadcc: tolerance (TOL) must be a single real scalar > 0"); - return retval; - } + error ("quadcc: tolerance (TOL) must be a single real scalar > 0"); else tol = args(3).double_value (); @@ -1633,10 +1624,7 @@ nivals = 1; } else if (!(args(4).is_real_scalar () || args(4).is_real_matrix ())) - { - error ("quadcc: list of singularities (SING) must be a vector of real values"); - return retval; - } + error ("quadcc: list of singularities (SING) must be a vector of real values"); else { nivals = 1 + args(4).numel (); @@ -1705,16 +1693,12 @@ fargs(0) = ex; fvals = feval (fcn, fargs, 1); if (fvals.length () != 1 || ! fvals(0).is_real_matrix ()) - { - error ("quadcc: integrand F must return a single, real-valued vector"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector"); + Matrix effex = fvals(0).matrix_value (); if (effex.numel () != ex.numel ()) - { - error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); + for (i = 0; i <= n[3]; i++) { iv->fx[i] = effex(i); @@ -1824,16 +1808,12 @@ fargs(0) = ex; fvals = feval (fcn, fargs, 1); if (fvals.length () != 1 || ! fvals(0).is_real_matrix ()) - { - error ("quadcc: integrand F must return a single, real-valued vector"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector"); + Matrix effex = fvals(0).matrix_value (); if (effex.numel () != ex.numel ()) - { - error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); + neval += effex.numel (); for (i = 0; i < n[d] / 2; i++) { @@ -1972,16 +1952,12 @@ fargs(0) = ex; fvals = feval (fcn, fargs, 1); if (fvals.length () != 1 || ! fvals(0).is_real_matrix ()) - { - error ("quadcc: integrand F must return a single, real-valued vector"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector"); + Matrix effex = fvals(0).matrix_value (); if (effex.numel () != ex.numel ()) - { - error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); + neval += effex.numel (); for (i = 0; i < n[0] - 1; i++) { @@ -2068,16 +2044,12 @@ fargs(0) = ex; fvals = feval (fcn, fargs, 1); if (fvals.length () != 1 || ! fvals(0).is_real_matrix ()) - { - error ("quadcc: integrand F must return a single, real-valued vector"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector"); + Matrix effex = fvals(0).matrix_value (); if (effex.numel () != ex.numel ()) - { - error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); - return retval; - } + error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); + neval += effex.numel (); for (i = 0; i < n[0] - 1; i++) { diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/qz.cc --- a/libinterp/corefcn/qz.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/qz.cc Wed Dec 09 14:00:43 2015 -0500 @@ -409,10 +409,7 @@ || ord_job == 'S' || ord_job == 's' || ord_job == 'B' || ord_job == 'b' || ord_job == '+' || ord_job == '-')) - { - error ("qz: invalid order option"); - return retval; - } + error ("qz: invalid order option"); // overflow constant required by dlag2 F77_FUNC (xdlamch, XDLAMCH) (F77_CONST_CHAR_ARG2 ("S", 1), @@ -512,10 +509,7 @@ = (args(0).is_complex_type () || args(1).is_complex_type ()); if (nargin == 3 && complex_case) - { - error ("qz: cannot re-order complex qz decomposition"); - return retval; - } + error ("qz: cannot re-order complex qz decomposition"); // First, declare variables used in both the real and complex case. Matrix QQ(nn,nn), ZZ(nn,nn), VR(nn,nn), VL(nn,nn); @@ -794,216 +788,211 @@ if (! (ord_job == 'N' || ord_job == 'n')) { if (complex_case) - { - // Probably not needed, but better be safe. - error ("qz: cannot re-order complex qz decomposition"); - return retval; - } - else - { + // Probably not needed, but better be safe. + error ("qz: cannot re-order complex qz decomposition"); + #ifdef DEBUG_SORT - std::cout << "qz: ordering eigenvalues: ord_job = " - << ord_job << std::endl; + std::cout << "qz: ordering eigenvalues: ord_job = " + << ord_job << std::endl; #endif - // Declared static to avoid vfork/long jump compiler complaints. - static sort_function sort_test; - sort_test = 0; + // Declared static to avoid vfork/long jump compiler complaints. + static sort_function sort_test; + sort_test = 0; - switch (ord_job) - { - case 'S': - case 's': - sort_test = &fin; - break; + switch (ord_job) + { + case 'S': + case 's': + sort_test = &fin; + break; - case 'B': - case 'b': - sort_test = &fout; - break; + case 'B': + case 'b': + sort_test = &fout; + break; - case '+': - sort_test = &fcrhp; - break; + case '+': + sort_test = &fcrhp; + break; - case '-': - sort_test = &folhp; - break; + case '-': + sort_test = &folhp; + break; - default: - // Invalid order option (should never happen, since we - // checked the options at the top). - panic_impossible (); - break; - } + default: + // Invalid order option (should never happen, since we + // checked the options at the top). + panic_impossible (); + break; + } - octave_idx_type ndim, fail; - double inf_norm; + octave_idx_type ndim, fail; + double inf_norm; - F77_XFCN (xdlange, XDLANGE, - (F77_CONST_CHAR_ARG2 ("I", 1), - nn, nn, aa.data (), nn, work.fortran_vec (), inf_norm - F77_CHAR_ARG_LEN (1))); + F77_XFCN (xdlange, XDLANGE, + (F77_CONST_CHAR_ARG2 ("I", 1), + nn, nn, aa.data (), nn, work.fortran_vec (), inf_norm + F77_CHAR_ARG_LEN (1))); - double eps = std::numeric_limits::epsilon () * inf_norm * nn; + double eps = std::numeric_limits::epsilon () * inf_norm * nn; #ifdef DEBUG_SORT - std::cout << "qz: calling dsubsp: aa=" << std::endl; - octave_print_internal (std::cout, aa, 0); - std::cout << std::endl << "bb=" << std::endl; - octave_print_internal (std::cout, bb, 0); - if (compz == 'V') - { - std::cout << std::endl << "ZZ=" << std::endl; - octave_print_internal (std::cout, ZZ, 0); - } - std::cout << std::endl; - std::cout << "alphar = " << std::endl; - octave_print_internal (std::cout, (Matrix) alphar, 0); - std::cout << std::endl << "alphai = " << std::endl; - octave_print_internal (std::cout, (Matrix) alphai, 0); - std::cout << std::endl << "beta = " << std::endl; - octave_print_internal (std::cout, (Matrix) betar, 0); - std::cout << std::endl; + std::cout << "qz: calling dsubsp: aa=" << std::endl; + octave_print_internal (std::cout, aa, 0); + std::cout << std::endl << "bb=" << std::endl; + octave_print_internal (std::cout, bb, 0); + if (compz == 'V') + { + std::cout << std::endl << "ZZ=" << std::endl; + octave_print_internal (std::cout, ZZ, 0); + } + std::cout << std::endl; + std::cout << "alphar = " << std::endl; + octave_print_internal (std::cout, (Matrix) alphar, 0); + std::cout << std::endl << "alphai = " << std::endl; + octave_print_internal (std::cout, (Matrix) alphai, 0); + std::cout << std::endl << "beta = " << std::endl; + octave_print_internal (std::cout, (Matrix) betar, 0); + std::cout << std::endl; #endif - Array ind (dim_vector (nn, 1)); + Array ind (dim_vector (nn, 1)); - F77_XFCN (dsubsp, DSUBSP, - (nn, nn, aa.fortran_vec (), bb.fortran_vec (), - ZZ.fortran_vec (), sort_test, eps, ndim, fail, - ind.fortran_vec ())); + F77_XFCN (dsubsp, DSUBSP, + (nn, nn, aa.fortran_vec (), bb.fortran_vec (), + ZZ.fortran_vec (), sort_test, eps, ndim, fail, + ind.fortran_vec ())); #ifdef DEBUG - std::cout << "qz: back from dsubsp: aa=" << std::endl; - octave_print_internal (std::cout, aa, 0); - std::cout << std::endl << "bb=" << std::endl; - octave_print_internal (std::cout, bb, 0); - if (compz == 'V') - { - std::cout << std::endl << "ZZ=" << std::endl; - octave_print_internal (std::cout, ZZ, 0); - } - std::cout << std::endl; + std::cout << "qz: back from dsubsp: aa=" << std::endl; + octave_print_internal (std::cout, aa, 0); + std::cout << std::endl << "bb=" << std::endl; + octave_print_internal (std::cout, bb, 0); + if (compz == 'V') + { + std::cout << std::endl << "ZZ=" << std::endl; + octave_print_internal (std::cout, ZZ, 0); + } + std::cout << std::endl; #endif - // Manually update alphar, alphai, betar. - static int jj; + // Manually update alphar, alphai, betar. + static int jj; + + jj = 0; + while (jj < nn) + { +#ifdef DEBUG_EIG + std::cout << "computing gen eig #" << jj << std::endl; +#endif + + // Number of zeros in this block. + static int zcnt; - jj = 0; - while (jj < nn) + if (jj == (nn-1)) + zcnt = 1; + else if (aa(jj+1,jj) == 0) + zcnt = 1; + else zcnt = 2; + + if (zcnt == 1) { + // Real zero. #ifdef DEBUG_EIG - std::cout << "computing gen eig #" << jj << std::endl; + std::cout << " single gen eig:" << std::endl; + std::cout << " alphar(" << jj << ") = " << aa(jj,jj) + << std::endl; + std::cout << " betar(" << jj << ") = " << bb(jj,jj) + << std::endl; + std::cout << " alphai(" << jj << ") = 0" << std::endl; #endif - // Number of zeros in this block. - static int zcnt; - - if (jj == (nn-1)) - zcnt = 1; - else if (aa(jj+1,jj) == 0) - zcnt = 1; - else zcnt = 2; + alphar(jj) = aa(jj,jj); + alphai(jj) = 0; + betar(jj) = bb(jj,jj); + } + else + { + // Complex conjugate pair. +#ifdef DEBUG_EIG + std::cout << "qz: calling dlag2:" << std::endl; + std::cout << "safmin=" + << setiosflags (std::ios::scientific) + << safmin << std::endl; - if (zcnt == 1) + for (int idr = jj; idr <= jj+1; idr++) { - // Real zero. -#ifdef DEBUG_EIG - std::cout << " single gen eig:" << std::endl; - std::cout << " alphar(" << jj << ") = " << aa(jj,jj) - << std::endl; - std::cout << " betar(" << jj << ") = " << bb(jj,jj) - << std::endl; - std::cout << " alphai(" << jj << ") = 0" << std::endl; + for (int idc = jj; idc <= jj+1; idc++) + { + std::cout << "aa(" << idr << "," << idc << ")=" + << aa(idr,idc) << std::endl; + std::cout << "bb(" << idr << "," << idc << ")=" + << bb(idr,idc) << std::endl; + } + } #endif - alphar(jj) = aa(jj,jj); + // FIXME: probably should be using + // fortran_vec instead of &aa(jj,jj) here. + + double scale1, scale2, wr1, wr2, wi; + const double *aa_ptr = aa.data () + jj * nn + jj; + const double *bb_ptr = bb.data () + jj * nn + jj; + F77_XFCN (dlag2, DLAG2, + (aa_ptr, nn, bb_ptr, nn, safmin, + scale1, scale2, wr1, wr2, wi)); + +#ifdef DEBUG_EIG + std::cout << "dlag2 returns: scale1=" << scale1 + << "\tscale2=" << scale2 << std::endl + << "\twr1=" << wr1 << "\twr2=" << wr2 + << "\twi=" << wi << std::endl; +#endif + + // Just to be safe, check if it's a real pair. + if (wi == 0) + { + alphar(jj) = wr1; alphai(jj) = 0; - betar(jj) = bb(jj,jj); + betar(jj) = scale1; + alphar(jj+1) = wr2; + alphai(jj+1) = 0; + betar(jj+1) = scale2; } else { - // Complex conjugate pair. -#ifdef DEBUG_EIG - std::cout << "qz: calling dlag2:" << std::endl; - std::cout << "safmin=" - << setiosflags (std::ios::scientific) - << safmin << std::endl; - - for (int idr = jj; idr <= jj+1; idr++) - { - for (int idc = jj; idc <= jj+1; idc++) - { - std::cout << "aa(" << idr << "," << idc << ")=" - << aa(idr,idc) << std::endl; - std::cout << "bb(" << idr << "," << idc << ")=" - << bb(idr,idc) << std::endl; - } - } -#endif - - // FIXME: probably should be using - // fortran_vec instead of &aa(jj,jj) here. - - double scale1, scale2, wr1, wr2, wi; - const double *aa_ptr = aa.data () + jj * nn + jj; - const double *bb_ptr = bb.data () + jj * nn + jj; - F77_XFCN (dlag2, DLAG2, - (aa_ptr, nn, bb_ptr, nn, safmin, - scale1, scale2, wr1, wr2, wi)); - -#ifdef DEBUG_EIG - std::cout << "dlag2 returns: scale1=" << scale1 - << "\tscale2=" << scale2 << std::endl - << "\twr1=" << wr1 << "\twr2=" << wr2 - << "\twi=" << wi << std::endl; -#endif - - // Just to be safe, check if it's a real pair. - if (wi == 0) - { - alphar(jj) = wr1; - alphai(jj) = 0; - betar(jj) = scale1; - alphar(jj+1) = wr2; - alphai(jj+1) = 0; - betar(jj+1) = scale2; - } - else - { - alphar(jj) = alphar(jj+1) = wr1; - alphai(jj) = -(alphai(jj+1) = wi); - betar(jj) = betar(jj+1) = scale1; - } + alphar(jj) = alphar(jj+1) = wr1; + alphai(jj) = -(alphai(jj+1) = wi); + betar(jj) = betar(jj+1) = scale1; } - - // Advance past this block. - jj += zcnt; } + // Advance past this block. + jj += zcnt; + } + #ifdef DEBUG_SORT - std::cout << "qz: back from dsubsp: aa=" << std::endl; - octave_print_internal (std::cout, aa, 0); - std::cout << std::endl << "bb=" << std::endl; - octave_print_internal (std::cout, bb, 0); + std::cout << "qz: back from dsubsp: aa=" << std::endl; + octave_print_internal (std::cout, aa, 0); + std::cout << std::endl << "bb=" << std::endl; + octave_print_internal (std::cout, bb, 0); - if (compz == 'V') - { - std::cout << std::endl << "ZZ=" << std::endl; - octave_print_internal (std::cout, ZZ, 0); - } - std::cout << std::endl << "qz: ndim=" << ndim << std::endl - << "fail=" << fail << std::endl; - std::cout << "alphar = " << std::endl; - octave_print_internal (std::cout, (Matrix) alphar, 0); - std::cout << std::endl << "alphai = " << std::endl; - octave_print_internal (std::cout, (Matrix) alphai, 0); - std::cout << std::endl << "beta = " << std::endl; - octave_print_internal (std::cout, (Matrix) betar, 0); - std::cout << std::endl; + if (compz == 'V') + { + std::cout << std::endl << "ZZ=" << std::endl; + octave_print_internal (std::cout, ZZ, 0); + } + std::cout << std::endl << "qz: ndim=" << ndim << std::endl + << "fail=" << fail << std::endl; + std::cout << "alphar = " << std::endl; + octave_print_internal (std::cout, (Matrix) alphar, 0); + std::cout << std::endl << "alphai = " << std::endl; + octave_print_internal (std::cout, (Matrix) alphai, 0); + std::cout << std::endl << "beta = " << std::endl; + octave_print_internal (std::cout, (Matrix) betar, 0); + std::cout << std::endl; #endif - } } // Compute generalized eigenvalues? diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/rand.cc --- a/libinterp/corefcn/rand.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/rand.cc Wed Dec 09 14:00:43 2015 -0500 @@ -86,10 +86,7 @@ if (additional_arg) { if (nargin == 0) - { - error ("%s: at least one argument is required", fcn); - goto done; - } + error ("%s: at least one argument is required", fcn); else if (args(0).is_string ()) additional_arg = false; else @@ -166,9 +163,7 @@ double dval = tmp.double_value (); if (xisnan (dval)) - { - error ("%s: NaN is invalid matrix dimension", fcn); - } + error ("%s: NaN is invalid matrix dimension", fcn); else { dims.resize (2); @@ -314,10 +309,8 @@ else { if (a.dims () != dims) - { - error ("%s: mismatch in argument size", fcn); - return retval; - } + error ("%s: mismatch in argument size", fcn); + octave_idx_type len = a.numel (); FloatNDArray m (dims); float *v = m.fortran_vec (); @@ -338,10 +331,8 @@ else { if (a.dims () != dims) - { - error ("%s: mismatch in argument size", fcn); - return retval; - } + error ("%s: mismatch in argument size", fcn); + octave_idx_type len = a.numel (); NDArray m (dims); double *v = m.fortran_vec (); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/strfind.cc --- a/libinterp/corefcn/strfind.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/strfind.cc Wed Dec 09 14:00:43 2015 -0500 @@ -254,10 +254,7 @@ true, true); } else - { - error ("strfind: each element of CELLSTR must be a string"); - break; - } + error ("strfind: each element of CELLSTR must be a string"); } retval = retc; @@ -437,10 +434,7 @@ retc(i) = qs_replace (argse.char_array_value (), pat, rep, table, overlaps); else - { - error ("strrep: each element of S must be a string"); - break; - } + error ("strrep: each element of S must be a string"); } retval = retc; diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/strfns.cc --- a/libinterp/corefcn/strfns.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/strfns.cc Wed Dec 09 14:00:43 2015 -0500 @@ -486,10 +486,7 @@ else { if (size1 != size2) - { - error ("%s: nonconformant cell arrays", fcn_name); - return retval; - } + error ("%s: nonconformant cell arrays", fcn_name); if (cell1.is_cellstr () && cell2.is_cellstr ()) { diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/sysdep.cc --- a/libinterp/corefcn/sysdep.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/sysdep.cc Wed Dec 09 14:00:43 2015 -0500 @@ -338,7 +338,6 @@ { if (interactive && ! forced_interactive) error ("stdin is not a tty!"); - return; } if (on == curr_on) diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/toplev.cc Wed Dec 09 14:00:43 2015 -0500 @@ -1045,10 +1045,7 @@ else if (type_str == "async") type = et_async; else - { - error ("system: TYPE must be \"sync\" or \"async\""); - return retval; - } + error ("system: TYPE must be \"sync\" or \"async\""); } if (nargin > 1) @@ -1064,10 +1061,7 @@ } if (return_output && type == et_async) - { - error ("system: can't return output from commands run asynchronously"); - return retval; - } + error ("system: can't return output from commands run asynchronously"); std::string cmd_str = args(0).xstring_value ("system: first argument must be a string"); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/tril.cc --- a/libinterp/corefcn/tril.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/tril.cc Wed Dec 09 14:00:43 2015 -0500 @@ -131,10 +131,7 @@ do_tril (const Sparse& a, octave_idx_type k, bool pack) { if (pack) // FIXME - { - error ("tril: \"pack\" not implemented for sparse matrices"); - return Sparse (); - } + error ("tril: \"pack\" not implemented for sparse matrices"); Sparse m = a; octave_idx_type nc = m.cols (); @@ -145,6 +142,7 @@ m.data(i) = 0.; m.maybe_compress (true); + return m; } @@ -153,10 +151,7 @@ do_triu (const Sparse& a, octave_idx_type k, bool pack) { if (pack) // FIXME - { - error ("triu: \"pack\" not implemented for sparse matrices"); - return Sparse (); - } + error ("triu: \"pack\" not implemented for sparse matrices"); Sparse m = a; octave_idx_type nc = m.cols (); @@ -267,11 +262,8 @@ // but will also work on arbitrary user types if (pack) // FIXME - { - error ("%s: \"pack\" not implemented for class %s", - name.c_str (), arg.class_name ().c_str ()); - return octave_value (); - } + error ("%s: \"pack\" not implemented for class %s", + name.c_str (), arg.class_name ().c_str ()); octave_value tmp = arg; if (arg.numel () == 0) diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/typecast.cc --- a/libinterp/corefcn/typecast.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/typecast.cc Wed Dec 09 14:00:43 2015 -0500 @@ -81,10 +81,9 @@ return retval; } else - { - error ("typecast: incorrect number of input values to make output value"); - return ArrayType (); - } + error ("typecast: incorrect number of input values to make output value"); + + return ArrayType (); } @@ -291,10 +290,9 @@ return retval; } else - { - error ("bitpack: incorrect number of bits to make up output value"); - return ArrayType (); - } + error ("bitpack: incorrect number of bits to make up output value"); + + return ArrayType (); } DEFUN (bitpack, args, , diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/urlwrite.cc --- a/libinterp/corefcn/urlwrite.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/urlwrite.cc Wed Dec 09 14:00:43 2015 -0500 @@ -80,11 +80,7 @@ create_instance (); if (! instance) - { - error ("unable to create ch_manager!"); - - retval = false; - } + error ("unable to create ch_manager!"); return retval; } @@ -355,18 +351,12 @@ method = args(2).xstring_value ("urlwrite: METHOD must be a string"); if (method != "get" && method != "post") - { - error ("urlwrite: METHOD must be \"get\" or \"post\""); - return retval; - } + error ("urlwrite: METHOD must be \"get\" or \"post\""); param = args(3).xcellstr_value ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell array of strings"); if (param.numel () % 2 == 1) - { - error ("urlwrite: number of elements in PARAM must be even"); - return retval; - } + error ("urlwrite: number of elements in PARAM must be even"); } // The file should only be deleted if it doesn't initially exist, we @@ -378,10 +368,7 @@ std::ofstream ofile (filename.c_str (), std::ios::out | std::ios::binary); if (! ofile.is_open ()) - { - error ("urlwrite: unable to open file"); - return retval; - } + error ("urlwrite: unable to open file"); unwind_protect_safe frame; @@ -486,18 +473,12 @@ method = args(1).xstring_value ("urlread: METHOD must be a string"); if (method != "get" && method != "post") - { - error ("urlread: METHOD must be \"get\" or \"post\""); - return retval; - } + error ("urlread: METHOD must be \"get\" or \"post\""); param = args(2).xcellstr_value ("urlread: parameters (PARAM) for get and post requests must be given as a cell array of strings"); if (param.numel () % 2 == 1) - { - error ("urlread: number of elements in PARAM must be even"); - return retval; - } + error ("urlread: number of elements in PARAM must be even"); } std::ostringstream buf; @@ -915,20 +896,14 @@ file_stat fs (file); if (! fs.exists ()) - { - error ("__ftp__mput: file does not exist"); - break; - } + error ("__ftp__mput: file does not exist"); if (fs.is_dir ()) { file_list.append (curl.mput_directory ("", file)); if (! curl.good ()) - { - error ("__ftp_mput__: %s", curl.lasterror().c_str()); - break; - } + error ("__ftp_mput__: %s", curl.lasterror().c_str()); } else { @@ -937,20 +912,14 @@ std::ios::binary); if (! ifile.is_open ()) - { - error ("__ftp_mput__: unable to open file"); - break; - } + error ("__ftp_mput__: unable to open file"); curl.put (file, ifile); ifile.close (); if (! curl.good ()) - { - error ("__ftp_mput__: %s", curl.lasterror().c_str()); - break; - } + error ("__ftp_mput__: %s", curl.lasterror().c_str()); file_list.append (file); } @@ -1017,10 +986,7 @@ std::ios::binary); if (! ofile.is_open ()) - { - error ("__ftp_mget__: unable to open file"); - break; - } + error ("__ftp_mget__: unable to open file"); unwind_protect_safe frame; @@ -1035,10 +1001,7 @@ } if (! curl.good ()) - { - error ("__ftp_mget__: %s", curl.lasterror().c_str()); - break; - } + error ("__ftp_mget__: %s", curl.lasterror().c_str()); } } diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/utils.cc --- a/libinterp/corefcn/utils.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/utils.cc Wed Dec 09 14:00:43 2015 -0500 @@ -1475,10 +1475,7 @@ dims = ccells[i].dims (); } else if (dims != ccells[i].dims ()) - { - error ("%s: cell arguments must have matching sizes", fun_name); - break; - } + error ("%s: cell arguments must have matching sizes", fun_name); } } @@ -1496,15 +1493,10 @@ const octave_value_list tmp = fun (new_args, nargout); if (tmp.length () < nargout) - { - error ("%s: do_simple_cellfun: internal error", fun_name); - break; - } - else - { - for (int i = 0; i < nargout; i++) - rcells[i](j) = tmp(i); - } + error ("%s: do_simple_cellfun: internal error", fun_name); + + for (int i = 0; i < nargout; i++) + rcells[i](j) = tmp(i); } retval.resize (nargout); diff -r ae0bd73671f3 -r 35241c4b696c libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Tue Dec 08 17:41:32 2015 -0800 +++ b/libinterp/corefcn/variables.cc Wed Dec 09 14:00:43 2015 -0500 @@ -163,11 +163,8 @@ retval = is_valid_function (fname, warn_for, 0); if (! retval) - { - error ("%s: '%s' is not valid as a function", - warn_for.c_str (), fname.c_str ()); - return retval; - } + error ("%s: '%s' is not valid as a function", + warn_for.c_str (), fname.c_str ()); warning ("%s: passing function body as a string is obsolete; please use anonymous functions", warn_for.c_str ()); @@ -332,10 +329,7 @@ print_usage (); if (! args(0).is_string ()) - { - error ("isglobal: NAME must be a string"); - return retval; - } + error ("isglobal: NAME must be a string"); std::string name = args(0).string_value (); @@ -397,10 +391,7 @@ if (! (search_any || search_var || search_dir || search_file || search_builtin || search_class)) - { - error ("exist: unrecognized type argument \"%s\"", type.c_str ()); - return 0; - } + error ("exist: unrecognized type argument \"%s\"", type.c_str ()); if (search_any || search_var) { @@ -1490,10 +1481,7 @@ &a, &b, &balance) - 1; if (items < 2) - { - error ("whos_line_format: parameter structure without command in whos_line_format"); - error_encountered = true; - } + error ("whos_line_format: parameter structure without command in whos_line_format"); // Insert data into parameter param.first_parameter_length = 0; @@ -1510,11 +1498,8 @@ param.first_parameter_length = b; } else - { - error ("whos_line_format: '%c' is not a command", - param.command); - error_encountered = true; - } + error ("whos_line_format: '%c' is not a command", + param.command); if (param.command == 's') { @@ -1559,11 +1544,8 @@ } } else if (param.modifier == 'c') - { - error ("whos_line_format: modifier 'c' not available for command '%c'", - param.command); - error_encountered = true; - } + error ("whos_line_format: modifier 'c' not available for command '%c'", + param.command); // What happens if whos_line_format contains negative numbers // at param_length positions?