zlib 3.1.2 → 3.2.3
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/README.md +1 -1
- data/ext/zlib/zlib.c +273 -198
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 336dc64dd83cbbd9a74ca0494fd75bc2324ff0a615baa20b3c45c232ea6ee35a
|
|
4
|
+
data.tar.gz: f23633ed1053a62b9423628edf0ad19149bf1785371f5c5bc3b08900dabeb56e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6b289bcde42b602690993bd4dc087928f1d50542ed9ddeffb148071f3e5eb9e37bd3891cfa9ec435648a62e01b6cffcfdc1dd92995674efe39c88c434843c6f
|
|
7
|
+
data.tar.gz: 00764a29cf1ecbe3a0db97919a911e98ec21d1690599381c12e34a736469f1be8643997964575b4782aa5a100b0f219e645ca067bd22ad222e34b723f886d2f0
|
data/README.md
CHANGED
|
@@ -53,7 +53,7 @@ puts "Uncompressed data is: #{uncompressed_data}"
|
|
|
53
53
|
|
|
54
54
|
## Development
|
|
55
55
|
|
|
56
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
56
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake compile test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
57
57
|
|
|
58
58
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
59
59
|
|
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 "3.
|
|
28
|
+
#define RUBY_ZLIB_VERSION "3.2.3"
|
|
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)
|
|
@@ -90,7 +90,7 @@ static void zstream_expand_buffer_into(struct zstream*, unsigned long);
|
|
|
90
90
|
static int zstream_expand_buffer_non_stream(struct zstream *z);
|
|
91
91
|
static void zstream_append_buffer(struct zstream*, const Bytef*, long);
|
|
92
92
|
static VALUE zstream_detach_buffer(struct zstream*);
|
|
93
|
-
static VALUE zstream_shift_buffer(struct zstream*, long);
|
|
93
|
+
static VALUE zstream_shift_buffer(struct zstream*, long, VALUE);
|
|
94
94
|
static void zstream_buffer_ungets(struct zstream*, const Bytef*, unsigned long);
|
|
95
95
|
static void zstream_buffer_ungetbyte(struct zstream*, int);
|
|
96
96
|
static void zstream_append_input(struct zstream*, const Bytef*, long);
|
|
@@ -170,8 +170,8 @@ static void gzfile_check_footer(struct gzfile*, VALUE outbuf);
|
|
|
170
170
|
static void gzfile_write(struct gzfile*, Bytef*, long);
|
|
171
171
|
static long gzfile_read_more(struct gzfile*, VALUE outbuf);
|
|
172
172
|
static void gzfile_calc_crc(struct gzfile*, VALUE);
|
|
173
|
-
static VALUE gzfile_read(struct gzfile*, long);
|
|
174
|
-
static VALUE gzfile_read_all(struct gzfile
|
|
173
|
+
static VALUE gzfile_read(struct gzfile*, long, VALUE);
|
|
174
|
+
static VALUE gzfile_read_all(struct gzfile*, VALUE);
|
|
175
175
|
static void gzfile_ungets(struct gzfile*, const Bytef*, long);
|
|
176
176
|
static void gzfile_ungetbyte(struct gzfile*, int);
|
|
177
177
|
static VALUE gzfile_writer_end_run(VALUE);
|
|
@@ -674,9 +674,7 @@ zstream_expand_buffer(struct zstream *z)
|
|
|
674
674
|
rb_obj_reveal(z->buf, rb_cString);
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
-
|
|
678
|
-
rb_protect(rb_yield, z->buf, &state);
|
|
679
|
-
rb_mutex_lock(z->mutex);
|
|
677
|
+
rb_protect(rb_yield, z->buf, &state);
|
|
680
678
|
|
|
681
679
|
if (ZSTREAM_REUSE_BUFFER_P(z)) {
|
|
682
680
|
rb_str_modify(z->buf);
|
|
@@ -720,15 +718,14 @@ zstream_expand_buffer_into(struct zstream *z, unsigned long size)
|
|
|
720
718
|
}
|
|
721
719
|
}
|
|
722
720
|
|
|
723
|
-
static
|
|
724
|
-
zstream_expand_buffer_protect(
|
|
721
|
+
static int
|
|
722
|
+
zstream_expand_buffer_protect(struct zstream *z)
|
|
725
723
|
{
|
|
726
|
-
struct zstream *z = (struct zstream *)ptr;
|
|
727
724
|
int state = 0;
|
|
728
725
|
|
|
729
726
|
rb_protect((VALUE (*)(VALUE))zstream_expand_buffer, (VALUE)z, &state);
|
|
730
727
|
|
|
731
|
-
return
|
|
728
|
+
return state;
|
|
732
729
|
}
|
|
733
730
|
|
|
734
731
|
static int
|
|
@@ -820,19 +817,31 @@ zstream_detach_buffer(struct zstream *z)
|
|
|
820
817
|
}
|
|
821
818
|
|
|
822
819
|
static VALUE
|
|
823
|
-
zstream_shift_buffer(struct zstream *z, long len)
|
|
820
|
+
zstream_shift_buffer(struct zstream *z, long len, VALUE dst)
|
|
824
821
|
{
|
|
825
|
-
VALUE dst;
|
|
826
822
|
char *bufptr;
|
|
827
823
|
long buflen = ZSTREAM_BUF_FILLED(z);
|
|
828
824
|
|
|
829
825
|
if (buflen <= len) {
|
|
830
|
-
|
|
826
|
+
if (NIL_P(dst) || (!ZSTREAM_IS_FINISHED(z) && !ZSTREAM_IS_GZFILE(z) &&
|
|
827
|
+
rb_block_given_p())) {
|
|
828
|
+
return zstream_detach_buffer(z);
|
|
829
|
+
} else {
|
|
830
|
+
bufptr = RSTRING_PTR(z->buf);
|
|
831
|
+
rb_str_resize(dst, buflen);
|
|
832
|
+
memcpy(RSTRING_PTR(dst), bufptr, buflen);
|
|
833
|
+
}
|
|
834
|
+
buflen = 0;
|
|
835
|
+
} else {
|
|
836
|
+
bufptr = RSTRING_PTR(z->buf);
|
|
837
|
+
if (NIL_P(dst)) {
|
|
838
|
+
dst = rb_str_new(bufptr, len);
|
|
839
|
+
} else {
|
|
840
|
+
rb_str_resize(dst, len);
|
|
841
|
+
memcpy(RSTRING_PTR(dst), bufptr, len);
|
|
842
|
+
}
|
|
843
|
+
buflen -= len;
|
|
831
844
|
}
|
|
832
|
-
|
|
833
|
-
bufptr = RSTRING_PTR(z->buf);
|
|
834
|
-
dst = rb_str_new(bufptr, len);
|
|
835
|
-
buflen -= len;
|
|
836
845
|
memmove(bufptr, bufptr + len, buflen);
|
|
837
846
|
rb_str_set_len(z->buf, buflen);
|
|
838
847
|
z->stream.next_out = (Bytef*)RSTRING_END(z->buf);
|
|
@@ -1009,57 +1018,14 @@ zstream_ensure_end(VALUE v)
|
|
|
1009
1018
|
}
|
|
1010
1019
|
|
|
1011
1020
|
static void *
|
|
1012
|
-
|
|
1021
|
+
zstream_run_once(void *_arguments)
|
|
1013
1022
|
{
|
|
1014
|
-
struct zstream_run_args *
|
|
1015
|
-
|
|
1016
|
-
struct zstream *z = args->z;
|
|
1017
|
-
uInt n;
|
|
1018
|
-
|
|
1019
|
-
err = Z_OK;
|
|
1020
|
-
while (!args->interrupt) {
|
|
1021
|
-
n = z->stream.avail_out;
|
|
1022
|
-
err = z->func->run(&z->stream, flush);
|
|
1023
|
-
rb_str_set_len(z->buf, ZSTREAM_BUF_FILLED(z) + (n - z->stream.avail_out));
|
|
1024
|
-
|
|
1025
|
-
if (err == Z_STREAM_END) {
|
|
1026
|
-
z->flags &= ~ZSTREAM_FLAG_IN_STREAM;
|
|
1027
|
-
z->flags |= ZSTREAM_FLAG_FINISHED;
|
|
1028
|
-
break;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
if (err != Z_OK && err != Z_BUF_ERROR)
|
|
1032
|
-
break;
|
|
1033
|
-
|
|
1034
|
-
if (z->stream.avail_out > 0) {
|
|
1035
|
-
z->flags |= ZSTREAM_FLAG_IN_STREAM;
|
|
1036
|
-
break;
|
|
1037
|
-
}
|
|
1023
|
+
struct zstream_run_args *arguments = (struct zstream_run_args *)_arguments;
|
|
1024
|
+
struct zstream *z = arguments->z;
|
|
1038
1025
|
|
|
1039
|
-
|
|
1040
|
-
/* break here because inflate() return Z_BUF_ERROR when avail_in == 0. */
|
|
1041
|
-
/* but deflate() could be called with avail_in == 0 (there's hidden buffer
|
|
1042
|
-
in zstream->state) */
|
|
1043
|
-
z->flags |= ZSTREAM_FLAG_IN_STREAM;
|
|
1044
|
-
break;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
if (args->stream_output) {
|
|
1048
|
-
state = (int)(VALUE)rb_thread_call_with_gvl(zstream_expand_buffer_protect,
|
|
1049
|
-
(void *)z);
|
|
1050
|
-
}
|
|
1051
|
-
else {
|
|
1052
|
-
state = zstream_expand_buffer_non_stream(z);
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
if (state) {
|
|
1056
|
-
err = Z_OK; /* buffer expanded but stream processing was stopped */
|
|
1057
|
-
args->jump_state = state;
|
|
1058
|
-
break;
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1026
|
+
uintptr_t error = z->func->run(&z->stream, arguments->flush);
|
|
1061
1027
|
|
|
1062
|
-
return (void
|
|
1028
|
+
return (void*)error;
|
|
1063
1029
|
}
|
|
1064
1030
|
|
|
1065
1031
|
/*
|
|
@@ -1074,6 +1040,91 @@ zstream_unblock_func(void *ptr)
|
|
|
1074
1040
|
args->interrupt = 1;
|
|
1075
1041
|
}
|
|
1076
1042
|
|
|
1043
|
+
#ifndef RB_NOGVL_OFFLOAD_SAFE
|
|
1044
|
+
// Default to no-op if it's not defined:
|
|
1045
|
+
#define RB_NOGVL_OFFLOAD_SAFE 0
|
|
1046
|
+
#endif
|
|
1047
|
+
|
|
1048
|
+
static VALUE
|
|
1049
|
+
zstream_run_once_begin(VALUE _arguments)
|
|
1050
|
+
{
|
|
1051
|
+
struct zstream_run_args *arguments = (struct zstream_run_args *)_arguments;
|
|
1052
|
+
struct zstream *z = arguments->z;
|
|
1053
|
+
|
|
1054
|
+
rb_str_locktmp(z->buf);
|
|
1055
|
+
|
|
1056
|
+
#ifndef RB_NOGVL_UBF_ASYNC_SAFE
|
|
1057
|
+
return (VALUE)rb_thread_call_without_gvl(zstream_run_once, (void *)arguments, zstream_unblock_func, (void *)arguments);
|
|
1058
|
+
#else
|
|
1059
|
+
return (VALUE)rb_nogvl(zstream_run_once, (void *)arguments, zstream_unblock_func, (void *)arguments, RB_NOGVL_UBF_ASYNC_SAFE | RB_NOGVL_OFFLOAD_SAFE);
|
|
1060
|
+
#endif
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
static VALUE
|
|
1064
|
+
zstream_run_once_ensure(VALUE _arguments)
|
|
1065
|
+
{
|
|
1066
|
+
struct zstream_run_args *arguments = (struct zstream_run_args *)_arguments;
|
|
1067
|
+
struct zstream *z = arguments->z;
|
|
1068
|
+
|
|
1069
|
+
rb_str_unlocktmp(z->buf);
|
|
1070
|
+
|
|
1071
|
+
return Qnil;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
static int
|
|
1075
|
+
zstream_run_func(struct zstream_run_args *args)
|
|
1076
|
+
{
|
|
1077
|
+
struct zstream *z = args->z;
|
|
1078
|
+
int state;
|
|
1079
|
+
uInt n;
|
|
1080
|
+
|
|
1081
|
+
int err = Z_OK;
|
|
1082
|
+
while (!args->interrupt) {
|
|
1083
|
+
n = z->stream.avail_out;
|
|
1084
|
+
|
|
1085
|
+
err = (int)(VALUE)rb_ensure(zstream_run_once_begin, (VALUE)args, zstream_run_once_ensure, (VALUE)args);
|
|
1086
|
+
|
|
1087
|
+
rb_str_set_len(z->buf, ZSTREAM_BUF_FILLED(z) + (n - z->stream.avail_out));
|
|
1088
|
+
|
|
1089
|
+
if (err == Z_STREAM_END) {
|
|
1090
|
+
z->flags &= ~ZSTREAM_FLAG_IN_STREAM;
|
|
1091
|
+
z->flags |= ZSTREAM_FLAG_FINISHED;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
if (err != Z_OK && err != Z_BUF_ERROR)
|
|
1096
|
+
break;
|
|
1097
|
+
|
|
1098
|
+
if (z->stream.avail_out > 0) {
|
|
1099
|
+
z->flags |= ZSTREAM_FLAG_IN_STREAM;
|
|
1100
|
+
break;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if (z->stream.avail_in == 0 && z->func == &inflate_funcs) {
|
|
1104
|
+
/* break here because inflate() return Z_BUF_ERROR when avail_in == 0. */
|
|
1105
|
+
/* but deflate() could be called with avail_in == 0 (there's hidden buffer
|
|
1106
|
+
in zstream->state) */
|
|
1107
|
+
z->flags |= ZSTREAM_FLAG_IN_STREAM;
|
|
1108
|
+
break;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
if (args->stream_output) {
|
|
1112
|
+
state = zstream_expand_buffer_protect(z);
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
state = zstream_expand_buffer_non_stream(z);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
if (state) {
|
|
1119
|
+
err = Z_OK; /* buffer expanded but stream processing was stopped */
|
|
1120
|
+
args->jump_state = state;
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
return err;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1077
1128
|
static VALUE
|
|
1078
1129
|
zstream_run_try(VALUE value_arg)
|
|
1079
1130
|
{
|
|
@@ -1086,6 +1137,12 @@ zstream_run_try(VALUE value_arg)
|
|
|
1086
1137
|
int err;
|
|
1087
1138
|
VALUE old_input = Qnil;
|
|
1088
1139
|
|
|
1140
|
+
/* Cannot start zstream while it is in progress. */
|
|
1141
|
+
if (z->flags & ZSTREAM_IN_PROGRESS) {
|
|
1142
|
+
rb_raise(cInProgressError, "zlib stream is in progress");
|
|
1143
|
+
}
|
|
1144
|
+
z->flags |= ZSTREAM_IN_PROGRESS;
|
|
1145
|
+
|
|
1089
1146
|
if (NIL_P(z->input) && len == 0) {
|
|
1090
1147
|
z->stream.next_in = (Bytef*)"";
|
|
1091
1148
|
z->stream.avail_in = 0;
|
|
@@ -1106,14 +1163,7 @@ zstream_run_try(VALUE value_arg)
|
|
|
1106
1163
|
}
|
|
1107
1164
|
|
|
1108
1165
|
loop:
|
|
1109
|
-
|
|
1110
|
-
err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)args,
|
|
1111
|
-
zstream_unblock_func, (void *)args);
|
|
1112
|
-
#else
|
|
1113
|
-
err = (int)(VALUE)rb_nogvl(zstream_run_func, (void *)args,
|
|
1114
|
-
zstream_unblock_func, (void *)args,
|
|
1115
|
-
RB_NOGVL_UBF_ASYNC_SAFE);
|
|
1116
|
-
#endif
|
|
1166
|
+
err = zstream_run_func(args);
|
|
1117
1167
|
|
|
1118
1168
|
/* retry if no exception is thrown */
|
|
1119
1169
|
if (err == Z_OK && args->interrupt) {
|
|
@@ -1153,9 +1203,6 @@ loop:
|
|
|
1153
1203
|
rb_str_resize(old_input, 0);
|
|
1154
1204
|
}
|
|
1155
1205
|
|
|
1156
|
-
if (args->jump_state)
|
|
1157
|
-
rb_jump_tag(args->jump_state);
|
|
1158
|
-
|
|
1159
1206
|
return Qnil;
|
|
1160
1207
|
}
|
|
1161
1208
|
|
|
@@ -1163,25 +1210,10 @@ static VALUE
|
|
|
1163
1210
|
zstream_run_ensure(VALUE value_arg)
|
|
1164
1211
|
{
|
|
1165
1212
|
struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
|
|
1213
|
+
struct zstream *z = args->z;
|
|
1166
1214
|
|
|
1167
1215
|
/* Remove ZSTREAM_IN_PROGRESS flag to signal that this zstream is not in use. */
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
return Qnil;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
static VALUE
|
|
1174
|
-
zstream_run_synchronized(VALUE value_arg)
|
|
1175
|
-
{
|
|
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);
|
|
1216
|
+
z->flags &= ~ZSTREAM_IN_PROGRESS;
|
|
1185
1217
|
|
|
1186
1218
|
return Qnil;
|
|
1187
1219
|
}
|
|
@@ -1198,7 +1230,10 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush)
|
|
|
1198
1230
|
.jump_state = 0,
|
|
1199
1231
|
.stream_output = !ZSTREAM_IS_GZFILE(z) && rb_block_given_p(),
|
|
1200
1232
|
};
|
|
1201
|
-
|
|
1233
|
+
|
|
1234
|
+
rb_ensure(zstream_run_try, (VALUE)&args, zstream_run_ensure, (VALUE)&args);
|
|
1235
|
+
if (args.jump_state)
|
|
1236
|
+
rb_jump_tag(args.jump_state);
|
|
1202
1237
|
}
|
|
1203
1238
|
|
|
1204
1239
|
static VALUE
|
|
@@ -1507,7 +1542,7 @@ rb_zstream_total_out(VALUE obj)
|
|
|
1507
1542
|
}
|
|
1508
1543
|
|
|
1509
1544
|
/*
|
|
1510
|
-
* Guesses the type of the data which have been
|
|
1545
|
+
* Guesses the type of the data which have been inputted into the stream. The
|
|
1511
1546
|
* returned value is either <tt>BINARY</tt>, <tt>ASCII</tt>, or
|
|
1512
1547
|
* <tt>UNKNOWN</tt>.
|
|
1513
1548
|
*/
|
|
@@ -1764,6 +1799,22 @@ do_deflate(struct zstream *z, VALUE src, int flush)
|
|
|
1764
1799
|
}
|
|
1765
1800
|
}
|
|
1766
1801
|
|
|
1802
|
+
struct rb_zlib_deflate_arguments {
|
|
1803
|
+
struct zstream *z;
|
|
1804
|
+
VALUE src;
|
|
1805
|
+
int flush;
|
|
1806
|
+
};
|
|
1807
|
+
|
|
1808
|
+
static VALUE
|
|
1809
|
+
rb_deflate_deflate_body(VALUE args)
|
|
1810
|
+
{
|
|
1811
|
+
struct rb_zlib_deflate_arguments *arguments = (struct rb_zlib_deflate_arguments *)args;
|
|
1812
|
+
|
|
1813
|
+
do_deflate(arguments->z, arguments->src, arguments->flush);
|
|
1814
|
+
|
|
1815
|
+
return zstream_detach_buffer(arguments->z);
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1767
1818
|
/*
|
|
1768
1819
|
* Document-method: Zlib::Deflate#deflate
|
|
1769
1820
|
*
|
|
@@ -1795,11 +1846,10 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
|
|
|
1795
1846
|
{
|
|
1796
1847
|
struct zstream *z = get_zstream(obj);
|
|
1797
1848
|
VALUE src, flush;
|
|
1798
|
-
|
|
1799
1849
|
rb_scan_args(argc, argv, "11", &src, &flush);
|
|
1800
|
-
|
|
1850
|
+
struct rb_zlib_deflate_arguments arguments = {z, src, ARG_FLUSH(flush)};
|
|
1801
1851
|
|
|
1802
|
-
return
|
|
1852
|
+
return rb_mutex_synchronize(z->mutex, rb_deflate_deflate_body, (VALUE)&arguments);
|
|
1803
1853
|
}
|
|
1804
1854
|
|
|
1805
1855
|
/*
|
|
@@ -2095,56 +2145,19 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
|
|
|
2095
2145
|
return obj;
|
|
2096
2146
|
}
|
|
2097
2147
|
|
|
2098
|
-
|
|
2099
|
-
*
|
|
2100
|
-
|
|
2101
|
-
*
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
*
|
|
2105
|
-
* Inputs +deflate_string+ into the inflate stream and returns the output from
|
|
2106
|
-
* the stream. Calling this method, both the input and the output buffer of
|
|
2107
|
-
* the stream are flushed. If string is +nil+, this method finishes the
|
|
2108
|
-
* stream, just like Zlib::ZStream#finish.
|
|
2109
|
-
*
|
|
2110
|
-
* If a block is given consecutive inflated chunks from the +deflate_string+
|
|
2111
|
-
* are yielded to the block and +nil+ is returned.
|
|
2112
|
-
*
|
|
2113
|
-
* If a :buffer keyword argument is given and not nil:
|
|
2114
|
-
*
|
|
2115
|
-
* * The :buffer keyword should be a String, and will used as the output buffer.
|
|
2116
|
-
* Using this option can reuse the memory required during inflation.
|
|
2117
|
-
* * When not passing a block, the return value will be the same object as the
|
|
2118
|
-
* :buffer keyword argument.
|
|
2119
|
-
* * When passing a block, the yielded chunks will be the same value as the
|
|
2120
|
-
* :buffer keyword argument.
|
|
2121
|
-
*
|
|
2122
|
-
* Raises a Zlib::NeedDict exception if a preset dictionary is needed to
|
|
2123
|
-
* decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
|
|
2124
|
-
* call this method again with an empty string to flush the stream:
|
|
2125
|
-
*
|
|
2126
|
-
* inflater = Zlib::Inflate.new
|
|
2127
|
-
*
|
|
2128
|
-
* begin
|
|
2129
|
-
* out = inflater.inflate compressed
|
|
2130
|
-
* rescue Zlib::NeedDict
|
|
2131
|
-
* # ensure the dictionary matches the stream's required dictionary
|
|
2132
|
-
* raise unless inflater.adler == Zlib.adler32(dictionary)
|
|
2133
|
-
*
|
|
2134
|
-
* inflater.set_dictionary dictionary
|
|
2135
|
-
* inflater.inflate ''
|
|
2136
|
-
* end
|
|
2137
|
-
*
|
|
2138
|
-
* # ...
|
|
2139
|
-
*
|
|
2140
|
-
* inflater.close
|
|
2141
|
-
*
|
|
2142
|
-
* See also Zlib::Inflate.new
|
|
2143
|
-
*/
|
|
2148
|
+
struct rb_zlib_inflate_arguments {
|
|
2149
|
+
struct zstream *z;
|
|
2150
|
+
int argc;
|
|
2151
|
+
VALUE *argv;
|
|
2152
|
+
};
|
|
2153
|
+
|
|
2144
2154
|
static VALUE
|
|
2145
|
-
|
|
2155
|
+
rb_inflate_inflate_body(VALUE _arguments)
|
|
2146
2156
|
{
|
|
2147
|
-
struct
|
|
2157
|
+
struct rb_zlib_inflate_arguments *arguments = (struct rb_zlib_inflate_arguments*)_arguments;
|
|
2158
|
+
struct zstream *z = arguments->z;
|
|
2159
|
+
int argc = arguments->argc;
|
|
2160
|
+
VALUE *argv = arguments->argv;
|
|
2148
2161
|
VALUE dst, src, opts, buffer = Qnil;
|
|
2149
2162
|
|
|
2150
2163
|
if (OPTHASH_GIVEN_P(opts)) {
|
|
@@ -2199,6 +2212,60 @@ rb_inflate_inflate(int argc, VALUE* argv, VALUE obj)
|
|
|
2199
2212
|
return dst;
|
|
2200
2213
|
}
|
|
2201
2214
|
|
|
2215
|
+
/*
|
|
2216
|
+
* Document-method: Zlib::Inflate#inflate
|
|
2217
|
+
*
|
|
2218
|
+
* call-seq:
|
|
2219
|
+
* inflate(deflate_string, buffer: nil) -> String
|
|
2220
|
+
* inflate(deflate_string, buffer: nil) { |chunk| ... } -> nil
|
|
2221
|
+
*
|
|
2222
|
+
* Inputs +deflate_string+ into the inflate stream and returns the output from
|
|
2223
|
+
* the stream. Calling this method, both the input and the output buffer of
|
|
2224
|
+
* the stream are flushed. If string is +nil+, this method finishes the
|
|
2225
|
+
* stream, just like Zlib::ZStream#finish.
|
|
2226
|
+
*
|
|
2227
|
+
* If a block is given consecutive inflated chunks from the +deflate_string+
|
|
2228
|
+
* are yielded to the block and +nil+ is returned.
|
|
2229
|
+
*
|
|
2230
|
+
* If a :buffer keyword argument is given and not nil:
|
|
2231
|
+
*
|
|
2232
|
+
* * The :buffer keyword should be a String, and will used as the output buffer.
|
|
2233
|
+
* Using this option can reuse the memory required during inflation.
|
|
2234
|
+
* * When not passing a block, the return value will be the same object as the
|
|
2235
|
+
* :buffer keyword argument.
|
|
2236
|
+
* * When passing a block, the yielded chunks will be the same value as the
|
|
2237
|
+
* :buffer keyword argument.
|
|
2238
|
+
*
|
|
2239
|
+
* Raises a Zlib::NeedDict exception if a preset dictionary is needed to
|
|
2240
|
+
* decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
|
|
2241
|
+
* call this method again with an empty string to flush the stream:
|
|
2242
|
+
*
|
|
2243
|
+
* inflater = Zlib::Inflate.new
|
|
2244
|
+
*
|
|
2245
|
+
* begin
|
|
2246
|
+
* out = inflater.inflate compressed
|
|
2247
|
+
* rescue Zlib::NeedDict
|
|
2248
|
+
* # ensure the dictionary matches the stream's required dictionary
|
|
2249
|
+
* raise unless inflater.adler == Zlib.adler32(dictionary)
|
|
2250
|
+
*
|
|
2251
|
+
* inflater.set_dictionary dictionary
|
|
2252
|
+
* inflater.inflate ''
|
|
2253
|
+
* end
|
|
2254
|
+
*
|
|
2255
|
+
* # ...
|
|
2256
|
+
*
|
|
2257
|
+
* inflater.close
|
|
2258
|
+
*
|
|
2259
|
+
* See also Zlib::Inflate.new
|
|
2260
|
+
*/
|
|
2261
|
+
static VALUE
|
|
2262
|
+
rb_inflate_inflate(int argc, VALUE* argv, VALUE obj)
|
|
2263
|
+
{
|
|
2264
|
+
struct zstream *z = get_zstream(obj);
|
|
2265
|
+
struct rb_zlib_inflate_arguments arguments = {z, argc, argv};
|
|
2266
|
+
return rb_mutex_synchronize(z->mutex, rb_inflate_inflate_body, (VALUE)&arguments);
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2202
2269
|
/*
|
|
2203
2270
|
* call-seq: << string
|
|
2204
2271
|
*
|
|
@@ -2375,17 +2442,16 @@ struct gzfile {
|
|
|
2375
2442
|
|
|
2376
2443
|
#define GZFILE_READ_SIZE 2048
|
|
2377
2444
|
|
|
2445
|
+
enum { read_raw_arg_len, read_raw_arg_buf, read_raw_arg__count};
|
|
2378
2446
|
struct read_raw_arg {
|
|
2379
2447
|
VALUE io;
|
|
2380
|
-
|
|
2381
|
-
const VALUE argv[2]; /* for rb_funcallv */
|
|
2382
|
-
struct {
|
|
2383
|
-
VALUE len;
|
|
2384
|
-
VALUE buf;
|
|
2385
|
-
} in;
|
|
2386
|
-
} as;
|
|
2448
|
+
const VALUE argv[read_raw_arg__count]; /* for rb_funcallv */
|
|
2387
2449
|
};
|
|
2388
2450
|
|
|
2451
|
+
#define read_raw_arg_argc(ra) \
|
|
2452
|
+
((int)read_raw_arg__count - NIL_P((ra)->argv[read_raw_arg__count - 1]))
|
|
2453
|
+
#define read_raw_arg_init(io, len, buf) { io, { len, buf } }
|
|
2454
|
+
|
|
2389
2455
|
static void
|
|
2390
2456
|
gzfile_mark(void *p)
|
|
2391
2457
|
{
|
|
@@ -2511,9 +2577,9 @@ gzfile_read_raw_partial(VALUE arg)
|
|
|
2511
2577
|
{
|
|
2512
2578
|
struct read_raw_arg *ra = (struct read_raw_arg *)arg;
|
|
2513
2579
|
VALUE str;
|
|
2514
|
-
int argc =
|
|
2580
|
+
int argc = read_raw_arg_argc(ra);
|
|
2515
2581
|
|
|
2516
|
-
str = rb_funcallv(ra->io, id_readpartial, argc, ra->
|
|
2582
|
+
str = rb_funcallv(ra->io, id_readpartial, argc, ra->argv);
|
|
2517
2583
|
Check_Type(str, T_STRING);
|
|
2518
2584
|
return str;
|
|
2519
2585
|
}
|
|
@@ -2524,8 +2590,8 @@ gzfile_read_raw_rescue(VALUE arg, VALUE _)
|
|
|
2524
2590
|
struct read_raw_arg *ra = (struct read_raw_arg *)arg;
|
|
2525
2591
|
VALUE str = Qnil;
|
|
2526
2592
|
if (rb_obj_is_kind_of(rb_errinfo(), rb_eNoMethodError)) {
|
|
2527
|
-
int argc =
|
|
2528
|
-
str = rb_funcallv(ra->io, id_read, argc, ra->
|
|
2593
|
+
int argc = read_raw_arg_argc(ra);
|
|
2594
|
+
str = rb_funcallv(ra->io, id_read, argc, ra->argv);
|
|
2529
2595
|
if (!NIL_P(str)) {
|
|
2530
2596
|
Check_Type(str, T_STRING);
|
|
2531
2597
|
}
|
|
@@ -2536,11 +2602,8 @@ gzfile_read_raw_rescue(VALUE arg, VALUE _)
|
|
|
2536
2602
|
static VALUE
|
|
2537
2603
|
gzfile_read_raw(struct gzfile *gz, VALUE outbuf)
|
|
2538
2604
|
{
|
|
2539
|
-
struct read_raw_arg ra
|
|
2540
|
-
|
|
2541
|
-
ra.io = gz->io;
|
|
2542
|
-
ra.as.in.len = INT2FIX(GZFILE_READ_SIZE);
|
|
2543
|
-
ra.as.in.buf = outbuf;
|
|
2605
|
+
struct read_raw_arg ra =
|
|
2606
|
+
read_raw_arg_init(gz->io, INT2FIX(GZFILE_READ_SIZE), outbuf);
|
|
2544
2607
|
|
|
2545
2608
|
return rb_rescue2(gzfile_read_raw_partial, (VALUE)&ra,
|
|
2546
2609
|
gzfile_read_raw_rescue, (VALUE)&ra,
|
|
@@ -2872,18 +2935,18 @@ gzfile_newstr(struct gzfile *gz, VALUE str)
|
|
|
2872
2935
|
}
|
|
2873
2936
|
|
|
2874
2937
|
static long
|
|
2875
|
-
gzfile_fill(struct gzfile *gz, long len)
|
|
2938
|
+
gzfile_fill(struct gzfile *gz, long len, VALUE outbuf)
|
|
2876
2939
|
{
|
|
2877
2940
|
if (len < 0)
|
|
2878
2941
|
rb_raise(rb_eArgError, "negative length %ld given", len);
|
|
2879
2942
|
if (len == 0)
|
|
2880
2943
|
return 0;
|
|
2881
2944
|
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
|
|
2882
|
-
gzfile_read_more(gz,
|
|
2945
|
+
gzfile_read_more(gz, outbuf);
|
|
2883
2946
|
}
|
|
2884
2947
|
if (GZFILE_IS_FINISHED(gz)) {
|
|
2885
2948
|
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
|
2886
|
-
gzfile_check_footer(gz,
|
|
2949
|
+
gzfile_check_footer(gz, outbuf);
|
|
2887
2950
|
}
|
|
2888
2951
|
return -1;
|
|
2889
2952
|
}
|
|
@@ -2891,14 +2954,27 @@ gzfile_fill(struct gzfile *gz, long len)
|
|
|
2891
2954
|
}
|
|
2892
2955
|
|
|
2893
2956
|
static VALUE
|
|
2894
|
-
gzfile_read(struct gzfile *gz, long len)
|
|
2957
|
+
gzfile_read(struct gzfile *gz, long len, VALUE outbuf)
|
|
2895
2958
|
{
|
|
2896
2959
|
VALUE dst;
|
|
2897
2960
|
|
|
2898
|
-
len = gzfile_fill(gz, len);
|
|
2899
|
-
|
|
2900
|
-
if (len < 0)
|
|
2901
|
-
|
|
2961
|
+
len = gzfile_fill(gz, len, outbuf);
|
|
2962
|
+
|
|
2963
|
+
if (len < 0) {
|
|
2964
|
+
if (!NIL_P(outbuf))
|
|
2965
|
+
rb_str_resize(outbuf, 0);
|
|
2966
|
+
return Qnil;
|
|
2967
|
+
}
|
|
2968
|
+
if (len == 0) {
|
|
2969
|
+
if (NIL_P(outbuf))
|
|
2970
|
+
return rb_str_new(0, 0);
|
|
2971
|
+
else {
|
|
2972
|
+
rb_str_resize(outbuf, 0);
|
|
2973
|
+
return outbuf;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
dst = zstream_shift_buffer(&gz->z, len, outbuf);
|
|
2902
2978
|
if (!NIL_P(dst)) gzfile_calc_crc(gz, dst);
|
|
2903
2979
|
return dst;
|
|
2904
2980
|
}
|
|
@@ -2931,29 +3007,26 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
|
|
|
2931
3007
|
rb_raise(rb_eEOFError, "end of file reached");
|
|
2932
3008
|
}
|
|
2933
3009
|
|
|
2934
|
-
dst = zstream_shift_buffer(&gz->z, len);
|
|
3010
|
+
dst = zstream_shift_buffer(&gz->z, len, outbuf);
|
|
2935
3011
|
gzfile_calc_crc(gz, dst);
|
|
2936
3012
|
|
|
2937
|
-
if (!NIL_P(outbuf)) {
|
|
2938
|
-
rb_str_resize(outbuf, RSTRING_LEN(dst));
|
|
2939
|
-
memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
|
|
2940
|
-
dst = outbuf;
|
|
2941
|
-
}
|
|
2942
3013
|
return dst;
|
|
2943
3014
|
}
|
|
2944
3015
|
|
|
2945
3016
|
static VALUE
|
|
2946
|
-
gzfile_read_all(struct gzfile *gz)
|
|
3017
|
+
gzfile_read_all(struct gzfile *gz, VALUE dst)
|
|
2947
3018
|
{
|
|
2948
|
-
VALUE dst;
|
|
2949
|
-
|
|
2950
3019
|
while (!ZSTREAM_IS_FINISHED(&gz->z)) {
|
|
2951
|
-
gzfile_read_more(gz,
|
|
3020
|
+
gzfile_read_more(gz, dst);
|
|
2952
3021
|
}
|
|
2953
3022
|
if (GZFILE_IS_FINISHED(gz)) {
|
|
2954
3023
|
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
|
2955
|
-
gzfile_check_footer(gz,
|
|
3024
|
+
gzfile_check_footer(gz, dst);
|
|
2956
3025
|
}
|
|
3026
|
+
if (!NIL_P(dst)) {
|
|
3027
|
+
rb_str_resize(dst, 0);
|
|
3028
|
+
return dst;
|
|
3029
|
+
}
|
|
2957
3030
|
return rb_str_new(0, 0);
|
|
2958
3031
|
}
|
|
2959
3032
|
|
|
@@ -2991,7 +3064,7 @@ gzfile_getc(struct gzfile *gz)
|
|
|
2991
3064
|
de = (unsigned char *)ds + GZFILE_CBUF_CAPA;
|
|
2992
3065
|
(void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT);
|
|
2993
3066
|
rb_econv_check_error(gz->ec);
|
|
2994
|
-
dst = zstream_shift_buffer(&gz->z, sp - ss);
|
|
3067
|
+
dst = zstream_shift_buffer(&gz->z, sp - ss, Qnil);
|
|
2995
3068
|
gzfile_calc_crc(gz, dst);
|
|
2996
3069
|
rb_str_resize(cbuf, dp - ds);
|
|
2997
3070
|
return cbuf;
|
|
@@ -2999,7 +3072,7 @@ gzfile_getc(struct gzfile *gz)
|
|
|
2999
3072
|
else {
|
|
3000
3073
|
buf = gz->z.buf;
|
|
3001
3074
|
len = rb_enc_mbclen(RSTRING_PTR(buf), RSTRING_END(buf), gz->enc);
|
|
3002
|
-
dst = gzfile_read(gz, len);
|
|
3075
|
+
dst = gzfile_read(gz, len, Qnil);
|
|
3003
3076
|
if (NIL_P(dst)) return dst;
|
|
3004
3077
|
return gzfile_newstr(gz, dst);
|
|
3005
3078
|
}
|
|
@@ -3907,7 +3980,7 @@ rb_gzreader_s_zcat(int argc, VALUE *argv, VALUE klass)
|
|
|
3907
3980
|
if (!buf) {
|
|
3908
3981
|
buf = rb_str_new(0, 0);
|
|
3909
3982
|
}
|
|
3910
|
-
tmpbuf = gzfile_read_all(get_gzfile(obj));
|
|
3983
|
+
tmpbuf = gzfile_read_all(get_gzfile(obj), Qnil);
|
|
3911
3984
|
rb_str_cat(buf, RSTRING_PTR(tmpbuf), RSTRING_LEN(tmpbuf));
|
|
3912
3985
|
}
|
|
3913
3986
|
|
|
@@ -4009,19 +4082,19 @@ static VALUE
|
|
|
4009
4082
|
rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
|
|
4010
4083
|
{
|
|
4011
4084
|
struct gzfile *gz = get_gzfile(obj);
|
|
4012
|
-
VALUE vlen;
|
|
4085
|
+
VALUE vlen, outbuf;
|
|
4013
4086
|
long len;
|
|
4014
4087
|
|
|
4015
|
-
rb_scan_args(argc, argv, "
|
|
4088
|
+
rb_scan_args(argc, argv, "02", &vlen, &outbuf);
|
|
4016
4089
|
if (NIL_P(vlen)) {
|
|
4017
|
-
return gzfile_read_all(gz);
|
|
4090
|
+
return gzfile_read_all(gz, outbuf);
|
|
4018
4091
|
}
|
|
4019
4092
|
|
|
4020
4093
|
len = NUM2INT(vlen);
|
|
4021
4094
|
if (len < 0) {
|
|
4022
4095
|
rb_raise(rb_eArgError, "negative length %ld given", len);
|
|
4023
4096
|
}
|
|
4024
|
-
return gzfile_read(gz, len);
|
|
4097
|
+
return gzfile_read(gz, len, outbuf);
|
|
4025
4098
|
}
|
|
4026
4099
|
|
|
4027
4100
|
/*
|
|
@@ -4030,7 +4103,7 @@ rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
|
|
|
4030
4103
|
* call-seq:
|
|
4031
4104
|
* gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
|
|
4032
4105
|
*
|
|
4033
|
-
* Reads at most <i>maxlen</i> bytes from the
|
|
4106
|
+
* Reads at most <i>maxlen</i> bytes from the gzipped stream but
|
|
4034
4107
|
* it blocks only if <em>gzipreader</em> has no data immediately available.
|
|
4035
4108
|
* If the optional <i>outbuf</i> argument is present,
|
|
4036
4109
|
* it must reference a String, which will receive the data.
|
|
@@ -4094,7 +4167,7 @@ rb_gzreader_getbyte(VALUE obj)
|
|
|
4094
4167
|
struct gzfile *gz = get_gzfile(obj);
|
|
4095
4168
|
VALUE dst;
|
|
4096
4169
|
|
|
4097
|
-
dst = gzfile_read(gz, 1);
|
|
4170
|
+
dst = gzfile_read(gz, 1, Qnil);
|
|
4098
4171
|
if (!NIL_P(dst)) {
|
|
4099
4172
|
dst = INT2FIX((unsigned int)(RSTRING_PTR(dst)[0]) & 0xff);
|
|
4100
4173
|
}
|
|
@@ -4205,6 +4278,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
|
|
|
4205
4278
|
while (n++, *(p++) == '\n') {
|
|
4206
4279
|
if (n >= ZSTREAM_BUF_FILLED(&gz->z)) {
|
|
4207
4280
|
str = zstream_detach_buffer(&gz->z);
|
|
4281
|
+
ASSUME(!NIL_P(str));
|
|
4208
4282
|
gzfile_calc_crc(gz, str);
|
|
4209
4283
|
while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
|
|
4210
4284
|
if (GZFILE_IS_FINISHED(gz)) return;
|
|
@@ -4215,7 +4289,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
|
|
|
4215
4289
|
}
|
|
4216
4290
|
}
|
|
4217
4291
|
|
|
4218
|
-
str = zstream_shift_buffer(&gz->z, n - 1);
|
|
4292
|
+
str = zstream_shift_buffer(&gz->z, n - 1, Qnil);
|
|
4219
4293
|
gzfile_calc_crc(gz, str);
|
|
4220
4294
|
}
|
|
4221
4295
|
|
|
@@ -4236,7 +4310,7 @@ gzreader_charboundary(struct gzfile *gz, long n)
|
|
|
4236
4310
|
if (l < n) {
|
|
4237
4311
|
int n_bytes = rb_enc_precise_mbclen(p, e, gz->enc);
|
|
4238
4312
|
if (MBCLEN_NEEDMORE_P(n_bytes)) {
|
|
4239
|
-
if ((l = gzfile_fill(gz, n + MBCLEN_NEEDMORE_LEN(n_bytes))) > 0) {
|
|
4313
|
+
if ((l = gzfile_fill(gz, n + MBCLEN_NEEDMORE_LEN(n_bytes), Qnil)) > 0) {
|
|
4240
4314
|
return l;
|
|
4241
4315
|
}
|
|
4242
4316
|
}
|
|
@@ -4288,10 +4362,10 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
|
|
|
4288
4362
|
|
|
4289
4363
|
if (NIL_P(rs)) {
|
|
4290
4364
|
if (limit < 0) {
|
|
4291
|
-
dst = gzfile_read_all(gz);
|
|
4365
|
+
dst = gzfile_read_all(gz, Qnil);
|
|
4292
4366
|
if (RSTRING_LEN(dst) == 0) return Qnil;
|
|
4293
4367
|
}
|
|
4294
|
-
else if ((n = gzfile_fill(gz, limit)) <= 0) {
|
|
4368
|
+
else if ((n = gzfile_fill(gz, limit, Qnil)) <= 0) {
|
|
4295
4369
|
return Qnil;
|
|
4296
4370
|
}
|
|
4297
4371
|
else {
|
|
@@ -4301,7 +4375,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
|
|
|
4301
4375
|
else {
|
|
4302
4376
|
n = limit;
|
|
4303
4377
|
}
|
|
4304
|
-
dst = zstream_shift_buffer(&gz->z, n);
|
|
4378
|
+
dst = zstream_shift_buffer(&gz->z, n, Qnil);
|
|
4305
4379
|
if (NIL_P(dst)) return dst;
|
|
4306
4380
|
gzfile_calc_crc(gz, dst);
|
|
4307
4381
|
dst = gzfile_newstr(gz, dst);
|
|
@@ -4328,7 +4402,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
|
|
|
4328
4402
|
while (ZSTREAM_BUF_FILLED(&gz->z) < rslen) {
|
|
4329
4403
|
if (ZSTREAM_IS_FINISHED(&gz->z)) {
|
|
4330
4404
|
if (ZSTREAM_BUF_FILLED(&gz->z) > 0) gz->lineno++;
|
|
4331
|
-
return gzfile_read(gz, rslen);
|
|
4405
|
+
return gzfile_read(gz, rslen, Qnil);
|
|
4332
4406
|
}
|
|
4333
4407
|
gzfile_read_more(gz, Qnil);
|
|
4334
4408
|
}
|
|
@@ -4365,7 +4439,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
|
|
|
4365
4439
|
}
|
|
4366
4440
|
|
|
4367
4441
|
gz->lineno++;
|
|
4368
|
-
dst = gzfile_read(gz, n);
|
|
4442
|
+
dst = gzfile_read(gz, n, Qnil);
|
|
4369
4443
|
if (NIL_P(dst)) return dst;
|
|
4370
4444
|
if (rspara) {
|
|
4371
4445
|
gzreader_skip_linebreaks(gz);
|
|
@@ -4613,6 +4687,7 @@ zlib_gunzip_run(VALUE arg)
|
|
|
4613
4687
|
|
|
4614
4688
|
gzfile_read_header(gz, Qnil);
|
|
4615
4689
|
dst = zstream_detach_buffer(&gz->z);
|
|
4690
|
+
ASSUME(!NIL_P(dst));
|
|
4616
4691
|
gzfile_calc_crc(gz, dst);
|
|
4617
4692
|
if (!ZSTREAM_IS_FINISHED(&gz->z)) {
|
|
4618
4693
|
rb_raise(cGzError, "unexpected end of file");
|
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: 3.
|
|
4
|
+
version: 3.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yukihiro Matsumoto
|
|
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
45
|
version: '0'
|
|
46
46
|
requirements: []
|
|
47
|
-
rubygems_version:
|
|
47
|
+
rubygems_version: 3.6.9
|
|
48
48
|
specification_version: 4
|
|
49
49
|
summary: Ruby interface for the zlib compression/decompression library
|
|
50
50
|
test_files: []
|