mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-29 13:03:38 +01:00
string: add and test strspn and strcspn (DONE)
This commit is contained in:
parent
8368ba70fd
commit
cda27ac2db
5 changed files with 23 additions and 5 deletions
|
@ -140,6 +140,7 @@ set(SOURCES
|
||||||
src/libc/string/strchrnul.c
|
src/libc/string/strchrnul.c
|
||||||
src/libc/string/strcmp.c
|
src/libc/string/strcmp.c
|
||||||
src/libc/string/strcpy.c
|
src/libc/string/strcpy.c
|
||||||
|
src/libc/string/strcspn.c
|
||||||
src/libc/string/strdup.c
|
src/libc/string/strdup.c
|
||||||
src/libc/string/strerror.c
|
src/libc/string/strerror.c
|
||||||
src/libc/string/strlen.c
|
src/libc/string/strlen.c
|
||||||
|
@ -148,7 +149,8 @@ set(SOURCES
|
||||||
src/libc/string/strncpy.c
|
src/libc/string/strncpy.c
|
||||||
src/libc/string/strndup.c
|
src/libc/string/strndup.c
|
||||||
src/libc/string/strnlen.c
|
src/libc/string/strnlen.c
|
||||||
src/libc/string/strrchr.c)
|
src/libc/string/strrchr.c
|
||||||
|
src/libc/string/strspn.c)
|
||||||
|
|
||||||
if(vhex-generic IN_LIST TARGET_FOLDERS)
|
if(vhex-generic IN_LIST TARGET_FOLDERS)
|
||||||
# TODO
|
# TODO
|
||||||
|
|
4
STATUS
4
STATUS
|
@ -122,10 +122,10 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested
|
||||||
! 7.21.4.5 strxfrm: TODO
|
! 7.21.4.5 strxfrm: TODO
|
||||||
7.21.5.1 memchr: DONE
|
7.21.5.1 memchr: DONE
|
||||||
7.21.5.2 strchr: DONE
|
7.21.5.2 strchr: DONE
|
||||||
! 7.21.5.3 strcspn: TODO
|
7.21.5.3 strcspn: DONE
|
||||||
! 7.21.5.4 strpbrk: TODO
|
! 7.21.5.4 strpbrk: TODO
|
||||||
7.21.5.5 strrchr: DONE
|
7.21.5.5 strrchr: DONE
|
||||||
! 7.21.5.6 strspn: TODO
|
7.21.5.6 strspn: DONE
|
||||||
! 7.21.5.7 strstr: TODO
|
! 7.21.5.7 strstr: TODO
|
||||||
! 7.21.5.8 strtok: TODO
|
! 7.21.5.8 strtok: TODO
|
||||||
7.21.6.1 memset: DONE
|
7.21.6.1 memset: DONE
|
||||||
|
|
|
@ -54,7 +54,7 @@ extern void *memchr(void const *__s, int __c, size_t __n);
|
||||||
extern char *strchr(char const *__s, int __c);
|
extern char *strchr(char const *__s, int __c);
|
||||||
|
|
||||||
/* Count initial characters of __s that are not in __exclude. */
|
/* Count initial characters of __s that are not in __exclude. */
|
||||||
extern char *strcspn(char const *__s, char const *__exclude);
|
extern size_t strcspn(char const *__s, char const *__exclude);
|
||||||
|
|
||||||
/* Find the first character of __s that is also in __include. */
|
/* Find the first character of __s that is also in __include. */
|
||||||
extern char *strpbrk(char const *__s, char const *__include);
|
extern char *strpbrk(char const *__s, char const *__include);
|
||||||
|
@ -63,7 +63,7 @@ extern char *strpbrk(char const *__s, char const *__include);
|
||||||
extern char *strrchr(char const *__s, int __c);
|
extern char *strrchr(char const *__s, int __c);
|
||||||
|
|
||||||
/* Count initial characters of __s that are in __include. */
|
/* Count initial characters of __s that are in __include. */
|
||||||
extern char *strspn(char const *__s, char const *__include);
|
extern size_t strspn(char const *__s, char const *__include);
|
||||||
|
|
||||||
/* Find the first occurrence of __s2 as a substring of __s1. */
|
/* Find the first occurrence of __s2 as a substring of __s1. */
|
||||||
extern char *strstr(char const *__s1, char const *__s2);
|
extern char *strstr(char const *__s1, char const *__s2);
|
||||||
|
|
8
src/libc/string/strcspn.c
Normal file
8
src/libc/string/strcspn.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
size_t strcspn(char const *s, char const *reject)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
while(s[i] && !strchr(reject, s[i])) i++;
|
||||||
|
return i;
|
||||||
|
}
|
8
src/libc/string/strspn.c
Normal file
8
src/libc/string/strspn.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
size_t strspn(char const *s, char const *accept)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
while(s[i] && strchr(accept, s[i])) i++;
|
||||||
|
return i;
|
||||||
|
}
|
Loading…
Reference in a new issue