Skip to content

Commit 2325413

Browse files
committed
Merge pull request #6093
3da7849 [squashme] simplify SetupEnvironment() (by dexX7) (Jonas Schnelli) b3ffcdf don't imbue boost::filesystem::path with locale "C" on windows (Jonas Schnelli)
2 parents 7eb6618 + 3da7849 commit 2325413

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/util.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,18 +726,20 @@ 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.
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());
741743
boost::filesystem::path::imbue(loc);
742744
}
743745

0 commit comments

Comments
 (0)