Tokenizer: call createLinks() only once.
Fixed simplifyIfAssign() and simplifyIfNot() to link() just inseted tokens. No functional change.
This commit is contained in:
parent
6347d0e976
commit
fe1101771a
|
@ -2616,11 +2616,12 @@ bool Tokenizer::simplifyIfAssign()
|
||||||
if (isNot)
|
if (isNot)
|
||||||
tok->next()->deleteNext();
|
tok->next()->deleteNext();
|
||||||
|
|
||||||
// Delete paranthesis.. and remember how many there are.
|
// Delete paranthesis.. and remember how many there are with
|
||||||
unsigned int numpar = 0;
|
// their links.
|
||||||
|
std::list<Token *> braces;
|
||||||
while (tok->next()->str() == "(")
|
while (tok->next()->str() == "(")
|
||||||
{
|
{
|
||||||
++numpar;
|
braces.push_back(tok->next()->link());
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2647,8 +2648,14 @@ bool Tokenizer::simplifyIfAssign()
|
||||||
tok2->insertToken(tok->strAt(2));
|
tok2->insertToken(tok->strAt(2));
|
||||||
}
|
}
|
||||||
tok2->insertToken(tok->strAt(1));
|
tok2->insertToken(tok->strAt(1));
|
||||||
for (unsigned int p = 0; p < numpar; ++p)
|
|
||||||
|
while (! braces.empty())
|
||||||
|
{
|
||||||
tok2->insertToken("(");
|
tok2->insertToken("(");
|
||||||
|
Token::createMutualLinks(tok2->next(), braces.back());
|
||||||
|
braces.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
if (isNot)
|
if (isNot)
|
||||||
tok2->next()->insertToken("!");
|
tok2->next()->insertToken("!");
|
||||||
tok2->insertToken(iswhile ? "while" : "if");
|
tok2->insertToken(iswhile ? "while" : "if");
|
||||||
|
@ -2743,6 +2750,7 @@ bool Tokenizer::simplifyIfNot()
|
||||||
// if( (x) == 0 )
|
// if( (x) == 0 )
|
||||||
tok->link()->insertToken("(");
|
tok->link()->insertToken("(");
|
||||||
tok->link()->str("!");
|
tok->link()->str("!");
|
||||||
|
Token::createMutualLinks(tok->link()->next(), tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -3011,9 +3019,6 @@ bool Tokenizer::elseif()
|
||||||
|
|
||||||
bool Tokenizer::simplifyRedundantParanthesis()
|
bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
{
|
{
|
||||||
if (!createLinks())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue