about summary refs log tree commit diff
path: root/third_party/nix/src/nix-build
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-08-06T08·28-0700
committerkanepyork <rikingcoding@gmail.com>2020-08-06T20·50+0000
commita5dae62e85d9ff9db6c4088d64559d7bac713486 (patch)
treee551ce79399e51dba895f95b8077c877cd94942a /third_party/nix/src/nix-build
parent6a97206cebf17f15b5cfede556bcb3c259ce5154 (diff)
fix(3p/nix): Use SkipEmpty in all calls to absl::StrSplit r/1613
The behavior to return a list containing a single empty string when
provided an empty string is a behavior that absl inherited from legacy
code. However, the behavior expected by legacy code in Nix is the
behavior provided by the SkipEmpty option. Switch all calls to use
SkipEmpty, except for the call already using SkipWhitespace.

See also commit 26a59482d2427f640893517f1b24dd650a5bd5da, with the
partly-prophetic message: "there may be other places we need to
fix this as well."

Change-Id: I6e94856a12cfb1b7e4a3b4e221769ed446648861
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1687
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'third_party/nix/src/nix-build')
-rw-r--r--third_party/nix/src/nix-build/nix-build.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/third_party/nix/src/nix-build/nix-build.cc b/third_party/nix/src/nix-build/nix-build.cc
index 7ebb14e1f319..dde03c52cbe0 100644
--- a/third_party/nix/src/nix-build/nix-build.cc
+++ b/third_party/nix/src/nix-build/nix-build.cc
@@ -114,7 +114,8 @@ static void _main(int argc, char** argv) {
       !std::regex_search(argv[1], std::regex("nix-shell"))) {
     script = argv[1];
     try {
-      Strings lines = absl::StrSplit(readFile(script), absl::ByChar('\n'));
+      Strings lines = absl::StrSplit(readFile(script), absl::ByChar('\n'),
+                                     absl::SkipEmpty());
       if (std::regex_search(lines.front(), std::regex("^#!"))) {
         lines.pop_front();
         inShebang = true;
@@ -443,8 +444,9 @@ static void _main(int argc, char** argv) {
     env["NIX_STORE"] = store->storeDir;
     env["NIX_BUILD_CORES"] = std::to_string(settings.buildCores);
 
-    StringSet passAsFile = absl::StrSplit(get(drv.env, "passAsFile", ""),
-                                          absl::ByAnyChar(" \t\n\r"));
+    StringSet passAsFile =
+        absl::StrSplit(get(drv.env, "passAsFile", ""),
+                       absl::ByAnyChar(" \t\n\r"), absl::SkipEmpty());
 
     bool keepTmp = false;
     int fileNr = 0;