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
Updated by drbrain (Eric Hodel) over 12 years ago
- Category set to doc
- Assignee set to drbrain (Eric Hodel)
Updated by drbrain (Eric Hodel) over 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r35273.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- ext/zlib/zlib.c (rb_deflate_s_deflate): Fixed ruby example replacing
NO_FLUSH with FINISH. [ruby-trunk - Bug #6273]