Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/parser/dbc/DbcParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool DbcParser::parseFile(QFile *file, CanDb &candb)

DbcToken *DbcParser::createNewToken(QChar ch, int line, int column)
{
static const QString acceptableIdStartChars("ABCDEFGHIKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_");
static const QString acceptableIdStartChars("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_");
static const QRegExp numberRegExp("^(\\d+(\\.\\d*)?(E[-+]?\\d*)?)$");

if (ch.isSpace()) {
Expand Down Expand Up @@ -100,17 +100,19 @@ DbcParser::error_t DbcParser::tokenize(QFile *file, DbcParser::DbcTokenList &tok
DbcToken *currentToken = 0;
int line = 1;
int column = 0;
QString s;
QChar ch;

error_t retval = err_ok;

QTextStream in(file);
in.setCodec("ISO 8859-1");

while (true) {
QString s = in.read(1);
s = in.read(1);
if (s.isEmpty()) { break; }

QChar ch = s[0];
ch = s[0];

if (ch=='\n') {
line++;
Expand All @@ -119,6 +121,19 @@ DbcParser::error_t DbcParser::tokenize(QFile *file, DbcParser::DbcTokenList &tok
column++;
}

// handle escape of " - need to replace it to '
if(ch=='\\') {
s = in.read(1);
ch = s[0];
if(ch!='"') {
retval = err_tokenize_error;
_errorColumn = column;
_errorLine = line;
break;
}
ch = '\'';
}

if (currentToken) {
if (!currentToken->appendChar(ch)) {
tokens.append(currentToken);
Expand Down