summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:54:32 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:54:32 +0000
commitdf9c0ae4abd6cb93cc8d541acc4b59570653e5c5 (patch)
tree97a0bc2df4c6adf87342779e64b3cd31fe15c94f
parent0293c3cb52c3eaa9068a2b3848271e1bc98c4199 (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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--io.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b0fd4eb63..6a9e200ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Dec 23 23:49:37 2008 Tanaka Akira <akr@fsij.org>
+
+ * io.c (rb_io_init_copy): call io_seek only if io_tell succeeds.
+
Tue Dec 23 20:28:28 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* io.c: rdoc for File::open and 1.9 feature in file modes.
diff --git a/io.c b/io.c
index 27da626ff..605799259 100644
--- a/io.c
+++ b/io.c
@@ -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);
}