diff src/ov-cell.cc @ 6767:a6c8000f113e

[project @ 2007-06-28 19:42:42 by jwe]
author jwe
date Thu, 28 Jun 2007 19:42:42 +0000
parents 2aad75fcc93a
children e8a18d380097
line wrap: on
line diff
--- a/src/ov-cell.cc	Thu Jun 28 15:40:21 2007 +0000
+++ b/src/ov-cell.cc	Thu Jun 28 19:42:42 2007 +0000
@@ -137,20 +137,34 @@
 	{
 	case '(':
 	  {
-	    octave_value tmp = do_index_op (idx.front (), true);
+	    if (is_empty () && type[1] == '.')
+	      {
+		// Allow conversion of empty cell array to some other
+		// type in cases like
+		//
+		//  x = []; x(i).f = rhs
 
-	    if (! tmp.is_defined ())
-	      tmp = octave_value::empty_conv (type.substr (1), rhs);
+		octave_value tmp = octave_value::empty_conv (type, rhs);
 
-	    if (! error_state)
+		return tmp.subsasgn (type, idx, rhs);
+	      }
+	    else
 	      {
-		std::list<octave_value_list> next_idx (idx);
+		octave_value tmp = do_index_op (idx.front (), true);
 
-		next_idx.erase (next_idx.begin ());
+		if (! tmp.is_defined ())
+		  tmp = octave_value::empty_conv (type.substr (1), rhs);
 
-		tmp.make_unique ();
+		if (! error_state)
+		  {
+		    std::list<octave_value_list> next_idx (idx);
 
-		t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
+		    next_idx.erase (next_idx.begin ());
+
+		    tmp.make_unique ();
+
+		    t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
+		  }
 	      }
 	  }
 	  break;