summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRob Kendrick <rjek@netsurf-browser.org>2007-06-16 23:30:47 +0000
committerRob Kendrick <rjek@netsurf-browser.org>2007-06-16 23:30:47 +0000
commit36ecbc6be227102eed47b8a61f8de46e322d70ec (patch)
tree493dcdec9a8785368d0caa74efe7f32f04161a9c /utils
parent43257a160bbdef8a8381fc7cc01741568ae1e320 (diff)
downloadnetsurf-36ecbc6be227102eed47b8a61f8de46e322d70ec.tar.gz
netsurf-36ecbc6be227102eed47b8a61f8de46e322d70ec.tar.bz2
Add HAVE_STRNDUP and supporting structure to config.h and make utils.[ch] reflect it.
svn path=/trunk/netsurf/; revision=3351
Diffstat (limited to 'utils')
-rw-r--r--utils/config.h13
-rw-r--r--utils/utils.c2
-rw-r--r--utils/utils.h4
3 files changed, 13 insertions, 6 deletions
diff --git a/utils/config.h b/utils/config.h
index e90bb4244..afb7fa298 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -9,7 +9,18 @@
#ifndef _NETSURF_UTILS_CONFIG_H_
#define _NETSURF_UTILS_CONFIG_H_
-/* This file toggles build options on and off.
+/* Try to detect which features the target OS supports */
+
+#define HAVE_STRNDUP
+#if defined(__FreeBSD__) || (defined(__SRV4) && defined(__sun))
+ /* FreeBSD and Solaris do not have this function, so
+ * we implement it ourselves in util.c
+ */
+#undef HAVE_STRNDUP
+char *strndup(const char *s, size_t n);
+#endif
+
+/* This section toggles build options on and off.
* Simply undefine a symbol to turn the relevant feature off.
*
* IF ADDING A FEATURE HERE, ADD IT TO Docs/Doxyfile LINE 892 AS WELL.
diff --git a/utils/utils.c b/utils/utils.c
index 53124a0d1..3ce1e48e6 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -257,7 +257,7 @@ unsigned int wallclock(void)
}
-#if defined(__FreeBSD__) || (defined(__SVR4) && defined(__sun))
+#ifndef HAVE_STRNDUP
/**
* Duplicate up to n characters of a string.
diff --git a/utils/utils.h b/utils/utils.h
index d080bd018..502847836 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -59,10 +59,6 @@ const char *rfc1123_date(time_t t);
char *strcasestr(const char *haystack, const char *needle);
#endif
unsigned int wallclock(void);
-#ifdef __FreeBSD__
-/* FreeBSD lacks strndup */
-char *strndup(const char *s, size_t n);
-#endif
/* Platform specific functions */
void die(const char * const error);