mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Fix lack of warning of unrecognized section names
1. Fix lack of warning by collecting all section names by moving m_config_sections.clear() to ArgsManager::ReadConfigFiles(). 2. Add info(file name, line number) to warning message. 3. Add a test code to confirm this situation. 3. Do clear() in ReadConfigString().
This commit is contained in:
@@ -132,6 +132,13 @@ enum class OptionsCategory {
|
||||
HIDDEN // Always the last option to avoid printing these in the help
|
||||
};
|
||||
|
||||
struct SectionInfo
|
||||
{
|
||||
std::string m_name;
|
||||
std::string m_file;
|
||||
int m_line;
|
||||
};
|
||||
|
||||
class ArgsManager
|
||||
{
|
||||
protected:
|
||||
@@ -152,9 +159,9 @@ protected:
|
||||
std::string m_network GUARDED_BY(cs_args);
|
||||
std::set<std::string> m_network_only_args GUARDED_BY(cs_args);
|
||||
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
|
||||
std::set<std::string> m_config_sections GUARDED_BY(cs_args);
|
||||
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
||||
|
||||
NODISCARD bool ReadConfigStream(std::istream& stream, std::string& error, bool ignore_invalid_keys = false);
|
||||
NODISCARD bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
|
||||
|
||||
public:
|
||||
ArgsManager();
|
||||
@@ -178,7 +185,7 @@ public:
|
||||
/**
|
||||
* Log warnings for unrecognized section names in the config file.
|
||||
*/
|
||||
const std::set<std::string> GetUnrecognizedSections() const;
|
||||
const std::list<SectionInfo> GetUnrecognizedSections() const;
|
||||
|
||||
/**
|
||||
* Return a vector of strings of the given argument
|
||||
|
||||
Reference in New Issue
Block a user