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"
|
// Get the DEF in this line: "#ifdef DEF"
|
||||||
static std::string getdef(std::string line, bool 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 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 "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,6 @@ private:
|
||||||
|
|
||||||
void if_cond1()
|
void if_cond1()
|
||||||
{
|
{
|
||||||
/* TODO: Make this work
|
|
||||||
const char filedata[] = "#if LIBVER>100\n"
|
const char filedata[] = "#if LIBVER>100\n"
|
||||||
" A\n"
|
" A\n"
|
||||||
"#else\n"
|
"#else\n"
|
||||||
|
@ -293,7 +292,8 @@ private:
|
||||||
"#endif\n";
|
"#endif\n";
|
||||||
|
|
||||||
std::map<std::string, std::string> expected;
|
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..
|
// Preprocess => actual result..
|
||||||
std::istringstream istr(filedata);
|
std::istringstream istr(filedata);
|
||||||
|
@ -302,7 +302,6 @@ private:
|
||||||
|
|
||||||
// Compare results..
|
// Compare results..
|
||||||
ASSERT_EQUALS( true, cmpmaps(actual, expected));
|
ASSERT_EQUALS( true, cmpmaps(actual, expected));
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue