preprocessor: bail out code in expandMacros

This commit is contained in:
Daniel Marjamäki 2009-01-16 21:30:06 +00:00
parent 449dcc2a60
commit c279f83664
1 changed files with 3 additions and 0 deletions

View File

@ -481,6 +481,8 @@ std::string Preprocessor::expandMacros(std::string code)
tokenizer.tokenize(istr, ""); tokenizer.tokenize(istr, "");
if (! tokenizer.tokens()) if (! tokenizer.tokens())
continue; continue;
if (! tokenizer.tokens()->isName())
continue;
// Extract macro parameters // Extract macro parameters
std::vector<std::string> macroparams; std::vector<std::string> macroparams;
@ -602,6 +604,7 @@ std::string Preprocessor::expandMacros(std::string code)
// Insert macro code.. // Insert macro code..
if (!macroparams.empty()) if (!macroparams.empty())
++pos2; ++pos2;
code.erase(pos1, pos2 - pos1); code.erase(pos1, pos2 - pos1);
code.insert(pos1, macrocode); code.insert(pos1, macrocode);
pos1 += macrocode.length(); pos1 += macrocode.length();