Remove double-dash parameters from mapArgs
Should be merged after pull request #4281 ("Add `-version` option to get just the version #4281"), because is changed "--help" to "-help". Checked that grep of 'mapArgs.count("--' returned only three places that are fixed by pull request #4281.
This commit is contained in:
parent
a99f9be0eb
commit
71aaff393f
1 changed files with 8 additions and 12 deletions
20
src/util.cpp
20
src/util.cpp
|
@ -459,6 +459,7 @@ void ParseParameters(int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
mapArgs.clear();
|
mapArgs.clear();
|
||||||
mapMultiArgs.clear();
|
mapMultiArgs.clear();
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
std::string str(argv[i]);
|
std::string str(argv[i]);
|
||||||
|
@ -474,9 +475,15 @@ void ParseParameters(int argc, const char* const argv[])
|
||||||
if (boost::algorithm::starts_with(str, "/"))
|
if (boost::algorithm::starts_with(str, "/"))
|
||||||
str = "-" + str.substr(1);
|
str = "-" + str.substr(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (str[0] != '-')
|
if (str[0] != '-')
|
||||||
break;
|
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;
|
mapArgs[str] = strValue;
|
||||||
mapMultiArgs[str].push_back(strValue);
|
mapMultiArgs[str].push_back(strValue);
|
||||||
}
|
}
|
||||||
|
@ -484,19 +491,8 @@ void ParseParameters(int argc, const char* const argv[])
|
||||||
// New 0.6 features:
|
// New 0.6 features:
|
||||||
BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs)
|
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
|
// interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
|
||||||
InterpretNegativeSetting(name, mapArgs);
|
InterpretNegativeSetting(entry.first, mapArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue