From a5dae62e85d9ff9db6c4088d64559d7bac713486 Mon Sep 17 00:00:00 2001 From: Kane York Date: Thu, 6 Aug 2020 01:28:00 -0700 Subject: fix(3p/nix): Use SkipEmpty in all calls to absl::StrSplit 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 --- third_party/nix/src/libutil/config.cc | 4 ++-- third_party/nix/src/libutil/util.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'third_party/nix/src/libutil') diff --git a/third_party/nix/src/libutil/config.cc b/third_party/nix/src/libutil/config.cc index 5d28b7a20f..7c6e7af487 100644 --- a/third_party/nix/src/libutil/config.cc +++ b/third_party/nix/src/libutil/config.cc @@ -262,7 +262,7 @@ void BaseSetting::convertToArg(Args& args, const std::string& category) { template <> void BaseSetting::set(const std::string& str) { - value = absl::StrSplit(str, absl::ByAnyChar(" \t\n\r")); + value = absl::StrSplit(str, absl::ByAnyChar(" \t\n\r"), absl::SkipEmpty()); } template <> @@ -280,7 +280,7 @@ void BaseSetting::toJSON(JSONPlaceholder& out) { template <> void BaseSetting::set(const std::string& str) { - value = absl::StrSplit(str, absl::ByAnyChar(" \t\n\r")); + value = absl::StrSplit(str, absl::ByAnyChar(" \t\n\r"), absl::SkipEmpty()); } template <> diff --git a/third_party/nix/src/libutil/util.cc b/third_party/nix/src/libutil/util.cc index 75a8e73eac..3e88fd29b9 100644 --- a/third_party/nix/src/libutil/util.cc +++ b/third_party/nix/src/libutil/util.cc @@ -547,7 +547,7 @@ std::vector getConfigDirs() { Path configHome = getConfigDir(); std::string configDirs = getEnv("XDG_CONFIG_DIRS"); std::vector result = - absl::StrSplit(configDirs, absl::ByChar(':')); + absl::StrSplit(configDirs, absl::ByChar(':'), absl::SkipEmpty()); result.insert(result.begin(), configHome); return result; } -- cgit 1.4.1