forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -283,6 +283,10 @@ void Parser::Private::parseHeader(QIODevice *device)
|
|||||||
while (!device->atEnd()) {
|
while (!device->atEnd()) {
|
||||||
QByteArray line = device->readLine();
|
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
|
// 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.
|
// and cost column descriptions. speed is unimportant here.
|
||||||
if (line.startsWith('#')) {
|
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)
|
void Parser::Private::dispatchLine(const QByteArray &line)
|
||||||
{
|
{
|
||||||
|
int lineEnding = line.endsWith("\r\n") ? 2 : 1;
|
||||||
const char *const begin = line.constData();
|
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;
|
const char *current = begin;
|
||||||
|
|
||||||
// shortest possible line is "1 1" - a cost item line
|
// shortest possible line is "1 1" - a cost item line
|
||||||
|
Reference in New Issue
Block a user