From e5783d41132d353a40fe1cf1d546ccd325d10ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20BOULMIER?= Date: Thu, 21 Nov 2019 22:26:53 +0100 Subject: [PATCH] Include empty tokens when splitting if necessary (#1893) Fixes #1881 --- include/utils/string.hpp | 2 +- src/modules/bspwm.cpp | 8 ++---- src/modules/i3.cpp | 2 +- src/modules/xkeyboard.cpp | 6 ++-- src/modules/xworkspaces.cpp | 2 +- src/utils/string.cpp | 47 ++++++++++++++++++++----------- tests/unit_tests/utils/string.cpp | 44 +++++++++++++++++++++-------- 7 files changed, 71 insertions(+), 40 deletions(-) diff --git a/include/utils/string.hpp b/include/utils/string.hpp index abc073be..40130c44 100644 --- a/include/utils/string.hpp +++ b/include/utils/string.hpp @@ -88,8 +88,8 @@ namespace string_util { string utf8_truncate(string&& value, size_t len); string join(const vector& strs, const string& delim); - vector& split_into(const string& s, char delim, vector& container); vector split(const string& s, char delim); + std::vector tokenize(const string& str, char delimiters); size_t find_nth(const string& haystack, size_t pos, const string& needle, size_t nth); diff --git a/src/modules/bspwm.cpp b/src/modules/bspwm.cpp index cf6817cd..3d145f64 100644 --- a/src/modules/bspwm.cpp +++ b/src/modules/bspwm.cpp @@ -131,7 +131,7 @@ namespace modules { m_icons->add(DEFAULT_ICON, factory_util::shared