Skip to content
Snippets Groups Projects
Commit 230612b2 authored by John Hodge's avatar John Hodge
Browse files

Usermode/libc - Fix strchr and strrchr behavior

parent 86b0974b
No related merge requests found
......@@ -184,15 +184,16 @@ EXPORT char *strndup(const char *str, size_t maxlen)
/**
* \fn EXPORT char *strchr(char *str, int character)
* \brief Locate a character in a string
* \note The terminating NUL is part of the string
*/
EXPORT char *strchr(const char *_str, int character)
{
const unsigned char* str = (const unsigned char*)_str;
for(;*str;str++)
do
{
if( *str == character )
return (char*)str;
}
} while( *str++ );
return NULL;
}
......@@ -203,11 +204,12 @@ EXPORT char *strchr(const char *_str, int character)
EXPORT char *strrchr(const char *_str, int character)
{
const unsigned char* str = (const unsigned char*)_str;
for( size_t i = strlen(_str); i--; )
size_t i = strlen(_str);
do
{
if(str[i] == character)
return (void*)&str[i];
}
} while( i -- );
return NULL;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment