Tracegen: code tidies
* Do not rely on the side-effect that QTextStream returns _null_ strings (rather than empty strings) to signal EOF; just check for it, making the code easier to read. * Scope a variable properly * Use the char-based functions, rather than string-based functions (e.g. QString::split(QChar), not QString::split(QString)) when we're actually passing just one character * Make error cases more verbose Change-Id: I415773a60ea1b9013193a9a77e52655a6459047d Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
This commit is contained in:
parent
ce6c4349f7
commit
d5e5e15c1c
@ -272,35 +272,28 @@ Provider parseProvider(const QString &filename)
|
|||||||
|
|
||||||
static const QRegExp tracedef(QStringLiteral("([A-Za-z][A-Za-z0-9_]*)\\((.*)\\)"));
|
static const QRegExp tracedef(QStringLiteral("([A-Za-z][A-Za-z0-9_]*)\\((.*)\\)"));
|
||||||
|
|
||||||
int lineNumber = 0;
|
|
||||||
|
|
||||||
Provider provider;
|
Provider provider;
|
||||||
provider.name = QFileInfo(filename).baseName();
|
provider.name = QFileInfo(filename).baseName();
|
||||||
|
|
||||||
for (;;) {
|
for (int lineNumber = 1; !s.atEnd(); ++lineNumber) {
|
||||||
QString line = s.readLine().trimmed();
|
QString line = s.readLine().trimmed();
|
||||||
|
|
||||||
if (line.isNull())
|
if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
|
||||||
break;
|
|
||||||
|
|
||||||
if (line.isEmpty() || line.startsWith(QStringLiteral("#"))) {
|
|
||||||
++lineNumber;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (tracedef.exactMatch(line)) {
|
if (tracedef.exactMatch(line)) {
|
||||||
const QString name = tracedef.cap(1);
|
const QString name = tracedef.cap(1);
|
||||||
QStringList args = tracedef.cap(2).split(QStringLiteral(","), QString::SkipEmptyParts);
|
const QString argsString = tracedef.cap(2);
|
||||||
|
const QStringList args = argsString.split(QLatin1Char(','),
|
||||||
if (args.at(0).isNull())
|
QString::SkipEmptyParts);
|
||||||
args.clear();
|
|
||||||
|
|
||||||
provider.tracepoints << parseTracepoint(name, args, filename, lineNumber);
|
provider.tracepoints << parseTracepoint(name, args, filename, lineNumber);
|
||||||
} else {
|
} else {
|
||||||
panic("Syntax error whilre processing %s on line %d", qPrintable(filename), lineNumber);
|
panic("Syntax error while processing '%s' line %d:\n"
|
||||||
|
" '%s' does not look like a tracepoint definition",
|
||||||
|
qPrintable(filename), lineNumber,
|
||||||
|
qPrintable(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
++lineNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TRACEGEN_DEBUG
|
#ifdef TRACEGEN_DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user