No longer accept and silently convert invalid REAL tokens to zero

This commit is contained in:
Thomas Krijnen
2014-03-22 13:02:21 +00:00
parent b6a811ae7e
commit bd02aac18a
+5 -1
View File
@@ -345,7 +345,11 @@ bool TokenFunc::asBool(const Token& t) {
}
double TokenFunc::asFloat(const Token& t) {
const std::string str = asString(t);
return (double) atof(str.c_str());
const char* start = str.c_str();
char* end;
double result = strtod(start,&end);
if ( start == end ) throw IfcException("Token is not a real");
return result;
}
std::string TokenFunc::asString(const Token& t) {
if ( isOperator(t,'$') ) return "";