changeset 7531:c9a476b1e664

correctly set ans for cs-lists and simplify printing them
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2008 02:16:32 -0500
parents bb0f2353cff5
children 493bb0de3199
files src/ChangeLog src/ov-cs-list.cc src/ov-cs-list.h src/variables.cc
diffstat 4 files changed, 21 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Feb 25 19:01:30 2008 -0500
+++ b/src/ChangeLog	Tue Feb 26 02:16:32 2008 -0500
@@ -1,3 +1,10 @@
+2008-02-26  John W. Eaton  <jwe@octave.org>
+
+	* variables.cc (bind_ans): Handle cs-lists recursively.
+
+	* ov-cs-list.h, ov-cs-list.cc (octave_cs_list::print,
+	octave_cs_list::print_raw): Delete.
+
 2008-02-25  John W. Eaton  <jwe@octave.org>
 
 	* Cell.cc (Cell::map): New function.
--- a/src/ov-cs-list.cc	Mon Feb 25 19:01:30 2008 -0500
+++ b/src/ov-cs-list.cc	Tue Feb 26 02:16:32 2008 -0500
@@ -49,50 +49,6 @@
     lst(i) = c(i);
 }
 
-void
-octave_cs_list::print (std::ostream& os, bool) const
-{
-  print_raw (os);
-}
-
-void
-octave_cs_list::print_raw (std::ostream& os, bool) const
-{
-  unwind_protect::begin_frame ("octave_cs_list_print");
-
-  octave_idx_type n = lst.length ();
-
-  if (n > 0)
-    {
-      indent (os);
-      os << "(,";
-      newline (os);
-
-      increment_indent_level ();
-
-      for (octave_idx_type i = 0; i < n; i++)
-	{
-	  std::ostringstream buf;
-	  buf << "[" << i+1 << "]";
-
-	  octave_value val = lst(i);
-
-	  val.print_with_name (os, buf.str ());
-	}
-
-      decrement_indent_level ();
-
-      indent (os);
-      os << ",)";
-    }
-  else
-    os << "(,,)";
-
-  newline (os);
-
-  unwind_protect::run_frame ("octave_cs_list_print");
-}
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/ov-cs-list.h	Mon Feb 25 19:01:30 2008 -0500
+++ b/src/ov-cs-list.h	Tue Feb 26 02:16:32 2008 -0500
@@ -73,10 +73,6 @@
 
   octave_value_list list_value (void) const { return lst; }
 
-  void print (std::ostream& os, bool) const;
-
-  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
-
 private:
 
   // The list of Octave values.
--- a/src/variables.cc	Mon Feb 25 19:01:30 2008 -0500
+++ b/src/variables.cc	Tue Feb 26 02:16:32 2008 -0500
@@ -1886,10 +1886,20 @@
 
   if (val.is_defined ())
     {
-      symbol_table::varref (ans) = val;
-
-      if (print)
-	val.print_with_name (octave_stdout, ans);
+      if (val.is_cs_list ())
+	{
+	  octave_value_list lst = val.list_value ();
+
+	  for (octave_idx_type i = 0; i < lst.length (); i++)
+	    bind_ans (lst(i), print);
+	}
+      else
+	{
+	  symbol_table::varref (ans) = val;
+
+	  if (print)
+	    val.print_with_name (octave_stdout, ans);
+	}
     }
 }