diff options
author | 2019-09-10 21:37:36 +0200 | |
---|---|---|
committer | 2019-09-10 21:37:36 +0200 | |
commit | 7dea07a3baecfafe630a0613db0ca919f12d5f4c (patch) | |
tree | 530540f619589a763dde4c282452654328b11fdb /src/lib/netlist/plib/pfmtlog.cpp | |
parent | 53df4f447db0408d00bdcbee3105e013bdd19c3a (diff) |
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.
Diffstat (limited to 'src/lib/netlist/plib/pfmtlog.cpp')
-rw-r--r-- | src/lib/netlist/plib/pfmtlog.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
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 <cstdlib> #include <cstring> #include <iostream> -#include <locale> +#include <clocale> namespace plib { @@ -26,6 +26,10 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) std::array<char, 2048> 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; } |