Changed: Replaced atoi and atof by NLMISC::fromString
This commit is contained in:
parent
793d8fb8c4
commit
2ad2fea0bc
4 changed files with 10 additions and 6 deletions
|
@ -1499,7 +1499,7 @@ void cf_setVar (NLMISC::CConfigFile::CVar &Var, cf_value Val)
|
|||
switch (Val.Type)
|
||||
{
|
||||
case NLMISC::CConfigFile::CVar::T_REAL: Var.IntValues.push_back ((int)Val.Real); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: Var.IntValues.push_back (atoi(Val.String)); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: int val = 0; NLMISC::fromString(Val.String, val); Var.IntValues.push_back(val); break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
|
@ -1507,7 +1507,7 @@ void cf_setVar (NLMISC::CConfigFile::CVar &Var, cf_value Val)
|
|||
switch (Val.Type)
|
||||
{
|
||||
case NLMISC::CConfigFile::CVar::T_INT: Var.RealValues.push_back ((double)Val.Int); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: Var.RealValues.push_back (atof(Val.String)); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: double val = 0.0; NLMISC::fromString(Val.String, val); Var.RealValues.push_back(val); break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -517,7 +517,7 @@ void cf_setVar (NLMISC::CConfigFile::CVar &Var, cf_value Val)
|
|||
switch (Val.Type)
|
||||
{
|
||||
case NLMISC::CConfigFile::CVar::T_REAL: Var.IntValues.push_back ((int)Val.Real); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: Var.IntValues.push_back (atoi(Val.String)); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: int val = 0; NLMISC::fromString(Val.String, val); Var.RealValues.push_back(val); break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
|
@ -525,7 +525,7 @@ void cf_setVar (NLMISC::CConfigFile::CVar &Var, cf_value Val)
|
|||
switch (Val.Type)
|
||||
{
|
||||
case NLMISC::CConfigFile::CVar::T_INT: Var.RealValues.push_back ((double)Val.Int); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: Var.RealValues.push_back (atof(Val.String)); break;
|
||||
case NLMISC::CConfigFile::CVar::T_STRING: double val = 0.0; NLMISC::fromString(Val.String, val); Var.RealValues.push_back(val); break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -2337,7 +2337,7 @@ YY_RULE_SETUP
|
|||
if (!cf_Ignore)
|
||||
{
|
||||
cflval.Val.Type = T_REAL;
|
||||
cflval.Val.Real = atof (yytext);
|
||||
NLMISC::fromString(yytext, cflval.Val.Real);
|
||||
DEBUG_PRINTF("lex: real '%s' '%f\n", yytext, cflval.Val.Real);
|
||||
return REAL;
|
||||
}
|
||||
|
|
|
@ -85,8 +85,12 @@ double CConfigFile::CVar::asDouble (int index) const
|
|||
if (index >= (int)IntValues.size () || index < 0) throw EBadSize (Name, (int)IntValues.size (), index);
|
||||
return (double)IntValues[index];
|
||||
case T_STRING:
|
||||
{
|
||||
if (index >= (int)StrValues.size () || index < 0) throw EBadSize (Name, (int)StrValues.size (), index);
|
||||
return atof(StrValues[index].c_str());
|
||||
double val;
|
||||
NLMISC::fromString(StrValues[index], val);
|
||||
return val;
|
||||
}
|
||||
default:
|
||||
if (index >= (int)RealValues.size () || index < 0) throw EBadSize (Name, (int)RealValues.size (), index);
|
||||
return RealValues[index];
|
||||
|
|
Loading…
Reference in a new issue