summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-06-06 21:49:28 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-06-06 21:49:28 +0200
commit3c9772456931842dee211444086c15dd2e5f9a29 (patch)
treeec89e57d200b65c4bc99553a3b9bec2dbf2a4ceb /cmdline
parent9cc83a6fbc089ccf9cb8d52ee9f380cf5df62d5c (diff)
use the GroupedFromCommandLine() method in the dotty and xvcg command
to get all the funky features in less lines
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc84
1 files changed, 28 insertions, 56 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index de4288c5a..7cb95b3f8 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -787,38 +787,24 @@ bool XVcg(CommandLine &CmdL)
ShapeMap[Pkg->ID] = 3;
}
}
-
+
// 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;
-
- if (Force == true)
- Flags[Pkg->ID] |= ForceNR;
+ Flags[Pkg->ID] |= ForceNR;
}
-
+
// Little header
cout << "graph: { title: \"packages\"" << endl <<
"xmax: 700 ymax: 700 x: 30 y: 30" << endl <<
@@ -1015,38 +1001,24 @@ bool Dotty(CommandLine &CmdL)
ShapeMap[Pkg->ID] = 3;
}
}
-
+
// 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;
-
- if (Force == true)
- Flags[Pkg->ID] |= ForceNR;
+ Flags[Pkg->ID] |= ForceNR;
}
-
+
// Little header
printf("digraph packages {\n");
printf("concentrate=true;\n");