diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-24T21·29+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-24T21·29+0100 |
commit | 838f86b0fd880b26539664140f04e5d16669dad8 (patch) | |
tree | c8fee2f0c136fbe5bb0735604e2f04d5b02698ba /third_party/nix/src/libmain | |
parent | f30b2e610d9e612504a9f6460e0cc83413b80aeb (diff) |
style(3p/nix): Remove 'using std::*' from types.hh r/840
It is considered bad form to use things from includes in headers, as these directives propagate to everywhere else and can make it confusing. types.hh (which is includes almost literally everywhere) had some of these directives, which this commit removes.
Diffstat (limited to 'third_party/nix/src/libmain')
-rw-r--r-- | third_party/nix/src/libmain/common-args.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/libmain/common-args.hh | 4 | ||||
-rw-r--r-- | third_party/nix/src/libmain/shared.cc | 18 | ||||
-rw-r--r-- | third_party/nix/src/libmain/shared.hh | 18 |
4 files changed, 21 insertions, 21 deletions
diff --git a/third_party/nix/src/libmain/common-args.cc b/third_party/nix/src/libmain/common-args.cc index 3d9b8ebfaefd..f85eadbf70d9 100644 --- a/third_party/nix/src/libmain/common-args.cc +++ b/third_party/nix/src/libmain/common-args.cc @@ -6,7 +6,7 @@ namespace nix { -MixCommonArgs::MixCommonArgs(const string& programName) +MixCommonArgs::MixCommonArgs(const std::string& programName) : programName(programName) { mkFlag() .longName("option") diff --git a/third_party/nix/src/libmain/common-args.hh b/third_party/nix/src/libmain/common-args.hh index d8917b836778..88b51047dfbe 100644 --- a/third_party/nix/src/libmain/common-args.hh +++ b/third_party/nix/src/libmain/common-args.hh @@ -5,8 +5,8 @@ namespace nix { struct MixCommonArgs : virtual Args { - string programName; - MixCommonArgs(const string& programName); + std::string programName; + MixCommonArgs(const std::string& programName); }; struct MixDryRun : virtual Args { diff --git a/third_party/nix/src/libmain/shared.cc b/third_party/nix/src/libmain/shared.cc index d2b2a2800c46..549134872e91 100644 --- a/third_party/nix/src/libmain/shared.cc +++ b/third_party/nix/src/libmain/shared.cc @@ -83,8 +83,8 @@ void printMissing(const ref<Store>& store, const PathSet& willBuild, } } -string getArg(const string& opt, Strings::iterator& i, - const Strings::iterator& end) { +std::string getArg(const std::string& opt, Strings::iterator& i, + const Strings::iterator& end) { ++i; if (i == end) { throw UsageError(format("'%1%' requires an argument") % opt); @@ -246,13 +246,13 @@ void parseCmdLine( } void parseCmdLine( - const string& programName, const Strings& args, + const std::string& programName, const Strings& args, std::function<bool(Strings::iterator& arg, const Strings::iterator& end)> parseArg) { LegacyArgs(programName, std::move(parseArg)).parseCmdline(args); } -void printVersion(const string& programName) { +void printVersion(const std::string& programName) { std::cout << format("%1% (Nix) %2%") % programName % nixVersion << std::endl; // TODO(tazjin): figure out what the fuck this is @@ -273,18 +273,18 @@ void printVersion(const string& programName) { throw Exit(); } -void showManPage(const string& name) { +void showManPage(const std::string& name) { restoreSignals(); setenv("MANPATH", settings.nixManDir.c_str(), 1); execlp("man", "man", name.c_str(), nullptr); throw SysError(format("command 'man %1%' failed") % name.c_str()); } -int handleExceptions(const string& programName, +int handleExceptions(const std::string& programName, const std::function<void()>& fun) { ReceiveInterrupts receiveInterrupts; // FIXME: need better place for this - string error = ANSI_RED "error:" ANSI_NORMAL " "; + std::string error = ANSI_RED "error:" ANSI_NORMAL " "; try { try { fun(); @@ -328,7 +328,7 @@ RunPager::RunPager() { if (pager == nullptr) { pager = getenv("PAGER"); } - if (pager && ((string)pager == "" || (string)pager == "cat")) { + if (pager && ((std::string)pager == "" || (std::string)pager == "cat")) { return; } @@ -371,7 +371,7 @@ RunPager::~RunPager() { } } -string showBytes(unsigned long long bytes) { +std::string showBytes(unsigned long long bytes) { return (format("%.2f MiB") % (bytes / (1024.0 * 1024.0))).str(); } diff --git a/third_party/nix/src/libmain/shared.hh b/third_party/nix/src/libmain/shared.hh index da1c9cc66ac3..edd0a5159a9d 100644 --- a/third_party/nix/src/libmain/shared.hh +++ b/third_party/nix/src/libmain/shared.hh @@ -18,7 +18,7 @@ class Exit : public std::exception { virtual ~Exit(); }; -int handleExceptions(const string& programName, +int handleExceptions(const std::string& programName, const std::function<void()>& fun); /* Don't forget to call initPlugins() after settings are initialized! */ @@ -30,11 +30,11 @@ void parseCmdLine( parseArg); void parseCmdLine( - const string& programName, const Strings& args, + const std::string& programName, const Strings& args, std::function<bool(Strings::iterator& arg, const Strings::iterator& end)> parseArg); -void printVersion(const string& programName); +void printVersion(const std::string& programName); /* Ugh. No better place to put this. */ void printGCWarning(); @@ -47,17 +47,17 @@ void printMissing(const ref<Store>& store, const PathSet& willBuild, const PathSet& willSubstitute, const PathSet& unknown, unsigned long long downloadSize, unsigned long long narSize); -string getArg(const string& opt, Strings::iterator& i, - const Strings::iterator& end); +std::string getArg(const std::string& opt, Strings::iterator& i, + const Strings::iterator& end); template <class N> -N getIntArg(const string& opt, Strings::iterator& i, +N getIntArg(const std::string& opt, Strings::iterator& i, const Strings::iterator& end, bool allowUnit) { ++i; if (i == end) { throw UsageError(format("'%1%' requires an argument") % opt); } - string s = *i; + std::string s = *i; N multiplier = 1; if (allowUnit && !s.empty()) { char u = std::toupper(*s.rbegin()); @@ -98,7 +98,7 @@ struct LegacyArgs : public MixCommonArgs { }; /* Show the manual page for the specified program. */ -void showManPage(const string& name); +void showManPage(const std::string& name); /* The constructor of this class starts a pager if stdout is a terminal and $PAGER is set. Stdout is redirected to the pager. */ @@ -115,7 +115,7 @@ extern volatile ::sig_atomic_t blockInt; /* GC helpers. */ -string showBytes(unsigned long long bytes); +std::string showBytes(unsigned long long bytes); struct GCResults; |