style(3p/nix): Enforce braces around loops and conditionals

This change was generated with:

  fd -e cc -e hh | xargs -I{} clang-tidy {} -p ~/projects/nix-build/ \
    --checks='-*,readability-braces-around-statements' --fix \
    -fix-errors

Some manual fixes were applied because some convoluted unbraced
statements couldn't be untangled by clang-tidy.

This commit still includes invalid files, but I decided to clean them
up in a subsequent commit so that it becomes more obvious where
clang-tidy failed. Maybe this will allow for a bug-report to
clang-tidy.
This commit is contained in:
Vincent Ambo 2020-05-19 17:38:04 +01:00
parent c758de9d22
commit b490742a51
44 changed files with 661 additions and 298 deletions

View file

@ -5,7 +5,9 @@
namespace nix {
static void skipWhitespace(const char*& s) {
while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r') s++;
while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r') {
s++;
}
}
static string parseJSONString(const char*& s) {
@ -39,8 +41,10 @@ static string parseJSONString(const char*& s) {
else
throw JSONParseError("invalid escaped character in JSON string");
s++;
} else
res += *s++;
} else {
res
}
+= *s++;
}
s++;
return res;
@ -62,7 +66,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
parseJSON(state, s, *v2);
values.push_back(v2);
skipWhitespace(s);
if (*s == ']') break;
if (*s == ']') {
break;
}
if (*s != ',')
throw JSONParseError("expected ',' or ']' after JSON array element");
s++;
@ -86,7 +92,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
parseJSON(state, s, *v2);
attrs[state.symbols.create(name)] = v2;
skipWhitespace(s);
if (*s == '}') break;
if (*s == '}') {
break;
}
if (*s != ',')
throw JSONParseError("expected ',' or '}' after JSON member");
s++;