Subject: | raw inflate with dictionary. |
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 |
--- 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) {