Commit fdf54b5f authored by Eben Blaisdell's avatar Eben Blaisdell

bcfe math ops default to zero on parse error

parent 3474879a
......@@ -141,6 +141,14 @@ function get(varName, scope){
return null;
}
function dzParseFloat(str){
var num = dzParseFloat(str);
if(num == NaN){
return 0;
}
return num;
}
function evalBool(strBool){
return (falsey.indexOf(strBool.toLowerCase()) == -1);
}
......@@ -232,8 +240,8 @@ builtinfuncs = {
return boolStr(ex0 != ex1);
}
else{
num0 = parseFloat(ex0);
num1 = parseFloat(ex1);
num0 = dzParseFloat(ex0);
num1 = dzParseFloat(ex1);
switch(op){
case "=":
return boolStr(num0 == num1);
......@@ -251,8 +259,8 @@ builtinfuncs = {
}
},
bimath:function (scope){
num0 = parseFloat(ea(0,scope));
num1 = parseFloat(ea(2,scope));
num0 = dzParseFloat(ea(0,scope));
num1 = dzParseFloat(ea(2,scope));
op = ea(1,scope);
switch(op){
case "+":
......@@ -274,9 +282,9 @@ builtinfuncs = {
case "length":
return ea(1,scope).length;
case "substr":
start = parseFloat(ea(2,scope));
start = dzParseFloat(ea(2,scope));
if(scope.args.hasOwnProperty(3)){
length = parseFloat(ea(3,scope));
length = dzParseFloat(ea(3,scope));
return ea(1,scope).substring(start,start + length);
}
else{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment