From c1f5b0ab485e13dde662e7a320a511c66b2fb386 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 10 Feb 2024 01:50:22 +0000 Subject: [PATCH] internal: fix handling of escaped # --- src/config.cpp | 1 + tests/parse/main.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index fceffb1..b56c1b9 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -404,6 +404,7 @@ CParseResult CConfig::parseLine(std::string line, bool dynamic) { line = line.substr(0, commentPos); break; } else { + line = line.substr(0, commentPos + 1) + line.substr(commentPos + 2); commentPos = line.find('#', lastHashPos); } } diff --git a/tests/parse/main.cpp b/tests/parse/main.cpp index d858c74..691aa58 100644 --- a/tests/parse/main.cpp +++ b/tests/parse/main.cpp @@ -129,7 +129,7 @@ int main(int argc, char** argv, char** envp) { EXPECT(std::any_cast(config.getConfigValue("testFloat")), 123.456f); auto EXP = Hyprlang::SVector2D{69, 420}; EXPECT(std::any_cast(config.getConfigValue("testVec")), EXP); - EXPECT(std::any_cast(config.getConfigValue("testString")), std::string{"Hello World! ## This is not a comment!"}); + EXPECT(std::any_cast(config.getConfigValue("testString")), std::string{"Hello World! # This is not a comment!"}); EXPECT(std::any_cast(config.getConfigValue("testStringQuotes")), std::string{"\"Hello World!\""}); EXPECT(std::any_cast(config.getConfigValue("testCategory:testValueInt")), 123456L); EXPECT(std::any_cast(config.getConfigValue("testCategory:testValueHex")), 0xFFFFAABBL);