aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/objectivec
diff options
context:
space:
mode:
authorSergio Campamá <kaipi@google.com>2016-08-12 11:44:03 -0700
committerThomas Van Lenten <thomasvl@google.com>2016-08-12 14:44:03 -0400
commita2484208c3291ea522a891114d2821829bd09083 (patch)
tree02d7a7b2711896de51ef0c414b6ab240b9598267 /src/google/protobuf/compiler/objectivec
parentcd561dddc9a0e6d9ea5f355148505de4bd62dabc (diff)
downloadprotobuf-a2484208c3291ea522a891114d2821829bd09083.tar.gz
protobuf-a2484208c3291ea522a891114d2821829bd09083.tar.bz2
protobuf-a2484208c3291ea522a891114d2821829bd09083.zip
Fixes extra whitespace on generated comments. (#1950)
Fixes extra whitespace on generated comments.
Diffstat (limited to 'src/google/protobuf/compiler/objectivec')
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_helpers.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
index 28b3f5ae..4a94373a 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
@@ -850,14 +850,17 @@ string BuildCommentsString(const SourceLocation& location,
string final_comments;
string epilogue;
+ bool add_leading_space = false;
+
if (prefer_single_line && lines.size() == 1) {
prefix = "/** ";
suffix = " */\n";
} else {
- prefix = " * ";
+ prefix = "* ";
suffix = "\n";
final_comments += "/**\n";
epilogue = " **/\n";
+ add_leading_space = true;
}
for (int i = 0; i < lines.size(); i++) {
@@ -868,7 +871,12 @@ string BuildCommentsString(const SourceLocation& location,
// Decouple / from * to not have inline comments inside comments.
line = StringReplace(line, "/*", "/\\*", true);
line = StringReplace(line, "*/", "*\\/", true);
- final_comments += prefix + line + suffix;
+ line = prefix + line;
+ StripWhitespace(&line);
+ // If not a one line, need to add the first space before *, as
+ // StripWhitespace would have removed it.
+ line = (add_leading_space ? " " : "") + line;
+ final_comments += line + suffix;
}
final_comments += epilogue;
return final_comments;