mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 23:49:49 +01:00
varlist: allow using s for std::isspace
This commit is contained in:
parent
583b8842e7
commit
7f0738bcb3
1 changed files with 14 additions and 3 deletions
|
@ -86,12 +86,23 @@ struct SExecRequestedRule {
|
||||||
|
|
||||||
class CVarList {
|
class CVarList {
|
||||||
public:
|
public:
|
||||||
|
/* passing 's' as a separator will use std::isspace */
|
||||||
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
|
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
|
||||||
std::string curitem = "";
|
std::string curitem = "";
|
||||||
std::string argZ = in;
|
std::string argZ = in;
|
||||||
|
const bool SPACESEP = separator == 's';
|
||||||
|
|
||||||
auto nextItem = [&]() {
|
auto nextItem = [&]() {
|
||||||
auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : argZ.find_first_of(separator);
|
auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : ([&]() -> size_t {
|
||||||
|
if (!SPACESEP)
|
||||||
|
return argZ.find_first_of(separator);
|
||||||
|
|
||||||
|
uint64_t pos = -1;
|
||||||
|
while (!std::isspace(argZ[++pos]) && pos < argZ.length())
|
||||||
|
;
|
||||||
|
|
||||||
|
return pos < argZ.length() ? pos : std::string::npos;
|
||||||
|
}());
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
if (idx != std::string::npos) {
|
||||||
curitem = argZ.substr(0, idx);
|
curitem = argZ.substr(0, idx);
|
||||||
|
|
Loading…
Reference in a new issue