zstdlib 0.1.1-x64-mingw32 → 0.1.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f2de100633dcb53e30130bd57ea22fc33b41c97ad52c40ccc9fab03ea04ece2
4
- data.tar.gz: 23eb114a96ef1a18f2efa637eec8536ad6bf984ca2ce3a609dcf946067dc9047
3
+ metadata.gz: 22dde9d0561a77e919a514c52648b1a398ee546c16032f0b82e39eb7d61aa4e0
4
+ data.tar.gz: 92173294999653ce6bcb02430f79b6b0ac706127daab936cdeed29da7c5da226
5
5
  SHA512:
6
- metadata.gz: 4ff53a115a045bfd4700c16d7fd6cdf3b9339c2ca82b52163e1ffcd8512faf79cad4ab3a598e1f3efeaac44c109a15ecc39b35f1b34624b0e797eed6b6369288
7
- data.tar.gz: 56f869456b6c5a4974cd43b9324e723692411e3198b13cd6f972c1fb6c6ce003acac4e1d36a1d905e1ca98cfbae9a3b703a26fda7664eee31c90a234664dedf0
6
+ metadata.gz: 0f176af2c7d0acdecfbee258a656a6c9d81ea43d5bedecc7764004285f5db2eb0055e98e91cf42b954511d33d71dee288f52c22f8b44d878025b4fd2964028a0
7
+ data.tar.gz: 7b7fc72b08f4cfe8977e83fbab7a93c34be1320ff41519ac878947553c4f7e4024c25f4468f0654795c74ca97efd37fdeb1b8bb822a520dcafc77bb01b233da3
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.1.2
2
+
3
+ Implemented `Zstdlib::ZSTD_VERSION` constant and `Zstdlib.zstd_version` module method for Zstd version retrieval.
4
+
5
+ Documentation updates.
6
+
7
+
1
8
  # 0.1.1
2
9
 
3
10
  Pick up the most recent compatible source for _zstdlib_ Ruby extension module instead of target Ruby version.
@@ -8,6 +15,7 @@ Fixed a few missing methods on Ruby side.
8
15
 
9
16
  Documentation updates.
10
17
 
18
+
11
19
  # 0.1.0
12
20
 
13
21
  Initial release.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [Zstdlib](https://bitbucket.org/fougas/zstdlib) - a Zstd (de)compression library binding for Ruby
1
+ # [Zstdlib](https://bitbucket.org/fougas/zstdlib) - a Zstandard data compression library binding for Ruby
2
2
 
3
3
  _zstdlib_ is native Ruby extension for [Zstandard](https://facebook.github.io/zstd/) data compression library.
4
4
 
@@ -17,7 +17,7 @@ Streams produced by `Zstdlib::Deflate` can be decompressed with standard _zstd_
17
17
  ### Simple string compression
18
18
  ````ruby
19
19
  require 'zstdlib'
20
- data = Zstdlib.deflate('Hello, Zstd!')
20
+ data = Zstdlib.deflate('Hello Zstd')
21
21
  ````
22
22
 
23
23
  ### Incremental data compression
@@ -47,6 +47,9 @@ _zstdlib_ covers the following parts of _zlib_:
47
47
  Note that _zstdlib_ currently omits Gzip file support with its `GzipFile`, `GzipReader` and `GzipWriter` classes
48
48
  and associated constants although this may be changed in future.
49
49
 
50
+ There exist `Zstdlib::ZSTD_VERSION` constant and `Zstdlib.zstd_version` module method which can be used to obtain shipped Zstd library version.
51
+
52
+
50
53
  ### General guidelines
51
54
 
52
55
  In order to enable Zstd (de)compression capability in existing code, simply replace _zlib_ with _zstdlib_ in require statements and
@@ -18,17 +18,7 @@ zlib = File.expand_path "zlib-#{ZLIB_VERSION}", root
18
18
  zstd = File.expand_path "zstd-#{ZSTD_VERSION}/lib", root
19
19
  zlibwrapper = File.expand_path "zstd-#{ZSTD_VERSION}/zlibWrapper", root
20
20
 
21
- File.open('zstdlib.c', 'w') do |file|
22
- file << %~\n#include <zstd.h>\n~
23
- file << File.read("#{zmod}/zlib.c").
24
- gsub(%~Init_zlib~, %~Init_zstdlib~).
25
- gsub(/"([Zz])lib"/, '"\1stdlib"').
26
- gsub(/Zlib(\.|::)/, 'Zstdlib\1').
27
- gsub(%~<zlib.h>~, %~<zstd_zlibwrapper.h>~).
28
- gsub(%~Z_DEFAULT_COMPRESSION~, %~ZSTD_CLEVEL_DEFAULT~).
29
- gsub(%~Z_BEST_COMPRESSION~, %~ZSTD_maxCLevel()~)
30
- file << %~\n/* Ruby: #{RB_VERSION} Zlib: #{ZMOD_VERSION} */\n~
31
- end
21
+ cp "#{zmod}/zstdlib.c", 'zstdlib.c'
32
22
 
33
23
  $srcs = ['zstdlib.c']
34
24
 
@@ -1,3 +1,4 @@
1
+ #include <zstd.h>
1
2
  /*
2
3
  * zlib.c - An interface for zlib.
3
4
  *
@@ -7,7 +8,7 @@
7
8
  */
8
9
 
9
10
  #include <ruby.h>
10
- #include <zlib.h>
11
+ #include <zstd_zlibwrapper.h>
11
12
  #include <time.h>
12
13
  #include <ruby/io.h>
13
14
  #include <ruby/thread.h>
@@ -251,48 +252,48 @@ static VALUE rb_gzreader_readlines(int, VALUE*, VALUE);
251
252
  * Using the wrapper to compress strings with default parameters is quite
252
253
  * simple:
253
254
  *
254
- * require "zlib"
255
+ * require "zstdlib"
255
256
  *
256
257
  * data_to_compress = File.read("don_quixote.txt")
257
258
  *
258
259
  * puts "Input size: #{data_to_compress.size}"
259
260
  * #=> Input size: 2347740
260
261
  *
261
- * data_compressed = Zlib::Deflate.deflate(data_to_compress)
262
+ * data_compressed = Zstdlib::Deflate.deflate(data_to_compress)
262
263
  *
263
264
  * puts "Compressed size: #{data_compressed.size}"
264
265
  * #=> Compressed size: 887238
265
266
  *
266
- * uncompressed_data = Zlib::Inflate.inflate(data_compressed)
267
+ * uncompressed_data = Zstdlib::Inflate.inflate(data_compressed)
267
268
  *
268
269
  * puts "Uncompressed data is: #{uncompressed_data}"
269
270
  * #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
270
271
  *
271
272
  * == Class tree
272
273
  *
273
- * - Zlib::Deflate
274
- * - Zlib::Inflate
275
- * - Zlib::ZStream
276
- * - Zlib::Error
277
- * - Zlib::StreamEnd
278
- * - Zlib::NeedDict
279
- * - Zlib::DataError
280
- * - Zlib::StreamError
281
- * - Zlib::MemError
282
- * - Zlib::BufError
283
- * - Zlib::VersionError
274
+ * - Zstdlib::Deflate
275
+ * - Zstdlib::Inflate
276
+ * - Zstdlib::ZStream
277
+ * - Zstdlib::Error
278
+ * - Zstdlib::StreamEnd
279
+ * - Zstdlib::NeedDict
280
+ * - Zstdlib::DataError
281
+ * - Zstdlib::StreamError
282
+ * - Zstdlib::MemError
283
+ * - Zstdlib::BufError
284
+ * - Zstdlib::VersionError
284
285
  *
285
286
  * (if you have GZIP_SUPPORT)
286
- * - Zlib::GzipReader
287
- * - Zlib::GzipWriter
288
- * - Zlib::GzipFile
289
- * - Zlib::GzipFile::Error
290
- * - Zlib::GzipFile::LengthError
291
- * - Zlib::GzipFile::CRCError
292
- * - Zlib::GzipFile::NoFooter
287
+ * - Zstdlib::GzipReader
288
+ * - Zstdlib::GzipWriter
289
+ * - Zstdlib::GzipFile
290
+ * - Zstdlib::GzipFile::Error
291
+ * - Zstdlib::GzipFile::LengthError
292
+ * - Zstdlib::GzipFile::CRCError
293
+ * - Zstdlib::GzipFile::NoFooter
293
294
  *
294
295
  */
295
- void Init_zlib(void);
296
+ void Init_zstdlib(void);
296
297
 
297
298
  /*--------- Exceptions --------*/
298
299
 
@@ -352,9 +353,22 @@ finalizer_warn(const char *msg)
352
353
 
353
354
 
354
355
  /*-------- module Zlib --------*/
356
+ /*
357
+ * Document-method: Zstdlib.zstd_version
358
+ *
359
+ * Returns the string which represents the version of zstd library.
360
+ */
361
+ static VALUE
362
+ rb_zstd_version(VALUE klass)
363
+ {
364
+ VALUE str;
365
+ str = rb_str_new2(ZSTD_versionString());
366
+ OBJ_TAINT(str);
367
+ return str;
368
+ }
355
369
 
356
370
  /*
357
- * Document-method: Zlib.zlib_version
371
+ * Document-method: Zstdlib.zlib_version
358
372
  *
359
373
  * Returns the string which represents the version of zlib library.
360
374
  */
@@ -418,9 +432,9 @@ do_checksum(argc, argv, func)
418
432
  }
419
433
 
420
434
  /*
421
- * Document-method: Zlib.adler32
435
+ * Document-method: Zstdlib.adler32
422
436
  *
423
- * call-seq: Zlib.adler32(string, adler)
437
+ * call-seq: Zstdlib.adler32(string, adler)
424
438
  *
425
439
  * Calculates Adler-32 checksum for +string+, and returns updated value of
426
440
  * +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
@@ -428,10 +442,10 @@ do_checksum(argc, argv, func)
428
442
  *
429
443
  * Example usage:
430
444
  *
431
- * require "zlib"
445
+ * require "zstdlib"
432
446
  *
433
447
  * data = "foo"
434
- * puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}"
448
+ * puts "Adler32 checksum: #{Zstdlib.adler32(data).to_s(16)}"
435
449
  * #=> Adler32 checksum: 2820145
436
450
  *
437
451
  */
@@ -443,9 +457,9 @@ rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
443
457
 
444
458
  #ifdef HAVE_ADLER32_COMBINE
445
459
  /*
446
- * Document-method: Zlib.adler32_combine
460
+ * Document-method: Zstdlib.adler32_combine
447
461
  *
448
- * call-seq: Zlib.adler32_combine(adler1, adler2, len2)
462
+ * call-seq: Zstdlib.adler32_combine(adler1, adler2, len2)
449
463
  *
450
464
  * Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32
451
465
  * value, +adler2+ is the second Adler-32 value. +len2+ is the length of the
@@ -463,9 +477,9 @@ rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2)
463
477
  #endif
464
478
 
465
479
  /*
466
- * Document-method: Zlib.crc32
480
+ * Document-method: Zstdlib.crc32
467
481
  *
468
- * call-seq: Zlib.crc32(string, crc)
482
+ * call-seq: Zstdlib.crc32(string, crc)
469
483
  *
470
484
  * Calculates CRC checksum for +string+, and returns updated value of +crc+. If
471
485
  * +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it
@@ -481,9 +495,9 @@ rb_zlib_crc32(int argc, VALUE *argv, VALUE klass)
481
495
 
482
496
  #ifdef HAVE_CRC32_COMBINE
483
497
  /*
484
- * Document-method: Zlib.crc32_combine
498
+ * Document-method: Zstdlib.crc32_combine
485
499
  *
486
- * call-seq: Zlib.crc32_combine(crc1, crc2, len2)
500
+ * call-seq: Zstdlib.crc32_combine(crc1, crc2, len2)
487
501
  *
488
502
  * Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32
489
503
  * value, +crc2+ is the second CRC-32 value. +len2+ is the length of the
@@ -501,7 +515,7 @@ rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2)
501
515
  #endif
502
516
 
503
517
  /*
504
- * Document-method: Zlib.crc_table
518
+ * Document-method: Zstdlib.crc_table
505
519
  *
506
520
  * Returns the table for calculating CRC checksum as an array.
507
521
  */
@@ -1207,19 +1221,19 @@ get_zstream(VALUE obj)
1207
1221
  /* ------------------------------------------------------------------------- */
1208
1222
 
1209
1223
  /*
1210
- * Document-class: Zlib::ZStream
1224
+ * Document-class: Zstdlib::ZStream
1211
1225
  *
1212
- * Zlib::ZStream is the abstract class for the stream which handles the
1226
+ * Zstdlib::ZStream is the abstract class for the stream which handles the
1213
1227
  * compressed data. The operations are defined in the subclasses:
1214
- * Zlib::Deflate for compression, and Zlib::Inflate for decompression.
1228
+ * Zstdlib::Deflate for compression, and Zstdlib::Inflate for decompression.
1215
1229
  *
1216
- * An instance of Zlib::ZStream has one stream (struct zstream in the source)
1230
+ * An instance of Zstdlib::ZStream has one stream (struct zstream in the source)
1217
1231
  * and two variable-length buffers which associated to the input (next_in) of
1218
1232
  * the stream and the output (next_out) of the stream. In this document,
1219
1233
  * "input buffer" means the buffer for input, and "output buffer" means the
1220
1234
  * buffer for output.
1221
1235
  *
1222
- * Data input into an instance of Zlib::ZStream are temporally stored into
1236
+ * Data input into an instance of Zstdlib::ZStream are temporally stored into
1223
1237
  * the end of input buffer, and then data in input buffer are processed from
1224
1238
  * the beginning of the buffer until no more output from the stream is
1225
1239
  * produced (i.e. until avail_out > 0 after processing). During processing,
@@ -1231,7 +1245,7 @@ get_zstream(VALUE obj)
1231
1245
  *
1232
1246
  * Here is an ascii art for describing above:
1233
1247
  *
1234
- * +================ an instance of Zlib::ZStream ================+
1248
+ * +================ an instance of Zstdlib::ZStream ================+
1235
1249
  * || ||
1236
1250
  * || +--------+ +-------+ +--------+ ||
1237
1251
  * || +--| output |<---------|zstream|<---------| input |<--+ ||
@@ -1244,15 +1258,15 @@ get_zstream(VALUE obj)
1244
1258
  * "output data" "input data"
1245
1259
  *
1246
1260
  * If an error occurs during processing input buffer, an exception which is a
1247
- * subclass of Zlib::Error is raised. At that time, both input and output
1261
+ * subclass of Zstdlib::Error is raised. At that time, both input and output
1248
1262
  * buffer keep their conditions at the time when the error occurs.
1249
1263
  *
1250
1264
  * == Method Catalogue
1251
1265
  *
1252
1266
  * Many of the methods in this class are fairly low-level and unlikely to be
1253
1267
  * of interest to users. In fact, users are unlikely to use this class
1254
- * directly; rather they will be interested in Zlib::Inflate and
1255
- * Zlib::Deflate.
1268
+ * directly; rather they will be interested in Zstdlib::Inflate and
1269
+ * Zstdlib::Deflate.
1256
1270
  *
1257
1271
  * The higher level methods are listed below.
1258
1272
  *
@@ -1445,9 +1459,9 @@ rb_zstream_closed_p(VALUE obj)
1445
1459
  /* ------------------------------------------------------------------------- */
1446
1460
 
1447
1461
  /*
1448
- * Document-class: Zlib::Deflate
1462
+ * Document-class: Zstdlib::Deflate
1449
1463
  *
1450
- * Zlib::Deflate is the class for compressing data. See Zlib::ZStream for more
1464
+ * Zstdlib::Deflate is the class for compressing data. See Zstdlib::ZStream for more
1451
1465
  * information.
1452
1466
  */
1453
1467
 
@@ -1455,7 +1469,7 @@ rb_zstream_closed_p(VALUE obj)
1455
1469
  (NIL_P((val)) ? (ifnil) \
1456
1470
  : ((void)Check_Type((val), T_FIXNUM), FIX2INT((val))))
1457
1471
 
1458
- #define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
1472
+ #define ARG_LEVEL(val) FIXNUMARG((val), ZSTD_CLEVEL_DEFAULT)
1459
1473
  #define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
1460
1474
  #define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
1461
1475
  #define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
@@ -1469,10 +1483,10 @@ rb_deflate_s_allocate(VALUE klass)
1469
1483
  }
1470
1484
 
1471
1485
  /*
1472
- * Document-method: Zlib::Deflate.new
1486
+ * Document-method: Zstdlib::Deflate.new
1473
1487
  *
1474
1488
  * call-seq:
1475
- * Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY)
1489
+ * Zstdlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY)
1476
1490
  *
1477
1491
  * Creates a new deflate stream for compression. If a given argument is nil,
1478
1492
  * the default value of that argument is used.
@@ -1481,10 +1495,10 @@ rb_deflate_s_allocate(VALUE klass)
1481
1495
  * compression) and 9 (best compression). The following constants have been
1482
1496
  * defined to make code more readable:
1483
1497
  *
1484
- * * Zlib::DEFAULT_COMPRESSION
1485
- * * Zlib::NO_COMPRESSION
1486
- * * Zlib::BEST_SPEED
1487
- * * Zlib::BEST_COMPRESSION
1498
+ * * Zstdlib::DEFAULT_COMPRESSION
1499
+ * * Zstdlib::NO_COMPRESSION
1500
+ * * Zstdlib::BEST_SPEED
1501
+ * * Zstdlib::BEST_COMPRESSION
1488
1502
  *
1489
1503
  * See http://www.zlib.net/manual.html#Constants for further information.
1490
1504
  *
@@ -1497,17 +1511,17 @@ rb_deflate_s_allocate(VALUE klass)
1497
1511
  * compression ratio while 9 uses maximum memory for optimal speed. The
1498
1512
  * default value is 8. Two constants are defined:
1499
1513
  *
1500
- * * Zlib::DEF_MEM_LEVEL
1501
- * * Zlib::MAX_MEM_LEVEL
1514
+ * * Zstdlib::DEF_MEM_LEVEL
1515
+ * * Zstdlib::MAX_MEM_LEVEL
1502
1516
  *
1503
1517
  * The +strategy+ sets the deflate compression strategy. The following
1504
1518
  * strategies are available:
1505
1519
  *
1506
- * Zlib::DEFAULT_STRATEGY:: For normal data
1507
- * Zlib::FILTERED:: For data produced by a filter or predictor
1508
- * Zlib::FIXED:: Prevents dynamic Huffman codes
1509
- * Zlib::HUFFMAN_ONLY:: Prevents string matching
1510
- * Zlib::RLE:: Designed for better compression of PNG image data
1520
+ * Zstdlib::DEFAULT_STRATEGY:: For normal data
1521
+ * Zstdlib::FILTERED:: For data produced by a filter or predictor
1522
+ * Zstdlib::FIXED:: Prevents dynamic Huffman codes
1523
+ * Zstdlib::HUFFMAN_ONLY:: Prevents string matching
1524
+ * Zstdlib::RLE:: Designed for better compression of PNG image data
1511
1525
  *
1512
1526
  * See the constants for further description.
1513
1527
  *
@@ -1516,16 +1530,16 @@ rb_deflate_s_allocate(VALUE klass)
1516
1530
  * === Basic
1517
1531
  *
1518
1532
  * open "compressed.file", "w+" do |io|
1519
- * io << Zlib::Deflate.new.deflate(File.read("big.file"))
1533
+ * io << Zstdlib::Deflate.new.deflate(File.read("big.file"))
1520
1534
  * end
1521
1535
  *
1522
1536
  * === Custom compression
1523
1537
  *
1524
1538
  * open "compressed.file", "w+" do |compressed_io|
1525
- * deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION,
1526
- * Zlib::MAX_WBITS,
1527
- * Zlib::MAX_MEM_LEVEL,
1528
- * Zlib::HUFFMAN_ONLY)
1539
+ * deflate = Zstdlib::Deflate.new(Zstdlib::BEST_COMPRESSION,
1540
+ * Zstdlib::MAX_WBITS,
1541
+ * Zstdlib::MAX_MEM_LEVEL,
1542
+ * Zstdlib::HUFFMAN_ONLY)
1529
1543
  *
1530
1544
  * begin
1531
1545
  * open "big.file" do |big_io|
@@ -1563,7 +1577,7 @@ rb_deflate_initialize(int argc, VALUE *argv, VALUE obj)
1563
1577
  }
1564
1578
 
1565
1579
  /*
1566
- * Document-method: Zlib::Deflate#initialize_copy
1580
+ * Document-method: Zstdlib::Deflate#initialize_copy
1567
1581
  *
1568
1582
  * Duplicates the deflate stream.
1569
1583
  */
@@ -1600,26 +1614,26 @@ deflate_run(VALUE args)
1600
1614
  }
1601
1615
 
1602
1616
  /*
1603
- * Document-method: Zlib::Deflate.deflate
1617
+ * Document-method: Zstdlib::Deflate.deflate
1604
1618
  *
1605
1619
  * call-seq:
1606
- * Zlib.deflate(string[, level])
1607
- * Zlib::Deflate.deflate(string[, level])
1620
+ * Zstdlib.deflate(string[, level])
1621
+ * Zstdlib::Deflate.deflate(string[, level])
1608
1622
  *
1609
1623
  * Compresses the given +string+. Valid values of level are
1610
- * Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION,
1611
- * Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
1624
+ * Zstdlib::NO_COMPRESSION, Zstdlib::BEST_SPEED, Zstdlib::BEST_COMPRESSION,
1625
+ * Zstdlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
1612
1626
  *
1613
1627
  * This method is almost equivalent to the following code:
1614
1628
  *
1615
1629
  * def deflate(string, level)
1616
- * z = Zlib::Deflate.new(level)
1617
- * dst = z.deflate(string, Zlib::FINISH)
1630
+ * z = Zstdlib::Deflate.new(level)
1631
+ * dst = z.deflate(string, Zstdlib::FINISH)
1618
1632
  * z.close
1619
1633
  * dst
1620
1634
  * end
1621
1635
  *
1622
- * See also Zlib.inflate
1636
+ * See also Zstdlib.inflate
1623
1637
  *
1624
1638
  */
1625
1639
  static VALUE
@@ -1662,16 +1676,16 @@ do_deflate(struct zstream *z, VALUE src, int flush)
1662
1676
  }
1663
1677
 
1664
1678
  /*
1665
- * Document-method: Zlib::Deflate#deflate
1679
+ * Document-method: Zstdlib::Deflate#deflate
1666
1680
  *
1667
1681
  * call-seq:
1668
- * z.deflate(string, flush = Zlib::NO_FLUSH) -> String
1669
- * z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } -> nil
1682
+ * z.deflate(string, flush = Zstdlib::NO_FLUSH) -> String
1683
+ * z.deflate(string, flush = Zstdlib::NO_FLUSH) { |chunk| ... } -> nil
1670
1684
  *
1671
1685
  * Inputs +string+ into the deflate stream and returns the output from the
1672
1686
  * stream. On calling this method, both the input and the output buffers of
1673
1687
  * the stream are flushed. If +string+ is nil, this method finishes the
1674
- * stream, just like Zlib::ZStream#finish.
1688
+ * stream, just like Zstdlib::ZStream#finish.
1675
1689
  *
1676
1690
  * If a block is given consecutive deflated chunks from the +string+ are
1677
1691
  * yielded to the block and +nil+ is returned.
@@ -1679,10 +1693,10 @@ do_deflate(struct zstream *z, VALUE src, int flush)
1679
1693
  * The +flush+ parameter specifies the flush mode. The following constants
1680
1694
  * may be used:
1681
1695
  *
1682
- * Zlib::NO_FLUSH:: The default
1683
- * Zlib::SYNC_FLUSH:: Flushes the output to a byte boundary
1684
- * Zlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state
1685
- * Zlib::FINISH:: Pending input is processed, pending output is flushed.
1696
+ * Zstdlib::NO_FLUSH:: The default
1697
+ * Zstdlib::SYNC_FLUSH:: Flushes the output to a byte boundary
1698
+ * Zstdlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state
1699
+ * Zstdlib::FINISH:: Pending input is processed, pending output is flushed.
1686
1700
  *
1687
1701
  * See the constants for further description.
1688
1702
  *
@@ -1701,12 +1715,12 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
1701
1715
  }
1702
1716
 
1703
1717
  /*
1704
- * Document-method: Zlib::Deflate#<<
1718
+ * Document-method: Zstdlib::Deflate#<<
1705
1719
  *
1706
1720
  * call-seq: << string
1707
1721
  *
1708
- * Inputs +string+ into the deflate stream just like Zlib::Deflate#deflate, but
1709
- * returns the Zlib::Deflate object itself. The output from the stream is
1722
+ * Inputs +string+ into the deflate stream just like Zstdlib::Deflate#deflate, but
1723
+ * returns the Zstdlib::Deflate object itself. The output from the stream is
1710
1724
  * preserved in output buffer.
1711
1725
  */
1712
1726
  static VALUE
@@ -1718,18 +1732,18 @@ rb_deflate_addstr(VALUE obj, VALUE src)
1718
1732
  }
1719
1733
 
1720
1734
  /*
1721
- * Document-method: Zlib::Deflate#flush
1735
+ * Document-method: Zstdlib::Deflate#flush
1722
1736
  *
1723
1737
  * call-seq:
1724
- * flush(flush = Zlib::SYNC_FLUSH) -> String
1725
- * flush(flush = Zlib::SYNC_FLUSH) { |chunk| ... } -> nil
1738
+ * flush(flush = Zstdlib::SYNC_FLUSH) -> String
1739
+ * flush(flush = Zstdlib::SYNC_FLUSH) { |chunk| ... } -> nil
1726
1740
  *
1727
1741
  * This method is equivalent to <tt>deflate('', flush)</tt>. This method is
1728
1742
  * just provided to improve the readability of your Ruby program. If a block
1729
1743
  * is given chunks of deflate output are yielded to the block until the buffer
1730
1744
  * is flushed.
1731
1745
  *
1732
- * See Zlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH,
1746
+ * See Zstdlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH,
1733
1747
  * SYNC_FLUSH, FULL_FLUSH and FINISH.
1734
1748
  */
1735
1749
  static VALUE
@@ -1749,7 +1763,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
1749
1763
  }
1750
1764
 
1751
1765
  /*
1752
- * Document-method: Zlib::Deflate.params
1766
+ * Document-method: Zstdlib::Deflate.params
1753
1767
  *
1754
1768
  * call-seq: params(level, strategy)
1755
1769
  *
@@ -1757,7 +1771,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
1757
1771
  * different types of data that require different types of compression. Any
1758
1772
  * unprocessed data is flushed before changing the params.
1759
1773
  *
1760
- * See Zlib::Deflate.new for a description of +level+ and +strategy+.
1774
+ * See Zstdlib::Deflate.new for a description of +level+ and +strategy+.
1761
1775
  *
1762
1776
  */
1763
1777
  static VALUE
@@ -1789,12 +1803,12 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
1789
1803
  }
1790
1804
 
1791
1805
  /*
1792
- * Document-method: Zlib::Deflate.set_dictionary
1806
+ * Document-method: Zstdlib::Deflate.set_dictionary
1793
1807
  *
1794
1808
  * call-seq: set_dictionary(string)
1795
1809
  *
1796
1810
  * Sets the preset dictionary and returns +string+. This method is available
1797
- * just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called.
1811
+ * just only after Zstdlib::Deflate.new or Zstdlib::ZStream#reset method was called.
1798
1812
  * See zlib.h for details.
1799
1813
  *
1800
1814
  * Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as
@@ -1824,10 +1838,10 @@ rb_deflate_set_dictionary(VALUE obj, VALUE dic)
1824
1838
  /* ------------------------------------------------------------------------- */
1825
1839
 
1826
1840
  /*
1827
- * Document-class: Zlib::Inflate
1841
+ * Document-class: Zstdlib::Inflate
1828
1842
  *
1829
1843
  * Zlib:Inflate is the class for decompressing compressed data. Unlike
1830
- * Zlib::Deflate, an instance of this class is not able to duplicate (clone,
1844
+ * Zstdlib::Deflate, an instance of this class is not able to duplicate (clone,
1831
1845
  * dup) itself.
1832
1846
  */
1833
1847
 
@@ -1840,10 +1854,10 @@ rb_inflate_s_allocate(VALUE klass)
1840
1854
  }
1841
1855
 
1842
1856
  /*
1843
- * Document-method: Zlib::Inflate.new
1857
+ * Document-method: Zstdlib::Inflate.new
1844
1858
  *
1845
1859
  * call-seq:
1846
- * Zlib::Inflate.new(window_bits = Zlib::MAX_WBITS)
1860
+ * Zstdlib::Inflate.new(window_bits = Zstdlib::MAX_WBITS)
1847
1861
  *
1848
1862
  * Creates a new inflate stream for decompression. +window_bits+ sets the
1849
1863
  * size of the history buffer and can have the following values:
@@ -1860,7 +1874,7 @@ rb_inflate_s_allocate(VALUE klass)
1860
1874
  * Greater than 15::
1861
1875
  * Add 32 to window_bits to enable zlib and gzip decoding with automatic
1862
1876
  * header detection, or add 16 to decode only the gzip format (a
1863
- * Zlib::DataError will be raised for a non-gzip stream).
1877
+ * Zstdlib::DataError will be raised for a non-gzip stream).
1864
1878
  *
1865
1879
  * (-8..-15)::
1866
1880
  * Enables raw deflate mode which will not generate a check value, and will
@@ -1872,7 +1886,7 @@ rb_inflate_s_allocate(VALUE klass)
1872
1886
  * == Example
1873
1887
  *
1874
1888
  * open "compressed.file" do |compressed_io|
1875
- * zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)
1889
+ * zi = Zstdlib::Inflate.new(Zstdlib::MAX_WBITS + 32)
1876
1890
  *
1877
1891
  * begin
1878
1892
  * open "uncompressed.file", "w+" do |uncompressed_io|
@@ -1915,26 +1929,26 @@ inflate_run(VALUE args)
1915
1929
  }
1916
1930
 
1917
1931
  /*
1918
- * Document-method: Zlib::inflate
1932
+ * Document-method: Zstdlib::inflate
1919
1933
  *
1920
1934
  * call-seq:
1921
- * Zlib.inflate(string)
1922
- * Zlib::Inflate.inflate(string)
1935
+ * Zstdlib.inflate(string)
1936
+ * Zstdlib::Inflate.inflate(string)
1923
1937
  *
1924
- * Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
1938
+ * Decompresses +string+. Raises a Zstdlib::NeedDict exception if a preset
1925
1939
  * dictionary is needed for decompression.
1926
1940
  *
1927
1941
  * This method is almost equivalent to the following code:
1928
1942
  *
1929
1943
  * def inflate(string)
1930
- * zstream = Zlib::Inflate.new
1944
+ * zstream = Zstdlib::Inflate.new
1931
1945
  * buf = zstream.inflate(string)
1932
1946
  * zstream.finish
1933
1947
  * zstream.close
1934
1948
  * buf
1935
1949
  * end
1936
1950
  *
1937
- * See also Zlib.deflate
1951
+ * See also Zstdlib.deflate
1938
1952
  *
1939
1953
  */
1940
1954
  static VALUE
@@ -1973,7 +1987,7 @@ do_inflate(struct zstream *z, VALUE src)
1973
1987
  }
1974
1988
  }
1975
1989
 
1976
- /* Document-method: Zlib::Inflate#add_dictionary
1990
+ /* Document-method: Zstdlib::Inflate#add_dictionary
1977
1991
  *
1978
1992
  * call-seq: add_dictionary(string)
1979
1993
  *
@@ -1993,7 +2007,7 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary) {
1993
2007
  }
1994
2008
 
1995
2009
  /*
1996
- * Document-method: Zlib::Inflate#inflate
2010
+ * Document-method: Zstdlib::Inflate#inflate
1997
2011
  *
1998
2012
  * call-seq:
1999
2013
  * inflate(deflate_string) -> String
@@ -2002,22 +2016,22 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary) {
2002
2016
  * Inputs +deflate_string+ into the inflate stream and returns the output from
2003
2017
  * the stream. Calling this method, both the input and the output buffer of
2004
2018
  * the stream are flushed. If string is +nil+, this method finishes the
2005
- * stream, just like Zlib::ZStream#finish.
2019
+ * stream, just like Zstdlib::ZStream#finish.
2006
2020
  *
2007
2021
  * If a block is given consecutive inflated chunks from the +deflate_string+
2008
2022
  * are yielded to the block and +nil+ is returned.
2009
2023
  *
2010
- * Raises a Zlib::NeedDict exception if a preset dictionary is needed to
2011
- * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
2024
+ * Raises a Zstdlib::NeedDict exception if a preset dictionary is needed to
2025
+ * decompress. Set the dictionary by Zstdlib::Inflate#set_dictionary and then
2012
2026
  * call this method again with an empty string to flush the stream:
2013
2027
  *
2014
- * inflater = Zlib::Inflate.new
2028
+ * inflater = Zstdlib::Inflate.new
2015
2029
  *
2016
2030
  * begin
2017
2031
  * out = inflater.inflate compressed
2018
- * rescue Zlib::NeedDict
2032
+ * rescue Zstdlib::NeedDict
2019
2033
  * # ensure the dictionary matches the stream's required dictionary
2020
- * raise unless inflater.adler == Zlib.adler32(dictionary)
2034
+ * raise unless inflater.adler == Zstdlib.adler32(dictionary)
2021
2035
  *
2022
2036
  * inflater.set_dictionary dictionary
2023
2037
  * inflater.inflate ''
@@ -2027,7 +2041,7 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary) {
2027
2041
  *
2028
2042
  * inflater.close
2029
2043
  *
2030
- * See also Zlib::Inflate.new
2044
+ * See also Zstdlib::Inflate.new
2031
2045
  */
2032
2046
  static VALUE
2033
2047
  rb_inflate_inflate(VALUE obj, VALUE src)
@@ -2062,8 +2076,8 @@ rb_inflate_inflate(VALUE obj, VALUE src)
2062
2076
  /*
2063
2077
  * call-seq: << string
2064
2078
  *
2065
- * Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but
2066
- * returns the Zlib::Inflate object itself. The output from the stream is
2079
+ * Inputs +string+ into the inflate stream just like Zstdlib::Inflate#inflate, but
2080
+ * returns the Zstdlib::Inflate object itself. The output from the stream is
2067
2081
  * preserved in output buffer.
2068
2082
  */
2069
2083
  static VALUE
@@ -2131,10 +2145,10 @@ rb_inflate_sync_point_p(VALUE obj)
2131
2145
  }
2132
2146
 
2133
2147
  /*
2134
- * Document-method: Zlib::Inflate#set_dictionary
2148
+ * Document-method: Zstdlib::Inflate#set_dictionary
2135
2149
  *
2136
2150
  * Sets the preset dictionary and returns +string+. This method is available just
2137
- * only after a Zlib::NeedDict exception was raised. See zlib.h for details.
2151
+ * only after a Zstdlib::NeedDict exception was raised. See zlib.h for details.
2138
2152
  *
2139
2153
  */
2140
2154
  static VALUE
@@ -2261,7 +2275,7 @@ gzfile_free(void *p)
2261
2275
 
2262
2276
  if (ZSTREAM_IS_READY(z)) {
2263
2277
  if (z->func == &deflate_funcs) {
2264
- finalizer_warn("Zlib::GzipWriter object must be closed explicitly.");
2278
+ finalizer_warn("Zstdlib::GzipWriter object must be closed explicitly.");
2265
2279
  }
2266
2280
  zstream_finalize(z);
2267
2281
  }
@@ -2475,7 +2489,7 @@ gzfile_raise(struct gzfile *gz, VALUE klass, const char *message)
2475
2489
  }
2476
2490
 
2477
2491
  /*
2478
- * Document-method: Zlib::GzipFile::Error#inspect
2492
+ * Document-method: Zstdlib::GzipFile::Error#inspect
2479
2493
  *
2480
2494
  * Constructs a String of the GzipFile Error
2481
2495
  */
@@ -2513,7 +2527,7 @@ gzfile_make_header(struct gzfile *gz)
2513
2527
  if (gz->level == Z_BEST_SPEED) {
2514
2528
  extraflags |= GZ_EXTRAFLAG_FAST;
2515
2529
  }
2516
- else if (gz->level == Z_BEST_COMPRESSION) {
2530
+ else if (gz->level == ZSTD_maxCLevel()) {
2517
2531
  extraflags |= GZ_EXTRAFLAG_SLOW;
2518
2532
  }
2519
2533
 
@@ -2584,10 +2598,10 @@ gzfile_read_header(struct gzfile *gz)
2584
2598
  gz->level = Z_BEST_SPEED;
2585
2599
  }
2586
2600
  else if (head[8] & GZ_EXTRAFLAG_SLOW) {
2587
- gz->level = Z_BEST_COMPRESSION;
2601
+ gz->level = ZSTD_maxCLevel();
2588
2602
  }
2589
2603
  else {
2590
- gz->level = Z_DEFAULT_COMPRESSION;
2604
+ gz->level = ZSTD_CLEVEL_DEFAULT;
2591
2605
  }
2592
2606
 
2593
2607
  gz->mtime = gzfile_get32(&head[4]);
@@ -2974,40 +2988,40 @@ get_gzfile(VALUE obj)
2974
2988
  /* ------------------------------------------------------------------------- */
2975
2989
 
2976
2990
  /*
2977
- * Document-class: Zlib::GzipFile
2991
+ * Document-class: Zstdlib::GzipFile
2978
2992
  *
2979
- * Zlib::GzipFile is an abstract class for handling a gzip formatted
2993
+ * Zstdlib::GzipFile is an abstract class for handling a gzip formatted
2980
2994
  * compressed file. The operations are defined in the subclasses,
2981
- * Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
2995
+ * Zstdlib::GzipReader for reading, and Zstdlib::GzipWriter for writing.
2982
2996
  *
2983
2997
  * GzipReader should be used by associating an IO, or IO-like, object.
2984
2998
  *
2985
2999
  * == Method Catalogue
2986
3000
  *
2987
3001
  * - ::wrap
2988
- * - ::open (Zlib::GzipReader::open and Zlib::GzipWriter::open)
3002
+ * - ::open (Zstdlib::GzipReader::open and Zstdlib::GzipWriter::open)
2989
3003
  * - #close
2990
3004
  * - #closed?
2991
3005
  * - #comment
2992
- * - comment= (Zlib::GzipWriter#comment=)
3006
+ * - comment= (Zstdlib::GzipWriter#comment=)
2993
3007
  * - #crc
2994
- * - eof? (Zlib::GzipReader#eof?)
3008
+ * - eof? (Zstdlib::GzipReader#eof?)
2995
3009
  * - #finish
2996
3010
  * - #level
2997
- * - lineno (Zlib::GzipReader#lineno)
2998
- * - lineno= (Zlib::GzipReader#lineno=)
3011
+ * - lineno (Zstdlib::GzipReader#lineno)
3012
+ * - lineno= (Zstdlib::GzipReader#lineno=)
2999
3013
  * - #mtime
3000
- * - mtime= (Zlib::GzipWriter#mtime=)
3014
+ * - mtime= (Zstdlib::GzipWriter#mtime=)
3001
3015
  * - #orig_name
3002
- * - orig_name (Zlib::GzipWriter#orig_name=)
3016
+ * - orig_name (Zstdlib::GzipWriter#orig_name=)
3003
3017
  * - #os_code
3004
3018
  * - path (when the underlying IO supports #path)
3005
3019
  * - #sync
3006
3020
  * - #sync=
3007
3021
  * - #to_io
3008
3022
  *
3009
- * (due to internal structure, documentation may appear under Zlib::GzipReader
3010
- * or Zlib::GzipWriter)
3023
+ * (due to internal structure, documentation may appear under Zstdlib::GzipReader
3024
+ * or Zstdlib::GzipWriter)
3011
3025
  */
3012
3026
 
3013
3027
 
@@ -3066,11 +3080,11 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
3066
3080
  }
3067
3081
 
3068
3082
  /*
3069
- * Document-method: Zlib::GzipFile.wrap
3083
+ * Document-method: Zstdlib::GzipFile.wrap
3070
3084
  *
3071
3085
  * call-seq:
3072
- * Zlib::GzipReader.wrap(io, ...) { |gz| ... }
3073
- * Zlib::GzipWriter.wrap(io, ...) { |gz| ... }
3086
+ * Zstdlib::GzipReader.wrap(io, ...) { |gz| ... }
3087
+ * Zstdlib::GzipWriter.wrap(io, ...) { |gz| ... }
3074
3088
  *
3075
3089
  * Creates a GzipReader or GzipWriter associated with +io+, passing in any
3076
3090
  * necessary extra options, and executes the block with the newly created
@@ -3078,7 +3092,7 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
3078
3092
  *
3079
3093
  * The GzipFile object will be closed automatically after executing the block.
3080
3094
  * If you want to keep the associated IO object open, you may call
3081
- * Zlib::GzipFile#finish method in the block.
3095
+ * Zstdlib::GzipFile#finish method in the block.
3082
3096
  */
3083
3097
  static VALUE
3084
3098
  rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
@@ -3087,9 +3101,9 @@ rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
3087
3101
  }
3088
3102
 
3089
3103
  /*
3090
- * Document-method: Zlib::GzipFile.open
3104
+ * Document-method: Zstdlib::GzipFile.open
3091
3105
  *
3092
- * See Zlib::GzipReader#open and Zlib::GzipWriter#open.
3106
+ * See Zstdlib::GzipReader#open and Zstdlib::GzipWriter#open.
3093
3107
  */
3094
3108
  static VALUE
3095
3109
  gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
@@ -3106,7 +3120,7 @@ gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
3106
3120
  }
3107
3121
 
3108
3122
  /*
3109
- * Document-method: Zlib::GzipFile#to_io
3123
+ * Document-method: Zstdlib::GzipFile#to_io
3110
3124
  *
3111
3125
  * Same as IO.
3112
3126
  */
@@ -3117,7 +3131,7 @@ rb_gzfile_to_io(VALUE obj)
3117
3131
  }
3118
3132
 
3119
3133
  /*
3120
- * Document-method: Zlib::GzipFile#crc
3134
+ * Document-method: Zstdlib::GzipFile#crc
3121
3135
  *
3122
3136
  * Returns CRC value of the uncompressed data.
3123
3137
  */
@@ -3128,7 +3142,7 @@ rb_gzfile_crc(VALUE obj)
3128
3142
  }
3129
3143
 
3130
3144
  /*
3131
- * Document-method: Zlib::GzipFile#mtime
3145
+ * Document-method: Zstdlib::GzipFile#mtime
3132
3146
  *
3133
3147
  * Returns last modification time recorded in the gzip file header.
3134
3148
  */
@@ -3139,7 +3153,7 @@ rb_gzfile_mtime(VALUE obj)
3139
3153
  }
3140
3154
 
3141
3155
  /*
3142
- * Document-method: Zlib::GzipFile#level
3156
+ * Document-method: Zstdlib::GzipFile#level
3143
3157
  *
3144
3158
  * Returns compression level.
3145
3159
  */
@@ -3150,7 +3164,7 @@ rb_gzfile_level(VALUE obj)
3150
3164
  }
3151
3165
 
3152
3166
  /*
3153
- * Document-method: Zlib::GzipFile#os_code
3167
+ * Document-method: Zstdlib::GzipFile#os_code
3154
3168
  *
3155
3169
  * Returns OS code number recorded in the gzip file header.
3156
3170
  */
@@ -3161,7 +3175,7 @@ rb_gzfile_os_code(VALUE obj)
3161
3175
  }
3162
3176
 
3163
3177
  /*
3164
- * Document-method: Zlib::GzipFile#orig_name
3178
+ * Document-method: Zstdlib::GzipFile#orig_name
3165
3179
  *
3166
3180
  * Returns original filename recorded in the gzip file header, or +nil+ if
3167
3181
  * original filename is not present.
@@ -3178,7 +3192,7 @@ rb_gzfile_orig_name(VALUE obj)
3178
3192
  }
3179
3193
 
3180
3194
  /*
3181
- * Document-method: Zlib::GzipFile#comment
3195
+ * Document-method: Zstdlib::GzipFile#comment
3182
3196
  *
3183
3197
  * Returns comments recorded in the gzip file header, or nil if the comments
3184
3198
  * is not present.
@@ -3195,7 +3209,7 @@ rb_gzfile_comment(VALUE obj)
3195
3209
  }
3196
3210
 
3197
3211
  /*
3198
- * Document-method: Zlib::GzipFile#lineno
3212
+ * Document-method: Zstdlib::GzipFile#lineno
3199
3213
  *
3200
3214
  * The line number of the last row read from this file.
3201
3215
  */
@@ -3206,7 +3220,7 @@ rb_gzfile_lineno(VALUE obj)
3206
3220
  }
3207
3221
 
3208
3222
  /*
3209
- * Document-method: Zlib::GzipReader#lineno=
3223
+ * Document-method: Zstdlib::GzipReader#lineno=
3210
3224
  *
3211
3225
  * Specify line number of the last row read from this file.
3212
3226
  */
@@ -3219,7 +3233,7 @@ rb_gzfile_set_lineno(VALUE obj, VALUE lineno)
3219
3233
  }
3220
3234
 
3221
3235
  /*
3222
- * Document-method: Zlib::GzipWriter#mtime=
3236
+ * Document-method: Zstdlib::GzipWriter#mtime=
3223
3237
  *
3224
3238
  * Specify the modification time (+mtime+) in the gzip header.
3225
3239
  * Using a Fixnum or Integer
@@ -3241,7 +3255,7 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
3241
3255
  }
3242
3256
 
3243
3257
  /*
3244
- * Document-method: Zlib::GzipFile#orig_name=
3258
+ * Document-method: Zstdlib::GzipFile#orig_name=
3245
3259
  *
3246
3260
  * Specify the original name (+str+) in the gzip header.
3247
3261
  */
@@ -3265,7 +3279,7 @@ rb_gzfile_set_orig_name(VALUE obj, VALUE str)
3265
3279
  }
3266
3280
 
3267
3281
  /*
3268
- * Document-method: Zlib::GzipFile#comment=
3282
+ * Document-method: Zstdlib::GzipFile#comment=
3269
3283
  *
3270
3284
  * Specify the comment (+str+) in the gzip header.
3271
3285
  */
@@ -3289,7 +3303,7 @@ rb_gzfile_set_comment(VALUE obj, VALUE str)
3289
3303
  }
3290
3304
 
3291
3305
  /*
3292
- * Document-method: Zlib::GzipFile#close
3306
+ * Document-method: Zstdlib::GzipFile#close
3293
3307
  *
3294
3308
  * Closes the GzipFile object. This method calls close method of the
3295
3309
  * associated IO object. Returns the associated IO object.
@@ -3306,9 +3320,9 @@ rb_gzfile_close(VALUE obj)
3306
3320
  }
3307
3321
 
3308
3322
  /*
3309
- * Document-method: Zlib::GzipFile#finish
3323
+ * Document-method: Zstdlib::GzipFile#finish
3310
3324
  *
3311
- * Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never
3325
+ * Closes the GzipFile object. Unlike Zstdlib::GzipFile#close, this method never
3312
3326
  * calls the close method of the associated IO object. Returns the associated IO
3313
3327
  * object.
3314
3328
  */
@@ -3324,7 +3338,7 @@ rb_gzfile_finish(VALUE obj)
3324
3338
  }
3325
3339
 
3326
3340
  /*
3327
- * Document-method: Zlib::GzipFile#closed?
3341
+ * Document-method: Zstdlib::GzipFile#closed?
3328
3342
  *
3329
3343
  * Same as IO#closed?
3330
3344
  *
@@ -3338,7 +3352,7 @@ rb_gzfile_closed_p(VALUE obj)
3338
3352
  }
3339
3353
 
3340
3354
  /*
3341
- * Document-method: Zlib::GzipFile#eof?
3355
+ * Document-method: Zstdlib::GzipFile#eof?
3342
3356
  *
3343
3357
  * Returns +true+ or +false+ whether the stream has reached the end.
3344
3358
  */
@@ -3350,7 +3364,7 @@ rb_gzfile_eof_p(VALUE obj)
3350
3364
  }
3351
3365
 
3352
3366
  /*
3353
- * Document-method: Zlib::GzipFile#sync
3367
+ * Document-method: Zstdlib::GzipFile#sync
3354
3368
  *
3355
3369
  * Same as IO#sync
3356
3370
  *
@@ -3362,7 +3376,7 @@ rb_gzfile_sync(VALUE obj)
3362
3376
  }
3363
3377
 
3364
3378
  /*
3365
- * Document-method: Zlib::GzipFile#sync=
3379
+ * Document-method: Zstdlib::GzipFile#sync=
3366
3380
  *
3367
3381
  * call-seq: sync = flag
3368
3382
  *
@@ -3385,7 +3399,7 @@ rb_gzfile_set_sync(VALUE obj, VALUE mode)
3385
3399
  }
3386
3400
 
3387
3401
  /*
3388
- * Document-method: Zlib::GzipFile#total_in
3402
+ * Document-method: Zstdlib::GzipFile#total_in
3389
3403
  *
3390
3404
  * Total number of input bytes read so far.
3391
3405
  */
@@ -3396,7 +3410,7 @@ rb_gzfile_total_in(VALUE obj)
3396
3410
  }
3397
3411
 
3398
3412
  /*
3399
- * Document-method: Zlib::GzipFile#total_out
3413
+ * Document-method: Zstdlib::GzipFile#total_out
3400
3414
  *
3401
3415
  * Total number of output bytes output so far.
3402
3416
  */
@@ -3408,7 +3422,7 @@ rb_gzfile_total_out(VALUE obj)
3408
3422
  }
3409
3423
 
3410
3424
  /*
3411
- * Document-method: Zlib::GzipFile#path
3425
+ * Document-method: Zstdlib::GzipFile#path
3412
3426
  *
3413
3427
  * call-seq: path
3414
3428
  *
@@ -3440,19 +3454,19 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
3440
3454
  /* ------------------------------------------------------------------------- */
3441
3455
 
3442
3456
  /*
3443
- * Document-class: Zlib::GzipWriter
3457
+ * Document-class: Zstdlib::GzipWriter
3444
3458
  *
3445
- * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
3459
+ * Zstdlib::GzipWriter is a class for writing gzipped files. GzipWriter should
3446
3460
  * be used with an instance of IO, or IO-like, object.
3447
3461
  *
3448
3462
  * Following two example generate the same result.
3449
3463
  *
3450
- * Zlib::GzipWriter.open('hoge.gz') do |gz|
3464
+ * Zstdlib::GzipWriter.open('hoge.gz') do |gz|
3451
3465
  * gz.write 'jugemu jugemu gokou no surikire...'
3452
3466
  * end
3453
3467
  *
3454
3468
  * File.open('hoge.gz', 'w') do |f|
3455
- * gz = Zlib::GzipWriter.new(f)
3469
+ * gz = Zstdlib::GzipWriter.new(f)
3456
3470
  * gz.write 'jugemu jugemu gokou no surikire...'
3457
3471
  * gz.close
3458
3472
  * end
@@ -3460,14 +3474,14 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
3460
3474
  * To make like gzip(1) does, run following:
3461
3475
  *
3462
3476
  * orig = 'hoge.txt'
3463
- * Zlib::GzipWriter.open('hoge.gz') do |gz|
3477
+ * Zstdlib::GzipWriter.open('hoge.gz') do |gz|
3464
3478
  * gz.mtime = File.mtime(orig)
3465
3479
  * gz.orig_name = orig
3466
3480
  * gz.write IO.binread(orig)
3467
3481
  * end
3468
3482
  *
3469
3483
  * NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
3470
- * GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
3484
+ * GzipWriter objects by Zstdlib::GzipWriter#close etc. Otherwise, GzipWriter
3471
3485
  * will be not able to write the gzip footer and will generate a broken gzip
3472
3486
  * file.
3473
3487
  */
@@ -3479,11 +3493,11 @@ rb_gzwriter_s_allocate(VALUE klass)
3479
3493
  }
3480
3494
 
3481
3495
  /*
3482
- * call-seq: Zlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
3496
+ * call-seq: Zstdlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
3483
3497
  *
3484
3498
  * Opens a file specified by +filename+ for writing gzip compressed data, and
3485
3499
  * returns a GzipWriter object associated with that file. Further details of
3486
- * this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap.
3500
+ * this method are found in Zstdlib::GzipWriter.new and Zstdlib::GzipFile.wrap.
3487
3501
  */
3488
3502
  static VALUE
3489
3503
  rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
@@ -3493,10 +3507,10 @@ rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
3493
3507
 
3494
3508
  /*
3495
3509
  * call-seq:
3496
- * Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
3510
+ * Zstdlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
3497
3511
  *
3498
3512
  * Creates a GzipWriter object associated with +io+. +level+ and +strategy+
3499
- * should be the same as the arguments of Zlib::Deflate.new. The GzipWriter
3513
+ * should be the same as the arguments of Zstdlib::Deflate.new. The GzipWriter
3500
3514
  * object writes gzipped data to +io+. +io+ must respond to the
3501
3515
  * +write+ method that behaves the same as IO#write.
3502
3516
  *
@@ -3542,8 +3556,8 @@ rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj)
3542
3556
  * call-seq: flush(flush=nil)
3543
3557
  *
3544
3558
  * Flushes all the internal buffers of the GzipWriter object. The meaning of
3545
- * +flush+ is same as in Zlib::Deflate#deflate. <tt>Zlib::SYNC_FLUSH</tt> is used if
3546
- * +flush+ is omitted. It is no use giving flush <tt>Zlib::NO_FLUSH</tt>.
3559
+ * +flush+ is same as in Zstdlib::Deflate#deflate. <tt>Zstdlib::SYNC_FLUSH</tt> is used if
3560
+ * +flush+ is omitted. It is no use giving flush <tt>Zstdlib::NO_FLUSH</tt>.
3547
3561
  */
3548
3562
  static VALUE
3549
3563
  rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj)
@@ -3623,25 +3637,25 @@ rb_gzwriter_putc(VALUE obj, VALUE ch)
3623
3637
  /* ------------------------------------------------------------------------- */
3624
3638
 
3625
3639
  /*
3626
- * Document-class: Zlib::GzipReader
3640
+ * Document-class: Zstdlib::GzipReader
3627
3641
  *
3628
- * Zlib::GzipReader is the class for reading a gzipped file. GzipReader should
3642
+ * Zstdlib::GzipReader is the class for reading a gzipped file. GzipReader should
3629
3643
  * be used an IO, or -IO-like, object.
3630
3644
  *
3631
- * Zlib::GzipReader.open('hoge.gz') {|gz|
3645
+ * Zstdlib::GzipReader.open('hoge.gz') {|gz|
3632
3646
  * print gz.read
3633
3647
  * }
3634
3648
  *
3635
3649
  * File.open('hoge.gz') do |f|
3636
- * gz = Zlib::GzipReader.new(f)
3650
+ * gz = Zstdlib::GzipReader.new(f)
3637
3651
  * print gz.read
3638
3652
  * gz.close
3639
3653
  * end
3640
3654
  *
3641
3655
  * == Method Catalogue
3642
3656
  *
3643
- * The following methods in Zlib::GzipReader are just like their counterparts
3644
- * in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
3657
+ * The following methods in Zstdlib::GzipReader are just like their counterparts
3658
+ * in IO, but they raise Zstdlib::Error or Zstdlib::GzipFile::Error exception if an
3645
3659
  * error was found in the gzip file.
3646
3660
  * - #each
3647
3661
  * - #each_line
@@ -3659,15 +3673,15 @@ rb_gzwriter_putc(VALUE obj, VALUE ch)
3659
3673
  * Be careful of the footer of the gzip file. A gzip file has the checksum of
3660
3674
  * pre-compressed data in its footer. GzipReader checks all uncompressed data
3661
3675
  * against that checksum at the following cases, and if it fails, raises
3662
- * <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or
3663
- * <tt>Zlib::GzipFile::LengthError</tt> exception.
3676
+ * <tt>Zstdlib::GzipFile::NoFooter</tt>, <tt>Zstdlib::GzipFile::CRCError</tt>, or
3677
+ * <tt>Zstdlib::GzipFile::LengthError</tt> exception.
3664
3678
  *
3665
3679
  * - When an reading request is received beyond the end of file (the end of
3666
- * compressed data). That is, when Zlib::GzipReader#read,
3667
- * Zlib::GzipReader#gets, or some other methods for reading returns nil.
3668
- * - When Zlib::GzipFile#close method is called after the object reaches the
3680
+ * compressed data). That is, when Zstdlib::GzipReader#read,
3681
+ * Zstdlib::GzipReader#gets, or some other methods for reading returns nil.
3682
+ * - When Zstdlib::GzipFile#close method is called after the object reaches the
3669
3683
  * end of file.
3670
- * - When Zlib::GzipReader#unused method is called after the object reaches
3684
+ * - When Zstdlib::GzipReader#unused method is called after the object reaches
3671
3685
  * the end of file.
3672
3686
  *
3673
3687
  * The rest of the methods are adequately described in their own
@@ -3681,13 +3695,13 @@ rb_gzreader_s_allocate(VALUE klass)
3681
3695
  }
3682
3696
 
3683
3697
  /*
3684
- * Document-method: Zlib::GzipReader.open
3698
+ * Document-method: Zstdlib::GzipReader.open
3685
3699
  *
3686
- * call-seq: Zlib::GzipReader.open(filename) {|gz| ... }
3700
+ * call-seq: Zstdlib::GzipReader.open(filename) {|gz| ... }
3687
3701
  *
3688
3702
  * Opens a file specified by +filename+ as a gzipped file, and returns a
3689
3703
  * GzipReader object associated with that file. Further details of this method
3690
- * are in Zlib::GzipReader.new and ZLib::GzipFile.wrap.
3704
+ * are in Zstdlib::GzipReader.new and ZLib::GzipFile.wrap.
3691
3705
  */
3692
3706
  static VALUE
3693
3707
  rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
@@ -3696,10 +3710,10 @@ rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
3696
3710
  }
3697
3711
 
3698
3712
  /*
3699
- * Document-method: Zlib::GzipReader.new
3713
+ * Document-method: Zstdlib::GzipReader.new
3700
3714
  *
3701
3715
  * call-seq:
3702
- * Zlib::GzipReader.new(io, options = {})
3716
+ * Zstdlib::GzipReader.new(io, options = {})
3703
3717
  *
3704
3718
  * Creates a GzipReader object associated with +io+. The GzipReader object reads
3705
3719
  * gzipped data from +io+, and parses/decompresses it. The +io+ must
@@ -3709,7 +3723,7 @@ rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
3709
3723
  * +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in
3710
3724
  * IO::new.
3711
3725
  *
3712
- * If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
3726
+ * If the gzip file header is incorrect, raises an Zstdlib::GzipFile::Error
3713
3727
  * exception.
3714
3728
  */
3715
3729
  static VALUE
@@ -3741,7 +3755,7 @@ rb_gzreader_initialize(int argc, VALUE *argv, VALUE obj)
3741
3755
  }
3742
3756
 
3743
3757
  /*
3744
- * Document-method: Zlib::GzipReader#rewind
3758
+ * Document-method: Zstdlib::GzipReader#rewind
3745
3759
  *
3746
3760
  * Resets the position of the file pointer to the point created the GzipReader
3747
3761
  * object. The associated IO object needs to respond to the +seek+ method.
@@ -3755,7 +3769,7 @@ rb_gzreader_rewind(VALUE obj)
3755
3769
  }
3756
3770
 
3757
3771
  /*
3758
- * Document-method: Zlib::GzipReader#unused
3772
+ * Document-method: Zstdlib::GzipReader#unused
3759
3773
  *
3760
3774
  * Returns the rest of the data which had read for parsing gzip format, or
3761
3775
  * +nil+ if the whole gzip file is not parsed yet.
@@ -3769,9 +3783,9 @@ rb_gzreader_unused(VALUE obj)
3769
3783
  }
3770
3784
 
3771
3785
  /*
3772
- * Document-method: Zlib::GzipReader#read
3786
+ * Document-method: Zstdlib::GzipReader#read
3773
3787
  *
3774
- * See Zlib::GzipReader documentation for a description.
3788
+ * See Zstdlib::GzipReader documentation for a description.
3775
3789
  */
3776
3790
  static VALUE
3777
3791
  rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
@@ -3793,7 +3807,7 @@ rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
3793
3807
  }
3794
3808
 
3795
3809
  /*
3796
- * Document-method: Zlib::GzipReader#readpartial
3810
+ * Document-method: Zstdlib::GzipReader#readpartial
3797
3811
  *
3798
3812
  * call-seq:
3799
3813
  * gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
@@ -3823,9 +3837,9 @@ rb_gzreader_readpartial(int argc, VALUE *argv, VALUE obj)
3823
3837
  }
3824
3838
 
3825
3839
  /*
3826
- * Document-method: Zlib::GzipReader#getc
3840
+ * Document-method: Zstdlib::GzipReader#getc
3827
3841
  *
3828
- * See Zlib::GzipReader documentation for a description.
3842
+ * See Zstdlib::GzipReader documentation for a description.
3829
3843
  */
3830
3844
  static VALUE
3831
3845
  rb_gzreader_getc(VALUE obj)
@@ -3836,9 +3850,9 @@ rb_gzreader_getc(VALUE obj)
3836
3850
  }
3837
3851
 
3838
3852
  /*
3839
- * Document-method: Zlib::GzipReader#readchar
3853
+ * Document-method: Zstdlib::GzipReader#readchar
3840
3854
  *
3841
- * See Zlib::GzipReader documentation for a description.
3855
+ * See Zstdlib::GzipReader documentation for a description.
3842
3856
  */
3843
3857
  static VALUE
3844
3858
  rb_gzreader_readchar(VALUE obj)
@@ -3852,9 +3866,9 @@ rb_gzreader_readchar(VALUE obj)
3852
3866
  }
3853
3867
 
3854
3868
  /*
3855
- * Document-method: Zlib::GzipReader#getbyte
3869
+ * Document-method: Zstdlib::GzipReader#getbyte
3856
3870
  *
3857
- * See Zlib::GzipReader documentation for a description.
3871
+ * See Zstdlib::GzipReader documentation for a description.
3858
3872
  */
3859
3873
  static VALUE
3860
3874
  rb_gzreader_getbyte(VALUE obj)
@@ -3870,9 +3884,9 @@ rb_gzreader_getbyte(VALUE obj)
3870
3884
  }
3871
3885
 
3872
3886
  /*
3873
- * Document-method: Zlib::GzipReader#readbyte
3887
+ * Document-method: Zstdlib::GzipReader#readbyte
3874
3888
  *
3875
- * See Zlib::GzipReader documentation for a description.
3889
+ * See Zstdlib::GzipReader documentation for a description.
3876
3890
  */
3877
3891
  static VALUE
3878
3892
  rb_gzreader_readbyte(VALUE obj)
@@ -3886,9 +3900,9 @@ rb_gzreader_readbyte(VALUE obj)
3886
3900
  }
3887
3901
 
3888
3902
  /*
3889
- * Document-method: Zlib::GzipReader#each_char
3903
+ * Document-method: Zstdlib::GzipReader#each_char
3890
3904
  *
3891
- * See Zlib::GzipReader documentation for a description.
3905
+ * See Zstdlib::GzipReader documentation for a description.
3892
3906
  */
3893
3907
  static VALUE
3894
3908
  rb_gzreader_each_char(VALUE obj)
@@ -3904,9 +3918,9 @@ rb_gzreader_each_char(VALUE obj)
3904
3918
  }
3905
3919
 
3906
3920
  /*
3907
- * Document-method: Zlib::GzipReader#each_byte
3921
+ * Document-method: Zstdlib::GzipReader#each_byte
3908
3922
  *
3909
- * See Zlib::GzipReader documentation for a description.
3923
+ * See Zstdlib::GzipReader documentation for a description.
3910
3924
  */
3911
3925
  static VALUE
3912
3926
  rb_gzreader_each_byte(VALUE obj)
@@ -3922,23 +3936,23 @@ rb_gzreader_each_byte(VALUE obj)
3922
3936
  }
3923
3937
 
3924
3938
  /*
3925
- * Document-method: Zlib::GzipReader#bytes
3939
+ * Document-method: Zstdlib::GzipReader#bytes
3926
3940
  *
3927
3941
  * This is a deprecated alias for <code>each_byte</code>.
3928
3942
  */
3929
3943
  static VALUE
3930
3944
  rb_gzreader_bytes(VALUE obj)
3931
3945
  {
3932
- rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
3946
+ rb_warn("Zstdlib::GzipReader#bytes is deprecated; use #each_byte instead");
3933
3947
  if (!rb_block_given_p())
3934
3948
  return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0);
3935
3949
  return rb_gzreader_each_byte(obj);
3936
3950
  }
3937
3951
 
3938
3952
  /*
3939
- * Document-method: Zlib::GzipReader#ungetc
3953
+ * Document-method: Zstdlib::GzipReader#ungetc
3940
3954
  *
3941
- * See Zlib::GzipReader documentation for a description.
3955
+ * See Zstdlib::GzipReader documentation for a description.
3942
3956
  */
3943
3957
  static VALUE
3944
3958
  rb_gzreader_ungetc(VALUE obj, VALUE s)
@@ -3957,9 +3971,9 @@ rb_gzreader_ungetc(VALUE obj, VALUE s)
3957
3971
  }
3958
3972
 
3959
3973
  /*
3960
- * Document-method: Zlib::GzipReader#ungetbyte
3974
+ * Document-method: Zstdlib::GzipReader#ungetbyte
3961
3975
  *
3962
- * See Zlib::GzipReader documentation for a description.
3976
+ * See Zstdlib::GzipReader documentation for a description.
3963
3977
  */
3964
3978
  static VALUE
3965
3979
  rb_gzreader_ungetbyte(VALUE obj, VALUE ch)
@@ -4154,9 +4168,9 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
4154
4168
  }
4155
4169
 
4156
4170
  /*
4157
- * Document-method: Zlib::GzipReader#gets
4171
+ * Document-method: Zstdlib::GzipReader#gets
4158
4172
  *
4159
- * See Zlib::GzipReader documentation for a description.
4173
+ * See Zstdlib::GzipReader documentation for a description.
4160
4174
  */
4161
4175
  static VALUE
4162
4176
  rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
@@ -4170,9 +4184,9 @@ rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
4170
4184
  }
4171
4185
 
4172
4186
  /*
4173
- * Document-method: Zlib::GzipReader#readline
4187
+ * Document-method: Zstdlib::GzipReader#readline
4174
4188
  *
4175
- * See Zlib::GzipReader documentation for a description.
4189
+ * See Zstdlib::GzipReader documentation for a description.
4176
4190
  */
4177
4191
  static VALUE
4178
4192
  rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
@@ -4186,9 +4200,9 @@ rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
4186
4200
  }
4187
4201
 
4188
4202
  /*
4189
- * Document-method: Zlib::GzipReader#each
4203
+ * Document-method: Zstdlib::GzipReader#each
4190
4204
  *
4191
- * See Zlib::GzipReader documentation for a description.
4205
+ * See Zstdlib::GzipReader documentation for a description.
4192
4206
  */
4193
4207
  static VALUE
4194
4208
  rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
@@ -4204,23 +4218,23 @@ rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
4204
4218
  }
4205
4219
 
4206
4220
  /*
4207
- * Document-method: Zlib::GzipReader#lines
4221
+ * Document-method: Zstdlib::GzipReader#lines
4208
4222
  *
4209
4223
  * This is a deprecated alias for <code>each_line</code>.
4210
4224
  */
4211
4225
  static VALUE
4212
4226
  rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
4213
4227
  {
4214
- rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead");
4228
+ rb_warn("Zstdlib::GzipReader#lines is deprecated; use #each_line instead");
4215
4229
  if (!rb_block_given_p())
4216
4230
  return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv);
4217
4231
  return rb_gzreader_each(argc, argv, obj);
4218
4232
  }
4219
4233
 
4220
4234
  /*
4221
- * Document-method: Zlib::GzipReader#readlines
4235
+ * Document-method: Zstdlib::GzipReader#readlines
4222
4236
  *
4223
- * See Zlib::GzipReader documentation for a description.
4237
+ * See Zstdlib::GzipReader documentation for a description.
4224
4238
  */
4225
4239
  static VALUE
4226
4240
  rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
@@ -4236,14 +4250,14 @@ rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
4236
4250
  #endif /* GZIP_SUPPORT */
4237
4251
 
4238
4252
  void
4239
- Init_zlib(void)
4253
+ Init_zstdlib(void)
4240
4254
  {
4241
4255
  VALUE mZlib, cZStream, cDeflate, cInflate;
4242
4256
  #if GZIP_SUPPORT
4243
4257
  VALUE cGzipFile, cGzipWriter, cGzipReader;
4244
4258
  #endif
4245
4259
 
4246
- mZlib = rb_define_module("Zlib");
4260
+ mZlib = rb_define_module("Zstdlib");
4247
4261
 
4248
4262
  id_dictionaries = rb_intern("@dictionaries");
4249
4263
 
@@ -4267,6 +4281,8 @@ Init_zlib(void)
4267
4281
  rb_define_const(mZlib, "VERSION", rb_str_new2(RUBY_ZLIB_VERSION));
4268
4282
  /* The string which represents the version of zlib.h */
4269
4283
  rb_define_const(mZlib, "ZLIB_VERSION", rb_str_new2(ZLIB_VERSION));
4284
+ rb_define_const(mZlib, "ZSTD_VERSION", rb_str_new2(ZSTD_versionString()));
4285
+ rb_define_module_function(mZlib, "zstd_version", rb_zstd_version, 0);
4270
4286
 
4271
4287
  cZStream = rb_define_class_under(mZlib, "ZStream", rb_cObject);
4272
4288
  rb_undef_alloc_func(cZStream);
@@ -4290,7 +4306,7 @@ Init_zlib(void)
4290
4306
 
4291
4307
  /* Represents binary data as guessed by deflate.
4292
4308
  *
4293
- * See Zlib::Deflate#data_type. */
4309
+ * See Zstdlib::Deflate#data_type. */
4294
4310
  rb_define_const(mZlib, "BINARY", INT2FIX(Z_BINARY));
4295
4311
 
4296
4312
  /* Represents text data as guessed by deflate.
@@ -4298,19 +4314,19 @@ Init_zlib(void)
4298
4314
  * NOTE: The underlying constant Z_ASCII was deprecated in favor of Z_TEXT
4299
4315
  * in zlib 1.2.2. New applications should not use this constant.
4300
4316
  *
4301
- * See Zlib::Deflate#data_type. */
4317
+ * See Zstdlib::Deflate#data_type. */
4302
4318
  rb_define_const(mZlib, "ASCII", INT2FIX(Z_ASCII));
4303
4319
 
4304
4320
  #ifdef Z_TEXT
4305
4321
  /* Represents text data as guessed by deflate.
4306
4322
  *
4307
- * See Zlib::Deflate#data_type. */
4323
+ * See Zstdlib::Deflate#data_type. */
4308
4324
  rb_define_const(mZlib, "TEXT", INT2FIX(Z_TEXT));
4309
4325
  #endif
4310
4326
 
4311
4327
  /* Represents an unknown data type as guessed by deflate.
4312
4328
  *
4313
- * See Zlib::Deflate#data_type. */
4329
+ * See Zstdlib::Deflate#data_type. */
4314
4330
  rb_define_const(mZlib, "UNKNOWN", INT2FIX(Z_UNKNOWN));
4315
4331
 
4316
4332
  cDeflate = rb_define_class_under(mZlib, "Deflate", cZStream);
@@ -4344,12 +4360,12 @@ Init_zlib(void)
4344
4360
  /* Fastest compression level, but with with lowest space savings. */
4345
4361
  rb_define_const(mZlib, "BEST_SPEED", INT2FIX(Z_BEST_SPEED));
4346
4362
  /* Slowest compression level, but with the best space savings. */
4347
- rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(Z_BEST_COMPRESSION));
4363
+ rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(ZSTD_maxCLevel()));
4348
4364
  /* Default compression level which is a good trade-off between space and
4349
4365
  * time
4350
4366
  */
4351
4367
  rb_define_const(mZlib, "DEFAULT_COMPRESSION",
4352
- INT2FIX(Z_DEFAULT_COMPRESSION));
4368
+ INT2FIX(ZSTD_CLEVEL_DEFAULT));
4353
4369
 
4354
4370
  /* Deflate strategy for data produced by a filter (or predictor). The
4355
4371
  * effect of FILTERED is to force more Huffman codes and less string
@@ -4380,7 +4396,7 @@ Init_zlib(void)
4380
4396
  rb_define_const(mZlib, "DEFAULT_STRATEGY", INT2FIX(Z_DEFAULT_STRATEGY));
4381
4397
 
4382
4398
  /* The maximum size of the zlib history buffer. Note that zlib allows
4383
- * larger values to enable different inflate modes. See Zlib::Inflate.new
4399
+ * larger values to enable different inflate modes. See Zstdlib::Inflate.new
4384
4400
  * for details.
4385
4401
  */
4386
4402
  rb_define_const(mZlib, "MAX_WBITS", INT2FIX(MAX_WBITS));
@@ -4541,28 +4557,28 @@ Init_zlib(void)
4541
4557
  /* Document error classes. */
4542
4558
 
4543
4559
  /*
4544
- * Document-class: Zlib::Error
4560
+ * Document-class: Zstdlib::Error
4545
4561
  *
4546
4562
  * The superclass for all exceptions raised by Ruby/zlib.
4547
4563
  *
4548
- * The following exceptions are defined as subclasses of Zlib::Error. These
4564
+ * The following exceptions are defined as subclasses of Zstdlib::Error. These
4549
4565
  * exceptions are raised when zlib library functions return with an error
4550
4566
  * status.
4551
4567
  *
4552
- * - Zlib::StreamEnd
4553
- * - Zlib::NeedDict
4554
- * - Zlib::DataError
4555
- * - Zlib::StreamError
4556
- * - Zlib::MemError
4557
- * - Zlib::BufError
4558
- * - Zlib::VersionError
4568
+ * - Zstdlib::StreamEnd
4569
+ * - Zstdlib::NeedDict
4570
+ * - Zstdlib::DataError
4571
+ * - Zstdlib::StreamError
4572
+ * - Zstdlib::MemError
4573
+ * - Zstdlib::BufError
4574
+ * - Zstdlib::VersionError
4559
4575
  *
4560
4576
  */
4561
4577
 
4562
4578
  /*
4563
- * Document-class: Zlib::StreamEnd
4579
+ * Document-class: Zstdlib::StreamEnd
4564
4580
  *
4565
- * Subclass of Zlib::Error
4581
+ * Subclass of Zstdlib::Error
4566
4582
  *
4567
4583
  * When zlib returns a Z_STREAM_END
4568
4584
  * is return if the end of the compressed data has been reached
@@ -4571,20 +4587,20 @@ Init_zlib(void)
4571
4587
  */
4572
4588
 
4573
4589
  /*
4574
- * Document-class: Zlib::NeedDict
4590
+ * Document-class: Zstdlib::NeedDict
4575
4591
  *
4576
- * Subclass of Zlib::Error
4592
+ * Subclass of Zstdlib::Error
4577
4593
  *
4578
4594
  * When zlib returns a Z_NEED_DICT
4579
4595
  * if a preset dictionary is needed at this point.
4580
4596
  *
4581
- * Used by Zlib::Inflate.inflate and <tt>Zlib.inflate</tt>
4597
+ * Used by Zstdlib::Inflate.inflate and <tt>Zstdlib.inflate</tt>
4582
4598
  */
4583
4599
 
4584
4600
  /*
4585
- * Document-class: Zlib::VersionError
4601
+ * Document-class: Zstdlib::VersionError
4586
4602
  *
4587
- * Subclass of Zlib::Error
4603
+ * Subclass of Zstdlib::Error
4588
4604
  *
4589
4605
  * When zlib returns a Z_VERSION_ERROR,
4590
4606
  * usually if the zlib library version is incompatible with the
@@ -4593,9 +4609,9 @@ Init_zlib(void)
4593
4609
  */
4594
4610
 
4595
4611
  /*
4596
- * Document-class: Zlib::MemError
4612
+ * Document-class: Zstdlib::MemError
4597
4613
  *
4598
- * Subclass of Zlib::Error
4614
+ * Subclass of Zstdlib::Error
4599
4615
  *
4600
4616
  * When zlib returns a Z_MEM_ERROR,
4601
4617
  * usually if there was not enough memory.
@@ -4603,9 +4619,9 @@ Init_zlib(void)
4603
4619
  */
4604
4620
 
4605
4621
  /*
4606
- * Document-class: Zlib::StreamError
4622
+ * Document-class: Zstdlib::StreamError
4607
4623
  *
4608
- * Subclass of Zlib::Error
4624
+ * Subclass of Zstdlib::Error
4609
4625
  *
4610
4626
  * When zlib returns a Z_STREAM_ERROR,
4611
4627
  * usually if the stream state was inconsistent.
@@ -4613,44 +4629,44 @@ Init_zlib(void)
4613
4629
  */
4614
4630
 
4615
4631
  /*
4616
- * Document-class: Zlib::BufError
4632
+ * Document-class: Zstdlib::BufError
4617
4633
  *
4618
- * Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR.
4634
+ * Subclass of Zstdlib::Error when zlib returns a Z_BUF_ERROR.
4619
4635
  *
4620
4636
  * Usually if no progress is possible.
4621
4637
  *
4622
4638
  */
4623
4639
 
4624
4640
  /*
4625
- * Document-class: Zlib::DataError
4641
+ * Document-class: Zstdlib::DataError
4626
4642
  *
4627
- * Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR.
4643
+ * Subclass of Zstdlib::Error when zlib returns a Z_DATA_ERROR.
4628
4644
  *
4629
4645
  * Usually if a stream was prematurely freed.
4630
4646
  *
4631
4647
  */
4632
4648
 
4633
4649
  /*
4634
- * Document-class: Zlib::GzipFile::Error
4650
+ * Document-class: Zstdlib::GzipFile::Error
4635
4651
  *
4636
4652
  * Base class of errors that occur when processing GZIP files.
4637
4653
  */
4638
4654
 
4639
4655
  /*
4640
- * Document-class: Zlib::GzipFile::NoFooter
4656
+ * Document-class: Zstdlib::GzipFile::NoFooter
4641
4657
  *
4642
4658
  * Raised when gzip file footer is not found.
4643
4659
  */
4644
4660
 
4645
4661
  /*
4646
- * Document-class: Zlib::GzipFile::CRCError
4662
+ * Document-class: Zstdlib::GzipFile::CRCError
4647
4663
  *
4648
4664
  * Raised when the CRC checksum recorded in gzip file footer is not equivalent
4649
4665
  * to the CRC checksum of the actual uncompressed data.
4650
4666
  */
4651
4667
 
4652
4668
  /*
4653
- * Document-class: Zlib::GzipFile::LengthError
4669
+ * Document-class: Zstdlib::GzipFile::LengthError
4654
4670
  *
4655
4671
  * Raised when the data length recorded in the gzip file footer is not equivalent
4656
4672
  * to the length of the actual uncompressed data.