Skip to content

Commit

Permalink
set column in TokenList::copyTokens
Browse files Browse the repository at this point in the history
  • Loading branch information
ludviggunne committed Oct 9, 2024
1 parent 6d56c7f commit 0741bf5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ Token *TokenList::copyTokens(Token *dest, const Token *first, const Token *last,
std::stack<Token *> links;
Token *tok2 = dest;
int linenr = dest->linenr();
int column = dest->next() ? dest->next()->column() : dest->column() + dest->str().length() + 1;
const int commonFileIndex = dest->fileIndex();
for (const Token *tok = first; tok != last->next(); tok = tok->next()) {
tok2->insertToken(tok->str());
tok2 = tok2->next();
tok2->fileIndex(commonFileIndex);
tok2->linenr(linenr);
tok2->column(column);
tok2->tokType(tok->tokType());
tok2->flags(tok->flags());
tok2->varId(tok->varId());
Expand All @@ -292,6 +294,9 @@ Token *TokenList::copyTokens(Token *dest, const Token *first, const Token *last,

links.pop();
}

column += tok->next() ? tok->next()->column() - tok->column() : tok->str().length() + 1;

if (!one_line && tok->next())
linenr += tok->next()->linenr() - tok->linenr();
}
Expand Down

0 comments on commit 0741bf5

Please sign in to comment.