diff options
author | chriseth <chris@ethereum.org> | 2016-09-01 03:20:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 03:20:05 +0800 |
commit | b962d3c071f2f476d8ea05dd9869565175c2cd65 (patch) | |
tree | dfdd358f93c809af43811abf4e093a003853cb2f /lllc | |
parent | 9714bcf6ebd2aede1889df4c15426c51dfe46292 (diff) | |
parent | 68bd463bea5d5a17b90e76ee7f1bff0593775ca8 (diff) | |
download | dexon-solidity-b962d3c071f2f476d8ea05dd9869565175c2cd65.tar dexon-solidity-b962d3c071f2f476d8ea05dd9869565175c2cd65.tar.gz dexon-solidity-b962d3c071f2f476d8ea05dd9869565175c2cd65.tar.bz2 dexon-solidity-b962d3c071f2f476d8ea05dd9869565175c2cd65.tar.lz dexon-solidity-b962d3c071f2f476d8ea05dd9869565175c2cd65.tar.xz dexon-solidity-b962d3c071f2f476d8ea05dd9869565175c2cd65.tar.zst dexon-solidity-b962d3c071f2f476d8ea05dd9869565175c2cd65.zip |
Merge pull request #975 from blockchaindev/bug/674-solc-crash
solc crashes without 'export LC_ALL=C'
Diffstat (limited to 'lllc')
-rw-r--r-- | lllc/main.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lllc/main.cpp b/lllc/main.cpp index a4c92d67..ecd0de99 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -22,6 +22,7 @@ #include <fstream> #include <iostream> +#include <clocale> #include <liblll/Compiler.h> #include <libdevcore/CommonIO.h> #include <libdevcore/CommonData.h> @@ -52,10 +53,34 @@ void version() exit(0); } +/* +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 __unix__ + if (!std::setlocale(LC_ALL, "")) + { + setenv("LC_ALL", "C", 1); + } +#endif +} + enum Mode { Binary, Hex, Assembly, ParseTree, Disassemble }; int main(int argc, char** argv) { + setDefaultOrCLocale(); unsigned optimise = 1; string infile; Mode mode = Hex; |