From 909e07be65d74eb50fc7a41b27852ae387475738 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Sun, 6 Aug 2023 19:34:50 -0700
Subject: [PATCH] Rename HAVE_STRLCPY to SRB2_HAVE_STRLCPY, fix non-glibc
 compile

- Fix compile with msvcrt
- Fix compile with SDL 2.28.2
---
 src/doomtype.h | 12 ++++++++----
 src/string.c   |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/doomtype.h b/src/doomtype.h
index dd5fb0f8dc..4321c707d7 100644
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -122,9 +122,13 @@ int endswith (const char *base, const char *tag);
 #define HAVE_DOSSTR_FUNCS
 #endif
 
-// glibc 2.38: added strlcpy and strlcat to _DEFAULT_SOURCE
-#if defined (__APPLE__) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 38)
-#define HAVE_STRLCPY
+#if defined (__APPLE__)
+	#define SRB2_HAVE_STRLCPY
+#elif defined (__GLIBC_PREREQ)
+	// glibc 2.38: added strlcpy and strlcat to _DEFAULT_SOURCE
+	#if __GLIBC_PREREQ(2, 38)
+		#define SRB2_HAVE_STRLCPY
+	#endif
 #endif
 
 #ifndef HAVE_DOSSTR_FUNCS
@@ -134,7 +138,7 @@ int strlwr(char *n); // from dosstr.c
 
 #include <stddef.h> // for size_t
 
-#ifndef HAVE_STRLCPY
+#ifndef SRB2_HAVE_STRLCPY
 size_t strlcat(char *dst, const char *src, size_t siz);
 size_t strlcpy(char *dst, const char *src, size_t siz);
 #endif
diff --git a/src/string.c b/src/string.c
index cbc8ea5826..2f16fa4c68 100644
--- a/src/string.c
+++ b/src/string.c
@@ -15,7 +15,7 @@
 #include <string.h>
 #include "doomdef.h"
 
-#ifndef HAVE_STRLCPY
+#ifndef SRB2_HAVE_STRLCPY
 
 // Like the OpenBSD version, but it doesn't check for src not being a valid
 // C string.
-- 
GitLab