]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Slight improvement in the way we include the strl{cat,cpy} declarations and implement...
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 27 Jan 2004 09:08:55 +0000 (09:08 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 27 Jan 2004 09:08:55 +0000 (09:08 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3841 d7cf8633-e32d-0410-b094-e92efae38249

common.c
common.h

index 45e9f814050eac6b858266d88eedeb680bc426b2..8af5518b1ef3e0ac9baff0a141ad3706d294cd2d 100644 (file)
--- 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 $     */
 
 
 /*     $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)
 {
 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 */
 }
 
        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)
 {
 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 */
 }
 
        return(s - src - 1);    /* count does not include NUL */
 }
 
-#endif  // #if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
+#endif  // #ifndef HAVE_STRLCPY
index 69a67f2617f0d4f7606974b960237926230976d7..837b01c16463b5440b9f2625f2261be00e842937 100644 (file)
--- 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
 
 // 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
 /*
  * 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);
  * 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).
 /*
  * 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);
 
  */
 size_t strlcpy(char *dst, const char *src, size_t siz);
 
-#endif  // #if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
+#endif  // #ifndef HAVE_STRLCPY
 
 #endif
 
 
 #endif