changeset 3961:635209a37bf4

[project @ 2002-06-03 18:15:47 by jwe]
author jwe
date Mon, 03 Jun 2002 18:15:47 +0000
parents b2133db551dd
children e39b0ee1da6c
files src/ov-struct.cc src/ov.cc
diffstat 2 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/ov-struct.cc
+++ b/src/ov-struct.cc
@@ -379,8 +379,12 @@
 
   unwind_protect_int (Vstruct_levels_to_print);
 
-  if (Vstruct_levels_to_print-- > 0)
+  if (Vstruct_levels_to_print >= 0)
     {
+      bool print_keys_only = (Vstruct_levels_to_print == 0);
+
+      Vstruct_levels_to_print--;
+
       indent (os);
       os << "{";
       newline (os);
@@ -394,13 +398,16 @@
 	  std::string key = map.key (p);
 	  octave_value_list val = map.contents (p);
 
-	  if (n == 1)
-	    val(0).print_with_name (os, key);
-	  else
+	  octave_value tmp = (n == 1) ? val(0) : octave_list (val);
+
+	  if (print_keys_only)
 	    {
-	      octave_list tmp (val);
-	      tmp.print_with_name (os, key);
+	      indent (os);
+	      os << key << ": " << tmp.type_name ();
+	      newline (os);
 	    }
+	  else
+	    val(0).print_with_name (os, key);
 	}
 
       decrement_indent_level ();
@@ -411,7 +418,8 @@
     }
   else
     {
-      os << " <structure>";
+      indent (os);
+      os << "<structure>";
       newline (os);
     }
 
@@ -421,10 +429,20 @@
 bool
 octave_struct::print_name_tag (std::ostream& os, const std::string& name) const
 {
+  bool retval = false;
+
   indent (os);
-  os << name << " =";
-  newline (os);
-  return false;
+
+  if (Vstruct_levels_to_print < 0)
+    os << name << " = ";
+  else
+    {
+      os << name << " =";
+      newline (os);
+      retval = true;
+    }
+
+  return retval;
 }
 
 /*
--- a/src/ov.cc
+++ b/src/ov.cc
@@ -1608,7 +1608,7 @@
       && ! xisnan (val))
     {
       int ival = NINT (val);
-      if (ival >= 0 && ival == val)
+      if (ival == val)
 	{
 	  Vstruct_levels_to_print = ival;
 	  return 0;