aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-02-09 13:12:28 -0500
committerkwolekr <kwolekr@minetest.net>2014-02-09 13:57:29 -0500
commita0683b811c6641528161050ea91f0425f038fa90 (patch)
tree1d3f43cbd9b985cfbb18694d68730f7c5365532c /src
parent2a01050a0cf0826f25240e2cb407535394ee360f (diff)
downloadminetest-a0683b811c6641528161050ea91f0425f038fa90.tar.gz
minetest-a0683b811c6641528161050ea91f0425f038fa90.tar.bz2
minetest-a0683b811c6641528161050ea91f0425f038fa90.zip
Define strlcpy on platforms that do not have it
Diffstat (limited to 'src')
-rw-r--r--src/porting.h23
-rw-r--r--src/script/common/c_content.cpp1
2 files changed, 19 insertions, 5 deletions
diff --git a/src/porting.h b/src/porting.h
index 0f2007fa7..c03ae40aa 100644
--- a/src/porting.h
+++ b/src/porting.h
@@ -88,11 +88,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define strtoull(x, y, z) _strtoui64(x, y, z)
#define strcasecmp(x, y) stricmp(x, y)
#define strncasecmp(x, y, n) strnicmp(x, y, n)
-
- // We can't simply alias strlcpy() to MSVC's strcpy_s(), since strcpy_s
- // by default raises an assertion error and aborts the program if the
- // buffer is too small. So we need to define our own.
- #define strlcpy(x, y, n) mystrlcpy(x, y, n)
#else
#define ALIGNOF(x) __alignof__(x)
#endif
@@ -101,6 +96,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define strtok_r(x, y, z) mystrtok_r(x, y, z)
#endif
+// strlcpy is missing from glibc. thanks a lot, drepper.
+// strlcpy is also missing from AIX and HP-UX because they aim to be weird.
+// We can't simply alias strlcpy to MSVC's strcpy_s, since strcpy_s by
+// default raises an assertion error and aborts the program if the buffer is
+// too small.
+#if defined(__FreeBSD__) || defined(__NetBSD__) || \
+ defined(__OpenBSD__) || defined(__DragonFly__) || \
+ defined(__APPLE__) || \
+ defined(__sun) || defined(sun) || \
+ defined(__QNX__) || defined(__QNXNTO__)
+ #define HAVE_STRLCPY
+#endif
+
+// So we need to define our own.
+#ifndef HAVE_STRLCPY
+ #define strlcpy(d, s, n) mystrlcpy(d, s, n)
+#endif
+
#define PADDING(x, y) ((ALIGNOF(y) - ((uintptr_t)(x) & (ALIGNOF(y) - 1))) & (ALIGNOF(y) - 1))
namespace porting
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 4e26dc245..8e4da1b05 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "tool.h"
#include "serverobject.h"
+#include "porting.h"
#include "mapgen.h"
#include "json/json.h"