Fixed a bug in Tokenizer::simplifyTokenList. The keyword operator is

never used in a variable declaration
This commit is contained in:
Daniel Marjamäki 2008-12-07 08:47:56 +00:00
parent ea57f2b820
commit c907589deb
1 changed files with 19 additions and 31 deletions

View File

@ -846,7 +846,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->aaaa0()) ) if ( ! TOKEN::Match(tok, "[{};]") )
continue; continue;
TOKEN *type0 = tok->next; TOKEN *type0 = tok->next;
@ -858,61 +858,49 @@ void Tokenizer::simplifyTokenList()
TOKEN *tok2 = NULL; TOKEN *tok2 = NULL;
unsigned int typelen = 0; unsigned int typelen = 0;
if ( TOKEN::Match(type0, "%type% %var% ,") ) if ( TOKEN::Match(type0, "%type% %var% ,|=") )
{ {
tok2 = _gettok(type0, 2); // The ',' token if ( type0->next->str() != "operator" )
typelen = 1; {
tok2 = _gettok(type0, 2); // The ',' or '=' token
typelen = 1;
}
} }
else if ( TOKEN::Match(type0, "%type% * %var% ,") ) else if ( TOKEN::Match(type0, "%type% * %var% ,|=") )
{ {
tok2 = _gettok(type0, 3); // The ',' token if ( type0->next->next->str() != "operator" )
typelen = 1; {
tok2 = _gettok(type0, 3); // The ',' token
typelen = 1;
}
} }
else if ( TOKEN::Match(type0, "%type% %var% [ %num% ] ,") ) else if ( TOKEN::Match(type0, "%type% %var% [ %num% ] ,|=") )
{ {
tok2 = _gettok(type0, 5); // The ',' token tok2 = _gettok(type0, 5); // The ',' token
typelen = 1; typelen = 1;
} }
else if ( TOKEN::Match(type0, "%type% * %var% [ %num% ] ,") ) else if ( TOKEN::Match(type0, "%type% * %var% [ %num% ] ,|=") )
{ {
tok2 = _gettok(type0, 6); // The ',' token tok2 = _gettok(type0, 6); // The ',' token
typelen = 1; typelen = 1;
} }
else if ( TOKEN::Match(type0, "struct %type% %var% ,") ) else if ( TOKEN::Match(type0, "struct %type% %var% ,|=") )
{ {
tok2 = _gettok(type0, 3); tok2 = _gettok(type0, 3);
typelen = 2; typelen = 2;
} }
else if ( TOKEN::Match(type0, "struct %type% * %var% ,") ) else if ( TOKEN::Match(type0, "struct %type% * %var% ,|=") )
{ {
tok2 = _gettok(type0, 4); tok2 = _gettok(type0, 4);
typelen = 2; typelen = 2;
} }
else if ( TOKEN::Match(type0, "%type% %var% =") )
{
tok2 = _gettok(type0, 2);
typelen = 1;
}
else if ( TOKEN::Match(type0, "%type% * %var% =") )
{
tok2 = _gettok(type0, 3);
typelen = 1;
}
else if ( TOKEN::Match(type0, "struct %type% * %var% =") )
{
tok2 = _gettok(type0, 4);
typelen = 2;
}
if (tok2) if (tok2)
{ {
if (tok2->str() == ",") if (tok2->str() == ",")