diff options
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r-- | ext/zlib/zlib.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 5607162..b5495a2 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -3,7 +3,7 @@ * * Copyright (C) UENO Katsuhiro 2000-2003 * - * $Id: zlib.c 34544 2012-02-10 18:37:45Z naruse $ + * $Id: zlib.c 36939 2012-09-09 14:01:53Z naruse $ */ #include <ruby.h> @@ -464,7 +464,11 @@ rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2) static VALUE rb_zlib_crc_table(VALUE obj) { - const unsigned long *crctbl; +#if !defined(HAVE_TYPE_Z_CRC_T) + /* z_crc_t is defined since zlib-1.2.7. */ + typedef unsigned long z_crc_t; +#endif + const z_crc_t *crctbl; VALUE dst; int i; @@ -1732,7 +1736,7 @@ do_inflate(struct zstream *z, VALUE src) return; } StringValue(src); - if (RSTRING_LEN(src) > 0) { /* prevent Z_BUF_ERROR */ + if (RSTRING_LEN(src) > 0 || z->stream.avail_in > 0) { /* prevent Z_BUF_ERROR */ zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_SYNC_FLUSH); } } @@ -1749,7 +1753,23 @@ do_inflate(struct zstream *z, VALUE src) * * Raises a Zlib::NeedDict exception if a preset dictionary is needed to * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then - * call this method again with an empty string. (<i>???</i>) + * call this method again with an empty string to flush the stream: + * + * inflater = Zlib::Inflate.new + * + * begin + * out = inflater.inflate compressed + * rescue Zlib::NeedDict + * # ensure the dictionary matches the stream's required dictionary + * raise unless inflater.adler == Zlib.adler32(dictionary) + * + * inflater.set_dictionary dictionary + * inflater.inflate '' + * end + * + * # ... + * + * inflater.close * * See also Zlib::Inflate.new */ |