tools/reduce: removing blocks of code that contain #if,#else,#endif

This commit is contained in:
Daniel Marjamäki 2013-01-01 14:33:32 +01:00
parent 6ee32943f2
commit e824f76ed7
1 changed files with 9 additions and 1 deletions

View File

@ -216,8 +216,16 @@ int main(int argc, char *argv[])
pos2 += 2;
// find end of block..
while ((pos2 < filedata.size()) && (filedata[pos2].empty() || std::isspace(filedata[pos2].at(0))))
int level = 0;
while ((pos2 < filedata.size()) && (filedata[pos2].empty() || std::isspace(filedata[pos2].at(0)) || filedata[pos2].compare(0,3,"#if")==0 || filedata[pos2]=="#else" || filedata[pos2]=="#endif")) {
if (filedata[pos2].compare(0,3,"#if") == 0)
++level;
else if (filedata[pos2] == "#endif")
--level;
++pos2;
}
if (level != 0)
break;
// does block of code end with a '}'
if ((pos2 < filedata.size()) && (filedata[pos2] == "}" || filedata[pos2] == "};")) {