From a82e91b7dbb30ccd45e280a8ec922b5efbf26d14 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 18 Feb 2008 15:58:01 -0800 Subject: [PATCH] Actually implement strnlen() Actually implement strnlen(), which was in the header files but not in the library. --- com32/lib/Makefile | 1 + com32/lib/strnlen.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 com32/lib/strnlen.c diff --git a/com32/lib/Makefile b/com32/lib/Makefile index def1729..d8fb30d 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -12,6 +12,7 @@ LIBOBJS = \ perror.o printf.o puts.o qsort.o realloc.o seed48.o snprintf.o \ sprintf.o srand48.o sscanf.o stack.o strcasecmp.o strcat.o \ strchr.o strcmp.o strcpy.o strdup.o strerror.o strlen.o \ + strnlen.o \ strncasecmp.o strncat.o strncmp.o strncpy.o stpncpy.o strndup.o \ strntoimax.o strntoumax.o strrchr.o strsep.o strspn.o strstr.o \ strtoimax.o strtok.o strtol.o strtoll.o strtoul.o strtoull.o \ diff --git a/com32/lib/strnlen.c b/com32/lib/strnlen.c new file mode 100644 index 0000000..d073561 --- /dev/null +++ b/com32/lib/strnlen.c @@ -0,0 +1,13 @@ +/* + * strnlen() + */ + +#include + +size_t strnlen(const char *s, size_t n) +{ + const char *ss = s; + while ( n-- && *ss ) + ss++; + return ss-s; +} -- 2.7.4