TokenList: Handle #line better. Ticket: #4505

This commit is contained in:
Daniel Marjamäki 2013-01-23 07:04:45 +01:00
parent 645126fb8e
commit 683c8adb74
1 changed files with 12 additions and 1 deletions

View File

@ -294,8 +294,19 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0)
std::getline(code, line);
// Update the current line number
if (!(std::stringstream(line) >> lineno))
std::string::size_type n = 0;
while (n < line.size() && std::isspace(line[n]))
++n;
if (n == line.size())
++lineno;
else {
while (n < line.size() && std::isdigit(line[n]))
++n;
if (n < line.size() && !std::isspace(line[n]))
++lineno;
else
std::istringstream(line) >> lineno;
}
CurrentToken.clear();
continue;
} else if (CurrentToken == "#endfile") {