Skip to content

Commit f69f719

Browse files
committed
bump simplecpp (handling #define with multiline comments)
1 parent cdfe92b commit f69f719

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

externals/simplecpp/simplecpp.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ unsigned long long stringToULL(const std::string &s)
8181
return ret;
8282
}
8383

84+
bool startsWith(const std::string &str, const std::string &s) {
85+
return (str.size() >= s.size() && str.compare(0, s.size(), s) == 0);
86+
}
87+
8488
bool endsWith(const std::string &s, const std::string &e) {
8589
return (s.size() >= e.size() && s.compare(s.size() - e.size(), e.size(), e) == 0);
8690
}
@@ -400,11 +404,19 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
400404
ch = readChar(istr,bom);
401405
}
402406
// multiline..
407+
403408
std::string::size_type pos = 0;
404409
while ((pos = currentToken.find("\\\n",pos)) != std::string::npos) {
405410
currentToken.erase(pos,2);
406411
++multiline;
407412
}
413+
if (multiline || startsWith(lastLine(10),"# ")) {
414+
pos = 0;
415+
while ((pos = currentToken.find("\n",pos)) != std::string::npos) {
416+
currentToken.erase(pos,1);
417+
++multiline;
418+
}
419+
}
408420
}
409421

410422
// string / char literal

0 commit comments

Comments
 (0)