diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-20T21·27+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-20T21·27+0100 |
commit | 689ef502f5b0655c9923ed77da2ae3504630f473 (patch) | |
tree | 3e331c153646f136875f047cc3b9f0aad8c86341 /third_party/nix/src/libutil/args.cc | |
parent | d331d3a0b5c497a46e2636f308234be66566c04c (diff) |
refactor(3p/nix): Apply clang-tidy's readability-* fixes r/788
This applies the readability fixes listed here: https://clang.llvm.org/extra/clang-tidy/checks/list.html
Diffstat (limited to 'third_party/nix/src/libutil/args.cc')
-rw-r--r-- | third_party/nix/src/libutil/args.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/third_party/nix/src/libutil/args.cc b/third_party/nix/src/libutil/args.cc index 92343d88e5a3..2b4407480254 100644 --- a/third_party/nix/src/libutil/args.cc +++ b/third_party/nix/src/libutil/args.cc @@ -7,9 +7,9 @@ namespace nix { Args::FlagMaker Args::mkFlag() { return FlagMaker(*this); } Args::FlagMaker::~FlagMaker() { - assert(flag->longName != ""); + assert(!flag->longName.empty()); args.longFlags[flag->longName] = flag; - if (flag->shortName) { + if (flag->shortName != 0) { args.shortFlags[flag->shortName] = flag; } } @@ -26,12 +26,12 @@ void Args::parseCmdline(const Strings& _cmdline) { /* Expand compound dash options (i.e., `-qlf' -> `-q -l -f', `-j3` -> `-j 3`). */ if (!dashDash && arg.length() > 2 && arg[0] == '-' && arg[1] != '-' && - isalpha(arg[1])) { + (isalpha(arg[1]) != 0)) { *pos = (string) "-" + arg[1]; auto next = pos; ++next; for (unsigned int j = 2; j < arg.length(); j++) { - if (isalpha(arg[j])) { + if (isalpha(arg[j]) != 0) { cmdline.insert(next, (string) "-" + arg[j]); } else { cmdline.insert(next, string(arg, j)); @@ -74,11 +74,11 @@ void Args::printHelp(const string& programName, std::ostream& out) { std::cout << "\n"; auto s = description(); - if (s != "") { + if (!s.empty()) { std::cout << "\nSummary: " << s << ".\n"; } - if (longFlags.size()) { + if (!longFlags.empty() != 0u) { std::cout << "\n"; std::cout << "Flags:\n"; printFlags(out); @@ -88,11 +88,11 @@ void Args::printHelp(const string& programName, std::ostream& out) { void Args::printFlags(std::ostream& out) { Table2 table; for (auto& flag : longFlags) { - if (hiddenCategories.count(flag.second->category)) { + if (hiddenCategories.count(flag.second->category) != 0u) { continue; } table.push_back(std::make_pair( - (flag.second->shortName + (flag.second->shortName != 0 ? std::string("-") + flag.second->shortName + ", " : " ") + "--" + flag.first + renderLabels(flag.second->labels), @@ -188,7 +188,7 @@ Strings argvToStrings(int argc, char** argv) { Strings args; argc--; argv++; - while (argc--) { + while ((argc--) != 0) { args.push_back(*argv++); } return args; |