mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Code review changes: Renamed function and added some documentation about what the function does and why
This commit is contained in:
parent
a91bca7937
commit
68bd463bea
@ -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;
|
||||
|
@ -27,9 +27,22 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
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);
|
||||
@ -39,7 +52,7 @@ void setEnv()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
setEnv();
|
||||
setDefaultOrCLocale();
|
||||
dev::solidity::CommandLineInterface cli;
|
||||
if (!cli.parseArguments(argc, argv))
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user