mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2025-04-20 01:47:12 +02:00
string: add and test strtok (DONE)
This commit is contained in:
parent
3a9a60db78
commit
1e7e2c656b
3 changed files with 20 additions and 1 deletions
|
@ -158,6 +158,7 @@ set(SOURCES
|
||||||
src/libc/string/strspn.c
|
src/libc/string/strspn.c
|
||||||
src/libc/string/strstr.c
|
src/libc/string/strstr.c
|
||||||
src/libc/string/strstr_base.c
|
src/libc/string/strstr_base.c
|
||||||
|
src/libc/string/strtok.c
|
||||||
src/libc/string/strxfrm.c)
|
src/libc/string/strxfrm.c)
|
||||||
|
|
||||||
if(vhex-generic IN_LIST TARGET_FOLDERS)
|
if(vhex-generic IN_LIST TARGET_FOLDERS)
|
||||||
|
|
2
STATUS
2
STATUS
|
@ -127,7 +127,7 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested
|
||||||
7.21.5.5 strrchr: DONE
|
7.21.5.5 strrchr: DONE
|
||||||
7.21.5.6 strspn: DONE
|
7.21.5.6 strspn: DONE
|
||||||
7.21.5.7 strstr: DONE
|
7.21.5.7 strstr: DONE
|
||||||
! 7.21.5.8 strtok: TODO
|
7.21.5.8 strtok: DONE
|
||||||
7.21.6.1 memset: DONE
|
7.21.6.1 memset: DONE
|
||||||
7.21.6.2 strerror: DONE
|
7.21.6.2 strerror: DONE
|
||||||
7.21.6.3 strlen: DONE
|
7.21.6.3 strlen: DONE
|
||||||
|
|
18
src/libc/string/strtok.c
Normal file
18
src/libc/string/strtok.c
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
char *strtok(char * restrict new_s, char const * restrict separators)
|
||||||
|
{
|
||||||
|
static char *s = NULL;
|
||||||
|
if(new_s) s = new_s;
|
||||||
|
|
||||||
|
/* Skip leading delimiters */
|
||||||
|
s += strspn(s, separators);
|
||||||
|
if(!*s) return NULL;
|
||||||
|
|
||||||
|
/* Skip non-delimiters */
|
||||||
|
char *token = s;
|
||||||
|
s += strcspn(s, separators);
|
||||||
|
*s++ = 0;
|
||||||
|
|
||||||
|
return token;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue