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	Thu Jul 01 10:01:56 2010 +0200
+++ b/src/ChangeLog	Fri Jul 02 08:10:57 2010 +0200
@@ -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	Thu Jul 01 10:01:56 2010 +0200
+++ b/src/data.cc	Fri Jul 02 08:10:57 2010 +0200
@@ -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	Thu Jul 01 10:01:56 2010 +0200
+++ b/src/oct-map.cc	Fri Jul 02 08:10:57 2010 +0200
@@ -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;