zlib 2.1.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/zlib/extconf.rb +2 -0
- data/ext/zlib/zlib.c +101 -56
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5256d7574d4fcaf95d85282fb08608413d86ebd4818db7cde168441b0c3872a
|
|
4
|
+
data.tar.gz: 51c94357b975da64fecb9aa6a7d76ecfe465de32beba7d9c7e2f3b16ffa7c2e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ae90c906532814044b416cfec733b13409b99a6bb2e32d3a4aa2f18f068327442dde8b5c4898b556bc0905bb61de9211a8cc9a014e95d39f09343be0de377f3c
|
|
7
|
+
data.tar.gz: 1e43996f98659c4718cfb02650fb473666d779d8b45aa42cd287cc7bd42d09723b7fc8dac30f48ae4e348901fa473bca7b197c00feefc081276844712d18efed
|
data/ext/zlib/extconf.rb
CHANGED
|
@@ -121,10 +121,12 @@ if have_zlib
|
|
|
121
121
|
$defs << "-DHAVE_CRC32_COMBINE"
|
|
122
122
|
$defs << "-DHAVE_ADLER32_COMBINE"
|
|
123
123
|
$defs << "-DHAVE_TYPE_Z_CRC_T"
|
|
124
|
+
$defs << "-DHAVE_TYPE_Z_SIZE_T"
|
|
124
125
|
else
|
|
125
126
|
have_func('crc32_combine', 'zlib.h')
|
|
126
127
|
have_func('adler32_combine', 'zlib.h')
|
|
127
128
|
have_type('z_crc_t', 'zlib.h')
|
|
129
|
+
have_type('z_size_t', 'zlib.h')
|
|
128
130
|
end
|
|
129
131
|
|
|
130
132
|
create_makefile('zlib') {|conf|
|
data/ext/zlib/zlib.c
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
|
|
26
26
|
#endif
|
|
27
27
|
|
|
28
|
-
#define RUBY_ZLIB_VERSION "
|
|
28
|
+
#define RUBY_ZLIB_VERSION "3.0.1"
|
|
29
29
|
|
|
30
30
|
#ifndef RB_PASS_CALLED_KEYWORDS
|
|
31
31
|
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
|
|
@@ -44,6 +44,14 @@
|
|
|
44
44
|
#endif
|
|
45
45
|
#endif
|
|
46
46
|
|
|
47
|
+
#if defined(HAVE_TYPE_Z_SIZE_T)
|
|
48
|
+
typedef uLong (*checksum_func)(uLong, const Bytef*, z_size_t);
|
|
49
|
+
# define crc32 crc32_z
|
|
50
|
+
# define adler32 adler32_z
|
|
51
|
+
#else
|
|
52
|
+
typedef uLong (*checksum_func)(uLong, const Bytef*, uInt);
|
|
53
|
+
#endif
|
|
54
|
+
|
|
47
55
|
#if SIZEOF_LONG > SIZEOF_INT
|
|
48
56
|
static inline uInt
|
|
49
57
|
max_uint(long n)
|
|
@@ -65,7 +73,7 @@ static ID id_dictionaries, id_read, id_buffer;
|
|
|
65
73
|
|
|
66
74
|
static NORETURN(void raise_zlib_error(int, const char*));
|
|
67
75
|
static VALUE rb_zlib_version(VALUE);
|
|
68
|
-
static VALUE do_checksum(int, VALUE*,
|
|
76
|
+
static VALUE do_checksum(int, VALUE*, checksum_func);
|
|
69
77
|
static VALUE rb_zlib_adler32(int, VALUE*, VALUE);
|
|
70
78
|
static VALUE rb_zlib_crc32(int, VALUE*, VALUE);
|
|
71
79
|
static VALUE rb_zlib_crc_table(VALUE);
|
|
@@ -288,6 +296,7 @@ static VALUE rb_gzreader_readlines(int, VALUE*, VALUE);
|
|
|
288
296
|
* - Zlib::MemError
|
|
289
297
|
* - Zlib::BufError
|
|
290
298
|
* - Zlib::VersionError
|
|
299
|
+
* - Zlib::InProgressError
|
|
291
300
|
*
|
|
292
301
|
* (if you have GZIP_SUPPORT)
|
|
293
302
|
* - Zlib::GzipReader
|
|
@@ -304,7 +313,7 @@ void Init_zlib(void);
|
|
|
304
313
|
/*--------- Exceptions --------*/
|
|
305
314
|
|
|
306
315
|
static VALUE cZError, cStreamEnd, cNeedDict;
|
|
307
|
-
static VALUE cStreamError, cDataError, cMemError, cBufError, cVersionError;
|
|
316
|
+
static VALUE cStreamError, cDataError, cMemError, cBufError, cVersionError, cInProgressError;
|
|
308
317
|
|
|
309
318
|
static void
|
|
310
319
|
raise_zlib_error(int err, const char *msg)
|
|
@@ -373,26 +382,32 @@ rb_zlib_version(VALUE klass)
|
|
|
373
382
|
return rb_str_new2(zlibVersion());
|
|
374
383
|
}
|
|
375
384
|
|
|
376
|
-
#if SIZEOF_LONG >
|
|
385
|
+
#if SIZEOF_LONG * CHAR_BIT > 32
|
|
386
|
+
# define mask32(x) ((x) & 0xffffffff)
|
|
387
|
+
#else
|
|
388
|
+
# define mask32(x) (x)
|
|
389
|
+
#endif
|
|
390
|
+
|
|
391
|
+
#if SIZEOF_LONG > SIZEOF_INT && !defined(HAVE_TYPE_Z_SIZE_T)
|
|
377
392
|
static uLong
|
|
378
393
|
checksum_long(uLong (*func)(uLong, const Bytef*, uInt), uLong sum, const Bytef *ptr, long len)
|
|
379
394
|
{
|
|
380
395
|
if (len > UINT_MAX) {
|
|
381
396
|
do {
|
|
382
|
-
sum = func(sum, ptr, UINT_MAX);
|
|
397
|
+
sum = func(mask32(sum), ptr, UINT_MAX);
|
|
383
398
|
ptr += UINT_MAX;
|
|
384
399
|
len -= UINT_MAX;
|
|
385
400
|
} while (len >= UINT_MAX);
|
|
386
401
|
}
|
|
387
|
-
if (len > 0) sum = func(sum, ptr, (uInt)len);
|
|
402
|
+
if (len > 0) sum = func(mask32(sum), ptr, (uInt)len);
|
|
388
403
|
return sum;
|
|
389
404
|
}
|
|
390
405
|
#else
|
|
391
|
-
#define checksum_long(func, sum, ptr, len) (func)((sum), (ptr), (len))
|
|
406
|
+
#define checksum_long(func, sum, ptr, len) (func)(mask32(sum), (ptr), (len))
|
|
392
407
|
#endif
|
|
393
408
|
|
|
394
409
|
static VALUE
|
|
395
|
-
do_checksum(int argc, VALUE *argv,
|
|
410
|
+
do_checksum(int argc, VALUE *argv, checksum_func func)
|
|
396
411
|
{
|
|
397
412
|
VALUE str, vsum;
|
|
398
413
|
unsigned long sum;
|
|
@@ -410,7 +425,7 @@ do_checksum(int argc, VALUE *argv, uLong (*func)(uLong, const Bytef*, uInt))
|
|
|
410
425
|
}
|
|
411
426
|
|
|
412
427
|
if (NIL_P(str)) {
|
|
413
|
-
sum = func(sum, Z_NULL, 0);
|
|
428
|
+
sum = func(mask32(sum), Z_NULL, 0);
|
|
414
429
|
}
|
|
415
430
|
else if (rb_obj_is_kind_of(str, rb_cIO)) {
|
|
416
431
|
VALUE buf;
|
|
@@ -460,7 +475,7 @@ rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
|
|
|
460
475
|
*
|
|
461
476
|
* call-seq: Zlib.adler32_combine(adler1, adler2, len2)
|
|
462
477
|
*
|
|
463
|
-
* Combine two Adler-32 check values in to one. +
|
|
478
|
+
* Combine two Adler-32 check values in to one. +adler1+ is the first Adler-32
|
|
464
479
|
* value, +adler2+ is the second Adler-32 value. +len2+ is the length of the
|
|
465
480
|
* string used to generate +adler2+.
|
|
466
481
|
*
|
|
@@ -557,14 +572,15 @@ struct zstream {
|
|
|
557
572
|
} *func;
|
|
558
573
|
};
|
|
559
574
|
|
|
560
|
-
#define ZSTREAM_FLAG_READY
|
|
561
|
-
#define ZSTREAM_FLAG_IN_STREAM
|
|
562
|
-
#define ZSTREAM_FLAG_FINISHED
|
|
563
|
-
#define ZSTREAM_FLAG_CLOSING
|
|
564
|
-
#define ZSTREAM_FLAG_GZFILE
|
|
575
|
+
#define ZSTREAM_FLAG_READY (1 << 0)
|
|
576
|
+
#define ZSTREAM_FLAG_IN_STREAM (1 << 1)
|
|
577
|
+
#define ZSTREAM_FLAG_FINISHED (1 << 2)
|
|
578
|
+
#define ZSTREAM_FLAG_CLOSING (1 << 3)
|
|
579
|
+
#define ZSTREAM_FLAG_GZFILE (1 << 4) /* disallows yield from expand_buffer for
|
|
565
580
|
gzip*/
|
|
566
|
-
#define ZSTREAM_REUSE_BUFFER
|
|
567
|
-
#define
|
|
581
|
+
#define ZSTREAM_REUSE_BUFFER (1 << 5)
|
|
582
|
+
#define ZSTREAM_IN_PROGRESS (1 << 6)
|
|
583
|
+
#define ZSTREAM_FLAG_UNUSED (1 << 7)
|
|
568
584
|
|
|
569
585
|
#define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
|
|
570
586
|
#define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
|
|
@@ -593,7 +609,9 @@ static const struct zstream_funcs inflate_funcs = {
|
|
|
593
609
|
};
|
|
594
610
|
|
|
595
611
|
struct zstream_run_args {
|
|
596
|
-
struct zstream * z;
|
|
612
|
+
struct zstream *const z;
|
|
613
|
+
Bytef *src;
|
|
614
|
+
long len;
|
|
597
615
|
int flush; /* stream flush value for inflate() or deflate() */
|
|
598
616
|
int interrupt; /* stop processing the stream and return to ruby */
|
|
599
617
|
int jump_state; /* for buffer expansion block break or exception */
|
|
@@ -833,9 +851,7 @@ zstream_buffer_ungets(struct zstream *z, const Bytef *b, unsigned long len)
|
|
|
833
851
|
char *bufptr;
|
|
834
852
|
long filled;
|
|
835
853
|
|
|
836
|
-
|
|
837
|
-
zstream_expand_buffer_into(z, len);
|
|
838
|
-
}
|
|
854
|
+
zstream_expand_buffer_into(z, len);
|
|
839
855
|
|
|
840
856
|
RSTRING_GETMEM(z->buf, bufptr, filled);
|
|
841
857
|
memmove(bufptr + len, bufptr, filled);
|
|
@@ -894,7 +910,6 @@ zstream_discard_input(struct zstream *z, long len)
|
|
|
894
910
|
}
|
|
895
911
|
rb_str_resize(z->input, newlen);
|
|
896
912
|
if (newlen == 0) {
|
|
897
|
-
rb_gc_force_recycle(z->input);
|
|
898
913
|
z->input = Qnil;
|
|
899
914
|
}
|
|
900
915
|
else {
|
|
@@ -1059,19 +1074,18 @@ zstream_unblock_func(void *ptr)
|
|
|
1059
1074
|
args->interrupt = 1;
|
|
1060
1075
|
}
|
|
1061
1076
|
|
|
1062
|
-
static
|
|
1063
|
-
|
|
1077
|
+
static VALUE
|
|
1078
|
+
zstream_run_try(VALUE value_arg)
|
|
1064
1079
|
{
|
|
1065
|
-
struct zstream_run_args args;
|
|
1080
|
+
struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
|
|
1081
|
+
struct zstream *z = args->z;
|
|
1082
|
+
Bytef *src = args->src;
|
|
1083
|
+
long len = args->len;
|
|
1084
|
+
int flush = args->flush;
|
|
1085
|
+
|
|
1066
1086
|
int err;
|
|
1067
1087
|
VALUE old_input = Qnil;
|
|
1068
1088
|
|
|
1069
|
-
args.z = z;
|
|
1070
|
-
args.flush = flush;
|
|
1071
|
-
args.interrupt = 0;
|
|
1072
|
-
args.jump_state = 0;
|
|
1073
|
-
args.stream_output = !ZSTREAM_IS_GZFILE(z) && rb_block_given_p();
|
|
1074
|
-
|
|
1075
1089
|
if (NIL_P(z->input) && len == 0) {
|
|
1076
1090
|
z->stream.next_in = (Bytef*)"";
|
|
1077
1091
|
z->stream.avail_in = 0;
|
|
@@ -1093,17 +1107,17 @@ zstream_run0(struct zstream *z, Bytef *src, long len, int flush)
|
|
|
1093
1107
|
|
|
1094
1108
|
loop:
|
|
1095
1109
|
#ifndef RB_NOGVL_UBF_ASYNC_SAFE
|
|
1096
|
-
err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)
|
|
1097
|
-
zstream_unblock_func, (void *)
|
|
1110
|
+
err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)args,
|
|
1111
|
+
zstream_unblock_func, (void *)args);
|
|
1098
1112
|
#else
|
|
1099
|
-
err = (int)(VALUE)rb_nogvl(zstream_run_func, (void *)
|
|
1100
|
-
zstream_unblock_func, (void *)
|
|
1113
|
+
err = (int)(VALUE)rb_nogvl(zstream_run_func, (void *)args,
|
|
1114
|
+
zstream_unblock_func, (void *)args,
|
|
1101
1115
|
RB_NOGVL_UBF_ASYNC_SAFE);
|
|
1102
1116
|
#endif
|
|
1103
1117
|
|
|
1104
1118
|
/* retry if no exception is thrown */
|
|
1105
|
-
if (err == Z_OK && args
|
|
1106
|
-
args
|
|
1119
|
+
if (err == Z_OK && args->interrupt) {
|
|
1120
|
+
args->interrupt = 0;
|
|
1107
1121
|
goto loop;
|
|
1108
1122
|
}
|
|
1109
1123
|
|
|
@@ -1137,37 +1151,54 @@ loop:
|
|
|
1137
1151
|
}
|
|
1138
1152
|
if (!NIL_P(old_input)) {
|
|
1139
1153
|
rb_str_resize(old_input, 0);
|
|
1140
|
-
rb_gc_force_recycle(old_input);
|
|
1141
1154
|
}
|
|
1142
1155
|
|
|
1143
|
-
if (args
|
|
1144
|
-
rb_jump_tag(args
|
|
1156
|
+
if (args->jump_state)
|
|
1157
|
+
rb_jump_tag(args->jump_state);
|
|
1158
|
+
|
|
1159
|
+
return Qnil;
|
|
1145
1160
|
}
|
|
1146
1161
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1162
|
+
static VALUE
|
|
1163
|
+
zstream_run_ensure(VALUE value_arg)
|
|
1164
|
+
{
|
|
1165
|
+
struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
|
|
1166
|
+
|
|
1167
|
+
/* Remove ZSTREAM_IN_PROGRESS flag to signal that this zstream is not in use. */
|
|
1168
|
+
args->z->flags &= ~ZSTREAM_IN_PROGRESS;
|
|
1169
|
+
|
|
1170
|
+
return Qnil;
|
|
1171
|
+
}
|
|
1153
1172
|
|
|
1154
1173
|
static VALUE
|
|
1155
1174
|
zstream_run_synchronized(VALUE value_arg)
|
|
1156
1175
|
{
|
|
1157
|
-
struct
|
|
1158
|
-
|
|
1176
|
+
struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
|
|
1177
|
+
|
|
1178
|
+
/* Cannot start zstream while it is in progress. */
|
|
1179
|
+
if (args->z->flags & ZSTREAM_IN_PROGRESS) {
|
|
1180
|
+
rb_raise(cInProgressError, "zlib stream is in progress");
|
|
1181
|
+
}
|
|
1182
|
+
args->z->flags |= ZSTREAM_IN_PROGRESS;
|
|
1183
|
+
|
|
1184
|
+
rb_ensure(zstream_run_try, value_arg, zstream_run_ensure, value_arg);
|
|
1185
|
+
|
|
1159
1186
|
return Qnil;
|
|
1160
1187
|
}
|
|
1161
1188
|
|
|
1162
1189
|
static void
|
|
1163
1190
|
zstream_run(struct zstream *z, Bytef *src, long len, int flush)
|
|
1164
1191
|
{
|
|
1165
|
-
struct
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1192
|
+
struct zstream_run_args args = {
|
|
1193
|
+
.z = z,
|
|
1194
|
+
.src = src,
|
|
1195
|
+
.len = len,
|
|
1196
|
+
.flush = flush,
|
|
1197
|
+
.interrupt = 0,
|
|
1198
|
+
.jump_state = 0,
|
|
1199
|
+
.stream_output = !ZSTREAM_IS_GZFILE(z) && rb_block_given_p(),
|
|
1200
|
+
};
|
|
1201
|
+
rb_mutex_synchronize(z->mutex, zstream_run_synchronized, (VALUE)&args);
|
|
1171
1202
|
}
|
|
1172
1203
|
|
|
1173
1204
|
static VALUE
|
|
@@ -2906,8 +2937,6 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
|
|
|
2906
2937
|
if (!NIL_P(outbuf)) {
|
|
2907
2938
|
rb_str_resize(outbuf, RSTRING_LEN(dst));
|
|
2908
2939
|
memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
|
|
2909
|
-
rb_str_resize(dst, 0);
|
|
2910
|
-
rb_gc_force_recycle(dst);
|
|
2911
2940
|
dst = outbuf;
|
|
2912
2941
|
}
|
|
2913
2942
|
return dst;
|
|
@@ -4619,6 +4648,7 @@ Init_zlib(void)
|
|
|
4619
4648
|
cMemError = rb_define_class_under(mZlib, "MemError", cZError);
|
|
4620
4649
|
cBufError = rb_define_class_under(mZlib, "BufError", cZError);
|
|
4621
4650
|
cVersionError = rb_define_class_under(mZlib, "VersionError", cZError);
|
|
4651
|
+
cInProgressError = rb_define_class_under(mZlib, "InProgressError", cZError);
|
|
4622
4652
|
|
|
4623
4653
|
rb_define_module_function(mZlib, "zlib_version", rb_zlib_version, 0);
|
|
4624
4654
|
rb_define_module_function(mZlib, "adler32", rb_zlib_adler32, -1);
|
|
@@ -4926,6 +4956,7 @@ Init_zlib(void)
|
|
|
4926
4956
|
* - Zlib::MemError
|
|
4927
4957
|
* - Zlib::BufError
|
|
4928
4958
|
* - Zlib::VersionError
|
|
4959
|
+
* - Zlib::InProgressError
|
|
4929
4960
|
*
|
|
4930
4961
|
*/
|
|
4931
4962
|
|
|
@@ -5000,6 +5031,20 @@ Init_zlib(void)
|
|
|
5000
5031
|
*
|
|
5001
5032
|
*/
|
|
5002
5033
|
|
|
5034
|
+
/*
|
|
5035
|
+
* Document-class: Zlib::InProgressError
|
|
5036
|
+
*
|
|
5037
|
+
* Subclass of Zlib::Error. This error is raised when the zlib
|
|
5038
|
+
* stream is currently in progress.
|
|
5039
|
+
*
|
|
5040
|
+
* For example:
|
|
5041
|
+
*
|
|
5042
|
+
* inflater = Zlib::Inflate.new
|
|
5043
|
+
* inflater.inflate(compressed) do
|
|
5044
|
+
* inflater.inflate(compressed) # Raises Zlib::InProgressError
|
|
5045
|
+
* end
|
|
5046
|
+
*/
|
|
5047
|
+
|
|
5003
5048
|
/*
|
|
5004
5049
|
* Document-class: Zlib::GzipFile::Error
|
|
5005
5050
|
*
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zlib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yukihiro Matsumoto
|
|
8
8
|
- UENO Katsuhiro
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: exe
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies: []
|
|
14
13
|
description: Ruby interface for the zlib compression/decompression library
|
|
15
14
|
email:
|
|
@@ -30,7 +29,6 @@ licenses:
|
|
|
30
29
|
- Ruby
|
|
31
30
|
- BSD-2-Clause
|
|
32
31
|
metadata: {}
|
|
33
|
-
post_install_message:
|
|
34
32
|
rdoc_options: []
|
|
35
33
|
require_paths:
|
|
36
34
|
- lib
|
|
@@ -45,8 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
45
43
|
- !ruby/object:Gem::Version
|
|
46
44
|
version: '0'
|
|
47
45
|
requirements: []
|
|
48
|
-
rubygems_version:
|
|
49
|
-
signing_key:
|
|
46
|
+
rubygems_version: 4.0.3
|
|
50
47
|
specification_version: 4
|
|
51
48
|
summary: Ruby interface for the zlib compression/decompression library
|
|
52
49
|
test_files: []
|