mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 15:05:59 +01:00
allow # escaping in config
This commit is contained in:
parent
ba9a8a9ded
commit
cdb331076a
1 changed files with 18 additions and 5 deletions
|
@ -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') {
|
||||
|
|
Loading…
Reference in a new issue