From b5d172b6e94d07c29f85c9dc03811d442d99099c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 1 Aug 2009 14:55:45 +0200 Subject: [PATCH] preprocessor: fixed problem in Preprocessor::expandMacros when macro argument is for example 'unsigned long' --- src/preprocessor.cpp | 6 +++++- test/testpreprocessor.cpp | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index f24b8c34c..cef3766a8 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -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) { diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 983901891..68734a09f 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -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"