* io.c (io_write): must check returned value from fwrite() before
test with ferror(). (ruby-bugs-ja:PR#350) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e2d1e7cfe4
commit
00882bfe35
@ -1,3 +1,8 @@
|
|||||||
|
Tue Oct 8 14:19:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
|
* io.c (io_write): must check returned value from fwrite() before
|
||||||
|
test with ferror(). (ruby-bugs-ja:PR#350)
|
||||||
|
|
||||||
Tue Oct 8 10:55:23 2002 Tanaka Akira <akr@m17n.org>
|
Tue Oct 8 10:55:23 2002 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* lib/prettyprint.rb (PrettyPrint.singleline_format): new method.
|
* lib/prettyprint.rb (PrettyPrint.singleline_format): new method.
|
||||||
|
10
io.c
10
io.c
@ -366,17 +366,15 @@ io_write(io, str)
|
|||||||
|
|
||||||
ptr = RSTRING(str)->ptr;
|
ptr = RSTRING(str)->ptr;
|
||||||
n = RSTRING(str)->len;
|
n = RSTRING(str)->len;
|
||||||
do {
|
|
||||||
#ifdef __human68k__
|
#ifdef __human68k__
|
||||||
|
do {
|
||||||
if (fputc(*ptr++, f) == EOF) {
|
if (fputc(*ptr++, f) == EOF) {
|
||||||
if (ferror(f)) rb_sys_fail(fptr->path);
|
if (ferror(f)) rb_sys_fail(fptr->path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--n;
|
} while (--n > 0);
|
||||||
#else
|
#else
|
||||||
r = fwrite(ptr, 1, n, f);
|
for (; (r = fwrite(ptr, 1, n, f)) < n; ptr += r, n -= r) {
|
||||||
ptr += r;
|
|
||||||
n -= r;
|
|
||||||
if (ferror(f)) {
|
if (ferror(f)) {
|
||||||
if (rb_io_wait_writable(fileno(f))) {
|
if (rb_io_wait_writable(fileno(f))) {
|
||||||
clearerr(f);
|
clearerr(f);
|
||||||
@ -384,8 +382,8 @@ io_write(io, str)
|
|||||||
}
|
}
|
||||||
rb_sys_fail(fptr->path);
|
rb_sys_fail(fptr->path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} while (n > 0);
|
|
||||||
n = ptr - RSTRING(str)->ptr;
|
n = ptr - RSTRING(str)->ptr;
|
||||||
if (fptr->mode & FMODE_SYNC) {
|
if (fptr->mode & FMODE_SYNC) {
|
||||||
io_fflush(f, fptr);
|
io_fflush(f, fptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user