From 76972e8dd3b1c69920feec20095e9cd5aa965250 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Wed, 7 Dec 2011 23:36:11 +0100 Subject: [PATCH] Extend 'Token::deleteNext' by introducing a new parameter which determines how many tokens should be deleted. It's still not used, though. --- AUTHORS | 1 + lib/token.cpp | 11 +++++++---- lib/token.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4e89e26a8..be057262f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,7 @@ The cppcheck team, in alphabetical order: Bill Egert Daniel Marjamäki +Edoardo Prezioso Gianluca Scacco Greg Hewgill Hoang Tuan Su diff --git a/lib/token.cpp b/lib/token.cpp index 5dd15e580..9870c83d2 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -121,11 +121,14 @@ std::string Token::strValue() const return _str.substr(1, _str.length() - 2); } -void Token::deleteNext() +void Token::deleteNext(unsigned long index) { - Token *n = _next; - _next = n->next(); - delete n; + while(_next && index--) { + Token *n = _next; + _next = n->next(); + delete n; + } + if (_next) _next->previous(this); else if (tokensBack) diff --git a/lib/token.h b/lib/token.h index 86007a353..1d9757db8 100644 --- a/lib/token.h +++ b/lib/token.h @@ -59,9 +59,9 @@ public: } /** - * Unlink and delete next token. + * Unlink and delete the next 'index' tokens. */ - void deleteNext(); + void deleteNext(unsigned long index = 1); /** * Returns token in given index, related to this token.