summaryrefslogtreecommitdiff
path: root/src/expr.cc
diff options
context:
space:
mode:
authorTorsten Paul <Torsten.Paul@gmx.de>2013-11-10 01:42:58 (GMT)
committerTorsten Paul <Torsten.Paul@gmx.de>2013-11-11 00:31:44 (GMT)
commit00a329f0bd4ab940c1063106ee6ba7db7811a090 (patch)
tree26872901c9cbc603e7a62b14975e306b0e146885 /src/expr.cc
parente5d535e900ae5bc5923fc76c80fb3b3f9153a80e (diff)
Add support for handling negative step values in ranges (fixes #500).
Diffstat (limited to 'src/expr.cc')
-rw-r--r--src/expr.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/expr.cc b/src/expr.cc
index 594fccf..51accf3 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -117,11 +117,18 @@ Value Expression::evaluate(const Context *context) const
if (this->type == "R") {
Value v1 = this->children[0]->evaluate(context);
Value v2 = this->children[1]->evaluate(context);
- Value v3 = this->children[2]->evaluate(context);
- if (v1.type() == Value::NUMBER && v2.type() == Value::NUMBER && v3.type() == Value::NUMBER) {
- Value::RangeType range(v1.toDouble(), v2.toDouble(), v3.toDouble());
- return Value(range);
- }
+ if (this->children.size() == 2) {
+ if (v1.type() == Value::NUMBER && v2.type() == Value::NUMBER) {
+ Value::RangeType range(v1.toDouble(), v2.toDouble());
+ return Value(range);
+ }
+ } else {
+ Value v3 = this->children[2]->evaluate(context);
+ if (v1.type() == Value::NUMBER && v2.type() == Value::NUMBER && v3.type() == Value::NUMBER) {
+ Value::RangeType range(v1.toDouble(), v2.toDouble(), v3.toDouble());
+ return Value(range);
+ }
+ }
return Value();
}
if (this->type == "V") {
contact: Jan Huwald // Impressum