From 43d017d69796a5093cb12506ec59285a34915b7f Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:51:30 +0000 Subject: [PATCH] New OR globbing mechanism Author: jgg Date: 1998-11-14 07:20:06 GMT New OR globbing mechanism --- apt-pkg/algorithms.cc | 15 ++++----------- apt-pkg/cacheiterators.h | 4 +++- apt-pkg/pkgcache.cc | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index c419022ff..210095810 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -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) diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 7cdc197a2..51714d259 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -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) diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 9e0d5db0d..2b52a9977 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -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 -- 2.45.2