mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
cabana: fix parsing multiple line comment (#30178)
fix parse error old-commit-hash: 29f10fd2aa0730681986631838f866462eb9af55
This commit is contained in:
@@ -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
|
||||
@@ -83,7 +83,7 @@ VAL_ 160 signal_1 0 "disabled" 1.2 "initializing" 2 "fault";
|
||||
|
||||
CM_ BO_ 160 "message comment" ;
|
||||
CM_ SG_ 160 signal_1 "signal comment";
|
||||
CM_ SG_ 160 signal_2 "multiple line comment
|
||||
CM_ SG_ 160 signal_2 "multiple line comment
|
||||
1
|
||||
2
|
||||
";)";
|
||||
@@ -113,7 +113,7 @@ CM_ SG_ 160 signal_2 "multiple line comment
|
||||
REQUIRE(sig_1->val_desc[2] == std::pair<double, QString>{2, "fault"});
|
||||
|
||||
auto &sig_2 = msg->sigs[1];
|
||||
REQUIRE(sig_2->comment == "multiple line comment\n1\n2");
|
||||
REQUIRE(sig_2->comment == "multiple line comment \n1\n2");
|
||||
|
||||
// multiplexed signals
|
||||
msg = file.msg(162);
|
||||
|
||||
Reference in New Issue
Block a user