zlib 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -2
- data/README.md +1 -1
- data/ext/zlib/zlib.c +156 -125
- data/zlib.gemspec +12 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 19ba8efdb32fca21018696b5c7c2daf46ac6be20d4eeac8c084bdd416f36d97a
|
4
|
+
data.tar.gz: c8aa54b4af9ced56c043853a85c948f736030a6d1cc1b2bd3693164d0a9b944c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fad984e401f53eba898295296b1a8dfaf7f5035c60c2e720501f03871ba3ba617167d093e6d17c4075bca2da2e838445367d0271fca7bff549ed3a8e0cc33a6b
|
7
|
+
data.tar.gz: 2b59bdabdba6fa6a09c31dc1ba1fe01110ef4ed775c41e8f386091ab547a874f5398603437817a66641ce99f2d083cbdf515a339765da7c615d648080ba1abdd
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/ext/zlib/zlib.c
CHANGED
@@ -25,7 +25,11 @@
|
|
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 "1.1.0"
|
29
|
+
|
30
|
+
#ifndef RB_PASS_CALLED_KEYWORDS
|
31
|
+
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
|
32
|
+
#endif
|
29
33
|
|
30
34
|
#ifndef GZIP_SUPPORT
|
31
35
|
#define GZIP_SUPPORT 1
|
@@ -85,6 +89,7 @@ static void zstream_passthrough_input(struct zstream*);
|
|
85
89
|
static VALUE zstream_detach_input(struct zstream*);
|
86
90
|
static void zstream_reset(struct zstream*);
|
87
91
|
static VALUE zstream_end(struct zstream*);
|
92
|
+
static VALUE zstream_ensure_end(VALUE v);
|
88
93
|
static void zstream_run(struct zstream*, Bytef*, long, int);
|
89
94
|
static VALUE zstream_sync(struct zstream*, Bytef*, long);
|
90
95
|
static void zstream_mark(void*);
|
@@ -140,19 +145,19 @@ static void gzfile_reset(struct gzfile*);
|
|
140
145
|
static void gzfile_close(struct gzfile*, int);
|
141
146
|
static void gzfile_write_raw(struct gzfile*);
|
142
147
|
static VALUE gzfile_read_raw_partial(VALUE);
|
143
|
-
static VALUE gzfile_read_raw_rescue(VALUE);
|
144
|
-
static VALUE gzfile_read_raw(struct gzfile
|
145
|
-
static int gzfile_read_raw_ensure(struct gzfile*, long);
|
148
|
+
static VALUE gzfile_read_raw_rescue(VALUE,VALUE);
|
149
|
+
static VALUE gzfile_read_raw(struct gzfile*, VALUE outbuf);
|
150
|
+
static int gzfile_read_raw_ensure(struct gzfile*, long, VALUE outbuf);
|
146
151
|
static char *gzfile_read_raw_until_zero(struct gzfile*, long);
|
147
152
|
static unsigned int gzfile_get16(const unsigned char*);
|
148
153
|
static unsigned long gzfile_get32(const unsigned char*);
|
149
154
|
static void gzfile_set32(unsigned long n, unsigned char*);
|
150
155
|
static void gzfile_make_header(struct gzfile*);
|
151
156
|
static void gzfile_make_footer(struct gzfile*);
|
152
|
-
static void gzfile_read_header(struct gzfile
|
153
|
-
static void gzfile_check_footer(struct gzfile
|
157
|
+
static void gzfile_read_header(struct gzfile*, VALUE outbuf);
|
158
|
+
static void gzfile_check_footer(struct gzfile*, VALUE outbuf);
|
154
159
|
static void gzfile_write(struct gzfile*, Bytef*, long);
|
155
|
-
static long gzfile_read_more(struct gzfile
|
160
|
+
static long gzfile_read_more(struct gzfile*, VALUE outbuf);
|
156
161
|
static void gzfile_calc_crc(struct gzfile*, VALUE);
|
157
162
|
static VALUE gzfile_read(struct gzfile*, long);
|
158
163
|
static VALUE gzfile_read_all(struct gzfile*);
|
@@ -360,11 +365,7 @@ finalizer_warn(const char *msg)
|
|
360
365
|
static VALUE
|
361
366
|
rb_zlib_version(VALUE klass)
|
362
367
|
{
|
363
|
-
|
364
|
-
|
365
|
-
str = rb_str_new2(zlibVersion());
|
366
|
-
OBJ_TAINT(str); /* for safe */
|
367
|
-
return str;
|
368
|
+
return rb_str_new2(zlibVersion());
|
368
369
|
}
|
369
370
|
|
370
371
|
#if SIZEOF_LONG > SIZEOF_INT
|
@@ -627,10 +628,8 @@ zstream_expand_buffer(struct zstream *z)
|
|
627
628
|
long buf_filled = ZSTREAM_BUF_FILLED(z);
|
628
629
|
if (buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
|
629
630
|
int state = 0;
|
630
|
-
VALUE self = (VALUE)z->stream.opaque;
|
631
631
|
|
632
632
|
rb_obj_reveal(z->buf, rb_cString);
|
633
|
-
OBJ_INFECT(z->buf, self);
|
634
633
|
|
635
634
|
rb_protect(rb_yield, z->buf, &state);
|
636
635
|
|
@@ -738,7 +737,7 @@ zstream_append_buffer(struct zstream *z, const Bytef *src, long len)
|
|
738
737
|
static VALUE
|
739
738
|
zstream_detach_buffer(struct zstream *z)
|
740
739
|
{
|
741
|
-
VALUE dst
|
740
|
+
VALUE dst;
|
742
741
|
|
743
742
|
if (!ZSTREAM_IS_FINISHED(z) && !ZSTREAM_IS_GZFILE(z) &&
|
744
743
|
rb_block_given_p()) {
|
@@ -755,8 +754,6 @@ zstream_detach_buffer(struct zstream *z)
|
|
755
754
|
rb_obj_reveal(dst, rb_cString);
|
756
755
|
}
|
757
756
|
|
758
|
-
OBJ_INFECT(dst, self);
|
759
|
-
|
760
757
|
z->buf = Qnil;
|
761
758
|
z->stream.next_out = 0;
|
762
759
|
z->stream.avail_out = 0;
|
@@ -845,19 +842,50 @@ zstream_append_input(struct zstream *z, const Bytef *src, long len)
|
|
845
842
|
static void
|
846
843
|
zstream_discard_input(struct zstream *z, long len)
|
847
844
|
{
|
848
|
-
if (NIL_P(z->input)
|
849
|
-
z->input = Qnil;
|
845
|
+
if (NIL_P(z->input)) {
|
850
846
|
}
|
851
|
-
else {
|
852
|
-
|
853
|
-
|
847
|
+
else if (RBASIC_CLASS(z->input) == 0) {
|
848
|
+
/* hidden, we created z->input and have complete control */
|
849
|
+
char *ptr;
|
850
|
+
long oldlen, newlen;
|
851
|
+
|
852
|
+
RSTRING_GETMEM(z->input, ptr, oldlen);
|
853
|
+
newlen = oldlen - len;
|
854
|
+
if (newlen > 0) {
|
855
|
+
memmove(ptr, ptr + len, newlen);
|
856
|
+
}
|
857
|
+
if (newlen < 0) {
|
858
|
+
newlen = 0;
|
859
|
+
}
|
860
|
+
rb_str_resize(z->input, newlen);
|
861
|
+
if (newlen == 0) {
|
862
|
+
rb_gc_force_recycle(z->input);
|
863
|
+
z->input = Qnil;
|
864
|
+
}
|
865
|
+
else {
|
866
|
+
rb_str_set_len(z->input, newlen);
|
867
|
+
}
|
868
|
+
}
|
869
|
+
else { /* do not mangle user-provided data */
|
870
|
+
if (RSTRING_LEN(z->input) <= len) {
|
871
|
+
z->input = Qnil;
|
872
|
+
}
|
873
|
+
else {
|
874
|
+
z->input = rb_str_substr(z->input, len,
|
875
|
+
RSTRING_LEN(z->input) - len);
|
876
|
+
}
|
854
877
|
}
|
855
878
|
}
|
856
879
|
|
857
880
|
static void
|
858
881
|
zstream_reset_input(struct zstream *z)
|
859
882
|
{
|
860
|
-
z->input
|
883
|
+
if (!NIL_P(z->input) && RBASIC_CLASS(z->input) == 0) {
|
884
|
+
rb_str_resize(z->input, 0);
|
885
|
+
}
|
886
|
+
else {
|
887
|
+
z->input = Qnil;
|
888
|
+
}
|
861
889
|
}
|
862
890
|
|
863
891
|
static void
|
@@ -882,7 +910,6 @@ zstream_detach_input(struct zstream *z)
|
|
882
910
|
rb_obj_reveal(dst, rb_cString);
|
883
911
|
}
|
884
912
|
z->input = Qnil;
|
885
|
-
rb_obj_reveal(dst, rb_cString);
|
886
913
|
return dst;
|
887
914
|
}
|
888
915
|
|
@@ -925,6 +952,12 @@ zstream_end(struct zstream *z)
|
|
925
952
|
return Qnil;
|
926
953
|
}
|
927
954
|
|
955
|
+
static VALUE
|
956
|
+
zstream_ensure_end(VALUE v)
|
957
|
+
{
|
958
|
+
return zstream_end((struct zstream *)v);
|
959
|
+
}
|
960
|
+
|
928
961
|
static void *
|
929
962
|
zstream_run_func(void *ptr)
|
930
963
|
{
|
@@ -981,6 +1014,7 @@ zstream_run_func(void *ptr)
|
|
981
1014
|
|
982
1015
|
/*
|
983
1016
|
* There is no safe way to interrupt z->run->func().
|
1017
|
+
* async-signal-safe
|
984
1018
|
*/
|
985
1019
|
static void
|
986
1020
|
zstream_unblock_func(void *ptr)
|
@@ -995,7 +1029,7 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush)
|
|
995
1029
|
{
|
996
1030
|
struct zstream_run_args args;
|
997
1031
|
int err;
|
998
|
-
VALUE
|
1032
|
+
VALUE old_input = Qnil;
|
999
1033
|
|
1000
1034
|
args.z = z;
|
1001
1035
|
args.flush = flush;
|
@@ -1009,12 +1043,13 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush)
|
|
1009
1043
|
}
|
1010
1044
|
else {
|
1011
1045
|
zstream_append_input(z, src, len);
|
1012
|
-
z->stream.next_in = (Bytef*)RSTRING_PTR(z->input);
|
1013
|
-
z->stream.avail_in = MAX_UINT(RSTRING_LEN(z->input));
|
1014
1046
|
/* keep reference to `z->input' so as not to be garbage collected
|
1015
1047
|
after zstream_reset_input() and prevent `z->stream.next_in'
|
1016
1048
|
from dangling. */
|
1017
|
-
|
1049
|
+
old_input = zstream_detach_input(z);
|
1050
|
+
rb_obj_hide(old_input); /* for GVL release and later recycle */
|
1051
|
+
z->stream.next_in = (Bytef*)RSTRING_PTR(old_input);
|
1052
|
+
z->stream.avail_in = MAX_UINT(RSTRING_LEN(old_input));
|
1018
1053
|
}
|
1019
1054
|
|
1020
1055
|
if (z->stream.avail_out == 0) {
|
@@ -1022,8 +1057,14 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush)
|
|
1022
1057
|
}
|
1023
1058
|
|
1024
1059
|
loop:
|
1060
|
+
#ifndef RB_NOGVL_UBF_ASYNC_SAFE
|
1025
1061
|
err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)&args,
|
1026
1062
|
zstream_unblock_func, (void *)&args);
|
1063
|
+
#else
|
1064
|
+
err = (int)(VALUE)rb_nogvl(zstream_run_func, (void *)&args,
|
1065
|
+
zstream_unblock_func, (void *)&args,
|
1066
|
+
RB_NOGVL_UBF_ASYNC_SAFE);
|
1067
|
+
#endif
|
1027
1068
|
|
1028
1069
|
if (flush != Z_FINISH && err == Z_BUF_ERROR
|
1029
1070
|
&& z->stream.avail_out > 0) {
|
@@ -1052,7 +1093,10 @@ loop:
|
|
1052
1093
|
|
1053
1094
|
if (z->stream.avail_in > 0) {
|
1054
1095
|
zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
|
1055
|
-
|
1096
|
+
}
|
1097
|
+
if (!NIL_P(old_input)) {
|
1098
|
+
rb_str_resize(old_input, 0);
|
1099
|
+
rb_gc_force_recycle(old_input);
|
1056
1100
|
}
|
1057
1101
|
|
1058
1102
|
if (args.jump_state)
|
@@ -1285,7 +1329,6 @@ rb_zstream_flush_next_in(VALUE obj)
|
|
1285
1329
|
|
1286
1330
|
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
|
1287
1331
|
dst = zstream_detach_input(z);
|
1288
|
-
OBJ_INFECT(dst, obj);
|
1289
1332
|
return dst;
|
1290
1333
|
}
|
1291
1334
|
|
@@ -1604,9 +1647,8 @@ rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
|
|
1604
1647
|
|
1605
1648
|
args[0] = (VALUE)&z;
|
1606
1649
|
args[1] = src;
|
1607
|
-
dst = rb_ensure(deflate_run, (VALUE)args,
|
1650
|
+
dst = rb_ensure(deflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z);
|
1608
1651
|
|
1609
|
-
OBJ_INFECT(dst, src);
|
1610
1652
|
return dst;
|
1611
1653
|
}
|
1612
1654
|
|
@@ -1656,7 +1698,6 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
|
|
1656
1698
|
VALUE src, flush;
|
1657
1699
|
|
1658
1700
|
rb_scan_args(argc, argv, "11", &src, &flush);
|
1659
|
-
OBJ_INFECT(obj, src);
|
1660
1701
|
do_deflate(z, src, ARG_FLUSH(flush));
|
1661
1702
|
|
1662
1703
|
return zstream_detach_buffer(z);
|
@@ -1674,7 +1715,6 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
|
|
1674
1715
|
static VALUE
|
1675
1716
|
rb_deflate_addstr(VALUE obj, VALUE src)
|
1676
1717
|
{
|
1677
|
-
OBJ_INFECT(obj, src);
|
1678
1718
|
do_deflate(get_zstream(obj), src, Z_NO_FLUSH);
|
1679
1719
|
return obj;
|
1680
1720
|
}
|
@@ -1774,7 +1814,6 @@ rb_deflate_set_dictionary(VALUE obj, VALUE dic)
|
|
1774
1814
|
VALUE src = dic;
|
1775
1815
|
int err;
|
1776
1816
|
|
1777
|
-
OBJ_INFECT(obj, dic);
|
1778
1817
|
StringValue(src);
|
1779
1818
|
err = deflateSetDictionary(&z->stream,
|
1780
1819
|
(Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src));
|
@@ -1919,9 +1958,8 @@ rb_inflate_s_inflate(VALUE obj, VALUE src)
|
|
1919
1958
|
|
1920
1959
|
args[0] = (VALUE)&z;
|
1921
1960
|
args[1] = src;
|
1922
|
-
dst = rb_ensure(inflate_run, (VALUE)args,
|
1961
|
+
dst = rb_ensure(inflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z);
|
1923
1962
|
|
1924
|
-
OBJ_INFECT(dst, src);
|
1925
1963
|
return dst;
|
1926
1964
|
}
|
1927
1965
|
|
@@ -2001,8 +2039,6 @@ rb_inflate_inflate(VALUE obj, VALUE src)
|
|
2001
2039
|
struct zstream *z = get_zstream(obj);
|
2002
2040
|
VALUE dst;
|
2003
2041
|
|
2004
|
-
OBJ_INFECT(obj, src);
|
2005
|
-
|
2006
2042
|
if (ZSTREAM_IS_FINISHED(z)) {
|
2007
2043
|
if (NIL_P(src)) {
|
2008
2044
|
dst = zstream_detach_buffer(z);
|
@@ -2011,7 +2047,6 @@ rb_inflate_inflate(VALUE obj, VALUE src)
|
|
2011
2047
|
StringValue(src);
|
2012
2048
|
zstream_append_buffer2(z, src);
|
2013
2049
|
dst = rb_str_new(0, 0);
|
2014
|
-
OBJ_INFECT(dst, obj);
|
2015
2050
|
}
|
2016
2051
|
}
|
2017
2052
|
else {
|
@@ -2037,8 +2072,6 @@ rb_inflate_addstr(VALUE obj, VALUE src)
|
|
2037
2072
|
{
|
2038
2073
|
struct zstream *z = get_zstream(obj);
|
2039
2074
|
|
2040
|
-
OBJ_INFECT(obj, src);
|
2041
|
-
|
2042
2075
|
if (ZSTREAM_IS_FINISHED(z)) {
|
2043
2076
|
if (!NIL_P(src)) {
|
2044
2077
|
StringValue(src);
|
@@ -2068,7 +2101,6 @@ rb_inflate_sync(VALUE obj, VALUE src)
|
|
2068
2101
|
{
|
2069
2102
|
struct zstream *z = get_zstream(obj);
|
2070
2103
|
|
2071
|
-
OBJ_INFECT(obj, src);
|
2072
2104
|
StringValue(src);
|
2073
2105
|
return zstream_sync(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src));
|
2074
2106
|
}
|
@@ -2110,7 +2142,6 @@ rb_inflate_set_dictionary(VALUE obj, VALUE dic)
|
|
2110
2142
|
VALUE src = dic;
|
2111
2143
|
int err;
|
2112
2144
|
|
2113
|
-
OBJ_INFECT(obj, dic);
|
2114
2145
|
StringValue(src);
|
2115
2146
|
err = inflateSetDictionary(&z->stream,
|
2116
2147
|
(Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src));
|
@@ -2191,7 +2222,6 @@ struct gzfile {
|
|
2191
2222
|
rb_encoding *enc2;
|
2192
2223
|
rb_econv_t *ec;
|
2193
2224
|
VALUE ecopts;
|
2194
|
-
char *cbuf;
|
2195
2225
|
VALUE path;
|
2196
2226
|
};
|
2197
2227
|
#define GZFILE_CBUF_CAPA 10
|
@@ -2199,12 +2229,23 @@ struct gzfile {
|
|
2199
2229
|
#define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED
|
2200
2230
|
#define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)
|
2201
2231
|
#define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
|
2232
|
+
#define GZFILE_FLAG_MTIME_IS_SET (ZSTREAM_FLAG_UNUSED << 3)
|
2202
2233
|
|
2203
2234
|
#define GZFILE_IS_FINISHED(gz) \
|
2204
2235
|
(ZSTREAM_IS_FINISHED(&(gz)->z) && ZSTREAM_BUF_FILLED(&(gz)->z) == 0)
|
2205
2236
|
|
2206
2237
|
#define GZFILE_READ_SIZE 2048
|
2207
2238
|
|
2239
|
+
struct read_raw_arg {
|
2240
|
+
VALUE io;
|
2241
|
+
union {
|
2242
|
+
const VALUE argv[2]; /* for rb_funcallv */
|
2243
|
+
struct {
|
2244
|
+
VALUE len;
|
2245
|
+
VALUE buf;
|
2246
|
+
} in;
|
2247
|
+
} as;
|
2248
|
+
};
|
2208
2249
|
|
2209
2250
|
static void
|
2210
2251
|
gzfile_mark(void *p)
|
@@ -2231,22 +2272,13 @@ gzfile_free(void *p)
|
|
2231
2272
|
}
|
2232
2273
|
zstream_finalize(z);
|
2233
2274
|
}
|
2234
|
-
if (gz->cbuf) {
|
2235
|
-
xfree(gz->cbuf);
|
2236
|
-
}
|
2237
2275
|
xfree(gz);
|
2238
2276
|
}
|
2239
2277
|
|
2240
2278
|
static size_t
|
2241
2279
|
gzfile_memsize(const void *p)
|
2242
2280
|
{
|
2243
|
-
|
2244
|
-
size_t size = sizeof(struct gzfile);
|
2245
|
-
|
2246
|
-
if (gz->cbuf)
|
2247
|
-
size += GZFILE_CBUF_CAPA;
|
2248
|
-
|
2249
|
-
return size;
|
2281
|
+
return sizeof(struct gzfile);
|
2250
2282
|
}
|
2251
2283
|
|
2252
2284
|
static const rb_data_type_t gzfile_data_type = {
|
@@ -2275,7 +2307,6 @@ gzfile_init(struct gzfile *gz, const struct zstream_funcs *funcs, void (*endfunc
|
|
2275
2307
|
gz->ec = NULL;
|
2276
2308
|
gz->ecflags = 0;
|
2277
2309
|
gz->ecopts = Qnil;
|
2278
|
-
gz->cbuf = 0;
|
2279
2310
|
gz->path = Qnil;
|
2280
2311
|
}
|
2281
2312
|
|
@@ -2329,7 +2360,6 @@ gzfile_write_raw(struct gzfile *gz)
|
|
2329
2360
|
|
2330
2361
|
if (ZSTREAM_BUF_FILLED(&gz->z) > 0) {
|
2331
2362
|
str = zstream_detach_buffer(&gz->z);
|
2332
|
-
OBJ_TAINT(str); /* for safe */
|
2333
2363
|
rb_funcall(gz->io, id_write, 1, str);
|
2334
2364
|
if ((gz->z.flags & GZFILE_FLAG_SYNC)
|
2335
2365
|
&& rb_respond_to(gz->io, id_flush))
|
@@ -2340,21 +2370,23 @@ gzfile_write_raw(struct gzfile *gz)
|
|
2340
2370
|
static VALUE
|
2341
2371
|
gzfile_read_raw_partial(VALUE arg)
|
2342
2372
|
{
|
2343
|
-
struct
|
2373
|
+
struct read_raw_arg *ra = (struct read_raw_arg *)arg;
|
2344
2374
|
VALUE str;
|
2375
|
+
int argc = NIL_P(ra->as.argv[1]) ? 1 : 2;
|
2345
2376
|
|
2346
|
-
str =
|
2377
|
+
str = rb_funcallv(ra->io, id_readpartial, argc, ra->as.argv);
|
2347
2378
|
Check_Type(str, T_STRING);
|
2348
2379
|
return str;
|
2349
2380
|
}
|
2350
2381
|
|
2351
2382
|
static VALUE
|
2352
|
-
gzfile_read_raw_rescue(VALUE arg)
|
2383
|
+
gzfile_read_raw_rescue(VALUE arg, VALUE _)
|
2353
2384
|
{
|
2354
|
-
struct
|
2385
|
+
struct read_raw_arg *ra = (struct read_raw_arg *)arg;
|
2355
2386
|
VALUE str = Qnil;
|
2356
2387
|
if (rb_obj_is_kind_of(rb_errinfo(), rb_eNoMethodError)) {
|
2357
|
-
|
2388
|
+
int argc = NIL_P(ra->as.argv[1]) ? 1 : 2;
|
2389
|
+
str = rb_funcallv(ra->io, id_read, argc, ra->as.argv);
|
2358
2390
|
if (!NIL_P(str)) {
|
2359
2391
|
Check_Type(str, T_STRING);
|
2360
2392
|
}
|
@@ -2363,15 +2395,21 @@ gzfile_read_raw_rescue(VALUE arg)
|
|
2363
2395
|
}
|
2364
2396
|
|
2365
2397
|
static VALUE
|
2366
|
-
gzfile_read_raw(struct gzfile *gz)
|
2398
|
+
gzfile_read_raw(struct gzfile *gz, VALUE outbuf)
|
2367
2399
|
{
|
2368
|
-
|
2369
|
-
|
2400
|
+
struct read_raw_arg ra;
|
2401
|
+
|
2402
|
+
ra.io = gz->io;
|
2403
|
+
ra.as.in.len = INT2FIX(GZFILE_READ_SIZE);
|
2404
|
+
ra.as.in.buf = outbuf;
|
2405
|
+
|
2406
|
+
return rb_rescue2(gzfile_read_raw_partial, (VALUE)&ra,
|
2407
|
+
gzfile_read_raw_rescue, (VALUE)&ra,
|
2370
2408
|
rb_eEOFError, rb_eNoMethodError, (VALUE)0);
|
2371
2409
|
}
|
2372
2410
|
|
2373
2411
|
static int
|
2374
|
-
gzfile_read_raw_ensure(struct gzfile *gz, long size)
|
2412
|
+
gzfile_read_raw_ensure(struct gzfile *gz, long size, VALUE outbuf)
|
2375
2413
|
{
|
2376
2414
|
VALUE str;
|
2377
2415
|
|
@@ -2380,7 +2418,7 @@ gzfile_read_raw_ensure(struct gzfile *gz, long size)
|
|
2380
2418
|
rb_raise(cGzError, "unexpected end of string");
|
2381
2419
|
}
|
2382
2420
|
while (NIL_P(gz->z.input) || RSTRING_LEN(gz->z.input) < size) {
|
2383
|
-
str = gzfile_read_raw(gz);
|
2421
|
+
str = gzfile_read_raw(gz, outbuf);
|
2384
2422
|
if (NIL_P(str)) return 0;
|
2385
2423
|
zstream_append_input2(&gz->z, str);
|
2386
2424
|
}
|
@@ -2397,7 +2435,7 @@ gzfile_read_raw_until_zero(struct gzfile *gz, long offset)
|
|
2397
2435
|
p = memchr(RSTRING_PTR(gz->z.input) + offset, '\0',
|
2398
2436
|
RSTRING_LEN(gz->z.input) - offset);
|
2399
2437
|
if (p) break;
|
2400
|
-
str = gzfile_read_raw(gz);
|
2438
|
+
str = gzfile_read_raw(gz, Qnil);
|
2401
2439
|
if (NIL_P(str)) {
|
2402
2440
|
rb_raise(cGzError, "unexpected end of file");
|
2403
2441
|
}
|
@@ -2478,7 +2516,7 @@ gzfile_make_header(struct gzfile *gz)
|
|
2478
2516
|
if (!NIL_P(gz->comment)) {
|
2479
2517
|
flags |= GZ_FLAG_COMMENT;
|
2480
2518
|
}
|
2481
|
-
if (gz->
|
2519
|
+
if (!(gz->z.flags & GZFILE_FLAG_MTIME_IS_SET)) {
|
2482
2520
|
gz->mtime = time(0);
|
2483
2521
|
}
|
2484
2522
|
|
@@ -2522,13 +2560,14 @@ gzfile_make_footer(struct gzfile *gz)
|
|
2522
2560
|
}
|
2523
2561
|
|
2524
2562
|
static void
|
2525
|
-
gzfile_read_header(struct gzfile *gz)
|
2563
|
+
gzfile_read_header(struct gzfile *gz, VALUE outbuf)
|
2526
2564
|
{
|
2527
2565
|
const unsigned char *head;
|
2528
2566
|
long len;
|
2529
2567
|
char flags, *p;
|
2530
2568
|
|
2531
|
-
|
2569
|
+
/* 10 is the size of gzip header */
|
2570
|
+
if (!gzfile_read_raw_ensure(gz, 10, outbuf)) {
|
2532
2571
|
gzfile_raise(gz, cGzError, "not in gzip format");
|
2533
2572
|
}
|
2534
2573
|
|
@@ -2567,33 +2606,31 @@ gzfile_read_header(struct gzfile *gz)
|
|
2567
2606
|
zstream_discard_input(&gz->z, 10);
|
2568
2607
|
|
2569
2608
|
if (flags & GZ_FLAG_EXTRA) {
|
2570
|
-
if (!gzfile_read_raw_ensure(gz, 2)) {
|
2609
|
+
if (!gzfile_read_raw_ensure(gz, 2, outbuf)) {
|
2571
2610
|
rb_raise(cGzError, "unexpected end of file");
|
2572
2611
|
}
|
2573
2612
|
len = gzfile_get16((Bytef*)RSTRING_PTR(gz->z.input));
|
2574
|
-
if (!gzfile_read_raw_ensure(gz, 2 + len)) {
|
2613
|
+
if (!gzfile_read_raw_ensure(gz, 2 + len, outbuf)) {
|
2575
2614
|
rb_raise(cGzError, "unexpected end of file");
|
2576
2615
|
}
|
2577
2616
|
zstream_discard_input(&gz->z, 2 + len);
|
2578
2617
|
}
|
2579
2618
|
if (flags & GZ_FLAG_ORIG_NAME) {
|
2580
|
-
if (!gzfile_read_raw_ensure(gz, 1)) {
|
2619
|
+
if (!gzfile_read_raw_ensure(gz, 1, outbuf)) {
|
2581
2620
|
rb_raise(cGzError, "unexpected end of file");
|
2582
2621
|
}
|
2583
2622
|
p = gzfile_read_raw_until_zero(gz, 0);
|
2584
2623
|
len = p - RSTRING_PTR(gz->z.input);
|
2585
2624
|
gz->orig_name = rb_str_new(RSTRING_PTR(gz->z.input), len);
|
2586
|
-
OBJ_TAINT(gz->orig_name); /* for safe */
|
2587
2625
|
zstream_discard_input(&gz->z, len + 1);
|
2588
2626
|
}
|
2589
2627
|
if (flags & GZ_FLAG_COMMENT) {
|
2590
|
-
if (!gzfile_read_raw_ensure(gz, 1)) {
|
2628
|
+
if (!gzfile_read_raw_ensure(gz, 1, outbuf)) {
|
2591
2629
|
rb_raise(cGzError, "unexpected end of file");
|
2592
2630
|
}
|
2593
2631
|
p = gzfile_read_raw_until_zero(gz, 0);
|
2594
2632
|
len = p - RSTRING_PTR(gz->z.input);
|
2595
2633
|
gz->comment = rb_str_new(RSTRING_PTR(gz->z.input), len);
|
2596
|
-
OBJ_TAINT(gz->comment); /* for safe */
|
2597
2634
|
zstream_discard_input(&gz->z, len + 1);
|
2598
2635
|
}
|
2599
2636
|
|
@@ -2603,13 +2640,14 @@ gzfile_read_header(struct gzfile *gz)
|
|
2603
2640
|
}
|
2604
2641
|
|
2605
2642
|
static void
|
2606
|
-
gzfile_check_footer(struct gzfile *gz)
|
2643
|
+
gzfile_check_footer(struct gzfile *gz, VALUE outbuf)
|
2607
2644
|
{
|
2608
2645
|
unsigned long crc, length;
|
2609
2646
|
|
2610
2647
|
gz->z.flags |= GZFILE_FLAG_FOOTER_FINISHED;
|
2611
2648
|
|
2612
|
-
|
2649
|
+
/* 8 is the size of gzip footer */
|
2650
|
+
if (!gzfile_read_raw_ensure(gz, 8, outbuf)) {
|
2613
2651
|
gzfile_raise(gz, cNoFooter, "footer is not found");
|
2614
2652
|
}
|
2615
2653
|
|
@@ -2643,12 +2681,12 @@ gzfile_write(struct gzfile *gz, Bytef *str, long len)
|
|
2643
2681
|
}
|
2644
2682
|
|
2645
2683
|
static long
|
2646
|
-
gzfile_read_more(struct gzfile *gz)
|
2684
|
+
gzfile_read_more(struct gzfile *gz, VALUE outbuf)
|
2647
2685
|
{
|
2648
2686
|
VALUE str;
|
2649
2687
|
|
2650
2688
|
while (!ZSTREAM_IS_FINISHED(&gz->z)) {
|
2651
|
-
str = gzfile_read_raw(gz);
|
2689
|
+
str = gzfile_read_raw(gz, outbuf);
|
2652
2690
|
if (NIL_P(str)) {
|
2653
2691
|
if (!ZSTREAM_IS_FINISHED(&gz->z)) {
|
2654
2692
|
rb_raise(cGzError, "unexpected end of file");
|
@@ -2683,13 +2721,11 @@ gzfile_newstr(struct gzfile *gz, VALUE str)
|
|
2683
2721
|
{
|
2684
2722
|
if (!gz->enc2) {
|
2685
2723
|
rb_enc_associate(str, gz->enc);
|
2686
|
-
OBJ_TAINT(str); /* for safe */
|
2687
2724
|
return str;
|
2688
2725
|
}
|
2689
2726
|
if (gz->ec && rb_enc_dummy_p(gz->enc2)) {
|
2690
2727
|
str = rb_econv_str_convert(gz->ec, str, ECONV_PARTIAL_INPUT);
|
2691
2728
|
rb_enc_associate(str, gz->enc);
|
2692
|
-
OBJ_TAINT(str);
|
2693
2729
|
return str;
|
2694
2730
|
}
|
2695
2731
|
return rb_str_conv_enc_opts(str, gz->enc2, gz->enc,
|
@@ -2704,11 +2740,11 @@ gzfile_fill(struct gzfile *gz, long len)
|
|
2704
2740
|
if (len == 0)
|
2705
2741
|
return 0;
|
2706
2742
|
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
|
2707
|
-
gzfile_read_more(gz);
|
2743
|
+
gzfile_read_more(gz, Qnil);
|
2708
2744
|
}
|
2709
2745
|
if (GZFILE_IS_FINISHED(gz)) {
|
2710
2746
|
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
2711
|
-
gzfile_check_footer(gz);
|
2747
|
+
gzfile_check_footer(gz, Qnil);
|
2712
2748
|
}
|
2713
2749
|
return -1;
|
2714
2750
|
}
|
@@ -2736,9 +2772,6 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
|
|
2736
2772
|
if (len < 0)
|
2737
2773
|
rb_raise(rb_eArgError, "negative length %ld given", len);
|
2738
2774
|
|
2739
|
-
if (!NIL_P(outbuf))
|
2740
|
-
OBJ_TAINT(outbuf);
|
2741
|
-
|
2742
2775
|
if (len == 0) {
|
2743
2776
|
if (NIL_P(outbuf))
|
2744
2777
|
return rb_str_new(0, 0);
|
@@ -2748,11 +2781,11 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
|
|
2748
2781
|
}
|
2749
2782
|
}
|
2750
2783
|
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) == 0) {
|
2751
|
-
gzfile_read_more(gz);
|
2784
|
+
gzfile_read_more(gz, outbuf);
|
2752
2785
|
}
|
2753
2786
|
if (GZFILE_IS_FINISHED(gz)) {
|
2754
2787
|
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
2755
|
-
gzfile_check_footer(gz);
|
2788
|
+
gzfile_check_footer(gz, outbuf);
|
2756
2789
|
}
|
2757
2790
|
if (!NIL_P(outbuf))
|
2758
2791
|
rb_str_resize(outbuf, 0);
|
@@ -2765,10 +2798,10 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
|
|
2765
2798
|
if (!NIL_P(outbuf)) {
|
2766
2799
|
rb_str_resize(outbuf, RSTRING_LEN(dst));
|
2767
2800
|
memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
|
2768
|
-
|
2801
|
+
rb_str_resize(dst, 0);
|
2802
|
+
rb_gc_force_recycle(dst);
|
2769
2803
|
dst = outbuf;
|
2770
2804
|
}
|
2771
|
-
OBJ_TAINT(dst); /* for safe */
|
2772
2805
|
return dst;
|
2773
2806
|
}
|
2774
2807
|
|
@@ -2778,11 +2811,11 @@ gzfile_read_all(struct gzfile *gz)
|
|
2778
2811
|
VALUE dst;
|
2779
2812
|
|
2780
2813
|
while (!ZSTREAM_IS_FINISHED(&gz->z)) {
|
2781
|
-
gzfile_read_more(gz);
|
2814
|
+
gzfile_read_more(gz, Qnil);
|
2782
2815
|
}
|
2783
2816
|
if (GZFILE_IS_FINISHED(gz)) {
|
2784
2817
|
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
2785
|
-
gzfile_check_footer(gz);
|
2818
|
+
gzfile_check_footer(gz, Qnil);
|
2786
2819
|
}
|
2787
2820
|
return rb_str_new(0, 0);
|
2788
2821
|
}
|
@@ -2790,7 +2823,6 @@ gzfile_read_all(struct gzfile *gz)
|
|
2790
2823
|
dst = zstream_detach_buffer(&gz->z);
|
2791
2824
|
if (NIL_P(dst)) return dst;
|
2792
2825
|
gzfile_calc_crc(gz, dst);
|
2793
|
-
OBJ_TAINT(dst);
|
2794
2826
|
return gzfile_newstr(gz, dst);
|
2795
2827
|
}
|
2796
2828
|
|
@@ -2802,11 +2834,11 @@ gzfile_getc(struct gzfile *gz)
|
|
2802
2834
|
|
2803
2835
|
len = rb_enc_mbmaxlen(gz->enc);
|
2804
2836
|
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
|
2805
|
-
gzfile_read_more(gz);
|
2837
|
+
gzfile_read_more(gz, Qnil);
|
2806
2838
|
}
|
2807
2839
|
if (GZFILE_IS_FINISHED(gz)) {
|
2808
2840
|
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
2809
|
-
gzfile_check_footer(gz);
|
2841
|
+
gzfile_check_footer(gz, Qnil);
|
2810
2842
|
}
|
2811
2843
|
return Qnil;
|
2812
2844
|
}
|
@@ -2814,22 +2846,18 @@ gzfile_getc(struct gzfile *gz)
|
|
2814
2846
|
if (gz->ec && rb_enc_dummy_p(gz->enc2)) {
|
2815
2847
|
const unsigned char *ss, *sp, *se;
|
2816
2848
|
unsigned char *ds, *dp, *de;
|
2849
|
+
VALUE cbuf = rb_enc_str_new(0, GZFILE_CBUF_CAPA, gz->enc);
|
2817
2850
|
|
2818
|
-
if (!gz->cbuf) {
|
2819
|
-
gz->cbuf = ALLOC_N(char, GZFILE_CBUF_CAPA);
|
2820
|
-
}
|
2821
2851
|
ss = sp = (const unsigned char*)RSTRING_PTR(gz->z.buf);
|
2822
2852
|
se = sp + ZSTREAM_BUF_FILLED(&gz->z);
|
2823
|
-
ds = dp = (unsigned char *)
|
2853
|
+
ds = dp = (unsigned char *)RSTRING_PTR(cbuf);
|
2824
2854
|
de = (unsigned char *)ds + GZFILE_CBUF_CAPA;
|
2825
2855
|
(void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT);
|
2826
2856
|
rb_econv_check_error(gz->ec);
|
2827
2857
|
dst = zstream_shift_buffer(&gz->z, sp - ss);
|
2828
2858
|
gzfile_calc_crc(gz, dst);
|
2829
|
-
|
2830
|
-
|
2831
|
-
OBJ_TAINT(dst);
|
2832
|
-
return dst;
|
2859
|
+
rb_str_resize(cbuf, dp - ds);
|
2860
|
+
return cbuf;
|
2833
2861
|
}
|
2834
2862
|
else {
|
2835
2863
|
buf = gz->z.buf;
|
@@ -2876,7 +2904,7 @@ gzfile_writer_end(struct gzfile *gz)
|
|
2876
2904
|
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
|
2877
2905
|
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
|
2878
2906
|
|
2879
|
-
rb_ensure(gzfile_writer_end_run, (VALUE)gz,
|
2907
|
+
rb_ensure(gzfile_writer_end_run, (VALUE)gz, zstream_ensure_end, (VALUE)&gz->z);
|
2880
2908
|
}
|
2881
2909
|
|
2882
2910
|
static VALUE
|
@@ -2886,7 +2914,7 @@ gzfile_reader_end_run(VALUE arg)
|
|
2886
2914
|
|
2887
2915
|
if (GZFILE_IS_FINISHED(gz)
|
2888
2916
|
&& !(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
2889
|
-
gzfile_check_footer(gz);
|
2917
|
+
gzfile_check_footer(gz, Qnil);
|
2890
2918
|
}
|
2891
2919
|
|
2892
2920
|
return Qnil;
|
@@ -2898,7 +2926,7 @@ gzfile_reader_end(struct gzfile *gz)
|
|
2898
2926
|
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
|
2899
2927
|
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
|
2900
2928
|
|
2901
|
-
rb_ensure(gzfile_reader_end_run, (VALUE)gz,
|
2929
|
+
rb_ensure(gzfile_reader_end_run, (VALUE)gz, zstream_ensure_end, (VALUE)&gz->z);
|
2902
2930
|
}
|
2903
2931
|
|
2904
2932
|
static void
|
@@ -2923,12 +2951,11 @@ gzfile_reader_get_unused(struct gzfile *gz)
|
|
2923
2951
|
if (!ZSTREAM_IS_READY(&gz->z)) return Qnil;
|
2924
2952
|
if (!GZFILE_IS_FINISHED(gz)) return Qnil;
|
2925
2953
|
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
2926
|
-
gzfile_check_footer(gz);
|
2954
|
+
gzfile_check_footer(gz, Qnil);
|
2927
2955
|
}
|
2928
2956
|
if (NIL_P(gz->z.input)) return Qnil;
|
2929
2957
|
|
2930
2958
|
str = rb_str_resurrect(gz->z.input);
|
2931
|
-
OBJ_TAINT(str); /* for safe */
|
2932
2959
|
return str;
|
2933
2960
|
}
|
2934
2961
|
|
@@ -2995,7 +3022,7 @@ static VALUE
|
|
2995
3022
|
new_wrap(VALUE tmp)
|
2996
3023
|
{
|
2997
3024
|
new_wrap_arg_t *arg = (new_wrap_arg_t *)tmp;
|
2998
|
-
return
|
3025
|
+
return rb_class_new_instance_kw(arg->argc, arg->argv, arg->klass, RB_PASS_CALLED_KEYWORDS);
|
2999
3026
|
}
|
3000
3027
|
|
3001
3028
|
static VALUE
|
@@ -3028,7 +3055,7 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
|
|
3028
3055
|
}
|
3029
3056
|
}
|
3030
3057
|
else {
|
3031
|
-
obj =
|
3058
|
+
obj = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
|
3032
3059
|
}
|
3033
3060
|
|
3034
3061
|
if (rb_block_given_p()) {
|
@@ -3145,7 +3172,6 @@ rb_gzfile_orig_name(VALUE obj)
|
|
3145
3172
|
if (!NIL_P(str)) {
|
3146
3173
|
str = rb_str_dup(str);
|
3147
3174
|
}
|
3148
|
-
OBJ_TAINT(str); /* for safe */
|
3149
3175
|
return str;
|
3150
3176
|
}
|
3151
3177
|
|
@@ -3162,7 +3188,6 @@ rb_gzfile_comment(VALUE obj)
|
|
3162
3188
|
if (!NIL_P(str)) {
|
3163
3189
|
str = rb_str_dup(str);
|
3164
3190
|
}
|
3165
|
-
OBJ_TAINT(str); /* for safe */
|
3166
3191
|
return str;
|
3167
3192
|
}
|
3168
3193
|
|
@@ -3221,6 +3246,7 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
|
|
3221
3246
|
|
3222
3247
|
val = rb_Integer(mtime);
|
3223
3248
|
gz->mtime = NUM2UINT(val);
|
3249
|
+
gz->z.flags |= GZFILE_FLAG_MTIME_IS_SET;
|
3224
3250
|
|
3225
3251
|
return mtime;
|
3226
3252
|
}
|
@@ -3731,7 +3757,7 @@ rb_gzreader_initialize(int argc, VALUE *argv, VALUE obj)
|
|
3731
3757
|
}
|
3732
3758
|
gz->io = io;
|
3733
3759
|
ZSTREAM_READY(&gz->z);
|
3734
|
-
gzfile_read_header(gz);
|
3760
|
+
gzfile_read_header(gz, Qnil);
|
3735
3761
|
rb_gzfile_ecopts(gz, opt);
|
3736
3762
|
|
3737
3763
|
if (rb_respond_to(io, id_path)) {
|
@@ -3981,7 +4007,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
|
|
3981
4007
|
|
3982
4008
|
while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
|
3983
4009
|
if (GZFILE_IS_FINISHED(gz)) return;
|
3984
|
-
gzfile_read_more(gz);
|
4010
|
+
gzfile_read_more(gz, Qnil);
|
3985
4011
|
}
|
3986
4012
|
n = 0;
|
3987
4013
|
p = RSTRING_PTR(gz->z.buf);
|
@@ -3992,7 +4018,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
|
|
3992
4018
|
gzfile_calc_crc(gz, str);
|
3993
4019
|
while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
|
3994
4020
|
if (GZFILE_IS_FINISHED(gz)) return;
|
3995
|
-
gzfile_read_more(gz);
|
4021
|
+
gzfile_read_more(gz, Qnil);
|
3996
4022
|
}
|
3997
4023
|
n = 0;
|
3998
4024
|
p = RSTRING_PTR(gz->z.buf);
|
@@ -4114,7 +4140,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
|
|
4114
4140
|
if (ZSTREAM_BUF_FILLED(&gz->z) > 0) gz->lineno++;
|
4115
4141
|
return gzfile_read(gz, rslen);
|
4116
4142
|
}
|
4117
|
-
gzfile_read_more(gz);
|
4143
|
+
gzfile_read_more(gz, Qnil);
|
4118
4144
|
}
|
4119
4145
|
|
4120
4146
|
p = RSTRING_PTR(gz->z.buf);
|
@@ -4123,7 +4149,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
|
|
4123
4149
|
long filled;
|
4124
4150
|
if (n > ZSTREAM_BUF_FILLED(&gz->z)) {
|
4125
4151
|
if (ZSTREAM_IS_FINISHED(&gz->z)) break;
|
4126
|
-
gzfile_read_more(gz);
|
4152
|
+
gzfile_read_more(gz, Qnil);
|
4127
4153
|
p = RSTRING_PTR(gz->z.buf) + n - rslen;
|
4128
4154
|
}
|
4129
4155
|
if (!rspara) rscheck(rsptr, rslen, rs);
|
@@ -4251,13 +4277,19 @@ rb_gzreader_external_encoding(VALUE self)
|
|
4251
4277
|
}
|
4252
4278
|
|
4253
4279
|
static VALUE
|
4254
|
-
|
4280
|
+
zlib_gzip_end_rescue(VALUE arg)
|
4255
4281
|
{
|
4256
4282
|
struct gzfile *gz = (struct gzfile *)arg;
|
4257
|
-
|
4283
|
+
gz->end(gz);
|
4258
4284
|
return Qnil;
|
4259
4285
|
}
|
4260
4286
|
|
4287
|
+
static VALUE
|
4288
|
+
zlib_gzip_ensure(VALUE arg)
|
4289
|
+
{
|
4290
|
+
return rb_rescue(zlib_gzip_end_rescue, arg, NULL, Qnil);
|
4291
|
+
}
|
4292
|
+
|
4261
4293
|
static void
|
4262
4294
|
zlib_gzip_end(struct gzfile *gz)
|
4263
4295
|
{
|
@@ -4403,7 +4435,7 @@ zlib_gunzip_run(VALUE arg)
|
|
4403
4435
|
struct gzfile *gz = (struct gzfile *)arg;
|
4404
4436
|
VALUE dst;
|
4405
4437
|
|
4406
|
-
gzfile_read_header(gz);
|
4438
|
+
gzfile_read_header(gz, Qnil);
|
4407
4439
|
dst = zstream_detach_buffer(&gz->z);
|
4408
4440
|
gzfile_calc_crc(gz, dst);
|
4409
4441
|
if (!ZSTREAM_IS_FINISHED(&gz->z)) {
|
@@ -4412,7 +4444,7 @@ zlib_gunzip_run(VALUE arg)
|
|
4412
4444
|
if (NIL_P(gz->z.input)) {
|
4413
4445
|
rb_raise(cNoFooter, "footer is not found");
|
4414
4446
|
}
|
4415
|
-
gzfile_check_footer(gz);
|
4447
|
+
gzfile_check_footer(gz, Qnil);
|
4416
4448
|
return dst;
|
4417
4449
|
}
|
4418
4450
|
|
@@ -4421,6 +4453,7 @@ zlib_gunzip_run(VALUE arg)
|
|
4421
4453
|
void
|
4422
4454
|
Init_zlib(void)
|
4423
4455
|
{
|
4456
|
+
#undef rb_intern
|
4424
4457
|
VALUE mZlib, cZStream, cDeflate, cInflate;
|
4425
4458
|
#if GZIP_SUPPORT
|
4426
4459
|
VALUE cGzipFile, cGzipWriter, cGzipReader;
|
@@ -4844,5 +4877,3 @@ Init_zlib(void)
|
|
4844
4877
|
* Raised when the data length recorded in the gzip file footer is not equivalent
|
4845
4878
|
* to the length of the actual uncompressed data.
|
4846
4879
|
*/
|
4847
|
-
|
4848
|
-
|
data/zlib.gemspec
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
+
|
4
|
+
source_version = ["", "ext/zlib/"].find do |dir|
|
5
|
+
begin
|
6
|
+
break File.open(File.join(__dir__, "#{dir}zlib.c")) {|f|
|
7
|
+
f.gets("\n#define RUBY_ZLIB_VERSION ")
|
8
|
+
f.gets[/\s*"(.+)"/, 1]
|
9
|
+
}
|
10
|
+
rescue Errno::ENOENT
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
3
14
|
Gem::Specification.new do |spec|
|
4
15
|
spec.name = "zlib"
|
5
|
-
spec.version =
|
6
|
-
spec.date = '2017-12-11'
|
16
|
+
spec.version = source_version
|
7
17
|
spec.authors = ["Yukihiro Matsumoto", "UENO Katsuhiro"]
|
8
18
|
spec.email = ["matz@ruby-lang.org", nil]
|
9
19
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -92,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
|
96
|
-
rubygems_version: 2.5.2.1
|
95
|
+
rubygems_version: 3.0.3
|
97
96
|
signing_key:
|
98
97
|
specification_version: 4
|
99
98
|
summary: Ruby interface for the zlib compression/decompression library
|