mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: don't let inserted /*line*/ become a // comment
Fixes #29383 Change-Id: I0fb2929863e153b96d32d851e25e536231e4ae65 Reviewed-on: https://go-review.googlesource.com/c/155638 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
e7c20b7917
commit
08477a38ab
2 changed files with 23 additions and 2 deletions
|
|
@ -1389,7 +1389,9 @@ func (p *Package) rewriteRef(f *File) {
|
|||
|
||||
// Record source-level edit for cgo output.
|
||||
if !r.Done {
|
||||
repl := gofmtPos(expr, old.Pos())
|
||||
// Prepend a space in case the earlier code ends
|
||||
// with '/', which would give us a "//" comment.
|
||||
repl := " " + gofmtPos(expr, old.Pos())
|
||||
end := fset.Position(old.End())
|
||||
// Subtract 1 from the column if we are going to
|
||||
// append a close parenthesis. That will set the
|
||||
|
|
@ -1399,7 +1401,7 @@ func (p *Package) rewriteRef(f *File) {
|
|||
sub = 1
|
||||
}
|
||||
if end.Column > sub {
|
||||
repl = fmt.Sprintf("%s/*line :%d:%d*/", repl, end.Line, end.Column-sub)
|
||||
repl = fmt.Sprintf("%s /*line :%d:%d*/", repl, end.Line, end.Column-sub)
|
||||
}
|
||||
if r.Name.Kind != "type" {
|
||||
repl = "(" + repl + ")"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue