diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-03-27 12:08:00 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-03-27 12:08:00 (GMT) |
commit | b3f88e8629390a49d12fd7684e711280b7b2c7c2 (patch) | |
tree | 7d6afd2740dd02894cec2a99d0511829f1703daa /tools/linguist/shared/cpp.cpp | |
parent | 7d2c8eb99c563b4fb236fe538123255f52f293a2 (diff) | |
download | Qt-b3f88e8629390a49d12fd7684e711280b7b2c7c2.zip Qt-b3f88e8629390a49d12fd7684e711280b7b2c7c2.tar.gz Qt-b3f88e8629390a49d12fd7684e711280b7b2c7c2.tar.bz2 |
properly process backslash line continuations
this is a backport of be5a9587865f9f042cac8feb5296b71b11a1a80f
Task-number: 249633
Diffstat (limited to 'tools/linguist/shared/cpp.cpp')
-rw-r--r-- | tools/linguist/shared/cpp.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/linguist/shared/cpp.cpp b/tools/linguist/shared/cpp.cpp index 333ffbf..2e137cf 100644 --- a/tools/linguist/shared/cpp.cpp +++ b/tools/linguist/shared/cpp.cpp @@ -130,12 +130,19 @@ static int yyInPos; static uint getChar() { - if (yyInPos >= yyInStr.size()) - return EOF; - QChar c = yyInStr[yyInPos++]; - if (c.unicode() == '\n') - ++yyCurLineNo; - return c.unicode(); + forever { + 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 == '\n') + ++yyCurLineNo; + return c; + } } static uint getToken() |