[Library] Update zlibng (#1255)

* Update zlibng

* Set cmake path more directly in zlibng to hopefully fix an issue with the build on drone

* I'm dumb, missing / in path

* Mackal helps with a dumb gitignore issue

* Adding all the files, not sure what's ignoring them and im tired of looking

* Some tweaks to zlibng build to hopefully get it to build properly. works on msvc now
This commit is contained in:
Alex
2021-02-23 17:00:26 -08:00
committed by GitHub
parent e6dee96266
commit 2957f5084d
184 changed files with 22029 additions and 11703 deletions
+57 -32
View File
@@ -4,9 +4,10 @@
*/
#include "zbuild.h"
#include "zutil_p.h"
#include "gzguts.h"
#if defined(WIN32) && !defined(__BORLANDC__)
#if defined(_WIN32)
# define LSEEK _lseeki64
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
@@ -28,6 +29,8 @@ static void gz_reset(gz_state *state) {
state->past = 0; /* have not read past end yet */
state->how = LOOK; /* look for gzip header */
}
else /* for writing ... */
state->reset = 0; /* no deflateReset pending */
state->seek = 0; /* no seek request pending */
gz_error(state, Z_OK, NULL); /* clear error */
state->x.pos = 0; /* no uncompressed data yet */
@@ -51,7 +54,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
return NULL;
/* allocate gzFile structure to return */
state = (gz_state *)malloc(sizeof(gz_state));
state = (gz_state *)zng_alloc(sizeof(gz_state));
if (state == NULL)
return NULL;
state->size = 0; /* no buffers allocated yet */
@@ -80,7 +83,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
break;
#endif
case '+': /* can't read and write at the same time */
free(state);
zng_free(state);
return NULL;
case 'b': /* ignore -- will request binary anyway */
break;
@@ -118,14 +121,14 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
/* must provide an "r", "w", or "a" */
if (state->mode == GZ_NONE) {
free(state);
zng_free(state);
return NULL;
}
/* can't force transparent read */
if (state->mode == GZ_READ) {
if (state->direct) {
free(state);
zng_free(state);
return NULL;
}
state->direct = 1; /* for empty file */
@@ -134,7 +137,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
/* save the path name for error messages */
#ifdef WIDECHAR
if (fd == -2) {
len = wcstombs(NULL, path, 0);
len = wcstombs(NULL, (const wchar_t *)path, 0);
if (len == (size_t)-1)
len = 0;
} else
@@ -142,13 +145,13 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
len = strlen((const char *)path);
state->path = (char *)malloc(len + 1);
if (state->path == NULL) {
free(state);
zng_free(state);
return NULL;
}
#ifdef WIDECHAR
if (fd == -2)
if (len) {
wcstombs(state->path, path, len + 1);
wcstombs(state->path, (const wchar_t *)path, len + 1);
} else {
*(state->path) = 0;
}
@@ -179,15 +182,15 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
#if defined(WIN32) || defined(__MINGW__)
fd == -2 ? _wopen(path, oflag, 0666) :
#if defined(_WIN32)
fd == -2 ? _wopen((const wchar_t *)path, oflag, 0666) :
#elif __CYGWIN__
fd == -2 ? open(state->path, oflag, 0666) :
#endif
open((const char *)path, oflag, 0666));
if (state->fd == -1) {
free(state->path);
free(state);
zng_free(state);
return NULL;
}
if (state->mode == GZ_APPEND) {
@@ -209,17 +212,18 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
}
/* -- see zlib.h -- */
gzFile ZEXPORT PREFIX(gzopen)(const char *path, const char *mode) {
gzFile Z_EXPORT PREFIX(gzopen)(const char *path, const char *mode) {
return gz_open(path, -1, mode);
}
/* -- see zlib.h -- */
gzFile ZEXPORT PREFIX(gzopen64)(const char *path, const char *mode) {
#ifdef ZLIB_COMPAT
gzFile Z_EXPORT PREFIX4(gzopen)(const char *path, const char *mode) {
return gz_open(path, -1, mode);
}
#endif
/* -- see zlib.h -- */
gzFile ZEXPORT PREFIX(gzdopen)(int fd, const char *mode) {
gzFile Z_EXPORT PREFIX(gzdopen)(int fd, const char *mode) {
char *path; /* identifier for error messages */
gzFile gz;
@@ -233,13 +237,27 @@ gzFile ZEXPORT PREFIX(gzdopen)(int fd, const char *mode) {
/* -- see zlib.h -- */
#ifdef WIDECHAR
gzFile ZEXPORT PREFIX(gzopen_w)(const wchar_t *path, const char *mode) {
gzFile Z_EXPORT PREFIX(gzopen_w)(const wchar_t *path, const char *mode) {
return gz_open(path, -2, mode);
}
#endif
int Z_EXPORT PREFIX(gzclose)(gzFile file) {
#ifndef NO_GZCOMPRESS
gz_state *state;
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_state *)file;
return state->mode == GZ_READ ? PREFIX(gzclose_r)(file) : PREFIX(gzclose_w)(file);
#else
return PREFIX(gzclose_r)(file);
#endif
}
/* -- see zlib.h -- */
int ZEXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) {
int Z_EXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) {
gz_state *state;
/* get internal structure and check integrity */
@@ -263,7 +281,7 @@ int ZEXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) {
}
/* -- see zlib.h -- */
int ZEXPORT PREFIX(gzrewind)(gzFile file) {
int Z_EXPORT PREFIX(gzrewind)(gzFile file) {
gz_state *state;
/* get internal structure */
@@ -283,7 +301,7 @@ int ZEXPORT PREFIX(gzrewind)(gzFile file) {
}
/* -- see zlib.h -- */
z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) {
z_off64_t Z_EXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) {
unsigned n;
z_off64_t ret;
gz_state *state;
@@ -354,15 +372,17 @@ z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) {
}
/* -- see zlib.h -- */
z_off_t ZEXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) {
#ifdef ZLIB_COMPAT
z_off_t Z_EXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) {
z_off64_t ret;
ret = PREFIX(gzseek64)(file, (z_off64_t)offset, whence);
ret = PREFIX4(gzseek)(file, (z_off64_t)offset, whence);
return ret == (z_off_t)ret ? (z_off_t)ret : -1;
}
#endif
/* -- see zlib.h -- */
z_off64_t ZEXPORT PREFIX(gztell64)(gzFile file) {
z_off64_t Z_EXPORT PREFIX4(gztell)(gzFile file) {
gz_state *state;
/* get internal structure and check integrity */
@@ -377,15 +397,18 @@ z_off64_t ZEXPORT PREFIX(gztell64)(gzFile file) {
}
/* -- see zlib.h -- */
z_off_t ZEXPORT PREFIX(gztell)(gzFile file) {
#ifdef ZLIB_COMPAT
z_off_t Z_EXPORT PREFIX(gztell)(gzFile file) {
z_off64_t ret;
ret = PREFIX(gztell64)(file);
ret = PREFIX4(gztell)(file);
return ret == (z_off_t)ret ? (z_off_t)ret : -1;
}
#endif
/* -- see zlib.h -- */
z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile file) {
z_off64_t Z_EXPORT PREFIX4(gzoffset)(gzFile file) {
z_off64_t offset;
gz_state *state;
@@ -406,15 +429,17 @@ z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile file) {
}
/* -- see zlib.h -- */
z_off_t ZEXPORT PREFIX(gzoffset)(gzFile file) {
#ifdef ZLIB_COMPAT
z_off_t Z_EXPORT PREFIX(gzoffset)(gzFile file) {
z_off64_t ret;
ret = PREFIX(gzoffset64)(file);
ret = PREFIX4(gzoffset)(file);
return ret == (z_off_t)ret ? (z_off_t)ret : -1;
}
#endif
/* -- see zlib.h -- */
int ZEXPORT PREFIX(gzeof)(gzFile file) {
int Z_EXPORT PREFIX(gzeof)(gzFile file) {
gz_state *state;
/* get internal structure and check integrity */
@@ -429,7 +454,7 @@ int ZEXPORT PREFIX(gzeof)(gzFile file) {
}
/* -- see zlib.h -- */
const char * ZEXPORT PREFIX(gzerror)(gzFile file, int *errnum) {
const char * Z_EXPORT PREFIX(gzerror)(gzFile file, int *errnum) {
gz_state *state;
/* get internal structure and check integrity */
@@ -446,7 +471,7 @@ const char * ZEXPORT PREFIX(gzerror)(gzFile file, int *errnum) {
}
/* -- see zlib.h -- */
void ZEXPORT PREFIX(gzclearerr)(gzFile file) {
void Z_EXPORT PREFIX(gzclearerr)(gzFile file) {
gz_state *state;
/* get internal structure and check integrity */
@@ -470,7 +495,7 @@ void ZEXPORT PREFIX(gzclearerr)(gzFile file) {
memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to
out of memory. */
void ZLIB_INTERNAL gz_error(gz_state *state, int err, const char *msg) {
void Z_INTERNAL gz_error(gz_state *state, int err, const char *msg) {
/* free previously allocated message and clear */
if (state->msg != NULL) {
if (state->err != Z_MEM_ERROR)
@@ -504,7 +529,7 @@ void ZLIB_INTERNAL gz_error(gz_state *state, int err, const char *msg) {
available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax() {
unsigned Z_INTERNAL gz_intmax() {
unsigned p, q;
p = 1;