Mercurial > hg > octave-terminal
changeset 2589:49ae0d992eea
[project @ 1996-12-13 08:41:43 by jwe]
author | jwe |
---|---|
date | Fri, 13 Dec 1996 08:41:55 +0000 |
parents | ccd72573a0cf |
children | c6cbc2041469 |
files | liboctave/Array2-idx.h liboctave/ChangeLog src/ChangeLog src/ov.cc |
diffstat | 4 files changed, 41 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array2-idx.h +++ b/liboctave/Array2-idx.h @@ -334,6 +334,22 @@ } } +#define MAYBE_RESIZE_LHS \ + do \ + { \ + if (liboctave_rre_flag) \ + { \ + int max_row_idx = idx_i_is_colon ? rhs_nr : idx_i.max () + 1; \ + int max_col_idx = idx_j_is_colon ? rhs_nc : idx_j.max () + 1; \ + \ + int new_nr = max_row_idx > lhs_nr ? max_row_idx : lhs_nr; \ + int new_nc = max_col_idx > lhs_nc ? max_col_idx : lhs_nc; \ + \ + lhs.resize (new_nr, new_nc, 0.0); \ + } \ + } \ + while (0) + template <class LT, class RT> int assign (Array2<LT>& lhs, const Array2<RT>& rhs) @@ -378,19 +394,10 @@ } else { - if (liboctave_rre_flag) - { - int max_row_idx = idx_i_is_colon ? rhs_nr : idx_i.max () + 1; - int max_col_idx = idx_j_is_colon ? rhs_nc : idx_j.max () + 1; - - int new_nr = max_row_idx > lhs_nr ? max_row_idx : lhs_nr; - int new_nc = max_col_idx > lhs_nc ? max_col_idx : lhs_nc; - - lhs.resize (new_nr, new_nc, 0.0); - } - if (rhs_nr == 1 && rhs_nc == 1 && n > 0 && m > 0) { + MAYBE_RESIZE_LHS; + RT scalar = rhs.elem (0, 0); for (int j = 0; j < m; j++) @@ -405,6 +412,8 @@ } else if (n == rhs_nr && m == rhs_nc) { + MAYBE_RESIZE_LHS; + for (int j = 0; j < m; j++) { int jj = idx_j.elem (j);
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +Fri Dec 13 02:01:32 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + + * Array2-idx.h (assign): Delay resizing left hand side until we + know if the assignment conforms. + Tue Dec 10 01:43:09 1996 John W. Eaton <jwe@bevo.che.wisc.edu> * Version 2.0 released.
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +Fri Dec 13 02:38:19 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + + * ov.cc (octave_value::convert_and_assign): Preserve lhs value if + assignment fails. + Wed Dec 11 12:33:16 1996 John W. Eaton <jwe@bevo.che.wisc.edu> * pt-plot.cc (GPLOT_CMD_END): Don't put semicolons at the end of
--- a/src/ov.cc +++ b/src/ov.cc @@ -590,18 +590,23 @@ if (tmp) { - if (tmp != rep) + octave_value *old_rep = rep; + rep = tmp; + rep->count = 1; + + assignment_ok = try_assignment (idx, rhs); + + if (! assignment_ok && old_rep) { if (--rep->count == 0) delete rep; - rep = tmp; - rep->count = 1; + rep = old_rep; + old_rep = 0; } - else - delete tmp; - assignment_ok = try_assignment (idx, rhs); + if (old_rep && --old_rep->count == 0) + delete old_rep; } else gripe_conversion_failed (type_name (), rhs.type_name ());