style(3p/nix): Add braces around single-line conditionals
These were not caught by the previous clang-tidy invocation, but were
instead sorted out using amber[0] as such:
ambr --regex 'if (\(.+\))\s([a-z].*;)' 'if $1 { $2 }'
[0]: https://github.com/dalance/amber
This commit is contained in:
parent
c6a31838cd
commit
867055133d
97 changed files with 2223 additions and 753 deletions
24
third_party/nix/src/libutil/config.cc
vendored
24
third_party/nix/src/libutil/config.cc
vendored
|
|
@ -11,7 +11,9 @@ namespace nix {
|
|||
|
||||
bool Config::set(const std::string& name, const std::string& value) {
|
||||
auto i = _settings.find(name);
|
||||
if (i == _settings.end()) return false;
|
||||
if (i == _settings.end()) {
|
||||
return false;
|
||||
}
|
||||
i->second.setting->set(value);
|
||||
i->second.setting->overriden = true;
|
||||
return true;
|
||||
|
|
@ -84,10 +86,14 @@ void AbstractConfig::applyConfigFile(const Path& path) {
|
|||
pos++;
|
||||
|
||||
string::size_type hash = line.find('#');
|
||||
if (hash != string::npos) line = string(line, 0, hash);
|
||||
if (hash != string::npos) {
|
||||
line = string(line, 0, hash);
|
||||
}
|
||||
|
||||
vector<string> tokens = tokenizeString<vector<string> >(line);
|
||||
if (tokens.empty()) continue;
|
||||
if (tokens.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tokens.size() < 2)
|
||||
throw UsageError("illegal configuration line '%1%' in '%2%'", line,
|
||||
|
|
@ -147,7 +153,9 @@ void Config::toJSON(JSONObject& out) {
|
|||
|
||||
void Config::convertToArgs(Args& args, const std::string& category) {
|
||||
for (auto& s : _settings)
|
||||
if (!s.second.isAlias) s.second.setting->convertToArg(args, category);
|
||||
if (!s.second.isAlias) {
|
||||
s.second.setting->convertToArg(args, category);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractSetting::AbstractSetting(const std::string& name,
|
||||
|
|
@ -284,7 +292,9 @@ void PathSetting::set(const std::string& str) {
|
|||
|
||||
bool GlobalConfig::set(const std::string& name, const std::string& value) {
|
||||
for (auto& config : *configRegistrations)
|
||||
if (config->set(name, value)) return true;
|
||||
if (config->set(name, value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
unknownSettings.emplace(name, value);
|
||||
|
||||
|
|
@ -315,7 +325,9 @@ GlobalConfig globalConfig;
|
|||
GlobalConfig::ConfigRegistrations* GlobalConfig::configRegistrations;
|
||||
|
||||
GlobalConfig::Register::Register(Config* config) {
|
||||
if (!configRegistrations) configRegistrations = new ConfigRegistrations;
|
||||
if (!configRegistrations) {
|
||||
configRegistrations = new ConfigRegistrations;
|
||||
}
|
||||
configRegistrations->emplace_back(config);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue