mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Fix argument parsing oddity with -noX
`bitcoind -X -noX` ends up, unintuitively, with `X` set. (for all boolean options X) This result is due to the odd two-pass processing of arguments. This patch fixes this oddity and simplifies the code at the same time.
This commit is contained in:
@@ -60,18 +60,18 @@ BOOST_AUTO_TEST_CASE(boolarg)
|
||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||
|
||||
ResetArgs("-foo -nofoo"); // -foo should win
|
||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||
|
||||
ResetArgs("-foo=1 -nofoo=1"); // -foo should win
|
||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||
|
||||
ResetArgs("-foo=0 -nofoo=0"); // -foo should win
|
||||
ResetArgs("-foo -nofoo"); // -nofoo should win
|
||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||
|
||||
ResetArgs("-foo=1 -nofoo=1"); // -nofoo should win
|
||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||
|
||||
ResetArgs("-foo=0 -nofoo=0"); // -nofoo=0 should win
|
||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||
|
||||
// New 0.6 feature: treat -- same as -:
|
||||
ResetArgs("--foo=1");
|
||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||
@@ -150,9 +150,9 @@ BOOST_AUTO_TEST_CASE(boolargno)
|
||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||
|
||||
ResetArgs("-foo --nofoo");
|
||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||
ResetArgs("-foo --nofoo"); // --nofoo should win
|
||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||
|
||||
ResetArgs("-nofoo -foo"); // foo always wins:
|
||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||
|
||||
Reference in New Issue
Block a user