changeset 11036:a7a7e54d52a6 draft

(svn r15376) -Fix [FS#2608] (r15371): OSX/BSD also seems to define strcasecmp under some circumstances.
author rubidium <rubidium@openttd.org>
date Fri, 06 Feb 2009 15:53:48 +0000
parents 1cbb47ebf5b2
children 0b68b7f9ea7f
files src/string.cpp src/string_func.h
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -362,7 +362,9 @@
 	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 @@
 
 	return NULL;
 }
-#endif /* !_GNU_SOURCE */
+#endif /* DEFINE_STRCASESTR */
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -234,9 +234,16 @@
 }
 
 #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 */