New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zlib::GzipReader does not support #ungetc or #ungetbyte #4631

Closed
haines opened this Issue May 29, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@haines
Contributor

haines commented May 29, 2017

Environment

jruby 9.1.10.0 (2.3.3) 2017-05-25 b09c48a Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]

Expected Behavior

Zlib::GzipReader supports pushing data back onto the buffer via #ungetc and #ungetbyte.

# frozen_string_literal: true

require "zlib"

io = StringIO.new
writer = Zlib::GzipWriter.new(io)
writer.write "foo bar baz"
writer.close

reader = Zlib::GzipReader.new(StringIO.new(io.string))
reader.getc
reader.ungetc "b"
puts reader.read
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

$ ruby gzip_reader_ungetc.rb
boo bar baz

$ ruby -r zlib -e "p Zlib::GzipReader.public_method_defined?(:ungetbyte)"
true

Actual Behavior

Zlib::GzipReader implements #ungetc as a no-op and does not respond to #ungetbyte.

$ ruby -v
jruby 9.1.10.0 (2.3.3) 2017-05-25 b09c48a Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]

$ ruby gzip_reader_ungetc.rb
oo bar baz

$ ruby -r zlib -e "p Zlib::GzipReader.public_method_defined?(:ungetbyte)"
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment