Skip to content

Commit 71aaff3

Browse files
committed
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.
1 parent a99f9be commit 71aaff3

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/util.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ void ParseParameters(int argc, const char* const argv[])
459459
{
460460
mapArgs.clear();
461461
mapMultiArgs.clear();
462+
462463
for (int i = 1; i < argc; i++)
463464
{
464465
std::string str(argv[i]);
@@ -474,29 +475,24 @@ void ParseParameters(int argc, const char* const argv[])
474475
if (boost::algorithm::starts_with(str, "/"))
475476
str = "-" + str.substr(1);
476477
#endif
478+
477479
if (str[0] != '-')
478480
break;
479481

482+
// Interpret --foo as -foo.
483+
// If both --foo and -foo are set, the last takes effect.
484+
if (str.length() > 1 && str[1] == '-')
485+
str = str.substr(1);
486+
480487
mapArgs[str] = strValue;
481488
mapMultiArgs[str].push_back(strValue);
482489
}
483490

484491
// New 0.6 features:
485492
BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs)
486493
{
487-
string name = entry.first;
488-
489-
// interpret --foo as -foo (as long as both are not set)
490-
if (name.find("--") == 0)
491-
{
492-
std::string singleDash(name.begin()+1, name.end());
493-
if (mapArgs.count(singleDash) == 0)
494-
mapArgs[singleDash] = entry.second;
495-
name = singleDash;
496-
}
497-
498494
// interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
499-
InterpretNegativeSetting(name, mapArgs);
495+
InterpretNegativeSetting(entry.first, mapArgs);
500496
}
501497
}
502498

0 commit comments

Comments
 (0)