Set the locale as early as possible

Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
This commit is contained in:
YRabbit 2022-03-16 05:39:55 +10:00
parent ad00f3fdeb
commit 53ddbbaa85
2 changed files with 9 additions and 10 deletions

View File

@ -45,7 +45,15 @@
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
CommandHandler::CommandHandler(int argc, char **argv) : argc(argc), argv(argv) { log_streams.clear(); } CommandHandler::CommandHandler(int argc, char **argv) : argc(argc), argv(argv)
{
try {
std::locale::global(std::locale(""));
} catch (const std::runtime_error &e) {
// the locale is broken in this system, so leave it as it is
}
log_streams.clear();
}
bool CommandHandler::parseOptions() bool CommandHandler::parseOptions()
{ {

View File

@ -91,15 +91,6 @@ void GowinCommandHandler::customAfterLoad(Context *ctx)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// set the locale here because when you create a context you create several
// floating point strings whose representation depends on the locale. If
// you don't do this, the strings will be in the C locale and later when Qt
// starts it won't be able to read them back as numbers.
try {
std::locale::global(std::locale(""));
} catch (const std::runtime_error &e) {
// the locale is broken in this system, so leave it as it is
}
GowinCommandHandler handler(argc, argv); GowinCommandHandler handler(argc, argv);
return handler.exec(); return handler.exec();
} }