Skip to content

Commit 3da7849

Browse files
committed
[squashme] simplify SetupEnvironment() (by dexX7)
1 parent b3ffcdf commit 3da7849

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/util.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,21 +726,21 @@ void RenameThread(const char* name)
726726

727727
void SetupEnvironment()
728728
{
729-
std::locale loc("C");
730729
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale
731730
// may be invalid, in which case the "C" locale is used as fallback.
732731
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
733732
try {
734-
loc = std::locale(""); // Raises a runtime error if current locale is invalid
733+
std::locale(""); // Raises a runtime error if current locale is invalid
735734
} catch (const std::runtime_error&) {
736735
setenv("LC_ALL", "C", 1);
737736
}
738737
#endif
739-
// The path locale is lazy initialized and to avoid deinitialization errors
738+
// The path locale is lazy initialized and to avoid deinitialization errors
740739
// in multithreading environments, it is set explicitly by the main thread.
741-
#if !defined(WIN32)
740+
// A dummy locale is used to extract the internal default locale, used by
741+
// boost::filesystem::path, which is then used to explicitly imbue the path.
742+
std::locale loc = boost::filesystem::path::imbue(std::locale::classic());
742743
boost::filesystem::path::imbue(loc);
743-
#endif
744744
}
745745

746746
void SetThreadPriority(int nPriority)

0 commit comments

Comments
 (0)