summaryrefslogtreecommitdiff
path: root/apt-pkg/cachefilter-patterns.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-02-01 17:04:58 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-02-03 12:54:42 +0100
commitbcb9ecb2cd2208d12b83c4e111be7c126b49dc7e (patch)
tree8987ecc069ec9d77254897c16f83fa6412b22575 /apt-pkg/cachefilter-patterns.cc
parent2746cd503accc4d995a9c11f294dbbc560997292 (diff)
patterns: Provide Node constructor, simplify error throwing
By having a node constructor, we can construct a node inline for error reporting needs, simplifying the code a bit.
Diffstat (limited to 'apt-pkg/cachefilter-patterns.cc')
-rw-r--r--apt-pkg/cachefilter-patterns.cc13
1 files changed, 3 insertions, 10 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc
index a9f76ff1d..b21f70d6a 100644
--- a/apt-pkg/cachefilter-patterns.cc
+++ b/apt-pkg/cachefilter-patterns.cc
@@ -33,13 +33,7 @@ std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseTop()
skipSpace();
if (node->end != sentence.size())
- {
- Node node2;
-
- node2.start = node->end;
- node2.end = sentence.size();
- throw Error{node2, "Expected end of file"};
- }
+ throw Error{Node{node->end, sentence.size()}, "Expected end of file"};
return node;
}
@@ -55,9 +49,8 @@ std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parse()
if ((node = parseWord()) != nullptr)
return node;
- Node eNode;
- eNode.end = eNode.start = state.offset;
- throw Error{eNode, "Expected pattern, quoted word, or word"};
+ throw Error{Node{state.offset, sentence.size()},
+ "Expected pattern, quoted word, or word"};
}
// Parse a list pattern (or function call pattern)