OpenBSD doesn't support per-thread locales.

This commit is contained in:
Anthony J. Bentley 2016-07-17 04:08:44 -06:00
parent 242c770fe5
commit 5c90738638

View File

@ -28,7 +28,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
#if !defined(_WIN32) && !defined(ANDROID) #if !defined(_WIN32) && !defined(ANDROID) && !defined(__OpenBSD__)
static locale_t GetCLocale() static locale_t GetCLocale()
{ {
static locale_t c_locale = newlocale(LC_ALL_MASK, "C", nullptr); static locale_t c_locale = newlocale(LC_ALL_MASK, "C", nullptr);
@ -121,11 +121,11 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
c_locale = _create_locale(LC_ALL, "C"); c_locale = _create_locale(LC_ALL, "C");
writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args); writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args);
#else #else
#if !defined(ANDROID) #if !defined(ANDROID) && !defined(__OpenBSD__)
locale_t previousLocale = uselocale(GetCLocale()); locale_t previousLocale = uselocale(GetCLocale());
#endif #endif
writtenCount = vsnprintf(out, outsize, format, args); writtenCount = vsnprintf(out, outsize, format, args);
#if !defined(ANDROID) #if !defined(ANDROID) && !defined(__OpenBSD__)
uselocale(previousLocale); uselocale(previousLocale);
#endif #endif
#endif #endif
@ -162,12 +162,12 @@ std::string StringFromFormatV(const char* format, va_list args)
std::string temp = buf; std::string temp = buf;
delete[] buf; delete[] buf;
#else #else
#if !defined(ANDROID) #if !defined(ANDROID) && !defined(__OpenBSD__)
locale_t previousLocale = uselocale(GetCLocale()); locale_t previousLocale = uselocale(GetCLocale());
#endif #endif
if (vasprintf(&buf, format, args) < 0) if (vasprintf(&buf, format, args) < 0)
ERROR_LOG(COMMON, "Unable to allocate memory for string"); ERROR_LOG(COMMON, "Unable to allocate memory for string");
#if !defined(ANDROID) #if !defined(ANDROID) && !defined(__OpenBSD__)
uselocale(previousLocale); uselocale(previousLocale);
#endif #endif