From eb1b0abc1ebc4d35e288f9f91f9ad5a5be1606b6 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sun, 16 Nov 2008 16:13:38 +0000 Subject: [PATCH] Refactoring: tokens() changed to const and to return const pointer. --- CheckHeaders.cpp | 8 ++++---- CheckOther.cpp | 2 +- tokenize.cpp | 2 +- tokenize.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CheckHeaders.cpp b/CheckHeaders.cpp index 9d8eeb060..a8d9eff6e 100644 --- a/CheckHeaders.cpp +++ b/CheckHeaders.cpp @@ -47,7 +47,7 @@ CheckHeaders::~CheckHeaders() void CheckHeaders::WarningHeaderWithImplementation() { - for (TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next) + for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next) { // Only interested in included file if (tok->FileIndex == 0) @@ -82,7 +82,7 @@ void CheckHeaders::WarningHeaderWithImplementation() void CheckHeaders::WarningIncludeHeader() { // Including.. - for (TOKEN *includetok = _tokenizer->tokens(); includetok; includetok = includetok->next) + for ( const TOKEN *includetok = _tokenizer->tokens(); includetok; includetok = includetok->next) { if (strcmp(includetok->str, "#include") != 0) continue; @@ -111,7 +111,7 @@ void CheckHeaders::WarningIncludeHeader() // Extract classes and names in the header.. int indentlevel = 0; - for ( TOKEN *tok1 = _tokenizer->tokens(); tok1; tok1 = tok1->next ) + for ( const TOKEN *tok1 = _tokenizer->tokens(); tok1; tok1 = tok1->next ) { if ( tok1->FileIndex != hfile ) continue; @@ -205,7 +205,7 @@ void CheckHeaders::WarningIncludeHeader() // Check if the extracted names are used... bool Needed = false; bool NeedDeclaration = false; - for (TOKEN *tok1 = _tokenizer->tokens(); tok1; tok1 = tok1->next) + for ( const TOKEN *tok1 = _tokenizer->tokens(); tok1; tok1 = tok1->next) { if (tok1->FileIndex != includetok->FileIndex) continue; diff --git a/CheckOther.cpp b/CheckOther.cpp index 26e187ebe..5bae59368 100644 --- a/CheckOther.cpp +++ b/CheckOther.cpp @@ -377,7 +377,7 @@ void CheckOther::CheckUnsignedDivision() { // Check for "ivar / uvar" and "uvar / ivar" std::map varsign; - for ( TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next ) + for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next ) { if ( Match(tok, "[{};(,] %type% %var% [;=,)]") ) { diff --git a/tokenize.cpp b/tokenize.cpp index 02f0425e0..62bb2477d 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -73,7 +73,7 @@ TOKEN *Tokenizer::_gettok(TOKEN *tok, int index) } //--------------------------------------------------------------------------- -TOKEN *Tokenizer::tokens() +const TOKEN *Tokenizer::tokens() const { return _tokens; } diff --git a/tokenize.h b/tokenize.h index 9310d5fe3..19508fbef 100644 --- a/tokenize.h +++ b/tokenize.h @@ -94,7 +94,7 @@ public: const TOKEN *GetFunctionTokenByName( const char funcname[] ) const; void CheckGlobalFunctionUsage(const std::vector &filenames); void settings( const Settings &settings ); - TOKEN *tokens(); + const TOKEN *tokens() const; private: struct DefineSymbol