File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
third-party/thrift/src/thrift/compiler/generate/python Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 1616
1717#include < thrift/compiler/generate/python/util.h>
1818
19- #include < regex>
2019#include < boost/algorithm/string.hpp>
2120#include < boost/algorithm/string/replace.hpp>
2221#include < thrift/compiler/generate/cpp/util.h>
@@ -89,14 +88,18 @@ void strip_cpp_comments_and_newlines(std::string& s) {
8988 s.erase (fr, to - fr + 2 );
9089 fr = s.find (" /*" , fr);
9190 }
92- // strip cpp-style comments
93- s.replace (
94- s.begin (),
95- s.end (),
96- std::regex_replace (
97- s,
98- std::regex (" //.*(?=$|\\ n)" ), /* simulate multiline regex */
99- " " ));
91+
92+ // strip cpp-style comments - '//' followed by 0+ non-newline characters
93+ fr = s.find (" //" );
94+ while (fr != std::string::npos) {
95+ auto to = s.find (' \n ' , fr + 2 );
96+ // Erase from '//' through to the following newline
97+ // If to == npos (last line commented without final line break), we erase to
98+ // the end of s
99+ s.erase (fr, to - fr);
100+
101+ fr = s.find (" //" , fr);
102+ }
100103
101104 // strip newlines
102105 boost::algorithm::replace_all (s, " \n " , " " );
You can’t perform that action at this time.
0 commit comments