changeset 6392:e8c42df3d234

[project @ 2007-03-07 18:20:46 by jwe]
author jwe
date Wed, 07 Mar 2007 18:20:47 +0000
parents 3f3e86e9fb57
children 428b147d7e93
files liboctave/Array.cc liboctave/ChangeLog scripts/ChangeLog scripts/testfun/assert.m
diffstat 4 files changed, 43 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array.cc	Wed Mar 07 18:14:44 2007 +0000
+++ b/liboctave/Array.cc	Wed Mar 07 18:20:47 2007 +0000
@@ -2525,38 +2525,40 @@
 
 	  retval = 0;
 	}
-
-      if (rhs_len == n || rhs_len == 1)
-	{
-	  octave_idx_type max_idx = lhs_idx.max () + 1;
-	  if (max_idx > lhs_len)
-	    lhs.resize_and_fill (max_idx, rfv);
-	}
-
-      if (rhs_len == n)
-	{
-	  for (octave_idx_type i = 0; i < n; i++)
-	    {
-	      octave_idx_type ii = lhs_idx.elem (i);
-	      lhs.elem (ii) = rhs.elem (i);
-	    }
-	}
-      else if (rhs_len == 1)
-	{
-	  RT scalar = rhs.elem (0);
-
-	  for (octave_idx_type i = 0; i < n; i++)
-	    {
-	      octave_idx_type ii = lhs_idx.elem (i);
-	      lhs.elem (ii) = scalar;
-	    }
-	}
       else
 	{
-	  (*current_liboctave_error_handler)
-	    ("A(I) = X: X must be a scalar or a vector with same length as I");
-
-	  retval = 0;
+	  if (rhs_len == n || rhs_len == 1)
+	    {
+	      octave_idx_type max_idx = lhs_idx.max () + 1;
+	      if (max_idx > lhs_len)
+		lhs.resize_and_fill (max_idx, rfv);
+	    }
+
+	  if (rhs_len == n)
+	    {
+	      for (octave_idx_type i = 0; i < n; i++)
+		{
+		  octave_idx_type ii = lhs_idx.elem (i);
+		  lhs.elem (ii) = rhs.elem (i);
+		}
+	    }
+	  else if (rhs_len == 1)
+	    {
+	      RT scalar = rhs.elem (0);
+
+	      for (octave_idx_type i = 0; i < n; i++)
+		{
+		  octave_idx_type ii = lhs_idx.elem (i);
+		  lhs.elem (ii) = scalar;
+		}
+	    }
+	  else
+	    {
+	      (*current_liboctave_error_handler)
+		("A(I) = X: X must be a scalar or a vector with same length as I");
+
+	      retval = 0;
+	    }
 	}
     }
   else if (lhs_idx.is_colon ())
--- a/liboctave/ChangeLog	Wed Mar 07 18:14:44 2007 +0000
+++ b/liboctave/ChangeLog	Wed Mar 07 18:20:47 2007 +0000
@@ -1,5 +1,7 @@
 2007-03-07  John W. Eaton  <jwe@octave.org>
 
+	* Array.cc (assign1): Avoid resizing if there is an error.
+
 	* dMatrix.cc, CMatrix.cc (operator *): Only check
 	f77_exception_encountered immediately after calls that use F77_XFCN.
 
--- a/scripts/ChangeLog	Wed Mar 07 18:14:44 2007 +0000
+++ b/scripts/ChangeLog	Wed Mar 07 18:20:47 2007 +0000
@@ -1,3 +1,8 @@
+2007-03-07  John W. Eaton  <jwe@octave.org>
+
+	* testfun/assert.m: Check that number of dimensions match before
+	checking dimensions.
+
 2007-03-07  Muthiah Annamalai  <muthuspost@gmail.com>
 
 	* specfun/perms.m, specfun/factorial.m: Check args.
--- a/scripts/testfun/assert.m	Wed Mar 07 18:14:44 2007 +0000
+++ b/scripts/testfun/assert.m	Wed Mar 07 18:20:47 2007 +0000
@@ -100,8 +100,8 @@
     endif
 
   elseif (isstruct (expected))
-    if (!isstruct (cond) || any(size(cond) != size(expected)) || ...
-	rows(struct_elements(cond)) != rows(struct_elements(expected)))
+    if (!isstruct (cond) || any(size(cond) != size(expected))
+	|| rows(struct_elements(cond)) != rows(struct_elements(expected)))
       iserror = 1;
     else
       try
@@ -121,7 +121,8 @@
   elseif (isempty (expected))
     iserror = (any (size (cond) != size (expected)));
 
-  elseif (any (size (cond) != size (expected)))
+  elseif (ndims (cond) != ndims (expected)
+	  || any (size (cond) != size (expected)))
     iserror = 1;
     coda = "Dimensions don't match";