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.)
This commit is contained in:
Augustin Cavalier
2026-03-30 19:21:33 -04:00
parent d6c0df2394
commit cc9cae1908
+9
View File
@@ -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;
}