]> Cypherpunks repositories - gostls13.git/commitdiff
pkg/go/ast: Avoid doing zero-length writes to the fd.
authorAkshat Kumar <seed@mail.nanosouffle.net>
Sun, 23 Sep 2012 22:30:28 +0000 (08:30 +1000)
committerRob Pike <r@golang.org>
Sun, 23 Sep 2012 22:30:28 +0000 (08:30 +1000)
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

src/pkg/go/ast/print.go

index 2de9af299e5cd811a60354dc99a8244b4bda94a4..4a1ce480f42cd6ada35e1055f35166cdc36224cb 100644 (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
 }