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
diff --git a/src/pkg/go/ast/print.go b/src/pkg/go/ast/print.go
index 2de9af2..4a1ce48 100644
--- a/src/pkg/go/ast/print.go
+++ b/src/pkg/go/ast/print.go
@@ -108,8 +108,10 @@
}
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
}