// -*- 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
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)
// -*- 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
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)
// -*- 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
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