aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorChris Moore <dooglus@gmail.com>2012-02-16 12:08:32 -0800
committerChris Moore <dooglus@gmail.com>2012-02-16 12:08:58 -0800
commitd64e124cf4212a9e5b4607c4f752a0c2921bc308 (patch)
treee8a5de135eba5f53f3e226933c45cac01f065e0f /src/util.cpp
parentb7c25e0c1346256be12310264ea5cc4ce7794118 (diff)
Fix #846. Allow negative options such as "nolisten=1" in bitcoin.conf as well as on the command line.
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 12ac076f0d..f1af91de27 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -454,6 +454,21 @@ vector<unsigned char> ParseHex(const string& str)
return ParseHex(str.c_str());
}
+static void InterpretNegativeSetting(string name, map<string, string>& mapSettingsRet)
+{
+ // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
+ if (name.find("-no") == 0)
+ {
+ std::string positive("-");
+ positive.append(name.begin()+3, name.end());
+ if (mapSettingsRet.count(positive) == 0)
+ {
+ bool value = !GetBoolArg(name);
+ mapSettingsRet[positive] = (value ? "1" : "0");
+ }
+ }
+}
+
void ParseParameters(int argc, const char*const argv[])
{
mapArgs.clear();
@@ -494,17 +509,8 @@ void ParseParameters(int argc, const char*const argv[])
name = singleDash;
}
- // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1, as long as -foo not set)
- if (name.find("-no") == 0)
- {
- std::string positive("-");
- positive.append(name.begin()+3, name.end());
- if (mapArgs.count(positive) == 0)
- {
- bool value = !GetBoolArg(name);
- mapArgs[positive] = (value ? "1" : "0");
- }
- }
+ // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
+ InterpretNegativeSetting(name, mapArgs);
}
}
@@ -920,7 +926,11 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
// Don't overwrite existing settings so command line settings override bitcoin.conf
string strKey = string("-") + it->string_key;
if (mapSettingsRet.count(strKey) == 0)
+ {
mapSettingsRet[strKey] = it->value[0];
+ // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set)
+ InterpretNegativeSetting(strKey, mapSettingsRet);
+ }
mapMultiSettingsRet[strKey].push_back(it->value[0]);
}
}