diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-17 09:24:13 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-17 09:24:13 +0000 |
commit | e77ddaf0d1d421da2f655832a45f237558e23115 (patch) | |
tree | b20cb859d6ca1886f525e4b7477601bb1a5fbe31 /file.c | |
parent | 7b66963f61609fe8edea2380cba43289381a43d7 (diff) | |
download | ruby-e77ddaf0d1d421da2f655832a45f237558e23115.tar.gz |
* array.c (rb_ary_delete): element comparison might change array
size. [ruby-dev:24273]
* parse.y: make ruby parser reentrant. merge ripper parser to the
real one. this change makes ruby require bison.
* file.c (rb_file_truncate): clear stdio buffer before truncating
the file. [ruby-dev:24191]
* ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF
which might return singleton class. [ruby-dev:24202]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -2965,18 +2965,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(); |