Mercurial > hg > octave-nkf
diff src/oct-lvalue.cc @ 10227:d3fc22c3071c
omit ~ values from multi-assignment return lists
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 30 Jan 2010 06:03:19 +0100 |
parents | 37a08e0ce2dc |
children | 57a59eae83cc |
line wrap: on
line diff
--- a/src/oct-lvalue.cc +++ b/src/oct-lvalue.cc @@ -33,12 +33,15 @@ void octave_lvalue::assign (octave_value::assign_op op, const octave_value& rhs) { - octave_value tmp (idx.empty () - ? val->assign (op, rhs) - : val->assign (op, type, idx, rhs)); + if (val) + { + octave_value tmp (idx.empty () + ? val->assign (op, rhs) + : val->assign (op, type, idx, rhs)); - if (! error_state) - *val = tmp; + if (! error_state) + *val = tmp; + } } void @@ -57,12 +60,17 @@ void octave_lvalue::do_unary_op (octave_value::unary_op op) { - octave_value tmp (idx.empty () - ? val->do_non_const_unary_op (op) - : val->do_non_const_unary_op (op, type, idx)); + if (val) + { + octave_value tmp (idx.empty () + ? val->do_non_const_unary_op (op) + : val->do_non_const_unary_op (op, type, idx)); - if (! error_state) - *val = tmp; + if (! error_state) + *val = tmp; + } + else + error ("internal: invalid operation on ~"); } octave_value @@ -70,18 +78,21 @@ { octave_value retval; - if (idx.empty ()) - retval = *val; - else + if (val) { - if (val->is_constant ()) - retval = val->subsref (type, idx); + if (idx.empty ()) + retval = *val; else - { - octave_value_list t = val->subsref (type, idx, 1); - if (t.length () > 0) - retval = t(0); - } + { + if (val->is_constant ()) + retval = val->subsref (type, idx); + else + { + octave_value_list t = val->subsref (type, idx, 1); + if (t.length () > 0) + retval = t(0); + } + } } return retval;