From 43d017d69796a5093cb12506ec59285a34915b7f Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:51:30 +0000 Subject: New OR globbing mechanism Author: jgg Date: 1998-11-14 07:20:06 GMT New OR globbing mechanism --- apt-pkg/pkgcache.cc | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'apt-pkg/pkgcache.cc') 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 -- cgit v1.2.3