summaryrefslogtreecommitdiffhomepage
path: root/csv/csv.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-07 08:43:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-08 21:30:48 +0100
commit709fe557a3a5c2dc8675472dac9325f8efdff004 (patch)
treefa257eae76fc50d3cbe7b69b5c423108c170af90 /csv/csv.cpp
parent788cfe69a1668dfd7e6bca16907de696e6063fbe (diff)
clean up a bit
Diffstat (limited to 'csv/csv.cpp')
-rw-r--r--csv/csv.cpp41
1 files changed, 15 insertions, 26 deletions
diff --git a/csv/csv.cpp b/csv/csv.cpp
index 73c56aed..aa518673 100644
--- a/csv/csv.cpp
+++ b/csv/csv.cpp
@@ -137,43 +137,32 @@ bool CSV::getGameData(int id, unsigned char* table, QString& gamename)
const QByteArray id_cstr = gameLine[7].toLatin1();
- if (proto == QStringLiteral("V160"))
- {
- /* nothing */
- }
- else if (id_cstr.length() != 22 ||
- sscanf(id_cstr.constData(),
- "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
- fuzz + 2,
- fuzz + 0,
- tmp + 3,
- tmp + 2,
- tmp + 1,
- tmp + 0,
- tmp + 7,
- tmp + 6,
- tmp + 5,
- tmp + 4,
- fuzz + 1) != 11)
- {
+ auto do_scanf = [&]() {
+ return sscanf(id_cstr.constData(),
+ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ fuzz + 2,
+ fuzz + 0,
+ tmp + 3, tmp + 2, tmp + 1, tmp + 0,
+ tmp + 7, tmp + 6, tmp + 5, tmp + 4,
+ fuzz + 1);
+ };
+
+ if (proto == QStringLiteral("V160") || id_cstr.length() != 22)
+ (void)0;
+ else if (id_cstr.length() != 22 || do_scanf() != 11)
qDebug() << "scanf failed" << lineno;
- }
else
{
+ using uchar = unsigned char;
for (int i = 0; i < 8; i++)
- {
- using t = unsigned char;
- table[i] = t(tmp[i]);
- }
+ table[i] = uchar(tmp[i]);
}
gamename = std::move(name);
return true;
}
}
else
- {
qDebug() << "malformed csv line" << lineno;
- }
}
if (id)