Issue #6179 has been updated by phasis68 (Heesob Park).


I guess it is related with binary mode reading.
If I open a file with text mode, it works fine.

irb(main):001:0> a = File.open('foo.txt')
=> #<File:foo.txt>
irb(main):002:0> a.getc
=> "1"
irb(main):003:0> a.pos
=> 2
irb(main):004:0> a.getc
=> "3"
irb(main):005:0> a.pos
fptr->rbuf.len = 0
=> 4
irb(main):006:0> a = File.open('foo.txt','rt')
=> #<File:foo.txt>
irb(main):007:0> a.getc
=> "1"
irb(main):008:0> a.pos
fptr->rbuf.len = 0
=> 1
irb(main):009:0> a.getc
=> "2"
irb(main):010:0> a.pos
fptr->rbuf.len = 0
=> 2
irb(main):011:0> a.getc
=> "3"
irb(main):012:0> a.pos
fptr->rbuf.len = 0
=> 3

BTW, my test OS is Windows XP SP3.

----------------------------------------
Bug #6179: File::pos broken in Windows 1.9.3p125
https://bugs.ruby-lang.org/issues/6179#change-25006

Author: jmthomas (Jason Thomas)
Status: Closed
Priority: Normal
Assignee: 
Category: core
Target version: 1.9.3
ruby -v: 1.9.3p125


Calling the pos method on a File in the Windows version of Ruby on 1.9.3p125 moves the file pointer. Thus it can not be called without side effect.


-- 
http://bugs.ruby-lang.org/