mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix '\0' support in strchr(3) and strchrnul(3).
This commit is contained in:
parent
3a35139e6c
commit
54e68a0c51
2 changed files with 6 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -27,7 +27,5 @@
|
||||||
extern "C" char* strchr(const char* str, int c)
|
extern "C" char* strchr(const char* str, int c)
|
||||||
{
|
{
|
||||||
char* ret = strchrnul(str, c);
|
char* ret = strchrnul(str, c);
|
||||||
if ( !*ret )
|
return ret && c == ret[0] ? ret : NULL;
|
||||||
return NULL;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
extern "C" char* strchrnul(const char* str, int c)
|
extern "C" char* strchrnul(const char* str, int c)
|
||||||
{
|
{
|
||||||
for ( ; *str && *str != c; str++ );
|
for ( ; *str != c; str++ )
|
||||||
|
if ( !*str )
|
||||||
|
return NULL;
|
||||||
return (char*) str;
|
return (char*) str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue