From e7c9b80d853a195c7cfd081584ebd766b9a49d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 29 Sep 2022 14:22:56 +0800 Subject: [PATCH] Fix building on Linux It seems that glibc doesn't support strnstr, and strcasestr requires _GNU_SOURCE to be defined --- CMakeLists.txt | 2 ++ src/detection/displayserver/linux/wayland.c | 2 -- src/util/FFstrbuf.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 533340744..b0c9af29b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,6 +333,8 @@ add_library(libfastfetch OBJECT ${LIBFASTFETCH_SRC} ) +target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE) + CHECK_INCLUDE_FILE("sys/sysinfo.h" HAVE_SYSINFO_H) if(HAVE_SYSINFO_H) # needs to be public, because changes fastfech.h ABI diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 03d3f907f..39743282c 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -1,5 +1,3 @@ -#define _GNU_SOURCE //required for struct ucred - #include "displayserver_linux.h" #include diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index ec985b84f..d6397c6dc 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -159,7 +159,7 @@ static inline FF_C_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, con static inline FF_C_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) { - return strnstr(strbuf->chars, str, strbuf->length) != NULL; + return strstr(strbuf->chars, str) != NULL; } static inline FF_C_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str)