diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T19·47+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T19·51+0100 |
commit | 39087321811e81e26a1a47d6967df1088dcf0e95 (patch) | |
tree | 57110be423eeb7869e9960466f4b17c0ea7cd961 /third_party/nix/src/libutil/args.cc | |
parent | cf40d08908ede4061eb15513b770c98877844b8b (diff) |
style(3p/nix): Final act in the brace-wrapping saga r/777
This last change set was generated by a full clang-tidy run (including compilation): clang-tidy -p ~/projects/nix-build/ \ -checks=-*,readability-braces-around-statements -fix src/*/*.cc Actually running clang-tidy requires some massaging to make it play nice with Nix + meson, I'll be adding a wrapper or something for that soon.
Diffstat (limited to 'third_party/nix/src/libutil/args.cc')
-rw-r--r-- | third_party/nix/src/libutil/args.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/third_party/nix/src/libutil/args.cc b/third_party/nix/src/libutil/args.cc index be1d915819e3..92343d88e5a3 100644 --- a/third_party/nix/src/libutil/args.cc +++ b/third_party/nix/src/libutil/args.cc @@ -30,13 +30,14 @@ void Args::parseCmdline(const Strings& _cmdline) { *pos = (string) "-" + arg[1]; auto next = pos; ++next; - for (unsigned int j = 2; j < arg.length(); j++) - if (isalpha(arg[j])) + for (unsigned int j = 2; j < arg.length(); j++) { + if (isalpha(arg[j])) { cmdline.insert(next, (string) "-" + arg[j]); - else { + } else { cmdline.insert(next, string(arg, j)); break; } + } arg = *pos; } @@ -44,8 +45,9 @@ void Args::parseCmdline(const Strings& _cmdline) { dashDash = true; ++pos; } else if (!dashDash && std::string(arg, 0, 1) == "-") { - if (!processFlag(pos, cmdline.end())) + if (!processFlag(pos, cmdline.end())) { throw UsageError(format("unrecognised flag '%1%'") % arg); + } } else { pendingArgs.push_back(*pos++); if (processArgs(pendingArgs, false)) { @@ -141,8 +143,9 @@ bool Args::processFlag(Strings::iterator& pos, Strings::iterator end) { bool Args::processArgs(const Strings& args, bool finish) { if (expectedArgs.empty()) { - if (!args.empty()) + if (!args.empty()) { throw UsageError(format("unexpected argument '%1%'") % args.front()); + } return true; } @@ -161,8 +164,9 @@ bool Args::processArgs(const Strings& args, bool finish) { res = true; } - if (finish && !expectedArgs.empty() && !expectedArgs.front().optional) + if (finish && !expectedArgs.empty() && !expectedArgs.front().optional) { throw UsageError("more arguments are required"); + } return res; } @@ -184,7 +188,9 @@ Strings argvToStrings(int argc, char** argv) { Strings args; argc--; argv++; - while (argc--) args.push_back(*argv++); + while (argc--) { + args.push_back(*argv++); + } return args; } |