X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/90986d4dbbd38e2e89f986d621e301304210452e..ef00bd7af5b2bc0625df58482eacb4c2873c3647:/cmdline/apt-mark.cc diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 2491a8ebf..4e86edc77 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -48,9 +48,8 @@ using namespace std; static bool DoAuto(CommandLine &CmdL) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - pkgDepCache *DepCache = CacheFile.GetDepCache(); - if (unlikely(Cache == NULL || DepCache == NULL)) + pkgDepCache * const DepCache = CacheFile.GetDepCache(); + if (unlikely(DepCache == nullptr)) return false; APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1); @@ -95,9 +94,8 @@ static bool DoAuto(CommandLine &CmdL) static bool DoMarkAuto(CommandLine &CmdL) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - pkgDepCache *DepCache = CacheFile.GetDepCache(); - if (unlikely(Cache == NULL || DepCache == NULL)) + pkgDepCache * const DepCache = CacheFile.GetDepCache(); + if (unlikely(DepCache == nullptr)) return false; APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1); @@ -132,9 +130,8 @@ static bool DoMarkAuto(CommandLine &CmdL) static bool ShowAuto(CommandLine &CmdL) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - pkgDepCache *DepCache = CacheFile.GetDepCache(); - if (unlikely(Cache == NULL || DepCache == NULL)) + pkgDepCache * const DepCache = CacheFile.GetDepCache(); + if (unlikely(DepCache == nullptr)) return false; std::vector packages; @@ -143,8 +140,8 @@ static bool ShowAuto(CommandLine &CmdL) if (CmdL.FileList[1] == 0) { - packages.reserve(Cache->HeaderP->PackageCount / 3); - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) + packages.reserve(DepCache->Head().PackageCount / 3); + for (pkgCache::PkgIterator P = DepCache->PkgBegin(); P.end() == false; ++P) if (P->CurrentVer != 0 && (((*DepCache)[P].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto) == ShowAuto) packages.push_back(P.FullName(true)); @@ -172,8 +169,8 @@ static bool ShowAuto(CommandLine &CmdL) static bool DoSelection(CommandLine &CmdL) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - if (unlikely(Cache == NULL)) + pkgCache * const Cache = CacheFile.GetPkgCache(); + if (unlikely(Cache == nullptr)) return false; APT::VersionVector pkgset = APT::VersionVector::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::CacheSetHelper::INSTCAND); @@ -238,8 +235,8 @@ static bool DoSelection(CommandLine &CmdL) static bool ShowSelection(CommandLine &CmdL) /*{{{*/ { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - if (unlikely(Cache == NULL)) + pkgCache * const Cache = CacheFile.GetPkgCache(); + if (unlikely(Cache == nullptr)) return false; pkgCache::State::PkgSelectedState selector; @@ -280,7 +277,7 @@ static bool ShowSelection(CommandLine &CmdL) /*{{{*/ return true; } /*}}}*/ -bool ShowHelp(CommandLine &) /*{{{*/ +static bool ShowHelp(CommandLine &) /*{{{*/ { std::cout << _("Usage: apt-mark [options] {auto|manual} pkg1 [pkg2 ...]\n" @@ -292,7 +289,7 @@ bool ShowHelp(CommandLine &) /*{{{*/ return true; } /*}}}*/ -std::vector GetCommands() /*{{{*/ +static std::vector GetCommands() /*{{{*/ { return { {"auto",&DoAuto, _("Mark the given packages as automatically installed")},