]> git.saurik.com Git - apt.git/commitdiff
New OR globbing mechanism
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:30 +0000 (16:51 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:30 +0000 (16:51 +0000)
Author: jgg
Date: 1998-11-14 07:20:06 GMT
New OR globbing mechanism

apt-pkg/algorithms.cc
apt-pkg/cacheiterators.h
apt-pkg/pkgcache.cc

index c419022ff56bc6d399a959cd34750f1c74e5a056..21009581004dc17da55f13fc8b7d684b2b5e72b5 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: algorithms.cc,v 1.10 1998/11/14 03:32:36 jgg Exp $
+// $Id: algorithms.cc,v 1.11 1998/11/14 07:20:06 jgg Exp $
 /* ######################################################################
 
    Algorithms - A set of misc algorithms
@@ -671,16 +671,9 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
         for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false;)
         {
            // Compute a single dependency element (glob or)
-           pkgCache::DepIterator Start = D;
-           pkgCache::DepIterator End = D;
-           unsigned char State = 0;
-           for (bool LastOR = true; D.end() == false && LastOR == true; D++)
-           {
-              State |= Cache[D];
-              LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
-              if (LastOR == true)
-                 End = D;
-           }
+           pkgCache::DepIterator Start;
+           pkgCache::DepIterator End;
+           D.GlobOr(Start,End);
            
            // We only worry about critical deps.
            if (End.IsCritical() != true)
index 7cdc197a2a39db516bf0191d1b8a4c27af63a1ff..51714d2590b5101944d345deea1705a495a90c0c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cacheiterators.h,v 1.7 1998/10/02 04:39:44 jgg Exp $
+// $Id: cacheiterators.h,v 1.8 1998/11/14 07:20:08 jgg Exp $
 /* ######################################################################
    
    Cache Iterators - Iterators for navigating the cache structure
@@ -171,9 +171,11 @@ class pkgCache::DepIterator
    inline bool Reverse() {return Type == DepRev;};
    inline unsigned long Index() const {return Dep - Owner->DepP;};
    bool IsCritical();
+   void GlobOr(DepIterator &Start,DepIterator &End);
    Version **AllTargets();   
    bool SmartTargetPkg(PkgIterator &Result);
    const char *CompType();
+   const char *DepType();
    
    inline DepIterator(pkgCache &Owner,Dependency *Trg,Version * = 0) :
           Dep(Trg), Type(DepVer), Owner(&Owner) 
index 9e0d5db0df636566718eb1ec12f9fa4aaa9e3a28..2b52a9977eb19a85ed3b7f957f59164f893053bb 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.16 1998/11/14 07:20:09 jgg Exp $
 /* ######################################################################
    
    Package Cache - Accessor code for the cache
@@ -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