summaryrefslogtreecommitdiffstats
path: root/tools/linguist/shared/cpp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/linguist/shared/cpp.cpp')
-rw-r--r--tools/linguist/shared/cpp.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/tools/linguist/shared/cpp.cpp b/tools/linguist/shared/cpp.cpp
index 2e137cfa6f..541543fa13 100644
--- a/tools/linguist/shared/cpp.cpp
+++ b/tools/linguist/shared/cpp.cpp
@@ -134,13 +134,28 @@ static uint getChar()
if (yyInPos >= yyInStr.size())
return EOF;
uint c = yyInStr[yyInPos++].unicode();
- if (c == '\\' && yyInPos < yyInStr.size() && yyInStr[yyInPos].unicode() == '\n') {
- ++yyCurLineNo;
- ++yyInPos;
- continue;
+ if (c == '\\' && yyInPos < yyInStr.size()) {
+ if (yyInStr[yyInPos].unicode() == '\n') {
+ ++yyCurLineNo;
+ ++yyInPos;
+ continue;
+ }
+ if (yyInStr[yyInPos].unicode() == '\r') {
+ ++yyCurLineNo;
+ ++yyInPos;
+ if (yyInPos < yyInStr.size() && yyInStr[yyInPos].unicode() == '\n')
+ ++yyInPos;
+ continue;
+ }
}
- if (c == '\n')
+ if (c == '\r') {
+ if (yyInPos < yyInStr.size() && yyInStr[yyInPos].unicode() == '\n')
+ ++yyInPos;
+ c = '\n';
+ ++yyCurLineNo;
+ } else if (c == '\n') {
++yyCurLineNo;
+ }
return c;
}
}
@@ -465,7 +480,9 @@ static bool matchString(QString *s)
s->clear();
while (yyTok == Tok_String) {
*s += yyString;
- yyTok = getToken();
+ do {
+ yyTok = getToken();
+ } while (yyTok == Tok_Comment);
}
return matches;
}