Improve fix made for Ticket #85 to handle strings that are in 3 parts also.
This commit is contained in:
parent
4305d749ff
commit
da3efe8fa2
|
@ -556,7 +556,7 @@ void Tokenizer::simplifyTokenList()
|
|||
// Combine strings
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str()[0] == '"' && tok->next() && tok->next()->str()[0] == '"')
|
||||
while (tok->str()[0] == '"' && tok->next() && tok->next()->str()[0] == '"')
|
||||
{
|
||||
// Two strings after each other, combine them
|
||||
std::string temp = tok->str();
|
||||
|
|
|
@ -107,6 +107,7 @@ private:
|
|||
"const char *a =\n"
|
||||
"{\n"
|
||||
"\"hello \"\n"
|
||||
"\"more \"\n"
|
||||
"\"world\"\n"
|
||||
"};\n"
|
||||
"}\n");
|
||||
|
|
|
@ -109,6 +109,7 @@ private:
|
|||
TEST_CASE(sizeof4);
|
||||
TEST_CASE(simplify_numeric_condition);
|
||||
TEST_CASE(tokenize_double);
|
||||
TEST_CASE(tokenize_strings);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1008,6 +1009,30 @@ private:
|
|||
ostr << " " << tok->str();
|
||||
ASSERT_EQUALS(std::string(" void f ( ) { double a = 4.2 ; float b = 4.2f ; }"), ostr.str());
|
||||
}
|
||||
|
||||
void tokenize_strings()
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
"const char *a =\n"
|
||||
"{\n"
|
||||
"\"hello \"\n"
|
||||
"\"more \"\n"
|
||||
"\"world\"\n"
|
||||
"};\n"
|
||||
"}\n";
|
||||
|
||||
// tokenize..
|
||||
OurTokenizer tokenizer;
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
tokenizer.simplifyTokenList();
|
||||
|
||||
std::ostringstream ostr;
|
||||
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
|
||||
ostr << " " << tok->str();
|
||||
ASSERT_EQUALS(std::string(" void f ( ) { const char * a = { \"hello more world\" } ; }"), ostr.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestTokenizer)
|
||||
|
|
Loading…
Reference in New Issue