Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use self-descriptive name for config file parser, document #11037

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/libutil/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ void Config::getSettings(std::map<std::string, SettingInfo> & res, bool overridd
}


static void applyConfigInner(const std::string & contents, const std::string & path, std::vector<std::pair<std::string, std::string>> & parsedContents) {
/**
* Parse configuration in `contents`, and also the configuration files included from there, with their location specified relative to `path`.
*
* `contents` and `path` represent the file that is being parsed.
* The result is only an intermediate list of key-value pairs of strings.
* More parsing according to the settings-specific semantics is being done by `loadConfFile` in `libstore/globals.cc`.
*/
static void parseConfigFiles(const std::string & contents, const std::string & path, std::vector<std::pair<std::string, std::string>> & parsedContents) {
unsigned int pos = 0;

while (pos < contents.size()) {
Expand Down Expand Up @@ -125,7 +132,7 @@ static void applyConfigInner(const std::string & contents, const std::string & p
if (pathExists(p)) {
try {
std::string includedContents = readFile(p);
applyConfigInner(includedContents, p, parsedContents);
parseConfigFiles(includedContents, p, parsedContents);
} catch (SystemError &) {
// TODO: Do we actually want to ignore this? Or is it better to fail?
}
Expand Down Expand Up @@ -153,7 +160,7 @@ static void applyConfigInner(const std::string & contents, const std::string & p
void AbstractConfig::applyConfig(const std::string & contents, const std::string & path) {
std::vector<std::pair<std::string, std::string>> parsedContents;

applyConfigInner(contents, path, parsedContents);
parseConfigFiles(contents, path, parsedContents);

// First apply experimental-feature related settings
for (const auto & [name, value] : parsedContents)
Expand Down
Loading