From 26a59482d2427f640893517f1b24dd650a5bd5da Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 3 Aug 2020 19:45:38 -0400 Subject: fix(3p/nix): pass SkipEmpty to StrSplit("", ...) 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 Tested-by: BuildkiteCI --- third_party/nix/src/libstore/build.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'third_party/nix/src') 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 #include +#include +#include #include #include #include @@ -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 ss = absl::StrSplit(s, absl::ByAnyChar(" \t\n\r")); + std::vector 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>(worker.expectedSubstitutions); -- cgit 1.4.1