diff options
Diffstat (limited to 'src/pkg/go/doc/comment.go')
-rw-r--r-- | src/pkg/go/doc/comment.go | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/pkg/go/doc/comment.go b/src/pkg/go/doc/comment.go index 3d04c349c..ba9371439 100644 --- a/src/pkg/go/doc/comment.go +++ b/src/pkg/go/doc/comment.go @@ -19,11 +19,11 @@ import ( // with the comment markers - //, /*, and */ - removed. func CommentText(comment *ast.CommentGroup) string { if comment == nil { - return ""; + return "" } comments := make([]string, len(comment.List)); for i, c := range comment.List { - comments[i] = string(c.Text); + comments[i] = string(c.Text) } lines := make([]string, 0, 20); @@ -32,12 +32,12 @@ func CommentText(comment *ast.CommentGroup) string { // The parser has given us exactly the comment text. switch n := len(c); { case n >= 4 && c[0:2] == "/*" && c[n-2 : n] == "*/": - c = c[2 : n-2]; + c = c[2 : n-2] case n >= 2 && c[0:2] == "//": c = c[2:n]; // Remove leading space after //, if there is one. if len(c) > 0 && c[0] == ' ' { - c = c[1:len(c)]; + c = c[1:len(c)] } } @@ -49,7 +49,7 @@ func CommentText(comment *ast.CommentGroup) string { // Strip trailing white space m := len(l); for m > 0 && (l[m-1] == ' ' || l[m-1] == '\n' || l[m-1] == '\t' || l[m-1] == '\r') { - m--; + m-- } l = l[0:m]; @@ -58,7 +58,7 @@ func CommentText(comment *ast.CommentGroup) string { if n+1 >= cap(lines) { newlines := make([]string, n, 2*cap(lines)); for k := range newlines { - newlines[k] = lines[k]; + newlines[k] = lines[k] } lines = newlines; } @@ -100,7 +100,7 @@ func split(text []byte) [][]byte { } } if last < len(text) { - n++; + n++ } // split @@ -115,7 +115,7 @@ func split(text []byte) [][]byte { } } if last < len(text) { - out[n] = text[last:len(text)]; + out[n] = text[last:len(text)] } return out; @@ -137,9 +137,9 @@ func commentEscape(w io.Writer, s []byte) { last = i+2; switch s[i] { case '`': - w.Write(ldquo); + w.Write(ldquo) case '\'': - w.Write(rdquo); + w.Write(rdquo) } i++; // loop will add one more } @@ -159,7 +159,7 @@ var ( func indentLen(s []byte) int { i := 0; for i < len(s) && (s[i] == ' ' || s[i] == '\t') { - i++; + i++ } return i; } @@ -171,7 +171,7 @@ func isBlank(s []byte) bool { return len(s) == 0 || (len(s) == 1 && s[0] == '\n' func commonPrefix(a, b []byte) []byte { i := 0; for i < len(a) && i < len(b) && a[i] == b[i] { - i++; + i++ } return a[0:i]; } @@ -179,14 +179,14 @@ func commonPrefix(a, b []byte) []byte { func unindent(block [][]byte) { if len(block) == 0 { - return; + return } // compute maximum common white prefix prefix := block[0][0 : indentLen(block[0])]; for _, line := range block { if !isBlank(line) { - prefix = commonPrefix(prefix, line[0 : indentLen(line)]); + prefix = commonPrefix(prefix, line[0 : indentLen(line)]) } } n := len(prefix); @@ -194,7 +194,7 @@ func unindent(block [][]byte) { // remove for i, line := range block { if !isBlank(line) { - block[i] = line[n:len(line)]; + block[i] = line[n:len(line)] } } } @@ -244,11 +244,11 @@ func ToHTML(w io.Writer, s []byte) { // count indented or blank lines j := i+1; for j < len(lines) && (isBlank(lines[j]) || indentLen(lines[j]) > 0) { - j++; + j++ } // but not trailing blank lines for j > i && isBlank(lines[j-1]) { - j--; + j-- } block := lines[i:j]; i = j; @@ -260,7 +260,7 @@ func ToHTML(w io.Writer, s []byte) { // just html escaping w.Write(html_pre); for _, line := range block { - template.HTMLEscape(w, line); + template.HTMLEscape(w, line) } w.Write(html_endpre); continue; |