Commit 8f42a69f authored by Ilya Lipnitskiy's avatar Ilya Lipnitskiy

protoc-c/c_helpers.cc: Enhance comment string parsing

Certain protobuf comments could generate invalid C comments
and inadvertently close the comment block. This commit removes '/'
signs in such comments.

One example of a .proto file containing such comments is a commonly
included descriptor.proto from the protobuf library.
parent 5238d655
...@@ -225,6 +225,14 @@ void PrintComment (io::Printer* printer, string comment) ...@@ -225,6 +225,14 @@ void PrintComment (io::Printer* printer, string comment)
if (comment_lines[i][0] == '/') if (comment_lines[i][0] == '/')
comment_lines[i] = ' ' + comment_lines[i]; comment_lines[i] = ' ' + comment_lines[i];
/* Or cause other compiler issues. */
size_t delim_i;
while ((delim_i = comment_lines[i].find("/*")) != string::npos)
comment_lines[i][delim_i] = ' ';
while ((delim_i = comment_lines[i].find("*/")) != string::npos)
comment_lines[i][delim_i + 1] = ' ';
printer->Print (" *$line$\n", "line", comment_lines[i]); printer->Print (" *$line$\n", "line", comment_lines[i]);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment