summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2019-06-12 10:56:20 +0200
committerChristian Stenger <christian.stenger@qt.io>2019-06-13 11:51:47 +0000
commit5f28af5e4d7f100019e562bcb21b321403e3fd8a (patch)
treebcefe04a48d2551986543fbdcaadf1716b62d8cf
parent58451e630df822f299e5e222957f954d57b1fc74 (diff)
downloadqt-creator-5f28af5e4d7f100019e562bcb21b321403e3fd8a.tar.gz
Valgrind: Handle CRLF appropriate
The valgrind parser might be used on Windows and if a device has Windows line endings it might end up with wrong data. Handle the additional line ending character if present. Change-Id: Ia86fa88f78b40e77e6236ed6769820e074a95db6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/plugins/valgrind/callgrind/callgrindparser.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/valgrind/callgrind/callgrindparser.cpp b/src/plugins/valgrind/callgrind/callgrindparser.cpp
index 153fa866db..c80a30b99b 100644
--- a/src/plugins/valgrind/callgrind/callgrindparser.cpp
+++ b/src/plugins/valgrind/callgrind/callgrindparser.cpp
@@ -283,6 +283,10 @@ void Parser::Private::parseHeader(QIODevice *device)
while (!device->atEnd()) {
QByteArray line = device->readLine();
+ // last character will be ignored anyhow, but we might have CRLF; if so cut the last one
+ if (line.endsWith("\r\n"))
+ line.chop(1);
+
// now that we're done checking if we're done (heh) with the header, parse the address
// and cost column descriptions. speed is unimportant here.
if (line.startsWith('#')) {
@@ -352,8 +356,9 @@ Parser::Private::NamePair Parser::Private::parseName(const char *begin, const ch
void Parser::Private::dispatchLine(const QByteArray &line)
{
+ int lineEnding = line.endsWith("\r\n") ? 2 : 1;
const char *const begin = line.constData();
- const char *const end = begin + line.length() - 1; // we're not interested in the '\n'
+ const char *const end = begin + line.length() - lineEnding; // we're not interested in the '\n'
const char *current = begin;
// shortest possible line is "1 1" - a cost item line