Explorar el Código

use the GroupedFromCommandLine() method in the dotty and xvcg command
to get all the funky features in less lines

David Kalnischkies hace 16 años
padre
commit
3c97724569
Se han modificado 1 ficheros con 28 adiciones y 56 borrados
  1. 28 56
      cmdline/apt-cache.cc

+ 28 - 56
cmdline/apt-cache.cc

@@ -787,38 +787,24 @@ bool XVcg(CommandLine &CmdL)
 	    ShapeMap[Pkg->ID] = 3;
 	    ShapeMap[Pkg->ID] = 3;
       }
       }
    }
    }
-   
+
    // Load the list of packages from the command line into the show list
    // Load the list of packages from the command line into the show list
-   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   std::list<APT::PackageSet::Modifier> mods;
+   mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
+   mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
+   std::map<unsigned short, APT::PackageSet> pkgsets =
+		APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0);
+
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
+	Pkg != pkgsets[0].end(); ++Pkg)
+      Show[Pkg->ID] = ToShow;
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[1].begin();
+	Pkg != pkgsets[1].end(); ++Pkg)
    {
    {
-      // Process per-package flags
-      string P = *I;
-      bool Force = false;
-      if (P.length() > 3)
-      {
-	 if (P.end()[-1] == '^')
-	 {
-	    Force = true;
-	    P.erase(P.end()-1);
-	 }
-	 
-	 if (P.end()[-1] == ',')
-	    P.erase(P.end()-1);
-      }
-      
-      // Locate the package
-      pkgCache::PkgIterator Pkg = Cache->FindPkg(P);
-      if (Pkg.end() == true)
-      {
-	 _error->Warning(_("Unable to locate package %s"),*I);
-	 continue;
-      }
       Show[Pkg->ID] = ToShow;
       Show[Pkg->ID] = ToShow;
-      
-      if (Force == true)
-	 Flags[Pkg->ID] |= ForceNR;
+      Flags[Pkg->ID] |= ForceNR;
    }
    }
-   
+
    // Little header
    // Little header
    cout << "graph: { title: \"packages\"" << endl <<
    cout << "graph: { title: \"packages\"" << endl <<
      "xmax: 700 ymax: 700 x: 30 y: 30" << endl <<
      "xmax: 700 ymax: 700 x: 30 y: 30" << endl <<
@@ -1015,38 +1001,24 @@ bool Dotty(CommandLine &CmdL)
 	    ShapeMap[Pkg->ID] = 3;
 	    ShapeMap[Pkg->ID] = 3;
       }
       }
    }
    }
-   
+
    // Load the list of packages from the command line into the show list
    // Load the list of packages from the command line into the show list
-   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   std::list<APT::PackageSet::Modifier> mods;
+   mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
+   mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
+   std::map<unsigned short, APT::PackageSet> pkgsets =
+		APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0);
+
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
+	Pkg != pkgsets[0].end(); ++Pkg)
+      Show[Pkg->ID] = ToShow;
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[1].begin();
+	Pkg != pkgsets[1].end(); ++Pkg)
    {
    {
-      // Process per-package flags
-      string P = *I;
-      bool Force = false;
-      if (P.length() > 3)
-      {
-	 if (P.end()[-1] == '^')
-	 {
-	    Force = true;
-	    P.erase(P.end()-1);
-	 }
-	 
-	 if (P.end()[-1] == ',')
-	    P.erase(P.end()-1);
-      }
-      
-      // Locate the package
-      pkgCache::PkgIterator Pkg = Cache->FindPkg(P);
-      if (Pkg.end() == true)
-      {
-	 _error->Warning(_("Unable to locate package %s"),*I);
-	 continue;
-      }
       Show[Pkg->ID] = ToShow;
       Show[Pkg->ID] = ToShow;
-      
-      if (Force == true)
-	 Flags[Pkg->ID] |= ForceNR;
+      Flags[Pkg->ID] |= ForceNR;
    }
    }
-   
+
    // Little header
    // Little header
    printf("digraph packages {\n");
    printf("digraph packages {\n");
    printf("concentrate=true;\n");
    printf("concentrate=true;\n");