Skip to content

Commit

Permalink
reduce: reduce structs/enums/etc better
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Jan 20, 2013
1 parent 67c9720 commit 89b54cb
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions tools/reduce.cpp
Expand Up @@ -262,21 +262,30 @@ static bool removeBlocksOfCode(const ReduceSettings &settings, std::vector<std::

// does code block start with "{"
std::size_t pos2 = pos;
if (filedata[pos].find("(") != std::string::npos && filedata[pos].find(")")==std::string::npos) {
++pos2;
while (pos2+2U < filedata.size() && !filedata[pos2].empty() && filedata[pos2].find_first_of("(){}") == std::string::npos)
++pos2;
if (filedata[pos2].find_first_of("({}")!=std::string::npos || filedata[pos2].find(")") == std::string::npos)
break;

// struct X { ..
if (filedata[pos].find_first_of("();}") == std::string::npos && filedata[pos].at(filedata[pos].size()-1U) == '{') {

}
pos2++;
if (pos2 < filedata.size() && !filedata[pos2].empty() && filedata[pos2].at(filedata[pos2].find_first_not_of(" ")) == ':') {

// function declaration ..
else {
if (filedata[pos].find("(") != std::string::npos && filedata[pos].find(")")==std::string::npos) {
++pos2;
while (pos2+2U < filedata.size() && !filedata[pos2].empty() && filedata[pos2].find_first_of("(){}") == std::string::npos)
++pos2;
if (filedata[pos2].find_first_of("({}")!=std::string::npos || filedata[pos2].find(")") == std::string::npos)
break;
}
pos2++;
while (pos2 < filedata.size() && !filedata[pos2].empty() && filedata[pos2].at(filedata[pos2].find_first_not_of(" ")) == ',')
if (pos2 < filedata.size() && !filedata[pos2].empty() && filedata[pos2].at(filedata[pos2].find_first_not_of(" ")) == ':') {
pos2++;
while (pos2 < filedata.size() && !filedata[pos2].empty() && filedata[pos2].at(filedata[pos2].find_first_not_of(" ")) == ',')
pos2++;
}
if (pos2+2U >= filedata.size() || filedata[pos2] != "{")
break;
}
if (pos2+2U >= filedata.size() || filedata[pos2] != "{")
break;
pos2++;

// find end of block..
Expand Down

0 comments on commit 89b54cb

Please sign in to comment.