Mercurial > octave
changeset 20977:c6a170510735
maint: pt-idx.cc, pt-assign.cc: invert if/else/error instances.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 24 Dec 2015 11:42:57 -0500 |
parents | 0fd972b06a6f |
children | a5b500efca9f |
files | libinterp/parse-tree/pt-assign.cc libinterp/parse-tree/pt-idx.cc |
diffstat | 2 files changed, 18 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-assign.cc Wed Dec 23 17:47:40 2015 -0500 +++ b/libinterp/parse-tree/pt-assign.cc Thu Dec 24 11:42:57 2015 -0500 @@ -84,10 +84,10 @@ { const octave_value_list lst = rhs_val.list_value (); - if (! lst.empty ()) - rhs_val = lst(0); - else + if (lst.empty ()) error ("invalid number of elements on RHS of assignment"); + + rhs_val = lst(0); } try @@ -262,20 +262,18 @@ ult.set_index ("{", idx); } - if (k + nel <= n) - { - // This won't do a copy. - octave_value_list ovl = rhs_val.slice (k, nel); + if (k + nel > n) + error ("some elements undefined in return list"); + + // This won't do a copy. + octave_value_list ovl = rhs_val.slice (k, nel); - ult.assign (octave_value::op_asn_eq, - octave_value (ovl, true)); - - retval_list.push_back (ovl); + ult.assign (octave_value::op_asn_eq, + octave_value (ovl, true)); - k += nel; - } - else - error ("some elements undefined in return list"); + retval_list.push_back (ovl); + + k += nel; } else {
--- a/libinterp/parse-tree/pt-idx.cc Wed Dec 23 17:47:40 2015 -0500 +++ b/libinterp/parse-tree/pt-idx.cc Thu Dec 24 11:42:57 2015 -0500 @@ -501,6 +501,7 @@ { final_index_error (e, expr); } + tmpidx.clear (); } @@ -515,13 +516,11 @@ if (i < n - 1) { - if (type[i+1] == '.') - { - tmpidx.push_back (tidx); - tmpi = i+1; - } - else + if (type[i+1] != '.') error ("() must be followed by . or close the index chain"); + + tmpidx.push_back (tidx); + tmpi = i+1; } } break;