diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-25T14·54+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-25T14·54+0100 |
commit | bf452cbc2ae2b209ec262ce858deca470d086f24 (patch) | |
tree | 198e98902be569301ecb9a821b0c9512b128f930 /third_party/nix/src/libstore/globals.cc | |
parent | b99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (diff) |
refactor(3p/nix): Replace tokenizeStrings with absl::StrSplit r/846
This function was a custom (and inefficient in the case of single-character delimiters) string splitter which was used all over the codebase. Abseil provides an appropriate replacement function.
Diffstat (limited to 'third_party/nix/src/libstore/globals.cc')
-rw-r--r-- | third_party/nix/src/libstore/globals.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/third_party/nix/src/libstore/globals.cc b/third_party/nix/src/libstore/globals.cc index 7307f035275f..f218534cc9f8 100644 --- a/third_party/nix/src/libstore/globals.cc +++ b/third_party/nix/src/libstore/globals.cc @@ -5,6 +5,8 @@ #include <thread> #include <absl/strings/numbers.h> +#include <absl/strings/str_cat.h> +#include <absl/strings/str_split.h> #include <dlfcn.h> #include "archive.hh" @@ -20,9 +22,6 @@ namespace nix { must be deleted and recreated on startup.) */ #define DEFAULT_SOCKET_PATH "/daemon-socket/socket" -// TODO(tazjin): this was __APPLE__ specific, still needed? -#define DEFAULT_ALLOWED_IMPURE_PREFIXES "" - Settings settings; static GlobalConfig::Register r1(&settings); @@ -55,21 +54,18 @@ Settings::Settings() } /* Backwards compatibility. */ + // TODO(tazjin): still? auto s = getEnv("NIX_REMOTE_SYSTEMS"); if (!s.empty()) { Strings ss; - for (auto& p : tokenizeString<Strings>(s, ":")) { - ss.push_back("@" + p); + for (auto p : absl::StrSplit(s, absl::ByChar(':'))) { + ss.push_back(absl::StrCat("@", p)); } builders = concatStringsSep(" ", ss); } -#if defined(__linux__) && defined(SANDBOX_SHELL) - sandboxPaths = tokenizeString<StringSet>("/bin/sh=" SANDBOX_SHELL); -#endif - - allowedImpureHostPrefixes = - tokenizeString<StringSet>(DEFAULT_ALLOWED_IMPURE_PREFIXES); + sandboxPaths = + absl::StrSplit("/bin/sh=" SANDBOX_SHELL, absl::ByAnyChar(" \t\n\r")); } void loadConfFile() { |