summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-23 15:22:18 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-23 15:22:18 +0000
commit4fe1dc5201ac8185a6b7e1d8681c596955ee5c79 (patch)
tree604fbfd93af1928bce3979d5561190412a3a3f19
parent6acb3c5f9a8d1bd7822d8f7b984291f3e63bc3d6 (diff)
downloadruby-4fe1dc5201ac8185a6b7e1d8681c596955ee5c79.tar.gz
ruby-4fe1dc5201ac8185a6b7e1d8681c596955ee5c79.tar.xz
ruby-4fe1dc5201ac8185a6b7e1d8681c596955ee5c79.zip
* io.c (rb_io_init_copy): call io_seek only if io_tell succeeds.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--io.c5
2 files changed, 10 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c32f12d5b..d12bec132 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,15 @@
+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 22:57:48 2008 Tanaka Akira <akr@fsij.org>
- * process.c (rb_fork): don't propagete an error message if error
+ * process.c (rb_fork): don't propagate an error message if error
buffer not given.
Tue Dec 23 21:55:05 2008 Tanaka Akira <akr@fsij.org>
- * process.c (rb_fork): propagete an error message from child to parent.
+ * process.c (rb_fork): propagate an error message from child to parent.
(rb_f_exec): show details of error in child process on
exception.
(save_redirect_fd): add error message arguments.
diff --git a/io.c b/io.c
index eae314b73..e86a59ae7 100644
--- a/io.c
+++ b/io.c
@@ -5368,6 +5368,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;
@@ -5386,7 +5387,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);
}