]> git.proxmox.com Git - libgit2.git/commitdiff
Use our strnlen on MacOS for backward compat
authorRussell Belfer <rb@github.com>
Fri, 3 Jan 2014 19:37:23 +0000 (11:37 -0800)
committerRussell Belfer <rb@github.com>
Fri, 3 Jan 2014 19:37:23 +0000 (11:37 -0800)
Apparently MacOS didn't have strnlen on 10.6 and earlier.  To
avoid having linking problems on older versions, we'll just use
our internal version.

src/posix.h

index f529914fef2d3b6e2ccae4ce7755f4f7fe635624..0d9be49a96276a74bdb09e258005b9cd3c61257b 100644 (file)
@@ -89,13 +89,17 @@ extern struct tm * p_gmtime_r (const time_t *timer, struct tm *result);
 #      include "unix/posix.h"
 #endif
 
-#if defined(__MINGW32__) || defined(__sun)
+#if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__)
+#   define NO_STRNLEN
+#endif
+
+#ifdef NO_STRNLEN
 GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) {
        const char *end = memchr(s, 0, maxlen);
        return end ? (size_t)(end - s) : maxlen;
 }
 #else
-# define p_strnlen strnlen
+#   define p_strnlen strnlen
 #endif
 
 #ifdef NO_READDIR_R