diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·55+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·55+0100 |
commit | 867055133d3f487e52dd44149f76347c2c28bf10 (patch) | |
tree | c367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/libexpr/json-to-value.cc | |
parent | c6a31838cd7e88ebcb01422b329a499d04ab4b6b (diff) |
style(3p/nix): Add braces around single-line conditionals r/771
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
Diffstat (limited to 'third_party/nix/src/libexpr/json-to-value.cc')
-rw-r--r-- | third_party/nix/src/libexpr/json-to-value.cc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/third_party/nix/src/libexpr/json-to-value.cc b/third_party/nix/src/libexpr/json-to-value.cc index 8d84a5ac6901..a7d9c4904c8e 100644 --- a/third_party/nix/src/libexpr/json-to-value.cc +++ b/third_party/nix/src/libexpr/json-to-value.cc @@ -12,9 +12,13 @@ static void skipWhitespace(const char*& s) { static string parseJSONString(const char*& s) { string res; - if (*s++ != '"') throw JSONParseError("expected JSON string"); + if (*s++ != '"') { + throw JSONParseError("expected JSON string"); + } while (*s != '"') { - if (!*s) throw JSONParseError("got end-of-string in JSON string"); + if (!*s) { + throw JSONParseError("got end-of-string in JSON string"); + } if (*s == '\\') { s++; if (*s == '"') @@ -52,7 +56,9 @@ static string parseJSONString(const char*& s) { static void parseJSON(EvalState& state, const char*& s, Value& v) { skipWhitespace(s); - if (!*s) throw JSONParseError("expected JSON value"); + if (!*s) { + throw JSONParseError("expected JSON value"); + } if (*s == '[') { s++; @@ -60,7 +66,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) { values.reserve(128); skipWhitespace(s); while (1) { - if (values.empty() && *s == ']') break; + if (values.empty() && *s == ']') { + break; + } Value* v2 = state.allocValue(); parseJSON(state, s, *v2); values.push_back(v2); @@ -82,10 +90,14 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) { ValueMap attrs; while (1) { skipWhitespace(s); - if (attrs.empty() && *s == '}') break; + if (attrs.empty() && *s == '}') { + break; + } string name = parseJSONString(s); skipWhitespace(s); - if (*s != ':') throw JSONParseError("expected ':' in JSON object"); + if (*s != ':') { + throw JSONParseError("expected ':' in JSON object"); + } s++; Value* v2 = state.allocValue(); parseJSON(state, s, *v2); @@ -114,7 +126,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) { ValueType number_type = tInt; while (isdigit(*s) || *s == '-' || *s == '.' || *s == 'e' || *s == 'E') { - if (*s == '.' || *s == 'e' || *s == 'E') number_type = tFloat; + if (*s == '.' || *s == 'e' || *s == 'E') { + number_type = tFloat; + } tmp_number += *s++; } |