mirror of
https://github.com/znc/znc.git
synced 2026-08-07 01:13:25 +02:00
Config: Fix some errors in the comment handling
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
+7
-16
@@ -76,26 +76,17 @@ bool CConfig::Parse(CFile& file, CString& sErrorMsg)
|
||||
sLine.TrimLeft();
|
||||
sLine.TrimRight("\r\n");
|
||||
|
||||
if (bCommented || sLine.Left(2) == "/*") {
|
||||
/* Does this comment end on the same line again? */
|
||||
bCommented = (sLine.Right(2) != "*/");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((sLine.empty()) || (sLine[0] == '#') || (sLine.Left(2) == "//")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sLine.Left(2) == "/*") {
|
||||
if (sLine.Right(2) != "*/") {
|
||||
bCommented = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bCommented) {
|
||||
if (sLine.Right(2) == "*/") {
|
||||
bCommented = false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((sLine.Left(1) == "<") && (sLine.Right(1) == ">")) {
|
||||
sLine.LeftChomp();
|
||||
sLine.RightChomp();
|
||||
|
||||
@@ -150,6 +150,8 @@ int main() {
|
||||
TEST_SUCCESS("Foo = bar // baz\n// Bar = baz", "foo=bar // baz\n"),
|
||||
TEST_SUCCESS("Foo = bar /* baz */\n/*** Foo = baz ***/\n /**** asdsdfdf \n Some quite invalid stuff ***/\n", "foo=bar /* baz */\n"),
|
||||
TEST_ERROR("<foo foo>\n/* Just a comment\n</foo>", "Error on line 3: Comment not closed at end of file."),
|
||||
TEST_SUCCESS("/* Foo\n/* Bar */", ""),
|
||||
TEST_SUCCESS("/* Foo\n// */", ""),
|
||||
};
|
||||
unsigned int i;
|
||||
unsigned int failed = 0;
|
||||
|
||||
Reference in New Issue
Block a user