aboutsummaryrefslogtreecommitdiffstats
path: root/lllc/main.cpp
diff options
context:
space:
mode:
authorChristopher Gilbert <christopher.john.gilbert@gmail.com>2016-08-31 03:32:30 +0800
committerChristopher Gilbert <christopher.john.gilbert@gmail.com>2016-08-31 03:32:30 +0800
commit68bd463bea5d5a17b90e76ee7f1bff0593775ca8 (patch)
treed1a196de1779252d0f9dbacd052d57c660deb345 /lllc/main.cpp
parenta91bca7937e7f6ffdc84c998eade6d38fb08cbb9 (diff)
downloaddexon-solidity-68bd463bea5d5a17b90e76ee7f1bff0593775ca8.tar
dexon-solidity-68bd463bea5d5a17b90e76ee7f1bff0593775ca8.tar.gz
dexon-solidity-68bd463bea5d5a17b90e76ee7f1bff0593775ca8.tar.bz2
dexon-solidity-68bd463bea5d5a17b90e76ee7f1bff0593775ca8.tar.lz
dexon-solidity-68bd463bea5d5a17b90e76ee7f1bff0593775ca8.tar.xz
dexon-solidity-68bd463bea5d5a17b90e76ee7f1bff0593775ca8.tar.zst
dexon-solidity-68bd463bea5d5a17b90e76ee7f1bff0593775ca8.zip
Code review changes: Renamed function and added some documentation about what the function does and why
Diffstat (limited to 'lllc/main.cpp')
-rw-r--r--lllc/main.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/lllc/main.cpp b/lllc/main.cpp
index ed91c0a2..ecd0de99 100644
--- a/lllc/main.cpp
+++ b/lllc/main.cpp
@@ -53,9 +53,22 @@ void version()
exit(0);
}
-void setEnv()
+/*
+The equivalent of setlocale(LC_ALL, ā€œCā€) is called before any user code is run.
+If the user has an invalid environment setting then it is possible for the call
+to set locale to fail, so there are only two possible actions, the first is to
+throw a runtime exception and cause the program to quit (default behaviour),
+or the second is to modify the environment to something sensible (least
+surprising behaviour).
+
+The follow code produces the least surprising behaviour. It will use the user
+specified default locale if it is valid, and if not then it will modify the
+environment the process is running in to use a sensible default. This also means
+that users do not need to install language packs for their OS.
+*/
+void setDefaultOrCLocale()
{
-#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+#if __unix__
if (!std::setlocale(LC_ALL, ""))
{
setenv("LC_ALL", "C", 1);
@@ -67,7 +80,7 @@ enum Mode { Binary, Hex, Assembly, ParseTree, Disassemble };
int main(int argc, char** argv)
{
- setEnv();
+ setDefaultOrCLocale();
unsigned optimise = 1;
string infile;
Mode mode = Hex;