Merge pull request #123 from nikitoz/master

Add std namespace for pow, ldexp, sscanf function calls.
This commit is contained in:
Syoyo Fujita
2017-02-23 00:35:52 +09:00
committed by GitHub

View File

@@ -529,7 +529,7 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) {
// NOTE: Don't use powf here, it will absolutely murder precision. // NOTE: Don't use powf here, it will absolutely murder precision.
mantissa += static_cast<int>(*curr - 0x30) * mantissa += static_cast<int>(*curr - 0x30) *
(read < lut_entries ? pow_lut[read] : pow(10.0, -read)); (read < lut_entries ? pow_lut[read] : std::pow(10.0, -read));
read++; read++;
curr++; curr++;
end_not_reached = (curr != s_end); end_not_reached = (curr != s_end);
@@ -571,7 +571,7 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) {
assemble: assemble:
*result = *result =
(sign == '+' ? 1 : -1) * (sign == '+' ? 1 : -1) *
(exponent ? ldexp(mantissa * pow(5.0, exponent), exponent) : mantissa); (exponent ? std::ldexp(mantissa * std::pow(5.0, exponent), exponent) : mantissa);
return true; return true;
fail: fail:
return false; return false;
@@ -1020,7 +1020,7 @@ void LoadMtl(std::map<std::string, int> *material_map,
#ifdef _MSC_VER #ifdef _MSC_VER
sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
#else #else
sscanf(token, "%s", namebuf); std::sscanf(token, "%s", namebuf);
#endif #endif
material.name = namebuf; material.name = namebuf;
continue; continue;
@@ -1522,7 +1522,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
#ifdef _MSC_VER #ifdef _MSC_VER
sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
#else #else
sscanf(token, "%s", namebuf); std::sscanf(token, "%s", namebuf);
#endif #endif
int newMaterialId = -1; int newMaterialId = -1;
@@ -1642,7 +1642,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
#ifdef _MSC_VER #ifdef _MSC_VER
sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
#else #else
sscanf(token, "%s", namebuf); std::sscanf(token, "%s", namebuf);
#endif #endif
name = std::string(namebuf); name = std::string(namebuf);
@@ -1657,7 +1657,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
#ifdef _MSC_VER #ifdef _MSC_VER
sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
#else #else
sscanf(token, "%s", namebuf); std::sscanf(token, "%s", namebuf);
#endif #endif
tag.name = std::string(namebuf); tag.name = std::string(namebuf);
@@ -1686,7 +1686,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
sscanf_s(token, "%s", stringValueBuffer, sscanf_s(token, "%s", stringValueBuffer,
(unsigned)_countof(stringValueBuffer)); (unsigned)_countof(stringValueBuffer));
#else #else
sscanf(token, "%s", stringValueBuffer); std::sscanf(token, "%s", stringValueBuffer);
#endif #endif
tag.stringValues[i] = stringValueBuffer; tag.stringValues[i] = stringValueBuffer;
token += tag.stringValues[i].size() + 1; token += tag.stringValues[i].size() + 1;
@@ -1833,7 +1833,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
sscanf_s(token, "%s", namebuf, sscanf_s(token, "%s", namebuf,
static_cast<unsigned int>(_countof(namebuf))); static_cast<unsigned int>(_countof(namebuf)));
#else #else
sscanf(token, "%s", namebuf); std::sscanf(token, "%s", namebuf);
#endif #endif
int newMaterialId = -1; int newMaterialId = -1;
@@ -1947,7 +1947,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
#ifdef _MSC_VER #ifdef _MSC_VER
sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
#else #else
sscanf(token, "%s", namebuf); std::sscanf(token, "%s", namebuf);
#endif #endif
std::string object_name = std::string(namebuf); std::string object_name = std::string(namebuf);
@@ -1967,7 +1967,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
#ifdef _MSC_VER #ifdef _MSC_VER
sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
#else #else
sscanf(token, "%s", namebuf); std::sscanf(token, "%s", namebuf);
#endif #endif
tag.name = std::string(namebuf); tag.name = std::string(namebuf);
@@ -1996,7 +1996,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
sscanf_s(token, "%s", stringValueBuffer, sscanf_s(token, "%s", stringValueBuffer,
(unsigned)_countof(stringValueBuffer)); (unsigned)_countof(stringValueBuffer));
#else #else
sscanf(token, "%s", stringValueBuffer); std::sscanf(token, "%s", stringValueBuffer);
#endif #endif
tag.stringValues[i] = stringValueBuffer; tag.stringValues[i] = stringValueBuffer;
token += tag.stringValues[i].size() + 1; token += tag.stringValues[i].size() + 1;