mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
ape: add strnlen
This commit is contained in:
parent
3b376b43af
commit
55c122d59f
4 changed files with 13 additions and 1 deletions
|
@ -32,6 +32,7 @@ extern char *strtok(char *, const char *);
|
|||
extern void *memset(void *, int, size_t);
|
||||
extern char *strerror(int);
|
||||
extern size_t strlen(const char *);
|
||||
extern size_t strnlen(const char *, size_t);
|
||||
|
||||
#ifdef _REENTRANT_SOURCE
|
||||
extern char *strerror_r(int, const char *, int);
|
||||
|
|
|
@ -43,6 +43,7 @@ ALLOFILES=\
|
|||
strncat.$O\
|
||||
strncmp.$O\
|
||||
strncpy.$O\
|
||||
strnlen.$O\
|
||||
strpbrk.$O\
|
||||
strrchr.$O\
|
||||
strspn.$O\
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
size_t
|
||||
strlen(const char *s)
|
||||
{
|
||||
|
||||
return strchr(s, 0) - s;
|
||||
}
|
||||
|
|
11
sys/src/ape/lib/ap/gen/strnlen.c
Normal file
11
sys/src/ape/lib/ap/gen/strnlen.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <string.h>
|
||||
|
||||
size_t
|
||||
strnlen(const char *s, size_t maxlen)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < maxlen && s[i] != '\0'; i++)
|
||||
;
|
||||
return i;
|
||||
}
|
Loading…
Reference in a new issue