summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/io.c b/io.c
index 54438b4f87..c5fb2359f6 100644
--- a/io.c
+++ b/io.c
@@ -255,14 +255,14 @@ io_write(io, str)
n = (int)RSTRING(str)->len;
while (--n >= 0)
if (fputc(*ptr++, f) == EOF)
- rb_sys_fail(fptr->path);
+ break;
n = ptr - RSTRING(str)->ptr;
}
- if (ferror(f))
+ if (n == 0 && ferror(f))
rb_sys_fail(fptr->path);
#else
n = fwrite(RSTRING(str)->ptr, 1, RSTRING(str)->len, f);
- if (ferror(f)) {
+ if (n == 0 && ferror(f)) {
rb_sys_fail(fptr->path);
}
#endif