From f02ea29e5f5f1b14e71dfdf44bf39ee969ca9bde Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Mon, 11 Mar 2024 22:24:14 +0100 Subject: [PATCH] Improve detection of UNIX-style systems in minizip. Not all toolchains on UNIX-style operating systems predefine "unix". For example, it's missing on NetBSD, OpenBSD/gcc, AIX, HP-UX. There is no single macro defined everywhere, but checking both "__unix__" and "__unix" should cover everything except macOS, which is already checked for using "__APPLE__". Note that case sensitivity should default to off on macOS and cygwin, so the check there is different. --- contrib/minizip/make_vms.com | 2 +- contrib/minizip/miniunz.c | 8 ++------ contrib/minizip/minizip.c | 4 +--- contrib/minizip/unzip.c | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/contrib/minizip/make_vms.com b/contrib/minizip/make_vms.com index 9ac13a9..4a0a77e 100644 --- a/contrib/minizip/make_vms.com +++ b/contrib/minizip/make_vms.com @@ -2,7 +2,7 @@ $ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig $ open/write zdef vmsdefs.h $ copy sys$input: zdef $ deck -#define unix +#define __unix__ #define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from #define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator #define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c index d871b3f..8e19534 100644 --- a/contrib/minizip/miniunz.c +++ b/contrib/minizip/miniunz.c @@ -93,8 +93,7 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat LocalFileTimeToFileTime(&ftLocal,&ftm); SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); CloseHandle(hFile); -#else -#if defined(unix) || defined(__APPLE__) +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) (void)dosdate; struct utimbuf ut; struct tm newdate; @@ -116,7 +115,6 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat (void)dosdate; (void)tmu_date; #endif -#endif } @@ -127,9 +125,7 @@ static int mymkdir(const char* dirname) { int ret=0; #ifdef _WIN32 ret = _mkdir(dirname); -#elif unix - ret = mkdir (dirname,0775); -#elif __APPLE__ +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) ret = mkdir (dirname,0775); #else (void)dirname; diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c index 26ee8d0..4d93d22 100644 --- a/contrib/minizip/minizip.c +++ b/contrib/minizip/minizip.c @@ -91,8 +91,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { } return ret; } -#else -#if defined(unix) || defined(__APPLE__) +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) /* f: name of file to get info on, tmzip: return value: access, modification and creation times, dt: dostime */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { @@ -143,7 +142,6 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { return 0; } #endif -#endif diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index b5783ca..feaec67 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c @@ -88,7 +88,7 @@ #ifndef CASESENSITIVITYDEFAULT_NO -# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) +# if (!defined(__unix__) && !defined(__unix) || defined(__CYGWIN__)) && !defined(CASESENSITIVITYDEFAULT_YES) # define CASESENSITIVITYDEFAULT_NO # endif #endif