Hi,

At Fri, 21 May 2004 01:22:49 +0900,
Simon Strandgaard wrote in [ruby-talk:100910]:
> position is not copied.. try this example for yourself

I've expected it had been fixed.

This patch works?


Index: io.c =================================================================== RCS file: /cvs/ruby/src/ruby/io.c,v retrieving revision 1.274 diff -U2 -p -d -r1.274 io.c --- io.c 8 May 2004 08:11:33 -0000 1.274 +++ io.c 21 May 2004 06:17:56 -0000 @@ -3295,4 +3295,5 @@ rb_io_init_copy(dest, io) int fd; char *mode; + off_t pos1, pos2; io = rb_io_get_io(io); @@ -3303,12 +3304,10 @@ rb_io_init_copy(dest, io) if (orig->f2) { io_fflush(orig->f2, orig); - fseeko(orig->f, 0L, SEEK_CUR); + pos2 = fseeko(orig->f2, 0L, SEEK_CUR); } else if (orig->mode & FMODE_WRITABLE) { io_fflush(orig->f, orig); } - else { - fseeko(orig->f, 0L, SEEK_CUR); - } + pos1 = fseeko(orig->f, 0L, SEEK_CUR); /* copy OpenFile structure */ @@ -3332,4 +3331,5 @@ rb_io_init_copy(dest, io) fd = ruby_dup(fileno(orig->f)); fptr->f = rb_fdopen(fd, mode); + fseeko(fptr->f, pos1, SEEK_SET); if (orig->f2) { if (fileno(orig->f) != fileno(orig->f2)) { @@ -3337,4 +3337,5 @@ rb_io_init_copy(dest, io) } fptr->f2 = rb_fdopen(fd, "w"); + fseeko(fptr->f2, pos2, SEEK_SET); } if (fptr->mode & FMODE_BINMODE) {
-- Nobu Nakada