summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-05-06 01:16:20 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-05-06 01:16:20 +0100
commit7f0738bcb3647f766427706b28a1f72677de9b1b (patch)
tree5f3cad2428dffee2697ade080c5cf9eaa7c2da82 /src
parent583b8842e74b9a3d3b42280a6a53a382554a1975 (diff)
varlist: allow using s for std::isspace
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.hpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index df948e85..4b4e3b4b 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -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);