commit 830384d068b500a18a6aeb7a5a45e70bfad72d51
Author: Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Thu Feb 16 21:05:39 2017 +0100
Commit: Roberto E. Vargas Caballero <[email protected]>
CommitDate: Thu Feb 16 21:05:39 2017 +0100
[libc] Add strcmp()
diff --git a/libc/src/Makefile b/libc/src/Makefile
index fc94ea8..125f3e3 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
@@ -1,7 +1,7 @@
# See LICENSE file for copyright and license details.
.POSIX:
-LIBCOBJ = assert.o strcpy.o
+LIBCOBJ = assert.o strcpy.o strcmp.o
libc.a: $(LIBCOJB)
ar $(ARFLAGS) $@ $?
diff --git a/libc/src/strcmp.c b/libc/src/strcmp.c
new file mode 100644
index 0000000..56ab3a4
--- /dev/null
+++ b/libc/src/strcmp.c
@@ -0,0 +1,11 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+int
+strcmp(const char *s1, const char *s2)
+{
+ while (*s1 && *s2 && *s1 != *s2)
+ ++s1, ++s2;
+ return *s1 - *s2;
+}