Mercurial > hg > octave-lojdl
changeset 10763:b397b8edd8c5
fix off-by-1 dim in scalar map horzcat/vertcat
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 02 Jul 2010 08:10:57 +0200 |
parents | d53eb6249892 |
children | e141bcb1befd |
files | src/ChangeLog src/data.cc src/oct-map.cc |
diffstat | 3 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-07-02 Jaroslav Hajek <highegg@gmail.com> + + * oct-map.cc (octave_map::cat (..., const octave_scalar_map *)): + Handle special dims (-1, -2). + * data.cc (do_single_type_concat_map): Don't handle them here. + 2010-07-01 Jaroslav Hajek <highegg@gmail.com> * syscalls.cc (mk_stat_map, Funame): Use octave_scalar_map.
--- a/src/data.cc +++ b/src/data.cc @@ -1482,12 +1482,7 @@ { octave_map result; if (all_scalar_1x1 (args)) // optimize all scalars case. - { - if (dim < 0) - dim = -dim; - - single_type_concat_map<octave_scalar_map> (result, args, dim); - } + single_type_concat_map<octave_scalar_map> (result, args, dim); else single_type_concat_map<octave_map> (result, args, dim);
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -640,6 +640,13 @@ octave_map::cat (int dim, octave_idx_type n, const octave_scalar_map *map_list) { octave_map retval; + // Allow dim = -1, -2 for compatibility, though it makes no difference here. + if (dim == -1 || dim == -2) + dim = -dim - 1; + else if (dim < 0) + (*current_liboctave_error_handler) + ("cat: invalid dimension"); + if (n > 0) { retval.xkeys = map_list[0].xkeys;