From e3df7caf18e6260dad84b8e4dd09f11886fbbe0e Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 21 May 2010 15:56:19 +0000 Subject: (svn r19874) -Fix [FS#3845]: NetBSD compilation was still broken in some cases (Krille) --- src/string.cpp | 4 ++-- src/string_func.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/string.cpp b/src/string.cpp index 58ac00a6c..4ed2da129 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -398,7 +398,7 @@ size_t Utf8TrimString(char *s, size_t maxlen) return length; } -#ifndef _GNU_SOURCE +#ifdef DEFINE_STRNDUP #include "core/math_func.hpp" char *strndup(const char *s, size_t len) { @@ -407,7 +407,7 @@ char *strndup(const char *s, size_t len) memcpy(tmp, s, len); return tmp; } -#endif /* !_GNU_SOURCE */ +#endif /* DEFINE_STRNDUP */ #ifdef DEFINE_STRCASESTR char *strcasestr(const char *haystack, const char *needle) diff --git a/src/string_func.h b/src/string_func.h index 7787ee57c..f921397a0 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -251,10 +251,13 @@ static inline bool IsWhitespace(WChar c) #include #endif -#if !defined(_GNU_SOURCE) && !(defined(__NetBSD_Version__) && 400000000 < __NetBSD_Version__ ) /* strndup is a GNU extension */ +#if defined(_GNU_SOURCE) || (defined(__NetBSD_Version__) && 400000000 <= __NetBSD_Version__) +# undef DEFINE_STRNDUP +#else +# define DEFINE_STRNDUP char *strndup(const char *s, size_t len); -#endif /* !_GNU_SOURCE */ +#endif /* strndup is available */ /* strcasestr is available for _GNU_SOURCE, BSD and some Apple */ #if defined(_GNU_SOURCE) || (defined(__BSD_VISIBLE) && __BSD_VISIBLE) || (defined(__APPLE__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))) || defined(_NETBSD_SOURCE) -- cgit v1.2.3-54-g00ecf