# HG changeset patch # User John W. Eaton # Date 1204010192 18000 # Node ID c9a476b1e6646ddec0e6efb310437d945f6e593b # Parent bb0f2353cff56ce32d23919fc684174158826009 correctly set ans for cs-lists and simplify printing them diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2008-02-26 John W. Eaton + + * 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 * Cell.cc (Cell::map): New function. diff --git a/src/ov-cs-list.cc b/src/ov-cs-list.cc --- a/src/ov-cs-list.cc +++ b/src/ov-cs-list.cc @@ -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++ *** diff --git a/src/ov-cs-list.h b/src/ov-cs-list.h --- a/src/ov-cs-list.h +++ b/src/ov-cs-list.h @@ -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. diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -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); + } } }