Skip to content

Commit

Permalink
dd
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Apr 11, 2024
1 parent 07457c1 commit 41c483a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tools/cabana/dbc/dbcfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ cabana::Msg *DBCFile::parseBO(const QString &line) {
}

void DBCFile::parseCM_BO(const QString &line, const QString &content, const QString &raw_line, const QTextStream &stream) {
const static QRegularExpression msg_comment_regexp(R"(^CM_ BO_ *(\w+) *\"((?:[^"\\]|\\.)*)\"\s*;)");
const static QRegularExpression msg_comment_regexp(R"(^CM_ BO_ *(?<address>\w+) *\"(?<comment>(?:[^"\\]|\\.)*)\"\s*;)");

QString parse_line = line;
if (!parse_line.endsWith("\";")) {
Expand All @@ -161,10 +161,10 @@ void DBCFile::parseCM_BO(const QString &line, const QString &content, const QStr
}
auto match = msg_comment_regexp.match(parse_line);
if (!match.hasMatch())
throw std::runtime_error("");
throw std::runtime_error("Invalid message comment format");

if (auto m = (cabana::Msg *)msg(match.captured(1).toUInt()))
m->comment = match.captured(2).trimmed().replace("\\\"", "\"");
if (auto m = (cabana::Msg *)msg(match.captured("address").toUInt()))
m->comment = match.captured("comment").trimmed().replace("\\\"", "\"");
}

cabana::Signal *DBCFile::parseSG(const QString &line, int &multiplexor_cnt) {
Expand All @@ -178,7 +178,7 @@ cabana::Signal *DBCFile::parseSG(const QString &line, int &multiplexor_cnt) {
offset = 1;
}
if (!match.hasMatch())
throw std::runtime_error("");
throw std::runtime_error("Invalid SG_ line format");

auto name = match.captured(1);
// if (signal())
Expand Down Expand Up @@ -222,7 +222,7 @@ void DBCFile::parseCM_SG(const QString &line, const QString &content, const QStr
}
auto match = sg_comment_regexp.match(parse_line);
if (!match.hasMatch())
throw std::runtime_error("");
throw std::runtime_error("Invalid CM_ SG_ line format");

if (auto s = signal(match.captured(1).toUInt(), match.captured(2))) {
s->comment = match.captured(3).trimmed().replace("\\\"", "\"");
Expand All @@ -234,7 +234,7 @@ void DBCFile::parseVAL(const QString &line) {

auto match = val_regexp.match(line);
if (!match.hasMatch())
throw std::runtime_error("");
throw std::runtime_error("invalid VAL_ line format");

if (auto s = signal(match.captured(1).toUInt(), match.captured(2))) {
QStringList desc_list = match.captured(3).trimmed().split('"');
Expand Down

0 comments on commit 41c483a

Please sign in to comment.