Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -58,25 +58,16 @@ CPP="$OBJCPP" CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS" OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions -fobjc-exceptions -funwind-tables" OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString" -AX_CHECK_COMPILER_FLAGS(-std=gnu11, [ - OBJCFLAGS="$OBJCFLAGS -std=gnu11" +AX_CHECK_COMPILER_FLAGS(-std=c11, [ + OBJCFLAGS="$OBJCFLAGS -std=c11" ], [ - AX_CHECK_COMPILER_FLAGS(-std=gnu99, - [OBJCFLAGS="$OBJCFLAGS -std=gnu99"]) + AX_CHECK_COMPILER_FLAGS(-std=c99, [OBJCFLAGS="$OBJCFLAGS -std=c99"]) ]) -case $OBJC in - *clang*) - ;; - *) - AX_CHECK_COMPILER_FLAGS([-fgnu89-inline -Werror], - [OBJCFLAGS="$OBJCFLAGS -fgnu89-inline"]) - ;; -esac AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"]) AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"]) AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [ OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings" AC_SUBST(NO_CONST_CFSTRINGS, "-fno-constant-cfstrings") Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -12,13 +12,14 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ +#define _POSIX_SOURCE + #include "config.h" -#define _GNU_SOURCE #include #include #include #include #include Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -11,10 +11,12 @@ * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ + +#define _POSIX_C_SOURCE 200112L #include "config.h" #define __NO_EXT_QNX Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -143,11 +143,11 @@ } static OF_INLINE OFString* normalizedKey(OFString *key) { - char *cString = strdup([key UTF8String]); + char *cString = of_strdup([key UTF8String]); uint8_t *tmp = (uint8_t*)cString; bool firstLetter = true; if (cString == NULL) @throw [OFOutOfMemoryException Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -11,10 +11,12 @@ * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ + +#define _BSD_SOURCE #include "config.h" #include Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -11,10 +11,12 @@ * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ + +#define _BSD_SOURCE #include "config.h" #include #include Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -11,10 +11,12 @@ * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ + +#define _POSIX_SOURCE #include "config.h" #include Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -11,10 +11,12 @@ * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ + +#define _POSIX_C_SOURCE 199309 #include "config.h" #define OF_THREAD_M Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -56,11 +56,11 @@ self = [super init]; @try { char *tmp, *tmp2; - if ((UTF8String2 = strdup([string UTF8String])) == NULL) + if ((UTF8String2 = of_strdup([string UTF8String])) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: [string UTF8StringLength]]; UTF8String = UTF8String2; @@ -192,11 +192,11 @@ _host = [URL->_host copy]; _port = URL->_port; _user = [URL->_user copy]; _password = [URL->_password copy]; - if ((UTF8String2 = strdup([string UTF8String])) == NULL) + if ((UTF8String2 = of_strdup([string UTF8String])) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: [string UTF8StringLength]]; UTF8String = UTF8String2; Index: src/exceptions/OFAddressTranslationFailedException.m ================================================================== --- src/exceptions/OFAddressTranslationFailedException.m +++ src/exceptions/OFAddressTranslationFailedException.m @@ -11,10 +11,12 @@ * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ + +#define _BSD_SOURCE #include "config.h" #import "OFAddressTranslationFailedException.h" #import "OFString.h" Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -12,13 +12,13 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#include "config.h" - #define _GNU_SOURCE + +#include "config.h" #include #ifdef HAVE_DLFCN_H # include Index: src/exceptions/common.h ================================================================== --- src/exceptions/common.h +++ src/exceptions/common.h @@ -17,12 +17,12 @@ #include #include #import "macros.h" -#ifdef HAVE_NETDB_H -# include +#ifdef OF_HAVE_SOCKETS +# include "socket_helpers.h" #endif #ifndef _WIN32 # define GET_ERRNO errno # ifdef OF_HAVE_SOCKETS Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -18,10 +18,11 @@ #include #include #include #include +#include #if defined(OF_APPLE_RUNTIME) # import #endif @@ -409,5 +410,19 @@ of_dimension(width, height) }; return rectangle; } + +static OF_INLINE char* +of_strdup(const char *string) +{ + char *copy; + size_t length = strlen(string); + + if ((copy = malloc(length + 1)) == NULL) + return NULL; + + memcpy(copy, string, length + 1); + + return copy; +} Index: src/of_asprintf.m ================================================================== --- src/of_asprintf.m +++ src/of_asprintf.m @@ -12,13 +12,14 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ +#define _GNU_SOURCE + #include "config.h" -#define _GNU_SOURCE #include #include #include #include #include Index: src/runtime/selector.m ================================================================== --- src/runtime/selector.m +++ src/runtime/selector.m @@ -21,10 +21,12 @@ #include #import "runtime.h" #import "runtime-private.h" +#import "macros.h" + #ifdef OF_SELUID24 # define SEL_MAX 0xFFFFFF #else # define SEL_MAX 0xFFFF #endif @@ -77,11 +79,11 @@ } if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); - if ((sel->name = strdup(name)) == NULL) + if ((sel->name = of_strdup(name)) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); sel->types = NULL; if ((free_list = realloc(free_list,