dep/reshadefx: Avoid snprintf() when writing float constants
Locale-specific, causes breakage on some systems.
This commit is contained in:
parent
e0911d7f54
commit
2d2bc93ada
|
@ -9,6 +9,9 @@
|
|||
#include <cstdio> // snprintf
|
||||
#include <cassert>
|
||||
#include <algorithm> // std::find_if, std::max
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace reshadefx;
|
||||
|
@ -360,9 +363,12 @@ private:
|
|||
s += std::signbit(data.as_float[i]) ? "1.0/0.0/*inf*/" : "-1.0/0.0/*-inf*/";
|
||||
break;
|
||||
}
|
||||
char temp[64]; // Will be null-terminated by snprintf
|
||||
std::snprintf(temp, sizeof(temp), "%1.8e", data.as_float[i]);
|
||||
s += temp;
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss.imbue(std::locale::classic());
|
||||
ss << std::fixed << data.as_float[i];
|
||||
s += ss.str();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include <cassert>
|
||||
#include <cstring> // stricmp
|
||||
#include <algorithm> // std::find_if, std::max
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
|
||||
using namespace reshadefx;
|
||||
|
||||
|
@ -339,9 +342,12 @@ private:
|
|||
s += std::signbit(data.as_float[i]) ? "1.#INF" : "-1.#INF";
|
||||
break;
|
||||
}
|
||||
char temp[64]; // Will be null-terminated by snprintf
|
||||
std::snprintf(temp, sizeof(temp), "%1.8e", data.as_float[i]);
|
||||
s += temp;
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss.imbue(std::locale::classic());
|
||||
ss << std::fixed << data.as_float[i];
|
||||
s += ss.str();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
|
Loading…
Reference in New Issue