diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-08-03T23·45-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-08-04T00·43+0000 |
commit | 26a59482d2427f640893517f1b24dd650a5bd5da (patch) | |
tree | 79698ee863dd395a2e4099904d38a92030ea62f1 /third_party/nix/src | |
parent | 2344f8e5289ccd64f2eb3594aac3fee62f76395a (diff) |
fix(3p/nix): pass SkipEmpty to StrSplit("", ...) r/1574
When tokenizeString was changed to absl::StrSplit, there was a behavior change because tokenizeString on an empty string returned an empty vector - which the derivation builder (and likely a bunch of other stuff) was depending on. The canonical way of fixing this is by passing absl::SkipEmpty() to the function - there may be other places we need to fix this as well. This commit also includes some opportunistic absl::StrFormats and StrCats, because I was here anyway, but those have no semantic difference. Change-Id: Ibf9bb602284f793fa55728481f63b838fb7a41db Reviewed-on: https://cl.tvl.fyi/c/depot/+/1631 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src')
-rw-r--r-- | third_party/nix/src/libstore/build.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc index 74db67e862a7..afd2374b0ac1 100644 --- a/third_party/nix/src/libstore/build.cc +++ b/third_party/nix/src/libstore/build.cc @@ -15,6 +15,8 @@ #include <absl/strings/ascii.h> #include <absl/strings/numbers.h> +#include <absl/strings/str_cat.h> +#include <absl/strings/str_format.h> #include <absl/strings/str_split.h> #include <fcntl.h> #include <glog/logging.h> @@ -1970,10 +1972,12 @@ void DerivationGoal::startBuilder() { by `nix-store --register-validity'. However, the deriver fields are left empty. */ std::string s = get(drv->env, "exportReferencesGraph"); - std::vector<std::string> ss = absl::StrSplit(s, absl::ByAnyChar(" \t\n\r")); + std::vector<std::string> ss = + absl::StrSplit(s, absl::ByAnyChar(" \t\n\r"), absl::SkipEmpty()); if (ss.size() % 2 != 0) { - throw BuildError( - format("odd number of tokens in 'exportReferencesGraph': '%1%'") % s); + throw BuildError(absl::StrFormat( + "odd number of tokens %d in 'exportReferencesGraph': '%s'", ss.size(), + s)); } for (auto i = ss.begin(); i != ss.end();) { std::string fileName = *i++; @@ -3959,7 +3963,7 @@ SubstitutionGoal::SubstitutionGoal(const Path& storePath, Worker& worker, : Goal(worker), repair(repair) { this->storePath = storePath; state = &SubstitutionGoal::init; - name = (format("substitution of '%1%'") % storePath).str(); + name = absl::StrCat("substitution of ", storePath); trace("created"); maintainExpectedSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.expectedSubstitutions); |