Merge remote-tracking branch 'upstream/debian/sid' into debian/sid
[ntk/apt.git] / apt-pkg / cachefilter.cc
index 35f95fe..e388f24 100644 (file)
@@ -9,10 +9,12 @@
 #include <apt-pkg/cachefilter.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/macros.h>
 
 #include <string>
-
+#include <string.h>
 #include <regex.h>
 #include <fnmatch.h>
 
@@ -55,6 +57,17 @@ PackageNameMatchesRegEx::~PackageNameMatchesRegEx() {                        /*{{{*/
 }
                                                                        /*}}}*/
 
+// Fnmatch support                                     /*{{{*/
+//----------------------------------------------------------------------
+bool PackageNameMatchesFnmatch::operator() (pkgCache::PkgIterator const &Pkg) {/*{{{*/
+   return fnmatch(Pattern.c_str(), Pkg.Name(), FNM_CASEFOLD) == 0;
+}
+                                                                       /*}}}*/
+bool PackageNameMatchesFnmatch::operator() (pkgCache::GrpIterator const &Grp) {/*{{{*/
+   return fnmatch(Pattern.c_str(), Grp.Name(), FNM_CASEFOLD) == 0;
+}
+                                                                       /*}}}*/
+
 // CompleteArch to <kernel>-<cpu> tuple                                        /*{{{*/
 //----------------------------------------------------------------------
 /* The complete architecture, consisting of <kernel>-<cpu>. */
@@ -66,19 +79,12 @@ static std::string CompleteArch(std::string const &arch) {
                complete = complete.substr(1, complete.size()-2);
                return complete;
        }
-       else if (arch == "armel")               return "linux-arm";
-       else if (arch == "armhf")               return "linux-arm";
-       else if (arch == "lpia")                return "linux-i386";
-       else if (arch == "powerpcspe")          return "linux-powerpc";
-       else if (arch == "uclibc-linux-armel")  return "linux-arm";
-       else if (arch == "uclinux-armel")       return "uclinux-arm";
        else if (arch == "any")                 return "*-*";
        else                                    return "linux-" + arch;
 }
                                                                        /*}}}*/
 PackageArchitectureMatchesSpecification::PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern) :/*{{{*/
-                                       literal(pattern), isPattern(isPattern), d(NULL) {
-       complete = CompleteArch(pattern);
+                                       literal(pattern), complete(CompleteArch(pattern)), isPattern(isPattern), d(NULL) {
 }
                                                                        /*}}}*/
 bool PackageArchitectureMatchesSpecification::operator() (char const * const &arch) {/*{{{*/