Skip to content

Commit

Permalink
Improve detection of UNIX-style systems in minizip.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
miller-alex authored and madler committed Mar 16, 2024
1 parent 9f418e1 commit f02ea29
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contrib/minizip/make_vms.com
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions contrib/minizip/miniunz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}


Expand All @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions contrib/minizip/minizip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -143,7 +142,6 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
return 0;
}
#endif
#endif



Expand Down
2 changes: 1 addition & 1 deletion contrib/minizip/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f02ea29

Please sign in to comment.