1
0
mirror of https://github.com/golang/go synced 2024-11-22 23:50:03 -07:00

go/printer: don't use 'infinity' value when it might lead to int32 overflow

Fixes 386 build breakage.

R=rsc
CC=golang-dev
https://golang.org/cl/6844091
This commit is contained in:
Robert Griesemer 2012-11-26 14:20:05 -08:00
parent 127d2bf785
commit 4a1b814668

View File

@ -1431,11 +1431,11 @@ func (p *printer) bodySize(b *ast.BlockStmt, maxSize int) int {
pos2 := b.Rbrace
if pos1.IsValid() && pos2.IsValid() && p.lineFor(pos1) != p.lineFor(pos2) {
// opening and closing brace are on different lines - don't make it a one-liner
return infinity
return maxSize + 1
}
if len(b.List) > 5 || p.commentBefore(p.posFor(pos2)) {
// too many statements or there is a comment inside - don't make it a one-liner
return infinity
return maxSize + 1
}
// otherwise, estimate body size
bodySize := 0