Better remove_documentation.
GitOrigin-RevId: ba92888e8278594dc6be6035a40e1292110ca647
This commit is contained in:
parent
65fc8f9809
commit
ea504ae920
@ -856,6 +856,7 @@ static bool put_file_contents(const std::string &file_name, const std::string &m
|
|||||||
static std::string remove_documentation(const std::string &str) {
|
static std::string remove_documentation(const std::string &str) {
|
||||||
std::size_t line_begin = 0;
|
std::size_t line_begin = 0;
|
||||||
std::string result;
|
std::string result;
|
||||||
|
bool inside_documentation = false;
|
||||||
while (line_begin < str.size()) {
|
while (line_begin < str.size()) {
|
||||||
std::size_t line_end = str.find('\n', line_begin);
|
std::size_t line_end = str.find('\n', line_begin);
|
||||||
if (line_end == std::string::npos) {
|
if (line_end == std::string::npos) {
|
||||||
@ -865,12 +866,15 @@ static std::string remove_documentation(const std::string &str) {
|
|||||||
line_begin = line_end + 1;
|
line_begin = line_end + 1;
|
||||||
|
|
||||||
std::size_t pos = line.find_first_not_of(' ');
|
std::size_t pos = line.find_first_not_of(' ');
|
||||||
if (pos != std::string::npos &&
|
if (pos != std::string::npos && ((line[pos] == '/' && line[pos + 1] == '/' && line[pos + 2] == '/') ||
|
||||||
((line[pos] == '/' && line[pos + 1] == '/' && line[pos + 2] == '/') ||
|
(line[pos] == '/' && line[pos + 1] == '*' && line[pos + 2] == '*') ||
|
||||||
(line[pos] == '/' && line[pos + 1] == '*' && line[pos + 2] == '*') || line[pos] == '*')) {
|
(inside_documentation && line[pos] == '*'))) {
|
||||||
|
inside_documentation = !(line[pos] == '/' && line[pos + 1] == '/' && line[pos + 2] == '/') &&
|
||||||
|
!(line[pos] == '*' && line[pos + 1] == '/');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inside_documentation = false;
|
||||||
result += line;
|
result += line;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user