Tokenizer::simplifySizeof(): use Token::getStrLength().
Fixed wrong result when string contains escaped quotes.
Correction for 0e729fedc0
commit.
This commit is contained in:
parent
1ba546407f
commit
313479cf8d
|
@ -1301,7 +1301,7 @@ void Tokenizer::simplifySizeof()
|
||||||
{
|
{
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << (strlen(tok->str().c_str()) - 1);
|
ostr << Token::getStrLength(tok) + 1;
|
||||||
tok->str(ostr.str());
|
tok->str(ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,7 +1311,7 @@ void Tokenizer::simplifySizeof()
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << (strlen(tok->str().c_str()) - 1);
|
ostr << Token::getStrLength(tok) + 1;
|
||||||
tok->str(ostr.str());
|
tok->str(ostr.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -671,6 +671,12 @@ private:
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_("; sizeof \"123\""));
|
ASSERT_EQUALS(expected.str(), sizeof_("; sizeof \"123\""));
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_("; sizeof(\"123\")"));
|
ASSERT_EQUALS(expected.str(), sizeof_("; sizeof(\"123\")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ostringstream expected;
|
||||||
|
expected << "; " << sizeof("\"quote\"");
|
||||||
|
ASSERT_EQUALS(expected.str(), sizeof_("; sizeof(\"\\\"quote\\\"\")"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void casting()
|
void casting()
|
||||||
|
|
Loading…
Reference in New Issue