unzip: fix configure script when using clang 16

Clang 16 makes implicit int and function declarations an error by
default in any mode except for C89. The configure script has two of
these that cause it to misdetect features when using Clang 16.

* Implicit `int main` in the errno check. This is fixed by adding the
missing `int`.
* Implicit definitions of `opendir` and `closedir`. These are fixed by
including the required headers.

+25
+4
pkgs/tools/archivers/unzip/default.nix
··· 60 60 ]; 61 61 sha256 = "sha256-on79jElQ+z2ULWAq14RpluAqr9d6itHiZwDkKubBzTc="; 62 62 }) 63 + # Clang 16 makes implicit declarations an error by default for C99 and newer, causing the 64 + # configure script to fail to detect errno and the directory libraries on Darwin. 65 + ./implicit-declarations-fix.patch 63 66 ] ++ lib.optional enableNLS 64 67 (fetchurl { 65 68 url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/unzip/files/unzip-6.0-natspec.patch?id=56bd759df1d0c750a065b8c845e93d5dfa6b549d"; 66 69 name = "unzip-6.0-natspec.patch"; 67 70 sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1"; 68 71 }); 72 + 69 73 70 74 nativeBuildInputs = [ bzip2 ]; 71 75 buildInputs = [ bzip2 ] ++ lib.optional enableNLS libnatspec;
+21
pkgs/tools/archivers/unzip/implicit-declarations-fix.patch
··· 1 + --- a/unix/configure 2009-04-16 15:25:12.000000000 -0400 2 + +++ b/unix/configure 2023-05-30 15:18:33.670321348 -0400 3 + @@ -408,7 +408,7 @@ 4 + echo Check for errno declaration 5 + cat > conftest.c << _EOF_ 6 + #include <errno.h> 7 + -main() 8 + +int main() 9 + { 10 + errno = 0; 11 + return 0; 12 + @@ -419,6 +419,8 @@ 13 + 14 + echo Check for directory libraries 15 + cat > conftest.c << _EOF_ 16 + +#include <sys/types.h> 17 + +#include <dirent.h> 18 + int main() { return closedir(opendir(".")); } 19 + _EOF_ 20 + 21 +