From ea504ae920b1eddc5c9b84cc4040e414c978a1d2 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 16 Mar 2018 16:07:34 +0300 Subject: [PATCH] Better remove_documentation. GitOrigin-RevId: ba92888e8278594dc6be6035a40e1292110ca647 --- tdtl/td/tl/tl_generate.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tdtl/td/tl/tl_generate.cpp b/tdtl/td/tl/tl_generate.cpp index 7d1e563cf..cb00cc11a 100644 --- a/tdtl/td/tl/tl_generate.cpp +++ b/tdtl/td/tl/tl_generate.cpp @@ -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) { std::size_t line_begin = 0; std::string result; + bool inside_documentation = false; while (line_begin < str.size()) { std::size_t line_end = str.find('\n', line_begin); if (line_end == std::string::npos) { @@ -865,12 +866,15 @@ static std::string remove_documentation(const std::string &str) { line_begin = line_end + 1; std::size_t pos = line.find_first_not_of(' '); - if (pos != std::string::npos && - ((line[pos] == '/' && line[pos + 1] == '/' && line[pos + 2] == '/') || - (line[pos] == '/' && line[pos + 1] == '*' && line[pos + 2] == '*') || line[pos] == '*')) { + if (pos != std::string::npos && ((line[pos] == '/' && line[pos + 1] == '/' && line[pos + 2] == '/') || + (line[pos] == '/' && line[pos + 1] == '*' && line[pos + 2] == '*') || + (inside_documentation && line[pos] == '*'))) { + inside_documentation = !(line[pos] == '/' && line[pos + 1] == '/' && line[pos + 2] == '/') && + !(line[pos] == '*' && line[pos + 1] == '/'); continue; } + inside_documentation = false; result += line; } return result;