]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
merge with my debian-sid branch
[apt.git] / apt-pkg / deb / deblistparser.cc
index 0562be44c114ad5ec6531b2993f14609941bc658..fd3e4808dfff1816cda28ab09a138fb6db2a5145 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/macros.h>
@@ -23,6 +26,8 @@
 #include <ctype.h>
                                                                        /*}}}*/
 
 #include <ctype.h>
                                                                        /*}}}*/
 
+using std::string;
+
 static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
                        {"required",pkgCache::State::Required},
                        {"standard",pkgCache::State::Standard},
 static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
                        {"required",pkgCache::State::Required},
                        {"standard",pkgCache::State::Standard},
@@ -69,10 +74,7 @@ string debListParser::Package() {
 // ---------------------------------------------------------------------
 /* This will return the Architecture of the package this section describes */
 string debListParser::Architecture() {
 // ---------------------------------------------------------------------
 /* This will return the Architecture of the package this section describes */
 string debListParser::Architecture() {
-   std::string const Arch = Section.FindS("Architecture");
-   if (Arch.empty() == true)
-      return _config->Find("APT::Architecture");
-   return Arch;
+   return Section.FindS("Architecture");
 }
                                                                        /*}}}*/
 // ListParser::ArchitectureAll                                         /*{{{*/
 }
                                                                        /*}}}*/
 // ListParser::ArchitectureAll                                         /*{{{*/
@@ -128,12 +130,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
    }
 
    if (ArchitectureAll() == true)
    }
 
    if (ArchitectureAll() == true)
-      switch (Ver->MultiArch)
-      {
-        case pkgCache::Version::Foreign: Ver->MultiArch = pkgCache::Version::AllForeign; break;
-        case pkgCache::Version::Allowed: Ver->MultiArch = pkgCache::Version::AllAllowed; break;
-        default: Ver->MultiArch = pkgCache::Version::All;
-      }
+      Ver->MultiArch |= pkgCache::Version::All;
 
    // Archive Size
    Ver->Size = Section.FindULL("Size");
 
    // Archive Size
    Ver->Size = Section.FindULL("Size");
@@ -690,12 +687,12 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
 
    if (MultiArchEnabled == false)
       return true;
 
    if (MultiArchEnabled == false)
       return true;
-   else if (Ver->MultiArch == pkgCache::Version::Allowed || Ver->MultiArch == pkgCache::Version::AllAllowed)
+   else if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
    {
       string const Package = string(Ver.ParentPkg().Name()).append(":").append("any");
       return NewProvidesAllArch(Ver, Package, Ver.VerStr());
    }
    {
       string const Package = string(Ver.ParentPkg().Name()).append(":").append("any");
       return NewProvidesAllArch(Ver, Package, Ver.VerStr());
    }
-   else if (Ver->MultiArch == pkgCache::Version::Foreign || Ver->MultiArch == pkgCache::Version::AllForeign)
+   else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
       return NewProvidesAllArch(Ver, Ver.ParentPkg().Name(), Ver.VerStr());
 
    return true;
       return NewProvidesAllArch(Ver, Ver.ParentPkg().Name(), Ver.VerStr());
 
    return true;
@@ -816,16 +813,16 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
       ++lineEnd;
 
       // which datastorage need to be updated
       ++lineEnd;
 
       // which datastorage need to be updated
-      map_ptrloc* writeTo = NULL;
+      enum { Suite, Component, Version, Origin, Codename, Label, None } writeTo = None;
       if (buffer[0] == ' ')
         ;
       if (buffer[0] == ' ')
         ;
-      #define APT_PARSER_WRITETO(X, Y) else if (strncmp(Y, buffer, len) == 0) writeTo = &X;
-      APT_PARSER_WRITETO(FileI->Archive, "Suite")
-      APT_PARSER_WRITETO(FileI->Component, "Component")
-      APT_PARSER_WRITETO(FileI->Version, "Version")
-      APT_PARSER_WRITETO(FileI->Origin, "Origin")
-      APT_PARSER_WRITETO(FileI->Codename, "Codename")
-      APT_PARSER_WRITETO(FileI->Label, "Label")
+      #define APT_PARSER_WRITETO(X) else if (strncmp(#X, buffer, len) == 0) writeTo = X;
+      APT_PARSER_WRITETO(Suite)
+      APT_PARSER_WRITETO(Component)
+      APT_PARSER_WRITETO(Version)
+      APT_PARSER_WRITETO(Origin)
+      APT_PARSER_WRITETO(Codename)
+      APT_PARSER_WRITETO(Label)
       #undef APT_PARSER_WRITETO
       #define APT_PARSER_FLAGIT(X) else if (strncmp(#X, buffer, len) == 0) \
         pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, lineEnd);
       #undef APT_PARSER_WRITETO
       #define APT_PARSER_FLAGIT(X) else if (strncmp(#X, buffer, len) == 0) \
         pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, lineEnd);
@@ -835,19 +832,19 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
 
       // load all data from the line and save it
       string data;
 
       // load all data from the line and save it
       string data;
-      if (writeTo != NULL)
+      if (writeTo != None)
         data.append(dataStart, dataEnd);
       if (sizeof(buffer) - 1 == (dataEnd - buffer))
       {
         while (fgets(buffer, sizeof(buffer), release) != NULL)
         {
         data.append(dataStart, dataEnd);
       if (sizeof(buffer) - 1 == (dataEnd - buffer))
       {
         while (fgets(buffer, sizeof(buffer), release) != NULL)
         {
-           if (writeTo != NULL)
+           if (writeTo != None)
               data.append(buffer);
            if (strlen(buffer) != sizeof(buffer) - 1)
               break;
         }
       }
               data.append(buffer);
            if (strlen(buffer) != sizeof(buffer) - 1)
               break;
         }
       }
-      if (writeTo != NULL)
+      if (writeTo != None)
       {
         // remove spaces and stuff from the end of the data line
         for (std::string::reverse_iterator s = data.rbegin();
       {
         // remove spaces and stuff from the end of the data line
         for (std::string::reverse_iterator s = data.rbegin();
@@ -857,7 +854,15 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
               break;
            *s = '\0';
         }
               break;
            *s = '\0';
         }
-        *writeTo = WriteUniqString(data);
+        switch (writeTo) {
+        case Suite: FileI->Archive = WriteUniqString(data); break;
+        case Component: FileI->Component = WriteUniqString(data); break;
+        case Version: FileI->Version = WriteUniqString(data); break;
+        case Origin: FileI->Origin = WriteUniqString(data); break;
+        case Codename: FileI->Codename = WriteUniqString(data); break;
+        case Label: FileI->Label = WriteUniqString(data); break;
+        case None: break;
+        }
       }
    }
    fclose(release);
       }
    }
    fclose(release);