From 668558cf2ee4f7053bedc5af2651d4c9c387f609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 17 Nov 2016 23:31:09 +0100 Subject: [PATCH] Improved error reporting --- src/nmeaparser.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/nmeaparser.cpp b/src/nmeaparser.cpp index 95a53244..61d42a22 100644 --- a/src/nmeaparser.cpp +++ b/src/nmeaparser.cpp @@ -101,7 +101,7 @@ static bool readFloat(const char *data, int len, qreal &f) return ok; } -static bool validLine(const char *line, int len) +static bool validSentence(const char *line, int len) { const char *lp; @@ -395,6 +395,7 @@ bool NMEAParser::loadFile(QFile *file) { qint64 len; char line[80 + 2 + 1 + 1]; + bool nmea = false; _errorLine = 1; @@ -414,12 +415,14 @@ bool NMEAParser::loadFile(QFile *file) return false; } - if (!validLine(line, len)) { - fprintf(stderr, "%s:%d: Invalid NMEA sentence\n", - qPrintable(file->fileName()), _errorLine); + if (!validSentence(line, len)) { + if (nmea) + fprintf(stderr, "%s:%d: Invalid NMEA sentence\n", + qPrintable(file->fileName()), _errorLine); _errorLine++; continue; - } + } else + nmea = true; if (!memcmp(line + 3, "RMC,", 4)) { if (!readRMC(line + 7, len))