zlib 0.0.1 → 0.1.0

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/zlib/zlib.c +72 -94
  4. data/zlib.gemspec +3 -1
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d60efaf687f037ce7ed325d6231f4c6cb6038018
4
- data.tar.gz: 17ddee8ebcd67f9b81707e506c458bbc5d71ebce
3
+ metadata.gz: c89a988315358942a700fcaad47423267840ffe6
4
+ data.tar.gz: '0967f4982f0a1c36f43815420f05e6ef674c1252'
5
5
  SHA512:
6
- metadata.gz: 128f27173fde64a1490443eb037ec63885bdd490b5d80df635d9f27a50c5dbf5794915214e91b9b09dca3127d68695236f96c7327fa295c37d5d7629e623ebfb
7
- data.tar.gz: 9f245a7543a223501e004fe5262e53f98130bfa84b2a68dbcbb2562e6de3c9ebea5c2b762e13a404eb50dbde8da7e23417db1bf93e2bc0604264b3573a5ae589
6
+ metadata.gz: 6e1a0fee0c0f38e9fccf904f70b3f3d71753ce537bf7bee59aa390d57e548588ecc2d5253b13904e7c61c4983475e8603759e51f6bd0bed1795c7f852f9dc2aa
7
+ data.tar.gz: 92b5a9d994aa80fa3b7fc15064b3753e604ba024f37ed6258772c7e38ea84aeadb49fd2ea9054707cff0c564d873aa3cf836f46c174ce2e4adaee1e7539fd395
data/README.md CHANGED
@@ -37,4 +37,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/z
37
37
 
38
38
  ## License
39
39
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+ The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
@@ -72,6 +72,7 @@ struct zstream_run_args;
72
72
  static void zstream_init(struct zstream*, const struct zstream_funcs*);
73
73
  static void zstream_expand_buffer(struct zstream*);
74
74
  static void zstream_expand_buffer_into(struct zstream*, unsigned long);
75
+ static int zstream_expand_buffer_non_stream(struct zstream *z);
75
76
  static void zstream_append_buffer(struct zstream*, const Bytef*, long);
76
77
  static VALUE zstream_detach_buffer(struct zstream*);
77
78
  static VALUE zstream_shift_buffer(struct zstream*, long);
@@ -527,7 +528,6 @@ rb_zlib_crc_table(VALUE obj)
527
528
  struct zstream {
528
529
  unsigned long flags;
529
530
  VALUE buf;
530
- long buf_filled;
531
531
  VALUE input;
532
532
  z_stream stream;
533
533
  const struct zstream_funcs {
@@ -550,6 +550,7 @@ struct zstream {
550
550
  #define ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED)
551
551
  #define ZSTREAM_IS_CLOSING(z) ((z)->flags & ZSTREAM_FLAG_CLOSING)
552
552
  #define ZSTREAM_IS_GZFILE(z) ((z)->flags & ZSTREAM_FLAG_GZFILE)
553
+ #define ZSTREAM_BUF_FILLED(z) (NIL_P((z)->buf) ? 0 : RSTRING_LEN((z)->buf))
553
554
 
554
555
  #define ZSTREAM_EXPAND_BUFFER_OK 0
555
556
 
@@ -599,7 +600,6 @@ zstream_init(struct zstream *z, const struct zstream_funcs *func)
599
600
  {
600
601
  z->flags = 0;
601
602
  z->buf = Qnil;
602
- z->buf_filled = 0;
603
603
  z->input = Qnil;
604
604
  z->stream.zalloc = zlib_mem_alloc;
605
605
  z->stream.zfree = zlib_mem_free;
@@ -624,11 +624,11 @@ zstream_expand_buffer(struct zstream *z)
624
624
  }
625
625
 
626
626
  if (!ZSTREAM_IS_GZFILE(z) && rb_block_given_p()) {
627
- if (z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
627
+ long buf_filled = ZSTREAM_BUF_FILLED(z);
628
+ if (buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
628
629
  int state = 0;
629
630
  VALUE self = (VALUE)z->stream.opaque;
630
631
 
631
- rb_str_resize(z->buf, z->buf_filled);
632
632
  rb_obj_reveal(z->buf, rb_cString);
633
633
  OBJ_INFECT(z->buf, self);
634
634
 
@@ -644,23 +644,11 @@ zstream_expand_buffer(struct zstream *z)
644
644
  }
645
645
  else {
646
646
  zstream_expand_buffer_into(z,
647
- ZSTREAM_AVAIL_OUT_STEP_MAX - z->buf_filled);
647
+ ZSTREAM_AVAIL_OUT_STEP_MAX - buf_filled);
648
648
  }
649
649
  }
650
650
  else {
651
- if (RSTRING_LEN(z->buf) - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
652
- z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
653
- }
654
- else {
655
- long inc = z->buf_filled / 2;
656
- if (inc < ZSTREAM_AVAIL_OUT_STEP_MIN) {
657
- inc = ZSTREAM_AVAIL_OUT_STEP_MIN;
658
- }
659
- rb_str_resize(z->buf, z->buf_filled + inc);
660
- z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
661
- (int)inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
662
- }
663
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
651
+ zstream_expand_buffer_non_stream(z);
664
652
  }
665
653
  }
666
654
 
@@ -670,15 +658,14 @@ zstream_expand_buffer_into(struct zstream *z, unsigned long size)
670
658
  if (NIL_P(z->buf)) {
671
659
  /* I uses rb_str_new here not rb_str_buf_new because
672
660
  rb_str_buf_new makes a zero-length string. */
673
- z->buf = rb_str_new(0, size);
674
- z->buf_filled = 0;
661
+ z->buf = rb_str_buf_new(size);
675
662
  z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
676
663
  z->stream.avail_out = MAX_UINT(size);
677
664
  rb_obj_hide(z->buf);
678
665
  }
679
666
  else if (z->stream.avail_out != size) {
680
- rb_str_resize(z->buf, z->buf_filled + size);
681
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
667
+ rb_str_modify_expand(z->buf, size);
668
+ z->stream.next_out = (Bytef*)RSTRING_END(z->buf);
682
669
  z->stream.avail_out = MAX_UINT(size);
683
670
  }
684
671
  }
@@ -695,34 +682,24 @@ zstream_expand_buffer_protect(void *ptr)
695
682
  }
696
683
 
697
684
  static int
698
- zstream_expand_buffer_without_gvl(struct zstream *z)
685
+ zstream_expand_buffer_non_stream(struct zstream *z)
699
686
  {
700
- char * new_str;
701
- long inc, len;
687
+ long inc, len = ZSTREAM_BUF_FILLED(z);
702
688
 
703
- if (RSTRING_LEN(z->buf) - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
689
+ if (rb_str_capacity(z->buf) - len >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
704
690
  z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
705
691
  }
706
692
  else {
707
- inc = z->buf_filled / 2;
693
+ inc = len / 2;
708
694
  if (inc < ZSTREAM_AVAIL_OUT_STEP_MIN) {
709
695
  inc = ZSTREAM_AVAIL_OUT_STEP_MIN;
710
696
  }
711
697
 
712
- len = z->buf_filled + inc;
713
-
714
- new_str = ruby_xrealloc(RSTRING(z->buf)->as.heap.ptr, len + 1);
715
-
716
- /* from rb_str_resize */
717
- RSTRING(z->buf)->as.heap.ptr = new_str;
718
- RSTRING(z->buf)->as.heap.ptr[len] = '\0'; /* sentinel */
719
- RSTRING(z->buf)->as.heap.len =
720
- RSTRING(z->buf)->as.heap.aux.capa = len;
721
-
698
+ rb_str_modify_expand(z->buf, inc);
722
699
  z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
723
700
  (int)inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
724
701
  }
725
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
702
+ z->stream.next_out = (Bytef*)RSTRING_END(z->buf);
726
703
 
727
704
  return ZSTREAM_EXPAND_BUFFER_OK;
728
705
  }
@@ -733,15 +710,14 @@ zstream_append_buffer(struct zstream *z, const Bytef *src, long len)
733
710
  if (NIL_P(z->buf)) {
734
711
  z->buf = rb_str_buf_new(len);
735
712
  rb_str_buf_cat(z->buf, (const char*)src, len);
736
- z->buf_filled = len;
737
713
  z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
738
714
  z->stream.avail_out = 0;
739
715
  rb_obj_hide(z->buf);
740
716
  return;
741
717
  }
742
718
 
743
- if (RSTRING_LEN(z->buf) < z->buf_filled + len) {
744
- rb_str_resize(z->buf, z->buf_filled + len);
719
+ if ((long)rb_str_capacity(z->buf) < ZSTREAM_BUF_FILLED(z) + len) {
720
+ rb_str_modify_expand(z->buf, len);
745
721
  z->stream.avail_out = 0;
746
722
  }
747
723
  else {
@@ -752,9 +728,8 @@ zstream_append_buffer(struct zstream *z, const Bytef *src, long len)
752
728
  z->stream.avail_out = 0;
753
729
  }
754
730
  }
755
- memcpy(RSTRING_PTR(z->buf) + z->buf_filled, src, len);
756
- z->buf_filled += len;
757
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
731
+ rb_str_cat(z->buf, (const char *)src, len);
732
+ z->stream.next_out = (Bytef*)RSTRING_END(z->buf);
758
733
  }
759
734
 
760
735
  #define zstream_append_buffer2(z,v) \
@@ -777,14 +752,12 @@ zstream_detach_buffer(struct zstream *z)
777
752
  }
778
753
  else {
779
754
  dst = z->buf;
780
- rb_str_resize(dst, z->buf_filled);
781
755
  rb_obj_reveal(dst, rb_cString);
782
756
  }
783
757
 
784
758
  OBJ_INFECT(dst, self);
785
759
 
786
760
  z->buf = Qnil;
787
- z->buf_filled = 0;
788
761
  z->stream.next_out = 0;
789
762
  z->stream.avail_out = 0;
790
763
 
@@ -800,18 +773,20 @@ static VALUE
800
773
  zstream_shift_buffer(struct zstream *z, long len)
801
774
  {
802
775
  VALUE dst;
803
- long buflen;
776
+ char *bufptr;
777
+ long buflen = ZSTREAM_BUF_FILLED(z);
804
778
 
805
- if (z->buf_filled <= len) {
779
+ if (buflen <= len) {
806
780
  return zstream_detach_buffer(z);
807
781
  }
808
782
 
809
- dst = rb_str_new(RSTRING_PTR(z->buf), len);
810
- z->buf_filled -= len;
811
- memmove(RSTRING_PTR(z->buf), RSTRING_PTR(z->buf) + len,
812
- z->buf_filled);
813
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
814
- buflen = RSTRING_LEN(z->buf) - z->buf_filled;
783
+ bufptr = RSTRING_PTR(z->buf);
784
+ dst = rb_str_new(bufptr, len);
785
+ buflen -= len;
786
+ memmove(bufptr, bufptr + len, buflen);
787
+ rb_str_set_len(z->buf, buflen);
788
+ z->stream.next_out = (Bytef*)RSTRING_END(z->buf);
789
+ buflen = (long)rb_str_capacity(z->buf) - ZSTREAM_BUF_FILLED(z);
815
790
  if (buflen > ZSTREAM_AVAIL_OUT_STEP_MAX) {
816
791
  buflen = ZSTREAM_AVAIL_OUT_STEP_MAX;
817
792
  }
@@ -823,13 +798,17 @@ zstream_shift_buffer(struct zstream *z, long len)
823
798
  static void
824
799
  zstream_buffer_ungets(struct zstream *z, const Bytef *b, unsigned long len)
825
800
  {
826
- if (NIL_P(z->buf) || RSTRING_LEN(z->buf) - z->buf_filled == 0) {
801
+ char *bufptr;
802
+ long filled;
803
+
804
+ if (NIL_P(z->buf) || (long)rb_str_capacity(z->buf) <= ZSTREAM_BUF_FILLED(z)) {
827
805
  zstream_expand_buffer_into(z, len);
828
806
  }
829
807
 
830
- memmove(RSTRING_PTR(z->buf) + len, RSTRING_PTR(z->buf), z->buf_filled);
831
- memmove(RSTRING_PTR(z->buf), b, len);
832
- z->buf_filled+=len;
808
+ RSTRING_GETMEM(z->buf, bufptr, filled);
809
+ memmove(bufptr + len, bufptr, filled);
810
+ memmove(bufptr, b, len);
811
+ rb_str_set_len(z->buf, filled + len);
833
812
  if (z->stream.avail_out > 0) {
834
813
  if (len > z->stream.avail_out) len = z->stream.avail_out;
835
814
  z->stream.next_out+=len;
@@ -840,17 +819,8 @@ zstream_buffer_ungets(struct zstream *z, const Bytef *b, unsigned long len)
840
819
  static void
841
820
  zstream_buffer_ungetbyte(struct zstream *z, int c)
842
821
  {
843
- if (NIL_P(z->buf) || RSTRING_LEN(z->buf) - z->buf_filled == 0) {
844
- zstream_expand_buffer(z);
845
- }
846
-
847
- memmove(RSTRING_PTR(z->buf) + 1, RSTRING_PTR(z->buf), z->buf_filled);
848
- RSTRING_PTR(z->buf)[0] = (char)c;
849
- z->buf_filled++;
850
- if (z->stream.avail_out > 0) {
851
- z->stream.next_out++;
852
- z->stream.avail_out--;
853
- }
822
+ Bytef cc = (Bytef)c;
823
+ zstream_buffer_ungets(z, &cc, 1);
854
824
  }
855
825
 
856
826
  static void
@@ -927,7 +897,6 @@ zstream_reset(struct zstream *z)
927
897
  }
928
898
  z->flags = ZSTREAM_FLAG_READY;
929
899
  z->buf = Qnil;
930
- z->buf_filled = 0;
931
900
  z->stream.next_out = 0;
932
901
  z->stream.avail_out = 0;
933
902
  zstream_reset_input(z);
@@ -968,7 +937,7 @@ zstream_run_func(void *ptr)
968
937
  while (!args->interrupt) {
969
938
  n = z->stream.avail_out;
970
939
  err = z->func->run(&z->stream, flush);
971
- z->buf_filled += n - z->stream.avail_out;
940
+ rb_str_set_len(z->buf, ZSTREAM_BUF_FILLED(z) + (n - z->stream.avail_out));
972
941
 
973
942
  if (err == Z_STREAM_END) {
974
943
  z->flags &= ~ZSTREAM_FLAG_IN_STREAM;
@@ -997,7 +966,7 @@ zstream_run_func(void *ptr)
997
966
  (void *)z);
998
967
  }
999
968
  else {
1000
- state = zstream_expand_buffer_without_gvl(z);
969
+ state = zstream_expand_buffer_non_stream(z);
1001
970
  }
1002
971
 
1003
972
  if (state) {
@@ -1577,7 +1546,6 @@ rb_deflate_init_copy(VALUE self, VALUE orig)
1577
1546
  }
1578
1547
  z1->input = NIL_P(z2->input) ? Qnil : rb_str_dup(z2->input);
1579
1548
  z1->buf = NIL_P(z2->buf) ? Qnil : rb_str_dup(z2->buf);
1580
- z1->buf_filled = z2->buf_filled;
1581
1549
  z1->flags = z2->flags;
1582
1550
 
1583
1551
  return self;
@@ -1761,23 +1729,26 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
1761
1729
  int level, strategy;
1762
1730
  int err;
1763
1731
  uInt n;
1732
+ long filled;
1764
1733
 
1765
1734
  level = ARG_LEVEL(v_level);
1766
1735
  strategy = ARG_STRATEGY(v_strategy);
1767
1736
 
1768
1737
  n = z->stream.avail_out;
1769
1738
  err = deflateParams(&z->stream, level, strategy);
1770
- z->buf_filled += n - z->stream.avail_out;
1739
+ filled = n - z->stream.avail_out;
1771
1740
  while (err == Z_BUF_ERROR) {
1772
1741
  rb_warning("deflateParams() returned Z_BUF_ERROR");
1773
1742
  zstream_expand_buffer(z);
1743
+ rb_str_set_len(z->buf, RSTRING_LEN(z->buf) + filled);
1774
1744
  n = z->stream.avail_out;
1775
1745
  err = deflateParams(&z->stream, level, strategy);
1776
- z->buf_filled += n - z->stream.avail_out;
1746
+ filled = n - z->stream.avail_out;
1777
1747
  }
1778
1748
  if (err != Z_OK) {
1779
1749
  raise_zlib_error(err, z->stream.msg);
1780
1750
  }
1751
+ rb_str_set_len(z->buf, RSTRING_LEN(z->buf) + filled);
1781
1752
 
1782
1753
  return Qnil;
1783
1754
  }
@@ -2230,7 +2201,7 @@ struct gzfile {
2230
2201
  #define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
2231
2202
 
2232
2203
  #define GZFILE_IS_FINISHED(gz) \
2233
- (ZSTREAM_IS_FINISHED(&(gz)->z) && (gz)->z.buf_filled == 0)
2204
+ (ZSTREAM_IS_FINISHED(&(gz)->z) && ZSTREAM_BUF_FILLED(&(gz)->z) == 0)
2234
2205
 
2235
2206
  #define GZFILE_READ_SIZE 2048
2236
2207
 
@@ -2356,7 +2327,7 @@ gzfile_write_raw(struct gzfile *gz)
2356
2327
  {
2357
2328
  VALUE str;
2358
2329
 
2359
- if (gz->z.buf_filled > 0) {
2330
+ if (ZSTREAM_BUF_FILLED(&gz->z) > 0) {
2360
2331
  str = zstream_detach_buffer(&gz->z);
2361
2332
  OBJ_TAINT(str); /* for safe */
2362
2333
  rb_funcall(gz->io, id_write, 1, str);
@@ -2689,9 +2660,9 @@ gzfile_read_more(struct gzfile *gz)
2689
2660
  Z_SYNC_FLUSH);
2690
2661
  RB_GC_GUARD(str);
2691
2662
  }
2692
- if (gz->z.buf_filled > 0) break;
2663
+ if (ZSTREAM_BUF_FILLED(&gz->z) > 0) break;
2693
2664
  }
2694
- return gz->z.buf_filled;
2665
+ return ZSTREAM_BUF_FILLED(&gz->z);
2695
2666
  }
2696
2667
 
2697
2668
  static void
@@ -2732,7 +2703,7 @@ gzfile_fill(struct gzfile *gz, long len)
2732
2703
  rb_raise(rb_eArgError, "negative length %ld given", len);
2733
2704
  if (len == 0)
2734
2705
  return 0;
2735
- while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled < len) {
2706
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
2736
2707
  gzfile_read_more(gz);
2737
2708
  }
2738
2709
  if (GZFILE_IS_FINISHED(gz)) {
@@ -2741,7 +2712,7 @@ gzfile_fill(struct gzfile *gz, long len)
2741
2712
  }
2742
2713
  return -1;
2743
2714
  }
2744
- return len < gz->z.buf_filled ? len : gz->z.buf_filled;
2715
+ return len < ZSTREAM_BUF_FILLED(&gz->z) ? len : ZSTREAM_BUF_FILLED(&gz->z);
2745
2716
  }
2746
2717
 
2747
2718
  static VALUE
@@ -2776,7 +2747,7 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
2776
2747
  return outbuf;
2777
2748
  }
2778
2749
  }
2779
- while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled == 0) {
2750
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) == 0) {
2780
2751
  gzfile_read_more(gz);
2781
2752
  }
2782
2753
  if (GZFILE_IS_FINISHED(gz)) {
@@ -2830,7 +2801,7 @@ gzfile_getc(struct gzfile *gz)
2830
2801
  int len;
2831
2802
 
2832
2803
  len = rb_enc_mbmaxlen(gz->enc);
2833
- while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled < len) {
2804
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
2834
2805
  gzfile_read_more(gz);
2835
2806
  }
2836
2807
  if (GZFILE_IS_FINISHED(gz)) {
@@ -2848,7 +2819,7 @@ gzfile_getc(struct gzfile *gz)
2848
2819
  gz->cbuf = ALLOC_N(char, GZFILE_CBUF_CAPA);
2849
2820
  }
2850
2821
  ss = sp = (const unsigned char*)RSTRING_PTR(gz->z.buf);
2851
- se = sp + gz->z.buf_filled;
2822
+ se = sp + ZSTREAM_BUF_FILLED(&gz->z);
2852
2823
  ds = dp = (unsigned char *)gz->cbuf;
2853
2824
  de = (unsigned char *)ds + GZFILE_CBUF_CAPA;
2854
2825
  (void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT);
@@ -3422,7 +3393,14 @@ static VALUE
3422
3393
  rb_gzfile_total_out(VALUE obj)
3423
3394
  {
3424
3395
  struct gzfile *gz = get_gzfile(obj);
3425
- return rb_uint2inum(gz->z.stream.total_out - gz->z.buf_filled);
3396
+ uLong total_out = gz->z.stream.total_out;
3397
+ long buf_filled = ZSTREAM_BUF_FILLED(&gz->z);
3398
+
3399
+ if (total_out >= (uLong)buf_filled) {
3400
+ return rb_uint2inum(total_out - buf_filled);
3401
+ } else {
3402
+ return LONG2FIX(-(buf_filled - (long)total_out));
3403
+ }
3426
3404
  }
3427
3405
 
3428
3406
  /*
@@ -3996,7 +3974,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
3996
3974
  char *p;
3997
3975
  int n;
3998
3976
 
3999
- while (gz->z.buf_filled == 0) {
3977
+ while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
4000
3978
  if (GZFILE_IS_FINISHED(gz)) return;
4001
3979
  gzfile_read_more(gz);
4002
3980
  }
@@ -4004,10 +3982,10 @@ gzreader_skip_linebreaks(struct gzfile *gz)
4004
3982
  p = RSTRING_PTR(gz->z.buf);
4005
3983
 
4006
3984
  while (n++, *(p++) == '\n') {
4007
- if (n >= gz->z.buf_filled) {
3985
+ if (n >= ZSTREAM_BUF_FILLED(&gz->z)) {
4008
3986
  str = zstream_detach_buffer(&gz->z);
4009
3987
  gzfile_calc_crc(gz, str);
4010
- while (gz->z.buf_filled == 0) {
3988
+ while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
4011
3989
  if (GZFILE_IS_FINISHED(gz)) return;
4012
3990
  gzfile_read_more(gz);
4013
3991
  }
@@ -4031,7 +4009,7 @@ static long
4031
4009
  gzreader_charboundary(struct gzfile *gz, long n)
4032
4010
  {
4033
4011
  char *s = RSTRING_PTR(gz->z.buf);
4034
- char *e = s + gz->z.buf_filled;
4012
+ char *e = s + ZSTREAM_BUF_FILLED(&gz->z);
4035
4013
  char *p = rb_enc_left_char_head(s, s + n, e, gz->enc);
4036
4014
  long l = p - s;
4037
4015
  if (l < n) {
@@ -4126,9 +4104,9 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
4126
4104
  gzreader_skip_linebreaks(gz);
4127
4105
  }
4128
4106
 
4129
- while (gz->z.buf_filled < rslen) {
4107
+ while (ZSTREAM_BUF_FILLED(&gz->z) < rslen) {
4130
4108
  if (ZSTREAM_IS_FINISHED(&gz->z)) {
4131
- if (gz->z.buf_filled > 0) gz->lineno++;
4109
+ if (ZSTREAM_BUF_FILLED(&gz->z) > 0) gz->lineno++;
4132
4110
  return gzfile_read(gz, rslen);
4133
4111
  }
4134
4112
  gzfile_read_more(gz);
@@ -4138,13 +4116,13 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
4138
4116
  n = rslen;
4139
4117
  for (;;) {
4140
4118
  long filled;
4141
- if (n > gz->z.buf_filled) {
4119
+ if (n > ZSTREAM_BUF_FILLED(&gz->z)) {
4142
4120
  if (ZSTREAM_IS_FINISHED(&gz->z)) break;
4143
4121
  gzfile_read_more(gz);
4144
4122
  p = RSTRING_PTR(gz->z.buf) + n - rslen;
4145
4123
  }
4146
4124
  if (!rspara) rscheck(rsptr, rslen, rs);
4147
- filled = gz->z.buf_filled;
4125
+ filled = ZSTREAM_BUF_FILLED(&gz->z);
4148
4126
  if (limit > 0 && filled >= limit) {
4149
4127
  filled = limit;
4150
4128
  }
@@ -4161,7 +4139,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
4161
4139
  p++, n++;
4162
4140
  }
4163
4141
  }
4164
- if (maxlen > 1 && n == limit && (gz->z.buf_filled > n || !ZSTREAM_IS_FINISHED(&gz->z))) {
4142
+ if (maxlen > 1 && n == limit && (ZSTREAM_BUF_FILLED(&gz->z) > n || !ZSTREAM_IS_FINISHED(&gz->z))) {
4165
4143
  n = gzreader_charboundary(gz, n);
4166
4144
  }
4167
4145
 
@@ -1,7 +1,9 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  Gem::Specification.new do |spec|
3
4
  spec.name = "zlib"
4
- spec.version = "0.0.1"
5
+ spec.version = "0.1.0"
6
+ spec.date = '2017-09-13'
5
7
  spec.authors = ["Yukihiro Matsumoto", "UENO Katsuhiro"]
6
8
  spec.email = ["matz@ruby-lang.org", nil]
7
9
 
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: 0.0.1
4
+ version: 0.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: 2017-05-11 00:00:00.000000000 Z
12
+ date: 2017-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.6.12
96
+ rubygems_version: 2.6.13
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Ruby interface for the zlib compression/decompression library