Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reduce: reduce structs/enums/etc better

  • Loading branch information...
commit 89b54cb2c903a706f940b214fe31f58ef21101e4 1 parent 67c9720
@danmar authored
Showing with 20 additions and 11 deletions.
  1. +20 −11 tools/reduce.cpp
View
31 tools/reduce.cpp
@@ -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..
Please sign in to comment.
Something went wrong with that request. Please try again.