Revert to use std::strtof insted of std::stof to make travis happy

This commit is contained in:
teejusb
2020-04-08 22:41:19 -07:00
parent 1d365fbc18
commit 620ef3609d
+5 -23
View File
@@ -1877,38 +1877,20 @@ void MakeLower( wchar_t *p, size_t iLen )
float StringToFloat( const RString &sString ) float StringToFloat( const RString &sString )
{ {
try float fOut = std::strtof(sString, nullptr);
{
float fOut = std::stof(sString);
if (!isfinite(fOut)) if (!isfinite(fOut))
{ {
fOut = 0.0f; fOut = 0.0f;
} }
return fOut; return fOut;
}
catch(...)
{
return 0.0f;
}
} }
bool StringToFloat( const RString &sString, float &fOut ) bool StringToFloat( const RString &sString, float &fOut )
{ {
try char *endPtr = nullptr;
{
fOut = std::stof(sString); fOut = std::strtof(sString, &endPtr);
if (!isfinite(fOut)) return sString.size() && *endPtr == '\0' && isfinite(fOut);
{
fOut = 0.0f;
return false;
}
return true;
}
catch(...)
{
fOut = 0.0f;
return false;
}
} }
RString FloatToString( const float &num ) RString FloatToString( const float &num )