shithub: scc

Download patch

ref: c614e5f509f49a792a2e586fea167032ef57928f
parent: 1b6737c3ab2088041262077fadae13079b89fa88
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Apr 28 04:26:30 EDT 2020

libc: Remove strnlen()

Strlen() is a POSIX function and it is not defined in C99.

--- a/include/string.h
+++ b/include/string.h
@@ -29,6 +29,5 @@
 extern void *memset(void *s, int c, size_t n);
 extern char *strerror(int errnum);
 extern size_t strlen(const char *s);
-extern size_t strnlen(const char *s, size_t maxlen);
 
 #endif
--- a/src/libc/string/Makefile
+++ b/src/libc/string/Makefile
@@ -15,7 +15,6 @@
 	strncat.$O\
 	strncmp.$O\
 	strncpy.$O\
-	strnlen.$O\
 	strpbrk.$O\
 	strrchr.$O\
 	strspn.$O\
--- a/src/libc/string/strnlen.c
+++ /dev/null
@@ -1,13 +1,0 @@
-#include <string.h>
-
-#undef strnlen
-
-size_t
-strnlen(const char *s, size_t maxlen)
-{
-	size_t n;
-
-	for (n = 0; n < maxlen && *s++; ++n)
-		;
-	return n;
-}