Skip to content

Commit 8047fb0

Browse files
committed
Merge pull request #4193
71aaff3 Remove double-dash parameters from mapArgs (Kosta Zertsekel)
2 parents fe1f417 + 71aaff3 commit 8047fb0

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
@@ -460,6 +460,7 @@ void ParseParameters(int argc, const char* const argv[])
460460
{
461461
mapArgs.clear();
462462
mapMultiArgs.clear();
463+
463464
for (int i = 1; i < argc; i++)
464465
{
465466
std::string str(argv[i]);
@@ -475,29 +476,24 @@ void ParseParameters(int argc, const char* const argv[])
475476
if (boost::algorithm::starts_with(str, "/"))
476477
str = "-" + str.substr(1);
477478
#endif
479+
478480
if (str[0] != '-')
479481
break;
480482

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

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

0 commit comments

Comments
 (0)