diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:54:32 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:54:32 +0000 |
commit | c2f1f60fc2f631acccab6946ab16212b0a5920b7 (patch) | |
tree | 97a0bc2df4c6adf87342779e64b3cd31fe15c94f /io.c | |
parent | 9c171e3d6b15209be8ff142ae97a632cc91a1bf8 (diff) |
merges r20954 from trunk into ruby_1_9_1.
* io.c (rb_io_init_copy): call io_seek only if io_tell succeeds.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -5338,6 +5338,7 @@ rb_io_init_copy(VALUE dest, VALUE io) rb_io_t *fptr, *orig; int fd; VALUE write_io; + off_t pos; io = rb_io_get_io(io); if (dest == io) return dest; @@ -5356,7 +5357,9 @@ rb_io_init_copy(VALUE dest, VALUE io) fd = ruby_dup(orig->fd); fptr->fd = fd; - io_seek(fptr, io_tell(orig), SEEK_SET); + pos = io_tell(orig); + if (0 <= pos) + io_seek(fptr, pos, SEEK_SET); if (fptr->mode & FMODE_BINMODE) { rb_io_binmode(dest); } |