confusing rdoc on Zlib
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)
And the inflate snippet is:
zstream = Zlib::Inflate.new
buf = zstream.inflate(string)
And then testing them with:
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.
Updated by drbrain (Eric Hodel) over 8 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]