[comments] Strip additional comment marker at the end of comments (#264)

This commit is contained in:
Chen 2018-01-08 13:40:11 +08:00 committed by Fangrui Song
parent 63178468eb
commit acc8f42033

View File

@ -258,11 +258,13 @@ optional<std::string> ClangCursor::get_comments() const {
clang_disposeString(cx_raw); clang_disposeString(cx_raw);
while (ret.size() && isspace(ret.back())) while (ret.size() && isspace(ret.back()))
ret.pop_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); 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; return ret;
} }