Further address Microsoft deprecation warnings.
This commit is contained in:
parent
ceac32f156
commit
fd5fe8b17e
@ -16,6 +16,10 @@
|
||||
testing, and causes pufftest to fail with not enough output space (-f does
|
||||
a write like -w, so -w is not required). */
|
||||
|
||||
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "puff.h"
|
||||
@ -23,7 +27,7 @@
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
# define SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
|
||||
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
|
||||
#else
|
||||
# define SET_BINARY_MODE(file)
|
||||
#endif
|
||||
|
@ -10,6 +10,10 @@
|
||||
// the data, so it is fast, but no advantage is gained from the history that
|
||||
// could be available across member boundaries.
|
||||
|
||||
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <stdio.h> // fread, fwrite, putc, fflush, ferror, fprintf,
|
||||
// vsnprintf, stdout, stderr, NULL, FILE
|
||||
#include <stdlib.h> // malloc, free
|
||||
@ -24,7 +28,7 @@
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
# define SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
|
||||
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
|
||||
#else
|
||||
# define SET_BINARY_MODE(file)
|
||||
#endif
|
||||
|
@ -12,6 +12,10 @@
|
||||
Avoid some compiler warnings for input and output buffers
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
@ -20,7 +24,7 @@
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
# define SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
|
||||
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
|
||||
#else
|
||||
# define SET_BINARY_MODE(file)
|
||||
#endif
|
||||
|
11
gzguts.h
11
gzguts.h
@ -20,6 +20,9 @@
|
||||
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zlib.h"
|
||||
@ -40,7 +43,6 @@
|
||||
|
||||
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||
# include <io.h>
|
||||
# include <share.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
@ -48,13 +50,6 @@
|
||||
# define WIDECHAR
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(WINAPI_FAMILY)
|
||||
# define open _open
|
||||
# define read _read
|
||||
# define write _write
|
||||
# define close _close
|
||||
#endif
|
||||
|
||||
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||
# define NO_GZCOMPRESS
|
||||
#endif
|
||||
|
28
gzlib.c
28
gzlib.c
@ -5,15 +5,17 @@
|
||||
|
||||
#include "gzguts.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__BORLANDC__)
|
||||
#if defined(UNDER_CE)
|
||||
# define LSEEK _wcelseek
|
||||
#elif defined(__DJGPP__)
|
||||
# define LSEEK llseek
|
||||
#elif defined(_WIN32) && !defined(__BORLANDC__)
|
||||
# define LSEEK _lseeki64
|
||||
#else
|
||||
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
||||
#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
||||
# define LSEEK lseek64
|
||||
#else
|
||||
# define LSEEK lseek
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined UNDER_CE
|
||||
|
||||
@ -52,8 +54,7 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
|
||||
msgbuf[chars] = 0;
|
||||
}
|
||||
|
||||
z_size_t len;
|
||||
wcstombs_s(&len, buf, sizeof(buf), msgbuf, chars + 1);
|
||||
wcstombs(buf, msgbuf, chars + 1); // assumes buf is big enough
|
||||
LocalFree(msgbuf);
|
||||
}
|
||||
else {
|
||||
@ -180,10 +181,8 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
|
||||
/* save the path name for error messages */
|
||||
#ifdef WIDECHAR
|
||||
if (fd == -2) {
|
||||
if (wcstombs_s(&len, NULL, 0, path, 0) != 0)
|
||||
len = 0;
|
||||
}
|
||||
if (fd == -2)
|
||||
len = wcstombs(NULL, path, 0);
|
||||
else
|
||||
#endif
|
||||
len = strlen((const char *)path);
|
||||
@ -193,18 +192,21 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
return NULL;
|
||||
}
|
||||
#ifdef WIDECHAR
|
||||
if (fd == -2)
|
||||
if (fd == -2) {
|
||||
if (len)
|
||||
wcstombs_s(&len, state->path, len + 1, path, len + 1);
|
||||
wcstombs(state->path, path, len + 1);
|
||||
else
|
||||
*(state->path) = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||
(void)snprintf(state->path, len + 1, "%s", (const char *)path);
|
||||
#else
|
||||
strcpy(state->path, path);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* compute the flags for open() */
|
||||
oflag =
|
||||
@ -232,7 +234,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
state->fd = open((const char *)path, oflag, 0666);
|
||||
#ifdef WIDECHAR
|
||||
else if (fd == -2)
|
||||
_wsopen_s(&state->fd, path, oflag, _SH_DENYNO, _S_IREAD | _S_IWRITE);
|
||||
state->fd = _wopen(path, oflag, _S_IREAD | _S_IWRITE);
|
||||
#endif
|
||||
else
|
||||
state->fd = fd;
|
||||
|
@ -5,6 +5,10 @@
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "zlib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -19,6 +19,13 @@
|
||||
# define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include "zlib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@ -39,7 +46,7 @@
|
||||
# ifdef UNDER_CE
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
# define SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
|
||||
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
|
||||
#else
|
||||
# define SET_BINARY_MODE(file)
|
||||
#endif
|
||||
@ -58,10 +65,6 @@
|
||||
#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
# include <unix.h> /* for fileno */
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
# define fileno _fileno
|
||||
# define unlink _unlink
|
||||
#endif
|
||||
|
||||
#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
|
||||
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
|
||||
|
Loading…
Reference in New Issue
Block a user