Refactoring: tokens() changed to const and to return const pointer.

This commit is contained in:
Reijo Tomperi 2008-11-16 16:13:38 +00:00
parent aa579911ab
commit eb1b0abc1e
4 changed files with 7 additions and 7 deletions

View File

@ -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;

View File

@ -377,7 +377,7 @@ void CheckOther::CheckUnsignedDivision()
{
// Check for "ivar / uvar" and "uvar / ivar"
std::map<std::string, char> 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% [;=,)]") )
{

View File

@ -73,7 +73,7 @@ TOKEN *Tokenizer::_gettok(TOKEN *tok, int index)
}
//---------------------------------------------------------------------------
TOKEN *Tokenizer::tokens()
const TOKEN *Tokenizer::tokens() const
{
return _tokens;
}

View File

@ -94,7 +94,7 @@ public:
const TOKEN *GetFunctionTokenByName( const char funcname[] ) const;
void CheckGlobalFunctionUsage(const std::vector<std::string> &filenames);
void settings( const Settings &settings );
TOKEN *tokens();
const TOKEN *tokens() const;
private:
struct DefineSymbol