From b9a98af00d520be97c6c469328f732467e86d8d7 Mon Sep 17 00:00:00 2001 From: John McNamara Date: Fri, 16 Apr 2021 21:32:39 +0100 Subject: [PATCH] Another fix for modified zconf.h on Gentoo. Issue #116 --- CMakeLists.txt | 5 ----- include/xlsxwriter/third_party/ioapi.h | 6 +++++- src/Makefile | 6 ------ third_party/minizip/Makefile | 5 ----- third_party/minizip/ioapi.h | 10 ++++++++++ third_party/minizip/zip.h | 10 +++++++++- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e36a5ca8..99224a06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,11 +206,6 @@ endif() # ------- list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS NOCRYPT NOUNCRYPT) -# Fix for modified zconf.h on Gentoo. -if(${CMAKE_HOST_SYSTEM} MATCHES gentoo) - list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS OF=_Z_OF) -endif() - # Ensure CRT Secure warnings are disabled if(MSVC) list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS) diff --git a/include/xlsxwriter/third_party/ioapi.h b/include/xlsxwriter/third_party/ioapi.h index ba71ff71..623c9bb5 100644 --- a/include/xlsxwriter/third_party/ioapi.h +++ b/include/xlsxwriter/third_party/ioapi.h @@ -56,7 +56,7 @@ #define ftello64 ftell #define fseeko64 fseek #else -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) #define fopen64 fopen #define ftello64 ftello #define fseeko64 fseeko @@ -137,6 +137,10 @@ extern "C" { +/* Workaround for modified zconf.h on Gentoo system. */ +#if defined(_Z_OF) +#define OF _Z_OF +#endif typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); diff --git a/src/Makefile b/src/Makefile index afb48db7..835ed7ae 100644 --- a/src/Makefile +++ b/src/Makefile @@ -69,12 +69,6 @@ endif # Flags passed to compiler. CFLAGS += -g $(OPT_LEVEL) -Wall -Wextra -Wstrict-prototypes -pedantic -ansi -# Fix for modified zconf.h on Gentoo. -ifneq (,$(findstring gentoo, $(shell uname -sr))) -CFLAGS += -DOF=_Z_OF -endif - - # Ignore icc remarks about inlining limits. ifeq ($(CC),icc) CFLAGS +=-diag-disable=11074,11076 diff --git a/third_party/minizip/Makefile b/third_party/minizip/Makefile index 5251c3c3..a59c0eed 100644 --- a/third_party/minizip/Makefile +++ b/third_party/minizip/Makefile @@ -32,11 +32,6 @@ CC = gcc CFLAGS += -DUSE_FILE32API endif -# Fix for modified zconf.h on Gentoo. -ifneq (,$(findstring gentoo, $(UNAME))) -CFLAGS += -DOF=_Z_OF -endif - all: ioapi.o zip.o ioapi.so zip.so %.o : %.c diff --git a/third_party/minizip/ioapi.h b/third_party/minizip/ioapi.h index 43aaf6f1..623c9bb5 100644 --- a/third_party/minizip/ioapi.h +++ b/third_party/minizip/ioapi.h @@ -18,6 +18,12 @@ */ + +/* Pragma added by libxlsxwriter to avoid warnings with -pedantic -ansi. */ +#ifndef _WIN32 +#pragma GCC system_header +#endif + #ifndef _ZLIBIOAPI64_H #define _ZLIBIOAPI64_H @@ -131,6 +137,10 @@ extern "C" { +/* Workaround for modified zconf.h on Gentoo system. */ +#if defined(_Z_OF) +#define OF _Z_OF +#endif typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); diff --git a/third_party/minizip/zip.h b/third_party/minizip/zip.h index 067b912a..c1777442 100644 --- a/third_party/minizip/zip.h +++ b/third_party/minizip/zip.h @@ -37,7 +37,7 @@ */ -/* Pragma added by libxlsxwriter project to avoid warnings with -pedantic -ansi. */ +/* Pragma added by libxlsxwriter to avoid warnings with -pedantic -ansi. */ #ifndef _WIN32 #pragma GCC system_header #endif @@ -59,6 +59,14 @@ extern "C" { #include "ioapi.h" #endif +/* Encryption not required by libxlsxwriter. */ +#ifndef NOCRYPT +#define NOCRYPT +#endif +#ifndef NOUNCRYPT +#define NOUNCRYPT +#endif + #ifdef HAVE_BZIP2 #include "bzlib.h" #endif