https://bugs.gentoo.org/830231 https://github.com/nih-at/libzip/issues/253 https://github.com/nih-at/libzip/commit/e29f28b4fe66ef24e205678dc29f65d693c649eb From e29f28b4fe66ef24e205678dc29f65d693c649eb Mon Sep 17 00:00:00 2001 From: Dieter Baron Date: Fri, 22 Nov 2024 11:32:32 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20hardcode=20=5FNullable=20suppor?= =?UTF-8?q?t=20in=20zip.h.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on and closes #253. --- CMakeLists.txt | 11 ----------- config.h.in | 1 - lib/zip.h | 9 +++++++++ zipconf.h.in | 2 -- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23e0f0fd8..3d5fa1bc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,10 +192,6 @@ check_c_source_compiles("#include #include int main(int argc, char *argv[]) { unsigned long x = FICLONERANGE; }" HAVE_FICLONERANGE) -check_c_source_compiles(" -int foo(char * _Nullable bar); -int main(int argc, char *argv[]) { }" HAVE_NULLABLE) - test_big_endian(WORDS_BIGENDIAN) find_package(ZLIB 1.1.2 REQUIRED) @@ -458,13 +454,6 @@ elseif(LONG_LONG_LIBZIP EQUAL 8) set(ZIP_UINT64_T "unsigned long long") endif() -if(HAVE_NULLABLE) - set(ZIP_NULLABLE_DEFINES) -else() - set(ZIP_NULLABLE_DEFINES "#define _Nullable -#define _Nonnull") -endif() - # write out config file configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zipconf.h.in ${PROJECT_BINARY_DIR}/zipconf.h) diff --git a/config.h.in b/config.h.in index 90a324285..09d42384d 100644 --- a/config.h.in +++ b/config.h.in @@ -41,7 +41,6 @@ #cmakedefine HAVE_MEMCPY_S #cmakedefine HAVE_MBEDTLS #cmakedefine HAVE_MKSTEMP -#cmakedefine HAVE_NULLABLE #cmakedefine HAVE_OPENSSL #cmakedefine HAVE_SETMODE #cmakedefine HAVE_SNPRINTF diff --git a/lib/zip.h b/lib/zip.h index 14064062f..c2a8a8b46 100644 --- a/lib/zip.h +++ b/lib/zip.h @@ -34,6 +34,15 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if defined(__has_feature) + #if !__has_feature(nullability) + #define _Nullable + #define _Nonnull + #endif +#else + #define _Nullable + #define _Nonnull +#endif #ifdef __cplusplus extern "C" { diff --git a/zipconf.h.in b/zipconf.h.in index b88ed267f..04dce7184 100644 --- a/zipconf.h.in +++ b/zipconf.h.in @@ -15,8 +15,6 @@ #cmakedefine ZIP_STATIC -${ZIP_NULLABLE_DEFINES} - ${LIBZIP_TYPES_INCLUDE} typedef ${ZIP_INT8_T} zip_int8_t;