Mercurial > hg > octave-lyh
changeset 4876:05d464a13f43
[project @ 2004-04-22 19:38:14 by jwe]
author | jwe |
---|---|
date | Thu, 22 Apr 2004 19:38:14 +0000 |
parents | e674c7111b88 |
children | 0ab4fd8ded30 |
files | liboctave/Array.cc liboctave/ChangeLog src/ChangeLog src/pt-colon.cc |
diffstat | 4 files changed, 26 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2004,7 +2004,7 @@ if (len == 0 && idx_arg.one_zero_only ()) retval = Array<T> (tmp, dim_vector (0, 0)); - else + else if (len >= idx_orig_dims.numel ()) retval = Array<T> (tmp, idx_orig_dims); } else if (nr == 1 || nc == 1) @@ -2025,7 +2025,7 @@ else retval = Array<T> (tmp, dim_vector (len, 1)); } - else + else if (len >= idx_orig_dims.numel ()) retval = Array<T> (tmp, idx_orig_dims); } else @@ -2101,8 +2101,13 @@ Array<T> tmp = Array<T>::index (ra_idx, resize_ok); - if (tmp.length () != 0) - retval = Array<T> (tmp, idx_orig_dims); + int len = tmp.length (); + + if (len != 0) + { + if (len >= idx_orig_dims.numel ()) + retval = Array<T> (tmp, idx_orig_dims); + } else retval = Array<T> (tmp, dim_vector (0, 0)); } @@ -2154,7 +2159,7 @@ retval = Array<T> (tmp, new_dims); } - else + else if (tmp.length () >= idx_orig_dims.numel ()) retval = Array<T> (tmp, idx_orig_dims); (*current_liboctave_error_handler)
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2004-04-22 John W. Eaton <jwe@bevo.che.wisc.edu> + + * Array.cc (Array<T>::index2, Array<T>::indexN): + Don't set invalid dimensions on return value. + 2004-04-21 John W. Eaton <jwe@octave.org> * mx-inlines.cc (MX_ND_REDUCTION): Chop trailing singletons.
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-04-22 John W. Eaton <jwe@bevo.che.wisc.edu> + + * pt-colon.cc (tree_colon_expression::rvalue): Also check for + error_state after evaluating each subexpression. + 2004-04-22 David Bateman <dbateman@free.fr> * ov-base-scalar.h (octave_base_scalar<ST>::permute): New function.
--- a/src/pt-colon.cc +++ b/src/pt-colon.cc @@ -96,9 +96,9 @@ octave_value tmp = op_base->rvalue (); - if (tmp.is_undefined ()) + if (error_state || tmp.is_undefined ()) { - eval_error ("invalid null value in colon expression"); + eval_error ("invalid value in colon expression"); return retval; } @@ -112,9 +112,9 @@ tmp = op_limit->rvalue (); - if (tmp.is_undefined ()) + if (error_state || tmp.is_undefined ()) { - eval_error ("invalid null value in colon expression"); + eval_error ("invalid value in colon expression"); return retval; } @@ -132,9 +132,9 @@ { tmp = op_increment->rvalue (); - if (tmp.is_undefined ()) + if (error_state || tmp.is_undefined ()) { - eval_error ("invalid null value in colon expression"); + eval_error ("invalid value in colon expression"); return retval; }