Skip to content

Commit

Permalink
Config: Fix some errors in the comment handling
Browse files Browse the repository at this point in the history
Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed Apr 1, 2011
1 parent 90fb9e8 commit 2003465
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
17 changes: 4 additions & 13 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,14 @@ bool CConfig::Parse(CFile& file, CString& sErrorMsg)
sLine.TrimLeft();
sLine.TrimRight("\r\n");

if ((sLine.empty()) || (sLine[0] == '#') || (sLine.Left(2) == "//")) {
continue;
}

if (sLine.Left(2) == "/*") {
if (sLine.Right(2) != "*/") {
bCommented = true;
}
if (bCommented || sLine.Left(2) == "/*") {
/* Does this comment end on the same line again? */
bCommented = (sLine.Right(2) != "*/");

continue;
}

if (bCommented) {
if (sLine.Right(2) == "*/") {
bCommented = false;
}

if ((sLine.empty()) || (sLine[0] == '#') || (sLine.Left(2) == "//")) {
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions test/ConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2003465

Please sign in to comment.