zstdlib 0.11.0-x64-mingw-ucrt → 0.13.0-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +16 -0
  3. data/Rakefile +1 -1
  4. data/ext/zstdlib_c/extconf.rb +9 -4
  5. data/ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c +5090 -0
  6. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/adler32.c +5 -27
  7. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/compress.c +5 -16
  8. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/crc32.c +94 -161
  9. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/deflate.c +362 -434
  10. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/deflate.h +43 -12
  11. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzclose.c +1 -3
  12. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzguts.h +13 -18
  13. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzlib.c +28 -85
  14. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzread.c +23 -73
  15. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzwrite.c +19 -65
  16. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/infback.c +17 -30
  17. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffast.c +1 -4
  18. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffast.h +1 -1
  19. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inflate.c +36 -102
  20. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inftrees.c +6 -11
  21. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inftrees.h +6 -6
  22. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/trees.c +290 -355
  23. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/uncompr.c +4 -12
  24. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zconf.h +23 -14
  25. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zlib.h +202 -199
  26. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zutil.c +18 -44
  27. data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zutil.h +13 -33
  28. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/allocations.h +1 -1
  29. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/bitstream.h +49 -29
  30. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/compiler.h +114 -22
  31. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/cpu.h +36 -0
  32. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/debug.c +6 -0
  33. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/debug.h +20 -11
  34. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/error_private.h +45 -36
  35. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/fse.h +3 -2
  36. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/fse_decompress.c +19 -17
  37. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/huf.h +14 -1
  38. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/mem.h +0 -9
  39. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/pool.c +1 -1
  40. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/pool.h +1 -1
  41. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/portability_macros.h +2 -0
  42. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/threading.c +8 -2
  43. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/xxhash.c +5 -11
  44. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/xxhash.h +2341 -1007
  45. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_internal.h +5 -5
  46. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/fse_compress.c +8 -7
  47. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/huf_compress.c +54 -25
  48. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress.c +282 -161
  49. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_internal.h +29 -27
  50. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_superblock.c +224 -113
  51. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_cwksp.h +19 -13
  52. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_double_fast.c +17 -5
  53. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_double_fast.h +11 -0
  54. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_fast.c +14 -6
  55. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_lazy.c +129 -87
  56. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_lazy.h +103 -28
  57. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_ldm.c +8 -2
  58. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_opt.c +216 -112
  59. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_opt.h +31 -7
  60. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstdmt_compress.c +94 -79
  61. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/huf_decompress.c +188 -126
  62. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/huf_decompress_amd64.S +38 -19
  63. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress.c +84 -32
  64. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress_block.c +231 -208
  65. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress_block.h +1 -1
  66. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress_internal.h +2 -0
  67. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/zstd.h +129 -60
  68. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzclose.c +1 -3
  69. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzlib.c +20 -73
  70. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzread.c +17 -58
  71. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzwrite.c +18 -58
  72. data/lib/3.1/zstdlib_c.so +0 -0
  73. data/lib/3.2/zstdlib_c.so +0 -0
  74. data/lib/3.3/zstdlib_c.so +0 -0
  75. metadata +105 -103
  76. /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/crc32.h +0 -0
  77. /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffixed.h +0 -0
  78. /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inflate.h +0 -0
  79. /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/trees.h +0 -0
  80. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/bits.h +0 -0
  81. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/entropy_common.c +0 -0
  82. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/error_private.c +0 -0
  83. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/threading.h +0 -0
  84. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_common.c +0 -0
  85. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_deps.h +0 -0
  86. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_trace.h +0 -0
  87. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/clevels.h +0 -0
  88. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/hist.c +0 -0
  89. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/hist.h +0 -0
  90. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_literals.c +0 -0
  91. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_literals.h +0 -0
  92. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_sequences.c +0 -0
  93. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_sequences.h +0 -0
  94. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_superblock.h +0 -0
  95. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_fast.h +0 -0
  96. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_ldm.h +0 -0
  97. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_ldm_geartab.h +0 -0
  98. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstdmt_compress.h +0 -0
  99. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_ddict.c +0 -0
  100. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_ddict.h +0 -0
  101. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/zdict.h +0 -0
  102. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/zstd_errors.h +0 -0
  103. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzcompatibility.h +0 -0
  104. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzguts.h +0 -0
  105. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/zstd_zlibwrapper.c +0 -0
  106. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/zstd_zlibwrapper.h +0 -0
@@ -1,5 +1,5 @@
1
1
  /* deflate.h -- internal compression state
2
- * Copyright (C) 1995-2018 Jean-loup Gailly
2
+ * Copyright (C) 1995-2024 Jean-loup Gailly
3
3
  * For conditions of distribution and use, see copyright notice in zlib.h
4
4
  */
5
5
 
@@ -23,6 +23,10 @@
23
23
  # define GZIP
24
24
  #endif
25
25
 
26
+ /* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
27
+ the cost of a larger memory footprint */
28
+ /* #define LIT_MEM */
29
+
26
30
  /* ===========================================================================
27
31
  * Internal compression state.
28
32
  */
@@ -217,7 +221,14 @@ typedef struct internal_state {
217
221
  /* Depth of each subtree used as tie breaker for trees of equal frequency
218
222
  */
219
223
 
224
+ #ifdef LIT_MEM
225
+ # define LIT_BUFS 5
226
+ ushf *d_buf; /* buffer for distances */
227
+ uchf *l_buf; /* buffer for literals/lengths */
228
+ #else
229
+ # define LIT_BUFS 4
220
230
  uchf *sym_buf; /* buffer for distances and literals/lengths */
231
+ #endif
221
232
 
222
233
  uInt lit_bufsize;
223
234
  /* Size of match buffer for literals/lengths. There are 4 reasons for
@@ -239,7 +250,7 @@ typedef struct internal_state {
239
250
  * - I can't count above 4
240
251
  */
241
252
 
242
- uInt sym_next; /* running index in sym_buf */
253
+ uInt sym_next; /* running index in symbol buffer */
243
254
  uInt sym_end; /* symbol table full when sym_next reaches this */
244
255
 
245
256
  ulg opt_len; /* bit length of current block with optimal trees */
@@ -291,14 +302,14 @@ typedef struct internal_state {
291
302
  memory checker errors from longest match routines */
292
303
 
293
304
  /* in trees.c */
294
- void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
295
- int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
296
- void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
297
- ulg stored_len, int last));
298
- void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
299
- void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
300
- void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
301
- ulg stored_len, int last));
305
+ void ZLIB_INTERNAL _tr_init(deflate_state *s);
306
+ int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
307
+ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
308
+ ulg stored_len, int last);
309
+ void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
310
+ void ZLIB_INTERNAL _tr_align(deflate_state *s);
311
+ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
312
+ ulg stored_len, int last);
302
313
 
303
314
  #define d_code(dist) \
304
315
  ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
@@ -318,6 +329,25 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
318
329
  extern const uch ZLIB_INTERNAL _dist_code[];
319
330
  #endif
320
331
 
332
+ #ifdef LIT_MEM
333
+ # define _tr_tally_lit(s, c, flush) \
334
+ { uch cc = (c); \
335
+ s->d_buf[s->sym_next] = 0; \
336
+ s->l_buf[s->sym_next++] = cc; \
337
+ s->dyn_ltree[cc].Freq++; \
338
+ flush = (s->sym_next == s->sym_end); \
339
+ }
340
+ # define _tr_tally_dist(s, distance, length, flush) \
341
+ { uch len = (uch)(length); \
342
+ ush dist = (ush)(distance); \
343
+ s->d_buf[s->sym_next] = dist; \
344
+ s->l_buf[s->sym_next++] = len; \
345
+ dist--; \
346
+ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
347
+ s->dyn_dtree[d_code(dist)].Freq++; \
348
+ flush = (s->sym_next == s->sym_end); \
349
+ }
350
+ #else
321
351
  # define _tr_tally_lit(s, c, flush) \
322
352
  { uch cc = (c); \
323
353
  s->sym_buf[s->sym_next++] = 0; \
@@ -329,14 +359,15 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
329
359
  # define _tr_tally_dist(s, distance, length, flush) \
330
360
  { uch len = (uch)(length); \
331
361
  ush dist = (ush)(distance); \
332
- s->sym_buf[s->sym_next++] = dist; \
333
- s->sym_buf[s->sym_next++] = dist >> 8; \
362
+ s->sym_buf[s->sym_next++] = (uch)dist; \
363
+ s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
334
364
  s->sym_buf[s->sym_next++] = len; \
335
365
  dist--; \
336
366
  s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
337
367
  s->dyn_dtree[d_code(dist)].Freq++; \
338
368
  flush = (s->sym_next == s->sym_end); \
339
369
  }
370
+ #endif
340
371
  #else
341
372
  # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
342
373
  # define _tr_tally_dist(s, distance, length, flush) \
@@ -8,9 +8,7 @@
8
8
  /* gzclose() is in a separate file so that it is linked in only if it is used.
9
9
  That way the other gzclose functions can be used instead to avoid linking in
10
10
  unneeded compression or decompression routines. */
11
- int ZEXPORT gzclose(file)
12
- gzFile file;
13
- {
11
+ int ZEXPORT gzclose(gzFile file) {
14
12
  #ifndef NO_GZCOMPRESS
15
13
  gz_statep state;
16
14
 
@@ -1,5 +1,5 @@
1
1
  /* gzguts.h -- zlib internal header definitions for gz* operations
2
- * Copyright (C) 2004-2019 Mark Adler
2
+ * Copyright (C) 2004-2024 Mark Adler
3
3
  * For conditions of distribution and use, see copyright notice in zlib.h
4
4
  */
5
5
 
@@ -7,9 +7,8 @@
7
7
  # ifndef _LARGEFILE_SOURCE
8
8
  # define _LARGEFILE_SOURCE 1
9
9
  # endif
10
- # ifdef _FILE_OFFSET_BITS
11
- # undef _FILE_OFFSET_BITS
12
- # endif
10
+ # undef _FILE_OFFSET_BITS
11
+ # undef _TIME_BITS
13
12
  #endif
14
13
 
15
14
  #ifdef HAVE_HIDDEN
@@ -119,8 +118,8 @@
119
118
 
120
119
  /* gz* functions always use library allocation functions */
121
120
  #ifndef STDC
122
- extern voidp malloc OF((uInt size));
123
- extern void free OF((voidpf ptr));
121
+ extern voidp malloc(uInt size);
122
+ extern void free(voidpf ptr);
124
123
  #endif
125
124
 
126
125
  /* get errno and strerror definition */
@@ -138,10 +137,10 @@
138
137
 
139
138
  /* provide prototypes for these when building zlib without LFS */
140
139
  #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
141
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
142
- ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
143
- ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
144
- ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
140
+ ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
141
+ ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
142
+ ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
143
+ ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
145
144
  #endif
146
145
 
147
146
  /* default memLevel */
@@ -203,17 +202,13 @@ typedef struct {
203
202
  typedef gz_state FAR *gz_statep;
204
203
 
205
204
  /* shared functions */
206
- void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
205
+ void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
207
206
  #if defined UNDER_CE
208
- char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
207
+ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
209
208
  #endif
210
209
 
211
210
  /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
212
211
  value -- needed when comparing unsigned to z_off64_t, which is signed
213
212
  (possible z_off64_t types off_t, off64_t, and long are all signed) */
214
- #ifdef INT_MAX
215
- # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
216
- #else
217
- unsigned ZLIB_INTERNAL gz_intmax OF((void));
218
- # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
219
- #endif
213
+ unsigned ZLIB_INTERNAL gz_intmax(void);
214
+ #define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
@@ -1,5 +1,5 @@
1
1
  /* gzlib.c -- zlib functions common to reading and writing gzip files
2
- * Copyright (C) 2004-2019 Mark Adler
2
+ * Copyright (C) 2004-2024 Mark Adler
3
3
  * For conditions of distribution and use, see copyright notice in zlib.h
4
4
  */
5
5
 
@@ -15,10 +15,6 @@
15
15
  #endif
16
16
  #endif
17
17
 
18
- /* Local functions */
19
- local void gz_reset OF((gz_statep));
20
- local gzFile gz_open OF((const void *, int, const char *));
21
-
22
18
  #if defined UNDER_CE
23
19
 
24
20
  /* Map the Windows error number in ERROR to a locale-dependent error message
@@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *));
30
26
 
31
27
  The gz_strwinerror function does not change the current setting of
32
28
  GetLastError. */
33
- char ZLIB_INTERNAL *gz_strwinerror (error)
34
- DWORD error;
35
- {
29
+ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
36
30
  static char buf[1024];
37
31
 
38
32
  wchar_t *msgbuf;
@@ -72,9 +66,7 @@ char ZLIB_INTERNAL *gz_strwinerror (error)
72
66
  #endif /* UNDER_CE */
73
67
 
74
68
  /* Reset gzip file state */
75
- local void gz_reset(state)
76
- gz_statep state;
77
- {
69
+ local void gz_reset(gz_statep state) {
78
70
  state->x.have = 0; /* no output data available */
79
71
  if (state->mode == GZ_READ) { /* for reading ... */
80
72
  state->eof = 0; /* not at end of file */
@@ -90,11 +82,7 @@ local void gz_reset(state)
90
82
  }
91
83
 
92
84
  /* Open a gzip file either by name or file descriptor. */
93
- local gzFile gz_open(path, fd, mode)
94
- const void *path;
95
- int fd;
96
- const char *mode;
97
- {
85
+ local gzFile gz_open(const void *path, int fd, const char *mode) {
98
86
  gz_statep state;
99
87
  z_size_t len;
100
88
  int oflag;
@@ -269,26 +257,17 @@ local gzFile gz_open(path, fd, mode)
269
257
  }
270
258
 
271
259
  /* -- see zlib.h -- */
272
- gzFile ZEXPORT gzopen(path, mode)
273
- const char *path;
274
- const char *mode;
275
- {
260
+ gzFile ZEXPORT gzopen(const char *path, const char *mode) {
276
261
  return gz_open(path, -1, mode);
277
262
  }
278
263
 
279
264
  /* -- see zlib.h -- */
280
- gzFile ZEXPORT gzopen64(path, mode)
281
- const char *path;
282
- const char *mode;
283
- {
265
+ gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
284
266
  return gz_open(path, -1, mode);
285
267
  }
286
268
 
287
269
  /* -- see zlib.h -- */
288
- gzFile ZEXPORT gzdopen(fd, mode)
289
- int fd;
290
- const char *mode;
291
- {
270
+ gzFile ZEXPORT gzdopen(int fd, const char *mode) {
292
271
  char *path; /* identifier for error messages */
293
272
  gzFile gz;
294
273
 
@@ -306,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
306
285
 
307
286
  /* -- see zlib.h -- */
308
287
  #ifdef WIDECHAR
309
- gzFile ZEXPORT gzopen_w(path, mode)
310
- const wchar_t *path;
311
- const char *mode;
312
- {
288
+ gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
313
289
  return gz_open(path, -2, mode);
314
290
  }
315
291
  #endif
316
292
 
317
293
  /* -- see zlib.h -- */
318
- int ZEXPORT gzbuffer(file, size)
319
- gzFile file;
320
- unsigned size;
321
- {
294
+ int ZEXPORT gzbuffer(gzFile file, unsigned size) {
322
295
  gz_statep state;
323
296
 
324
297
  /* get internal structure and check integrity */
@@ -335,16 +308,14 @@ int ZEXPORT gzbuffer(file, size)
335
308
  /* check and set requested size */
336
309
  if ((size << 1) < size)
337
310
  return -1; /* need to be able to double it */
338
- if (size < 2)
339
- size = 2; /* need two bytes to check magic header */
311
+ if (size < 8)
312
+ size = 8; /* needed to behave well with flushing */
340
313
  state->want = size;
341
314
  return 0;
342
315
  }
343
316
 
344
317
  /* -- see zlib.h -- */
345
- int ZEXPORT gzrewind(file)
346
- gzFile file;
347
- {
318
+ int ZEXPORT gzrewind(gzFile file) {
348
319
  gz_statep state;
349
320
 
350
321
  /* get internal structure */
@@ -365,11 +336,7 @@ int ZEXPORT gzrewind(file)
365
336
  }
366
337
 
367
338
  /* -- see zlib.h -- */
368
- z_off64_t ZEXPORT gzseek64(file, offset, whence)
369
- gzFile file;
370
- z_off64_t offset;
371
- int whence;
372
- {
339
+ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
373
340
  unsigned n;
374
341
  z_off64_t ret;
375
342
  gz_statep state;
@@ -442,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
442
409
  }
443
410
 
444
411
  /* -- see zlib.h -- */
445
- z_off_t ZEXPORT gzseek(file, offset, whence)
446
- gzFile file;
447
- z_off_t offset;
448
- int whence;
449
- {
412
+ z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
450
413
  z_off64_t ret;
451
414
 
452
415
  ret = gzseek64(file, (z_off64_t)offset, whence);
@@ -454,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
454
417
  }
455
418
 
456
419
  /* -- see zlib.h -- */
457
- z_off64_t ZEXPORT gztell64(file)
458
- gzFile file;
459
- {
420
+ z_off64_t ZEXPORT gztell64(gzFile file) {
460
421
  gz_statep state;
461
422
 
462
423
  /* get internal structure and check integrity */
@@ -471,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file)
471
432
  }
472
433
 
473
434
  /* -- see zlib.h -- */
474
- z_off_t ZEXPORT gztell(file)
475
- gzFile file;
476
- {
435
+ z_off_t ZEXPORT gztell(gzFile file) {
477
436
  z_off64_t ret;
478
437
 
479
438
  ret = gztell64(file);
@@ -481,9 +440,7 @@ z_off_t ZEXPORT gztell(file)
481
440
  }
482
441
 
483
442
  /* -- see zlib.h -- */
484
- z_off64_t ZEXPORT gzoffset64(file)
485
- gzFile file;
486
- {
443
+ z_off64_t ZEXPORT gzoffset64(gzFile file) {
487
444
  z_off64_t offset;
488
445
  gz_statep state;
489
446
 
@@ -504,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file)
504
461
  }
505
462
 
506
463
  /* -- see zlib.h -- */
507
- z_off_t ZEXPORT gzoffset(file)
508
- gzFile file;
509
- {
464
+ z_off_t ZEXPORT gzoffset(gzFile file) {
510
465
  z_off64_t ret;
511
466
 
512
467
  ret = gzoffset64(file);
@@ -514,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file)
514
469
  }
515
470
 
516
471
  /* -- see zlib.h -- */
517
- int ZEXPORT gzeof(file)
518
- gzFile file;
519
- {
472
+ int ZEXPORT gzeof(gzFile file) {
520
473
  gz_statep state;
521
474
 
522
475
  /* get internal structure and check integrity */
@@ -531,10 +484,7 @@ int ZEXPORT gzeof(file)
531
484
  }
532
485
 
533
486
  /* -- see zlib.h -- */
534
- const char * ZEXPORT gzerror(file, errnum)
535
- gzFile file;
536
- int *errnum;
537
- {
487
+ const char * ZEXPORT gzerror(gzFile file, int *errnum) {
538
488
  gz_statep state;
539
489
 
540
490
  /* get internal structure and check integrity */
@@ -552,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum)
552
502
  }
553
503
 
554
504
  /* -- see zlib.h -- */
555
- void ZEXPORT gzclearerr(file)
556
- gzFile file;
557
- {
505
+ void ZEXPORT gzclearerr(gzFile file) {
558
506
  gz_statep state;
559
507
 
560
508
  /* get internal structure and check integrity */
@@ -578,11 +526,7 @@ void ZEXPORT gzclearerr(file)
578
526
  memory). Simply save the error message as a static string. If there is an
579
527
  allocation failure constructing the error message, then convert the error to
580
528
  out of memory. */
581
- void ZLIB_INTERNAL gz_error(state, err, msg)
582
- gz_statep state;
583
- int err;
584
- const char *msg;
585
- {
529
+ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
586
530
  /* free previously allocated message and clear */
587
531
  if (state->msg != NULL) {
588
532
  if (state->err != Z_MEM_ERROR)
@@ -619,21 +563,20 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
619
563
  #endif
620
564
  }
621
565
 
622
- #ifndef INT_MAX
623
566
  /* portably return maximum value for an int (when limits.h presumed not
624
567
  available) -- we need to do this to cover cases where 2's complement not
625
568
  used, since C standard permits 1's complement and sign-bit representations,
626
569
  otherwise we could just use ((unsigned)-1) >> 1 */
627
- unsigned ZLIB_INTERNAL gz_intmax()
628
- {
629
- unsigned p, q;
630
-
631
- p = 1;
570
+ unsigned ZLIB_INTERNAL gz_intmax(void) {
571
+ #ifdef INT_MAX
572
+ return INT_MAX;
573
+ #else
574
+ unsigned p = 1, q;
632
575
  do {
633
576
  q = p;
634
577
  p <<= 1;
635
578
  p++;
636
579
  } while (p > q);
637
580
  return q >> 1;
638
- }
639
581
  #endif
582
+ }
@@ -5,25 +5,12 @@
5
5
 
6
6
  #include "gzguts.h"
7
7
 
8
- /* Local functions */
9
- local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
10
- local int gz_avail OF((gz_statep));
11
- local int gz_look OF((gz_statep));
12
- local int gz_decomp OF((gz_statep));
13
- local int gz_fetch OF((gz_statep));
14
- local int gz_skip OF((gz_statep, z_off64_t));
15
- local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
16
-
17
8
  /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
18
9
  state->fd, and update state->eof, state->err, and state->msg as appropriate.
19
10
  This function needs to loop on read(), since read() is not guaranteed to
20
11
  read the number of bytes requested, depending on the type of descriptor. */
21
- local int gz_load(state, buf, len, have)
22
- gz_statep state;
23
- unsigned char *buf;
24
- unsigned len;
25
- unsigned *have;
26
- {
12
+ local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
13
+ unsigned *have) {
27
14
  int ret;
28
15
  unsigned get, max = ((unsigned)-1 >> 2) + 1;
29
16
 
@@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have)
53
40
  If strm->avail_in != 0, then the current data is moved to the beginning of
54
41
  the input buffer, and then the remainder of the buffer is loaded with the
55
42
  available data from the input file. */
56
- local int gz_avail(state)
57
- gz_statep state;
58
- {
43
+ local int gz_avail(gz_statep state) {
59
44
  unsigned got;
60
45
  z_streamp strm = &(state->strm);
61
46
 
@@ -88,9 +73,7 @@ local int gz_avail(state)
88
73
  case, all further file reads will be directly to either the output buffer or
89
74
  a user buffer. If decompressing, the inflate state will be initialized.
90
75
  gz_look() will return 0 on success or -1 on failure. */
91
- local int gz_look(state)
92
- gz_statep state;
93
- {
76
+ local int gz_look(gz_statep state) {
94
77
  z_streamp strm = &(state->strm);
95
78
 
96
79
  /* allocate read buffers and inflate memory */
@@ -157,11 +140,9 @@ local int gz_look(state)
157
140
  the output buffer is larger than the input buffer, which also assures
158
141
  space for gzungetc() */
159
142
  state->x.next = state->out;
160
- if (strm->avail_in) {
161
- memcpy(state->x.next, strm->next_in, strm->avail_in);
162
- state->x.have = strm->avail_in;
163
- strm->avail_in = 0;
164
- }
143
+ memcpy(state->x.next, strm->next_in, strm->avail_in);
144
+ state->x.have = strm->avail_in;
145
+ strm->avail_in = 0;
165
146
  state->how = COPY;
166
147
  state->direct = 1;
167
148
  return 0;
@@ -172,9 +153,7 @@ local int gz_look(state)
172
153
  data. If the gzip stream completes, state->how is reset to LOOK to look for
173
154
  the next gzip stream or raw data, once state->x.have is depleted. Returns 0
174
155
  on success, -1 on failure. */
175
- local int gz_decomp(state)
176
- gz_statep state;
177
- {
156
+ local int gz_decomp(gz_statep state) {
178
157
  int ret = Z_OK;
179
158
  unsigned had;
180
159
  z_streamp strm = &(state->strm);
@@ -226,9 +205,7 @@ local int gz_decomp(state)
226
205
  looked for to determine whether to copy or decompress. Returns -1 on error,
227
206
  otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
228
207
  end of the input file has been reached and all data has been processed. */
229
- local int gz_fetch(state)
230
- gz_statep state;
231
- {
208
+ local int gz_fetch(gz_statep state) {
232
209
  z_streamp strm = &(state->strm);
233
210
 
234
211
  do {
@@ -256,10 +233,7 @@ local int gz_fetch(state)
256
233
  }
257
234
 
258
235
  /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
259
- local int gz_skip(state, len)
260
- gz_statep state;
261
- z_off64_t len;
262
- {
236
+ local int gz_skip(gz_statep state, z_off64_t len) {
263
237
  unsigned n;
264
238
 
265
239
  /* skip over len bytes or reach end-of-file, whichever comes first */
@@ -291,11 +265,7 @@ local int gz_skip(state, len)
291
265
  input. Return the number of bytes read. If zero is returned, either the
292
266
  end of file was reached, or there was an error. state->err must be
293
267
  consulted in that case to determine which. */
294
- local z_size_t gz_read(state, buf, len)
295
- gz_statep state;
296
- voidp buf;
297
- z_size_t len;
298
- {
268
+ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
299
269
  z_size_t got;
300
270
  unsigned n;
301
271
 
@@ -372,11 +342,7 @@ local z_size_t gz_read(state, buf, len)
372
342
  }
373
343
 
374
344
  /* -- see zlib.h -- */
375
- int ZEXPORT gzread(file, buf, len)
376
- gzFile file;
377
- voidp buf;
378
- unsigned len;
379
- {
345
+ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
380
346
  gz_statep state;
381
347
 
382
348
  /* get internal structure */
@@ -408,12 +374,7 @@ int ZEXPORT gzread(file, buf, len)
408
374
  }
409
375
 
410
376
  /* -- see zlib.h -- */
411
- z_size_t ZEXPORT gzfread(buf, size, nitems, file)
412
- voidp buf;
413
- z_size_t size;
414
- z_size_t nitems;
415
- gzFile file;
416
- {
377
+ z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
417
378
  z_size_t len;
418
379
  gz_statep state;
419
380
 
@@ -444,9 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
444
405
  #else
445
406
  # undef gzgetc
446
407
  #endif
447
- int ZEXPORT gzgetc(file)
448
- gzFile file;
449
- {
408
+ int ZEXPORT gzgetc(gzFile file) {
450
409
  unsigned char buf[1];
451
410
  gz_statep state;
452
411
 
@@ -471,17 +430,12 @@ int ZEXPORT gzgetc(file)
471
430
  return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
472
431
  }
473
432
 
474
- int ZEXPORT gzgetc_(file)
475
- gzFile file;
476
- {
433
+ int ZEXPORT gzgetc_(gzFile file) {
477
434
  return gzgetc(file);
478
435
  }
479
436
 
480
437
  /* -- see zlib.h -- */
481
- int ZEXPORT gzungetc(c, file)
482
- int c;
483
- gzFile file;
484
- {
438
+ int ZEXPORT gzungetc(int c, gzFile file) {
485
439
  gz_statep state;
486
440
 
487
441
  /* get internal structure */
@@ -489,6 +443,10 @@ int ZEXPORT gzungetc(c, file)
489
443
  return -1;
490
444
  state = (gz_statep)file;
491
445
 
446
+ /* in case this was just opened, set up the input buffer */
447
+ if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
448
+ (void)gz_look(state);
449
+
492
450
  /* check that we're reading and that there's no (serious) error */
493
451
  if (state->mode != GZ_READ ||
494
452
  (state->err != Z_OK && state->err != Z_BUF_ERROR))
@@ -538,11 +496,7 @@ int ZEXPORT gzungetc(c, file)
538
496
  }
539
497
 
540
498
  /* -- see zlib.h -- */
541
- char * ZEXPORT gzgets(file, buf, len)
542
- gzFile file;
543
- char *buf;
544
- int len;
545
- {
499
+ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
546
500
  unsigned left, n;
547
501
  char *str;
548
502
  unsigned char *eol;
@@ -602,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len)
602
556
  }
603
557
 
604
558
  /* -- see zlib.h -- */
605
- int ZEXPORT gzdirect(file)
606
- gzFile file;
607
- {
559
+ int ZEXPORT gzdirect(gzFile file) {
608
560
  gz_statep state;
609
561
 
610
562
  /* get internal structure */
@@ -622,9 +574,7 @@ int ZEXPORT gzdirect(file)
622
574
  }
623
575
 
624
576
  /* -- see zlib.h -- */
625
- int ZEXPORT gzclose_r(file)
626
- gzFile file;
627
- {
577
+ int ZEXPORT gzclose_r(gzFile file) {
628
578
  int ret, err;
629
579
  gz_statep state;
630
580