aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYRabbit <rabbit@yrabbit.cyou>2022-03-16 05:39:55 +1000
committerYRabbit <rabbit@yrabbit.cyou>2022-03-16 05:39:55 +1000
commit53ddbbaa8584bac463718ba4837d1ee8f79d88c4 (patch)
treeaae65a6534963dccc9a5a70a24facce9cd870698
parentad00f3fdeb9e48a63c2781815d265266123f2621 (diff)
downloadnextpnr-53ddbbaa8584bac463718ba4837d1ee8f79d88c4.tar.gz
nextpnr-53ddbbaa8584bac463718ba4837d1ee8f79d88c4.tar.bz2
nextpnr-53ddbbaa8584bac463718ba4837d1ee8f79d88c4.zip
Set the locale as early as possible
Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
-rw-r--r--common/command.cc10
-rw-r--r--gowin/main.cc9
2 files changed, 9 insertions, 10 deletions
diff --git a/common/command.cc b/common/command.cc
index 2167deb9..0de9ccc4 100644
--- a/common/command.cc
+++ b/common/command.cc
@@ -45,7 +45,15 @@
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()
{
diff --git a/gowin/main.cc b/gowin/main.cc
index e3c6762b..19c1d02c 100644
--- a/gowin/main.cc
+++ b/gowin/main.cc
@@ -91,15 +91,6 @@ void GowinCommandHandler::customAfterLoad(Context *ctx)
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);
return handler.exec();
}