From acc8f420335ad386aac9e478a6aa7c7aa5f494fa Mon Sep 17 00:00:00 2001 From: Chen Date: Mon, 8 Jan 2018 13:40:11 +0800 Subject: [PATCH] [comments] Strip additional comment marker at the end of comments (#264) --- src/clang_cursor.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/clang_cursor.cc b/src/clang_cursor.cc index 873cbbc0..a4efda2b 100644 --- a/src/clang_cursor.cc +++ b/src/clang_cursor.cc @@ -258,11 +258,13 @@ optional ClangCursor::get_comments() const { clang_disposeString(cx_raw); while (ret.size() && isspace(ret.back())) ret.pop_back(); - if (ret.size() >= 2 && ret.compare(ret.size() - 2, 2, "*/") == 0) { + if (EndsWith(ret, "*/")) { + ret.resize(ret.size() - 2); + } else if (EndsWith(ret, "\n/")) { ret.resize(ret.size() - 2); - while (ret.size() && isspace(ret.back())) - ret.pop_back(); } + while (ret.size() && isspace(ret.back())) + ret.pop_back(); return ret; }