Skip to content

Commit 819435d

Browse files
committed
Call setlocale("C") along with setting global classic locale (gh #156)
1 parent 82977c7 commit 819435d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/dwarfs/safe_main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,21 @@ int safe_main(std::function<int(void)> fn) {
4444
#endif
4545
try {
4646
std::locale::global(std::locale(locale));
47+
if (!std::setlocale(LC_ALL, locale)) {
48+
std::cerr << "warning: setlocale(LC_ALL, \"\") failed\n";
49+
}
4750
} catch (std::exception const& e) {
4851
std::cerr << "warning: failed to set user default locale\n";
4952
try {
5053
std::locale::global(std::locale::classic());
54+
if (!std::setlocale(LC_ALL, "C")) {
55+
std::cerr << "warning: setlocale(LC_ALL, \"C\") failed\n";
56+
}
5157
} catch (std::exception const& e) {
5258
std::cerr << "warning: also failed to set classic locale\n";
5359
}
5460
}
5561

56-
if (!std::setlocale(LC_ALL, locale)) {
57-
std::cerr << "warning: setlocale(LC_ALL, \"\") failed\n";
58-
}
59-
6062
setup_terminal();
6163

6264
return fn();

0 commit comments

Comments
 (0)