From feb8c1c31ba0ca5eb9fcdc3f02b58893cc2e580e Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 11 Oct 2022 19:50:18 +0200 Subject: [PATCH] libc: Implement strchr() --- libs/libc/src/string.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/libc/src/string.cpp b/libs/libc/src/string.cpp index ffbf07f2..8055e9a0 100644 --- a/libs/libc/src/string.cpp +++ b/libs/libc/src/string.cpp @@ -61,9 +61,11 @@ extern "C" return dest; } - char* strchr(const char*, int) + char* strchr(const char* str, int chr) { - NOT_IMPLEMENTED("strchr"); + while (*str && *str != (char)chr) str++; + if (*str) return const_cast(str); + return NULL; } void* memclr(void* start, size_t count)