From cc9cae1908127012697e431e4d51577df811d8fe Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 30 Mar 2026 19:21:33 -0400 Subject: [PATCH] BString: memrchr is nonstandard and not available on macOS. We use BString in the build platform, so we need it to work everywhere. Add a fallback for non-Haiku targets (though glibc and others do have memrchr and so could keep this, if we added some more logic here.) --- src/kits/support/String.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/kits/support/String.cpp b/src/kits/support/String.cpp index c81811298f..628123d942 100644 --- a/src/kits/support/String.cpp +++ b/src/kits/support/String.cpp @@ -2529,6 +2529,7 @@ int32 BString::_FindBefore(const char* string, int32 offset, int32 length) const { if (fPrivateData != NULL) { +#ifdef __HAIKU__ const char* end = fPrivateData + offset - (length - 1); while (end >= fPrivateData) { const char* ptr = (const char*)memrchr(fPrivateData, @@ -2541,6 +2542,14 @@ BString::_FindBefore(const char* string, int32 offset, int32 length) const end = ptr; } +#else + const char* ptr = fPrivateData + offset - length; + while (ptr >= fPrivateData) { + if (!memcmp(ptr, string, length)) + return ptr - fPrivateData; + ptr--; + } +#endif } return B_ERROR; }