mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-09 15:45:57 +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 {
|
||||
public:
|
||||
/* passing 's' as a separator will use std::isspace */
|
||||
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
|
||||
std::string curitem = "";
|
||||
std::string argZ = in;
|
||||
std::string curitem = "";
|
||||
std::string argZ = in;
|
||||
const bool SPACESEP = separator == 's';
|
||||
|
||||
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) {
|
||||
curitem = argZ.substr(0, idx);
|
||||
|
|
Loading…
Reference in a new issue