cabana: fix parsing multiple line comment (#30178)

fix parse error
old-commit-hash: 29f10fd2aa
testing-closet
Dean Lee 2 years ago committed by GitHub
parent 4fab2c99e1
commit 0396152d98
  1. 7
      tools/cabana/dbc/dbcfile.cc
  2. 2
      tools/cabana/tests/test_cabana.cc

@ -107,7 +107,8 @@ void DBCFile::parse(const QString &content) {
int multiplexor_cnt = 0;
while (!stream.atEnd()) {
++line_num;
line = stream.readLine().trimmed();
QString raw_line = stream.readLine();
line = raw_line.trimmed();
if (line.startsWith("BO_ ")) {
multiplexor_cnt = 0;
auto match = bo_regexp.match(line);
@ -170,7 +171,7 @@ void DBCFile::parse(const QString &content) {
}
} else if (line.startsWith("CM_ BO_")) {
if (!line.endsWith("\";")) {
int pos = stream.pos() - line.length() - 1;
int pos = stream.pos() - raw_line.length() - 1;
line = content.mid(pos, content.indexOf("\";", pos));
}
auto match = msg_comment_regexp.match(line);
@ -180,7 +181,7 @@ void DBCFile::parse(const QString &content) {
}
} else if (line.startsWith("CM_ SG_ ")) {
if (!line.endsWith("\";")) {
int pos = stream.pos() - line.length() - 1;
int pos = stream.pos() - raw_line.length() - 1;
line = content.mid(pos, content.indexOf("\";", pos));
}
auto match = sg_comment_regexp.match(line);

@ -69,7 +69,7 @@ TEST_CASE("Parse can messages") {
}
}
TEST_CASE("Parse dbc") {
TEST_CASE("parse_dbc") {
QString content = R"(
BO_ 160 message_1: 8 EON
SG_ signal_1 : 0|12@1+ (1,0) [0|4095] "unit" XXX

Loading…
Cancel
Save