X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/d04e44ac8177fc5b70ae0189bb5e437c2502f910..baec76f5f0f9fcbd71f6e2afaa7fc85543bd624c:/cmdline/apt-mark.cc diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 132bd7ef6..0cba31e70 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")}, @@ -319,10 +316,8 @@ std::vector GetCommands() /*{{{*/ /*}}}*/ int main(int argc,const char *argv[]) /*{{{*/ { - InitLocale(); - CommandLine CmdL; - auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_MARK, &_config, &_system, argc, argv); + auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_MARK, &_config, &_system, argc, argv, &ShowHelp, &GetCommands); InitOutput();