Commit 828ec8fa by alokp@chromium.org

Builds for chrome memroy bots (windows only) do not link due to the usage of…

Builds for chrome memroy bots (windows only) do not link due to the usage of std::locale, the reason for which is still unknown. This patch avoids the usage of std::locale, while still enforcing "C" locale and checking for overflow. Review URL: https://codereview.appspot.com/6392046 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1203 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8963ec2a
......@@ -7,6 +7,9 @@
#include "Token.h"
#include <cassert>
#include <cerrno>
#include <cfloat>
#include <cstdlib>
#include <sstream>
template<typename IntType>
......@@ -89,10 +92,18 @@ bool Token::fValue(float* value) const
{
assert(type == CONST_FLOAT);
std::istringstream stream(text);
stream.imbue(std::locale("C"));
stream >> (*value);
return !stream.fail();
errno = 0;
double dValue = strtod(text.c_str(), NULL);
// Note that we do not need to check for negative numbers because the
// minus sign is never part of the token.
if ((errno == ERANGE) || (dValue > FLT_MAX))
{
errno = 0;
*value = FLT_MAX;
return false;
}
*value = static_cast<float>(dValue);
return true;
}
std::ostream& operator<<(std::ostream& out, const Token& token)
......
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