[Aptitude-devel] r3232 - branches/aptitude-0.3/aptitude/src/generic/problemresolver

Daniel Burrows dburrows@costa.debian.org
Sun, 01 May 2005 15:39:52 +0000


Author: dburrows
Date: Sun May  1 15:39:52 2005
New Revision: 3232

Modified:
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/test.cc
Log:
Remove some no longer necessary constructs, major reindentation.

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/test.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/test.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/test.cc	Sun May  1 15:39:52 2005
@@ -1108,179 +1108,172 @@
 
   f >> ws;
 
-  try
+  while(f)
     {
-      while(f)
-	{
-	  string s;
+      string s;
+
+      if(f.eof())
+	// This is the only place where EOF is valid.
+	return;
 
+      f >> s >> ws;
+
+      if(s == "UNIVERSE")
+	{
 	  if(f.eof())
-	    // This is the only place where EOF is valid.
-	    return;
+	    throw ParseError("Expected '[' following UNIVERSE, got EOF.");
 
 	  f >> s >> ws;
 
-	  if(s == "UNIVERSE")
-	    {
-	      if(f.eof())
-		throw ParseError("Expected '[' following UNIVERSE, got EOF.");
+	  if(s != "[")
+	    throw ParseError("Expected '[' following UNIVERSE, got " + s);
 
-	      f >> s >> ws;
+	  universe=parse_universe(f);
 
-	      if(s != "[")
-		throw ParseError("Expected '[' following UNIVERSE, got " + s);
+	  cout << "Input universe:" << endl;
+	  dump_universe(universe, cout);
+	}
+      else if(s == "TEST")
+	{
+	  if(!universe)
+	    throw ParseError("Expected UNIVERSE before TEST");
 
-	      universe=parse_universe(f);
+	  if(f.eof())
+	    throw ParseError("Expected step_score and broken_score following 'TEST', got EOF");
 
-	      cout << "Input universe:" << endl;
-	      dump_universe(universe, cout);
-	    }
-	  else if(s == "TEST")
-	    {
-	      if(!universe)
-		throw ParseError("Expected UNIVERSE before TEST");
+	  int step_score;
+	  int broken_score;
+	  int infinity;
+	  int max_successors;
+	  int goal_score;
 
-	      if(f.eof())
-		throw ParseError("Expected step_score and broken_score following 'TEST', got EOF");
+	  f >> step_score >> broken_score >> infinity >> max_successors >> goal_score;
 
-	      int step_score;
-	      int broken_score;
-	      int infinity;
-	      int max_successors;
-	      int goal_score;
+	  if(f.eof())
+	    throw ParseError("Expected '{' following broken_score, got EOF");
 
-	      f >> step_score >> broken_score >> infinity >> max_successors >> goal_score;
+	  if(!f)
+	    throw ParseError("Error reading step_score, broken_score, infinity, max_succ, and goal_score after 'TEST'");
 
-	      if(f.eof())
-		throw ParseError("Expected '{' following broken_score, got EOF");
+	  f >> s >> ws;
 
-	      if(!f)
-		throw ParseError("Error reading step_score, broken_score, infinity, max_succ, and goal_score after 'TEST'");
+	  if(s != "{")
+	    throw ParseError("Expected '{' following TEST, got "+s);
 
-	      f >> s >> ws;
+	  dummy_resolver resolver(step_score, broken_score,
+				  infinity, max_successors,
+				  goal_score, universe);
 
-	      if(s != "{")
-		throw ParseError("Expected '{' following TEST, got "+s);
+	  read_scores(f, universe, resolver);
 
-	      dummy_resolver resolver(step_score, broken_score,
-				      infinity, max_successors,
-				      goal_score, universe);
+	  if(f.eof())
+	    throw ParseError("Expected 'EXPECT', got EOF");
 
-	      read_scores(f, universe, resolver);
+	  f >> s >> ws;
 
-	      if(f.eof())
-		throw ParseError("Expected 'EXPECT', got EOF");
+	  if(s != "EXPECT")
+	    throw ParseError("Expected 'EXPECT', got "+s);
 
-	      f >> s >> ws;
+	  if(f.eof())
+	    throw ParseError("Expected '(' following EXPECT, got EOF");
+
+	  f >> s >> ws;
 
-	      if(s != "EXPECT")
-		throw ParseError("Expected 'EXPECT', got "+s);
+	  if(s != "(")
+	    throw ParseError("Expected '(' following EXPECT, got "+s);
 
+	  while(f)
+	    {
 	      if(f.eof())
-		throw ParseError("Expected '(' following EXPECT, got EOF");
+		throw ParseError("Expected ')' or package name, got EOF");
 
 	      f >> s >> ws;
 
-	      if(s != "(")
-		throw ParseError("Expected '(' following EXPECT, got "+s);
-
-	      while(f)
-		{
-		  if(f.eof())
-		    throw ParseError("Expected ')' or package name, got EOF");
-
-		  f >> s >> ws;
-
-		  if(s == ")")
-		    break;
+	      if(s == ")")
+		break;
 
-		  int step_count=atoi(s.c_str());
+	      int step_count=atoi(s.c_str());
 
-		  if(step_count<=0)
-		    throw ParseError("step_count must be a positive integer, not "+s);
+	      if(step_count<=0)
+		throw ParseError("step_count must be a positive integer, not "+s);
 
-		  f >> s >> ws;
+	      f >> s >> ws;
 
-		  if(s == "ANY")
+	      if(s == "ANY")
+		{
+		  try
 		    {
-		      try
-			{
-			  dummy_resolver::solution next_soln=resolver.find_next_solution(step_count);
+		      dummy_resolver::solution next_soln=resolver.find_next_solution(step_count);
 
-			  cout << "Next solution is ";
-			  next_soln.dump(cout);
+		      cout << "Next solution is ";
+		      next_soln.dump(cout);
 
-			  cout << " (ignored)" << endl;
-			}
-		      catch(NoMoreTime)
-			{
-			  cout << "Ran out of steps (ignored)" << endl;
-			}
-		      catch(NoMoreSolutions)
-			{
-			  cout << "Ran out of solutions (ignored)" << endl;
-			}
+		      cout << " (ignored)" << endl;
 		    }
-		  else if(s == "<")
+		  catch(NoMoreTime)
 		    {
-		      try
-			{
-			  map<dummy_universe::package, dummy_resolver::version> expected=read_solution(f, universe);
+		      cout << "Ran out of steps (ignored)" << endl;
+		    }
+		  catch(NoMoreSolutions)
+		    {
+		      cout << "Ran out of solutions (ignored)" << endl;
+		    }
+		}
+	      else if(s == "<")
+		{
+		  try
+		    {
+		      map<dummy_universe::package, dummy_resolver::version> expected=read_solution(f, universe);
 
-			  dummy_resolver::solution next_soln=resolver.find_next_solution(step_count);
+		      dummy_resolver::solution next_soln=resolver.find_next_solution(step_count);
 
 
-			  cout << "Next solution is ";
-			  next_soln.dump(cout);
+		      cout << "Next solution is ";
+		      next_soln.dump(cout);
 
-			  bool equal=true;
-
-			  map<dummy_universe::package, dummy_universe::version>::const_iterator expect_iter=expected.begin();
-			  map<dummy_universe::package, dummy_resolver::action>::const_iterator soln_iter=next_soln.get_actions().begin();
-
-			  while(equal &&
-				expect_iter != expected.end() &&
-				soln_iter != next_soln.get_actions().end())
-			    {
-			      if(expect_iter->first != soln_iter->first ||
-				 expect_iter->second != soln_iter->second.ver)
-				equal=false;
-			    }
-
-			  if(equal)
-			    cout << " (OK)" << endl;
-			  else
-			    {
-			      cout << " (FAILED)" << endl;
-			      cout << "Expected <";
-			      for(map<dummy_universe::package, dummy_universe::version>::const_iterator i=expected.begin();
-				  i!=expected.end(); ++i)
-				cout << i->first.get_name()
-				     << ":="
-				     << i->second.get_name();
-			      cout << ">" << endl;
-			    }
-			}
-		      catch(NoMoreSolutions)
+		      bool equal=true;
+
+		      map<dummy_universe::package, dummy_universe::version>::const_iterator expect_iter=expected.begin();
+		      map<dummy_universe::package, dummy_resolver::action>::const_iterator soln_iter=next_soln.get_actions().begin();
+
+		      while(equal &&
+			    expect_iter != expected.end() &&
+			    soln_iter != next_soln.get_actions().end())
 			{
-			  cout << "Ran out of solutions (FAILED)" << endl;
+			  if(expect_iter->first != soln_iter->first ||
+			     expect_iter->second != soln_iter->second.ver)
+			    equal=false;
 			}
-		      catch(NoMoreTime)
+
+		      if(equal)
+			cout << " (OK)" << endl;
+		      else
 			{
-			  cout << "Ran out of time (FAILED)" << endl;
+			  cout << " (FAILED)" << endl;
+			  cout << "Expected <";
+			  for(map<dummy_universe::package, dummy_universe::version>::const_iterator i=expected.begin();
+			      i!=expected.end(); ++i)
+			    cout << i->first.get_name()
+				 << ":="
+				 << i->second.get_name();
+			  cout << ">" << endl;
 			}
 		    }
-		  else
-		    throw ParseError("Expected ANY or '<', got "+s);
+		  catch(NoMoreSolutions)
+		    {
+		      cout << "Ran out of solutions (FAILED)" << endl;
+		    }
+		  catch(NoMoreTime)
+		    {
+		      cout << "Ran out of time (FAILED)" << endl;
+		    }
 		}
+	      else
+		throw ParseError("Expected ANY or '<', got "+s);
 	    }
-	  else
-	    throw ParseError("Expected UNIVERSE or TEST, got "+s);
 	}
-    }
-  catch(...)
-    {
-      throw;
+      else
+	throw ParseError("Expected UNIVERSE or TEST, got "+s);
     }
 }