Mercurial > hg > octave-nkf
diff liboctave/Array.cc @ 5052:c6ef19da4b24
[project @ 2004-10-19 18:40:48 by jwe]
author | jwe |
---|---|
date | Tue, 19 Oct 2004 18:40:48 +0000 |
parents | 36f954d8d53a |
children | 273205761b4d |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2940,7 +2940,9 @@ if (n_idx < lhs_dims_len) { - // Collapse dimensions beyond last index. + // Collapse dimensions beyond last index. Note that we + // delay resizing LHS until we know that the assignment will + // succeed. if (liboctave_wfi_flag && ! (idx(n_idx-1).is_colon ())) (*current_liboctave_warning_handler) @@ -2951,10 +2953,6 @@ lhs_dims.resize (n_idx); - lhs.resize (lhs_dims); - - lhs_dims = lhs.dims (); - lhs_dims_len = lhs_dims.length (); } @@ -3010,6 +3008,11 @@ } else { + // Determine final dimensions for LHS and reset the + // current size of the LHS. Note that we delay actually + // resizing LHS until we know that the assignment will + // succeed. + if (n_idx < orig_lhs_dims_len) { for (int i = 0; i < n_idx-1; i++) @@ -3018,9 +3021,7 @@ else final_lhs_dims = new_dims; - lhs.resize_and_fill (new_dims, rfv); - - lhs_dims = lhs.dims (); + lhs_dims = new_dims; lhs_dims_len = lhs_dims.length (); @@ -3028,6 +3029,8 @@ if (rhs_is_scalar) { + lhs.resize_and_fill (new_dims, rfv); + if (! final_lhs_dims.any_zero ()) { int n = Array<LT>::get_size (frozen_len); @@ -3085,6 +3088,8 @@ } else { + lhs.resize_and_fill (new_dims, rfv); + if (! final_lhs_dims.any_zero ()) { int n = Array<LT>::get_size (frozen_len); @@ -3105,10 +3110,12 @@ } } - lhs.resize (final_lhs_dims); + if (retval != 0) + lhs.resize (final_lhs_dims); } - lhs.chop_trailing_singletons (); + if (retval != 0) + lhs.chop_trailing_singletons (); lhs.clear_index ();