Skip Menu |
 

This queue is for tickets about the Compress-Raw-Zlib CPAN distribution.

Report information
The Basics
Id: 36046
Status: resolved
Priority: 0/
Queue: Compress-Raw-Zlib

People
Owner: Nobody in particular
Requestors: itsme [...] xs4all.nl
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 2.001
  • 2.002
  • 2.003
  • 2.004
  • 2.005
  • 2.006
  • 2.008
  • 2.009
  • 2.010
  • 2.011
Fixed in: 2.012



Subject: raw inflate with dictionary.
Download (untitled) / with headers
text/plain 427b
when you specify a negative value for WindowBits, zlib will operate in 'raw' mode, meaning: no wrapping, just the data. if you deflate with a dictionary, you need to specify this dictionary at inflate time, right after calling inflateInit. currently in Zlib.xs, inflateSetDictionary is only called when inflate returns a 'Z_NEED_DICT' status. in raw mode this will never happen. attached is a patch which fixes this. willem
Subject: zlib-rawdict.patch
Download zlib-rawdict.patch
text/x-diff 783b
--- Zlib.xs Tue May 20 19:02:51 2008 +++ Zlib-wj.xs Tue May 20 19:02:44 2008 @@ -1297,8 +1297,14 @@ } s->bytesInflated = 0; - while (1) { + RETVAL = Z_OK; + if (s->dictionary && s->WindowBits<0) { + RETVAL = inflateSetDictionary(&(s->stream), + (const Bytef*)SvPVbyte_nolen(s->dictionary), + SvCUR(s->dictionary)); + } + while (RETVAL == Z_OK) { if (s->stream.avail_out == 0 ) { /* out of space in the output buffer so make it bigger */ Sv_Grow(output, SvLEN(output) + bufinc) ; @@ -1331,8 +1337,6 @@ SvCUR(s->dictionary)); } - if (RETVAL != Z_OK) - break; } #ifdef NEED_DUMMY_BYTE_AT_END if (eof && RETVAL == Z_OK) {
Thanks Willem, patch applied to my development copy. cheers Paul
Download (untitled) / with headers
text/plain 513b
Actually, there is a problem with the patch as it stands. The patch adds a call to inflateSetDictionary is in the inflate method. That will, of course, mean it will get called directly after the call to inflateInit2 like it says in zlib.h, but it also means it will get called again every time inflate gets called. Thats not how I'm reading what zlib.h says should happen. I've moved the logic to _inflateInit where inflateSetDictionary will get called precisely once - just after inflateInit2 is called. Paul


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.