diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-06-05 15:13:17 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-06-05 15:27:56 (GMT) |
commit | 7f21512826689df38678c4cb954e9c347c01df8b (patch) | |
tree | 9925fb28261b86d9b3d51a37bb7c648c1f4f3de0 | |
parent | d29da4699a2887cdf0836ff39652524d015431c0 (diff) | |
download | Qt-7f21512826689df38678c4cb954e9c347c01df8b.zip Qt-7f21512826689df38678c4cb954e9c347c01df8b.tar.gz Qt-7f21512826689df38678c4cb954e9c347c01df8b.tar.bz2 |
explicitly handle windows and mac9 line endings
in practice, this matters only for backslashed line continuations
Task-number: 255336
-rw-r--r-- | tools/linguist/shared/cpp.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tools/linguist/shared/cpp.cpp b/tools/linguist/shared/cpp.cpp index 2e137cf..0aab661 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; } } |