diff options
Diffstat (limited to 'third_party/nix/src/nix')
-rw-r--r-- | third_party/nix/src/nix/command.cc | 9 | ||||
-rw-r--r-- | third_party/nix/src/nix/command.hh | 2 | ||||
-rw-r--r-- | third_party/nix/src/nix/installables.cc | 12 | ||||
-rw-r--r-- | third_party/nix/src/nix/legacy.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/nix/log.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/nix/main.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/nix/optimise-store.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/nix/repl.cc | 8 | ||||
-rw-r--r-- | third_party/nix/src/nix/run.cc | 11 | ||||
-rw-r--r-- | third_party/nix/src/nix/search.cc | 5 | ||||
-rw-r--r-- | third_party/nix/src/nix/show-config.cc | 2 |
11 files changed, 31 insertions, 26 deletions
diff --git a/third_party/nix/src/nix/command.cc b/third_party/nix/src/nix/command.cc index b35fb1be9898..b0efcb823dd6 100644 --- a/third_party/nix/src/nix/command.cc +++ b/third_party/nix/src/nix/command.cc @@ -1,11 +1,13 @@ #include "command.hh" +#include <utility> + #include "derivations.hh" #include "store-api.hh" namespace nix { -Commands* RegisterCommand::commands = 0; +Commands* RegisterCommand::commands = nullptr; void Command::printHelp(const string& programName, std::ostream& out) { Args::printHelp(programName, out); @@ -22,7 +24,8 @@ void Command::printHelp(const string& programName, std::ostream& out) { } } -MultiCommand::MultiCommand(const Commands& _commands) : commands(_commands) { +MultiCommand::MultiCommand(Commands _commands) + : commands(std::move(_commands)) { expectedArgs.push_back(ExpectedArg{ "command", 1, true, [=](std::vector<std::string> ss) { assert(!command); @@ -82,7 +85,7 @@ bool MultiCommand::processArgs(const Strings& args, bool finish) { } } -StoreCommand::StoreCommand() {} +StoreCommand::StoreCommand() = default; ref<Store> StoreCommand::getStore() { if (!_store) { diff --git a/third_party/nix/src/nix/command.hh b/third_party/nix/src/nix/command.hh index a86f4782133f..829ce080d3a2 100644 --- a/third_party/nix/src/nix/command.hh +++ b/third_party/nix/src/nix/command.hh @@ -149,7 +149,7 @@ class MultiCommand : virtual Args { std::shared_ptr<Command> command; - MultiCommand(const Commands& commands); + MultiCommand(Commands commands); void printHelp(const string& programName, std::ostream& out) override; diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc index 2d896e3bb9bb..06419f1f122d 100644 --- a/third_party/nix/src/nix/installables.cc +++ b/third_party/nix/src/nix/installables.cc @@ -1,4 +1,5 @@ #include <regex> +#include <utility> #include "attr-path.hh" #include "command.hh" @@ -100,7 +101,8 @@ Buildable Installable::toBuildable() { struct InstallableStorePath : Installable { Path storePath; - explicit InstallableStorePath(const Path& storePath) : storePath(storePath) {} + explicit InstallableStorePath(Path storePath) + : storePath(std::move(storePath)) {} std::string what() override { return storePath; } @@ -160,8 +162,8 @@ struct InstallableValue : Installable { struct InstallableExpr : InstallableValue { std::string text; - InstallableExpr(SourceExprCommand& cmd, const std::string& text) - : InstallableValue(cmd), text(text) {} + InstallableExpr(SourceExprCommand& cmd, std::string text) + : InstallableValue(cmd), text(std::move(text)) {} std::string what() override { return text; } @@ -175,8 +177,8 @@ struct InstallableExpr : InstallableValue { struct InstallableAttrPath : InstallableValue { std::string attrPath; - InstallableAttrPath(SourceExprCommand& cmd, const std::string& attrPath) - : InstallableValue(cmd), attrPath(attrPath) {} + InstallableAttrPath(SourceExprCommand& cmd, std::string attrPath) + : InstallableValue(cmd), attrPath(std::move(attrPath)) {} std::string what() override { return attrPath; } diff --git a/third_party/nix/src/nix/legacy.cc b/third_party/nix/src/nix/legacy.cc index 2860afe53a49..b851392b4276 100644 --- a/third_party/nix/src/nix/legacy.cc +++ b/third_party/nix/src/nix/legacy.cc @@ -2,6 +2,6 @@ namespace nix { -RegisterLegacyCommand::Commands* RegisterLegacyCommand::commands = 0; +RegisterLegacyCommand::Commands* RegisterLegacyCommand::commands = nullptr; } diff --git a/third_party/nix/src/nix/log.cc b/third_party/nix/src/nix/log.cc index 29107bbdcdff..86f133e94a7a 100644 --- a/third_party/nix/src/nix/log.cc +++ b/third_party/nix/src/nix/log.cc @@ -8,7 +8,7 @@ using namespace nix; struct CmdLog : InstallableCommand { - CmdLog() {} + CmdLog() = default; std::string name() override { return "log"; } diff --git a/third_party/nix/src/nix/main.cc b/third_party/nix/src/nix/main.cc index 23bc62887a88..54285bfa9313 100644 --- a/third_party/nix/src/nix/main.cc +++ b/third_party/nix/src/nix/main.cc @@ -179,7 +179,7 @@ void mainWrapped(int argc, char** argv) { } // namespace nix int main(int argc, char* argv[]) { - FLAGS_logtostderr = 1; + FLAGS_logtostderr = true; google::InitGoogleLogging(argv[0]); return nix::handleExceptions(argv[0], diff --git a/third_party/nix/src/nix/optimise-store.cc b/third_party/nix/src/nix/optimise-store.cc index 7814a1bcabf0..5fdcfb742465 100644 --- a/third_party/nix/src/nix/optimise-store.cc +++ b/third_party/nix/src/nix/optimise-store.cc @@ -7,7 +7,7 @@ using namespace nix; struct CmdOptimiseStore : StoreCommand { - CmdOptimiseStore() {} + CmdOptimiseStore() = default; std::string name() override { return "optimise-store"; } diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 80921f77dcfb..9567ad4315db 100644 --- a/third_party/nix/src/nix/repl.cc +++ b/third_party/nix/src/nix/repl.cc @@ -1,10 +1,10 @@ #include <climits> +#include <csetjmp> #include <cstdlib> #include <cstring> #include <iostream> #include <glog/logging.h> -#include <setjmp.h> #ifdef READLINE #include <readline/history.h> @@ -73,7 +73,7 @@ struct NixRepl { Expr* parseString(string s); void evalString(string s, Value& v); - typedef set<Value*> ValuesSeen; + using ValuesSeen = set<Value*>; std::ostream& printValue(std::ostream& str, Value& v, unsigned int maxDepth); std::ostream& printValue(std::ostream& str, Value& v, unsigned int maxDepth, ValuesSeen& seen); @@ -306,7 +306,7 @@ bool NixRepl::getLine(string& input, const std::string& prompt) { throw SysError("restoring signals"); } - if (sigaction(SIGINT, &old, 0)) { + if (sigaction(SIGINT, &old, nullptr)) { throw SysError("restoring handler for SIGINT"); } }; @@ -358,7 +358,7 @@ StringSet NixRepl::completePrefix(string prefix) { } } else if ((dot = cur.rfind('.')) == string::npos) { /* This is a variable name; look it up in the current scope. */ - StringSet::iterator i = varNames.lower_bound(cur); + auto i = varNames.lower_bound(cur); while (i != varNames.end()) { if (string(*i, 0, cur.size()) != cur) { break; diff --git a/third_party/nix/src/nix/run.cc b/third_party/nix/src/nix/run.cc index 523aa87472d6..5459c38952d4 100644 --- a/third_party/nix/src/nix/run.cc +++ b/third_party/nix/src/nix/run.cc @@ -225,7 +225,7 @@ void chrootHelper(int argc, char** argv) { createDirs(tmpDir + storeDir); if (mount(realStoreDir.c_str(), (tmpDir + storeDir).c_str(), "", MS_BIND, - 0) == -1) { + nullptr) == -1) { throw SysError("mounting '%s' on '%s'", realStoreDir, storeDir); } @@ -242,12 +242,13 @@ void chrootHelper(int argc, char** argv) { if (mkdir(dst.c_str(), 0700) == -1) { throw SysError("creating directory '%s'", dst); } - if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1) { + if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, nullptr) == + -1) { throw SysError("mounting '%s' on '%s'", src, dst); } } - char* cwd = getcwd(0, 0); + char* cwd = getcwd(nullptr, 0); if (!cwd) { throw SysError("getting current directory"); } @@ -260,8 +261,8 @@ void chrootHelper(int argc, char** argv) { if (chdir(cwd) == -1) { throw SysError(format("chdir to '%s' in chroot") % cwd); } - } else if (mount(realStoreDir.c_str(), storeDir.c_str(), "", MS_BIND, 0) == - -1) { + } else if (mount(realStoreDir.c_str(), storeDir.c_str(), "", MS_BIND, + nullptr) == -1) { throw SysError("mounting '%s' on '%s'", realStoreDir, storeDir); } diff --git a/third_party/nix/src/nix/search.cc b/third_party/nix/src/nix/search.cc index 5978d197fec6..78a1f21bc1e2 100644 --- a/third_party/nix/src/nix/search.cc +++ b/third_party/nix/src/nix/search.cc @@ -76,15 +76,14 @@ struct CmdSearch : SourceExprCommand, MixJSON { // Use "^" here instead of ".*" due to differences in resulting highlighting // (see #1893 -- libc++ claims empty search string is not in POSIX grammar) if (res.empty()) { - res.push_back("^"); + res.emplace_back("^"); } std::vector<std::regex> regexes; regexes.reserve(res.size()); for (auto& re : res) { - regexes.push_back( - std::regex(re, std::regex::extended | std::regex::icase)); + regexes.emplace_back(re, std::regex::extended | std::regex::icase); } auto state = getEvalState(); diff --git a/third_party/nix/src/nix/show-config.cc b/third_party/nix/src/nix/show-config.cc index 85b3c330cddb..51f02ed61bbe 100644 --- a/third_party/nix/src/nix/show-config.cc +++ b/third_party/nix/src/nix/show-config.cc @@ -7,7 +7,7 @@ using namespace nix; struct CmdShowConfig : Command, MixJSON { - CmdShowConfig() {} + CmdShowConfig() = default; std::string name() override { return "show-config"; } |