From 1f7525e99106d3543342ac5e8ec1dea39b7b3f80 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 27 May 2022 15:32:09 -0400 Subject: [PATCH] Remove leading blank lines in convert_comments.go The OpenSSL style writes multiline block comments with a blank line at the top and bottom, like so: /* * Some multi-line * comment */ The script already removed the trailing blank line, but not the leading one. When we go to run this script in crypto/asn1, etc., we'll come across those comments. Change-Id: I189aec87a08607008779f883a97f2c53d24ee2da Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52730 Reviewed-by: Bob Beck Commit-Queue: Bob Beck --- util/convert_comments.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/util/convert_comments.go b/util/convert_comments.go index c03eeb81b..afd070f70 100644 --- a/util/convert_comments.go +++ b/util/convert_comments.go @@ -232,6 +232,29 @@ func convertComments(path string, in []byte) []byte { } for i, line := range group.lines { + // The OpenSSL style writes multiline block comments with a + // blank line at the top and bottom, like so: + // + // /* + // * Some multi-line + // * comment + // */ + // + // The trailing lines are already removed above, when buffering. + // Remove the leading lines here. (The leading lines cannot be + // removed when buffering because we may discover the comment is + // not convertible in later lines.) + // + // Note the leading line cannot be easily removed if there is + // code before it, such as the following. Skip those cases. + // + // foo(); /* + // * Some multi-line + // * comment + // */ + if i == 0 && allSpaces(line[:group.column]) && len(line) == group.column+2 { + continue + } newLine := fmt.Sprintf("%s%s//%s", line[:group.column], adjust, strings.TrimRight(line[group.column+2:], " ")) if len(newLine) > 80 { fmt.Fprintf(os.Stderr, "%s:%d: Line is now longer than 80 characters\n", path, lineNo+i+1)