summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-10-25 14:32:25 +0100
committervaxerski <vaxry@vaxry.net>2022-10-25 14:32:25 +0100
commitcdb331076afcd1069d4d62805c3b48d237cc0b05 (patch)
treee752522eb076276a858356831c67686e3c9afb03 /src/config
parentba9a8a9ded02b5af182b0dfcb46da1769060fbba (diff)
allow # escaping in config
Diffstat (limited to 'src/config')
-rw-r--r--src/config/ConfigManager.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index d00c547b..790c7150 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -1016,13 +1016,26 @@ void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equals
void CConfigManager::parseLine(std::string& line) {
// first check if its not a comment
- const auto COMMENTSTART = line.find_first_of('#');
- if (COMMENTSTART == 0)
+ if (line[0] == '#')
return;
- // now, cut the comment off
- if (COMMENTSTART != std::string::npos)
- line = line.substr(0, COMMENTSTART);
+ // now, cut the comment off. ## is an escape.
+ for (long unsigned int i = 1; i < line.length(); ++i) {
+ if (line[i] == '#') {
+ if (i + 1 < line.length() && line[i + 1] != '#') {
+ line = line.substr(0, i);
+ break; // no need to parse more
+ }
+
+ i++;
+ }
+ }
+
+ size_t startPos = 0;
+ while ((startPos = line.find("##", startPos)) != std::string::npos) {
+ line.replace(startPos, 2, "#");
+ startPos++;
+ }
// remove shit at the beginning
while (line[0] == ' ' || line[0] == '\t') {