TOKEN: Refactoring the 'str' member variable

This commit is contained in:
Daniel Marjamäki 2008-11-24 19:38:08 +00:00
parent 31c3532b55
commit bc267bbca5
11 changed files with 239 additions and 223 deletions

View File

@ -85,12 +85,12 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
int indentlevel = 0; int indentlevel = 0;
for ( ; tok; tok = tok->next ) for ( ; tok; tok = tok->next )
{ {
if (TOKEN::Match(tok, "{")) if (tok->str() == "{")
{ {
indentlevel++; indentlevel++;
} }
else if (TOKEN::Match(tok, "}")) else if (tok->str() == "}")
{ {
indentlevel--; indentlevel--;
if ( indentlevel < 0 ) if ( indentlevel < 0 )
@ -98,7 +98,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
} }
// Array index.. // Array index..
if ( !TOKEN::Match(tok, "%var%") && !TOKEN::Match(tok,"[.&]") && TOKEN::Match(tok->next, "%var1% [ %num% ]", varname) ) if ( !tok->isName() && !TOKEN::Match(tok,"[.&]") && TOKEN::Match(tok->next, "%var1% [ %num% ]", varname) )
{ {
const char *num = tok->next->strAt(2 + varc); const char *num = tok->next->strAt(2 + varc);
if (strtol(num, NULL, 10) >= size) if (strtol(num, NULL, 10) >= size)
@ -151,8 +151,8 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
continue; continue;
// Get index variable and stopsize. // Get index variable and stopsize.
const char *strindex = tok2->str; const char *strindex = tok2->aaaa();
int value = (tok2->next->str[1] ? 1 : 0) + atoi(tok2->strAt(2)); int value = ((tok2->next->aaaa1() == '=') ? 1 : 0) + atoi(tok2->strAt(2));
if ( value <= size ) if ( value <= size )
continue; continue;
@ -168,13 +168,13 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
int indentlevel2 = 0; int indentlevel2 = 0;
while (tok2) while (tok2)
{ {
if ( TOKEN::Match(tok2, ";") && indentlevel2 == 0 ) if ( (tok2->str() == ";") && indentlevel2 == 0 )
break; break;
if ( TOKEN::Match(tok2, "{") ) if ( tok2->str() == "{" )
indentlevel2++; indentlevel2++;
if ( TOKEN::Match(tok2, "}") ) if ( tok2->str() == "}" )
{ {
indentlevel2--; indentlevel2--;
if ( indentlevel2 <= 0 ) if ( indentlevel2 <= 0 )
@ -225,12 +225,12 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
unsigned int parlevel = 0, par = 0; unsigned int parlevel = 0, par = 0;
for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next ) for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next )
{ {
if ( TOKEN::Match(tok2, "(") ) if ( tok2->str() == "(" )
{ {
parlevel++; parlevel++;
} }
else if ( TOKEN::Match(tok2, ")") ) else if ( tok2->str() == ")" )
{ {
parlevel--; parlevel--;
if ( parlevel < 1 ) if ( parlevel < 1 )
@ -240,7 +240,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
} }
} }
else if ( parlevel == 1 && TOKEN::Match(tok2, ",") ) else if ( parlevel == 1 && (tok2->str() == ",") )
{ {
par++; par++;
} }
@ -256,7 +256,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
continue; continue;
// Find function.. // Find function..
const TOKEN *ftok = _tokenizer->GetFunctionTokenByName( tok->str ); const TOKEN *ftok = _tokenizer->GetFunctionTokenByName( tok->aaaa() );
if ( ! ftok ) if ( ! ftok )
continue; continue;
@ -265,24 +265,24 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
parlevel = 1; parlevel = 1;
while ( ftok && parlevel == 1 && par >= 1 ) while ( ftok && parlevel == 1 && par >= 1 )
{ {
if ( TOKEN::Match(ftok, "(") ) if ( ftok->str() == "(" )
parlevel++; parlevel++;
else if ( TOKEN::Match(ftok, ")") ) else if ( ftok->str() == ")" )
parlevel--; parlevel--;
else if ( TOKEN::Match(ftok, ",") ) else if ( ftok->str() == "," )
par--; par--;
else if (par==1 && parlevel==1 && (TOKEN::Match(ftok, "%var% ,") || TOKEN::Match(ftok, "%var% )"))) else if (par==1 && parlevel==1 && (TOKEN::Match(ftok, "%var% ,") || TOKEN::Match(ftok, "%var% )")))
{ {
// Parameter name.. // Parameter name..
const char *parname[2]; const char *parname[2];
parname[0] = ftok->str; parname[0] = ftok->aaaa();
parname[1] = 0; parname[1] = 0;
// Goto function body.. // Goto function body..
while ( ftok && !TOKEN::Match(ftok,"{") ) while ( ftok && (ftok->str() != "{") )
ftok = ftok->next; ftok = ftok->next;
ftok = ftok ? ftok->next : 0; ftok = ftok ? ftok->next : 0;
@ -311,10 +311,10 @@ void CheckBufferOverrunClass::CheckBufferOverrun_LocalVariable()
int indentlevel = 0; int indentlevel = 0;
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next) for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next)
{ {
if (TOKEN::Match(tok, "{")) if (tok->str() == "{")
indentlevel++; indentlevel++;
else if (TOKEN::Match(tok, "}")) else if (tok->str() == "}")
indentlevel--; indentlevel--;
else if (indentlevel > 0) else if (indentlevel > 0)
@ -327,7 +327,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_LocalVariable()
{ {
varname[0] = tok->strAt(1); varname[0] = tok->strAt(1);
size = strtoul(tok->strAt(3), NULL, 10); size = strtoul(tok->strAt(3), NULL, 10);
type = tok->str; type = tok->aaaa();
} }
else if (indentlevel > 0 && TOKEN::Match(tok, "[*;{}] %var% = new %type% [ %num% ]")) else if (indentlevel > 0 && TOKEN::Match(tok, "[*;{}] %var% = new %type% [ %num% ]"))
{ {
@ -367,7 +367,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
if (!TOKEN::Match(tok,"struct") && !TOKEN::Match(tok,"class")) if (!TOKEN::Match(tok,"struct") && !TOKEN::Match(tok,"class"))
continue; continue;
const char *structname = tok->next->str; const char *structname = tok->next->aaaa();
if ( !(tok->next->isName()) ) if ( !(tok->next->isName()) )
continue; continue;
@ -393,7 +393,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
const char *varname[3] = {0,0,0}; const char *varname[3] = {0,0,0};
varname[1] = tok2->strAt(ivar); varname[1] = tok2->strAt(ivar);
int arrsize = atoi(tok2->strAt(ivar+2)); int arrsize = atoi(tok2->strAt(ivar+2));
int total_size = arrsize * _tokenizer->SizeOfType(tok2->next->str); int total_size = arrsize * _tokenizer->SizeOfType(tok2->next->aaaa());
if (total_size == 0) if (total_size == 0)
continue; continue;
@ -423,7 +423,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
for ( const TOKEN *tok3 = _tokenizer->tokens(); tok3; tok3 = tok3->next ) for ( const TOKEN *tok3 = _tokenizer->tokens(); tok3; tok3 = tok3->next )
{ {
if ( strcmp(tok3->str, structname) ) if ( strcmp(tok3->aaaa(), structname) )
continue; continue;
// Declare variable: Fred fred1; // Declare variable: Fred fred1;

View File

@ -57,9 +57,9 @@ struct VAR *CheckClass::ClassChecking_GetVarList(const TOKEN *tok1)
if (!tok->next) if (!tok->next)
break; break;
if (tok->str[0] == '{') if (tok->aaaa0() == '{')
indentlevel++; indentlevel++;
if (tok->str[0] == '}') if (tok->aaaa0() == '}')
{ {
if (indentlevel <= 1) if (indentlevel <= 1)
break; break;
@ -67,7 +67,7 @@ struct VAR *CheckClass::ClassChecking_GetVarList(const TOKEN *tok1)
} }
if (indentlevel==1 && (strchr(";{}", tok->str[0]) || (tok->str[0]!=':' && strchr(tok->str, ':')))) if (indentlevel==1 && (strchr(";{}", tok->aaaa0()) || (tok->aaaa0()!=':' && strchr(tok->aaaa(), ':'))))
{ {
const TOKEN *next = tok->next; const TOKEN *next = tok->next;
@ -79,9 +79,9 @@ struct VAR *CheckClass::ClassChecking_GetVarList(const TOKEN *tok1)
const char *types[] = {"bool", "char", "int", "short", "long", "float", "double", 0}; const char *types[] = {"bool", "char", "int", "short", "long", "float", "double", 0};
for ( int type = 0; types[type]; type++ ) for ( int type = 0; types[type]; type++ )
{ {
if ( strcmp(next->str, types[type]) == 0) if ( strcmp(next->aaaa(), types[type]) == 0)
{ {
varname = next->next->str; varname = next->next->aaaa();
break; break;
} }
} }
@ -132,7 +132,7 @@ const TOKEN * CheckClass::FindClassFunction( const TOKEN *tok, const char classn
indentlevel = 1; indentlevel = 1;
} }
if ( tok->str[0] == '{' ) if ( tok->aaaa0() == '{' )
{ {
// If indentlevel==0 don't go to indentlevel 1. Skip the block. // If indentlevel==0 don't go to indentlevel 1. Skip the block.
if ( indentlevel > 0 ) if ( indentlevel > 0 )
@ -142,9 +142,9 @@ const TOKEN * CheckClass::FindClassFunction( const TOKEN *tok, const char classn
{ {
for ( ; tok; tok = tok->next ) for ( ; tok; tok = tok->next )
{ {
if ( tok->str[0] == '{' ) if ( tok->aaaa0() == '{' )
++indentlevel; ++indentlevel;
else if ( tok->str[0] == '}' ) else if ( tok->aaaa0() == '}' )
{ {
--indentlevel; --indentlevel;
if ( indentlevel <= 0 ) if ( indentlevel <= 0 )
@ -158,7 +158,7 @@ const TOKEN * CheckClass::FindClassFunction( const TOKEN *tok, const char classn
} }
} }
if ( tok->str[0] == '}' ) if ( tok->aaaa0() == '}' )
{ {
indentlevel--; indentlevel--;
if ( indentlevel < 0 ) if ( indentlevel < 0 )
@ -171,9 +171,9 @@ const TOKEN * CheckClass::FindClassFunction( const TOKEN *tok, const char classn
if ( TOKEN::Match( tok, "%var1% (", _funcname ) ) if ( TOKEN::Match( tok, "%var1% (", _funcname ) )
{ {
const TOKEN *tok2 = tok; const TOKEN *tok2 = tok;
while ( tok2 && tok2->str[0] != '{' && tok2->str[0] != ';' ) while ( tok2 && tok2->aaaa0() != '{' && tok2->aaaa0() != ';' )
tok2 = tok2->next; tok2 = tok2->next;
if ( tok2 && tok2->str[0] == '{' ) if ( tok2 && tok2->aaaa0() == '{' )
return tok; return tok;
} }
} }
@ -218,20 +218,20 @@ void CheckClass::ClassChecking_VarList_Initialize(const TOKEN *tok1, const TOKEN
{ {
if (Assign && TOKEN::Match(ftok, "%var% (")) if (Assign && TOKEN::Match(ftok, "%var% ("))
{ {
InitVar( varlist, ftok->str ); InitVar( varlist, ftok->aaaa() );
} }
Assign |= (ftok->str[0] == ':'); Assign |= (ftok->aaaa0() == ':');
} }
if (ftok->str[0] == '{') if (ftok->aaaa0() == '{')
{ {
indentlevel++; indentlevel++;
Assign = false; Assign = false;
} }
if (ftok->str[0] == '}') if (ftok->aaaa0() == '}')
{ {
if (indentlevel <= 1) if (indentlevel <= 1)
break; break;
@ -275,11 +275,11 @@ void CheckClass::ClassChecking_VarList_Initialize(const TOKEN *tok1, const TOKEN
else if (TOKEN::Match(ftok, "%var% (")) else if (TOKEN::Match(ftok, "%var% ("))
{ {
// No recursive calls! // No recursive calls!
if ( std::find(callstack.begin(),callstack.end(),ftok->str) == callstack.end() ) if ( std::find(callstack.begin(),callstack.end(),ftok->aaaa()) == callstack.end() )
{ {
callstack.push_back( ftok->str ); callstack.push_back( ftok->aaaa() );
int i = 0; int i = 0;
const TOKEN *ftok2 = FindClassFunction( tok1, classname, ftok->str, i ); const TOKEN *ftok2 = FindClassFunction( tok1, classname, ftok->aaaa(), i );
ClassChecking_VarList_Initialize(tok1, ftok2, varlist, classname, callstack); ClassChecking_VarList_Initialize(tok1, ftok2, varlist, classname, callstack);
} }
} }
@ -287,13 +287,13 @@ void CheckClass::ClassChecking_VarList_Initialize(const TOKEN *tok1, const TOKEN
// Assignment of member variable? // Assignment of member variable?
else if (TOKEN::Match(ftok, "%var% =")) else if (TOKEN::Match(ftok, "%var% ="))
{ {
InitVar( varlist, ftok->str ); InitVar( varlist, ftok->aaaa() );
} }
// The functions 'clear' and 'Clear' are supposed to initialize variable. // The functions 'clear' and 'Clear' are supposed to initialize variable.
if (TOKEN::Match(ftok,"%var% . clear (") || TOKEN::Match(ftok,"%var% . Clear (")) if (TOKEN::Match(ftok,"%var% . clear (") || TOKEN::Match(ftok,"%var% . Clear ("))
{ {
InitVar( varlist, ftok->str ); InitVar( varlist, ftok->aaaa() );
} }
} }
} }
@ -314,7 +314,7 @@ void CheckClass::CheckConstructors()
const TOKEN *tok1 = TOKEN::findtoken(_tokenizer->tokens(), pattern_classname); const TOKEN *tok1 = TOKEN::findtoken(_tokenizer->tokens(), pattern_classname);
while (tok1) while (tok1)
{ {
const char *classname = tok1->next->str; const char *classname = tok1->next->aaaa();
if ( !(tok1->next->isName()) ) if ( !(tok1->next->isName()) )
{ {
tok1 = TOKEN::findtoken( tok1->next, pattern_classname ); tok1 = TOKEN::findtoken( tok1->next, pattern_classname );
@ -325,7 +325,7 @@ void CheckClass::CheckConstructors()
const char *constructor_pattern[] = {"","clKalle","(",NULL}; const char *constructor_pattern[] = {"","clKalle","(",NULL};
constructor_pattern[1] = classname; constructor_pattern[1] = classname;
const TOKEN *constructor_token = TOKEN::findtoken( _tokenizer->tokens(), constructor_pattern ); const TOKEN *constructor_token = TOKEN::findtoken( _tokenizer->tokens(), constructor_pattern );
while ( constructor_token && constructor_token->str[0] == '~' ) while ( constructor_token && constructor_token->aaaa0() == '~' )
constructor_token = TOKEN::findtoken( constructor_token->next, constructor_pattern ); constructor_token = TOKEN::findtoken( constructor_token->next, constructor_pattern );
if ( ! constructor_token ) if ( ! constructor_token )
{ {
@ -414,7 +414,7 @@ void CheckClass::CheckUnusedPrivateFunctions()
const char *pattern_class[] = {"class","","{",NULL}; const char *pattern_class[] = {"class","","{",NULL};
for (const TOKEN *tok1 = TOKEN::findtoken(_tokenizer->tokens(), pattern_class); tok1; tok1 = TOKEN::findtoken(tok1->next, pattern_class)) for (const TOKEN *tok1 = TOKEN::findtoken(_tokenizer->tokens(), pattern_class); tok1; tok1 = TOKEN::findtoken(tok1->next, pattern_class))
{ {
const char *classname = tok1->next->str; const char *classname = tok1->next->aaaa();
// The class implementation must be available.. // The class implementation must be available..
const char *pattern_classconstructor[] = {"","::","",NULL}; const char *pattern_classconstructor[] = {"","::","",NULL};
@ -437,21 +437,21 @@ void CheckClass::CheckUnusedPrivateFunctions()
break; break;
} }
if (tok->str[0] == '{') if (tok->aaaa0() == '{')
indent_level++; indent_level++;
if (tok->str[0] == '}') if (tok->aaaa0() == '}')
{ {
if (indent_level <= 1) if (indent_level <= 1)
break; break;
indent_level--; indent_level--;
} }
if (strcmp(tok->str,"};") == 0) if (strcmp(tok->aaaa(),"};") == 0)
break; break;
if (strcmp(tok->str,"private:") == 0) if (strcmp(tok->aaaa(),"private:") == 0)
priv = true; priv = true;
else if (strcmp(tok->str,"public:") == 0) else if (strcmp(tok->aaaa(),"public:") == 0)
priv = false; priv = false;
else if (strcmp(tok->str,"protected:") == 0) else if (strcmp(tok->aaaa(),"protected:") == 0)
priv = false; priv = false;
else if (priv && indent_level == 1) else if (priv && indent_level == 1)
{ {
@ -461,7 +461,7 @@ void CheckClass::CheckUnusedPrivateFunctions()
if (TOKEN::Match(tok, "%var% (") && if (TOKEN::Match(tok, "%var% (") &&
!TOKEN::Match(tok,classname)) !TOKEN::Match(tok,classname))
{ {
FuncList.push_back(tok->str); FuncList.push_back(tok->aaaa());
} }
} }
} }
@ -475,11 +475,11 @@ void CheckClass::CheckUnusedPrivateFunctions()
{ {
ftok = TOKEN::findtoken(ftok,pattern_function); ftok = TOKEN::findtoken(ftok,pattern_function);
int numpar = 0; int numpar = 0;
while (ftok && ftok->str[0]!=';' && ftok->str[0]!='{') while (ftok && ftok->aaaa0()!=';' && ftok->aaaa0()!='{')
{ {
if (ftok->str[0] == '(') if (ftok->aaaa0() == '(')
numpar++; numpar++;
else if (ftok->str[0] == ')') else if (ftok->aaaa0() == ')')
numpar--; numpar--;
ftok = ftok->next; ftok = ftok->next;
} }
@ -487,23 +487,23 @@ void CheckClass::CheckUnusedPrivateFunctions()
if (!ftok) if (!ftok)
break; break;
if (ftok->str[0] != ';' && numpar == 0) if (ftok->aaaa0() != ';' && numpar == 0)
{ {
HasFuncImpl = true; HasFuncImpl = true;
indent_level = 0; indent_level = 0;
while (ftok) while (ftok)
{ {
if (ftok->str[0] == '{') if (ftok->aaaa0() == '{')
indent_level++; indent_level++;
if (ftok->str[0] == '}') if (ftok->aaaa0() == '}')
{ {
if (indent_level<=1) if (indent_level<=1)
break; break;
indent_level--; indent_level--;
} }
if (ftok->next && ftok->next->str[0] == '(') if (ftok->next && ftok->next->aaaa0() == '(')
FuncList.remove(ftok->str); FuncList.remove(ftok->aaaa());
ftok = ftok->next; ftok = ftok->next;
} }
} }
@ -575,7 +575,7 @@ void CheckClass::CheckMemset()
if (TOKEN::findtoken(_tokenizer->tokens(),pattern1)) if (TOKEN::findtoken(_tokenizer->tokens(),pattern1))
{ {
std::ostringstream ostr; std::ostringstream ostr;
ostr << _tokenizer->fileLine(tok) << ": Using '" << tok->str << "' on class."; ostr << _tokenizer->fileLine(tok) << ": Using '" << tok->aaaa() << "' on class.";
_errorLogger->reportErr(ostr.str()); _errorLogger->reportErr(ostr.str());
continue; continue;
} }
@ -585,13 +585,13 @@ void CheckClass::CheckMemset()
pattern2[1] = type; pattern2[1] = type;
for (const TOKEN *tstruct = TOKEN::findtoken(_tokenizer->tokens(), pattern2); tstruct; tstruct = tstruct->next) for (const TOKEN *tstruct = TOKEN::findtoken(_tokenizer->tokens(), pattern2); tstruct; tstruct = tstruct->next)
{ {
if (tstruct->str[0] == '}') if (tstruct->aaaa0() == '}')
break; break;
if (TOKEN::Match(tstruct, "std :: %type% %var% ;")) if (TOKEN::Match(tstruct, "std :: %type% %var% ;"))
{ {
std::ostringstream ostr; std::ostringstream ostr;
ostr << _tokenizer->fileLine(tok) << ": Using '" << tok->str << "' on struct that contains a 'std::" << tstruct->strAt(2) << "'"; ostr << _tokenizer->fileLine(tok) << ": Using '" << tok->aaaa() << "' on struct that contains a 'std::" << tstruct->strAt(2) << "'";
_errorLogger->reportErr(ostr.str()); _errorLogger->reportErr(ostr.str());
break; break;
} }

View File

@ -71,7 +71,7 @@ void CheckFunctionUsage::parseTokens( const Tokenizer &tokenizer )
if ( funcname ) if ( funcname )
{ {
FunctionUsage &func = _functions[ funcname->str ]; FunctionUsage &func = _functions[ funcname->aaaa() ];
// No filename set yet.. // No filename set yet..
if (func.filename.empty()) if (func.filename.empty())
@ -107,10 +107,10 @@ void CheckFunctionUsage::parseTokens( const Tokenizer &tokenizer )
int parlevel = 0; int parlevel = 0;
for ( const TOKEN *tok2 = funcname; tok2; tok2 = tok2->next ) for ( const TOKEN *tok2 = funcname; tok2; tok2 = tok2->next )
{ {
if (TOKEN::Match(tok2, "(")) if (tok2->str() == "(")
++parlevel; ++parlevel;
else if (TOKEN::Match(tok2, ")")) else if (tok2->str() == ")")
{ {
--parlevel; --parlevel;
if (parlevel == 0 && (TOKEN::Match(tok2, ") {") || TOKEN::Match(tok2, ") const"))) if (parlevel == 0 && (TOKEN::Match(tok2, ") {") || TOKEN::Match(tok2, ") const")))
@ -123,7 +123,7 @@ void CheckFunctionUsage::parseTokens( const Tokenizer &tokenizer )
if ( funcname ) if ( funcname )
{ {
FunctionUsage &func = _functions[ funcname->str ]; FunctionUsage &func = _functions[ funcname->aaaa() ];
if ( func.filename.empty() || func.filename == "+" ) if ( func.filename.empty() || func.filename == "+" )
func.usedOtherFile = true; func.usedOtherFile = true;

View File

@ -85,12 +85,12 @@ void CheckHeaders::WarningIncludeHeader()
// Including.. // Including..
for ( const TOKEN *includetok = _tokenizer->tokens(); includetok; includetok = includetok->next) for ( const TOKEN *includetok = _tokenizer->tokens(); includetok; includetok = includetok->next)
{ {
if (strcmp(includetok->str, "#include") != 0) if (strcmp(includetok->aaaa(), "#include") != 0)
continue; continue;
// Get fileindex of included file.. // Get fileindex of included file..
unsigned int hfile = 0; unsigned int hfile = 0;
const char *includefile = includetok->next->str; const char *includefile = includetok->next->aaaa();
while (hfile < _tokenizer->getFiles()->size()) while (hfile < _tokenizer->getFiles()->size())
{ {
if ( Tokenizer::SameFileName( _tokenizer->getFiles()->at(hfile).c_str(), includefile ) ) if ( Tokenizer::SameFileName( _tokenizer->getFiles()->at(hfile).c_str(), includefile ) )
@ -118,10 +118,10 @@ void CheckHeaders::WarningIncludeHeader()
continue; continue;
// I'm only interested in stuff that is declared at indentlevel 0 // I'm only interested in stuff that is declared at indentlevel 0
if (tok1->str[0] == '{') if (tok1->aaaa0() == '{')
indentlevel++; indentlevel++;
else if (tok1->str[0] == '}') else if (tok1->aaaa0() == '}')
indentlevel--; indentlevel--;
if (indentlevel != 0) if (indentlevel != 0)
@ -148,13 +148,13 @@ void CheckHeaders::WarningIncludeHeader()
// enum.. // enum..
// -------------------------------------- // --------------------------------------
else if (strcmp(tok1->str, "enum") == 0) else if (strcmp(tok1->aaaa(), "enum") == 0)
{ {
tok1 = tok1->next; tok1 = tok1->next;
while (tok1->next && tok1->str[0]!=';') while (tok1->next && tok1->aaaa0()!=';')
{ {
if ( tok1->isName() ) if ( tok1->isName() )
namelist.push_back(tok1->str); namelist.push_back(tok1->aaaa());
tok1 = tok1->next; tok1 = tok1->next;
} }
} }
@ -175,26 +175,26 @@ void CheckHeaders::WarningIncludeHeader()
// typedef.. // typedef..
// -------------------------------------- // --------------------------------------
else if (strcmp(tok1->str,"typedef")==0) else if (strcmp(tok1->aaaa(),"typedef")==0)
{ {
if (strcmp(tok1->strAt(1),"enum")==0) if (strcmp(tok1->strAt(1),"enum")==0)
continue; continue;
int parlevel = 0; int parlevel = 0;
while (tok1->next) while (tok1->next)
{ {
if ( strchr("({", tok1->str[0]) ) if ( strchr("({", tok1->aaaa0()) )
parlevel++; parlevel++;
else if ( strchr(")}", tok1->str[0]) ) else if ( strchr(")}", tok1->aaaa0()) )
parlevel--; parlevel--;
else if (parlevel == 0) else if (parlevel == 0)
{ {
if ( tok1->str[0] == ';' ) if ( tok1->aaaa0() == ';' )
break; break;
if ( TOKEN::Match(tok1, "%var% ;") ) if ( TOKEN::Match(tok1, "%var% ;") )
namelist.push_back(tok1->str); namelist.push_back(tok1->aaaa());
} }
tok1 = tok1->next; tok1 = tok1->next;
@ -224,14 +224,14 @@ void CheckHeaders::WarningIncludeHeader()
if ( ! tok1->isName() ) if ( ! tok1->isName() )
continue; continue;
if (std::find(namelist.begin(),namelist.end(),tok1->str ) != namelist.end()) if (std::find(namelist.begin(),namelist.end(),tok1->aaaa() ) != namelist.end())
{ {
Needed = true; Needed = true;
break; break;
} }
if ( ! NeedDeclaration ) if ( ! NeedDeclaration )
NeedDeclaration = (std::find(classlist.begin(),classlist.end(),tok1->str ) != classlist.end()); NeedDeclaration = (std::find(classlist.begin(),classlist.end(),tok1->aaaa() ) != classlist.end());
} }

View File

@ -74,9 +74,9 @@ CheckMemoryLeakClass::AllocType CheckMemoryLeakClass::GetAllocationType( const T
// * var = (char *)malloc(10); // * var = (char *)malloc(10);
// * var = new char[10]; // * var = new char[10];
// * var = strdup("hello"); // * var = strdup("hello");
if ( tok2 && tok2->str[0] == '(' ) if ( tok2 && tok2->aaaa0() == '(' )
{ {
while ( tok2 && tok2->str[0] != ')' ) while ( tok2 && tok2->aaaa0() != ')' )
tok2 = tok2->next; tok2 = tok2->next;
tok2 = tok2 ? tok2->next : NULL; tok2 = tok2 ? tok2->next : NULL;
} }
@ -93,7 +93,7 @@ CheckMemoryLeakClass::AllocType CheckMemoryLeakClass::GetAllocationType( const T
0}; 0};
for ( unsigned int i = 0; mallocfunc[i]; i++ ) for ( unsigned int i = 0; mallocfunc[i]; i++ )
{ {
if ( strcmp(mallocfunc[i], tok2->str) == 0 ) if ( strcmp(mallocfunc[i], tok2->aaaa()) == 0 )
return Malloc; return Malloc;
} }
@ -115,7 +115,7 @@ CheckMemoryLeakClass::AllocType CheckMemoryLeakClass::GetAllocationType( const T
0}; 0};
for ( unsigned int i = 0; gmallocfunc[i]; i++ ) for ( unsigned int i = 0; gmallocfunc[i]; i++ )
{ {
if ( strcmp(gmallocfunc[i], tok2->str) == 0 ) if ( strcmp(gmallocfunc[i], tok2->aaaa()) == 0 )
return gMalloc; return gMalloc;
} }
@ -135,7 +135,7 @@ CheckMemoryLeakClass::AllocType CheckMemoryLeakClass::GetAllocationType( const T
std::list<AllocFunc>::const_iterator it = _listAllocFunc.begin(); std::list<AllocFunc>::const_iterator it = _listAllocFunc.begin();
while ( it != _listAllocFunc.end() ) while ( it != _listAllocFunc.end() )
{ {
if ( strcmp(tok2->str, it->funcname) == 0 ) if ( strcmp(tok2->aaaa(), it->funcname) == 0 )
return it->alloctype; return it->alloctype;
++it; ++it;
} }
@ -149,7 +149,7 @@ CheckMemoryLeakClass::AllocType CheckMemoryLeakClass::GetDeallocationType( const
if ( TOKEN::Match(tok, "if ( %var1% )", varnames) ) if ( TOKEN::Match(tok, "if ( %var1% )", varnames) )
{ {
tok = tok->tokAt(4); tok = tok->tokAt(4);
if ( TOKEN::Match(tok,"{") ) if (tok->str() =="{")
tok = tok->next; tok = tok->next;
} }
@ -189,10 +189,10 @@ const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list<const
if ( callstack.size() > 2 ) if ( callstack.size() > 2 )
return "dealloc"; return "dealloc";
const char *funcname = tok->str; const char *funcname = tok->aaaa();
for ( std::list<const TOKEN *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it ) for ( std::list<const TOKEN *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it )
{ {
if ( std::string(funcname) == (*it)->str ) if ( std::string(funcname) == (*it)->aaaa() )
return "dealloc"; return "dealloc";
} }
callstack.push_back(tok); callstack.push_back(tok);
@ -201,9 +201,9 @@ const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list<const
int parlevel = 0; int parlevel = 0;
for ( ; tok; tok = tok->next ) for ( ; tok; tok = tok->next )
{ {
if ( TOKEN::Match(tok, "(") ) if ( tok->str() == "(" )
++parlevel; ++parlevel;
else if ( TOKEN::Match(tok, ")") ) else if ( tok->str() == ")" )
{ {
--parlevel; --parlevel;
if ( parlevel < 1 ) if ( parlevel < 1 )
@ -212,7 +212,7 @@ const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list<const
if ( parlevel == 1 ) if ( parlevel == 1 )
{ {
if ( TOKEN::Match(tok, ",") ) if ( tok->str() == "," )
++par; ++par;
if ( TOKEN::Match(tok, "[,()] %var1% [,()]", varnames) ) if ( TOKEN::Match(tok, "[,()] %var1% [,()]", varnames) )
{ {
@ -221,7 +221,7 @@ const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list<const
if ( ! parname ) if ( ! parname )
return "use"; return "use";
// Check if the function deallocates the variable.. // Check if the function deallocates the variable..
while ( ftok && ! TOKEN::Match(ftok,"{") ) while ( ftok && (ftok->str() != "{") )
ftok = ftok->next; ftok = ftok->next;
TOKEN *func = getcode( ftok->tokAt(1), callstack, parname, alloctype, dealloctype ); TOKEN *func = getcode( ftok->tokAt(1), callstack, parname, alloctype, dealloctype );
simplifycode( func ); simplifycode( func );
@ -312,12 +312,12 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
int parlevel = 0; int parlevel = 0;
for ( ; tok; tok = tok->next ) for ( ; tok; tok = tok->next )
{ {
if ( tok->str[0] == '{' ) if ( tok->aaaa0() == '{' )
{ {
addtoken( "{" ); addtoken( "{" );
indentlevel++; indentlevel++;
} }
else if ( tok->str[0] == '}' ) else if ( tok->aaaa0() == '}' )
{ {
addtoken( "}" ); addtoken( "}" );
if ( indentlevel <= 0 ) if ( indentlevel <= 0 )
@ -325,13 +325,13 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
indentlevel--; indentlevel--;
} }
if ( tok->str[0] == '(' ) if ( tok->aaaa0() == '(' )
parlevel++; parlevel++;
else if ( tok->str[0] == ')' ) else if ( tok->aaaa0() == ')' )
parlevel--; parlevel--;
isloop &= ( parlevel > 0 ); isloop &= ( parlevel > 0 );
if ( parlevel == 0 && tok->str[0]==';') if ( parlevel == 0 && tok->aaaa0()==';')
addtoken(";"); addtoken(";");
if (TOKEN::Match(tok, "[(;{}] %var1% =", varnames)) if (TOKEN::Match(tok, "[(;{}] %var1% =", varnames))
@ -397,15 +397,15 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
int parlevel = 0; int parlevel = 0;
for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next ) for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next )
{ {
if ( TOKEN::Match(tok2,"(") ) if ( tok2->str() == "(" )
++parlevel; ++parlevel;
if ( TOKEN::Match(tok2,")") ) if ( tok2->str() == ")" )
{ {
--parlevel; --parlevel;
if ( parlevel <= 0 ) if ( parlevel <= 0 )
break; break;
} }
if ( !TOKEN::Match(tok2,".") && if ( (tok2->str() != ".") &&
TOKEN::Match(tok2->next, "%var1%", varnames) && TOKEN::Match(tok2->next, "%var1%", varnames) &&
!TOKEN::Match(tok2->next, "%var1% .", varnames) ) !TOKEN::Match(tok2->next, "%var1% .", varnames) )
{ {
@ -415,30 +415,30 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
} }
addtoken( (dep ? "ifv" : "if") ); addtoken( (dep ? "ifv" : "if") );
} }
else if ( TOKEN::Match(tok, "else") || TOKEN::Match(tok, "switch") ) else if ( (tok->str() == "else") || (tok->str() == "switch") )
{ {
addtoken(tok->str); addtoken(tok->aaaa());
} }
if ( TOKEN::Match(tok, "case") ) if ( (tok->str() == "case") )
{ {
addtoken("case"); addtoken("case");
addtoken(";"); addtoken(";");
} }
if ( TOKEN::Match(tok, "default") ) if ( (tok->str() == "default") )
{ {
addtoken("case"); addtoken("case");
addtoken(";"); addtoken(";");
} }
// Loops.. // Loops..
if (TOKEN::Match(tok, "for") || TOKEN::Match(tok, "while") ) if ((tok->str() == "for") || (tok->str() == "while") )
{ {
addtoken("loop"); addtoken("loop");
isloop = true; isloop = true;
} }
if ( TOKEN::Match(tok, "do") ) if ( (tok->str() == "do") )
{ {
addtoken("do"); addtoken("do");
} }
@ -446,19 +446,19 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
addtoken("!var"); addtoken("!var");
// continue / break.. // continue / break..
if ( TOKEN::Match(tok, "continue") ) if ( tok->str() == "continue" )
addtoken("continue"); addtoken("continue");
if ( TOKEN::Match(tok, "break") ) if ( tok->str() == "break" )
addtoken("break"); addtoken("break");
// goto.. // goto..
if ( TOKEN::Match(tok, "goto") ) if ( tok->str() == "goto" )
{ {
addtoken("goto"); addtoken("goto");
} }
// Return.. // Return..
if ( TOKEN::Match(tok, "return") ) if ( tok->str() == "return" )
{ {
addtoken("return"); addtoken("return");
if ( TOKEN::Match(tok, "return %var1%", varnames) || if ( TOKEN::Match(tok, "return %var1%", varnames) ||
@ -467,7 +467,7 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
} }
// throw.. // throw..
if ( TOKEN::Match(tok, "throw") ) if ( tok->str() == "throw" )
addtoken("throw"); addtoken("throw");
// Assignment.. // Assignment..
@ -532,13 +532,13 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
int indentlevel = 0; int indentlevel = 0;
for ( tok2_ = tok2; tok2_ && indentlevel>=0; tok2_ = tok2_->next ) for ( tok2_ = tok2; tok2_ && indentlevel>=0; tok2_ = tok2_->next )
{ {
if ( TOKEN::Match(tok2_, "{") ) if ( tok2_->str() == "{" )
++indentlevel; ++indentlevel;
else if ( TOKEN::Match(tok2_, "}") ) else if ( tok2_->str() == "}" )
--indentlevel; --indentlevel;
else if ( indentlevel == 0 && TOKEN::Match(tok2_->next, ";") ) else if ( indentlevel == 0 && (tok2_->next->str() == ";") )
break; break;
} }
@ -550,13 +550,13 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
indentlevel = 0; indentlevel = 0;
do do
{ {
if ( TOKEN::Match( tok2, "{" ) ) if ( tok2->str() == "{" )
++indentlevel; ++indentlevel;
else if ( TOKEN::Match(tok2, "}") ) else if ( tok2->str() == "}" )
--indentlevel; --indentlevel;
// Copy token.. // Copy token..
instoken( tok2_, tok2->str ); instoken( tok2_, tok2->aaaa() );
// Next token.. // Next token..
tok2 = tok2->next; tok2 = tok2->next;
@ -713,22 +713,22 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
bool incase = false; bool incase = false;
for ( const TOKEN * _tok = tok2->tokAt(2); _tok; _tok = _tok->next ) for ( const TOKEN * _tok = tok2->tokAt(2); _tok; _tok = _tok->next )
{ {
if ( _tok->str[0] == '{' ) if ( _tok->aaaa0() == '{' )
break; break;
else if ( _tok->str[0] == '}' ) else if ( _tok->aaaa0() == '}' )
{ {
valid = true; valid = true;
break; break;
} }
else if (strncmp(_tok->str,"if",2)==0) else if (strncmp(_tok->aaaa(),"if",2)==0)
break; break;
else if (strcmp(_tok->str,"switch")==0) else if (strcmp(_tok->aaaa(),"switch")==0)
break; break;
else if (strcmp(_tok->str,"loop")==0) else if (strcmp(_tok->aaaa(),"loop")==0)
break; break;
else if (incase && TOKEN::Match(_tok,"case")) else if (incase && TOKEN::Match(_tok,"case"))
@ -762,7 +762,7 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
instoken( tok2, "if" ); instoken( tok2, "if" );
instoken( tok2, "else" ); instoken( tok2, "else" );
} }
while ( tok2 && tok2->str[0] != '}' && ! TOKEN::Match(tok2,"break ;") ) while ( tok2 && tok2->aaaa0() != '}' && ! TOKEN::Match(tok2,"break ;") )
tok2 = tok2->next; tok2 = tok2->next;
if (TOKEN::Match(tok2,"break ;")) if (TOKEN::Match(tok2,"break ;"))
{ {
@ -885,10 +885,10 @@ void CheckMemoryLeakClass::CheckMemoryLeak_InFunction()
int indentlevel = 0; int indentlevel = 0;
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next) for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next)
{ {
if (tok->str[0]=='{') if (tok->aaaa0()=='{')
indentlevel++; indentlevel++;
else if (tok->str[0]=='}') else if (tok->aaaa0()=='}')
indentlevel--; indentlevel--;
@ -928,10 +928,10 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers()
int indentlevel = 0; int indentlevel = 0;
for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next ) for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next )
{ {
if ( tok->str[0] == '{' ) if ( tok->aaaa0() == '{' )
indentlevel++; indentlevel++;
else if ( tok->str[0] == '}' ) else if ( tok->aaaa0() == '}' )
indentlevel--; indentlevel--;
else if ( indentlevel == 0 && TOKEN::Match(tok, "class %var% [{:]") ) else if ( indentlevel == 0 && TOKEN::Match(tok, "class %var% [{:]") )
@ -947,7 +947,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers()
void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_ParseClass( const TOKEN *tok1, std::vector<const char *> &classname ) void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_ParseClass( const TOKEN *tok1, std::vector<const char *> &classname )
{ {
// Go into class. // Go into class.
while ( tok1 && tok1->str[0] != '{' ) while ( tok1 && tok1->aaaa0() != '{' )
tok1 = tok1->next; tok1 = tok1->next;
if ( tok1 ) if ( tok1 )
tok1 = tok1->next; tok1 = tok1->next;
@ -955,10 +955,10 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_ParseClass( const TOKEN
int indentlevel = 0; int indentlevel = 0;
for ( const TOKEN *tok = tok1; tok; tok = tok->next ) for ( const TOKEN *tok = tok1; tok; tok = tok->next )
{ {
if ( tok->str[0] == '{' ) if ( tok->aaaa0() == '{' )
indentlevel++; indentlevel++;
else if ( tok->str[0] == '}' ) else if ( tok->aaaa0() == '}' )
{ {
indentlevel--; indentlevel--;
if ( indentlevel < 0 ) if ( indentlevel < 0 )
@ -980,7 +980,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_ParseClass( const TOKEN
// Declaring member variable.. check allocations and deallocations // Declaring member variable.. check allocations and deallocations
if ( TOKEN::Match(tok->next, "%type% * %var% ;") ) if ( TOKEN::Match(tok->next, "%type% * %var% ;") )
{ {
if ( tok->isName() || strchr(";}", tok->str[0]) ) if ( tok->isName() || strchr(";}", tok->aaaa0()) )
{ {
if (_settings._showAll || !isclass(tok->strAt(1))) if (_settings._showAll || !isclass(tok->strAt(1)))
CheckMemoryLeak_ClassMembers_Variable( classname, tok->strAt(3) ); CheckMemoryLeak_ClassMembers_Variable( classname, tok->strAt(3) );
@ -1026,16 +1026,16 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_Variable( const std::vec
int indentlevel = 0; int indentlevel = 0;
for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next ) for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next )
{ {
if ( tok->str[0] == '{' ) if ( tok->aaaa0() == '{' )
indentlevel++; indentlevel++;
else if ( tok->str[0] == '}' ) else if ( tok->aaaa0() == '}' )
indentlevel--; indentlevel--;
// Set the 'memberfunction' variable.. // Set the 'memberfunction' variable..
if ( indentlevel == 0 ) if ( indentlevel == 0 )
{ {
if ( strchr(";}", tok->str[0]) ) if ( strchr(";}", tok->aaaa0()) )
memberfunction = false; memberfunction = false;
else if ( TOKEN::Match( tok, fpattern.str().c_str() ) || TOKEN::Match( tok, destructor.str().c_str() ) ) else if ( TOKEN::Match( tok, fpattern.str().c_str() ) || TOKEN::Match( tok, destructor.str().c_str() ) )
memberfunction = true; memberfunction = true;

View File

@ -101,7 +101,7 @@ void CheckOther::WarningIsAlpha()
{ {
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next) for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next)
{ {
if ( ! TOKEN::Match(tok, "(") ) if ( tok->str() != "(" )
continue; continue;
bool err = false; bool err = false;
@ -161,7 +161,7 @@ void CheckOther::WarningRedundantCode()
// if (p) delete p // if (p) delete p
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next) for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next)
{ {
if (!TOKEN::Match(tok,"if")) if ( tok->str() != "if" )
continue; continue;
const char *varname1 = NULL; const char *varname1 = NULL;
@ -181,7 +181,7 @@ void CheckOther::WarningRedundantCode()
if (varname1==NULL || tok2==NULL) if (varname1==NULL || tok2==NULL)
continue; continue;
if ( TOKEN::Match(tok2, "{") ) if ( tok2->str() == "{" )
tok2 = tok2->next; tok2 = tok2->next;
bool err = false; bool err = false;
@ -223,14 +223,14 @@ void CheckOther::WarningIf()
// Search for 'if (condition);' // Search for 'if (condition);'
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next) for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next)
{ {
if (TOKEN::Match(tok,"if")) if (tok->str() == "if")
{ {
int parlevel = 0; int parlevel = 0;
for (const TOKEN *tok2 = tok->next; tok2; tok2 = tok2->next) for (const TOKEN *tok2 = tok->next; tok2; tok2 = tok2->next)
{ {
if (TOKEN::Match(tok2,"(")) if (tok2->str() == "(")
parlevel++; parlevel++;
else if (TOKEN::Match(tok2,")")) else if (tok2->str() == ")")
{ {
parlevel--; parlevel--;
if (parlevel<=0) if (parlevel<=0)
@ -312,7 +312,7 @@ void CheckOther::InvalidFunctionUsage()
{ {
for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next ) for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next )
{ {
if (!TOKEN::Match(tok, "strtol") && !TOKEN::Match(tok, "strtoul")) if ((tok->str() != "strtol") && (tok->str() != "strtoul"))
continue; continue;
// Locate the third parameter of the function call.. // Locate the third parameter of the function call..
@ -447,21 +447,21 @@ void CheckOther::CheckVariableScope()
for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next ) for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next )
{ {
// Skip class and struct declarations.. // Skip class and struct declarations..
if ( TOKEN::Match(tok, "class") || TOKEN::Match(tok, "struct") ) if ( (tok->str() == "class") || (tok->str() == "struct") )
{ {
for (const TOKEN *tok2 = tok; tok2; tok2 = tok2->next) for (const TOKEN *tok2 = tok; tok2; tok2 = tok2->next)
{ {
if ( TOKEN::Match(tok2, "{") ) if ( tok2->str() == "{" )
{ {
int _indentlevel = 0; int _indentlevel = 0;
tok = tok2; tok = tok2;
for (tok = tok2; tok; tok = tok->next) for (tok = tok2; tok; tok = tok->next)
{ {
if ( TOKEN::Match(tok, "{") ) if ( tok->str() == "{" )
{ {
_indentlevel++; _indentlevel++;
} }
if ( TOKEN::Match(tok, "}") ) if ( tok->str() == "}" )
{ {
_indentlevel--; _indentlevel--;
if ( _indentlevel <= 0 ) if ( _indentlevel <= 0 )
@ -482,11 +482,11 @@ void CheckOther::CheckVariableScope()
break; break;
} }
if ( TOKEN::Match(tok, "{") ) if ( tok->str() == "{" )
{ {
indentlevel++; indentlevel++;
} }
if ( TOKEN::Match(tok, "}") ) if ( tok->str() == "}" )
{ {
indentlevel--; indentlevel--;
if ( indentlevel == 0 ) if ( indentlevel == 0 )
@ -503,10 +503,10 @@ void CheckOther::CheckVariableScope()
if ( ! tok1 ) if ( ! tok1 )
continue; continue;
if (TOKEN::Match(tok1,"return") || if ((tok1->str() == "return") ||
TOKEN::Match(tok1,"delete") || (tok1->str() == "delete") ||
TOKEN::Match(tok1,"goto") || (tok1->str() == "goto") ||
TOKEN::Match(tok1,"else")) (tok1->str() == "else"))
continue; continue;
// Variable declaration? // Variable declaration?
@ -536,12 +536,12 @@ void CheckOther::CheckVariableScope_LookupVar( const TOKEN *tok1, const char var
bool for_or_while = false; bool for_or_while = false;
while ( indentlevel >= 0 && tok ) while ( indentlevel >= 0 && tok )
{ {
if ( TOKEN::Match(tok, "{") ) if ( tok->str() == "{" )
{ {
indentlevel++; indentlevel++;
} }
else if ( TOKEN::Match(tok, "}") ) else if ( tok->str() == "}" )
{ {
indentlevel--; indentlevel--;
if ( indentlevel == 0 ) if ( indentlevel == 0 )
@ -553,18 +553,18 @@ void CheckOther::CheckVariableScope_LookupVar( const TOKEN *tok1, const char var
} }
} }
else if ( TOKEN::Match(tok, "(") ) else if ( tok->str() == "(" )
{ {
parlevel++; parlevel++;
} }
else if ( TOKEN::Match(tok, ")") ) else if ( tok->str() == ")" )
{ {
parlevel--; parlevel--;
} }
else if ( strcmp(tok->strAt( 0), varname) == 0 ) else if ( tok->str() == varname )
{ {
if ( indentlevel == 0 || used1 ) if ( indentlevel == 0 || used1 )
return; return;
@ -573,9 +573,9 @@ void CheckOther::CheckVariableScope_LookupVar( const TOKEN *tok1, const char var
else if ( indentlevel==0 ) else if ( indentlevel==0 )
{ {
if ( TOKEN::Match(tok,"for") || TOKEN::Match(tok,"while") ) if ( (tok->str() == "for") || (tok->str() == "while") )
for_or_while = true; for_or_while = true;
if ( parlevel == 0 && TOKEN::Match(tok, ";") ) if ( parlevel == 0 && (tok->str() == ";") )
for_or_while = false; for_or_while = false;
} }
@ -641,7 +641,7 @@ void CheckOther::CheckStructMemberUsage()
{ {
if ( tok->FileIndex != 0 ) if ( tok->FileIndex != 0 )
continue; continue;
if ( TOKEN::Match(tok,"}") ) if ( tok->str() == "}" )
structname = 0; structname = 0;
if ( TOKEN::Match(tok, "struct %type% {") ) if ( TOKEN::Match(tok, "struct %type% {") )
structname = tok->strAt( 1); structname = tok->strAt( 1);
@ -710,17 +710,17 @@ void CheckOther::CheckCharVariable()
int indentlevel = 0; int indentlevel = 0;
for ( const TOKEN *tok2 = tok->next; tok2; tok2 = tok2->next ) for ( const TOKEN *tok2 = tok->next; tok2; tok2 = tok2->next )
{ {
if ( TOKEN::Match(tok2, "{") ) if ( tok2->str() == "{" )
++indentlevel; ++indentlevel;
else if ( TOKEN::Match(tok2, "}") ) else if ( tok2->str() == "}" )
{ {
--indentlevel; --indentlevel;
if ( indentlevel <= 0 ) if ( indentlevel <= 0 )
break; break;
} }
if (!TOKEN::Match(tok2,".") && TOKEN::Match(tok2->next, "%var% [ %var1% ]", varname)) if ((tok2->str() != ".") && TOKEN::Match(tok2->next, "%var% [ %var1% ]", varname))
{ {
std::ostringstream errmsg; std::ostringstream errmsg;
errmsg << _tokenizer->fileLine(tok2->next) << ": Warning - using char variable as array index"; errmsg << _tokenizer->fileLine(tok2->next) << ": Warning - using char variable as array index";
@ -756,15 +756,15 @@ void CheckOther::CheckIncompleteStatement()
for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next ) for ( const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next )
{ {
if ( TOKEN::Match(tok, "(") ) if ( tok->str() == "(" )
++parlevel; ++parlevel;
else if ( TOKEN::Match(tok, ")") ) else if ( tok->str() == ")" )
--parlevel; --parlevel;
if ( parlevel != 0 ) if ( parlevel != 0 )
continue; continue;
if ( !TOKEN::Match(tok,"#") && TOKEN::Match(tok->next,"; %str%") && !TOKEN::Match(tok->tokAt(3), ",") ) if ( (tok->str() != "#") && TOKEN::Match(tok->next,"; %str%") && !TOKEN::Match(tok->tokAt(3), ",") )
{ {
std::ostringstream errmsg; std::ostringstream errmsg;
errmsg << _tokenizer->fileLine(tok->next) << ": Redundant code: Found a statement that begins with string constant"; errmsg << _tokenizer->fileLine(tok->next) << ": Redundant code: Found a statement that begins with string constant";

View File

@ -49,7 +49,7 @@ private:
std::string ret; std::string ret;
for ( const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next ) for ( const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next )
{ {
ret += std::string(tok->str) + " "; ret += std::string(tok->aaaa()) + " ";
} }
return ret; return ret;

View File

@ -51,7 +51,7 @@ private:
unsigned int i = 0; unsigned int i = 0;
for (; expected[i] && actual; ++i, actual = actual->next) for (; expected[i] && actual; ++i, actual = actual->next)
{ {
if ( strcmp( expected[i], actual->str ) != 0) if ( strcmp( expected[i], actual->aaaa() ) != 0)
return false; return false;
} }
return (expected[i] == NULL && actual == NULL); return (expected[i] == NULL && actual == NULL);
@ -94,7 +94,7 @@ private:
tokenizer.TokenizeCode(istr, 0); tokenizer.TokenizeCode(istr, 0);
// Expected result.. // Expected result..
ASSERT_EQUALS( std::string(10000,'a'), std::string(tokenizer.tokens()->str) ); ASSERT_EQUALS( std::string(10000,'a'), std::string(tokenizer.tokens()->aaaa()) );
} }
@ -149,7 +149,7 @@ private:
tokenizer.fillFunctionList(); tokenizer.fillFunctionList();
ASSERT_EQUALS( 1, tokenizer._functionList.size() ); ASSERT_EQUALS( 1, tokenizer._functionList.size() );
ASSERT_EQUALS( std::string("b"), tokenizer._functionList[0]->str ); ASSERT_EQUALS( std::string("b"), tokenizer._functionList[0]->aaaa() );
} }
}; };

View File

@ -28,7 +28,8 @@
TOKEN::TOKEN() TOKEN::TOKEN()
{ {
FileIndex = 0; FileIndex = 0;
_str = 0; _cstr = 0;
_str = "";
linenr = 0; linenr = 0;
next = 0; next = 0;
_isName = false; _isName = false;
@ -37,28 +38,27 @@ TOKEN::TOKEN()
TOKEN::~TOKEN() TOKEN::~TOKEN()
{ {
std::free(_str); std::free(_cstr);
} }
void TOKEN::setstr( const char s[] ) void TOKEN::setstr( const char s[] )
{ {
std::free(_str); _str = s;
std::free(_cstr);
#ifndef _MSC_VER #ifndef _MSC_VER
_str = strdup(s); _cstr = strdup(s);
#else #else
_str = _strdup(s); _cstr = _strdup(s);
#endif #endif
str = _str ? _str : ""; _isName = bool(_str[0]=='_' || isalpha(_str[0]));
_isNumber = bool(isdigit(_str[0]) != 0);
_isName = bool(str[0]=='_' || isalpha(str[0]));
_isNumber = bool(isdigit(str[0]) != 0);
} }
void TOKEN::combineWithNext(const char str1[], const char str2[]) void TOKEN::combineWithNext(const char str1[], const char str2[])
{ {
if (!(next)) if (!(next))
return; return;
if (strcmp(str,str1) || strcmp(next->str,str2)) if (_str!=str1 || next->_str!=str2)
return; return;
std::string newstr(std::string(str1) + std::string(str2)); std::string newstr(std::string(str1) + std::string(str2));
@ -87,7 +87,7 @@ const TOKEN *TOKEN::tokAt(int index) const
const char *TOKEN::strAt(int index) const const char *TOKEN::strAt(int index) const
{ {
const TOKEN *tok = this->tokAt(index); const TOKEN *tok = this->tokAt(index);
return tok ? tok->str : ""; return tok ? tok->_cstr : "";
} }
bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[], const char *varname2[]) bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[], const char *varname2[])
@ -132,7 +132,7 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
if ( ! varname ) if ( ! varname )
return false; return false;
if (strcmp(tok->str, varname[0]) != 0) if (tok->_str != varname[0])
return false; return false;
for ( int i = 1; varname[i]; i++ ) for ( int i = 1; varname[i]; i++ )
@ -159,19 +159,19 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
else if (strcmp(str,"%str%")==0) else if (strcmp(str,"%str%")==0)
{ {
if ( tok->str[0] != '\"' ) if ( tok->_str[0] != '\"' )
return false; return false;
} }
// [.. => search for a one-character token.. // [.. => search for a one-character token..
else if (str[0]=='[' && strchr(str, ']') && tok->str[1] == 0) else if (str[0]=='[' && strchr(str, ']') && tok->_str[1] == 0)
{ {
*strrchr(str, ']') = 0; *strrchr(str, ']') = 0;
if ( strchr( str + 1, tok->str[0] ) == 0 ) if ( strchr( str + 1, tok->_str[0] ) == 0 )
return false; return false;
} }
else if (strcmp(str, tok->str) != 0) else if (str != tok->_str)
return false; return false;
tok = tok->next; tok = tok->next;
@ -227,7 +227,7 @@ const TOKEN *TOKEN::findtoken(const TOKEN *tok1, const char *tokenstr[])
{ {
if (!tok) if (!tok)
return NULL; return NULL;
if (*(tokenstr[i]) && strcmp(tokenstr[i],tok->str)) if (*(tokenstr[i]) && (tokenstr[i] != tok->_str))
break; break;
tok = tok->next; tok = tok->next;
i++; i++;

20
token.h
View File

@ -19,6 +19,8 @@
#ifndef TOKEN_H #ifndef TOKEN_H
#define TOKEN_H #define TOKEN_H
#include <string>
class TOKEN class TOKEN
{ {
public: public:
@ -26,6 +28,19 @@ public:
~TOKEN(); ~TOKEN();
void setstr( const char s[] ); void setstr( const char s[] );
const std::string &str() const
{ return _str; }
const char *aaaa() const
{ return _cstr; }
char aaaa0() const
{ return _cstr[0]; }
char aaaa1() const
{ return _cstr[1]; }
/** /**
* Combine two tokens that belong to each other. * Combine two tokens that belong to each other.
* Ex: "<" and "=" may become "<=" * Ex: "<" and "=" may become "<="
@ -52,13 +67,14 @@ public:
static bool IsStandardType(const char str[]); static bool IsStandardType(const char str[]);
static const TOKEN *findmatch(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0); static const TOKEN *findmatch(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0);
static const TOKEN *findtoken(const TOKEN *tok1, const char *tokenstr[]); static const TOKEN *findtoken(const TOKEN *tok1, const char *tokenstr[]);
const char *str;
unsigned int FileIndex; unsigned int FileIndex;
unsigned int linenr; unsigned int linenr;
TOKEN *next; TOKEN *next;
private: private:
char * _str; std::string _str;
char * _cstr;
bool _isName; bool _isName;
bool _isNumber; bool _isNumber;
}; };

View File

@ -215,7 +215,7 @@ void Tokenizer::InsertTokens(TOKEN *dest, TOKEN *src, unsigned int n)
TOKEN *NewToken = new TOKEN; TOKEN *NewToken = new TOKEN;
NewToken->FileIndex = src->FileIndex; NewToken->FileIndex = src->FileIndex;
NewToken->linenr = src->linenr; NewToken->linenr = src->linenr;
NewToken->setstr(src->str); NewToken->setstr(src->aaaa());
NewToken->next = dest->next; NewToken->next = dest->next;
dest->next = NewToken; dest->next = NewToken;
@ -526,7 +526,7 @@ void Tokenizer::TokenizeCode(std::istream &code, const unsigned int FileIndex)
// Replace "->" with "." // Replace "->" with "."
for ( TOKEN *tok = _tokens; tok; tok = tok->next ) for ( TOKEN *tok = _tokens; tok; tok = tok->next )
{ {
if ( strcmp(tok->str, "->") == 0 ) if ( strcmp(tok->aaaa(), "->") == 0 )
{ {
tok->setstr("."); tok->setstr(".");
} }
@ -541,7 +541,7 @@ void Tokenizer::TokenizeCode(std::istream &code, const unsigned int FileIndex)
const char *type2 = tok->strAt( 2); const char *type2 = tok->strAt( 2);
for ( TOKEN *tok2 = tok; tok2; tok2 = tok2->next ) for ( TOKEN *tok2 = tok; tok2; tok2 = tok2->next )
{ {
if (tok2->str!=type1 && tok2->str!=type2 && strcmp(tok2->str,type2)==0) if (tok2->aaaa()!=type1 && tok2->aaaa()!=type2 && strcmp(tok2->aaaa(),type2)==0)
{ {
tok2->setstr(type1); tok2->setstr(type1);
} }
@ -560,7 +560,7 @@ void Tokenizer::TokenizeCode(std::istream &code, const unsigned int FileIndex)
for ( ; tok2; tok2 = tok2->next ) for ( ; tok2; tok2 = tok2->next )
{ {
if (tok2->str!=type3 && strcmp(tok2->str,type3)==0) if (tok2->aaaa()!=type3 && strcmp(tok2->aaaa(),type3)==0)
{ {
tok2->setstr(type1); tok2->setstr(type1);
@ -611,7 +611,7 @@ void Tokenizer::SimplifyTokenList()
// Remove the keyword 'unsigned' // Remove the keyword 'unsigned'
for ( TOKEN *tok = _tokens; tok; tok = tok->next ) for ( TOKEN *tok = _tokens; tok; tok = tok->next )
{ {
if (tok->next && strcmp(tok->next->str,"unsigned")==0) if (tok->next && strcmp(tok->next->aaaa(),"unsigned")==0)
{ {
tok->deleteNext(); tok->deleteNext();
} }
@ -627,7 +627,7 @@ void Tokenizer::SimplifyTokenList()
for (TOKEN *tok2 = _gettok(tok,6); tok2; tok2 = tok2->next) for (TOKEN *tok2 = _gettok(tok,6); tok2; tok2 = tok2->next)
{ {
if (strcmp(tok2->str,sym) == 0) if (strcmp(tok2->aaaa(),sym) == 0)
{ {
tok2->setstr(num); tok2->setstr(num);
} }
@ -661,7 +661,7 @@ void Tokenizer::SimplifyTokenList()
// Replace 'sizeof(type)'.. // Replace 'sizeof(type)'..
for (TOKEN *tok = _tokens; tok; tok = tok->next) for (TOKEN *tok = _tokens; tok; tok = tok->next)
{ {
if (strcmp(tok->str,"sizeof") != 0) if (strcmp(tok->aaaa(),"sizeof") != 0)
continue; continue;
if (TOKEN::Match(tok, "sizeof ( %type% * )")) if (TOKEN::Match(tok, "sizeof ( %type% * )"))
@ -708,7 +708,7 @@ void Tokenizer::SimplifyTokenList()
if ( ! TOKEN::Match(tok, "%type% %var% [ %num% ] ;") ) if ( ! TOKEN::Match(tok, "%type% %var% [ %num% ] ;") )
continue; continue;
int size = SizeOfType(tok->str); int size = SizeOfType(tok->aaaa());
if (size <= 0) if (size <= 0)
continue; continue;
@ -719,12 +719,12 @@ void Tokenizer::SimplifyTokenList()
int indentlevel = 0; int indentlevel = 0;
for ( TOKEN *tok2 = _gettok(tok,5); tok2; tok2 = tok2->next ) for ( TOKEN *tok2 = _gettok(tok,5); tok2; tok2 = tok2->next )
{ {
if (tok2->str[0] == '{') if (tok2->aaaa0() == '{')
{ {
indentlevel++; indentlevel++;
} }
else if (tok2->str[0] == '}') else if (tok2->aaaa0() == '}')
{ {
indentlevel--; indentlevel--;
if (indentlevel < 0) if (indentlevel < 0)
@ -765,7 +765,7 @@ void Tokenizer::SimplifyTokenList()
} }
// (1-2) // (1-2)
if (strchr("[,(=<>",tok->str[0]) && if (strchr("[,(=<>",tok->aaaa0()) &&
(tok->tokAt(1) && tok->tokAt(1)->isNumber()) && (tok->tokAt(1) && tok->tokAt(1)->isNumber()) &&
strchr("+-*/",*(tok->strAt(2))) && strchr("+-*/",*(tok->strAt(2))) &&
(tok->tokAt(3) && tok->tokAt(3)->isNumber()) && (tok->tokAt(3) && tok->tokAt(3)->isNumber()) &&
@ -803,7 +803,7 @@ void Tokenizer::SimplifyTokenList()
// Replace "*(str + num)" => "str[num]" // Replace "*(str + num)" => "str[num]"
for (TOKEN *tok = _tokens; tok; tok = tok->next) for (TOKEN *tok = _tokens; tok; tok = tok->next)
{ {
if ( ! strchr(";{}(=<>", tok->str[0]) ) if ( ! strchr(";{}(=<>", tok->aaaa0()) )
continue; continue;
TOKEN *next = tok->next; TOKEN *next = tok->next;
@ -832,7 +832,7 @@ void Tokenizer::SimplifyTokenList()
// Split up variable declarations if possible.. // Split up variable declarations if possible..
for (TOKEN *tok = _tokens; tok; tok = tok->next) for (TOKEN *tok = _tokens; tok; tok = tok->next)
{ {
if ( ! strchr("{};", tok->str[0]) ) if ( ! strchr("{};", tok->aaaa0()) )
continue; continue;
TOKEN *type0 = tok->next; TOKEN *type0 = tok->next;
@ -901,7 +901,7 @@ void Tokenizer::SimplifyTokenList()
if (tok2) if (tok2)
{ {
if (tok2->str[0] == ',') if (tok2->aaaa0() == ',')
{ {
tok2->setstr(";"); tok2->setstr(";");
InsertTokens(tok2, type0, typelen); InsertTokens(tok2, type0, typelen);
@ -914,29 +914,29 @@ void Tokenizer::SimplifyTokenList()
int parlevel = 0; int parlevel = 0;
while (tok2) while (tok2)
{ {
if ( strchr("{(", tok2->str[0]) ) if ( strchr("{(", tok2->aaaa0()) )
{ {
parlevel++; parlevel++;
} }
else if ( strchr("})", tok2->str[0]) ) else if ( strchr("})", tok2->aaaa0()) )
{ {
if (parlevel<0) if (parlevel<0)
break; break;
parlevel--; parlevel--;
} }
else if ( parlevel==0 && strchr(";,",tok2->str[0]) ) else if ( parlevel==0 && strchr(";,",tok2->aaaa0()) )
{ {
// "type var =" => "type var; var =" // "type var =" => "type var; var ="
TOKEN *VarTok = _gettok(type0,typelen); TOKEN *VarTok = _gettok(type0,typelen);
if (VarTok->str[0]=='*') if (VarTok->aaaa0()=='*')
VarTok = VarTok->next; VarTok = VarTok->next;
InsertTokens(eq, VarTok, 2); InsertTokens(eq, VarTok, 2);
eq->setstr(";"); eq->setstr(";");
// "= x, " => "= x; type " // "= x, " => "= x; type "
if (tok2->str[0] == ',') if (tok2->aaaa0() == ',')
{ {
tok2->setstr(";"); tok2->setstr(";");
InsertTokens( tok2, type0, typelen ); InsertTokens( tok2, type0, typelen );
@ -1002,7 +1002,7 @@ bool Tokenizer::simplifyConditions()
TOKEN::Match(tok->next, "%num%") && TOKEN::Match(tok->next, "%num%") &&
(TOKEN::Match(tok2, ")") || TOKEN::Match(tok2, "&&") || TOKEN::Match(tok2, "||")) ) (TOKEN::Match(tok2, ")") || TOKEN::Match(tok2, "&&") || TOKEN::Match(tok2, "||")) )
{ {
tok->next->setstr((strcmp(tok->next->str, "0")!=0) ? "true" : "false"); tok->next->setstr((strcmp(tok->next->aaaa(), "0")!=0) ? "true" : "false");
ret = false; ret = false;
} }
} }
@ -1023,7 +1023,7 @@ const TOKEN *Tokenizer::GetFunctionTokenByName( const char funcname[] ) const
{ {
for ( unsigned int i = 0; i < _functionList.size(); ++i ) for ( unsigned int i = 0; i < _functionList.size(); ++i )
{ {
if ( strcmp( _functionList[i]->str, funcname ) == 0 ) if ( strcmp( _functionList[i]->aaaa(), funcname ) == 0 )
{ {
return _functionList[i]; return _functionList[i];
} }
@ -1042,10 +1042,10 @@ void Tokenizer::fillFunctionList()
int indentlevel = 0; int indentlevel = 0;
for ( const TOKEN *tok = _tokens; tok; tok = tok->next ) for ( const TOKEN *tok = _tokens; tok; tok = tok->next )
{ {
if ( tok->str[0] == '{' ) if ( tok->aaaa0() == '{' )
indentlevel++; indentlevel++;
else if ( tok->str[0] == '}' ) else if ( tok->aaaa0() == '}' )
indentlevel--; indentlevel--;
if (indentlevel > 0) if (indentlevel > 0)
@ -1053,13 +1053,13 @@ void Tokenizer::fillFunctionList()
continue; continue;
} }
if (strchr("};", tok->str[0])) if (strchr("};", tok->aaaa0()))
staticfunc = classfunc = false; staticfunc = classfunc = false;
else if ( strcmp( tok->str, "static" ) == 0 ) else if ( strcmp( tok->aaaa(), "static" ) == 0 )
staticfunc = true; staticfunc = true;
else if ( strcmp( tok->str, "::" ) == 0 ) else if ( strcmp( tok->aaaa(), "::" ) == 0 )
classfunc = true; classfunc = true;
else if (TOKEN::Match(tok, "%var% (")) else if (TOKEN::Match(tok, "%var% ("))
@ -1067,18 +1067,18 @@ void Tokenizer::fillFunctionList()
// Check if this is the first token of a function implementation.. // Check if this is the first token of a function implementation..
for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next ) for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next )
{ {
if ( tok2->str[0] == ';' ) if ( tok2->aaaa0() == ';' )
{ {
tok = tok2; tok = tok2;
break; break;
} }
else if ( tok2->str[0] == '{' ) else if ( tok2->aaaa0() == '{' )
{ {
break; break;
} }
else if ( tok2->str[0] == ')' ) else if ( tok2->aaaa0() == ')' )
{ {
if ( TOKEN::Match(tok2, ") {") ) if ( TOKEN::Match(tok2, ") {") )
{ {
@ -1088,7 +1088,7 @@ void Tokenizer::fillFunctionList()
else else
{ {
tok = tok2; tok = tok2;
while (tok->next && !strchr(";{", tok->next->str[0])) while (tok->next && !strchr(";{", tok->next->aaaa0()))
tok = tok->next; tok = tok->next;
} }
break; break;
@ -1104,7 +1104,7 @@ void Tokenizer::fillFunctionList()
bool hasDuplicates = false; bool hasDuplicates = false;
for ( unsigned int func2 = func1 + 1; func2 < _functionList.size(); ) for ( unsigned int func2 = func1 + 1; func2 < _functionList.size(); )
{ {
if ( strcmp(_functionList[func1]->str, _functionList[func2]->str) == 0 ) if ( strcmp(_functionList[func1]->aaaa(), _functionList[func2]->aaaa()) == 0 )
{ {
hasDuplicates = true; hasDuplicates = true;
_functionList.erase( _functionList.begin() + func2 ); _functionList.erase( _functionList.begin() + func2 );
@ -1172,7 +1172,7 @@ const char *Tokenizer::getParameterName( const TOKEN *ftok, int par )
if ( TOKEN::Match(ftok, ",") ) if ( TOKEN::Match(ftok, ",") )
++_par; ++_par;
if ( par==_par && TOKEN::Match(ftok, "%var% [,)]") ) if ( par==_par && TOKEN::Match(ftok, "%var% [,)]") )
return ftok->str; return ftok->aaaa();
} }
return NULL; return NULL;
} }