]> git.saurik.com Git - apt-legacy.git/blobdiff - apt-pkg/deb/deblistparser.cc
Figured out a much simpler fix for the cache rebuild performance.
[apt-legacy.git] / apt-pkg / deb / deblistparser.cc
index 896d4d6d8590c3ef697d3171ea5f0bf994593e5c..de565d030a1aa84fd83d86ed1cda26279c2dbb93 100644 (file)
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/md5.h>
+#include <apt-pkg/macros.h>
 
 #include <ctype.h>
 
 #include <ctype.h>
-
-#include <system.h>
                                                                        /*}}}*/
 
 static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
                                                                        /*}}}*/
 
 static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
@@ -40,6 +39,18 @@ debListParser::debListParser(FileFd *File) : Tags(File)
 // ListParser::UniqFindTagWrite - Find the tag and write a unq string  /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // ListParser::UniqFindTagWrite - Find the tag and write a unq string  /*{{{*/
 // ---------------------------------------------------------------------
 /* */
+unsigned long debListParser::FindTagWrite(const char *Tag)
+{
+   const char *Start;
+   const char *Stop;
+   if (Section.Find(Tag,Start,Stop) == false)
+      return 0;
+   return WriteString(Start,Stop - Start);
+}
+                                                                       /*}}}*/
+// ListParser::UniqFindTagWrite - Find the tag and write a unq string  /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 unsigned long debListParser::UniqFindTagWrite(const char *Tag)
 {
    const char *Start;
 unsigned long debListParser::UniqFindTagWrite(const char *Tag)
 {
    const char *Start;
@@ -75,6 +86,10 @@ string debListParser::Version()
 /* */
 bool debListParser::NewVersion(pkgCache::VerIterator Ver)
 {
 /* */
 bool debListParser::NewVersion(pkgCache::VerIterator Ver)
 {
+   Ver->Display = FindTagWrite("Name");
+   if (Ver->Display == 0)
+      Ver->Display = FindTagWrite("Maemo-Display-Name");
+
    // Parse the section
    Ver->Section = UniqFindTagWrite("Section");
    Ver->Arch = UniqFindTagWrite("Architecture");
    // Parse the section
    Ver->Section = UniqFindTagWrite("Section");
    Ver->Arch = UniqFindTagWrite("Architecture");
@@ -109,6 +124,8 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
       return false;
    if (ParseDepends(Ver,"Replaces",pkgCache::Dep::Replaces) == false)
       return false;
       return false;
    if (ParseDepends(Ver,"Replaces",pkgCache::Dep::Replaces) == false)
       return false;
+   if (ParseDepends(Ver,"Enhances",pkgCache::Dep::Enhances) == false)
+      return false;
 
    // Obsolete.
    if (ParseDepends(Ver,"Optional",pkgCache::Dep::Suggests) == false)
 
    // Obsolete.
    if (ParseDepends(Ver,"Optional",pkgCache::Dep::Suggests) == false)
@@ -169,6 +186,10 @@ MD5SumValue debListParser::Description_md5()
 bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
                               pkgCache::VerIterator Ver)
 {
 bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
                               pkgCache::VerIterator Ver)
 {
+   if (Pkg->Display == 0)
+      Pkg->Display = FindTagWrite("Name");
+   if (Pkg->Display == 0)
+      Pkg->Display = FindTagWrite("Maemo-Display-Name");
    if (Pkg->Section == 0)
       Pkg->Section = UniqFindTagWrite("Section");
    if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
    if (Pkg->Section == 0)
       Pkg->Section = UniqFindTagWrite("Section");
    if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
@@ -181,6 +202,11 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
    
    if (ParseStatus(Pkg,Ver) == false)
       return false;
    
    if (ParseStatus(Pkg,Ver) == false)
       return false;
+
+   if (Pkg->TagList == 0)
+      if (ParseTag(Pkg) == false)
+         return false;
+
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
@@ -213,7 +239,7 @@ unsigned short debListParser::VersionHash()
       for (; Start != End; Start++)
       {
         if (isspace(*Start) == 0)
       for (; Start != End; Start++)
       {
         if (isspace(*Start) == 0)
-           *I++ = tolower(*Start);
+           *I++ = tolower_ascii(*Start);
         if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
            *I++ = '=';
         if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
         if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
            *I++ = '=';
         if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
@@ -563,6 +589,46 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver)
         break;
    }
    
         break;
    }
    
+   return true;
+}
+                                                                       /*}}}*/
+// ListParser::ParseTag - Parse the tag list                           /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debListParser::ParseTag(pkgCache::PkgIterator Pkg)
+{
+   const char *Start;
+   const char *Stop;
+   if (Section.Find("Tag",Start,Stop) == false)
+      return true;
+   
+   while (1) {
+      while (1) {
+         if (Start == Stop)
+            return true;
+         if (Stop[-1] != ' ' && Stop[-1] != '\t')
+            break;
+         --Stop;
+      }
+
+      const char *Begin = Stop - 1;
+      while (Begin != Start && Begin[-1] != ' ' && Begin[-1] != ',')
+         --Begin;
+
+      if (NewTag(Pkg, Begin, Stop - Begin) == false)
+         return false;
+
+      while (1) {
+         if (Begin == Start)
+            return true;
+         if (Begin[-1] == ',')
+            break;
+         --Begin;
+      }
+
+      Stop = Begin - 1;
+   }
+
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
@@ -590,11 +656,18 @@ bool debListParser::Step()
    iOffset = Tags.Offset();
    while (Tags.Step(Section) == true)
    {      
    iOffset = Tags.Offset();
    while (Tags.Step(Section) == true)
    {      
+      const char *Start;
+      const char *Stop;
+
+      if (Section.Find("Package",Start,Stop) == false) {
+         _error->Warning("Encountered a section with no Package: header");
+        continue;
+      }
+
       /* See if this is the correct Architecture, if it isn't then we
          drop the whole section. A missing arch tag only happens (in theory)
          inside the Status file, so that is a positive return */
       /* See if this is the correct Architecture, if it isn't then we
          drop the whole section. A missing arch tag only happens (in theory)
          inside the Status file, so that is a positive return */
-      const char *Start;
-      const char *Stop;
+
       if (Section.Find("Architecture",Start,Stop) == false)
         return true;
 
       if (Section.Find("Architecture",Start,Stop) == false)
         return true;