changeset 5099:f7e39f977fe8

[project @ 2004-12-24 19:06:01 by jwe]
author jwe
date Fri, 24 Dec 2004 19:06:01 +0000
parents ab4e64f92526
children 5a92c3177fc6
files doc/faq/Octave-FAQ.texi doc/liboctave/liboctave.texi src/ChangeLog src/ls-oct-ascii.cc src/ls-oct-ascii.h src/ov-bool-mat.cc src/ov-cell.cc src/ov-cx-mat.cc src/ov-re-mat.cc src/ov-str-mat.cc src/pt-idx.cc src/pt-idx.h src/version.h
diffstat 13 files changed, 451 insertions(+), 277 deletions(-) [+]
line wrap: on
line diff
--- a/doc/faq/Octave-FAQ.texi	Sat Dec 18 15:04:20 2004 +0000
+++ b/doc/faq/Octave-FAQ.texi	Fri Dec 24 19:06:01 2004 +0000
@@ -4,7 +4,9 @@
 @settitle Frequently asked questions about Octave (with answers)
 
 @setchapternewpage off
-
+@direntry
+* Octave-FAQ: (Octave-FAQ). Frequently asked questions about Octave
+@end direntry
 @titlepage
 @title Octave FAQ
 @subtitle Frequently asked questions about Octave
--- a/doc/liboctave/liboctave.texi	Sat Dec 18 15:04:20 2004 +0000
+++ b/doc/liboctave/liboctave.texi	Fri Dec 24 19:06:01 2004 +0000
@@ -4,6 +4,9 @@
 
 \input texinfo  @c -*-texinfo-*-
 @setfilename liboctave.info
+@direntry
+* liboctave: (liboctave). Octave C++ Classes
+@end direntry
 
 @c @smallbook
 @c @setchapternewpage odd
--- a/src/ChangeLog	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ChangeLog	Fri Dec 24 19:06:01 2004 +0000
@@ -1,3 +1,24 @@
+2004-12-22  John W. Eaton  <jwe@octave.org>
+
+	* ls-oct-ascii.cc (extract_keyword (std::istream&, const
+	string_vector&, std::string&, int&, const bool): New function.
+	* ls-oct-ascii.h: Provide decl.
+	* ov-bool-mat.cc (octave_bool_matrix::load_ascii):
+	Use new extract_keyword function to avoid calling tellg/seekg.
+	* ov-cell.cc (octave_cell::load_ascii): Likewise.
+	* ov-cx-mat.cc (octave_complex_matrix::load_ascii): Likewise.
+	* ov-re-mat.cc (octave_matrix::load_ascii): Likewise.
+	* ov-str-mat.cc (octave_char_matrix_str::load_ascii): Likewise.
+
+2004-12-20  John W. Eaton  <jwe@octave.org>
+
+	* pt-idx.cc (tree_index_expression::has_magic_end): Return true if
+	any argument list element has a magic end token.
+
+2004-12-03  John W. Eaton  <jwe@octave.org>
+  
+  	* version.h (OCTAVE_VERSION): Now 2.1.64.
+
 2004-12-03  Teemu Ikonen  <tpikonen@pcu.helsinki.fi>
 
 	* file-io.cc: Doc string fixes.
--- a/src/ls-oct-ascii.cc	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ls-oct-ascii.cc	Fri Dec 24 19:06:01 2004 +0000
@@ -234,6 +234,71 @@
   return status;
 }
 
+// Match one of the elements in KEYWORDS on stream IS, placing the
+// matched keyword in KW and the associated value in VALUE,
+// returning TRUE if successful and FALSE otherwise.
+//
+// Input should look something like:
+//
+//  [%#][ \t]*keyword[ \t]*int-value.*\n
+
+bool
+extract_keyword (std::istream& is, const string_vector& keywords,
+		 std::string& kw, int& value, const bool next_only)
+{
+  bool status = false;
+  kw = "";
+  value = 0;
+
+  char c;
+  while (is.get (c))
+    {
+      if (c == '%' || c == '#')
+	{
+	  OSSTREAM buf;
+
+	  while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
+	    ; // Skip whitespace and comment characters.
+
+	  if (isalpha (c))
+	    buf << c;
+
+	  while (is.get (c) && isalpha (c))
+	    buf << c;
+
+	  buf << OSSTREAM_ENDS;
+	  std::string tmp = OSSTREAM_STR (buf);
+	  OSSTREAM_FREEZE (buf);
+
+	  for (int i = 0; i < keywords.length (); i++)
+	    {
+	      int match = (tmp == keywords[i]);
+
+	      if (match)
+		{
+		  kw = keywords[i];
+
+		  while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
+		    ; // Skip whitespace and the colon.
+
+		  is.putback (c);
+		  if (c != '\n')
+		    is >> value;
+		  if (is)
+		    status = true;
+		  while (is.get (c) && c != '\n')
+		    ; // Skip to beginning of next line;
+		  return status;
+		}
+	    }
+
+	  if (next_only)
+	    break;
+	}
+    }
+  return status;
+}
+
 // Extract one value (scalar, matrix, string, etc.) from stream IS and
 // place it in TC, returning the name of the variable.  If the value
 // is tagged as global in the file, return TRUE in GLOBAL.
--- a/src/ls-oct-ascii.h	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ls-oct-ascii.h	Fri Dec 24 19:06:01 2004 +0000
@@ -25,6 +25,10 @@
 
 #include <cfloat>
 
+#include <string>
+
+#include "str-vec.h"
+
 // Flag for cell elements
 #define CELL_ELT_TAG "<cell-element>"
 
@@ -42,6 +46,11 @@
 extract_keyword (std::istream& is, const char *keyword, int& value,
 		 const bool next_only = false);
 
+extern  bool
+extract_keyword (std::istream& is, const string_vector& keywords,
+		 std::string& keyword, int& value,
+		 const bool next_only = false);
+
 extern std::string
 read_ascii_data (std::istream& is, const std::string& filename, bool& global,
 		 octave_value& tc, int count);
--- a/src/ov-bool-mat.cc	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ov-bool-mat.cc	Fri Dec 24 19:06:01 2004 +0000
@@ -187,80 +187,93 @@
 bool 
 octave_bool_matrix::load_ascii (std::istream& is)
 {
-  int mdims = 0;
   bool success = true;
-  std::streampos pos = is.tellg ();
 
-  if (extract_keyword (is, "ndims", mdims, true))
-    {
-      if (mdims >= 0)
-	{
-	  dim_vector dv;
-	  dv.resize (mdims);
+  string_vector keywords (2);
 
-	  for (int i = 0; i < mdims; i++)
-	    is >> dv(i);
-
-	  NDArray tmp(dv);
-	  is >> tmp;
+  keywords[0] = "ndims";
+  keywords[1] = "rows";
 
-	  if (!is) 
-	    {
-	      error ("load: failed to load matrix constant");
-	      success = false;
-	    }
+  std::string kw;
+  int val = 0;
 
-	  boolNDArray btmp (dv);
-	  for (int i = 0; i < btmp.nelem (); i++)
-	      btmp.elem (i) = (tmp.elem (i) != 0.);
-	  
-	  matrix = btmp;
-	}
-      else
-	{
-	  error ("load: failed to extract number of rows and columns");
-	  success = false;
-	}
-    }
-  else
+  if (extract_keyword (is, keywords, kw, val, true))
     {
-      int nr = 0;
-      int nc = 0;
-
-      // re-read the same line again
-      is.clear ();
-      is.seekg (pos);
+      if (kw == "ndims")
+	{
+	  int mdims = val;
 
-      if (extract_keyword (is, "rows", nr) && nr >= 0
-	  && extract_keyword (is, "columns", nc) && nc >= 0)
-	{
-	  if (nr > 0 && nc > 0)
+	  if (mdims >= 0)
 	    {
-	      Matrix tmp (nr, nc);
+	      dim_vector dv;
+	      dv.resize (mdims);
+
+	      for (int i = 0; i < mdims; i++)
+		is >> dv(i);
+
+	      NDArray tmp(dv);
 	      is >> tmp;
-	      if (!is) 
+
+	      if (!is)
 		{
 		  error ("load: failed to load matrix constant");
 		  success = false;
 		}
 
-	      boolMatrix btmp (nr,nc);
-	      for (int j = 0; j < nc; j++)
-		for (int i = 0; i < nr; i++)
-		  btmp.elem (i,j) = (tmp.elem (i, j) != 0.);
-	      
+	      boolNDArray btmp (dv);
+	      for (int i = 0; i < btmp.nelem (); i++)
+		btmp.elem (i) = (tmp.elem (i) != 0.);
+
 	      matrix = btmp;
 	    }
-	  else if (nr == 0 || nc == 0)
-	    matrix = boolMatrix (nr, nc);
 	  else
-	    panic_impossible ();
+	    {
+	      error ("load: failed to extract number of rows and columns");
+	      success = false;
+	    }
 	}
-      else 
+      else if (kw == "rows")
 	{
-	  error ("load: failed to extract number of rows and columns");
-	  success = false;
+	  int nr = val;
+	  int nc = 0;
+
+	  if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
+	    {
+	      if (nr > 0 && nc > 0)
+		{
+		  Matrix tmp (nr, nc);
+		  is >> tmp;
+		  if (!is) 
+		    {
+		      error ("load: failed to load matrix constant");
+		      success = false;
+		    }
+
+		  boolMatrix btmp (nr,nc);
+		  for (int j = 0; j < nc; j++)
+		    for (int i = 0; i < nr; i++)
+		      btmp.elem (i,j) = (tmp.elem (i, j) != 0.);
+
+		  matrix = btmp;
+		}
+	      else if (nr == 0 || nc == 0)
+		matrix = boolMatrix (nr, nc);
+	      else
+		panic_impossible ();
+	    }
+	  else
+	    {
+	      error ("load: failed to extract number of rows and columns");
+	      success = false;
+	    }
 	}
+      else
+	panic_impossible ();
+    }
+  else
+    {
+      error ("load: failed to extract number of rows and columns");
+      success = false;
     }
 
   return success;
--- a/src/ov-cell.cc	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ov-cell.cc	Fri Dec 24 19:06:01 2004 +0000
@@ -481,119 +481,132 @@
 bool 
 octave_cell::load_ascii (std::istream& is)
 {
-  int mdims = 0;
   bool success = true;
-  std::streampos pos = is.tellg ();
+
+  string_vector keywords(2);
 
-  if (extract_keyword (is, "ndims", mdims, true))
+  keywords[0] = "ndims";
+  keywords[1] = "rows";
+
+  std::string kw;
+  int val = 0;
+
+  if (extract_keyword (is, keywords, kw, val, true))
     {
-      if (mdims >= 0)
+      if (kw == "ndims")
 	{
-	  dim_vector dv;
-	  dv.resize (mdims);
+	  int mdims = val;
 
-	  for (int i = 0; i < mdims; i++)
-	    is >> dv(i);
+	  if (mdims >= 0)
+	    {
+	      dim_vector dv;
+	      dv.resize (mdims);
+
+	      for (int i = 0; i < mdims; i++)
+		is >> dv(i);
 
-	  Cell tmp(dv);
+	      Cell tmp(dv);
 
-	  for (int i = 0; i < dv.numel (); i++)
-	    {
-	      octave_value t2;
-	      bool dummy;
+	      for (int i = 0; i < dv.numel (); i++)
+		{
+		  octave_value t2;
+		  bool dummy;
+
+		  // recurse to read cell elements
+		  std::string nm = read_ascii_data (is, std::string (), 
+						    dummy, t2, count);
 
-	      // recurse to read cell elements
-	      std::string nm = read_ascii_data (is, std::string (), 
-						dummy, t2, count);
+		  if (nm == CELL_ELT_TAG)
+		    {
+		      if (is)
+			tmp.elem (i) = t2;
+		    }
+		  else
+		    {
+		      error ("load: cell array element had unexpected name");
+		      success = false;
+		      break;
+		    }
+		}
 
-	      if (nm == CELL_ELT_TAG)
-		{
-		  if (is)
-		    tmp.elem (i) = t2;
-		}
+	      if (is)
+		matrix = tmp;
 	      else
 		{
-		  error ("load: cell array element had unexpected name");
+		  error ("load: failed to load matrix constant");
 		  success = false;
-		  break;
 		}
 	    }
-
-	  if (is)
-	    matrix = tmp;
 	  else
 	    {
-	      error ("load: failed to load matrix constant");
+	      error ("load: failed to extract number of rows and columns");
+	      success = false;
+	    }
+	}
+      else if (kw == "rows")
+	{
+	  int nr = val;
+	  int nc = 0;
+
+	  if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
+	    {
+	      if (nr > 0 && nc > 0)
+		{
+		  Cell tmp (nr, nc);
+
+		  for (int j = 0; j < nc; j++)
+		    {
+		      for (int i = 0; i < nr; i++)
+			{
+			  octave_value t2;
+			  bool dummy;
+
+			  // recurse to read cell elements
+			  std::string nm = read_ascii_data (is, std::string (),
+							    dummy, t2, count);
+
+			  if (nm == CELL_ELT_TAG)
+			    {
+			      if (is)
+				tmp.elem (i, j) = t2;
+			    }
+			  else
+			    {
+			      error ("load: cell array element had unexpected name");
+			      success = false;
+			      goto cell_read_error;
+			    }
+			}
+		    }
+	      
+		cell_read_error:
+
+		  if (is)
+		    matrix = tmp;
+		  else
+		    {
+		      error ("load: failed to load cell element");
+		      success = false;
+		    }
+		}
+	      else if (nr == 0 || nc == 0)
+		matrix = Cell (nr, nc);
+	      else
+		panic_impossible ();
+	    }
+	  else
+	    {
+	      error ("load: failed to extract number of rows and columns for cell array");
 	      success = false;
 	    }
 	}
       else
-	{
-	  error ("load: failed to extract number of rows and columns");
-	  success = false;
-	}
-      
+	panic_impossible ();
     }
   else
     {
-      int nr = 0;
-      int nc = 0;
-
-      // re-read the same line again
-      is.clear ();
-      is.seekg (pos);
-
-      if (extract_keyword (is, "rows", nr) && nr >= 0
-	  && extract_keyword (is, "columns", nc) && nc >= 0)
-	{
-	  if (nr > 0 && nc > 0)
-	    {
-	      Cell tmp (nr, nc);
-
-	      for (int j = 0; j < nc; j++)
-		{
-		  for (int i = 0; i < nr; i++)
-		    {
-		      octave_value t2;
-		      bool dummy;
-
-		      // recurse to read cell elements
-		      std::string nm = read_ascii_data (is, std::string (), 
-							dummy, t2, count);
-
-		      if (nm == CELL_ELT_TAG)
-			{
-			  if (is)
-			    tmp.elem (i, j) = t2;
-			}
-		      else
-			{
-			  error ("load: cell array element had unexpected name");
-			  success = false;
-			  goto cell_read_error;
-			}
-		    }
-		}
-	      
-	    cell_read_error:
-
-	      if (is) 
-		matrix = tmp;
-	      else
-		{
-		  error ("load: failed to load cell element");
-		  success = false;
-		}
-	    }
-	  else if (nr == 0 || nc == 0)
-	    matrix = Cell (nr, nc);
-	  else
-	    panic_impossible ();
-	}
-      else {
-	error ("load: failed to extract number of rows and columns for cell array");
-	success = false;
-      }
+      error ("load: failed to extract number of rows and columns");
+      success = false;
     }
 
   return success;
--- a/src/ov-cx-mat.cc	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ov-cx-mat.cc	Fri Dec 24 19:06:01 2004 +0000
@@ -276,52 +276,33 @@
 bool 
 octave_complex_matrix::load_ascii (std::istream& is)
 {
-  int mdims = 0;
   bool success = true;
-  std::streampos pos = is.tellg ();
+
+  string_vector keywords(2);
+
+  keywords[0] = "ndims";
+  keywords[1] = "rows";
 
-  if (extract_keyword (is, "ndims", mdims, true))
+  std::string kw;
+  int val = 0;
+
+  if (extract_keyword (is, keywords, kw, val, true))
     {
-      if (mdims >= 0)
+      if (kw == "ndims")
 	{
-	  dim_vector dv;
-	  dv.resize (mdims);
+	  int mdims = val;
 
-	  for (int i = 0; i < mdims; i++)
-	    is >> dv(i);
-
-	  ComplexNDArray tmp(dv);
-	  is >> tmp;
-
-	  if (!is) 
+	  if (mdims >= 0)
 	    {
-	      error ("load: failed to load matrix constant");
-	      success = false;
-	    }
-	  matrix = tmp;
-	}
-      else
-	{
-	  error ("load: failed to extract number of rows and columns");
-	  success = false;
-	}
-    }
-  else
-    {
-      int nr = 0;
-      int nc = 0;
+	      dim_vector dv;
+	      dv.resize (mdims);
 
-      // re-read the same line again
-      is.clear ();
-      is.seekg (pos);
+	      for (int i = 0; i < mdims; i++)
+		is >> dv(i);
 
-      if (extract_keyword (is, "rows", nr) && nr >= 0
-	  && extract_keyword (is, "columns", nc) && nc >= 0)
-	{
-	  if (nr > 0 && nc > 0)
-	    {
-	      ComplexMatrix tmp (nr, nc);
+	      ComplexNDArray tmp(dv);
 	      is >> tmp;
+
 	      if (!is) 
 		{
 		  error ("load: failed to load matrix constant");
@@ -329,16 +310,48 @@
 		}
 	      matrix = tmp;
 	    }
-	  else if (nr == 0 || nc == 0)
-	    matrix = ComplexMatrix (nr, nc);
 	  else
-	    panic_impossible ();
+	    {
+	      error ("load: failed to extract number of rows and columns");
+	      success = false;
+	    }
 	}
-      else 
+      else if (kw == "rows")
 	{
-	  error ("load: failed to extract number of rows and columns");
-	  success = false;
+	  int nr = val;
+	  int nc = 0;
+
+	  if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
+	    {
+	      if (nr > 0 && nc > 0)
+		{
+		  ComplexMatrix tmp (nr, nc);
+		  is >> tmp;
+		  if (!is)
+		    {
+		      error ("load: failed to load matrix constant");
+		      success = false;
+		    }
+		  matrix = tmp;
+		}
+	      else if (nr == 0 || nc == 0)
+		matrix = ComplexMatrix (nr, nc);
+	      else
+		panic_impossible ();
+	    }
+	  else
+	    {
+	      error ("load: failed to extract number of rows and columns");
+	      success = false;
+	    }
 	}
+      else
+	panic_impossible ();
+    }
+  else
+    {
+      error ("load: failed to extract number of rows and columns");
+      success = false;
     }
 
   return success;
--- a/src/ov-re-mat.cc	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ov-re-mat.cc	Fri Dec 24 19:06:01 2004 +0000
@@ -329,70 +329,83 @@
 bool 
 octave_matrix::load_ascii (std::istream& is)
 {
-  int mdims = 0;
   bool success = true;
-  std::streampos pos = is.tellg ();
+
+  string_vector keywords(2);
+
+  keywords[0] = "ndims";
+  keywords[1] = "rows";
 
-  if (extract_keyword (is, "ndims", mdims, true))
+  std::string kw;
+  int val = 0;
+
+  if (extract_keyword (is, keywords, kw, val, true))
     {
-      if (mdims >= 0)
+      if (kw == "ndims")
 	{
-	  dim_vector dv;
-	  dv.resize (mdims);
+	  int mdims = val;
 
-	  for (int i = 0; i < mdims; i++)
-	    is >> dv(i);
-
-	  NDArray tmp(dv);
-	  is >> tmp;
-
-	  if (!is) 
+	  if (mdims >= 0)
 	    {
-	      error ("load: failed to load matrix constant");
-	      success = false;
-	    }
-	  matrix = tmp;
-	}
-      else
-	{
-	  error ("load: failed to extract number of rows and columns");
-	  success = false;
-	}
-    }
-  else
-    {
-      int nr = 0;
-      int nc = 0;
+	      dim_vector dv;
+	      dv.resize (mdims);
 
-      // re-read the same line again
-      is.clear ();
-      is.seekg (pos);
+	      for (int i = 0; i < mdims; i++)
+		is >> dv(i);
 
-      if (extract_keyword (is, "rows", nr) && nr >= 0
-	  && extract_keyword (is, "columns", nc) && nc >= 0)
-	{
-	  if (nr > 0 && nc > 0)
-	    {
-	      Matrix tmp (nr, nc);
+	      NDArray tmp(dv);
 	      is >> tmp;
-	      if (is)
-		matrix = tmp;
-	      else
+
+	      if (!is) 
 		{
 		  error ("load: failed to load matrix constant");
 		  success = false;
 		}
+	      matrix = tmp;
 	    }
-	  else if (nr == 0 || nc == 0)
-	    matrix = Matrix (nr, nc);
 	  else
-	    panic_impossible ();
+	    {
+	      error ("load: failed to extract number of rows and columns");
+	      success = false;
+	    }
 	}
-      else 
+      else if (kw == "rows")
 	{
-	  error ("load: failed to extract number of rows and columns");
-	  success = false;
+	  int nr = val;
+	  int nc = 0;
+
+	  if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
+	    {
+	      if (nr > 0 && nc > 0)
+		{
+		  Matrix tmp (nr, nc);
+		  is >> tmp;
+		  if (is)
+		    matrix = tmp;
+		  else
+		    {
+		      error ("load: failed to load matrix constant");
+		      success = false;
+		    }
+		}
+	      else if (nr == 0 || nc == 0)
+		matrix = Matrix (nr, nc);
+	      else
+		panic_impossible ();
+	    }
+	  else 
+	    {
+	      error ("load: failed to extract number of rows and columns");
+	      success = false;
+	    }
 	}
+      else
+	panic_impossible ();
+    }
+  else
+    {
+      error ("load: failed to extract number of rows and columns");
+      success = false;
     }
 
   return success;
--- a/src/ov-str-mat.cc	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/ov-str-mat.cc	Fri Dec 24 19:06:01 2004 +0000
@@ -294,51 +294,55 @@
 bool 
 octave_char_matrix_str::load_ascii (std::istream& is)
 {
-  int mdims = 0;
   bool success = true;
-  std::streampos pos = is.tellg ();
+
+  string_vector keywords(3);
+
+  keywords[0] = "ndims";
+  keywords[1] = "elements";
+  keywords[2] = "length";
+
+  std::string kw;
+  int val = 0;
 
-  if (extract_keyword (is, "ndims", mdims, true))
+  if (extract_keyword (is, keywords, kw, val, true))
     {
-      if (mdims >= 0)
+      if (kw == "ndims")
 	{
-	  dim_vector dv;
-	  dv.resize (mdims);
+	  int mdims = val;
+
+	  if (mdims >= 0)
+	    {
+	      dim_vector dv;
+	      dv.resize (mdims);
 
-	  for (int i = 0; i < mdims; i++)
-	    is >> dv(i);
+	      for (int i = 0; i < mdims; i++)
+		is >> dv(i);
 
-	  charNDArray tmp(dv);
-	  char *ftmp = tmp.fortran_vec ();
+	      charNDArray tmp(dv);
+	      char *ftmp = tmp.fortran_vec ();
+
+	      // Skip the return line
+	      if (! is.read (ftmp, 1))
+		return false;
 
-	  // Skip the return line
-	  if (! is.read (ftmp, 1))
-	    return false;
-
-	  if (! is.read (ftmp, dv.numel ()) || !is)
+	      if (! is.read (ftmp, dv.numel ()) || !is)
+		{
+		  error ("load: failed to load string constant");
+		  success = false;
+		}
+	      else
+		matrix = tmp;
+	    }
+	  else
 	    {
-	      error ("load: failed to load string constant");
+	      error ("load: failed to extract matrix size");
 	      success = false;
 	    }
-	  else
-	    matrix = tmp;
 	}
-      else
+      else if (kw == "elements")
 	{
-	  error ("load: failed to extract matrix size");
-	  success = false;
-	}
-    }
-  else
-    {
-      int elements;
-
-      // re-read the same line again
-      is.clear ();
-      is.seekg (pos);
-
-      if (extract_keyword (is, "elements", elements, true))
-	{
+	  int elements = val;
 
 	  if (elements >= 0)
 	    {
@@ -382,7 +386,6 @@
 	  
 	      if (! error_state)
 		matrix = chm;
-	  
 	    }
 	  else
 	    {
@@ -390,15 +393,11 @@
 	      success = false;
 	    }
 	}
-      else
+      else if (kw == "length")
 	{
-	  // re-read the same line again
-	  is.clear ();
-	  is.seekg (pos);
-
-	  int len;
+	  int len = val;
       
-	  if (extract_keyword (is, "length", len) && len >= 0)
+	  if (len >= 0)
 	    {
 	      // This is cruft for backward compatiability, 
 	      // but relatively harmless.
@@ -420,6 +419,13 @@
 		}
 	    }
 	}
+      else
+	panic_impossible ();
+    }
+  else
+    {
+      error ("load: failed to extract number of rows and columns");
+      success = false;
     }
 
   return success;
--- a/src/pt-idx.cc	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/pt-idx.cc	Fri Dec 24 19:06:01 2004 +0000
@@ -110,6 +110,22 @@
     }
 }
 
+bool
+tree_index_expression::has_magic_end (void) const
+{
+  for (std::list<tree_argument_list *>::const_iterator p = args.begin ();
+       p != args.end ();
+       p++)
+    {
+      tree_argument_list *elt = *p;
+
+      if (elt && elt->has_magic_end ())
+	return true;
+    }
+  
+  return false;
+}
+
 // This is useful for printing the name of the variable in an indexed
 // assignment.
 
--- a/src/pt-idx.h	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/pt-idx.h	Fri Dec 24 19:06:01 2004 +0000
@@ -60,7 +60,7 @@
 
   ~tree_index_expression (void);
 
-  bool has_magic_end (void) const { return false; }
+  bool has_magic_end (void) const;
 
   void append (tree_argument_list *lst = 0, char t = '(');
 
--- a/src/version.h	Sat Dec 18 15:04:20 2004 +0000
+++ b/src/version.h	Fri Dec 24 19:06:01 2004 +0000
@@ -23,7 +23,7 @@
 #if !defined (octave_version_h)
 #define octave_version_h 1
 
-#define OCTAVE_VERSION "2.1.63"
+#define OCTAVE_VERSION "2.1.64"
 
 #define OCTAVE_API_VERSION "api-v12"