From 2312445276fbb6641908b90fd3223f6a29a08020 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:51:06 +0100 Subject: [PATCH] check for _GNU_SOURCE for nongnu_strcasestr idk we dont need it and it throws warnings on new glibc so i dont want it tbh --- src/doomtype.h | 2 +- src/strcasestr.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 371cf3a6a..27571f981 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,8 +68,8 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -char *nongnu_strcasestr(const char *in, const char *what); #ifndef _GNU_SOURCE +char *nongnu_strcasestr(const char *in, const char *what); #define strcasestr nongnu_strcasestr #endif diff --git a/src/strcasestr.c b/src/strcasestr.c index f05449778..84bc0671e 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -23,24 +23,26 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _GNU_SOURCE + #include #include #include -static inline int -trycmp (char **pp, char *cp, - const char *q, size_t qn) +static inline int trycmp(char **pp, char *cp, const char *q, size_t qn) { char *p; p = (*pp); + if (strncasecmp(p, q, qn) == 0) return 0; + (*pp) = strchr(&p[1], (*cp)); + return 1; } -static inline void -swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) +static inline void swapp(char ***ppap, char ***ppbp, char **cpap, char **cpbp) { char **pp; char *p; @@ -54,8 +56,7 @@ swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) *cpbp = p; } -char * -nongnu_strcasestr (const char *s, const char *q) +char *nongnu_strcasestr(const char *s, const char *q) { size_t qn; @@ -113,3 +114,5 @@ nongnu_strcasestr (const char *s, const char *q) return NULL; } + +#endif