]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcache.cc
Version compare fixes
[apt.git] / apt-pkg / pkgcache.cc
index 9e0d5db0df636566718eb1ec12f9fa4aaa9e3a28..06cad4b16667b0983896489c41b64ef5604fb245 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcache.cc,v 1.15 1998/11/13 04:23:32 jgg Exp $
+// $Id: pkgcache.cc,v 1.18 1998/11/27 00:07:24 jgg Exp $
 /* ######################################################################
    
    Package Cache - Accessor code for the cache
@@ -203,7 +203,7 @@ void pkgCache::PkgIterator::operator ++(int)
 // ---------------------------------------------------------------------
 /* By this we mean if it is either cleanly installed or cleanly removed. */
 pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
-{
+{  
    if (Pkg->InstState == pkgCache::State::ReInstReq ||
        Pkg->InstState == pkgCache::State::HoldReInstReq)
       return NeedsUnpack;
@@ -351,11 +351,42 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets()
 const char *pkgCache::DepIterator::CompType()
 {
    const char *Ops[] = {"","<=",">=","<",">","=","!="};
-   if ((unsigned)(Dep->CompareOp & 0xF) < sizeof(Ops))
+   if ((unsigned)(Dep->CompareOp & 0xF) < 7)
       return Ops[Dep->CompareOp & 0xF];
    return "";   
 }
                                                                        /*}}}*/
+// DepIterator::DepType - Return a string describing the dep type      /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+const char *pkgCache::DepIterator::DepType()
+{
+   const char *Types[] = {"","Depends","PreDepends","Suggests",
+                          "Recommends","Conflicts","Replaces"};
+   if (Dep->Type < 7)
+      return Types[Dep->Type];
+   return "";
+}
+                                                                       /*}}}*/
+// DepIterator::GlobOr - Compute an OR group                           /*{{{*/
+// ---------------------------------------------------------------------
+/* This Takes an iterator, iterates past the current dependency grouping
+   and returns Start and End so that so End is the final element
+   in the group, if End == Start then D is End++ and End is the
+   dependency D was pointing to. Use in loops to iterate sensibly. */
+void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
+{
+   // Compute a single dependency element (glob or)
+   Start = *this;
+   End = *this;
+   for (bool LastOR = true; end() == false && LastOR == true; (*this)++)
+   {
+      LastOR = (Dep->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
+      if (LastOR == true)
+        End = (*this);
+   }
+}
+                                                                       /*}}}*/
 // VerIterator::CompareVer - Fast version compare for same pkgs                /*{{{*/
 // ---------------------------------------------------------------------
 /* This just looks over the version list to see if B is listed before A. In
@@ -391,6 +422,18 @@ bool pkgCache::VerIterator::Downloadable() const
    return false;
 }
                                                                        /*}}}*/
+// VerIterator::PriorityType - Return a string describing the priority /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+const char *pkgCache::VerIterator::PriorityType()
+{
+   const char *Types[] = {"","Important","Required","Standard",
+                          "Optional","Extra"};
+   if (Ver->Priority < 6)
+      return Types[Ver->Priority];
+   return "";
+}
+                                                                       /*}}}*/
 // PkgFileIterator::IsOk - Checks if the cache is in sync with the file        /*{{{*/
 // ---------------------------------------------------------------------
 /* This stats the file and compares its stats with the ones that were