Skip to content

Commit 76972e8

Browse files
committed
Extend 'Token::deleteNext' by introducing a new parameter which determines how many tokens should be deleted. It's still not used, though.
1 parent 5cc5330 commit 76972e8

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ The cppcheck team, in alphabetical order:
22

33
Bill Egert
44
Daniel Marjamäki
5+
Edoardo Prezioso
56
Gianluca Scacco
67
Greg Hewgill
78
Hoang Tuan Su

lib/token.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ std::string Token::strValue() const
121121
return _str.substr(1, _str.length() - 2);
122122
}
123123

124-
void Token::deleteNext()
124+
void Token::deleteNext(unsigned long index)
125125
{
126-
Token *n = _next;
127-
_next = n->next();
128-
delete n;
126+
while(_next && index--) {
127+
Token *n = _next;
128+
_next = n->next();
129+
delete n;
130+
}
131+
129132
if (_next)
130133
_next->previous(this);
131134
else if (tokensBack)

lib/token.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class Token {
5959
}
6060

6161
/**
62-
* Unlink and delete next token.
62+
* Unlink and delete the next 'index' tokens.
6363
*/
64-
void deleteNext();
64+
void deleteNext(unsigned long index = 1);
6565

6666
/**
6767
* Returns token in given index, related to this token.

0 commit comments

Comments
 (0)