Fix ticket #212 (Tokenizer: Handle L "text")
http://apps.sourceforge.net/trac/cppcheck/ticket/212
This commit is contained in:
parent
051f2929b5
commit
51d97fa831
|
@ -808,6 +808,17 @@ void Tokenizer::simplifyTokenList()
|
|||
|
||||
simplifyNamespaces();
|
||||
|
||||
// Combine wide strings
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
while (tok->str() == "L" && tok->next() && tok->next()->str()[0] == '"')
|
||||
{
|
||||
// Combine 'L "string"'
|
||||
tok->str(tok->next()->str().c_str());
|
||||
tok->deleteNext();
|
||||
}
|
||||
}
|
||||
|
||||
// Combine strings
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
|
|
|
@ -91,6 +91,7 @@ private:
|
|||
|
||||
// "if(0==x)" => "if(!x)"
|
||||
TEST_CASE(ifnot);
|
||||
TEST_CASE(combine_wstrings);
|
||||
}
|
||||
|
||||
std::string tok(const char code[])
|
||||
|
@ -212,6 +213,27 @@ private:
|
|||
ASSERT_EQUALS(tok(code2), tok(code1));
|
||||
}
|
||||
|
||||
void combine_wstrings()
|
||||
{
|
||||
const char code1[] = "void foo()\n"
|
||||
"{\n"
|
||||
"const wchar_t *a =\n"
|
||||
"{\n"
|
||||
"L\"hello \"\n"
|
||||
"L\"world\"\n"
|
||||
"};\n"
|
||||
"}\n";
|
||||
|
||||
const char code2[] = "void foo()\n"
|
||||
"{\n"
|
||||
"const wchar_t *a =\n"
|
||||
"{\n"
|
||||
"\"hello world\"\n"
|
||||
"};\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(tok(code2), tok(code1));
|
||||
}
|
||||
|
||||
void double_plus()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue