From 7dea07a3baecfafe630a0613db0ca919f12d5f4c Mon Sep 17 00:00:00 2001 From: couriersud Date: Tue, 10 Sep 2019 21:37:36 +0200 Subject: netlist: Fix exception on MacOSX [Couriersud] Some unknown system library seems to force the use of the global locale on OSX. This is not the case for other *nix or Windows builds. This commit fixes this by forcing the C locale in pfmt. --- src/lib/netlist/plib/pfmtlog.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp index a58ecd3113a..a42546629cf 100644 --- a/src/lib/netlist/plib/pfmtlog.cpp +++ b/src/lib/netlist/plib/pfmtlog.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include namespace plib { @@ -26,6 +26,10 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) std::array buf = {0}; std::size_t sl; bool found_abs = false; + pstring old_locale(std::setlocale(LC_ALL, nullptr)); + + if (old_locale != "C") + std::setlocale(LC_ALL, "C"); m_arg++; @@ -97,6 +101,8 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) m_str = m_str.substr(0, p) + pstring(buf.data()) + m_str.substr(p + sl); va_end(ap); } while (found_abs); + if (old_locale != "C") + std::setlocale(LC_ALL, old_locale.c_str()); return *this; } -- cgit v1.2.3