Actions
Bug #19389
closedStringIO gets(..., chomp: true) behaves differently to File/IO.
Bug #19389: StringIO gets(..., chomp: true) behaves differently to File/IO.
Description
It seems like StringIO and File #gets(..., chomp: true) have different behaviour.
irb(main):003:0> io = StringIO.new("foo\r\nbar\r\n\r\n") => #<StringIO:0x00000001077e2018> irb(main):004:0> io.gets("\r\n", chomp: true) => "foo" irb(main):005:0> io.gets("\r\n", chomp: true) => "bar" irb(main):006:0> io.gets("\r\n", chomp: true) => "\r\n" compared with File:
irb(main):008:0> io = Tempfile.new => #<File:/var/folders/cm/p8lkj40s0vz_vgx_b5df9dkm0000gn/T/20230128-37714-107ims> irb(main):009:0> io.write("foo\r\nbar\r\n\r\n") => 12 irb(main):012:0> io.rewind => 0 irb(main):013:0> io.gets("\r\n", chomp: true) => "foo" irb(main):014:0> io.gets("\r\n", chomp: true) => "bar" irb(main):015:0> io.gets("\r\n", chomp: true) => "" Actions