From de5a85496ac4ae7bd24b5fc7acb8001a5e4d8b7d Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 18 Sep 2004 06:56:38 +0000 Subject: * array.c (rb_ary_equal): element size might change during comparison. [ruby-dev:24254] * array.c (rb_ary_diff): ditto. [ruby-dev:24274] * array.c (rb_ary_select): ditto. [ruby-dev:24278] * array.c (rb_ary_delete): ditto. [ruby-dev:24283] * array.c (rb_ary_rindex): ditto. [ruby-dev:24275] * array.c (rb_ary_initialize): element size might change during initializing block. [ruby-dev:24284] * dir.c (dir_s_chdir): avoid memory leak and unnecessary chdir to the original directory when exception has caused in changing direcotry or within block. thanks to Johan Holmberg [ruby-core:03446] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 7f5452b7c5..a66e444543 100644 --- a/file.c +++ b/file.c @@ -2853,18 +2853,21 @@ rb_file_truncate(obj, len) VALUE obj, len; { OpenFile *fptr; + FILE *f; rb_secure(2); GetOpenFile(obj, fptr); if (!(fptr->mode & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "not opened for writing"); } + f = GetWriteFile(fptr); + fflush(f); #ifdef HAVE_TRUNCATE - if (ftruncate(fileno(fptr->f), NUM2OFFT(len)) < 0) + if (ftruncate(fileno(f), NUM2OFFT(len)) < 0) rb_sys_fail(fptr->path); #else # ifdef HAVE_CHSIZE - if (chsize(fileno(fptr->f), NUM2OFFT(len)) < 0) + if (chsize(fileno(f), NUM2OFFT(len)) < 0) rb_sys_fail(fptr->path); # else rb_notimplement(); -- cgit v1.2.3