mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_fflush): DRY patch from /Christoph applied.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
76f963d077
commit
564222ba27
2 changed files with 20 additions and 22 deletions
|
@ -20,6 +20,10 @@ Fri Mar 29 15:49:29 2002 Usaku Nakamura <usa@ruby-lang.org>
|
|||
|
||||
* win32/README.win32: follow recent changes.
|
||||
|
||||
Fri Mar 29 14:44:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* io.c (io_fflush): DRY patch from /Christoph applied.
|
||||
|
||||
Thu Mar 28 18:58:13 2002 Usaku Nakamura <usa@ruby-lang.org>
|
||||
|
||||
* win32/Makefile.sub (config.status): reflect user defined $CC in
|
||||
|
|
28
io.c
28
io.c
|
@ -244,9 +244,9 @@ ruby_dup(orig)
|
|||
}
|
||||
|
||||
static void
|
||||
io_fflush(f, path)
|
||||
io_fflush(f, fptr)
|
||||
FILE *f;
|
||||
const char *path;
|
||||
OpenFile *fptr;
|
||||
{
|
||||
int n;
|
||||
|
||||
|
@ -254,7 +254,7 @@ io_fflush(f, path)
|
|||
TRAP_BEG;
|
||||
n = fflush(f);
|
||||
TRAP_END;
|
||||
if (n == EOF) rb_sys_fail(path);
|
||||
if (n == EOF) rb_sys_fail(fptr->path);
|
||||
fptr->mode &= ~FMODE_WBUF;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ io_write(io, str)
|
|||
}
|
||||
#endif
|
||||
if (fptr->mode & FMODE_SYNC) {
|
||||
io_fflush(f, fptr->path);
|
||||
io_fflush(f, fptr);
|
||||
}
|
||||
else {
|
||||
fptr->mode |= FMODE_WBUF;
|
||||
|
@ -334,8 +334,7 @@ rb_io_flush(io)
|
|||
rb_io_check_writable(fptr);
|
||||
f = GetWriteFile(fptr);
|
||||
|
||||
io_fflush(f, fptr->path);
|
||||
fptr->mode &= ~FMODE_WBUF;
|
||||
io_fflush(f, fptr);
|
||||
|
||||
return io;
|
||||
}
|
||||
|
@ -485,8 +484,7 @@ rb_io_fsync(io)
|
|||
rb_io_check_writable(fptr);
|
||||
f = GetWriteFile(fptr);
|
||||
|
||||
io_fflush(f, fptr->path);
|
||||
fptr->mode &= ~FMODE_WBUF;
|
||||
io_fflush(f, fptr);
|
||||
if (fsync(fileno(f)) < 0)
|
||||
rb_sys_fail(fptr->path);
|
||||
return INT2FIX(0);
|
||||
|
@ -2075,12 +2073,11 @@ io_reopen(io, nfile)
|
|||
pos = ftello(orig->f);
|
||||
}
|
||||
if (orig->f2) {
|
||||
io_fflush(orig->f2, orig->path);
|
||||
io_fflush(orig->f2, orig);
|
||||
}
|
||||
else if (orig->mode & FMODE_WRITABLE) {
|
||||
io_fflush(orig->f, orig->path);
|
||||
io_fflush(orig->f, orig);
|
||||
}
|
||||
orig->mode &= ~FMODE_WBUF;
|
||||
rb_thread_fd_close(fileno(fptr->f));
|
||||
|
||||
/* copy OpenFile structure */
|
||||
|
@ -2205,12 +2202,11 @@ rb_io_clone(io)
|
|||
MakeOpenFile(clone, fptr);
|
||||
|
||||
if (orig->f2) {
|
||||
io_fflush(orig->f2, orig->path);
|
||||
io_fflush(orig->f2, orig);
|
||||
}
|
||||
else if (orig->mode & FMODE_WRITABLE) {
|
||||
io_fflush(orig->f, orig->path);
|
||||
io_fflush(orig->f, orig);
|
||||
}
|
||||
orig->mode &= ~FMODE_WBUF;
|
||||
|
||||
/* copy OpenFile structure */
|
||||
fptr->mode = orig->mode;
|
||||
|
@ -2335,10 +2331,8 @@ rb_io_putc(io, ch)
|
|||
|
||||
if (fputc(c, f) == EOF)
|
||||
rb_sys_fail(fptr->path);
|
||||
fptr->mode |= FMODE_WBUF;
|
||||
if (fptr->mode & FMODE_SYNC) {
|
||||
io_fflush(f, fptr->path);
|
||||
fptr->mode &= ~FMODE_WBUF;
|
||||
io_fflush(f, fptr);
|
||||
}
|
||||
else {
|
||||
fptr->mode |= FMODE_WBUF;
|
||||
|
|
Loading…
Reference in a new issue