fix bug, if there is no NL in the last line comment #40

if there was no NL in the line comment we ran into an
endless recursion, now we check for that corner case.
This commit is contained in:
Peinthor Rene
2014-02-14 13:41:15 +01:00
parent 5647fa86e0
commit 2552249cf8

View File

@@ -63,8 +63,9 @@ QString removeComments(QString s)
else if(!(!stringChars.empty() && (stringChars.last() != '\'' || stringChars.last() != '"')) || stringChars.empty())
stringChars.push_back(s.at(i));
} else if(stringChars.empty() && s.at(i) == '-' && lastChar == '-') {
if(s.contains('\n'))
return removeComments(s.remove(i-1, s.indexOf('\n', i)-i+2));
int nextNL = s.indexOf('\n', i);
if(nextNL >= 0)
return removeComments(s.remove(i-1, nextNL - i + 2));
else
return s.left(i-1);
}