Actions
Bug #6273
closedconfusing rdoc on Zlib
Description
=begin
The rdoc at ext/zlib/zlib.c gives some examples of code to deflate/inflate a string. If you try to use them to actually deflate/inflate it gives an error inflating.
The deflate snippet is:
def deflate(string, level)
z = Zlib::Deflate.new(level)
dst = z.deflate(string, Zlib::NO_FLUSH)
z.close
dst
end
And the inflate snippet is:
def inflate(string)
zstream = Zlib::Inflate.new
buf = zstream.inflate(string)
zstream.finish
zstream.close
buf
end
And then testing them with:
inflate(deflate("test-string", 6))
It returns "Zlib::BufError: buffer error".
The error is because the flush parameter used is NO_FLUSH. It should be changed to FINISH for the deflating/inflating to work.
=end
Actions
Like0
Like0Like0