Skip to content
Browse files

Config: Fix some errors in the comment handling

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
1 parent 90fb9e8 commit 200346548925a963d4aa4df1a1f3cbfd8494787a @psychon psychon committed Apr 1, 2011
Showing with 6 additions and 13 deletions.
  1. +4 −13 Config.cpp
  2. +2 −0 test/ConfigTest.cpp
View
17 Config.cpp
@@ -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;
}
View
2 test/ConfigTest.cpp
@@ -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;

0 comments on commit 2003465

Please sign in to comment.
Something went wrong with that request. Please try again.