=begin
なかだです。
At Sun, 28 Mar 2010 16:39:07 +0900,
Takashi Tamura wrote in [ruby-dev:40802]:
$ port info zlib
zlib @1.2.4, Revision 1 (archivers)
- Error:
test_params(TestZlibDeflate):
Zlib::BufError: buffer error
/Users/tamura/ruby/src/ruby19/test/zlib/test_zlib.rb:129:in inflate' /Users/tamura/ruby/src/ruby19/test/zlib/test_zlib.rb:129:in
test_params'
1.2.4のdeflateParams()が、すでにflushしているのに再度同じデータ
を追加しているようです。それをちゃんとカウントしていないのは
ext/zlibのバグだと思うのですが、zlib 1.2.4のほうもまたバグがある
ような気がします。どっちがいいんでしょうねぇ。
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 435a1a6..fbeb72a 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -1371,16 +1371,31 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
struct zstream *z = get_zstream(obj);
int level, strategy;
int err;
-
uInt n; /* workaround for 1.2.4 */
+#if 0
-
/* add extra data */
+#define ADJUST(z, n) (z->buf_filled += n - z->stream.avail_out)
+#else
-
/* drop extra data */
+#define ADJUST(z, n) ( \
-
z->stream.next_out -= n - z->stream.avail_out, \
-
z->stream.avail_out = n)
+#endif
level = ARG_LEVEL(v_level);
strategy = ARG_STRATEGY(v_strategy);
zstream_run(z, (Bytef*)"", 0, Z_SYNC_FLUSH);
-
zstream_run(z, (Bytef*)"", 0, Z_SYNC_FLUSH);
-
n = z->stream.avail_out;
err = deflateParams(&z->stream, level, strategy);
-
ADJUST(z, n);
while (err == Z_BUF_ERROR) {
rb_warning("deflateParams() returned Z_BUF_ERROR");
zstream_expand_buffer(z);
-
n = z->stream.avail_out;
err = deflateParams(&z->stream, level, strategy);
-
ADJUST(z, n);
}
if (err != Z_OK) {
raise_zlib_error(err, z->stream.msg);
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦
=end