Mercurial > hg > octave-lyh
diff src/ov-struct.cc @ 12181:88ff30dcc048
fix another bug in class assignment to undefined object with index
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 27 Jan 2011 06:16:50 -0500 |
parents | ed129a03f93c |
children | 7a5aacf65f81 |
line wrap: on
line diff
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -328,7 +328,9 @@ { octave_value& tmp = tmpc(0); - if (! tmp.is_defined () || tmp.is_zero_by_zero ()) + bool orig_undefined = tmp.is_undefined (); + + if (orig_undefined || tmp.is_zero_by_zero ()) { tmp = octave_value::empty_conv (next_type, rhs); tmp.make_unique (); // probably a no-op. @@ -338,7 +340,9 @@ tmp.make_unique (1); if (! error_state) - t_rhs = tmp.subsasgn (next_type, next_idx, rhs); + t_rhs = (orig_undefined + ? tmp.undef_subsasgn (next_type, next_idx, rhs) + : tmp.subsasgn (next_type, next_idx, rhs)); } else gripe_indexed_cs_list (); @@ -378,7 +382,9 @@ { octave_value& tmp = tmpc(0); - if (! tmp.is_defined () || tmp.is_zero_by_zero ()) + bool orig_undefined = tmp.is_undefined (); + + if (orig_undefined || tmp.is_zero_by_zero ()) { tmp = octave_value::empty_conv (next_type, rhs); tmp.make_unique (); // probably a no-op. @@ -388,7 +394,9 @@ tmp.make_unique (1); if (! error_state) - t_rhs = tmp.subsasgn (next_type, next_idx, rhs); + t_rhs = (orig_undefined + ? tmp.undef_subsasgn (next_type, next_idx, rhs) + : tmp.subsasgn (next_type, next_idx, rhs)); } else gripe_indexed_cs_list (); @@ -1244,7 +1252,9 @@ if (! error_state) { - if (! tmp.is_defined () || tmp.is_zero_by_zero ()) + bool orig_undefined = tmp.is_undefined (); + + if (orig_undefined || tmp.is_zero_by_zero ()) { tmp = octave_value::empty_conv (next_type, rhs); tmp.make_unique (); // probably a no-op. @@ -1254,7 +1264,9 @@ tmp.make_unique (1); if (! error_state) - t_rhs = tmp.subsasgn (next_type, next_idx, rhs); + t_rhs = (orig_undefined + ? tmp.undef_subsasgn (next_type, next_idx, rhs) + : tmp.subsasgn (next_type, next_idx, rhs)); } }