libc: Fix strrchr

This commit is contained in:
apio 2022-10-15 16:06:41 +02:00
parent 6953a28ce8
commit 5256166e7a

View File

@ -136,8 +136,9 @@ extern "C"
char* strrchr(const char* str, int c) char* strrchr(const char* str, int c)
{ {
const char* s = str + strlen(str); const char* s = str + strlen(str);
while (s != str && *str != (char)c) str--; while (s != str && *s != (char)c) s--;
if (s != str) return const_cast<char*>(s); if (s != str) return const_cast<char*>(s);
if (*s == (char)c) return const_cast<char*>(s);
return NULL; return NULL;
} }