[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.
This commit is contained in:
Werner Lemberg 2022-01-10 17:25:47 +01:00
parent a25e85ed95
commit da8a8b8bcf
4 changed files with 78 additions and 111 deletions

View File

@ -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 - Take the unmodified source code files from the zlib distribution that are
included by `ftgzip.c`. included by `ftgzip.c`.
- Apply the diff file(s) in the `patches` folder.
- Run zlib's `zlib2ansi` script on all `.c` files. - Run zlib's `zlib2ansi` script on all `.c` files.
- Apply the diff file(s) in the `patches` folder.

View File

@ -163,7 +163,7 @@
/* values for gz_state how */ /* values for gz_state how */
#define LOOK 0 /* look for a gzip header */ #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 */ #define GZIP 2 /* decompress a gzip stream */
/* internal gzip file state data structure */ /* internal gzip file state data structure */

View File

@ -1,48 +1,34 @@
From 2977ff0df909f939517e9857943938ff84201a26 Mon Sep 17 00:00:00 2001 [zlib] Fix zlib sources for compilation with FreeType
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 We must ensure that they do not issue compiler errors or warnings when they
warnings when they are compiled as part of src/gzip/ftgzip.c. are compiled as part of `src/gzip/ftgzip.c`.
* src/gzip/adler32.c: Do not define unused functions when Z_FREETYPE * src/gzip/adler32.c: Do not define unused functions when `Z_FREETYPE`
is set. is set.
* src/gzip/crc32.c: Undefined DO1 and DO8 macros that are already * src/gzip/crc32.c (DO1, DO8): Undefine. Already defined in `adler32.c`.
defined in adler32.c.
* src/gzip/gzguts.h: Rename COPY macro to COPY__ since COPY and * src/gzip/gzguts.h (COPY): Rename to...
COPY_ conflict with enum values with the same name in (COPY__): ... this since `COPY` and `COPY_` conflict with enum values,
zlib.h. which have the same name in `zlib.h`.
* src/gzip/inflate.c, src/gzip/adler32.c: Omit unused function * src/gzip/inflate.c, src/gzip/adler32.c: Omit unused function
declarations when Z_FREETYPE is defined. declarations when `Z_FREETYPE` is defined.
* src/gzip/zlib.h: Include "ftzconf.h" instead of "zconf.h" to * src/gzip/zlib.h: Include `ftzconf.h` instead of `zconf.h` to avoid
avoid conflicts with system-installed headers. Omit unused conflicts with system-installed headers.
function declarations when Z_FREETYPE is defined. Omit unused function declarations when `Z_FREETYPE` is defined.
* src/gzip/zutil.h: Use ft_memxxx() functions instead of memxxx(). * src/gzip/zutil.h: Use `ft_memxxx` functions instead of `memxxx`.
Omit unused function declarations when Z_FREETYPE is defined. Omit unused function declarations when `Z_FREETYPE` is defined.
* src/gzip/inflate.h, src/gzip/inftrees.h: Add header guard macros * src/gzip/inflate.h, src/gzip/inftrees.h: Add header guard macros to
to prevent compiler errors. 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 diff --git b/src/gzip/adler32.c a/src/gzip/adler32.c
index d0be4380a..a8242ba13 100644 index be5e8a247..aa032e1dd 100644
--- a/src/gzip/adler32.c --- b/src/gzip/adler32.c
+++ b/src/gzip/adler32.c +++ a/src/gzip/adler32.c
@@ -7,7 +7,9 @@ @@ -7,7 +7,9 @@
#include "zutil.h" #include "zutil.h"
@ -53,25 +39,25 @@ index d0be4380a..a8242ba13 100644
#define BASE 65521U /* largest prime smaller than 65536 */ #define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552 #define NMAX 5552
@@ -139,6 +141,8 @@ uLong ZEXPORT adler32(adler, buf, len) @@ -139,6 +141,8 @@ uLong ZEXPORT adler32(
return adler32_z(adler, buf, len); return adler32_z(adler, buf, len);
} }
+#ifndef Z_FREETYPE +#ifndef Z_FREETYPE
+ +
/* ========================================================================= */ /* ========================================================================= */
local uLong adler32_combine_(adler1, adler2, len2) local uLong adler32_combine_(
uLong adler1; uLong adler1,
@@ -184,3 +188,5 @@ uLong ZEXPORT adler32_combine64(adler1, adler2, len2) @@ -184,3 +188,5 @@ uLong ZEXPORT adler32_combine64(
{ {
return adler32_combine_(adler1, adler2, len2); return adler32_combine_(adler1, adler2, len2);
} }
+ +
+#endif /* !Z_FREETYPE */ +#endif /* !Z_FREETYPE */
diff --git a/src/gzip/crc32.c b/src/gzip/crc32.c diff --git b/src/gzip/crc32.c a/src/gzip/crc32.c
index 9580440c0..d67663a4e 100644 index 3e3eb1794..ffced1ea7 100644
--- a/src/gzip/crc32.c --- b/src/gzip/crc32.c
+++ b/src/gzip/crc32.c +++ a/src/gzip/crc32.c
@@ -195,6 +195,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table() @@ -195,6 +195,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
} }
@ -81,23 +67,23 @@ index 9580440c0..d67663a4e 100644
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
diff --git a/src/gzip/gzguts.h b/src/gzip/gzguts.h diff --git b/src/gzip/gzguts.h a/src/gzip/gzguts.h
index 990a4d251..a27f38998 100644 index 990a4d251..c81f8f392 100644
--- a/src/gzip/gzguts.h --- b/src/gzip/gzguts.h
+++ b/src/gzip/gzguts.h +++ a/src/gzip/gzguts.h
@@ -163,7 +163,7 @@ @@ -163,7 +163,7 @@
/* values for gz_state how */ /* values for gz_state how */
#define LOOK 0 /* look for a gzip header */ #define LOOK 0 /* look for a gzip header */
-#define COPY 1 /* copy input directly */ -#define COPY 1 /* copy input directly */
+#define COPY__ 1 /* copy input directly */ +#define COPY__ 1 /* copy input directly */
#define GZIP 2 /* decompress a gzip stream */ #define GZIP 2 /* decompress a gzip stream */
/* internal gzip file state data structure */ /* internal gzip file state data structure */
diff --git a/src/gzip/inflate.c b/src/gzip/inflate.c diff --git b/src/gzip/inflate.c a/src/gzip/inflate.c
index ac333e8c2..fa61003ce 100644 index 3f7ea647b..7387e6f57 100644
--- a/src/gzip/inflate.c --- b/src/gzip/inflate.c
+++ 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, @@ -99,8 +99,10 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
#ifdef BUILDFIXED #ifdef BUILDFIXED
void makefixed OF((void)); void makefixed OF((void));
@ -107,18 +93,18 @@ index ac333e8c2..fa61003ce 100644
unsigned len)); unsigned len));
+#endif +#endif
local int inflateStateCheck(strm) local int inflateStateCheck(
z_streamp strm; z_streamp strm)
@@ -244,6 +246,8 @@ int stream_size; @@ -244,6 +246,8 @@ int ZEXPORT inflateInit_(
return inflateInit2_(strm, DEF_WBITS, version, stream_size); return inflateInit2_(strm, DEF_WBITS, version, stream_size);
} }
+#ifndef Z_FREETYPE +#ifndef Z_FREETYPE
+ +
int ZEXPORT inflatePrime(strm, bits, value) int ZEXPORT inflatePrime(
z_streamp strm; z_streamp strm,
int bits; int bits,
@@ -265,6 +269,8 @@ int value; @@ -265,6 +269,8 @@ int ZEXPORT inflatePrime(
return Z_OK; return Z_OK;
} }
@ -127,16 +113,16 @@ index ac333e8c2..fa61003ce 100644
/* /*
Return state with length and distance decoding tables and index sizes set to Return state with length and distance decoding tables and index sizes set to
fixed code decoding. Normally this returns fixed tables from inffixed.h. fixed code decoding. Normally this returns fixed tables from inffixed.h.
@@ -1288,6 +1294,8 @@ z_streamp strm; @@ -1288,6 +1294,8 @@ int ZEXPORT inflateEnd(
return Z_OK; return Z_OK;
} }
+#ifndef Z_FREETYPE +#ifndef Z_FREETYPE
+ +
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) int ZEXPORT inflateGetDictionary(
z_streamp strm; z_streamp strm,
Bytef *dictionary; Bytef *dictionary,
@@ -1440,6 +1448,8 @@ z_streamp strm; @@ -1440,6 +1448,8 @@ int ZEXPORT inflateSync(
return Z_OK; return Z_OK;
} }
@ -145,43 +131,43 @@ index ac333e8c2..fa61003ce 100644
/* /*
Returns true if inflate is currently at the end of a block generated by 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 Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
@@ -1458,6 +1468,8 @@ z_streamp strm; @@ -1458,6 +1468,8 @@ int ZEXPORT inflateSyncPoint(
return state->mode == STORED && state->bits == 0; return state->mode == STORED && state->bits == 0;
} }
+#if !Z_FREETYPE +#if !Z_FREETYPE
+ +
int ZEXPORT inflateCopy(dest, source) int ZEXPORT inflateCopy(
z_streamp dest; z_streamp dest,
z_streamp source; z_streamp source)
@@ -1505,6 +1517,8 @@ z_streamp source; @@ -1505,6 +1517,8 @@ int ZEXPORT inflateCopy(
return Z_OK; return Z_OK;
} }
+#endif /* !Z_FREETYPE */ +#endif /* !Z_FREETYPE */
+ +
int ZEXPORT inflateUndermine(strm, subvert) int ZEXPORT inflateUndermine(
z_streamp strm; z_streamp strm,
int subvert; int subvert)
@@ -1538,6 +1552,8 @@ int check; @@ -1538,6 +1552,8 @@ int ZEXPORT inflateValidate(
return Z_OK; return Z_OK;
} }
+#ifndef Z_FREETYPE +#ifndef Z_FREETYPE
+ +
long ZEXPORT inflateMark(strm) long ZEXPORT inflateMark(
z_streamp strm; z_streamp strm)
{ {
@@ -1559,3 +1575,5 @@ z_streamp strm; @@ -1559,3 +1575,5 @@ unsigned long ZEXPORT inflateCodesUsed(
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR *)strm->state;
return (unsigned long)(state->next - state->codes); return (unsigned long)(state->next - state->codes);
} }
+ +
+#endif /* !Z_FREETYPE */ +#endif /* !Z_FREETYPE */
diff --git a/src/gzip/inflate.h b/src/gzip/inflate.h diff --git b/src/gzip/inflate.h a/src/gzip/inflate.h
index a46cce6b6..92ea758e2 100644 index a46cce6b6..92ea758e2 100644
--- a/src/gzip/inflate.h --- b/src/gzip/inflate.h
+++ b/src/gzip/inflate.h +++ a/src/gzip/inflate.h
@@ -3,6 +3,9 @@ @@ -3,6 +3,9 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -198,10 +184,10 @@ index a46cce6b6..92ea758e2 100644
}; };
+ +
+#endif /* INFLATE_H */ +#endif /* INFLATE_H */
diff --git a/src/gzip/inftrees.h b/src/gzip/inftrees.h diff --git b/src/gzip/inftrees.h a/src/gzip/inftrees.h
index baa53a0b1..c94eb78b5 100644 index baa53a0b1..c94eb78b5 100644
--- a/src/gzip/inftrees.h --- b/src/gzip/inftrees.h
+++ b/src/gzip/inftrees.h +++ a/src/gzip/inftrees.h
@@ -3,6 +3,9 @@ @@ -3,6 +3,9 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -218,10 +204,10 @@ index baa53a0b1..c94eb78b5 100644
unsigned FAR *bits, unsigned short FAR *work)); unsigned FAR *bits, unsigned short FAR *work));
+ +
+#endif /* INFTREES_H_ */ +#endif /* INFTREES_H_ */
diff --git a/src/gzip/zlib.h b/src/gzip/zlib.h diff --git b/src/gzip/zlib.h a/src/gzip/zlib.h
index f09cdaf1e..ff5ae736d 100644 index f09cdaf1e..1807c0645 100644
--- a/src/gzip/zlib.h --- b/src/gzip/zlib.h
+++ b/src/gzip/zlib.h +++ a/src/gzip/zlib.h
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
#ifndef ZLIB_H #ifndef ZLIB_H
#define ZLIB_H #define ZLIB_H
@ -319,22 +305,6 @@ index f09cdaf1e..ff5ae736d 100644
ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
z_size_t len)); 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, @@ -1805,6 +1821,19 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
ZLIB_VERSION, (int)sizeof(z_stream)) ZLIB_VERSION, (int)sizeof(z_stream))
#endif #endif
@ -379,10 +349,10 @@ index f09cdaf1e..ff5ae736d 100644
#ifdef __cplusplus #ifdef __cplusplus
} }
diff --git a/src/gzip/zutil.h b/src/gzip/zutil.h diff --git b/src/gzip/zutil.h a/src/gzip/zutil.h
index b079ea6a8..a38573878 100644 index b079ea6a8..a38573878 100644
--- a/src/gzip/zutil.h --- b/src/gzip/zutil.h
+++ 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 */ @@ -185,6 +185,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#pragma warn -8066 #pragma warn -8066
#endif #endif
@ -414,6 +384,3 @@ index b079ea6a8..a38573878 100644
# endif # endif
#else #else
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
--
2.30.2

View File

@ -1771,6 +1771,7 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
len2. len2.
*/ */
/* various hacks, don't look :) */ /* various hacks, don't look :) */
/* deflateInit and inflateInit are macros to allow checking the zlib version /* 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, ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
const char *version, int stream_size)); const char *version, int stream_size));
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
const char *version, int stream_size)); const char *version, int stream_size));
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,