summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/config.h26
-rw-r--r--utils/utils.c2
2 files changed, 19 insertions, 9 deletions
diff --git a/utils/config.h b/utils/config.h
index ba6d9b464..4a4fa069c 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -23,15 +23,30 @@
/* Try to detect which features the target OS supports */
+#if (defined(_GNU_SOURCE))
+#define HAVE_STRNDUP
+#else
+#undef HAVE_STRNDUP
char *strndup(const char *s, size_t n);
+#endif
+#if (defined(_GNU_SOURCE))
#define HAVE_STRCASESTR
-#if (!(defined(__NetBSD__) || defined(__OpenBSD__)) \
- || defined(riscos) || defined(__APPLE__) || defined(_WIN32))
+#else
#undef HAVE_STRCASESTR
char *strcasestr(const char *haystack, const char *needle);
#endif
+/* For some reason, UnixLib defines this unconditionally.
+ * Assume we're using UnixLib if building for RISC OS. */
+#if (defined(_GNU_SOURCE) || defined(riscos))
+#define HAVE_STRCHRNUL
+#else
+#undef HAVE_STRCHRNUL
+char *strchrnul(const char *s, int c);
+#endif
+
+
#define HAVE_UTSNAME
#if (defined(_WIN32))
#undef HAVE_UTSNAME
@@ -52,13 +67,6 @@ char *strcasestr(const char *haystack, const char *needle);
#undef HAVE_STDOUT
#endif
-#define HAVE_STRCHRNUL
-/* For some reason, UnixLib defines this unconditionally.
- * Assume we're using UnixLib if building for RISC OS. */
-#if !(defined(riscos))
-#undef HAVE_STRCHRNUL
-char *strchrnul(const char *s, int c);
-#endif
/* This section toggles build options on and off.
* Simply undefine a symbol to turn the relevant feature off.
diff --git a/utils/utils.c b/utils/utils.c
index b0069365e..175b33073 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -295,6 +295,7 @@ char *strcasestr(const char *haystack, const char *needle)
#endif
+#ifndef HAVE_STRNDUP
/**
* Duplicate up to n characters of a string.
@@ -317,6 +318,7 @@ char *strndup(const char *s, size_t n)
return s2;
}
+#endif
#ifndef HAVE_STRCHRNUL