diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-12-07 15:04:30 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2020-12-07 15:11:20 +0100 |
commit | f9a621d335622a8909177f6d347e32e3876fde3f (patch) | |
tree | c6d915fdba268e745c34f36b6290460e14c229b5 /apt-pkg | |
parent | d63772845a28a08ea9c812ad8ac281cf9e0ae12a (diff) |
patterns: Terminate short pattern by ~ and !
This allows patterns like ~nalpha~nbeta and ~nalpha!~nbeta to
work like they do in APT.
Also add a comment to remind readers that everything in START
should be in short too.
Cc: stable >= 2.0
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cachefilter-patterns.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index bc0eece30..fded7d92f 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -333,9 +333,12 @@ std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseQuotedWord() // Parse a bare word atom std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseWord(bool shrt) { + // Characters not allowed at the start of a word (also see ..._SHRT) static const constexpr auto DISALLOWED_START = "!?~|,() \0"_sv; + // Characters terminating a word inside a long pattern static const constexpr auto DISALLOWED_LONG = "|,()\0"_sv; - static const constexpr auto DISALLOWED_SHRT = "|,() ?\0"_sv; + // Characters terminating a word as a short form argument, should contain all of START. + static const constexpr auto DISALLOWED_SHRT = "!?~|,() \0"_sv; const auto DISALLOWED = shrt ? DISALLOWED_SHRT : DISALLOWED_LONG; if (DISALLOWED_START.find(sentence[state.offset]) != APT::StringView::npos) |