Index: CMT/HEAD/ChangeLog
===================================================================
--- CMT/HEAD/ChangeLog	(revision 572)
+++ CMT/HEAD/ChangeLog	(revision 574)
@@ -1,2 +1,9 @@
+2011-05-02    <rybkin@lal.in2p3.fr> 456
+
+	* source/cmt_use.cxx: In class Use, in function	show_sub_uses, make output
+	of "cmt show uses" command compatible with original as it is used by tools,
+	tbroadcast, for example, in function set_auto_imports, increase/decrease
+	level before/after considering sub-uses
+	
 2011-04-29    <rybkin@lal.in2p3.fr> 455
 
Index: CMT/HEAD/source/cmt_use.cxx
===================================================================
--- CMT/HEAD/source/cmt_use.cxx	(revision 572)
+++ CMT/HEAD/source/cmt_use.cxx	(revision 574)
@@ -3961,6 +3961,5 @@
 			    cmt_map <Use*, bool>& visited)
 {
-  static int level (-1);
-  level++;
+  static int level (0);
   /*
   if (level == 0)
@@ -3988,5 +3987,4 @@
       else
 	{
-	  level--;
 	  return;
 	}
@@ -3995,5 +3993,4 @@
       if (visited.has (this))
 	{
-	  level--;
 	  return;
 	}
@@ -4026,4 +4023,5 @@
     }
   
+  level++;
   for (int i = 0; i < sub_uses.size (); i++)
   //for (int i = sub_uses.size () - 1; i >= 0; i--)
@@ -4079,4 +4077,5 @@
 	}
     }
+  level--;
 
   if (Cmt::get_debug ())
@@ -4085,5 +4084,4 @@
     }
 
-  level--;
   return;
 }
@@ -4495,49 +4493,10 @@
   Use* current = &(Use::current ());
   static State context_state (auto_imports);
-  static int level (-1);
-  level++;
+  static int level (0);
 
   if (level == 0)
     {
       unselect_all ();
-      selected = true;
-    }
-
-  State saved_context_state (context_state);
-  switch (context_state)
-    {
-    case Unspecified:
-    case On:
-      if (!visited.has (this)
-	  || level == 1)
-	// show all direct sub-uses of current use
-	{
-	  context_state = UseContext::mask_auto_imports (context_state, specified_state);
-	}
-      else if (Off != auto_imports && Off != specified_state
-	       //      else if (specified_state == auto_imports && Off != specified_state
-	       && !selected)
-	// show this sub-use as it may have been used to make Off != auto_imports
-	// and is sufficient in order to consider it Off != auto_imports,
-	// mark selected not to consider use again and thus avoid looping this way
-	{
-	  selected = true;
-	  //	  auto_imports = specified_state;
-	  context_state = UseContext::mask_auto_imports (context_state, specified_state);
-	}
-      else
-	{
-	  level--;
-	  return;
-	}
-      break;
-    case Off:
-      if (visited.has (this)
-	  )
-	{
-	  level--;
-	  return;
-	}
-      break;
+      selected = false;
     }
 
@@ -4594,7 +4553,84 @@
     }
 
+  //  if (selected) return;
+  //  selected = true;
+
+  State saved_context_state (context_state);
+
+  switch (context_state)
+    {
+    case Unspecified:
+    case On:
+      if (!visited.has (this) ||
+	  !selected)
+	// selected == true means that
+	// this use has been shown with its actual auto_imports
+	// either Off != auto_imports or Off == auto_imports,
+	// mark selected not to consider use again and thus avoid looping this way
+	{
+	  switch (specified_state)
+	    {
+	    case Unspecified:
+	    case On:
+	      if (Off != auto_imports)
+		{
+		  // this path to use is informative
+		  // want to revisit sub-uses
+		  // to possibly find Off != auto_imports paths to them
+		  selected = true;
+		}
+	      break;
+	    case Off:
+	      if (Off == auto_imports)
+		{
+		  // this path to use is informative
+		  // no point in revisiting sub-uses
+		  selected = true;
+		  if (visited.has (this)) return;
+		}
+	      else
+		{
+		  // this path to use is not informative
+		  // no point in (re)visiting sub-uses
+		  return;
+		}
+	      break;
+	    }
+	  context_state = UseContext::mask_auto_imports (context_state, specified_state);
+	}
+      else
+	{
+	  return;
+	}
+      break;
+    case Off:
+      if (!visited.has (this) ||
+	  !selected)
+	{
+	  if (Off == auto_imports)
+	    {
+	      // this path to use is informative
+	      // no point in revisiting sub-uses
+	      selected = true;
+	      if (visited.has (this)) return;
+	    }
+	  else
+	    {
+	      // this path to use is not informative
+	      // no point in (re)visiting sub-uses
+	      return;
+	    }
+	}
+      else
+	{
+	  return;
+	}
+      break;
+    }
+
   static bool yes (true);
   visited.add (this, yes);
 
+  level++;
   for (int i = 0; i < sub_uses.size (); i++)
     {
@@ -4614,4 +4650,5 @@
 	  else
 	    {
+	      sub_uses[i]->select ();
 	      visited.add (sub_uses[i], yes);
 	      continue;
