preprocessor: Handling "#if .." better
This commit is contained in:
parent
a54cd2df44
commit
3bf539939f
|
@ -159,13 +159,8 @@ void preprocess(std::istream &istr, std::map<std::string, std::string> &result)
|
|||
// Get the DEF in this line: "#ifdef DEF"
|
||||
static std::string getdef(std::string line, bool def)
|
||||
{
|
||||
if ( def && line.find("#if 0") == 0 )
|
||||
return "0";
|
||||
if ( def && line.find("#if 1") == 0 )
|
||||
return "1";
|
||||
|
||||
// If def is true, the line must start with "#ifdef"
|
||||
if ( def && line.find("#ifdef ") != 0 )
|
||||
if ( def && line.find("#ifdef ") != 0 && line.find("#if ") != 0 )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -285,7 +285,6 @@ private:
|
|||
|
||||
void if_cond1()
|
||||
{
|
||||
/* TODO: Make this work
|
||||
const char filedata[] = "#if LIBVER>100\n"
|
||||
" A\n"
|
||||
"#else\n"
|
||||
|
@ -293,7 +292,8 @@ private:
|
|||
"#endif\n";
|
||||
|
||||
std::map<std::string, std::string> expected;
|
||||
expected[""] = filedata;
|
||||
expected[""] = "\n\n\nB\n\n";
|
||||
expected["LIBVER>100"] = "\nA\n\n\n\n";
|
||||
|
||||
// Preprocess => actual result..
|
||||
std::istringstream istr(filedata);
|
||||
|
@ -302,7 +302,6 @@ private:
|
|||
|
||||
// Compare results..
|
||||
ASSERT_EQUALS( true, cmpmaps(actual, expected));
|
||||
*/
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue