[hackers] [scc] [libc] Add strncmp || Quentin Rameau
commit 714865e3490220bae41784c95e0c99c9fcff11d7
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Tue Feb 21 17:48:50 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Tue Feb 21 19:41:25 2017 +0100
[libc] Add strncmp
diff --git a/libc/src/Makefile b/libc/src/Makefile
index 4423a90..82f02e7 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
_AT_@ -2,7 +2,7 @@
.POSIX:
LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
- strrchr.o strcat.o strncpy.o strncat.o strcoll.o \
+ strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \
strxfrm.o strtok.o \
memset.o memcpy.o memmove.o memcmp.o memchr.o \
isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
diff --git a/libc/src/strncmp.c b/libc/src/strncmp.c
new file mode 100644
index 0000000..42e857b
--- /dev/null
+++ b/libc/src/strncmp.c
_AT_@ -0,0 +1,11 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+int
+strncmp(const char *s1, const char *s2, size_t n)
+{
+ for (; n && *s1 && *s2 && *s1 != *s2; --n, ++s1, ++s2);
+ /* nothing */;
+ return n ? (*(unsigned char *)s1 - *(unsigned char *)s2) : 0;
+}
Received on Tue Feb 21 2017 - 19:42:00 CET
This archive was generated by hypermail 2.3.0
: Tue Feb 21 2017 - 19:48:39 CET