From: "YO4 (Yoshinao Muramatsu) via ruby-core" Date: 2025-11-15T16:59:35+00:00 Subject: [ruby-core:123806] [Ruby Bug#21687] IO#pos goes wrong after EOF character(ctrl-z) met. Issue #21687 has been reported by YO4 (Yoshinao Muramatsu). ---------------------------------------- Bug #21687: IO���pos goes wrong after EOF character(ctrl-z) met. https://bugs.ruby-lang.org/issues/21687 * Author: YO4 (Yoshinao Muramatsu) * Status: Open * ruby -v: ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x64-mingw-ucrt] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- In Windows environment, when opening a file with the "r", encountering an EOF character (Ctrl-Z, "\x1A") during reading causes the IO to report END-OF-FILE. ```ruby require 'tempfile' Tempfile.open do |f| str = "0123456789\x1A" f.write(str + "x"*(1024_0 - str.bytesize)) f.rewind p f.readline.size # => 10 p f.pos # => 8191, shuld be 10 but equals rbuf size end ``` When the file reaches its end, the file position moves to the position after the last character. Therefore, when encountering the EOF character, the file position is expected to move to the position of the EOF character. This is somewhat unrelated, but I understand that self.seek(0, File::SEEK_END) not positioning at the EOF character is a known limitation. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/