changeset 5433:2f51d6d65fb2

[project @ 2005-08-30 15:20:30 by jwe]
author jwe
date Tue, 30 Aug 2005 15:20:30 +0000
parents a42806a03f8f
children c2428a4b7d56
files src/ChangeLog src/ov-struct.cc
diffstat 2 files changed, 42 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Aug 29 20:55:27 2005 +0000
+++ b/src/ChangeLog	Tue Aug 30 15:20:30 2005 +0000
@@ -1,3 +1,9 @@
+2005-08-30  John W. Eaton  <jwe@octave.org>
+
+	* ov-struct.cc (octave_struct::load_ascii,
+	octave_struct::load_binary, octave_struct::load_hdf5): Try harder
+	to read old-style files correctly.
+
 2005-08-25  David Bateman <dbateman@free.fr>
 
         * OPERATORS/op-sm-m.cc, OPERATORS/op-sm-cm.cc, OPERATORS/op-scm-m.cc,
--- a/src/ov-struct.cc	Mon Aug 29 20:55:27 2005 +0000
+++ b/src/ov-struct.cc	Tue Aug 30 15:20:30 2005 +0000
@@ -1026,15 +1026,20 @@
 		break;
 
 	      // Try for some backward compatibility...
-	      Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-	      if (error_state)
+	      if (t2.is_cell () && t2.length() > 1)
+		m.assign (nm, t2);
+	      else
 		{
-		  error ("load: internal error loading struct elements");
-		  return false;
+		  Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
+
+		  if (error_state)
+		    {
+		      error ("load: internal error loading struct elements");
+		      return false;
+		    }
+
+		  m.assign (nm, tcell);
 		}
-
-	      m.assign (nm, tcell);
 	    }
 
 	  if (is) 
@@ -1111,15 +1116,20 @@
 	    break;
 
 	  // Try for some backward compatibility...
-	  Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-	  if (error_state)
+	  if (t2.is_cell () && t2.length() > 1)
+	    m.assign (nm, t2);
+	  else
 	    {
-	      error ("load: internal error loading struct elements");
-	      return false;
+	      Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
+ 
+	      if (error_state)
+		{
+		  error ("load: internal error loading struct elements");
+		  return false;
+		}
+
+	      m.assign (nm, tcell);
 	    }
-
-	  m.assign (nm, tcell);
 	}
 
       if (is) 
@@ -1197,16 +1207,21 @@
       octave_value t2 = dsub.tc;
 
       // Try for some backward compatibility...
-      Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-      if (error_state)
+      if (t2.is_cell () && t2.length() > 1)
+	m.assign (dsub.name, t2);
+      else
 	{
-	  error ("load: internal error loading struct elements");
-	  return false;
+	  Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
+ 
+	  if (error_state)
+	    {
+	      error ("load: internal error loading struct elements");
+	      return false;
+	    }
+
+	  m.assign (dsub.name, tcell);
 	}
 
-      m.assign (dsub.name, tcell);
-
       if (have_h5giterate_bug)
 	current_item++;  // H5Giterate returned the last index processed
     }