diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-02-01 17:11:19 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2020-02-03 12:55:54 +0100 |
commit | cfec457d599373e6014b1f4472f48d5f989d76a5 (patch) | |
tree | 3ce58c0bd67baa380cc79a8527ccf0d08dbba3a6 /apt-pkg/cachefilter-patterns.cc | |
parent | 775be4274e5c5427079e26d3ebe3c7f2f5f6b76a (diff) |
patterns: Allow rendering patterns as patterns instead of json-ish
Diffstat (limited to 'apt-pkg/cachefilter-patterns.cc')
-rw-r--r-- | apt-pkg/cachefilter-patterns.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index dbf58e2a9..dbe42b83f 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -285,20 +285,21 @@ std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseWord() // Rendering of the tree in JSON for debugging std::ostream &PatternTreeParser::PatternNode::render(std::ostream &os) { - os << "{" - << "\"term\": \"" << term.to_string() << "\",\n" - << "\"arguments\": [\n"; - for (auto &node : arguments) - node->render(os) << "," << std::endl; - os << "null]\n"; - os << "}\n"; + + os << term.to_string(); + if (haveArgumentList) + { + os << "("; + for (auto &node : arguments) + node->render(os) << ","; + os << ")"; + } return os; } std::ostream &PatternTreeParser::WordNode::render(std::ostream &os) { - os << '"' << word.to_string() << '"'; - return os; + return quoted ? os << '"' << word.to_string() << '"' : os << word.to_string(); } std::nullptr_t PatternTreeParser::Node::error(std::string message) |