preprocessor: fixed problem in Preprocessor::expandMacros when macro argument is for example 'unsigned long'

This commit is contained in:
Daniel Marjamäki 2009-08-01 14:55:45 +02:00
parent e6713e9774
commit b5d172b6e9
2 changed files with 13 additions and 1 deletions

View File

@ -1516,7 +1516,11 @@ std::string Preprocessor::expandMacros(std::string code, const std::string &file
}
else if (code[pos2] == ' ')
{
// Add space only if it is needed
if (par.size() && std::isalnum(par[par.length()-1]))
{
par += ' ';
}
}
else if (parlevel >= 1)
{

View File

@ -112,6 +112,7 @@ private:
TEST_CASE(macro_simple7);
TEST_CASE(macro_simple8);
TEST_CASE(macro_simple9);
TEST_CASE(macro_simple10);
TEST_CASE(macro_mismatch);
TEST_CASE(macro_linenumbers);
TEST_CASE(macro_nopar);
@ -782,6 +783,13 @@ private:
ASSERT_EQUALS("\nf(\"\\\"\");\nf(\"g\");", OurPreprocessor::expandMacros(filedata));
}
void macro_simple10()
{
const char filedata[] = "#define ABC(t) t x\n"
"ABC(unsigned long);";
ASSERT_EQUALS("\nunsigned long x;", OurPreprocessor::expandMacros(filedata));
}
void macro_mismatch()
{
const char filedata[] = "#define AAA(aa,bb) f(aa)\n"