From: Simon Strandgaard Date: 2004-05-22T01:02:02+09:00 Subject: Re: [rcr] make File#dup intuitive Simon Strandgaard wrote: > f1 = File.open(__FILE__, 'r') > f1.seek(5) > p f1.pos # -> 5 > f2 = f1.dup > p f2.pos # -> garbage > > server> ruby a.rb > 5 > 93 > server> then nobu.nokada@softhome.net wrote: > > Index: io.c > =================================================================== > RCS file: /cvs/ruby/src/ruby/io.c,v > retrieving revision 1.274 > diff -u -2 -p -r1.274 io.c > --- io.c 8 May 2004 08:11:33 -0000 1.274 > +++ io.c 21 May 2004 06:55:56 -0000 > @@ -3332,4 +3332,5 @@ rb_io_init_copy(dest, io) > fd = ruby_dup(fileno(orig->f)); > fptr->f = rb_fdopen(fd, mode); > + fseeko(fptr->f, ftello(orig->f), SEEK_SET); > if (orig->f2) { > if (fileno(orig->f) != fileno(orig->f2)) { > @@ -3337,4 +3338,5 @@ rb_io_init_copy(dest, io) > } > fptr->f2 = rb_fdopen(fd, "w"); > + fseeko(fptr->f2, ftello(orig->f2), SEEK_SET); > } > if (fptr->mode & FMODE_BINMODE) { > then Simon Strandgaard wrote: > Your new patch works like a charm :-) > > server> ./ruby a.rb > 5 > 5 > server> Will this wonderful patch be committed to cvs ? -- Simon Strandgaard