mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-02-03 09:44:24 -05:00
Relax ADIF log file parsing to allow garbage between records and records with no DX callsign
This commit is contained in:
parent
784f75ea74
commit
5e585e8027
@ -320,30 +320,27 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((end_position = buffer.indexOf ("<EOR>", 0, Qt::CaseInsensitive)) < 0 && !in.atEnd ());
|
while ((end_position = buffer.indexOf ("<EOR>", 0, Qt::CaseInsensitive)) < 0 && !in.atEnd ());
|
||||||
if (end_position < 0)
|
if (end_position >= 0) // require valid ADIF record
|
||||||
|
// with terminator
|
||||||
{
|
{
|
||||||
throw LoaderException (std::runtime_error {"Invalid ADIF record starting at: " + buffer.left (40).toStdString ()});
|
auto record = buffer.left (end_position + 5).trimmed ();
|
||||||
}
|
auto next_record = buffer.indexOf (QChar {'<'}, end_position + 5);
|
||||||
auto record = buffer.left (end_position + 5).trimmed ();
|
buffer.remove (0, next_record >=0 ? next_record : buffer.size ());
|
||||||
auto next_record = buffer.indexOf (QChar {'<'}, end_position + 5);
|
record = record.mid (record.indexOf (QChar {'<'}));
|
||||||
buffer.remove (0, next_record >=0 ? next_record : buffer.size ());
|
auto call = extractField (record, "CALL");
|
||||||
record = record.mid (record.indexOf (QChar {'<'}));
|
if (call.size ()) // require CALL field before we
|
||||||
auto call = extractField (record, "CALL");
|
// will parse a record
|
||||||
if (call.size ())
|
{
|
||||||
{
|
auto const& entity = prefixes->lookup (call);
|
||||||
auto const& entity = prefixes->lookup (call);
|
worked.emplace (call.toUpper ()
|
||||||
worked.emplace (call.toUpper ()
|
, extractField (record, "GRIDSQUARE").left (4).toUpper () // not interested in 6-digit grids
|
||||||
, extractField (record, "GRIDSQUARE").left (4).toUpper () // not interested in 6-digit grids
|
, extractField (record, "BAND").toUpper ()
|
||||||
, extractField (record, "BAND").toUpper ()
|
, extractField (record, "MODE").toUpper ()
|
||||||
, extractField (record, "MODE").toUpper ()
|
, entity.entity_name
|
||||||
, entity.entity_name
|
, entity.continent
|
||||||
, entity.continent
|
, entity.CQ_zone
|
||||||
, entity.CQ_zone
|
, entity.ITU_zone);
|
||||||
, entity.ITU_zone);
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw LoaderException (std::runtime_error {"Invalid ADIF record with no CALL: " + record.toStdString ()});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user