minor fixes

This commit is contained in:
Daniel Marjamäki 2009-11-28 11:47:44 +01:00
parent 3db49aee71
commit 6e175053c1
2 changed files with 8 additions and 4 deletions

10
lib/preprocessor.cpp Normal file → Executable file
View File

@ -1026,7 +1026,12 @@ void Preprocessor::simplifyCondition(const std::map<std::string, std::string> &v
{ {
const std::map<std::string, std::string>::const_iterator it = variables.find(tok->str()); const std::map<std::string, std::string>::const_iterator it = variables.find(tok->str());
if (it != variables.end()) if (it != variables.end())
tok->str(it->second); {
if (it->second.empty())
tok->deleteThis();
else
tok->str(it->second);
}
} }
// simplify calculations.. // simplify calculations..
@ -1272,8 +1277,7 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg,
// We must not remove #file tags or line numbers // We must not remove #file tags or line numbers
// are corrupted. File tags are removed by the tokenizer. // are corrupted. File tags are removed by the tokenizer.
} }
else if (!match || else if (!match || line.compare(0,1,"#") == 0)
line[0] == '#')
{ {
// Remove #if, #else, #pragma etc, leaving only // Remove #if, #else, #pragma etc, leaving only
// #define, #undef, #file and #endfile. and also lines // #define, #undef, #file and #endfile. and also lines

View File

@ -53,7 +53,7 @@ void Token::str(const std::string &s)
if (std::isdigit(_str[0])) if (std::isdigit(_str[0]))
_isNumber = true; _isNumber = true;
else if (_str.length() > 1 && _str[0] == '-' && std::isdigit(_str[0])) else if (_str.length() > 1 && _str[0] == '-' && std::isdigit(_str[1]))
_isNumber = true; _isNumber = true;
else else
_isNumber = false; _isNumber = false;