@@ -403,20 +403,20 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
403
403
if (key.length () > 1 && key[1 ] == ' -' )
404
404
key.erase (0 , 1 );
405
405
406
- // Check for -nofoo
407
- if (InterpretNegatedOption (key, val)) {
408
- m_override_args[key].clear ();
409
- } else {
410
- m_override_args[key].push_back (val);
411
- }
412
-
413
406
// Check that the arg is known
414
407
if (!(IsSwitchChar (key[0 ]) && key.size () == 1 )) {
415
408
if (!IsArgKnown (key)) {
416
409
error = strprintf (" Invalid parameter %s" , key.c_str ());
417
410
return false ;
418
411
}
419
412
}
413
+
414
+ // Check for -nofoo
415
+ if (InterpretNegatedOption (key, val)) {
416
+ m_override_args[key].clear ();
417
+ } else {
418
+ m_override_args[key].push_back (val);
419
+ }
420
420
}
421
421
422
422
// we do not allow -includeconf from command line, so we clear it here
@@ -434,17 +434,23 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
434
434
435
435
bool ArgsManager::IsArgKnown (const std::string& key) const
436
436
{
437
+ assert (key[0 ] == ' -' );
438
+
437
439
size_t option_index = key.find (' .' );
438
- std::string arg_no_net;
439
440
if (option_index == std::string::npos) {
440
- arg_no_net = key ;
441
+ option_index = 1 ;
441
442
} else {
442
- arg_no_net = std::string ( " - " ) + key. substr (option_index + 1 , std::string::npos) ;
443
+ ++option_index ;
443
444
}
445
+ if (key.substr (option_index, 2 ) == " no" ) {
446
+ option_index += 2 ;
447
+ }
448
+
449
+ const std::string base_arg_name = ' -' + key.substr (option_index);
444
450
445
451
LOCK (cs_args);
446
452
for (const auto & arg_map : m_available_args) {
447
- if (arg_map.second .count (arg_no_net )) return true ;
453
+ if (arg_map.second .count (base_arg_name )) return true ;
448
454
}
449
455
return false ;
450
456
}
@@ -840,23 +846,23 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
840
846
}
841
847
for (const std::pair<std::string, std::string>& option : options) {
842
848
std::string strKey = std::string (" -" ) + option.first ;
843
- std::string strValue = option.second ;
844
-
845
- if (InterpretNegatedOption (strKey, strValue)) {
846
- m_config_args[strKey].clear ();
847
- } else {
848
- m_config_args[strKey].push_back (strValue);
849
- }
850
-
851
849
// Check that the arg is known
852
850
if (!IsArgKnown (strKey)) {
853
851
if (!ignore_invalid_keys) {
854
852
error = strprintf (" Invalid configuration value %s" , option.first .c_str ());
855
853
return false ;
856
854
} else {
857
855
LogPrintf (" Ignoring unknown configuration value %s\n " , option.first );
856
+ continue ;
858
857
}
859
858
}
859
+
860
+ std::string strValue = option.second ;
861
+ if (InterpretNegatedOption (strKey, strValue)) {
862
+ m_config_args[strKey].clear ();
863
+ } else {
864
+ m_config_args[strKey].push_back (strValue);
865
+ }
860
866
}
861
867
return true ;
862
868
}
0 commit comments