varlist: allow using s for std::isspace

This commit is contained in:
vaxerski 2023-05-06 01:16:20 +01:00
parent 583b8842e7
commit 7f0738bcb3

View file

@ -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);