Skip to content

Commit

Permalink
Remove double-dash parameters from mapArgs
Browse files Browse the repository at this point in the history
Should be merged after pull request bitcoin#4281
("Add `-version` option to get just the version bitcoin#4281"),
because is changed "--help" to "-help".

Checked that grep of 'mapArgs.count("--' returned only
three places that are fixed by pull request bitcoin#4281.
  • Loading branch information
kostaz committed Jun 4, 2014
1 parent a99f9be commit 71aaff3
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ void ParseParameters(int argc, const char* const argv[])
{
mapArgs.clear();
mapMultiArgs.clear();

for (int i = 1; i < argc; i++)
{
std::string str(argv[i]);
Expand All @@ -474,29 +475,24 @@ void ParseParameters(int argc, const char* const argv[])
if (boost::algorithm::starts_with(str, "/"))
str = "-" + str.substr(1);
#endif

if (str[0] != '-')
break;

// Interpret --foo as -foo.
// If both --foo and -foo are set, the last takes effect.
if (str.length() > 1 && str[1] == '-')
str = str.substr(1);

mapArgs[str] = strValue;
mapMultiArgs[str].push_back(strValue);
}

// New 0.6 features:
BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs)
{
string name = entry.first;

// interpret --foo as -foo (as long as both are not set)
if (name.find("--") == 0)
{
std::string singleDash(name.begin()+1, name.end());
if (mapArgs.count(singleDash) == 0)
mapArgs[singleDash] = entry.second;
name = singleDash;
}

// interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
InterpretNegativeSetting(name, mapArgs);
InterpretNegativeSetting(entry.first, mapArgs);
}
}

Expand Down

0 comments on commit 71aaff3

Please sign in to comment.