summaryrefslogtreecommitdiff
path: root/libgo/go/os
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-02 19:34:41 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-02 19:34:41 +0000
commit0ba415ab214ea7bc9c0b5a31e809998686d8b511 (patch)
treefe0344f264049738dca876a6dd2f69e96621ca17 /libgo/go/os
parentb2c1d8d78d1a819c3cbadc61dea50b856a4f0607 (diff)
downloadgcc-0ba415ab214ea7bc9c0b5a31e809998686d8b511.tar.gz
libgo: Update to weekly.2011-11-01.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181938 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/os')
-rw-r--r--libgo/go/os/file.go2
-rw-r--r--libgo/go/os/os_test.go21
2 files changed, 22 insertions, 1 deletions
diff --git a/libgo/go/os/file.go b/libgo/go/os/file.go
index 4335d45e5a0..9f982e183a2 100644
--- a/libgo/go/os/file.go
+++ b/libgo/go/os/file.go
@@ -69,7 +69,7 @@ func (file *File) Read(b []byte) (n int, err Error) {
if n < 0 {
n = 0
}
- if n == 0 && !iserror(e) {
+ if n == 0 && len(b) > 0 && !iserror(e) {
return 0, EOF
}
if iserror(e) {
diff --git a/libgo/go/os/os_test.go b/libgo/go/os/os_test.go
index 3277fc22bfa..b8c4967b12d 100644
--- a/libgo/go/os/os_test.go
+++ b/libgo/go/os/os_test.go
@@ -163,6 +163,27 @@ func TestLstat(t *testing.T) {
}
}
+// Read with length 0 should not return EOF.
+func TestRead0(t *testing.T) {
+ path := sfdir + "/" + sfname
+ f, err := Open(path)
+ if err != nil {
+ t.Fatal("open failed:", err)
+ }
+ defer f.Close()
+
+ b := make([]byte, 0)
+ n, err := f.Read(b)
+ if n != 0 || err != nil {
+ t.Errorf("Read(0) = %d, %v, want 0, nil", n, err)
+ }
+ b = make([]byte, 100)
+ n, err = f.Read(b)
+ if n <= 0 || err != nil {
+ t.Errorf("Read(100) = %d, %v, want >0, nil", n, err)
+ }
+}
+
func testReaddirnames(dir string, contents []string, t *testing.T) {
file, err := Open(dir)
defer file.Close()