diff options
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/util.cpp b/src/util.cpp index 0d0f7e5f91..4192e44ae1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -346,6 +346,21 @@ bool SoftSetBoolArg(const std::string& strArg, bool fValue) return SoftSetArg(strArg, std::string("0")); } +static const int screenWidth = 79; +static const int optIndent = 2; +static const int msgIndent = 7; + +std::string HelpMessageGroup(const std::string &message) { + return std::string(message) + std::string("\n\n"); +} + +std::string HelpMessageOpt(const std::string &option, const std::string &message) { + return std::string(optIndent,' ') + std::string(option) + + std::string("\n") + std::string(msgIndent,' ') + + FormatParagraph(message, screenWidth - msgIndent, msgIndent) + + std::string("\n\n"); +} + static std::string FormatException(const std::exception* pex, const char* pszThread) { #ifdef WIN32 @@ -698,13 +713,8 @@ void RenameThread(const char* name) // removed. pthread_set_name_np(pthread_self(), name); -#elif defined(MAC_OSX) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) - -// pthread_setname_np is XCode 10.6-and-later -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 +#elif defined(MAC_OSX) pthread_setname_np(name); -#endif - #else // Prevent warnings for unused parameters... (void)name; @@ -713,18 +723,18 @@ void RenameThread(const char* name) void SetupEnvironment() { -#ifndef WIN32 - try - { -#if BOOST_FILESYSTEM_VERSION == 3 - boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid -#else // boost filesystem v2 - std::locale(); // Raises runtime error if current locale is invalid -#endif + // On most POSIX systems (e.g. Linux, but not BSD) the environment's locale + // may be invalid, in which case the "C" locale is used as fallback. +#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) + try { + std::locale(""); // Raises a runtime error if current locale is invalid } catch (const std::runtime_error&) { - setenv("LC_ALL", "C", 1); // Force C locale + std::locale::global(std::locale("C")); } #endif + // The path locale is lazy initialized and to avoid deinitialization errors + // in multithreading environments, it is set explicitly by the main thread. + boost::filesystem::path::imbue(std::locale()); } void SetThreadPriority(int nPriority) |