Skip to content

Commit 4c5126d

Browse files
akien-mgamandryskowski
authored andcommitted
zlib/minizip: Update to version 1.3
Upstreams the fix from godotengine#73310, so we can remove that patch. Remove `infback.c` which we stopped compiling after godotengine#79273. The `OF` macro was also removed so I can drop the patch where I yell at Gentoo developers.
1 parent ac89bf5 commit 4c5126d

34 files changed

+1479
-3192
lines changed

COPYRIGHT.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ License: Expat
493493

494494
Files: ./thirdparty/zlib/
495495
Comment: zlib
496-
Copyright: 1995-2022, Jean-loup Gailly and Mark Adler
496+
Copyright: 1995-2023, Jean-loup Gailly and Mark Adler
497497
License: Zlib
498498

499499
Files: ./thirdparty/zstd/

thirdparty/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ that file when upgrading.
458458
## minizip
459459

460460
- Upstream: https://www.zlib.net
461-
- Version: 1.2.13 (zlib contrib, 2022)
461+
- Version: 1.3 (zlib contrib, 2023)
462462
- License: zlib
463463

464464
Files extracted from the upstream source:
@@ -831,12 +831,12 @@ Files extracted from upstream source:
831831
## zlib
832832

833833
- Upstream: https://www.zlib.net
834-
- Version: 1.2.13 (2022)
834+
- Version: 1.3 (2023)
835835
- License: zlib
836836

837837
Files extracted from upstream source:
838838

839-
- All `*.c` and `*.h` files
839+
- All `*.c` and `*.h` files, minus `infback.c`
840840
- `LICENSE`
841841

842842

thirdparty/minizip/crypt.h

+4-8
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
/***********************************************************************
3333
* Return the next byte in the pseudo-random sequence
3434
*/
35-
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
36-
{
35+
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
3736
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
3837
* unpredictable manner on 16-bit systems; not a problem
3938
* with any known compiler so far, though */
@@ -46,8 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
4645
/***********************************************************************
4746
* Update the encryption keys with the next byte of plain text
4847
*/
49-
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
50-
{
48+
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
5149
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
5250
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
5351
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
@@ -63,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
6361
* Initialize the encryption keys and the random header according to
6462
* the given password.
6563
*/
66-
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
67-
{
64+
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
6865
*(pkeys+0) = 305419896L;
6966
*(pkeys+1) = 591751049L;
7067
*(pkeys+2) = 878082192L;
@@ -93,8 +90,7 @@ static unsigned crypthead(const char* passwd, /* password string */
9390
int bufSize,
9491
unsigned long* pkeys,
9592
const z_crc_t* pcrc_32_tab,
96-
unsigned long crcForCrypting)
97-
{
93+
unsigned long crcForCrypting) {
9894
unsigned n; /* index in random header */
9995
int t; /* temporary */
10096
int c; /* random byte */

thirdparty/minizip/ioapi.c

+18-44
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define _CRT_SECURE_NO_WARNINGS
1515
#endif
1616

17-
#if defined(__APPLE__) || defined(IOAPI_NO_64)
17+
#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
1818
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
1919
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
2020
#define FTELLO_FUNC(stream) ftello(stream)
@@ -28,8 +28,7 @@
2828

2929
#include "ioapi.h"
3030

31-
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
32-
{
31+
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) {
3332
if (pfilefunc->zfile_func64.zopen64_file != NULL)
3433
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
3534
else
@@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename
3837
}
3938
}
4039

41-
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
42-
{
40+
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) {
4341
if (pfilefunc->zfile_func64.zseek64_file != NULL)
4442
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
4543
else
@@ -52,8 +50,7 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
5250
}
5351
}
5452

55-
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
56-
{
53+
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) {
5754
if (pfilefunc->zfile_func64.zseek64_file != NULL)
5855
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
5956
else
@@ -66,11 +63,9 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream
6663
}
6764
}
6865

69-
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
70-
{
66+
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) {
7167
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
7268
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
73-
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
7469
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
7570
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
7671
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
@@ -91,16 +86,7 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
9186
// GODOT end
9287
9388
94-
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
95-
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
96-
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
97-
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
98-
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
99-
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
100-
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
101-
102-
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
103-
{
89+
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) {
10490
FILE* file = NULL;
10591
const char* mode_fopen = NULL;
10692
(void)opaque;
@@ -118,8 +104,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
118104
return file;
119105
}
120106
121-
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
122-
{
107+
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) {
123108
FILE* file = NULL;
124109
const char* mode_fopen = NULL;
125110
(void)opaque;
@@ -138,41 +123,36 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
138123
}
139124
140125
141-
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
142-
{
126+
static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) {
143127
uLong ret;
144128
(void)opaque;
145129
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
146130
return ret;
147131
}
148132
149-
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
150-
{
133+
static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
151134
uLong ret;
152135
(void)opaque;
153136
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
154137
return ret;
155138
}
156139
157-
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
158-
{
140+
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) {
159141
long ret;
160142
(void)opaque;
161143
ret = ftell((FILE *)stream);
162144
return ret;
163145
}
164146
165147
166-
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
167-
{
148+
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) {
168149
ZPOS64_T ret;
169150
(void)opaque;
170151
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
171152
return ret;
172153
}
173154
174-
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
175-
{
155+
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
176156
int fseek_origin=0;
177157
long ret;
178158
(void)opaque;
@@ -195,8 +175,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
195175
return ret;
196176
}
197177
198-
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
199-
{
178+
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
200179
int fseek_origin=0;
201180
long ret;
202181
(void)opaque;
@@ -215,32 +194,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
215194
}
216195
ret = 0;
217196
218-
if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0)
197+
if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0)
219198
ret = -1;
220199
221200
return ret;
222201
}
223202
224203
225-
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
226-
{
204+
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) {
227205
int ret;
228206
(void)opaque;
229207
ret = fclose((FILE *)stream);
230208
return ret;
231209
}
232210
233-
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
234-
{
211+
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) {
235212
int ret;
236213
(void)opaque;
237214
ret = ferror((FILE *)stream);
238215
return ret;
239216
}
240217
241-
void fill_fopen_filefunc (pzlib_filefunc_def)
242-
zlib_filefunc_def* pzlib_filefunc_def;
243-
{
218+
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
244219
pzlib_filefunc_def->zopen_file = fopen_file_func;
245220
pzlib_filefunc_def->zread_file = fread_file_func;
246221
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
@@ -251,8 +226,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
251226
pzlib_filefunc_def->opaque = NULL;
252227
}
253228
254-
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
255-
{
229+
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) {
256230
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
257231
pzlib_filefunc_def->zread_file = fread_file_func;
258232
pzlib_filefunc_def->zwrite_file = fwrite_file_func;

thirdparty/minizip/ioapi.h

+18-34
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,12 @@
4545
#include <stdlib.h>
4646
#include "zlib.h"
4747

48-
/* GODOT start */
49-
/* Mighty Gentoo saves the day by breaking the API of their zlib.h,
50-
* removing this definition of OF(args) for no practical reason
51-
* worth breaking compatibility with all projects that embed minizip
52-
* while trying not to diverge too much from upstream zlib.
53-
* Cf. https://github.com/godotengine/godot/issues/10539
54-
*
55-
* "By and large, this is good open source behaviour, and fits with
56-
* the gentoo _don't fuck with upstream's releases_ philosophy"
57-
* -- Gentoo philosopher
58-
*/
59-
#ifndef OF /* function prototypes */
60-
#define OF(args) args
61-
#endif
62-
/* GODOT end */
63-
6448
#if defined(USE_FILE32API)
6549
#define fopen64 fopen
6650
#define ftello64 ftell
6751
#define fseeko64 fseek
6852
#else
69-
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
53+
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
7054
#define fopen64 fopen
7155
#define ftello64 ftello
7256
#define fseeko64 fseeko
@@ -98,7 +82,7 @@
9882
#include "mz64conf.h"
9983
#endif
10084

101-
/* a type choosen by DEFINE */
85+
/* a type chosen by DEFINE */
10286
#ifdef HAVE_64BIT_INT_CUSTOM
10387
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
10488
#else
@@ -150,14 +134,14 @@ extern "C" {
150134

151135

152136

153-
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
154-
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
155-
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
156-
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
157-
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
137+
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
138+
typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
139+
typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
140+
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
141+
typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
158142

159-
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
160-
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
143+
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
144+
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
161145

162146

163147
/* here is the "old" 32 bits structure structure */
@@ -177,9 +161,9 @@ typedef struct zlib_filefunc_def_s
177161
/* GODOT end */
178162
} zlib_filefunc_def;
179163

180-
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
181-
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
182-
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
164+
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
165+
typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
166+
typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode);
183167

184168
typedef struct zlib_filefunc64_def_s
185169
{
@@ -197,8 +181,8 @@ typedef struct zlib_filefunc64_def_s
197181
/* GODOT end */
198182
} zlib_filefunc64_def;
199183

200-
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
201-
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
184+
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def);
185+
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
202186

203187
/* now internal definition, only for zip.c and unzip.h */
204188
typedef struct zlib_filefunc64_32_def_s
@@ -217,11 +201,11 @@ typedef struct zlib_filefunc64_32_def_s
217201
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
218202
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
219203

220-
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
221-
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
222-
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
204+
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
205+
long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
206+
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
223207

224-
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
208+
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
225209

226210
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
227211
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))

0 commit comments

Comments
 (0)