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 <cstdio> // snprintf
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <algorithm> // std::find_if, std::max
|
#include <algorithm> // std::find_if, std::max
|
||||||
|
#include <iomanip>
|
||||||
|
#include <locale>
|
||||||
|
#include <sstream>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
using namespace reshadefx;
|
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*/";
|
s += std::signbit(data.as_float[i]) ? "1.0/0.0/*inf*/" : "-1.0/0.0/*-inf*/";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char temp[64]; // Will be null-terminated by snprintf
|
{
|
||||||
std::snprintf(temp, sizeof(temp), "%1.8e", data.as_float[i]);
|
std::ostringstream ss;
|
||||||
s += temp;
|
ss.imbue(std::locale::classic());
|
||||||
|
ss << std::fixed << data.as_float[i];
|
||||||
|
s += ss.str();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring> // stricmp
|
#include <cstring> // stricmp
|
||||||
#include <algorithm> // std::find_if, std::max
|
#include <algorithm> // std::find_if, std::max
|
||||||
|
#include <iomanip>
|
||||||
|
#include <locale>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
using namespace reshadefx;
|
using namespace reshadefx;
|
||||||
|
|
||||||
|
@ -339,9 +342,12 @@ private:
|
||||||
s += std::signbit(data.as_float[i]) ? "1.#INF" : "-1.#INF";
|
s += std::signbit(data.as_float[i]) ? "1.#INF" : "-1.#INF";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char temp[64]; // Will be null-terminated by snprintf
|
{
|
||||||
std::snprintf(temp, sizeof(temp), "%1.8e", data.as_float[i]);
|
std::ostringstream ss;
|
||||||
s += temp;
|
ss.imbue(std::locale::classic());
|
||||||
|
ss << std::fixed << data.as_float[i];
|
||||||
|
s += ss.str();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
Loading…
Reference in New Issue