From: molivier Date: Tue, 27 Jan 2004 09:08:55 +0000 (+0000) Subject: Slight improvement in the way we include the strl{cat,cpy} declarations and implement... X-Git-Tag: xonotic-v0.1.0preview~6144 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=b22ff27a8a8ba82336afde66a0677de1cddfd6b8 Slight improvement in the way we include the strl{cat,cpy} declarations and implementations into the code. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3841 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/common.c b/common.c index 45e9f814..8af5518b 100644 --- a/common.c +++ b/common.c @@ -1115,9 +1115,7 @@ char *SearchInfostring(const char *infostring, const char *key) /* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ -// Most (all?) BSDs already have them -#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !(defined(__APPLE__) && defined(__MACH__)) - +#ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz) { @@ -1145,7 +1143,10 @@ strlcat(char *dst, const char *src, size_t siz) return(dlen + (s - src)); /* count does not include NUL */ } +#endif // #ifndef HAVE_STRLCAT + +#ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t siz) { @@ -1172,4 +1173,4 @@ strlcpy(char *dst, const char *src, size_t siz) return(s - src - 1); /* count does not include NUL */ } -#endif // #if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) +#endif // #ifndef HAVE_STRLCPY diff --git a/common.h b/common.h index 69a67f26..837b01c1 100644 --- a/common.h +++ b/common.h @@ -204,8 +204,12 @@ char *SearchInfostring(const char *infostring, const char *key); // strlcat and strlcpy, from OpenBSD // Most (all?) BSDs already have them -#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || (defined(__APPLE__) && defined(__MACH__)) +# define HAVE_STRLCAT 1 +# define HAVE_STRLCPY 1 +#endif +#ifndef HAVE_STRLCAT /* * 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 @@ -214,7 +218,9 @@ char *SearchInfostring(const char *infostring, const char *key); * If retval >= siz, truncation occurred. */ size_t strlcat(char *dst, const char *src, size_t siz); +#endif // #ifndef HAVE_STRLCAT +#ifndef HAVE_STRLCPY /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). @@ -222,7 +228,7 @@ size_t strlcat(char *dst, const char *src, size_t siz); */ size_t strlcpy(char *dst, const char *src, size_t siz); -#endif // #if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) +#endif // #ifndef HAVE_STRLCPY #endif