# HG changeset patch # User John W. Eaton # Date 1444416216 14400 # Node ID eef93a493ce3abb70a3a8484fbcec2d43c0e5128 # Parent e5986cba4ca820d0c2e17bda566e6a79f0da55b3 use new cell_value method to handle value extraction errors * cellfun.cc, ov-class.cc, ov-struct.cc, ov-usr-fcn.cc: Use new cell_value method. diff -r e5986cba4ca8 -r eef93a493ce3 libinterp/corefcn/cellfun.cc --- a/libinterp/corefcn/cellfun.cc Fri Oct 09 14:41:49 2015 -0400 +++ b/libinterp/corefcn/cellfun.cc Fri Oct 09 14:43:36 2015 -0400 @@ -2463,26 +2463,21 @@ if (args.length () >= 1) { - if (args(0).is_cell ()) - { - const Cell x = args(0).cell_value (); - NoAlias y(x.dims ()); - octave_idx_type nel = x.numel (); - octave_value_list idx = args.slice (1, args.length () - 1); + const Cell x = args(0).cell_value ("cellindexmat: X must be a cell"); + NoAlias y(x.dims ()); + octave_idx_type nel = x.numel (); + octave_value_list idx = args.slice (1, args.length () - 1); - for (octave_idx_type i = 0; i < nel; i++) - { - octave_quit (); - - octave_value tmp = x(i); + for (octave_idx_type i = 0; i < nel; i++) + { + octave_quit (); - y(i) = tmp.do_index_op (idx); - } + octave_value tmp = x(i); - retval = y; + y(i) = tmp.do_index_op (idx); } - else - error ("cellindexmat: X must be a cell"); + + retval = y; } else print_usage (); diff -r e5986cba4ca8 -r eef93a493ce3 libinterp/octave-value/ov-class.cc --- a/libinterp/octave-value/ov-class.cc Fri Oct 09 14:41:49 2015 -0400 +++ b/libinterp/octave-value/ov-class.cc Fri Oct 09 14:43:36 2015 -0400 @@ -1301,13 +1301,7 @@ if (! is) break; - Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); - - if (error_state) - { - error ("load: internal error loading class elements"); - return false; - } + Cell tcell = t2.is_cell () ? t2.cell_value ("load: internal error loading class elements") : Cell (t2); m.assign (nm, tcell); } @@ -1444,13 +1438,7 @@ if (! is) break; - Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); - - if (error_state) - { - error ("load: internal error loading class elements"); - return false; - } + Cell tcell = t2.is_cell () ? t2.cell_value ("load: internal error loading class elements") : Cell (t2); m.assign (nm, tcell); } @@ -1684,13 +1672,7 @@ { octave_value t2 = dsub.tc; - Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); - - if (error_state) - { - error ("load: internal error loading class elements"); - return false; - } + Cell tcell = t2.is_cell () ? t2.cell_value ("load: internal error loading class elements") : Cell (t2); m.assign (dsub.name, tcell); diff -r e5986cba4ca8 -r eef93a493ce3 libinterp/octave-value/ov-struct.cc --- a/libinterp/octave-value/ov-struct.cc Fri Oct 09 14:41:49 2015 -0400 +++ b/libinterp/octave-value/ov-struct.cc Fri Oct 09 14:43:36 2015 -0400 @@ -799,13 +799,7 @@ if (!is) break; - Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); - - if (error_state) - { - error ("load: internal error loading struct elements"); - return false; - } + Cell tcell = t2.is_cell () ? t2.cell_value ("load: internal error loading struct elements") : Cell (t2); m.setfield (nm, tcell); } @@ -927,13 +921,7 @@ if (!is) break; - Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); - - if (error_state) - { - error ("load: internal error loading struct elements"); - return false; - } + Cell tcell = t2.is_cell () ? t2.cell_value ("load: internal error loading struct elements") : Cell (t2); m.setfield (nm, tcell); } @@ -1030,13 +1018,7 @@ { octave_value t2 = dsub.tc; - Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); - - if (error_state) - { - error ("load: internal error loading struct elements"); - return false; - } + Cell tcell = t2.is_cell () ? t2.cell_value ("load: internal error loading struct elements") : Cell (t2); m.setfield (dsub.name, tcell); diff -r e5986cba4ca8 -r eef93a493ce3 libinterp/octave-value/ov-usr-fcn.cc --- a/libinterp/octave-value/ov-usr-fcn.cc Fri Oct 09 14:41:49 2015 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.cc Fri Oct 09 14:43:36 2015 -0400 @@ -635,12 +635,7 @@ octave_value varargout_varval = symbol_table::varval ("varargout"); if (varargout_varval.is_defined ()) - { - varargout = varargout_varval.cell_value (); - - if (error_state) - error ("expecting varargout to be a cell array object"); - } + varargout = varargout_varval.cell_value ("expecting varargout to be a cell array object"); } retval = ret_list->convert_to_const_vector (nargout, varargout);