reduce: simplify multiline #define statements
This commit is contained in:
parent
544a5957e1
commit
fbf09f11a0
|
@ -181,7 +181,7 @@ static std::vector<std::string> readfile(const std::string &filename)
|
||||||
filedata.push_back(line);
|
filedata.push_back(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// put declarations in a single line..
|
// put function declarations in a single line..
|
||||||
for (unsigned int linenr = 0U; linenr+1U < filedata.size(); ++linenr) {
|
for (unsigned int linenr = 0U; linenr+1U < filedata.size(); ++linenr) {
|
||||||
// Does this look like start of a function declaration?
|
// Does this look like start of a function declaration?
|
||||||
if (filedata[linenr].empty() ||
|
if (filedata[linenr].empty() ||
|
||||||
|
@ -214,6 +214,28 @@ static std::vector<std::string> readfile(const std::string &filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// put #define statements in a single line..
|
||||||
|
for (unsigned int linenr = 0U; linenr+1U < filedata.size(); ++linenr) {
|
||||||
|
// is this a multiline #define statement?
|
||||||
|
if (filedata[linenr].compare(0,8,"#define ")!=0 || getEndChar(filedata[linenr])!='\\')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// where does statement end?
|
||||||
|
unsigned int linenr2 = linenr + 1U;
|
||||||
|
while (linenr2 < filedata.size() && getEndChar(filedata[linenr2]) == '\\')
|
||||||
|
++linenr2;
|
||||||
|
|
||||||
|
// simplify
|
||||||
|
if (linenr2 < filedata.size()) {
|
||||||
|
std::string code;
|
||||||
|
for (unsigned int i = linenr; i <= linenr2; i++) {
|
||||||
|
code = code + filedata[i].substr(0,filedata[i].size() - 1U);
|
||||||
|
filedata[i].clear();
|
||||||
|
}
|
||||||
|
filedata[linenr] = code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return filedata;
|
return filedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue