Commit da8a8b8bcf492544902e5a82bad1d0f5c156939c

Werner Lemberg 2022-01-10T17:25:47

[zlib] Some organizational changes. We now first apply zlib's `zlib2ansi` script, then FreeType's patch file. * src/gzip/README.freetype: Updated. * patches/0001-zlib-Fix-zlib-sources-to-compile-for-FreeType.patch: Renamed to... * patches/freetype-zlib.diff: This. Clean up description, then regenerate it as follows: - Copy unmodified files from `zlib` repository. - Run `zlib2ansi` script. - Run `git diff -R > patches/freetype-zlib.diff.new`. - Insert patch description of old diff file, then replace old diff with new diff file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
diff --git a/src/gzip/README.freetype b/src/gzip/README.freetype
index ce77920..646ac2e 100644
--- a/src/gzip/README.freetype
+++ b/src/gzip/README.freetype
@@ -18,5 +18,5 @@ The files in this directory have been prepared as follows.
 
  - Take the unmodified source code files from the zlib distribution that are
    included by `ftgzip.c`.
- - Apply the diff file(s) in the `patches` folder.
  - Run zlib's `zlib2ansi` script on all `.c` files.
+ - Apply the diff file(s) in the `patches` folder.
diff --git a/src/gzip/gzguts.h b/src/gzip/gzguts.h
index a27f389..c81f8f3 100644
--- a/src/gzip/gzguts.h
+++ b/src/gzip/gzguts.h
@@ -163,7 +163,7 @@
 
 /* values for gz_state how */
 #define LOOK 0      /* look for a gzip header */
-#define COPY__ 1      /* copy input directly */
+#define COPY__ 1    /* copy input directly */
 #define GZIP 2      /* decompress a gzip stream */
 
 /* internal gzip file state data structure */
diff --git a/src/gzip/patches/0001-zlib-Fix-zlib-sources-to-compile-for-FreeType.patch b/src/gzip/patches/0001-zlib-Fix-zlib-sources-to-compile-for-FreeType.patch
deleted file mode 100644
index 385baa7..0000000
--- a/src/gzip/patches/0001-zlib-Fix-zlib-sources-to-compile-for-FreeType.patch
+++ /dev/null
@@ -1,419 +0,0 @@
-From 2977ff0df909f939517e9857943938ff84201a26 Mon Sep 17 00:00:00 2001
-From: David Turner <david@freetype.org>
-Date: Wed, 18 Aug 2021 00:17:35 +0200
-Subject: [zlib] Fix zlib sources to compile for FreeType
-
-Fix misc zlib sources to ensure that they do not issue compiler
-warnings when they are compiled as part of src/gzip/ftgzip.c.
-
-* src/gzip/adler32.c: Do not define unused functions when Z_FREETYPE
-  is set.
-
-* src/gzip/crc32.c: Undefined DO1 and DO8 macros that are already
-  defined in adler32.c.
-
-* src/gzip/gzguts.h: Rename COPY macro to COPY__ since COPY and
-  COPY_ conflict with enum values with the same name in
-  zlib.h.
-
-* src/gzip/inflate.c, src/gzip/adler32.c: Omit unused function
-  declarations when Z_FREETYPE is defined.
-
-* src/gzip/zlib.h: Include "ftzconf.h" instead of "zconf.h" to
-  avoid conflicts with system-installed headers. Omit unused
-  function declarations when Z_FREETYPE is defined.
-
-* src/gzip/zutil.h: Use ft_memxxx() functions instead of memxxx().
-  Omit unused function declarations when Z_FREETYPE is defined.
-
-* src/gzip/inflate.h, src/gzip/inftrees.h: Add header guard macros
-  to prevent compiler errors.
----
- src/gzip/adler32.c  |  6 ++++++
- src/gzip/crc32.c    |  2 ++
- src/gzip/gzguts.h   |  2 +-
- src/gzip/inflate.c  | 18 ++++++++++++++++++
- src/gzip/inflate.h  |  5 +++++
- src/gzip/inftrees.h |  5 +++++
- src/gzip/zlib.h     | 39 ++++++++++++++++++++++++++++++++++++---
- src/gzip/zutil.h    | 10 +++++++---
- 8 files changed, 80 insertions(+), 7 deletions(-)
-
-diff --git a/src/gzip/adler32.c b/src/gzip/adler32.c
-index d0be4380a..a8242ba13 100644
---- a/src/gzip/adler32.c
-+++ b/src/gzip/adler32.c
-@@ -7,7 +7,9 @@
- 
- #include "zutil.h"
- 
-+#ifndef Z_FREETYPE
- local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
-+#endif
- 
- #define BASE 65521U     /* largest prime smaller than 65536 */
- #define NMAX 5552
-@@ -139,6 +141,8 @@ uLong ZEXPORT adler32(adler, buf, len)
-     return adler32_z(adler, buf, len);
- }
- 
-+#ifndef Z_FREETYPE
-+
- /* ========================================================================= */
- local uLong adler32_combine_(adler1, adler2, len2)
-     uLong adler1;
-@@ -184,3 +188,5 @@ uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
- {
-     return adler32_combine_(adler1, adler2, len2);
- }
-+
-+#endif  /* !Z_FREETYPE */
-diff --git a/src/gzip/crc32.c b/src/gzip/crc32.c
-index 9580440c0..d67663a4e 100644
---- a/src/gzip/crc32.c
-+++ b/src/gzip/crc32.c
-@@ -195,6 +195,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
- }
- 
- /* ========================================================================= */
-+#undef DO1
-+#undef DO8
- #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
- #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
- 
-diff --git a/src/gzip/gzguts.h b/src/gzip/gzguts.h
-index 990a4d251..a27f38998 100644
---- a/src/gzip/gzguts.h
-+++ b/src/gzip/gzguts.h
-@@ -163,7 +163,7 @@
- 
- /* values for gz_state how */
- #define LOOK 0      /* look for a gzip header */
--#define COPY 1      /* copy input directly */
-+#define COPY__ 1      /* copy input directly */
- #define GZIP 2      /* decompress a gzip stream */
- 
- /* internal gzip file state data structure */
-diff --git a/src/gzip/inflate.c b/src/gzip/inflate.c
-index ac333e8c2..fa61003ce 100644
---- a/src/gzip/inflate.c
-+++ b/src/gzip/inflate.c
-@@ -99,8 +99,10 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
- #ifdef BUILDFIXED
-    void makefixed OF((void));
- #endif
-+#ifndef Z_FREETYPE
- local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
-                               unsigned len));
-+#endif
- 
- local int inflateStateCheck(strm)
- z_streamp strm;
-@@ -244,6 +246,8 @@ int stream_size;
-     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
- }
- 
-+#ifndef Z_FREETYPE
-+
- int ZEXPORT inflatePrime(strm, bits, value)
- z_streamp strm;
- int bits;
-@@ -265,6 +269,8 @@ int value;
-     return Z_OK;
- }
- 
-+#endif  /* Z_FREETYPE */
-+
- /*
-    Return state with length and distance decoding tables and index sizes set to
-    fixed code decoding.  Normally this returns fixed tables from inffixed.h.
-@@ -1288,6 +1294,8 @@ z_streamp strm;
-     return Z_OK;
- }
- 
-+#ifndef Z_FREETYPE
-+
- int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
- z_streamp strm;
- Bytef *dictionary;
-@@ -1440,6 +1448,8 @@ z_streamp strm;
-     return Z_OK;
- }
- 
-+#endif  /* !Z_FREETYPE */
-+
- /*
-    Returns true if inflate is currently at the end of a block generated by
-    Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
-@@ -1458,6 +1468,8 @@ z_streamp strm;
-     return state->mode == STORED && state->bits == 0;
- }
- 
-+#if !Z_FREETYPE
-+
- int ZEXPORT inflateCopy(dest, source)
- z_streamp dest;
- z_streamp source;
-@@ -1505,6 +1517,8 @@ z_streamp source;
-     return Z_OK;
- }
- 
-+#endif  /* !Z_FREETYPE */
-+
- int ZEXPORT inflateUndermine(strm, subvert)
- z_streamp strm;
- int subvert;
-@@ -1538,6 +1552,8 @@ int check;
-     return Z_OK;
- }
- 
-+#ifndef Z_FREETYPE
-+
- long ZEXPORT inflateMark(strm)
- z_streamp strm;
- {
-@@ -1559,3 +1575,5 @@ z_streamp strm;
-     state = (struct inflate_state FAR *)strm->state;
-     return (unsigned long)(state->next - state->codes);
- }
-+
-+#endif  /* !Z_FREETYPE */
-diff --git a/src/gzip/inflate.h b/src/gzip/inflate.h
-index a46cce6b6..92ea758e2 100644
---- a/src/gzip/inflate.h
-+++ b/src/gzip/inflate.h
-@@ -3,6 +3,9 @@
-  * For conditions of distribution and use, see copyright notice in zlib.h
-  */
- 
-+#ifndef INFLATE_H
-+#define INFLATE_H
-+
- /* WARNING: this file should *not* be used by applications. It is
-    part of the implementation of the compression library and is
-    subject to change. Applications should only use zlib.h.
-@@ -123,3 +126,5 @@ struct inflate_state {
-     int back;                   /* bits back of last unprocessed length/lit */
-     unsigned was;               /* initial length of match */
- };
-+
-+#endif  /* INFLATE_H */
-diff --git a/src/gzip/inftrees.h b/src/gzip/inftrees.h
-index baa53a0b1..c94eb78b5 100644
---- a/src/gzip/inftrees.h
-+++ b/src/gzip/inftrees.h
-@@ -3,6 +3,9 @@
-  * For conditions of distribution and use, see copyright notice in zlib.h
-  */
- 
-+#ifndef INFTREES_H
-+#define INFTREES_H
-+
- /* WARNING: this file should *not* be used by applications. It is
-    part of the implementation of the compression library and is
-    subject to change. Applications should only use zlib.h.
-@@ -60,3 +63,5 @@ typedef enum {
- int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
-                              unsigned codes, code FAR * FAR *table,
-                              unsigned FAR *bits, unsigned short FAR *work));
-+
-+#endif  /* INFTREES_H_ */
-diff --git a/src/gzip/zlib.h b/src/gzip/zlib.h
-index f09cdaf1e..ff5ae736d 100644
---- a/src/gzip/zlib.h
-+++ b/src/gzip/zlib.h
-@@ -31,7 +31,7 @@
- #ifndef ZLIB_H
- #define ZLIB_H
- 
--#include "zconf.h"
-+#include "ftzconf.h"
- 
- #ifdef __cplusplus
- extern "C" {
-@@ -211,6 +211,8 @@ typedef gz_header FAR *gz_headerp;
- 
- #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
- 
-+#ifndef Z_FREETYPE
-+
- #define zlib_version zlibVersion()
- /* for compatibility with versions < 1.0.2 */
- 
-@@ -246,7 +248,6 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-    this will be done by deflate().
- */
- 
--
- ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
- /*
-     deflate compresses as much data as possible, and stops when the input
-@@ -373,6 +374,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-    deallocated).
- */
- 
-+#endif  /* !Z_FREETYPE */
- 
- /*
- ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-@@ -534,6 +536,8 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-     The following functions are needed only in some special applications.
- */
- 
-+#ifndef Z_FREETYPE
-+
- /*
- ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
-                                      int  level,
-@@ -954,6 +958,8 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
-    destination.
- */
- 
-+#endif  /* !Z_FREETYPE */
-+
- ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
- /*
-      This function is equivalent to inflateEnd followed by inflateInit,
-@@ -978,6 +984,8 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
-    the windowBits parameter is invalid.
- */
- 
-+#ifndef Z_FREETYPE
-+
- ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
-                                      int bits,
-                                      int value));
-@@ -1067,6 +1075,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
-    stream state was inconsistent.
- */
- 
-+#endif  /* !Z_FREETYPE */
-+
- /*
- ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
-                                         unsigned char FAR *window));
-@@ -1093,6 +1103,8 @@ typedef unsigned (*in_func) OF((void FAR *,
-                                 z_const unsigned char FAR * FAR *));
- typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
- 
-+#ifndef Z_FREETYPE
-+
- ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
-                                     in_func in, void FAR *in_desc,
-                                     out_func out, void FAR *out_desc));
-@@ -1212,6 +1224,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-      27-31: 0 (reserved)
-  */
- 
-+#endif  /* !Z_FREETYPE */
-+
- #ifndef Z_SOLO
- 
-                         /* utility functions */
-@@ -1739,6 +1753,8 @@ ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
-      if (crc != original_crc) error();
- */
- 
-+#ifndef Z_FREETYPE
-+
- ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
-                                   z_size_t len));
- /*
-@@ -1755,7 +1771,6 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-    len2.
- */
- 
--
-                         /* various hacks, don't look :) */
- 
- /* deflateInit and inflateInit are macros to allow checking the zlib version
-@@ -1763,6 +1778,7 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-  */
- ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
-                                      const char *version, int stream_size));
-+
- ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
-                                      const char *version, int stream_size));
- ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
-@@ -1805,6 +1821,19 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
-                            ZLIB_VERSION, (int)sizeof(z_stream))
- #endif
- 
-+#else  /* Z_FREETYPE */
-+
-+
-+ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
-+                                      const char *version, int stream_size));
-+
-+#  define inflateInit2(strm, windowBits) \
-+          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
-+                        (int)sizeof(z_stream))
-+
-+#endif  /* Z_FREETYPE */
-+
-+
- #ifndef Z_SOLO
- 
- /* gzgetc() macro and its supporting function and exposed data structure.  Note
-@@ -1879,12 +1908,15 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
- 
- #else /* Z_SOLO */
- 
-+#ifndef Z_FREETYPE
-    ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
-    ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
-+#endif
- 
- #endif /* !Z_SOLO */
- 
- /* undocumented functions */
-+#ifndef Z_FREETYPE
- ZEXTERN const char   * ZEXPORT zError           OF((int));
- ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
- ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));
-@@ -1904,6 +1936,7 @@ ZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,
-                                                   va_list va));
- #  endif
- #endif
-+#endif  /* !Z_FREETYPE */
- 
- #ifdef __cplusplus
- }
-diff --git a/src/gzip/zutil.h b/src/gzip/zutil.h
-index b079ea6a8..a38573878 100644
---- a/src/gzip/zutil.h
-+++ b/src/gzip/zutil.h
-@@ -185,6 +185,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-   #pragma warn -8066
- #endif
- 
-+#ifndef Z_FREETYPE
-+
- /* provide prototypes for these when building zlib without LFS */
- #if !defined(_WIN32) && \
-     (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
-@@ -192,6 +194,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
- #endif
- 
-+#endif  /* !Z_FREETYPE */
-+
-         /* common defaults */
- 
- #ifndef OS_CODE
-@@ -223,9 +227,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
- #    define zmemcmp _fmemcmp
- #    define zmemzero(dest, len) _fmemset(dest, 0, len)
- #  else
--#    define zmemcpy memcpy
--#    define zmemcmp memcmp
--#    define zmemzero(dest, len) memset(dest, 0, len)
-+#    define zmemcpy ft_memcpy
-+#    define zmemcmp ft_memcmp
-+#    define zmemzero(dest, len) ft_memset(dest, 0, len)
- #  endif
- #else
-    void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
--- 
-2.30.2
-
diff --git a/src/gzip/patches/freetype-zlib.diff b/src/gzip/patches/freetype-zlib.diff
new file mode 100644
index 0000000..43fb5d6
--- /dev/null
+++ b/src/gzip/patches/freetype-zlib.diff
@@ -0,0 +1,386 @@
+[zlib] Fix zlib sources for compilation with FreeType
+
+We must ensure that they do not issue compiler errors or warnings when they
+are compiled as part of `src/gzip/ftgzip.c`.
+
+* src/gzip/adler32.c: Do not define unused functions when `Z_FREETYPE`
+is set.
+
+* src/gzip/crc32.c (DO1, DO8): Undefine.  Already defined in `adler32.c`.
+
+* src/gzip/gzguts.h (COPY): Rename to...
+(COPY__): ... this since `COPY` and `COPY_` conflict with enum values,
+which have the same name in `zlib.h`.
+
+* src/gzip/inflate.c, src/gzip/adler32.c: Omit unused function
+declarations when `Z_FREETYPE` is defined.
+
+* src/gzip/zlib.h: Include `ftzconf.h` instead of `zconf.h` to avoid
+conflicts with system-installed headers.
+Omit unused function declarations when `Z_FREETYPE` is defined.
+
+* src/gzip/zutil.h: Use `ft_memxxx` functions instead of `memxxx`.
+Omit unused function declarations when `Z_FREETYPE` is defined.
+
+* src/gzip/inflate.h, src/gzip/inftrees.h: Add header guard macros to
+prevent compiler errors.
+
+diff --git b/src/gzip/adler32.c a/src/gzip/adler32.c
+index be5e8a247..aa032e1dd 100644
+--- b/src/gzip/adler32.c
++++ a/src/gzip/adler32.c
+@@ -7,7 +7,9 @@
+ 
+ #include "zutil.h"
+ 
++#ifndef Z_FREETYPE
+ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
++#endif
+ 
+ #define BASE 65521U     /* largest prime smaller than 65536 */
+ #define NMAX 5552
+@@ -139,6 +141,8 @@ uLong ZEXPORT adler32(
+     return adler32_z(adler, buf, len);
+ }
+ 
++#ifndef Z_FREETYPE
++
+ /* ========================================================================= */
+ local uLong adler32_combine_(
+     uLong adler1,
+@@ -184,3 +188,5 @@ uLong ZEXPORT adler32_combine64(
+ {
+     return adler32_combine_(adler1, adler2, len2);
+ }
++
++#endif  /* !Z_FREETYPE */
+diff --git b/src/gzip/crc32.c a/src/gzip/crc32.c
+index 3e3eb1794..ffced1ea7 100644
+--- b/src/gzip/crc32.c
++++ a/src/gzip/crc32.c
+@@ -195,6 +195,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
+ }
+ 
+ /* ========================================================================= */
++#undef DO1
++#undef DO8
+ #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
+ #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
+ 
+diff --git b/src/gzip/gzguts.h a/src/gzip/gzguts.h
+index 990a4d251..c81f8f392 100644
+--- b/src/gzip/gzguts.h
++++ a/src/gzip/gzguts.h
+@@ -163,7 +163,7 @@
+ 
+ /* values for gz_state how */
+ #define LOOK 0      /* look for a gzip header */
+-#define COPY 1      /* copy input directly */
++#define COPY__ 1    /* copy input directly */
+ #define GZIP 2      /* decompress a gzip stream */
+ 
+ /* internal gzip file state data structure */
+diff --git b/src/gzip/inflate.c a/src/gzip/inflate.c
+index 3f7ea647b..7387e6f57 100644
+--- b/src/gzip/inflate.c
++++ a/src/gzip/inflate.c
+@@ -99,8 +99,10 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
+ #ifdef BUILDFIXED
+    void makefixed OF((void));
+ #endif
++#ifndef Z_FREETYPE
+ local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
+                               unsigned len));
++#endif
+ 
+ local int inflateStateCheck(
+     z_streamp strm)
+@@ -244,6 +246,8 @@ int ZEXPORT inflateInit_(
+     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
+ }
+ 
++#ifndef Z_FREETYPE
++
+ int ZEXPORT inflatePrime(
+     z_streamp strm,
+     int bits,
+@@ -265,6 +269,8 @@ int ZEXPORT inflatePrime(
+     return Z_OK;
+ }
+ 
++#endif  /* Z_FREETYPE */
++
+ /*
+    Return state with length and distance decoding tables and index sizes set to
+    fixed code decoding.  Normally this returns fixed tables from inffixed.h.
+@@ -1288,6 +1294,8 @@ int ZEXPORT inflateEnd(
+     return Z_OK;
+ }
+ 
++#ifndef Z_FREETYPE
++
+ int ZEXPORT inflateGetDictionary(
+     z_streamp strm,
+     Bytef *dictionary,
+@@ -1440,6 +1448,8 @@ int ZEXPORT inflateSync(
+     return Z_OK;
+ }
+ 
++#endif  /* !Z_FREETYPE */
++
+ /*
+    Returns true if inflate is currently at the end of a block generated by
+    Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
+@@ -1458,6 +1468,8 @@ int ZEXPORT inflateSyncPoint(
+     return state->mode == STORED && state->bits == 0;
+ }
+ 
++#if !Z_FREETYPE
++
+ int ZEXPORT inflateCopy(
+     z_streamp dest,
+     z_streamp source)
+@@ -1505,6 +1517,8 @@ int ZEXPORT inflateCopy(
+     return Z_OK;
+ }
+ 
++#endif  /* !Z_FREETYPE */
++
+ int ZEXPORT inflateUndermine(
+     z_streamp strm,
+     int subvert)
+@@ -1538,6 +1552,8 @@ int ZEXPORT inflateValidate(
+     return Z_OK;
+ }
+ 
++#ifndef Z_FREETYPE
++
+ long ZEXPORT inflateMark(
+     z_streamp strm)
+ {
+@@ -1559,3 +1575,5 @@ unsigned long ZEXPORT inflateCodesUsed(
+     state = (struct inflate_state FAR *)strm->state;
+     return (unsigned long)(state->next - state->codes);
+ }
++
++#endif  /* !Z_FREETYPE */
+diff --git b/src/gzip/inflate.h a/src/gzip/inflate.h
+index a46cce6b6..92ea758e2 100644
+--- b/src/gzip/inflate.h
++++ a/src/gzip/inflate.h
+@@ -3,6 +3,9 @@
+  * For conditions of distribution and use, see copyright notice in zlib.h
+  */
+ 
++#ifndef INFLATE_H
++#define INFLATE_H
++
+ /* WARNING: this file should *not* be used by applications. It is
+    part of the implementation of the compression library and is
+    subject to change. Applications should only use zlib.h.
+@@ -123,3 +126,5 @@ struct inflate_state {
+     int back;                   /* bits back of last unprocessed length/lit */
+     unsigned was;               /* initial length of match */
+ };
++
++#endif  /* INFLATE_H */
+diff --git b/src/gzip/inftrees.h a/src/gzip/inftrees.h
+index baa53a0b1..c94eb78b5 100644
+--- b/src/gzip/inftrees.h
++++ a/src/gzip/inftrees.h
+@@ -3,6 +3,9 @@
+  * For conditions of distribution and use, see copyright notice in zlib.h
+  */
+ 
++#ifndef INFTREES_H
++#define INFTREES_H
++
+ /* WARNING: this file should *not* be used by applications. It is
+    part of the implementation of the compression library and is
+    subject to change. Applications should only use zlib.h.
+@@ -60,3 +63,5 @@ typedef enum {
+ int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
+                              unsigned codes, code FAR * FAR *table,
+                              unsigned FAR *bits, unsigned short FAR *work));
++
++#endif  /* INFTREES_H_ */
+diff --git b/src/gzip/zlib.h a/src/gzip/zlib.h
+index f09cdaf1e..1807c0645 100644
+--- b/src/gzip/zlib.h
++++ a/src/gzip/zlib.h
+@@ -31,7 +31,7 @@
+ #ifndef ZLIB_H
+ #define ZLIB_H
+ 
+-#include "zconf.h"
++#include "ftzconf.h"
+ 
+ #ifdef __cplusplus
+ extern "C" {
+@@ -211,6 +211,8 @@ typedef gz_header FAR *gz_headerp;
+ 
+ #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+ 
++#ifndef Z_FREETYPE
++
+ #define zlib_version zlibVersion()
+ /* for compatibility with versions < 1.0.2 */
+ 
+@@ -246,7 +248,6 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+    this will be done by deflate().
+ */
+ 
+-
+ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+ /*
+     deflate compresses as much data as possible, and stops when the input
+@@ -373,6 +374,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+    deallocated).
+ */
+ 
++#endif  /* !Z_FREETYPE */
+ 
+ /*
+ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+@@ -534,6 +536,8 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+     The following functions are needed only in some special applications.
+ */
+ 
++#ifndef Z_FREETYPE
++
+ /*
+ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
+                                      int  level,
+@@ -954,6 +958,8 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
+    destination.
+ */
+ 
++#endif  /* !Z_FREETYPE */
++
+ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
+ /*
+      This function is equivalent to inflateEnd followed by inflateInit,
+@@ -978,6 +984,8 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
+    the windowBits parameter is invalid.
+ */
+ 
++#ifndef Z_FREETYPE
++
+ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
+                                      int bits,
+                                      int value));
+@@ -1067,6 +1075,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
+    stream state was inconsistent.
+ */
+ 
++#endif  /* !Z_FREETYPE */
++
+ /*
+ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
+                                         unsigned char FAR *window));
+@@ -1093,6 +1103,8 @@ typedef unsigned (*in_func) OF((void FAR *,
+                                 z_const unsigned char FAR * FAR *));
+ typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
+ 
++#ifndef Z_FREETYPE
++
+ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
+                                     in_func in, void FAR *in_desc,
+                                     out_func out, void FAR *out_desc));
+@@ -1212,6 +1224,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
+      27-31: 0 (reserved)
+  */
+ 
++#endif  /* !Z_FREETYPE */
++
+ #ifndef Z_SOLO
+ 
+                         /* utility functions */
+@@ -1739,6 +1753,8 @@ ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
+      if (crc != original_crc) error();
+ */
+ 
++#ifndef Z_FREETYPE
++
+ ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
+                                   z_size_t len));
+ /*
+@@ -1805,6 +1821,19 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
+                            ZLIB_VERSION, (int)sizeof(z_stream))
+ #endif
+ 
++#else  /* Z_FREETYPE */
++
++
++ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
++                                      const char *version, int stream_size));
++
++#  define inflateInit2(strm, windowBits) \
++          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
++                        (int)sizeof(z_stream))
++
++#endif  /* Z_FREETYPE */
++
++
+ #ifndef Z_SOLO
+ 
+ /* gzgetc() macro and its supporting function and exposed data structure.  Note
+@@ -1879,12 +1908,15 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
+ 
+ #else /* Z_SOLO */
+ 
++#ifndef Z_FREETYPE
+    ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+    ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
++#endif
+ 
+ #endif /* !Z_SOLO */
+ 
+ /* undocumented functions */
++#ifndef Z_FREETYPE
+ ZEXTERN const char   * ZEXPORT zError           OF((int));
+ ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
+ ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));
+@@ -1904,6 +1936,7 @@ ZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,
+                                                   va_list va));
+ #  endif
+ #endif
++#endif  /* !Z_FREETYPE */
+ 
+ #ifdef __cplusplus
+ }
+diff --git b/src/gzip/zutil.h a/src/gzip/zutil.h
+index b079ea6a8..a38573878 100644
+--- b/src/gzip/zutil.h
++++ a/src/gzip/zutil.h
+@@ -185,6 +185,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+   #pragma warn -8066
+ #endif
+ 
++#ifndef Z_FREETYPE
++
+ /* provide prototypes for these when building zlib without LFS */
+ #if !defined(_WIN32) && \
+     (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
+@@ -192,6 +194,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+ #endif
+ 
++#endif  /* !Z_FREETYPE */
++
+         /* common defaults */
+ 
+ #ifndef OS_CODE
+@@ -223,9 +227,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+ #    define zmemcmp _fmemcmp
+ #    define zmemzero(dest, len) _fmemset(dest, 0, len)
+ #  else
+-#    define zmemcpy memcpy
+-#    define zmemcmp memcmp
+-#    define zmemzero(dest, len) memset(dest, 0, len)
++#    define zmemcpy ft_memcpy
++#    define zmemcmp ft_memcmp
++#    define zmemzero(dest, len) ft_memset(dest, 0, len)
+ #  endif
+ #else
+    void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
diff --git a/src/gzip/zlib.h b/src/gzip/zlib.h
index ff5ae73..1807c06 100644
--- a/src/gzip/zlib.h
+++ b/src/gzip/zlib.h
@@ -1771,6 +1771,7 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
    len2.
 */
 
+
                         /* various hacks, don't look :) */
 
 /* deflateInit and inflateInit are macros to allow checking the zlib version
@@ -1778,7 +1779,6 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
  */
 ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
                                      const char *version, int stream_size));
-
 ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
                                      const char *version, int stream_size));
 ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,