]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
debian/control: Set Standards-Version to 3.9.7
[apt.git] / apt-pkg / deb / deblistparser.cc
index f3ab9d5d82be0213ede23bf5b19d77beadf885b7..ed5484ad97a0a5720134dffcc137ee1763ff1ce4 100644 (file)
@@ -34,6 +34,7 @@
                                                                        /*}}}*/
 
 using std::string;
                                                                        /*}}}*/
 
 using std::string;
+using APT::StringView;
 
 static const debListParser::WordList PrioList[] = {
    {"required",pkgCache::State::Required},
 
 static const debListParser::WordList PrioList[] = {
    {"required",pkgCache::State::Required},
@@ -41,7 +42,7 @@ static const debListParser::WordList PrioList[] = {
    {"standard",pkgCache::State::Standard},
    {"optional",pkgCache::State::Optional},
    {"extra",pkgCache::State::Extra},
    {"standard",pkgCache::State::Standard},
    {"optional",pkgCache::State::Optional},
    {"extra",pkgCache::State::Extra},
-   {NULL, 0}};
+   {"", 0}};
 
 // ListParser::debListParser - Constructor                             /*{{{*/
 // ---------------------------------------------------------------------
 
 // ListParser::debListParser - Constructor                             /*{{{*/
 // ---------------------------------------------------------------------
@@ -57,7 +58,7 @@ debListParser::debListParser(FileFd *File) :
 // ---------------------------------------------------------------------
 /* This is to return the name of the package this section describes */
 string debListParser::Package() {
 // ---------------------------------------------------------------------
 /* This is to return the name of the package this section describes */
 string debListParser::Package() {
-   string Result = Section.FindS("Package");
+   string Result = Section.Find("Package").to_string();
 
    // Normalize mixed case package names to lower case, like dpkg does
    // See Bug#807012 for details
 
    // Normalize mixed case package names to lower case, like dpkg does
    // See Bug#807012 for details
@@ -71,8 +72,8 @@ string debListParser::Package() {
 // ListParser::Architecture - Return the package arch                  /*{{{*/
 // ---------------------------------------------------------------------
 /* This will return the Architecture of the package this section describes */
 // ListParser::Architecture - Return the package arch                  /*{{{*/
 // ---------------------------------------------------------------------
 /* This will return the Architecture of the package this section describes */
-string debListParser::Architecture() {
-   std::string const Arch = Section.FindS("Architecture");
+APT::StringView debListParser::Architecture() {
+   auto const Arch = Section.Find("Architecture");
    return Arch.empty() ? "none" : Arch;
 }
                                                                        /*}}}*/
    return Arch.empty() ? "none" : Arch;
 }
                                                                        /*}}}*/
@@ -80,7 +81,7 @@ string debListParser::Architecture() {
 // ---------------------------------------------------------------------
 /* */
 bool debListParser::ArchitectureAll() {
 // ---------------------------------------------------------------------
 /* */
 bool debListParser::ArchitectureAll() {
-   return Section.FindS("Architecture") == "all";
+   return Section.Find("Architecture") == "all";
 }
                                                                        /*}}}*/
 // ListParser::Version - Return the version string                     /*{{{*/
 }
                                                                        /*}}}*/
 // ListParser::Version - Return the version string                     /*{{{*/
@@ -88,15 +89,15 @@ bool debListParser::ArchitectureAll() {
 /* This is to return the string describing the version in debian form,
    epoch:upstream-release. If this returns the blank string then the 
    entry is assumed to only describe package properties */
 /* This is to return the string describing the version in debian form,
    epoch:upstream-release. If this returns the blank string then the 
    entry is assumed to only describe package properties */
-string debListParser::Version()
+APT::StringView debListParser::Version()
 {
 {
-   return Section.FindS("Version");
+   return Section.Find("Version");
 }
                                                                        /*}}}*/
 unsigned char debListParser::ParseMultiArch(bool const showErrors)     /*{{{*/
 {
    unsigned char MA;
 }
                                                                        /*}}}*/
 unsigned char debListParser::ParseMultiArch(bool const showErrors)     /*{{{*/
 {
    unsigned char MA;
-   string const MultiArch = Section.FindS("Multi-Arch");
+   auto const MultiArch = Section.Find("Multi-Arch");
    if (MultiArch.empty() == true || MultiArch == "no")
       MA = pkgCache::Version::No;
    else if (MultiArch == "same") {
    if (MultiArch.empty() == true || MultiArch == "no")
       MA = pkgCache::Version::No;
    else if (MultiArch == "same") {
@@ -118,7 +119,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors)  /*{{{*/
    {
       if (showErrors == true)
         _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
    {
       if (showErrors == true)
         _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
-              MultiArch.c_str(), Section.FindS("Package").c_str());
+              MultiArch.to_string().c_str(), Section.FindS("Package").c_str());
       MA = pkgCache::Version::No;
    }
 
       MA = pkgCache::Version::No;
    }
 
@@ -143,7 +144,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
       Ver->Section = idx;
    }
    // Parse the source package name
       Ver->Section = idx;
    }
    // Parse the source package name
-   pkgCache::GrpIterator const G = Ver.ParentPkg().Group();
+   pkgCache::GrpIterator G = Ver.ParentPkg().Group();
    Ver->SourcePkgName = G->Name;
    Ver->SourceVerStr = Ver->VerStr;
    if (Section.Find("Source",Start,Stop) == true)
    Ver->SourcePkgName = G->Name;
    Ver->SourceVerStr = Ver->VerStr;
    if (Section.Find("Source",Start,Stop) == true)
@@ -153,24 +154,25 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
 
       if (Space != NULL)
       {
 
       if (Space != NULL)
       {
-        Stop = Space;
         const char * const Open = (const char * const) memchr(Space, '(', Stop - Space);
         if (likely(Open != NULL))
         {
            const char * const Close = (const char * const) memchr(Open, ')', Stop - Open);
            if (likely(Close != NULL))
            {
         const char * const Open = (const char * const) memchr(Space, '(', Stop - Space);
         if (likely(Open != NULL))
         {
            const char * const Close = (const char * const) memchr(Open, ')', Stop - Open);
            if (likely(Close != NULL))
            {
-              std::string const version(Open + 1, (Close - Open) - 1);
+              APT::StringView const version(Open + 1, (Close - Open) - 1);
               if (version != Ver.VerStr())
               {
                  map_stringitem_t const idx = StoreString(pkgCacheGenerator::VERSIONNUMBER, version);
               if (version != Ver.VerStr())
               {
                  map_stringitem_t const idx = StoreString(pkgCacheGenerator::VERSIONNUMBER, version);
+                 G = Ver.ParentPkg().Group();
                  Ver->SourceVerStr = idx;
               }
            }
         }
                  Ver->SourceVerStr = idx;
               }
            }
         }
+        Stop = Space;
       }
 
       }
 
-      std::string const pkgname(Start, Stop - Start);
+      APT::StringView const pkgname(Start, Stop - Start);
       if (pkgname != G.Name())
       {
         for (pkgCache::PkgIterator P = G.PackageList(); P.end() == false; P = G.NextPkg(P))
       if (pkgname != G.Name())
       {
         for (pkgCache::PkgIterator P = G.PackageList(); P.end() == false; P = G.NextPkg(P))
@@ -189,6 +191,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
         if (V.end() == true)
         {
            map_stringitem_t const idx = StoreString(pkgCacheGenerator::PKGNAME, pkgname);
         if (V.end() == true)
         {
            map_stringitem_t const idx = StoreString(pkgCacheGenerator::PKGNAME, pkgname);
+           G = Ver.ParentPkg().Group();
            Ver->SourcePkgName = idx;
         }
       }
            Ver->SourcePkgName = idx;
         }
       }
@@ -204,7 +207,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
    // Priority
    if (Section.Find("Priority",Start,Stop) == true)
    {
    // Priority
    if (Section.Find("Priority",Start,Stop) == true)
    {
-      if (GrabWord(string(Start,Stop-Start),PrioList,Ver->Priority) == false)
+      if (GrabWord(StringView(Start,Stop-Start),PrioList,Ver->Priority) == false)
         Ver->Priority = pkgCache::State::Extra;
    }
 
         Ver->Priority = pkgCache::State::Extra;
    }
 
@@ -234,30 +237,24 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
-// ListParser::Description - Return the description string             /*{{{*/
-// ---------------------------------------------------------------------
-/* This is to return the string describing the package in debian
-   form. If this returns the blank string then the entry is assumed to
-   only describe package properties */
-string debListParser::Description(std::string const &lang)
-{
-   if (lang.empty())
-      return Section.FindS("Description");
-   else
-      return Section.FindS(string("Description-").append(lang).c_str());
-}
-                                                                       /*}}}*/
 // ListParser::AvailableDescriptionLanguages                           /*{{{*/
 std::vector<std::string> debListParser::AvailableDescriptionLanguages()
 {
    std::vector<std::string> const understood = APT::Configuration::getLanguages();
    std::vector<std::string> avail;
 // ListParser::AvailableDescriptionLanguages                           /*{{{*/
 std::vector<std::string> debListParser::AvailableDescriptionLanguages()
 {
    std::vector<std::string> const understood = APT::Configuration::getLanguages();
    std::vector<std::string> avail;
+   static constexpr int prefixLen = 12;
+   static constexpr int avgLanguageLen = 5;
+   std::string tagname;
+
+   tagname.reserve(prefixLen + avgLanguageLen);
+   tagname.assign("Description-");
    if (Section.Exists("Description") == true)
       avail.push_back("");
    for (std::vector<std::string>::const_iterator lang = understood.begin(); lang != understood.end(); ++lang)
    {
    if (Section.Exists("Description") == true)
       avail.push_back("");
    for (std::vector<std::string>::const_iterator lang = understood.begin(); lang != understood.end(); ++lang)
    {
-      std::string const tagname = "Description-" + *lang;
-      if (Section.Exists(tagname.c_str()) == true)
+      tagname.resize(prefixLen);
+      tagname.append(*lang);
+      if (Section.Exists(tagname) == true)
         avail.push_back(*lang);
    }
    return avail;
         avail.push_back(*lang);
    }
    return avail;
@@ -271,25 +268,28 @@ std::vector<std::string> debListParser::AvailableDescriptionLanguages()
  */
 MD5SumValue debListParser::Description_md5()
 {
  */
 MD5SumValue debListParser::Description_md5()
 {
-   string const value = Section.FindS("Description-md5");
+   StringView const value = Section.Find("Description-md5");
    if (value.empty() == true)
    {
    if (value.empty() == true)
    {
-      std::string const desc = Description("") + "\n";
+      StringView const desc = Section.Find("Description");
       if (desc == "\n")
         return MD5SumValue();
 
       MD5Summation md5;
       if (desc == "\n")
         return MD5SumValue();
 
       MD5Summation md5;
-      md5.Add(desc.c_str());
+      md5.Add(desc.data(), desc.size());
+      md5.Add("\n");
       return md5.Result();
    }
    else if (likely(value.size() == 32))
    {
       return md5.Result();
    }
    else if (likely(value.size() == 32))
    {
-      if (likely(value.find_first_not_of("0123456789abcdefABCDEF") == string::npos))
-        return MD5SumValue(value);
-      _error->Error("Malformed Description-md5 line; includes invalid character '%s'", value.c_str());
+      MD5SumValue sumvalue;
+      if (sumvalue.Set(value))
+        return sumvalue;
+
+      _error->Error("Malformed Description-md5 line; includes invalid character '%.*s'", (int)value.length(), value.data());
       return MD5SumValue();
    }
       return MD5SumValue();
    }
-   _error->Error("Malformed Description-md5 line; doesn't have the required length (32 != %d) '%s'", (int)value.size(), value.c_str());
+   _error->Error("Malformed Description-md5 line; doesn't have the required length (32 != %d) '%.*s'", (int)value.size(), (int)value.length(), value.data());
    return MD5SumValue();
 }
                                                                         /*}}}*/
    return MD5SumValue();
 }
                                                                         /*}}}*/
@@ -330,21 +330,21 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
 /* */
 unsigned short debListParser::VersionHash()
 {
 /* */
 unsigned short debListParser::VersionHash()
 {
-   const char *Sections[] ={"Installed-Size",
+   static const StringView Sections[] ={"Installed-Size",
                             "Depends",
                             "Pre-Depends",
 //                            "Suggests",
 //                            "Recommends",
                             "Conflicts",
                             "Breaks",
                             "Depends",
                             "Pre-Depends",
 //                            "Suggests",
 //                            "Recommends",
                             "Conflicts",
                             "Breaks",
-                            "Replaces",0};
+                            "Replaces"};
    unsigned long Result = INIT_FCS;
    char S[1024];
    unsigned long Result = INIT_FCS;
    char S[1024];
-   for (const char * const *I = Sections; *I != 0; ++I)
+   for (StringView I : Sections)
    {
       const char *Start;
       const char *End;
    {
       const char *Start;
       const char *End;
-      if (Section.Find(*I,Start,End) == false || End - Start >= (signed)sizeof(S))
+      if (Section.Find(I,Start,End) == false || End - Start >= (signed)sizeof(S))
         continue;
       
       /* Strip out any spaces from the text, this undoes dpkgs reformatting
         continue;
       
       /* Strip out any spaces from the text, this undoes dpkgs reformatting
@@ -407,8 +407,8 @@ bool debStatusListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
                           {"hold",pkgCache::State::Hold},
                           {"deinstall",pkgCache::State::DeInstall},
                           {"purge",pkgCache::State::Purge},
                           {"hold",pkgCache::State::Hold},
                           {"deinstall",pkgCache::State::DeInstall},
                           {"purge",pkgCache::State::Purge},
-                          {NULL, 0}};
-   if (GrabWord(string(Start,I-Start),WantList,Pkg->SelectedState) == false)
+                          {"", 0}};
+   if (GrabWord(StringView(Start,I-Start),WantList,Pkg->SelectedState) == false)
       return _error->Error("Malformed 1st word in the Status line");
 
    // Isloate the next word
       return _error->Error("Malformed 1st word in the Status line");
 
    // Isloate the next word
@@ -423,8 +423,8 @@ bool debStatusListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
                           {"reinstreq",pkgCache::State::ReInstReq},
                           {"hold",pkgCache::State::HoldInst},
                           {"hold-reinstreq",pkgCache::State::HoldReInstReq},
                           {"reinstreq",pkgCache::State::ReInstReq},
                           {"hold",pkgCache::State::HoldInst},
                           {"hold-reinstreq",pkgCache::State::HoldReInstReq},
-                          {NULL, 0}};
-   if (GrabWord(string(Start,I-Start),FlagList,Pkg->InstState) == false)
+                          {"", 0}};
+   if (GrabWord(StringView(Start,I-Start),FlagList,Pkg->InstState) == false)
       return _error->Error("Malformed 2nd word in the Status line");
 
    // Isloate the last word
       return _error->Error("Malformed 2nd word in the Status line");
 
    // Isloate the last word
@@ -443,8 +443,8 @@ bool debStatusListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
                             {"triggers-awaited",pkgCache::State::TriggersAwaited},
                             {"triggers-pending",pkgCache::State::TriggersPending},
                             {"installed",pkgCache::State::Installed},
                             {"triggers-awaited",pkgCache::State::TriggersAwaited},
                             {"triggers-pending",pkgCache::State::TriggersPending},
                             {"installed",pkgCache::State::Installed},
-                            {NULL, 0}};
-   if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
+                            {"", 0}};
+   if (GrabWord(StringView(Start,I-Start),StatusList,Pkg->CurrentState) == false)
       return _error->Error("Malformed 3rd word in the Status line");
 
    /* A Status line marks the package as indicating the current
       return _error->Error("Malformed 3rd word in the Status line");
 
    /* A Status line marks the package as indicating the current
@@ -541,6 +541,22 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
                                        unsigned int &Op, bool const &ParseArchFlags,
                                        bool const &StripMultiArch,
                                        bool const &ParseRestrictionsList)
                                        unsigned int &Op, bool const &ParseArchFlags,
                                        bool const &StripMultiArch,
                                        bool const &ParseRestrictionsList)
+{
+   StringView PackageView;
+   StringView VerView;
+
+   auto res = ParseDepends(Start, Stop, PackageView, VerView, Op, (bool)ParseArchFlags,
+   (bool) StripMultiArch, (bool) ParseRestrictionsList);
+   Package = PackageView.to_string();
+   Ver = VerView.to_string();
+
+   return res;
+}
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+                                       StringView &Package,StringView &Ver,
+                                       unsigned int &Op, bool ParseArchFlags,
+                                       bool StripMultiArch,
+                                       bool ParseRestrictionsList)
 {
    // Strip off leading space
    for (;Start != Stop && isspace_ascii(*Start) != 0; ++Start);
 {
    // Strip off leading space
    for (;Start != Stop && isspace_ascii(*Start) != 0; ++Start);
@@ -559,16 +575,16 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       return 0;
    
    // Stash the package name
       return 0;
    
    // Stash the package name
-   Package.assign(Start,I - Start);
+   Package = StringView(Start, I - Start);
 
    // We don't want to confuse library users which can't handle MultiArch
 
    // We don't want to confuse library users which can't handle MultiArch
-   string const arch = _config->Find("APT::Architecture");
    if (StripMultiArch == true) {
    if (StripMultiArch == true) {
+      string const arch = _config->Find("APT::Architecture");
       size_t const found = Package.rfind(':');
       size_t const found = Package.rfind(':');
-      if (found != string::npos &&
-         (strcmp(Package.c_str() + found, ":any") == 0 ||
-          strcmp(Package.c_str() + found, ":native") == 0 ||
-          strcmp(Package.c_str() + found + 1, arch.c_str()) == 0))
+      if (found != StringView::npos &&
+         (Package.substr(found) == ":any" ||
+          Package.substr(found) == ":native" ||
+          Package.substr(found +1) == arch))
         Package = Package.substr(0,found);
    }
 
         Package = Package.substr(0,found);
    }
 
@@ -595,20 +611,21 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       const char *End = I;
       for (; End > Start && isspace_ascii(End[-1]); End--);
       
       const char *End = I;
       for (; End > Start && isspace_ascii(End[-1]); End--);
       
-      Ver.assign(Start,End-Start);
+      Ver = StringView(Start,End-Start);
       I++;
    }
    else
    {
       I++;
    }
    else
    {
-      Ver.clear();
+      Ver = StringView();
       Op = pkgCache::Dep::NoOp;
    }
    
    // Skip whitespace
    for (;I != Stop && isspace_ascii(*I) != 0; I++);
 
       Op = pkgCache::Dep::NoOp;
    }
    
    // Skip whitespace
    for (;I != Stop && isspace_ascii(*I) != 0; I++);
 
-   if (ParseArchFlags == true)
+   if (unlikely(ParseArchFlags == true))
    {
    {
+      string const arch = _config->Find("APT::Architecture");
       APT::CacheFilter::PackageArchitectureMatchesSpecification matchesArch(arch, false);
 
       // Parse an architecture
       APT::CacheFilter::PackageArchitectureMatchesSpecification matchesArch(arch, false);
 
       // Parse an architecture
@@ -636,7 +653,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
               ++I;
            }
 
               ++I;
            }
 
-           std::string arch(I, End);
+           std::string const arch(I, End);
            if (arch.empty() == false && matchesArch(arch.c_str()) == true)
            {
               Found = true;
            if (arch.empty() == false && matchesArch(arch.c_str()) == true)
            {
               Found = true;
@@ -666,7 +683,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       for (;I != Stop && isspace_ascii(*I) != 0; I++);
    }
 
       for (;I != Stop && isspace_ascii(*I) != 0; I++);
    }
 
-   if (ParseRestrictionsList == true)
+   if (unlikely(ParseRestrictionsList == true))
    {
       // Parse a restrictions formula which is in disjunctive normal form:
       // (foo AND bar) OR (blub AND bla)
    {
       // Parse a restrictions formula which is in disjunctive normal form:
       // (foo AND bar) OR (blub AND bla)
@@ -718,8 +735,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
                  ++I;
               }
 
                  ++I;
               }
 
-              std::string restriction(I, End);
-
+              std::string const restriction(I, End);
               if (restriction.empty() == false && profiles.empty() == false &&
                  std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
               {
               if (restriction.empty() == false && profiles.empty() == false &&
                  std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
               {
@@ -776,24 +792,24 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 /* This is the higher level depends parser. It takes a tag and generates
    a complete depends tree for the given version. */
 bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
 /* This is the higher level depends parser. It takes a tag and generates
    a complete depends tree for the given version. */
 bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
-                                const char *Tag,unsigned int Type)
+                                StringView Tag,unsigned int Type)
 {
    const char *Start;
    const char *Stop;
 {
    const char *Start;
    const char *Stop;
-   if (Section.Find(Tag,Start,Stop) == false)
+   if (Section.Find(Tag,Start,Stop) == false || Start == Stop)
       return true;
 
    string const pkgArch = Ver.Arch();
 
    while (1)
    {
       return true;
 
    string const pkgArch = Ver.Arch();
 
    while (1)
    {
-      string Package;
-      string Version;
+      StringView Package;
+      StringView Version;
       unsigned int Op;
 
       Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false);
       if (Start == 0)
       unsigned int Op;
 
       Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false);
       if (Start == 0)
-        return _error->Error("Problem parsing dependency %s",Tag);
+        return _error->Error("Problem parsing dependency %.*s",(int)Tag.length(), Tag.data());
       size_t const found = Package.rfind(':');
 
       if (found == string::npos)
       size_t const found = Package.rfind(':');
 
       if (found == string::npos)
@@ -801,7 +817,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
         if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
            return false;
       }
         if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
            return false;
       }
-      else if (strcmp(Package.c_str() + found, ":any") == 0)
+      else if (Package.substr(found) == ":any")
       {
         if (NewDepends(Ver,Package,"any",Version,Op,Type) == false)
            return false;
       {
         if (NewDepends(Ver,Package,"any",Version,Op,Type) == false)
            return false;
@@ -811,9 +827,12 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
         // Such dependencies are not supposed to be accepted …
         // … but this is probably the best thing to do anyway
         if (Package.substr(found + 1) == "native")
         // Such dependencies are not supposed to be accepted …
         // … but this is probably the best thing to do anyway
         if (Package.substr(found + 1) == "native")
-           Package = Package.substr(0, found) + ':' + Ver.Cache()->NativeArch();
-
-        if (NewDepends(Ver, Package, "any", Version, Op | pkgCache::Dep::ArchSpecific, Type) == false)
+        {
+           std::string const Pkg = Package.substr(0, found).to_string() + ':' + Ver.Cache()->NativeArch();
+           if (NewDepends(Ver, Pkg, "any", Version, Op | pkgCache::Dep::ArchSpecific, Type) == false)
+              return false;
+        }
+        else if (NewDepends(Ver, Package, "any", Version, Op | pkgCache::Dep::ArchSpecific, Type) == false)
            return false;
       }
 
            return false;
       }
 
@@ -849,8 +868,8 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
    const char *Stop;
    if (Section.Find("Provides",Start,Stop) == true)
    {
    const char *Stop;
    if (Section.Find("Provides",Start,Stop) == true)
    {
-      string Package;
-      string Version;
+      StringView Package;
+      StringView Version;
       unsigned int Op;
 
       do
       unsigned int Op;
 
       do
@@ -859,10 +878,10 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
         const size_t archfound = Package.rfind(':');
         if (Start == 0)
            return _error->Error("Problem parsing Provides line");
         const size_t archfound = Package.rfind(':');
         if (Start == 0)
            return _error->Error("Problem parsing Provides line");
-        if (Op != pkgCache::Dep::NoOp && Op != pkgCache::Dep::Equals) {
-           _error->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package.c_str());
+        if (unlikely(Op != pkgCache::Dep::NoOp && Op != pkgCache::Dep::Equals)) {
+           _error->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package.to_string().c_str());
         } else if (archfound != string::npos) {
         } else if (archfound != string::npos) {
-           std::string spzArch = Package.substr(archfound + 1);
+           StringView spzArch = Package.substr(archfound + 1);
            if (spzArch != "any")
            {
               if (NewProvides(Ver, Package.substr(0, archfound), spzArch, Version, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false)
            if (spzArch != "any")
            {
               if (NewProvides(Ver, Package.substr(0, archfound), spzArch, Version, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false)
@@ -872,12 +891,16 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
               return false;
         } else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
            if (APT::Configuration::checkArchitecture(Arch))
               return false;
         } else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
            if (APT::Configuration::checkArchitecture(Arch))
+           {
               if (NewProvidesAllArch(Ver, Package, Version, 0) == false)
                  return false;
               if (NewProvidesAllArch(Ver, Package, Version, 0) == false)
                  return false;
+           }
+           else if (NewProvides(Ver, Package, Arch, Version, 0) == false)
+              return false;
         } else {
            if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
            {
         } else {
            if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
            {
-              if (NewProvides(Ver, Package + ":any", "any", Version, pkgCache::Flag::MultiArchImplicit) == false)
+              if (NewProvides(Ver, Package.to_string().append(":any"), "any", Version, pkgCache::Flag::MultiArchImplicit) == false)
                  return false;
            }
            if (NewProvides(Ver, Package, Arch, Version, 0) == false)
                  return false;
            }
            if (NewProvides(Ver, Package, Arch, Version, 0) == false)
@@ -885,7 +908,9 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
         }
         if (archfound == std::string::npos)
         {
         }
         if (archfound == std::string::npos)
         {
-           std::string const spzName = Package + ':' + Ver.ParentPkg().Arch();
+           string spzName = Package.to_string();
+           spzName.push_back(':');
+           spzName.append(Ver.ParentPkg().Arch());
            pkgCache::PkgIterator const spzPkg = Ver.Cache()->FindPkg(spzName, "any");
            if (spzPkg.end() == false)
            {
            pkgCache::PkgIterator const spzPkg = Ver.Cache()->FindPkg(spzName, "any");
            if (spzPkg.end() == false)
            {
@@ -926,11 +951,12 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
 // ListParser::GrabWord - Matches a word and returns                   /*{{{*/
 // ---------------------------------------------------------------------
 /* Looks for a word in a list of words - for ParseStatus */
 // ListParser::GrabWord - Matches a word and returns                   /*{{{*/
 // ---------------------------------------------------------------------
 /* Looks for a word in a list of words - for ParseStatus */
-bool debListParser::GrabWord(string Word,const WordList *List,unsigned char &Out)
+bool debListParser::GrabWord(StringView Word, WordList const *List, unsigned char &Out)
 {
 {
-   for (unsigned int C = 0; List[C].Str != 0; C++)
+   for (unsigned int C = 0; List[C].Str.empty() == false; C++)
    {
    {
-      if (strcasecmp(Word.c_str(),List[C].Str) == 0)
+      if (Word.length() == List[C].Str.length() &&
+         strncasecmp(Word.data(), List[C].Str.data(), Word.length()) == 0)
       {
         Out = List[C].Val;
         return true;
       {
         Out = List[C].Val;
         return true;