From c64a85dd7524546864603b955f601bf64c9a4bcf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 15 Aug 2019 12:50:22 +0200 Subject: Add patterns for the existing CacheFilter::Matcher classes This implements the basic logic patterns: ?and ?false ?not ?or ?true and the basic package patterns: ?architecture ?name ?x-name-fnmatch --- apt-pkg/cachefilter-patterns.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'apt-pkg/cachefilter-patterns.cc') diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index ea4cf3cd8..dd5d741d3 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -208,6 +208,36 @@ std::unique_ptr PatternParser::aPattern(std::unique_p if (node == nullptr) nodeP->error("Expected a pattern"); + if (node->matches("?architecture", 1, 1)) + return std::make_unique(aWord(node->arguments[0])); + if (node->matches("?false", 0, 0)) + return std::make_unique(); + if (node->matches("?name", 1, 1)) + return std::make_unique(aWord(node->arguments[0])); + if (node->matches("?not", 1, 1)) + return std::make_unique(aPattern(node->arguments[0]).release()); + if (node->matches("?true", 0, 0)) + return std::make_unique(); + if (node->matches("?x-name-fnmatch", 1, 1)) + return std::make_unique(aWord(node->arguments[0])); + + // Variable argument patterns + if (node->matches("?and", 0, -1)) + { + auto pattern = std::make_unique(); + for (auto &arg : node->arguments) + pattern->AND(aPattern(arg).release()); + return pattern; + } + if (node->matches("?or", 0, -1)) + { + auto pattern = std::make_unique(); + + for (auto &arg : node->arguments) + pattern->OR(aPattern(arg).release()); + return pattern; + } + node->error(rstrprintf("Unrecognized pattern '%s'", node->term.to_string().c_str())); return nullptr; -- cgit v1.2.3