--- a/src/string.c Thu Oct 02 17:58:43 2025 +0200 +++ b/src/string.c Thu Oct 02 21:21:45 2025 +0200 @@ -25,14 +25,13 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef MEMRCHR_NEED_GNU #define _GNU_SOURCE -#include <string.h> -#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >=2 -#define FEATURE_MEMRCHR_AVAILABLE #endif #include "cx/string.h" +#include <string.h> #include <stdarg.h> #include <assert.h> #include <errno.h> @@ -239,7 +238,7 @@ cxstring string, int chr ) { -#ifdef FEATURE_MEMRCHR_AVAILABLE +#ifdef WITH_MEMRCHR char *ret = memrchr(string.ptr, 0xFF & chr, string.length); if (ret == NULL) return (cxstring) {NULL, 0}; return (cxstring) {ret, string.length - (ret - string.ptr)}; @@ -248,7 +247,6 @@ size_t i = string.length; while (i > 0) { i--; - // TODO: improve by comparing multiple bytes at once if (string.ptr[i] == chr) { return cx_strsubs(string, i); }