From 5f28af5e4d7f100019e562bcb21b321403e3fd8a Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 12 Jun 2019 10:56:20 +0200 Subject: 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 --- src/plugins/valgrind/callgrind/callgrindparser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/plugins/valgrind') 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 -- cgit v1.2.3