1
0
mirror of https://github.com/golang/go synced 2024-11-20 10:14:43 -07:00

pkg/go/ast: Avoid doing zero-length writes to the fd.

After each line, ast.Print would do a zero-length write,
which would hit the boundary condition on Plan 9 when
reading over pipes (since message boundaries are
preserved). This change makes sure we only do positive-
length writes.

R=rsc, rminnich, dave, r
CC=golang-dev
https://golang.org/cl/6558046
This commit is contained in:
Akshat Kumar 2012-09-24 08:30:28 +10:00 committed by Rob Pike
parent 3ec7be64c5
commit 659d1df1bc

View File

@ -108,8 +108,10 @@ func (p *printer) Write(data []byte) (n int, err error) {
}
p.last = b
}
m, err = p.output.Write(data[n:])
n += m
if len(data) > n {
m, err = p.output.Write(data[n:])
n += m
}
return
}