]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcache.cc
deprecate confusing Pkg.CandVersion() method
[apt.git] / apt-pkg / pkgcache.cc
index f4fb073f5c52b50a086ec5c4e699a809eff419ff..83cb6149ef157f98b361ae321f1f834cf9f24017 100644 (file)
@@ -59,7 +59,7 @@ pkgCache::Header::Header()
    /* Whenever the structures change the major version should be bumped,
       whenever the generator changes the minor version should be bumped. */
    APT_HEADER_SET(MajorVersion, 10);
-   APT_HEADER_SET(MinorVersion, 3);
+   APT_HEADER_SET(MinorVersion, 5);
    APT_HEADER_SET(Dirty, false);
 
    APT_HEADER_SET(HeaderSz, sizeof(pkgCache::Header));
@@ -127,7 +127,7 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
 // ---------------------------------------------------------------------
 /* */
 APT_IGNORE_DEPRECATED_PUSH
-pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map), d(NULL)
+pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map), VS(nullptr), d(NULL)
 {
    // call getArchitectures() with cached=false to ensure that the 
    // architectures cache is re-evaulated. this is needed in cases
@@ -184,10 +184,12 @@ bool pkgCache::ReMap(bool const &Errorchecks)
 
    // Check the architecture
    std::vector<std::string> archs = APT::Configuration::getArchitectures();
-   std::vector<std::string>::const_iterator a = archs.begin();
-   std::string list = *a;
-   for (++a; a != archs.end(); ++a)
-      list.append(",").append(*a);
+   std::string list = "";
+   for (auto const & arch : archs) {
+      if (!list.empty())
+         list.append(",");
+      list.append(arch);
+   }
    if (_config->Find("APT::Architecture") != StrP + HeaderP->Architecture ||
         list != StrP + HeaderP->GetArchitectures())
       return _error->Error(_("The package cache was built for different architectures: %s vs %s"), StrP + HeaderP->GetArchitectures(), list.c_str());
@@ -263,7 +265,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
 }
 
 pkgCache::PkgIterator pkgCache::FindPkg(StringView Name) {
-       auto const found = Name.find(':');
+       auto const found = Name.rfind(':');
        if (found == string::npos)
           return FindPkg(Name, "native");
        auto const Arch = Name.substr(found+1);
@@ -307,7 +309,7 @@ pkgCache::GrpIterator pkgCache::FindGrp(StringView Name) {
        // Look at the hash bucket for the group
        Group *Grp = GrpP + HeaderP->GrpHashTableP()[sHash(Name)];
        for (; Grp != GrpP; Grp = GrpP + Grp->Next) {
-               int const cmp = Name.compare(StrP + Grp->Name);
+               int const cmp = Name.compare(ViewString(Grp->Name));
                if (cmp == 0)
                        return GrpIterator(*this, Grp);
                else if (cmp < 0)
@@ -389,7 +391,7 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(StringView Arch) const {
        // Iterate over the list to find the matching arch
        for (pkgCache::Package *Pkg = PackageList(); Pkg != Owner->PkgP;
             Pkg = Owner->PkgP + Pkg->NextPackage) {
-               if (Arch.compare(Owner->StrP + Pkg->Arch) == 0)
+               if (Arch == Owner->ViewString(Pkg->Arch))
                        return PkgIterator(*Owner, Pkg);
                if ((Owner->PkgP + S->LastPackage) == Pkg)
                        break;
@@ -498,7 +500,7 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
    
    if (S->CurrentState == pkgCache::State::UnPacked ||
        S->CurrentState == pkgCache::State::HalfConfigured)
-      // we leave triggers alone complettely. dpkg deals with
+      // we leave triggers alone completely. dpkg deals with
       // them in a hard-to-predict manner and if they get 
       // resolved by dpkg before apt run dpkg --configure on 
       // the TriggersPending package dpkg returns a error
@@ -800,7 +802,7 @@ bool pkgCache::DepIterator::IsImplicit() const
    return false;
 }
                                                                        /*}}}*/
-// ostream operator to handle string representation of a dependecy     /*{{{*/
+// ostream operator to handle string representation of a dependency    /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 std::ostream& operator<<(std::ostream& out, pkgCache::DepIterator D)