diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-07-17 19:07:00 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-07-17 19:07:00 +0200 |
commit | 9ba5aa3b01f1f7c08c74f5d0a21971db221d30f1 (patch) | |
tree | d2b12bb5b382c36aeaf6872241e75a2b25923fe7 /cmdline | |
parent | fe1af091b871f9af715d729e515f2e3a62802c6f (diff) |
factor regex package name matches into newly created cachefilter classes
Diffstat (limited to 'cmdline')
-rw-r--r-- | cmdline/cacheset.cc | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/cmdline/cacheset.cc b/cmdline/cacheset.cc index 78c9d3f6c..0b099f442 100644 --- a/cmdline/cacheset.cc +++ b/cmdline/cacheset.cc @@ -10,6 +10,7 @@ /*}}}*/ // Include Files /*{{{*/ #include <apt-pkg/aptconfiguration.h> +#include <apt-pkg/cachefilter.h> #include <apt-pkg/error.h> #include <apt-pkg/strutl.h> #include <apt-pkg/versionmatch.h> @@ -97,22 +98,14 @@ PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, Cache arch = "native"; } - regex_t Pattern; - int Res; - if ((Res = regcomp(&Pattern, pattern.c_str() , REG_EXTENDED | REG_ICASE | REG_NOSUB)) != 0) { - char Error[300]; - regerror(Res, &Pattern, Error, sizeof(Error)); - _error->Error(_("Regex compilation error - %s"), Error); - return PackageSet(REGEX); - } - if (unlikely(Cache.GetPkgCache() == 0)) return PackageSet(REGEX); + APT::CacheFilter::PackageNameMatchesRegEx regexfilter(pattern); + PackageSet pkgset(REGEX); - for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp) - { - if (regexec(&Pattern, Grp.Name(), 0, 0, 0) != 0) + for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp) { + if (regexfilter(Grp) == false) continue; pkgCache::PkgIterator Pkg = Grp.FindPkg(arch); if (Pkg.end() == true) { @@ -128,7 +121,6 @@ PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, Cache pkgset.insert(Pkg); } - regfree(&Pattern); if (pkgset.empty() == true) return helper.canNotFindRegEx(Cache, pattern); |