summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-02-06 15:53:48 +0000
committerrubidium <rubidium@openttd.org>2009-02-06 15:53:48 +0000
commitcecc3863cdcc355ab6245bf8ebb8d62a468877ea (patch)
treef7ee9f37c53fbd50c1d59ee0764b26ab094ec044
parent9bc7e4bdb2fdc33e709ec25fdd0745921097915b (diff)
downloadopenttd-cecc3863cdcc355ab6245bf8ebb8d62a468877ea.tar.xz
(svn r15376) -Fix [FS#2608] (r15371): OSX/BSD also seems to define strcasecmp under some circumstances.
-rw-r--r--src/string.cpp4
-rw-r--r--src/string_func.h11
2 files changed, 12 insertions, 3 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 289031cfc..1ab68a274 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -362,7 +362,9 @@ char *strndup(const char *s, size_t len)
memcpy(tmp, s, len);
return tmp;
}
+#endif /* !_GNU_SOURCE */
+#ifdef DEFINE_STRCASESTR
const char *strcasestr(const char *haystack, const char *needle)
{
size_t hay_len = strlen(haystack);
@@ -376,4 +378,4 @@ const char *strcasestr(const char *haystack, const char *needle)
return NULL;
}
-#endif /* !_GNU_SOURCE */
+#endif /* DEFINE_STRCASESTR */
diff --git a/src/string_func.h b/src/string_func.h
index c63fc6719..ad32a5558 100644
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -234,9 +234,16 @@ static inline bool IsWhitespace(WChar c)
}
#ifndef _GNU_SOURCE
-/* strndup and strcasestr are GNU extensions */
+/* strndup is a GNU extension */
char *strndup(const char *s, size_t len);
-const char *strcasestr(const char *haystack, const char *needle);
#endif /* !_GNU_SOURCE */
+/* 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)))
+# undef DEFINE_STRCASESTR
+#else
+# define DEFINE_STRCASESTR
+const char *strcasestr(const char *haystack, const char *needle);
+#endif /* strcasestr is available */
+
#endif /* STRING_FUNC_H */