summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/gzip/patches/freetype-zlib.diff
blob: 6ac76df62aa5d2cedf543a07d61d934fdf8803c3 (plain)
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
[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/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, src/gzip/crc32.c,
src/gzip/zutil.c: Omit unused function declarations and definitions when
`Z_FREETYPE` is defined.

* src/gzip/inffast.h (inflate_fast): Declare as static.

* src/gzip/inftrees.c (inflate_copyright): Declare as static.

* 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.
(inflateInit2)[Z_FREETYPE]: Provide proper declaration.

* 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/inftrees.h: Add header guard macros to prevent compiler errors.
(inflate_table): Declare as static.

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 3a52aa89d..6cd1b09d5 100644
--- b/src/gzip/crc32.c
+++ a/src/gzip/crc32.c
@@ -103,9 +103,11 @@
 #  define ARMCRC32
 #endif
 
+#ifndef Z_FREETYPE
 /* Local functions. */
 local z_crc_t multmodp OF((z_crc_t a, z_crc_t b));
 local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
+#endif  /* Z_FREETYPE */
 
 #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
     local z_word_t byte_swap OF((z_word_t word));
@@ -544,6 +546,8 @@ local void braid(ltl, big, n, w)
  * generation above.
  */
 
+#ifndef Z_FREETYPE
+
 /*
   Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
   reflected. For speed, this requires that a not be zero.
@@ -600,6 +604,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
     return (const z_crc_t FAR *)crc_table;
 }
 
+#endif  /* Z_FREETYPE */
+
 /* =========================================================================
  * Use ARM machine instructions if available. This will compute the CRC about
  * ten times faster than the braided calculation. This code does not check for
@@ -1077,6 +1083,8 @@ unsigned long ZEXPORT crc32(
     return crc32_z(crc, buf, len);
 }
 
+#ifndef Z_FREETYPE
+
 /* ========================================================================= */
 uLong ZEXPORT crc32_combine64(
     uLong crc1,
@@ -1123,3 +1131,5 @@ uLong ZEXPORT crc32_combine_op(
 {
     return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
 }
+
+#endif  /* Z_FREETYPE */
diff --git b/src/gzip/gzguts.h a/src/gzip/gzguts.h
index 57faf3716..4f09a52a7 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/inffast.h a/src/gzip/inffast.h
index e5c1aa4ca..684ae878c 100644
--- b/src/gzip/inffast.h
+++ a/src/gzip/inffast.h
@@ -8,4 +8,4 @@
    subject to change. Applications should only use zlib.h.
  */
 
-void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
+static void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
diff --git b/src/gzip/inflate.c a/src/gzip/inflate.c
index c9e566b03..5117e2e26 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)
@@ -239,6 +241,8 @@ int ZEXPORT inflateInit2_(
     return ret;
 }
 
+#ifndef Z_FREETYPE
+
 int ZEXPORT inflateInit_(
     z_streamp strm,
     const char *version,
@@ -268,6 +272,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.
@@ -1315,6 +1321,8 @@ int ZEXPORT inflateEnd(
     return Z_OK;
 }
 
+#ifndef Z_FREETYPE
+
 int ZEXPORT inflateGetDictionary(
     z_streamp strm,
     Bytef *dictionary,
@@ -1593,3 +1601,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 f127b6b1f..c6f5a52e1 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.
@@ -124,3 +127,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.c a/src/gzip/inftrees.c
index d8405a24c..dd4965e9a 100644
--- b/src/gzip/inftrees.c
+++ a/src/gzip/inftrees.c
@@ -8,7 +8,7 @@
 
 #define MAXBITS 15
 
-const char inflate_copyright[] =
+static const char inflate_copyright[] =
    " inflate 1.2.13 Copyright 1995-2022 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
diff --git b/src/gzip/inftrees.h a/src/gzip/inftrees.h
index f53665311..a2207efb1 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.
@@ -57,6 +60,8 @@ typedef enum {
     DISTS
 } codetype;
 
-int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
+static 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 953cb5012..3f2f76e3c 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 */
 
@@ -373,6 +375,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
    deallocated).
 */
 
+#endif  /* !Z_FREETYPE */
 
 /*
 ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
@@ -534,6 +537,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,
@@ -956,6 +961,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,
@@ -980,6 +987,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));
@@ -1069,6 +1078,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));
@@ -1095,6 +1106,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));
@@ -1214,6 +1227,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
      27-31: 0 (reserved)
  */
 
+#endif  /* !Z_FREETYPE */
+
 #ifndef Z_SOLO
 
                         /* utility functions */
@@ -1765,6 +1780,8 @@ ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2));
    crc32_combine_op().
 */
 
+#ifndef Z_FREETYPE
+
 ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
 /*
      Give the same result as crc32_combine(), using op in place of len2. op is
@@ -1822,6 +1839,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
@@ -1901,20 +1931,25 @@ 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));
    ZEXTERN uLong ZEXPORT crc32_combine_gen OF((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));
 ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
 ZEXTERN int            ZEXPORT inflateValidate OF((z_streamp, int));
 ZEXTERN unsigned long  ZEXPORT inflateCodesUsed OF((z_streamp));
+#endif  /* !Z_FREETYPE */
 ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
+#ifndef Z_FREETYPE
 ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
 #if defined(_WIN32) && !defined(Z_SOLO)
 ZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,
@@ -1927,6 +1962,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.c a/src/gzip/zutil.c
index ef174ca64..542706ca0 100644
--- b/src/gzip/zutil.c
+++ a/src/gzip/zutil.c
@@ -10,6 +10,8 @@
 #  include "gzguts.h"
 #endif
 
+#ifndef Z_FREETYPE
+
 z_const char * const z_errmsg[10] = {
     (z_const char *)"need dictionary",     /* Z_NEED_DICT       2  */
     (z_const char *)"stream end",          /* Z_STREAM_END      1  */
@@ -138,6 +140,8 @@ const char * ZEXPORT zError(
     return ERR_MSG(err);
 }
 
+#endif  /* !Z_FREETYPE */
+
 #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
     /* The older Microsoft C Run-Time Library for Windows CE doesn't have
      * errno.  We define it as a global variable to simplify porting.
@@ -159,6 +163,8 @@ void ZLIB_INTERNAL zmemcpy(
     } while (--len != 0);
 }
 
+#ifndef Z_FREETYPE
+
 int ZLIB_INTERNAL zmemcmp(
     const Bytef* s1,
     const Bytef* s2,
@@ -181,6 +187,7 @@ void ZLIB_INTERNAL zmemzero(
         *dest++ = 0;  /* ??? to be unrolled */
     } while (--len != 0);
 }
+#endif  /* !Z_FREETYPE */
 #endif
 
 #ifndef Z_SOLO
diff --git b/src/gzip/zutil.h a/src/gzip/zutil.h
index 0bc7f4ecd..055ba8b62 100644
--- b/src/gzip/zutil.h
+++ a/src/gzip/zutil.h
@@ -53,8 +53,10 @@ typedef unsigned long  ulg;
 #  endif
 #endif
 
+#ifndef Z_FREETYPE
 extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 /* (size given to avoid silly warnings with Visual C++) */
+#endif  /* !Z_FREETYPE */
 
 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
 
@@ -188,6 +190,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)
@@ -196,6 +200,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
 #endif
 
+#endif  /* !Z_FREETYPE */
+
         /* common defaults */
 
 #ifndef OS_CODE
@@ -227,9 +233,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));