From 047fdbba3b8c692e2b78b7853769b5f3df7e0297 Mon Sep 17 00:00:00 2001 From: Zeex Date: Sat, 30 Dec 2017 22:14:22 +0600 Subject: [PATCH] Fix strlcpy/strlcat error on macOS --- source/compiler/lstring.c | 11 +---------- source/compiler/lstring.h | 12 +++++++++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/compiler/lstring.c b/source/compiler/lstring.c index bbd359f..3f02519 100644 --- a/source/compiler/lstring.c +++ b/source/compiler/lstring.c @@ -5,6 +5,7 @@ * (there is no need to include the same files twice). */ +#include /* for strlen() */ #include "lstring.h" #if !defined HAVE_STRLCPY @@ -27,11 +28,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* - #include already included through lstring.h - */ -#include /* for strlen() */ - /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). @@ -85,11 +81,6 @@ strlcpy(char *dst, const char *src, size_t siz) * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* - #include already included - #include already included -*/ - /* * Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters diff --git a/source/compiler/lstring.h b/source/compiler/lstring.h index ecf608b..9d011ec 100644 --- a/source/compiler/lstring.h +++ b/source/compiler/lstring.h @@ -2,12 +2,18 @@ #include -#if (defined __WATCOMC__ && __WATCOMC__ >= 1240) - /* OpenWatcom introduced BSD "safe string functions" with version 1.4 */ - || defined __APPLE__ +#if defined __WATCOMC__ && __WATCOMC__ >= 1240 + /* OpenWatcom introduced BSD "safe string functions" with version 1.4 */ #define HAVE_SAFESTR #endif +#if defined strlcpy + #define HAVE_STRLCPY +#endif +#if defined strlcat + #define HAVE_STRLCAT +#endif + #if defined HAVE_SAFESTR #define HAVE_STRLCPY #define HAVE_STRLCAT