summaryrefslogtreecommitdiff
path: root/src/control.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-12-09 04:12:13 (GMT)
committerMarius Kintel <marius@kintel.net>2013-12-09 04:12:13 (GMT)
commit462d4d447885594629fefb8a658f9f1d079bcc44 (patch)
tree6690951e4f814b87a1a372a913b75ceda1f6cc1a /src/control.cc
parent435e0c021c5018ee5de69d3218c3e31c8ab75be5 (diff)
parent33c34b6f7c43d19bbfa3bf91e7b577bcc062e5bd (diff)
Merge branch 'master' into travis
Diffstat (limited to 'src/control.cc')
-rw-r--r--src/control.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/control.cc b/src/control.cc
index 10aadf0..d5f664e 100644
--- a/src/control.cc
+++ b/src/control.cc
@@ -78,12 +78,14 @@ void ControlModule::for_eval(AbstractNode &node, const ModuleInstantiation &inst
Context c(ctx);
if (it_values.type() == Value::RANGE) {
Value::RangeType range = it_values.toRange();
- range.normalize();
- if (range.nbsteps()<10000) {
- for (double i = range.begin; i <= range.end; i += range.step) {
- c.set_variable(it_name, Value(i));
- for_eval(node, inst, l+1, &c, evalctx);
- }
+ uint32_t steps = range.nbsteps();
+ if (steps >= 10000) {
+ PRINTB("WARNING: Bad range parameter in for statement: too many elements (%lu).", steps);
+ } else {
+ for (Value::RangeType::iterator it = range.begin();it != range.end();it++) {
+ c.set_variable(it_name, Value(*it));
+ for_eval(node, inst, l+1, &c, evalctx);
+ }
}
}
else if (it_values.type() == Value::VECTOR) {
@@ -227,13 +229,13 @@ AbstractNode *ControlModule::instantiate(const Context* /*ctx*/, const ModuleIns
else if (value.type() == Value::RANGE) {
AbstractNode* node = new AbstractNode(inst);
Value::RangeType range = value.toRange();
- range.normalize();
- if (range.nbsteps()>=10000) {
- PRINTB("WARNING: Bad range parameter for children: too many elements (%d).", (int)((range.begin-range.end)/range.step));
+ uint32_t steps = range.nbsteps();
+ if (steps >= 10000) {
+ PRINTB("WARNING: Bad range parameter for children: too many elements (%lu).", steps);
return NULL;
}
- for (double i = range.begin; i <= range.end; i += range.step) {
- AbstractNode* childnode = getChild(Value(i),modulectx); // with error cases
+ for (Value::RangeType::iterator it = range.begin();it != range.end();it++) {
+ AbstractNode* childnode = getChild(Value(*it),modulectx); // with error cases
if (childnode==NULL) continue; // error
node->children.push_back(childnode);
}
contact: Jan Huwald // Impressum